endianness + depth_data_format) # new offset from where tail starts return (width, height, posx, posy, list(depth_data)), offset if __name__ == '__main__': s = connect() if s is None: sys.exit(0) do_plot = True if len(sys.argv) > 1 and sys.argv[1] == '--plot' else False start_time = time.time() count = 0 while True: try: (timestamp, frame_type), (width, height, posx, posy, depth_data), (writer_data,) = read_frame( s, decode_content) except: s.close() break print("{:<20d} {:<4d} {:<4d} {:<4d} '{}'".format(timestamp, frame_type, width, height, writer_data)) count += 1 if count == 100: print('='*30) print('FPS: ', 100.0 / (time.time() - start_time)) print('='*30) start_time = time.time() count = 0 if do_plot and count % 20 == 0 and height*width > 0:
frame_format * engaged) # new offset from where tail starts return decoded, offset if __name__ == '__main__': s = connect() if s is None: sys.exit(0) start_time = time.time() count = 0 while True: try: (timestamp, frame_type), (tracked_body_count, engaged, frame_pieces), (writer_data, ) = read_frame( s, decode_content) except: s.close() break print("{:<20d} {:<4d} {:<4d} {:<5s} '{}'".format( timestamp, frame_type, tracked_body_count, str(engaged > 0), writer_data.decode('ascii'))) print("\n\n") count += 1 if count == 100: print('=' * 30) print('FPS: ', 100.0 / (time.time() - start_time)) print('=' * 30) start_time = time.time()
if __name__ == '__main__': s = connect() if s is None: sys.exit(0) do_plot = True if len(sys.argv) > 1 and sys.argv[1] == '--plot' else False start_time = time.time() count = 0 while True: try: (timestamp, frame_type), (width, height, posx, posy, depth_data), (writer_data, ) = read_frame( s, decode_content) except: s.close() break print("{:<20d} {:<4d} {:<4d} {:<4d} '{}'".format( timestamp, frame_type, width, height, writer_data)) count += 1 if count == 100: print('=' * 30) print('FPS: ', 100.0 / (time.time() - start_time)) print('=' * 30) start_time = time.time() count = 0
command_format = str(command_length) + "s" command = struct.unpack_from(endianness + command_format, raw_frame, offset + content_header_size)[0] command = command.decode('ascii') offset = offset + content_header_size + struct.calcsize( endianness + command_format) # new offset from where tail starts return (command_length, command), offset if __name__ == '__main__': s = connect() if s is None: sys.exit(0) while True: try: (timestamp, frame_type), (command_length, command), (writer_data, ) = read_frame( s, decode_content) except: s.close() break if len(command) > 0 or len(writer_data) > 0: print("{:<20d} {:<4d} '{}' '{}'".format( timestamp, frame_type, command, writer_data.decode('ascii'))) print("\n\n")
# Timestamp | frame type | command_length | command def decode_content(raw_frame, offset): endianness = "<" # 4 bytes and 3 doubles content_format = "B" * 4 + "d" * 3 content_size = struct.calcsize(endianness + content_format) content = struct.unpack_from(endianness + content_format, raw_frame, offset) return content, offset + content_size if __name__ == '__main__': s = connect() if s is None: sys.exit(0) while True: try: (timestamp, frame_type), (faceFound, engaged, lookingAway, wearingGlasses, pitch, yaw, roll), (writer_data,) = read_frame(s, decode_content) except: s.close() break print(timestamp, frame_type) print("Face Found: {}, Engaged: {}, Looking Away: {}, Wearing Glasses: {}".format(faceFound, engaged, lookingAway, wearingGlasses)) print("Pitch: {}, Yaw: {}, Roll: {}".format(pitch, yaw, roll)) print("\n\n")