Skip to content

Commit 2b2d940

Browse files
committed
add extra text for camera selector for better guidance
1 parent 4069a48 commit 2b2d940

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

afy/cam_fomm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def select_camera(config):
128128
cam_frames = cam_selector.query_cameras(config['query_n_cams'])
129129

130130
if cam_frames:
131-
cam_id = cam_selector.select_camera(cam_frames, window="CLICK ON YOUR CAMERA")
131+
cam_id = cam_selector.select_camera(cam_frames)
132132
log(f"Selected camera {cam_id}")
133133

134134
with open(cam_config, 'w') as f:

afy/camera_selector.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def make_grid(images, cell_size=(320, 240), cols=2):
4646
# add rect
4747
img = cv2.rectangle(img, (1, 1), (w0 - 1, h0 - 1), (0, 0, 255), 2)
4848
# add id
49-
img = cv2.putText(img, f'{camid}', (10, 30), 0, 1, (0, 255, 0), 2)
49+
img = cv2.putText(img, f'Camera {camid}', (10, 30), 0, 1, (0, 255, 0), 2)
5050
c = i % cols
5151
r = i // cols
5252
grid[r * h0:(r + 1) * h0, c * w0:(c + 1) * w0] = img[..., :3]
@@ -64,11 +64,18 @@ def mouse_callback(event, x, y, flags, userdata):
6464
g_selected_cam = camid
6565

6666

67-
def select_camera(cam_frames, window="cameras"):
67+
def select_camera(cam_frames, window="Camera selector"):
6868
cell_size = 320, 240
6969
grid_cols = 2
7070
grid = make_grid(cam_frames, cols=grid_cols)
7171

72+
# to fit the text if only one cam available
73+
if grid.shape[1] == 320:
74+
cell_size = 640, 480
75+
grid = cv2.resize(grid, cell_size)
76+
77+
cv2.putText(grid, f'Click on the web camera to use', (10, grid.shape[0] - 30), 0, 0.7, (200, 200, 200), 2)
78+
7279
cv2.namedWindow(window)
7380
cv2.setMouseCallback(window, mouse_callback, (cell_size, grid_cols, cam_frames))
7481
cv2.imshow(window, grid)

0 commit comments

Comments
 (0)