- Port to Python3, wxPhoenix and OpenCV4, add patches: + 0001-Fix-print-and-exception-syntax-for-Python-3-compat.patch + 0002-Update-deprecated-imports-xrange-unicode-to-Python3.patch + 0003-Update-wxPython-syntax.patch + 0004-OpenCV4-support.patch OBS-URL: https://build.opensuse.org/request/show/956144 OBS-URL: https://build.opensuse.org/package/show/science/horus?expand=0&rev=13
117 lines
5.2 KiB
Diff
117 lines
5.2 KiB
Diff
From b03444ff6be3c7c16d1e14d724914ef23ffc688f Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
|
|
Date: Sun, 20 Feb 2022 07:46:21 +0100
|
|
Subject: [PATCH 4/4] OpenCV4 support
|
|
|
|
---
|
|
src/horus/engine/driver/camera.py | 29 +++++++++++++++--------------
|
|
1 file changed, 15 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/src/horus/engine/driver/camera.py b/src/horus/engine/driver/camera.py
|
|
index ca937c1..e7a3fda 100644
|
|
--- a/src/horus/engine/driver/camera.py
|
|
+++ b/src/horus/engine/driver/camera.py
|
|
@@ -166,7 +166,8 @@ class Camera(object):
|
|
brightness = self.get_brightness()
|
|
if brightness is not None:
|
|
c_bri = brightness >= 2
|
|
- except:
|
|
+ except Exception as e:
|
|
+ logger.error(repr(e))
|
|
raise WrongCamera()
|
|
|
|
if not c_exp or not c_bri:
|
|
@@ -242,7 +243,7 @@ class Camera(object):
|
|
ctl.set_val(self._line(value, 0, self._max_brightness, ctl.min, ctl.max))
|
|
else:
|
|
value = int(value) / self._max_brightness
|
|
- ret = self._capture.set(cv2.cv.CV_CAP_PROP_BRIGHTNESS, value)
|
|
+ ret = self._capture.set(cv2.CAP_PROP_BRIGHTNESS, value)
|
|
if system == 'Linux' and ret:
|
|
raise InputOutputError()
|
|
self._updating = False
|
|
@@ -257,7 +258,7 @@ class Camera(object):
|
|
ctl.set_val(self._line(value, 0, self._max_contrast, ctl.min, ctl.max))
|
|
else:
|
|
value = int(value) / self._max_contrast
|
|
- ret = self._capture.set(cv2.cv.CV_CAP_PROP_CONTRAST, value)
|
|
+ ret = self._capture.set(cv2.CAP_PROP_CONTRAST, value)
|
|
if system == 'Linux' and ret:
|
|
raise InputOutputError()
|
|
self._updating = False
|
|
@@ -272,7 +273,7 @@ class Camera(object):
|
|
ctl.set_val(self._line(value, 0, self._max_saturation, ctl.min, ctl.max))
|
|
else:
|
|
value = int(value) / self._max_saturation
|
|
- ret = self._capture.set(cv2.cv.CV_CAP_PROP_SATURATION, value)
|
|
+ ret = self._capture.set(cv2.CAP_PROP_SATURATION, value)
|
|
if system == 'Linux' and ret:
|
|
raise InputOutputError()
|
|
self._updating = False
|
|
@@ -291,10 +292,10 @@ class Camera(object):
|
|
ctl.set_val(value)
|
|
elif system == 'Windows':
|
|
value = int(round(-math.log(value) / math.log(2)))
|
|
- self._capture.set(cv2.cv.CV_CAP_PROP_EXPOSURE, value)
|
|
+ self._capture.set(cv2.CAP_PROP_EXPOSURE, value)
|
|
else:
|
|
value = int(value) / self._max_exposure
|
|
- ret = self._capture.set(cv2.cv.CV_CAP_PROP_EXPOSURE, value)
|
|
+ ret = self._capture.set(cv2.CAP_PROP_EXPOSURE, value)
|
|
if system == 'Linux' and ret:
|
|
raise InputOutputError()
|
|
self._updating = False
|
|
@@ -313,7 +314,7 @@ class Camera(object):
|
|
if self._frame_rate != value:
|
|
self._frame_rate = value
|
|
self._updating = True
|
|
- self._capture.set(cv2.cv.CV_CAP_PROP_FPS, value)
|
|
+ self._capture.set(cv2.CAP_PROP_FPS, value)
|
|
self._updating = False
|
|
|
|
def set_resolution(self, width, height):
|
|
@@ -326,14 +327,14 @@ class Camera(object):
|
|
self._updating = False
|
|
|
|
def _set_width(self, value):
|
|
- self._capture.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, value)
|
|
+ self._capture.set(cv2.CAP_PROP_FRAME_WIDTH, value)
|
|
|
|
def _set_height(self, value):
|
|
- self._capture.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, value)
|
|
+ self._capture.set(cv2.CAP_PROP_FRAME_HEIGHT, value)
|
|
|
|
def _update_resolution(self):
|
|
- self._width = int(self._capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH))
|
|
- self._height = int(self._capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT))
|
|
+ self._width = int(self._capture.get(cv2.CAP_PROP_FRAME_WIDTH))
|
|
+ self._height = int(self._capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
|
|
def get_brightness(self):
|
|
if self._is_connected:
|
|
@@ -341,7 +342,7 @@ class Camera(object):
|
|
ctl = self.controls['UVCC_REQ_BRIGHTNESS_ABS']
|
|
value = ctl.get_val()
|
|
else:
|
|
- value = self._capture.get(cv2.cv.CV_CAP_PROP_BRIGHTNESS)
|
|
+ value = self._capture.get(cv2.CAP_PROP_BRIGHTNESS)
|
|
value *= self._max_brightness
|
|
return value
|
|
|
|
@@ -352,10 +353,10 @@ class Camera(object):
|
|
value = ctl.get_val()
|
|
value /= self._rel_exposure
|
|
elif system == 'Windows':
|
|
- value = self._capture.get(cv2.cv.CV_CAP_PROP_EXPOSURE)
|
|
+ value = self._capture.get(cv2.CAP_PROP_EXPOSURE)
|
|
value = 2 ** -value
|
|
else:
|
|
- value = self._capture.get(cv2.cv.CV_CAP_PROP_EXPOSURE)
|
|
+ value = self._capture.get(cv2.CAP_PROP_EXPOSURE)
|
|
value *= self._max_exposure
|
|
return value
|
|
|
|
--
|
|
2.35.1
|
|
|