aboutsummaryrefslogtreecommitdiff
path: root/decoder.py
diff options
context:
space:
mode:
Diffstat (limited to 'decoder.py')
-rw-r--r--decoder.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/decoder.py b/decoder.py
index cb34487..2738939 100644
--- a/decoder.py
+++ b/decoder.py
@@ -14,7 +14,8 @@ parser.add_argument("-x", "--height", help="grid height", default=100, type=int)
parser.add_argument("-y", "--width", help="grid width", default=100, type=int)
parser.add_argument("-f", "--fps", help="frame rate", default=30, type=int)
parser.add_argument("-l", "--level", help="error correction level", default=0.1, type=float)
-parser.add_argument("-s", "--size", help="number of bytes to decode", default=2**16, type=int)
+parser.add_argument("-s", "--size", help="number of bytes to decode", type=int)
+parser.add_argument("-p", "--psize", help="packet size", type=int)
parser.add_argument("-e", "--erasure", help="detect erasures", action="store_true")
args = parser.parse_args()
@@ -56,9 +57,12 @@ while data is None:
if not ret:
print("End of stream")
break
+ # raw_frame is a uint8 BE CAREFUL
+ if type(args.input) == int:
+ X, Y = raw_frame.shape[:2]
+ raw_frame = raw_frame[X // 4:3 * X // 4, Y // 4: 3 * Y // 4]
cv2.imshow("", raw_frame)
cv2.waitKey(1)
- # raw_frame is a uint8 BE CAREFUL
raw_frame = cv2.cvtColor(raw_frame, cv2.COLOR_BGR2RGB)
X, Y = raw_frame.shape[:2]
@@ -123,7 +127,7 @@ while data is None:
)
)
# erase_pos = bytearray(np.where(frame == 0)[0]) if args.erasure else bytearray()
- data = decoder.decode(bytes(rsc.decode(bytearray(np.packbits(frame) ^ frame_xor))[0][:-4]))
+ data = decoder.decode(bytes(rsc.decode(bytearray(np.packbits(frame) ^ frame_xor))[0][:args.psize]))
print("Decoded frame")
except KeyboardInterrupt:
sys.exit()