Skip to content

Commit 115a769

Browse files
authored
Update capture_thread.py
Modify the image format setting before setting the resolution. If it is set after the resolution, it will not work.
1 parent 3752d1d commit 115a769

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

surround_view/capture_thread.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ def connect_camera(self):
8686
# try to set camera resolution
8787
if self.resolution is not None:
8888
width, height = self.resolution
89+
self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*"MJPG"))
8990
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
9091
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
91-
self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*"MJPG"))
9292
# some camera may become closed if the resolution is not supported
9393
if not self.cap.isOpened():
9494
qDebug("Resolution not supported by camera device: {}".format(self.resolution))
9595
return False
9696
# use the default resolution
9797
else:
98+
self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*"MJPG"))
9899
width = int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH))
99100
height = int(self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
100-
self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*"MJPG"))
101101
self.resolution = (width, height)
102102

103103
return True

0 commit comments

Comments
 (0)