Skip to content

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

TypeScript

comitting current state

Endurance Idehen8437134b07b5
diff --git a/freemocap/prod/cam/cam_detection.py b/freemocap/prod/cam/cam_detection.py
index b5b980b9..9994a54e 100644
--- a/freemocap/prod/cam/cam_detection.py
+++ b/freemocap/prod/cam/cam_detection.py
@@ -10,7 +10,6 @@ logger = logging.getLogger(__name__)
class RawCamera(BaseModel):
- name: str
index: int
@@ -29,17 +28,15 @@ class DetectPossibleCameras:
cap = cv2.VideoCapture(camNum, capBackend)
success, image = cap.read()
if success:
- cams_to_use_list.append(RawCamera(
- index=camNum,
- name='test'
- ))
- cap.release()
- logger.info("I was successful")
- logger.info(cap.get(cv2.CAP_PROP_SETTINGS))
+ try:
+ cams_to_use_list.append(RawCamera(
+ index=camNum,
+ ))
+ logger.info(cap.get(cv2.CAP_PROP_SETTINGS))
+ finally:
+ cap.release()
return FindAvailableResponse(
camera_found_count=len(cams_to_use_list),
cams_to_use=cams_to_use_list
- )
-
-
+ )
\ No newline at end of file
diff --git a/freemocap/prod/cam/opencv_camera.py b/freemocap/prod/cam/opencv_camera.py
index d2b92444..c0cd7807 100644
--- a/freemocap/prod/cam/opencv_camera.py
+++ b/freemocap/prod/cam/opencv_camera.py
@@ -1,6 +1,8 @@
import cv2
from pydantic import BaseModel
+from freemocap.prod.cam.cam_detection import DetectPossibleCameras
+
class OpenCVCameraOptions(BaseModel):
port_number: int
@@ -10,11 +12,13 @@ class OpenCVCameraOptions(BaseModel):
# # OpenCV Implementation of interacting with a camera
-# class OpenCVCamera:
-#
-# def __init__(self, options: OpenCVCameraOptions):
-# self._options = options
-#
-# def connect(self):
-# # c = cv2.VideoCapture()
-# cv2.VideoCapture(, cv2.CAP_ANY)
+class OpenCVCamera:
+
+ def __init__(self, options: OpenCVCameraOptions):
+ self._options = options
+
+ def connect(self):
+ c = DetectPossibleCameras()
+ available_cameras = c.find_available_cameras()
+
+
diff --git a/requirements.txt b/requirements.txt
index 65b021df..eeca4432 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -17,5 +17,6 @@ uvicorn==0.16.0
fastapi==0.71.0
gunicorn==20.1.0
requests==2.27.1
+pyudev==0.22.0
# opencv-python-headless==4.5.5.62
# opencv-python
\ No newline at end of file
diff --git a/src/api/app_factory.py b/src/api/app_factory.py
index bd972cc1..1b1a1e35 100644
--- a/src/api/app_factory.py
+++ b/src/api/app_factory.py
@@ -15,4 +15,4 @@ def create_app():
if __name__ == "__main__":
app = create_app()
- uvicorn.run(app, host="127.0.0.1", port=5000, log_level="info")
+ uvicorn.run(app, host="127.0.0.1", port=8080, log_level="info")
diff --git a/src/api/routes/camera/camera_route.py b/src/api/routes/camera/camera_route.py
index 5d237161..d732d11f 100644
--- a/src/api/routes/camera/camera_route.py
+++ b/src/api/routes/camera/camera_route.py
@@ -9,4 +9,4 @@ camera_router = APIRouter()
@camera_router.get("/camera/detect")
def camera_detect():
dpc = DetectPossibleCameras()
- return dpc.find_available_cameras()
+ return dpc.getSerialNumber()