Skip to content

Free Motion Capture for Everyone πŸ’€βœ¨

TypeScript

add custom exception

Jonb4a279edc43a
diff --git a/src/cameras/capture/opencv_camera/opencv_camera.py b/src/cameras/capture/opencv_camera/opencv_camera.py
index e2e038c6..0667a66a 100644
--- a/src/cameras/capture/opencv_camera/opencv_camera.py
+++ b/src/cameras/capture/opencv_camera/opencv_camera.py
@@ -11,7 +11,6 @@ from pydantic import BaseModel
from src.cameras.capture.frame_payload import FramePayload
from src.cameras.capture.opencv_camera.frame_grabber import FrameThread
-from src.core_processor.camera_calibration.lens_distortion_calibrator import LensDistortionCalibrationData
logger = logging.getLogger(__name__)
@@ -31,6 +30,10 @@ class WebcamConfig(BaseModel):
base_save_video_dir = _get_home_dir()
+class OpenCVCameraError(Exception):
+ pass
+
+
class OpenCVCamera:
"""
Performant implementation of video capture against webcams
@@ -120,15 +123,16 @@ class OpenCVCamera:
def image_width(self):
try:
return int(self._opencv_video_capture_object.get(3))
- except:
- return None
+ except OpenCVCameraError:
+ raise OpenCVCameraError("failed to return `image_width` property from OpenCVCamera")
+
@property
def image_height(self):
try:
return int(self._opencv_video_capture_object.get(4))
- except:
- return None
+ except OpenCVCameraError:
+ raise OpenCVCameraError("failed to return `image_height` property from OpenCVCamera")
def _apply_configuration(self):
# set camera stream parameters
diff --git a/src/cameras/detection/cam_detection.py b/src/cameras/detection/cam_detection.py
index aaaab6c7..15fb41b3 100644
--- a/src/cameras/detection/cam_detection.py
+++ b/src/cameras/detection/cam_detection.py
@@ -31,8 +31,7 @@ class DetectPossibleCameras:
cv2_backend=cv2_backend,
)
- @staticmethod
- def _determine_backend():
+ def _determine_backend(self):
if platform.system() == "Windows":
return cv2.CAP_DSHOW
else: