|
|
|
@ -107,8 +107,9 @@ class ThreadedWebcam: |
|
|
|
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height) |
|
|
|
# Minimize internal buffer so we always get the latest frame |
|
|
|
self.cap.set(cv2.CAP_PROP_BUFFERSIZE, 1) |
|
|
|
self.actual_w = int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH)) |
|
|
|
self.actual_h = int(self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) |
|
|
|
# After CCW 90° rotation, width and height are swapped |
|
|
|
self.actual_w = int(self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) |
|
|
|
self.actual_h = int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH)) |
|
|
|
self._frame = None |
|
|
|
self._lock = threading.Lock() |
|
|
|
self._stop = threading.Event() |
|
|
|
@ -116,9 +117,11 @@ class ThreadedWebcam: |
|
|
|
self._thread.start() |
|
|
|
|
|
|
|
def _capture_loop(self): |
|
|
|
import cv2 |
|
|
|
while not self._stop.is_set(): |
|
|
|
ret, frame = self.cap.read() |
|
|
|
if ret: |
|
|
|
frame = cv2.rotate(frame, cv2.ROTATE_90_COUNTERCLOCKWISE) |
|
|
|
with self._lock: |
|
|
|
self._frame = frame |
|
|
|
|
|
|
|
|