Skip to content

Commit f0f68f6

Browse files
committed
Add configuration for calibration
1 parent 2034c9c commit f0f68f6

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

cpopservice/capture_loop.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def run_capture_loop(capture, object_detector: ObjectDetector, result_queue):
2929
'Timestamp': timestamp,
3030
'Type': label,
3131
'Position': {'X': float(position[0]), 'Y': float(position[1]), 'Z': float(position[2])},
32-
'Shape': [{'X': width, 'Y': height, 'Z': 0.0}]
32+
'Shape': [{'X': width, 'Y': 0.0, 'Z': height}]
3333
}
3434

3535
LOG.debug('queueing message %s', message)

cpopservice/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
BROKER_STARTUP = os.environ.get('BROKER_STARTUP') not in ['false', '0', False]
1010

1111
# camera device
12+
CALIBRATE_FRAME = 'data/calib-and-test/frame_1920x1080.jpg'
1213
CAMERA_WIDTH = 1024
1314
CAMERA_HEIGHT = 576
1415

cpopservice/server.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,17 @@ def get_object_detector() -> ObjectDetector:
6565
object_detector = ObjectDetector()
6666

6767
LOG.info('initializing camera parameters')
68-
frame = capture_from_vid(source=0, width=1920, height=1080)
69-
# frame = cv2.imread('data/calib-and-test/frame_1920x1080.jpg')
68+
if config.CALIBRATE_FRAME and os.path.isfile(config.CALIBRATE_FRAME):
69+
LOG.info('using existing frame for calibration %s', config.CALIBRATE_FRAME)
70+
frame = cv2.imread(config.CALIBRATE_FRAME)
71+
else:
72+
LOG.info('capturing frame from source')
73+
frame = capture_from_vid(source=0, width=1920, height=1080)
7074

7175
object_detector.init_camera_parameters(frame, viz=False)
7276

77+
LOG.info('camera parameters (rvec: %s, tvec: %s)', object_detector.rvec, object_detector.tvec)
78+
7379
return object_detector
7480

7581

0 commit comments

Comments
 (0)