Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions vcm/qr_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def draw_qr(
img_qr = qr.make_image(fill_color="black", back_color="white")
img_qr = np.array(img_qr.convert('RGB'))[:, :, ::-1].copy()

if n_markers > 4:
n_markers = 4 # 4 markers at most

if n_markers==1:
markers = [[1080-dist-img_qr.shape[0],1920-dist-img_qr.shape[1]]]
elif n_markers==2:
Expand Down Expand Up @@ -124,16 +127,12 @@ def draw_qr(
run_process(ff_args)
shutil.rmtree(tmp_dir)

marker_pos = {
'marker_1_x1': markers[0][1],
'marker_1_x2': markers[0][1]+img_qr.shape[0],
'marker_1_y1': markers[0][0],
'marker_1_y2': markers[0][0]+img_qr.shape[1],
'marker_2_x1': markers[1][1],
'marker_2_x2': markers[1][1]+img_qr.shape[0],
'marker_2_y1': markers[1][0],
'marker_2_y2': markers[1][0]+img_qr.shape[1],
}
marker_pos = {}
for i in range(0, n_markers):
marker_pos['marker_'+str(i)+'_x1'] = markers[i][1],
marker_pos['marker_'+str(i)+'_x2'] = markers[i][1]+img_qr.shape[0],
marker_pos['marker_'+str(i)+'_y1'] = markers[i][0],
marker_pos['marker_'+str(i)+'_y2'] = markers[i][0]+img_qr.shape[1],

return marker_pos, output_video

Expand All @@ -158,4 +157,4 @@ def check_qr_codes(dst_video):
detected_frame = int(barcode.data.decode("utf-8"))
if detected_frame!=frame:
raise RuntimeError(f"Wrong frame number for QR code found. Actual frame: {frame}, detected frame {detected_frame}")
print(f'--> All QR codes succesfully detected')
print(f'--> All QR codes succesfully detected')