diff options
author | Anthony Wang | 2024-05-13 00:18:03 -0400 |
---|---|---|
committer | Anthony Wang | 2024-05-13 00:18:03 -0400 |
commit | 05e4dfbd5b9ddee59f6d42a608612f11102b61fe (patch) | |
tree | 947583ff4aa67a538b037075730e7fc0d0d30058 | |
parent | a1d77a466dcc694f0101d2588529ada8c858ed94 (diff) |
Use medians for deciding color, seems to work well in practice
-rw-r--r-- | decoder.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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( ( |