From 05e4dfbd5b9ddee59f6d42a608612f11102b61fe Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Mon, 13 May 2024 00:18:03 -0400 Subject: Use medians for deciding color, seems to work well in practice --- decoder.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/decoder.py b/decoder.py index b23d623..235a5f6 100644 --- a/decoder.py +++ b/decoder.py @@ -99,7 +99,11 @@ while data is None: ) frame = cv2.warpPerspective(raw_frame, M, (args.width, args.height)) # Convert to new color space - frame = (np.squeeze(F @ (frame - origin)[..., np.newaxis]) >= 160).astype(np.uint8) + frame = np.squeeze(F @ (frame - origin)[..., np.newaxis]) + rmed = np.median(frame[:,:,0]) + gmed = np.median(frame[:,:,1]) + bmed = np.median(frame[:,:,2]) + frame = np.dstack((frame[:,:,0] > rmed, frame[:,:,1] > gmed, frame[:,:,2] > bmed)).astype(np.uint8) frame = np.packbits( np.concatenate( ( -- cgit v1.2.3-70-g09d2