clean for distribute

This commit is contained in:
unknown
2026-01-14 15:22:31 +08:00
parent 721dccbab4
commit af0b15dc26
+1 -14
View File
@@ -160,13 +160,10 @@ class Sensor:
Returns: Returns:
np.ndarray: Processed grayscale image np.ndarray: Processed grayscale image
""" """
t0 = time.perf_counter()
ret, frame = self.cap.read() ret, frame = self.cap.read()
if not ret: if not ret:
print("Failed to get_img from video source.") print("Failed to get_img from video source.")
return None return None
t1 = time.perf_counter()
print(f"read frame time: {t1 - t0} seconds")
# Convert to grayscale # Convert to grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
@@ -414,18 +411,8 @@ class Sensor:
def _open_video_source(self, override, box): def _open_video_source(self, override, box):
"""Initialize video capture and calibration.""" """Initialize video capture and calibration."""
# Use DirectShow backend on Windows for cameras (more stable than MSMF)
if isinstance(self.vid_src, int):
# For camera indices, try DirectShow first (avoids MSMF errors)
try:
self.cap = cv2.VideoCapture(self.vid_src, cv2.CAP_DSHOW)
except:
# Fallback to default backend
self.cap = cv2.VideoCapture(self.vid_src)
else:
# For file paths, use default backend
self.cap = cv2.VideoCapture(self.vid_src)
self.cap = cv2.VideoCapture(self.vid_src)
# Set buffer size to 1 to reduce latency and avoid frame accumulation # Set buffer size to 1 to reduce latency and avoid frame accumulation
self.cap.set(cv2.CAP_PROP_BUFFERSIZE, 1) self.cap.set(cv2.CAP_PROP_BUFFERSIZE, 1)
self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('M', 'J', 'P', 'G')) self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('M', 'J', 'P', 'G'))