Skip to content

Commit 8343461

Browse files
committed
fix: API
1 parent 38edf1e commit 8343461

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/arduino/app_bricks/camera_code_detection/detection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import numpy as np
1111
from PIL.Image import Image, fromarray
1212

13-
from arduino.app_peripherals.camera import Camera
13+
from arduino.app_peripherals.camera import Camera, BaseCamera
1414
from arduino.app_utils.image import greyscale
1515
from arduino.app_utils import brick, Logger
1616

@@ -44,7 +44,7 @@ class CameraCodeDetection:
4444
"""Scans a camera video feed for QR codes and/or barcodes.
4545
4646
Args:
47-
camera (Camera): The camera instance to use for capturing video. If None, a default camera will be initialized.
47+
camera (BaseCamera): The camera instance to use for capturing video. If None, a default camera will be initialized.
4848
detect_qr (bool): Whether to detect QR codes. Defaults to True.
4949
detect_barcode (bool): Whether to detect barcodes. Defaults to True.
5050
@@ -55,13 +55,15 @@ class CameraCodeDetection:
5555

5656
def __init__(
5757
self,
58-
camera: Camera = None,
58+
camera: BaseCamera = None,
5959
detect_qr: bool = True,
6060
detect_barcode: bool = True,
6161
):
6262
"""Initialize the CameraCodeDetection brick."""
6363
if detect_qr is False and detect_barcode is False:
6464
raise ValueError("At least one of 'detect_qr' or 'detect_barcode' must be True.")
65+
66+
self._camera = camera if camera else Camera()
6567

6668
self._detect_qr = detect_qr
6769
self._detect_barcode = detect_barcode
@@ -76,8 +78,6 @@ def __init__(
7678

7779
self.already_seen_codes = set()
7880

79-
self._camera = camera if camera else Camera()
80-
8181
def start(self):
8282
"""Start the detector and begin scanning for codes."""
8383
self._camera.start()

src/arduino/app_bricks/video_imageclassification/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from websockets.sync.client import connect, ClientConnection
1313
from websockets.exceptions import ConnectionClosedOK, ConnectionClosedError
1414

15-
from arduino.app_peripherals.camera import Camera
15+
from arduino.app_peripherals.camera import Camera, BaseCamera
1616
from arduino.app_internal.core import load_brick_compose_file, resolve_address
1717
from arduino.app_internal.core import EdgeImpulseRunnerFacade
1818
from arduino.app_utils.image import compress_to_jpeg
@@ -30,11 +30,11 @@ class VideoImageClassification:
3030

3131
ALL_HANDLERS_KEY = "__ALL"
3232

33-
def __init__(self, camera: Camera = None, confidence: float = 0.3, debounce_sec: float = 0.0):
33+
def __init__(self, camera: BaseCamera = None, confidence: float = 0.3, debounce_sec: float = 0.0):
3434
"""Initialize the VideoImageClassification class.
3535
3636
Args:
37-
camera (Camera): The camera instance to use for capturing video. If None, a default camera will be initialized.
37+
camera (BaseCamera): The camera instance to use for capturing video. If None, a default camera will be initialized.
3838
confidence (float): The minimum confidence level for a classification to be considered valid. Default is 0.3.
3939
debounce_sec (float): The minimum time in seconds between consecutive detections of the same object
4040
to avoid multiple triggers. Default is 0 seconds.

src/arduino/app_bricks/video_objectdetection/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from websockets.sync.client import connect, ClientConnection
1313
from websockets.exceptions import ConnectionClosedOK, ConnectionClosedError
1414

15-
from arduino.app_peripherals.camera import Camera
15+
from arduino.app_peripherals.camera import Camera, BaseCamera
1616
from arduino.app_internal.core import load_brick_compose_file, resolve_address
1717
from arduino.app_internal.core import EdgeImpulseRunnerFacade
1818
from arduino.app_utils.image.adjustments import compress_to_jpeg
@@ -35,11 +35,11 @@ class VideoObjectDetection:
3535

3636
ALL_HANDLERS_KEY = "__ALL"
3737

38-
def __init__(self, camera: Camera = None, confidence: float = 0.3, debounce_sec: float = 0.0):
38+
def __init__(self, camera: BaseCamera = None, confidence: float = 0.3, debounce_sec: float = 0.0):
3939
"""Initialize the VideoObjectDetection class.
4040
4141
Args:
42-
camera (Camera): The camera instance to use for capturing video. If None, a default camera will be initialized.
42+
camera (BaseCamera): The camera instance to use for capturing video. If None, a default camera will be initialized.
4343
confidence (float): Confidence level for detection. Default is 0.3 (30%).
4444
debounce_sec (float): Minimum seconds between repeated detections of the same object. Default is 0 seconds.
4545

0 commit comments

Comments
 (0)