From 6aaf291c42b9836d4c77c8b6541c34a416ee8ded Mon Sep 17 00:00:00 2001 From: Don Restarone <35935196+donrestarone@users.noreply.github.com> Date: Sat, 8 Feb 2025 13:59:18 -0500 Subject: [PATCH 1/3] Update vilib.py return picamera reference so that additional configurations can be made (eg; set exposure, autofocus etc) --- vilib/vilib.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vilib/vilib.py b/vilib/vilib.py index a36c592..8a74035 100644 --- a/vilib/vilib.py +++ b/vilib/vilib.py @@ -38,6 +38,9 @@ # print(f"user: {user}") # print(f"user_home: {user_home}") +# init picamera2 reference +pi_camera_2 = None + # Default path for pictures and videos DEFAULLT_PICTURES_PATH = '%s/Pictures/vilib/'%user_home DEFAULLT_VIDEOS_PATH = '%s/Videos/vilib/'%user_home @@ -226,14 +229,23 @@ class Vilib(object): qrcode_detect_sw = False traffic_detect_sw = False + def get_instance(): + global pi_camera_2 + return pi_camera_2 + + @staticmethod def camera(): + global pi_camera_2 Vilib.camera_width = Vilib.camera_size[0] Vilib.camera_height = Vilib.camera_size[1] # init picamera picam2 = Picamera2() + # set global reference + pi_camera_2 = picam2 + preview_config = picam2.preview_configuration # preview_config.size = (800, 600) preview_config.size = Vilib.camera_size From 52e1d627839348ff0efeb229a177836220300bdd Mon Sep 17 00:00:00 2001 From: Don Restarone <35935196+donrestarone@users.noreply.github.com> Date: Sat, 8 Feb 2025 14:24:20 -0500 Subject: [PATCH 2/3] Update vilib.py set static member to fix 'AttributeError: type object 'Vilib' has no attribute 'get_instance'' --- vilib/vilib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vilib/vilib.py b/vilib/vilib.py index 8a74035..aaf4ce0 100644 --- a/vilib/vilib.py +++ b/vilib/vilib.py @@ -228,7 +228,8 @@ class Vilib(object): objects_detection_labels = None qrcode_detect_sw = False traffic_detect_sw = False - + + @staticmethod def get_instance(): global pi_camera_2 return pi_camera_2 From 7b8ade18186f79639bd7c466b1ec7a6c0d74ad84 Mon Sep 17 00:00:00 2001 From: Don Restarone <35935196+donrestarone@users.noreply.github.com> Date: Sat, 8 Feb 2025 19:46:50 +0000 Subject: [PATCH 3/3] bump version --- vilib/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vilib/version.py b/vilib/version.py index df0ed33..8a3be2e 100644 --- a/vilib/version.py +++ b/vilib/version.py @@ -1 +1 @@ -__version__ = "0.3.12" +__version__ = "0.3.13"