mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 19:33:45 +08:00
webcam: changes for comma zero (#35464)
* Revert "webcam: remove other cv2 usage (#33236)" This reverts commit0cade54015. * Revert "remove cv2 usage (#33101)" This reverts commit144e9e271c. * Revert "remove opencv-python-headless (#33082)" This reverts commit488e08507a. * webcam: set width, height, fps; flip image; use av reformat * 1280x720 @ 25fps
This commit is contained in:
@@ -11,7 +11,14 @@ class Camera:
|
||||
self.stream_type = stream_type
|
||||
self.cur_frame_id = 0
|
||||
|
||||
print(f"Opening {cam_type_state} at {camera_id}")
|
||||
|
||||
self.cap = cv.VideoCapture(camera_id)
|
||||
|
||||
self.cap.set(cv.CAP_PROP_FRAME_WIDTH, 1280.0)
|
||||
self.cap.set(cv.CAP_PROP_FRAME_HEIGHT, 720.0)
|
||||
self.cap.set(cv.CAP_PROP_FPS, 25.0)
|
||||
|
||||
self.W = self.cap.get(cv.CAP_PROP_FRAME_WIDTH)
|
||||
self.H = self.cap.get(cv.CAP_PROP_FRAME_HEIGHT)
|
||||
|
||||
@@ -25,6 +32,8 @@ class Camera:
|
||||
ret, frame = self.cap.read()
|
||||
if not ret:
|
||||
break
|
||||
# Rotate the frame 180 degrees (flip both axes)
|
||||
frame = cv.flip(frame, -1)
|
||||
yuv = Camera.bgr2nv12(frame)
|
||||
yield yuv.data.tobytes()
|
||||
self.cap.release()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import threading
|
||||
import os
|
||||
import platform
|
||||
from collections import namedtuple
|
||||
|
||||
from msgq.visionipc import VisionIpcServer, VisionStreamType
|
||||
@@ -30,8 +31,7 @@ class Camerad:
|
||||
|
||||
self.cameras = []
|
||||
for c in CAMERAS:
|
||||
cam_device = f"/dev/video{c.cam_id}"
|
||||
print(f"opening {c.msg_name} at {cam_device}")
|
||||
cam_device = f"/dev/video{c.cam_id}" if platform.system() != "Darwin" else c.cam_id
|
||||
cam = Camera(c.msg_name, c.stream_type, cam_device)
|
||||
self.cameras.append(cam)
|
||||
self.vipc_server.create_buffers(c.stream_type, 20, cam.W, cam.H)
|
||||
|
||||
Reference in New Issue
Block a user