fix: camera flip
This commit is contained in:
+6
-15
@@ -66,6 +66,12 @@ class CameraManager:
|
||||
with self._camera_lock:
|
||||
if self._camera is None:
|
||||
self._camera = camera.Camera(width, height)
|
||||
v_flip = getattr(config, 'CAMERA_V_FLIP', False)
|
||||
h_mirror = getattr(config, 'CAMERA_H_MIRROR', False)
|
||||
if v_flip:
|
||||
self._camera.vflip(1)
|
||||
if h_mirror:
|
||||
self._camera.hmirror(1)
|
||||
|
||||
return self._camera
|
||||
|
||||
@@ -111,21 +117,6 @@ class CameraManager:
|
||||
if self._camera is None:
|
||||
self.init_camera()
|
||||
frame = self._camera.read()
|
||||
if frame is not None and _USE_CV:
|
||||
try:
|
||||
v_flip = getattr(config, 'CAMERA_V_FLIP', False)
|
||||
h_mirror = getattr(config, 'CAMERA_H_MIRROR', False)
|
||||
if v_flip or h_mirror:
|
||||
img_cv = _maix_image.image2cv(frame, False, False)
|
||||
if v_flip and h_mirror:
|
||||
img_cv = cv2.flip(img_cv, -1)
|
||||
elif v_flip:
|
||||
img_cv = cv2.flip(img_cv, 0)
|
||||
elif h_mirror:
|
||||
img_cv = cv2.flip(img_cv, 1)
|
||||
frame = _maix_image.cv2image(img_cv, False, False)
|
||||
except Exception:
|
||||
pass
|
||||
return frame
|
||||
|
||||
def show(self, image):
|
||||
|
||||
Reference in New Issue
Block a user