diff options
-rw-r--r-- | decoder.py | 10 | ||||
-rw-r--r-- | encoder.py | 3 |
2 files changed, 8 insertions, 5 deletions
@@ -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() @@ -39,8 +39,7 @@ rcorner = np.pad(np.dstack((ones, zeros, zeros)), ((0, 1), (1, 0), (0, 0))) gcorner = np.pad(np.dstack((zeros, ones, zeros)), ((1, 0), (0, 1), (0, 0))) bcorner = np.pad(np.dstack((zeros, zeros, ones)), ((1, 0), (1, 0), (0, 0))) -print("Data length:", len(data)) -print("Packets:", len(packets)) +print(f"-x {args.height} -y {args.width} -l {args.level} -s {len(data)} -p {len(packets[0])}") def frame(packet): |