'{:6.2f}'.format(dict_['sensors']['temperature']['upa0']), ' DSS:' + '{:6.2f}'.format(dict_['sensors']['temperature']['upa1'])) frame_count[packet.stream_name] += 1 json_stream(frame_id, entries_prev) t_curr = time() if t_start + 1.0 < t_curr: t_start = t_curr for s in stream_names: frame_count_prev[s] = frame_count[s] frame_count[s] = 0 key = cv2.waitKey(1) if key == ord('c'): depthai.request_jpeg() elif key == ord('q'): break del p # in order to stop the pipeline object should be deleted, otherwise device will continue working. This is required if you are going to add code after the main loop, otherwise you can ommit it. depthai.deinit_device() # Close video output file if was opened if video_file is not None: video_file.close() print('py: DONE.')
def __del__(self): del self.pipeline depthai.deinit_device()
def main(): nfeatures = 2000 # Number of keypoints to sample inlierThreshold = 0.001 nms_dist = 4 conf_thresh = 0.005 nn_thresh = 0.7 h = 100 w = 100 res = '{}x{}'.format(h, w) if not depthai.init_device(consts.resource_paths.device_cmd_fpath): raise RuntimeError("Error initializing device. Try to reset it.") local_dir = os.getcwd() p = depthai.create_pipeline( config={ "streams": ["previewout", "metaout"], "ai": { "blob_file": os.path.join(local_dir, "output", "superpoint_{}.blob".format( res)), "blob_file_config": os.path.join(local_dir, "output", "superpoint_{}.json".format( res)), "calc_dist_to_bb": False, }, "app": { "sync_video_meta_stream": True }, }) if p is None: raise RuntimeError("Error initializing pipelne") sp = SuperPointWrapper(h=h, w=w, nms_dist=nms_dist, conf_thresh=conf_thresh, nn_thresh=nn_thresh) kp_desc_list = [] while True: nnet_packets, data_packets = p.get_available_nnet_and_data_packets() print('nnet_packets: ', len(nnet_packets)) packets_len = len(nnet_packets) + len(data_packets) print('packets_len: ', packets_len) kp_desc_list.extend(sp.decode_packets(nnet_packets)) for nnet_packet, packet in zip(nnet_packets, data_packets): if packet.stream_name == 'previewout': data = packet.getData() data0 = data[0, :, :] frame = cv2.cvtColor(data0, cv2.COLOR_GRAY2BGR) if len(kp_desc_list) > 0: kps, _ = kp_desc_list.pop(0) for k in kps: print(k[:2]) cv2.circle(frame, (int(k[0]), int(k[1])), 3, (0, 0, 255), -1) frame = cv2.resize(frame, (240, 240)) cv2.imshow('previewout', frame) if cv2.waitKey(1) == ord('q'): break del p depthai.deinit_device()
def __del__(self): if hasattr(self, 'pipeline'): del self.pipeline depthai.deinit_device()
def __del__(self): if hasattr(self, 'p'): del self.p depthai.deinit_device()