def main(): args = parse_args() if args.category_num <= 0: raise SystemExit('Bad category_num: %d!' % args.category_num) cam = Camera(args) cam.open() if not cam.is_opened: sys.exit('Failed to open camera!') cls_dict = get_cls_dict(args.category_num) yolo_dim = int(args.model.split('-')[-1]) if yolo_dim not in (288, 416, 608): raise SystemExit('Bad yolo_dim: %d!\nPlease make sure the model file name contains the correct dimension...' % yolo_dim) trt_yolov3 = TrtYOLOv3(args.model, (yolo_dim, yolo_dim), args.category_num) cam.start() open_window(WINDOW_NAME, args.image_width, args.image_height, 'Camera TensorRT YOLOv3 Demo') vis = BBoxVisualization(cls_dict) loop_and_detect(cam, trt_yolov3, conf_th=0.3, vis=vis) cam.stop() cam.release() cv2.destroyAllWindows()
def main(): global THREAD_RUNNING args = parse_args() cap = open_cam_rtsp(args.cam_name, args.cam_password, args.cam_ip) if not cap.isOpened(): sys.exit('Failed to open camera!') #抓取图像子进程 THREAD_RUNNING = True th = threading.Thread(target=grab_img, args=(cap, )) th.start() #目标识别 cls_dict = get_cls_dict('coco') yolo_dim = int(args.model.split('-')[-1]) # 416 or 608 trt_yolov3 = TrtYOLOv3(args.model, (yolo_dim, yolo_dim)) vis = BBoxVisualization(cls_dict) #考虑对roi区域裁剪并resize loop_and_detect(trt_yolov3, conf_th=0.3, vis=vis) #关闭图像子进程 THREAD_RUNNING = False th.join() cap.release() cv2.destroyAllWindows()
def main(): args = parse_args() #YOLO INIT #cls_dict = get_cls_dict('coco') cls_dict = get_cls_dict('deepfamily') print("classes count : ", len(cls_dict)) yolo_dim = int(args.model.split('-')[-1]) # 416 or 608 print("yolo_dim : ", yolo_dim) trt_yolov3 = TrtYOLOv3(args.model, (yolo_dim, yolo_dim)) #CAMERA cam = Camera(args) cam.open() if not cam.is_opened: sys.exit('Failed to open camera!') cam.start() #CAM-WINDOW open_window(WINDOW_NAME, args.image_width, args.image_height, 'DEEPFAMILY PROJECT - TensorRT YOLOv3') vis = BBoxVisualization(cls_dict) #DETECT-LOOP loop_and_detect(cam, trt_yolov3, conf_th=0.95, vis=vis) #loop_and_detect(cam, trt_yolov3, conf_th=0.95) cam.stop() cam.release() cv2.destroyAllWindows()
def main(): args = parse_args() cam = Camera(args) cam.open() if not cam.is_opened: sys.exit('Failed to open camera!') cls_dict = get_cls_dict('coco') yolo_dim = int(args.model.split('-')[-1]) # 416 or 608 trt_yolov3 = TrtYOLOv3(args.model, (yolo_dim, yolo_dim)) cam.start() # open_window(WINDOW_NAME, args.image_width, args.image_height, # 'Camera TensorRT YOLOv3 Demo') vis = BBoxVisualization(cls_dict) # for video # loop_and_detect(cam, trt_yolov3, conf_th=0.3, vis=vis) # for single file detect_demo(cam, trt_yolov3, conf_th=0.3, vis=vis) cam.stop() cam.release() cv2.destroyAllWindows()
def main(): args = parse_args() cls_dict = get_cls_dict('coco') yolo_dim = int(args.model.split('-')[-1]) # 416 or 608 trt_yolov3 = TrtYOLOv3(args.model, (yolo_dim, yolo_dim)) vis = BBoxVisualization(cls_dict) check(trt_yolov3, conf_th=0.3, vis=vis)
def main(): model = "yolov3-tiny-covid" category_num = 5 conf_th = 0.3 input_size = 608 cls_dict = get_cls_dict(category_num) vis = BBoxVisualization(cls_dict) #args = parse_args() detector = yoloRT(model, input_size, vis, conf_th, category_num) pub = rospy.Publisher('people_detection', Bool, queue_size=5) rospy.init_node('people_detector', anonymous=True) sub = rospy.Subscriber('front_camera/color/image_raw', Image, detector.detect) #pipeline = camera_config(sys.argv) try: rospy.spin() except KeyboardInterrupt: print("Shutting down") cls_dict = get_cls_dict(category_num) yolo_dim = model.split('-')[-1] if 'x' in yolo_dim: dim_split = yolo_dim.split('x') if len(dim_split) != 2: raise SystemExit('ERROR: bad yolo_dim (%s)!' % yolo_dim) w, h = int(dim_split[0]), int(dim_split[1]) else: h = w = int(608) if h % 32 != 0 or w % 32 != 0: raise SystemExit('ERROR: bad yolo_dim (%s)!' % yolo_dim) trt_yolov3 = TrtYOLOv3(model, (h, w), category_num) vis = BBoxVisualization(cls_dict) loop_and_detect(pub, pipeline, trt_yolov3, conf_th=0.3, vis=vis) pipeline.stop()
def main(): args = parse_args() if args.category_num <= 0: raise SystemExit('ERROR: bad category_num (%d)!' % args.category_num) if not os.path.isfile('yolov3_onnx/%s.trt' % args.model): raise SystemExit('ERROR: file (yolov3_onnx/%s.trt) not found!' % args.model) cam = Camera(args) cam.open() if not cam.is_opened: raise SystemExit('ERROR: failed to open camera!') cls_dict = get_cls_dict(args.category_num) yolo_dim = args.model.split('-')[-1] if 'x' in yolo_dim: dim_split = yolo_dim.split('x') if len(dim_split) != 2: raise SystemExit('ERROR: bad yolo_dim (%s)!' % yolo_dim) w, h = int(dim_split[0]), int(dim_split[1]) else: h = w = int(yolo_dim) if h % 32 != 0 or w % 32 != 0: raise SystemExit('ERROR: bad yolo_dim (%s)!' % yolo_dim) trt_yolov3 = TrtYOLOv3(args.model, (h, w), args.category_num) cam.start() open_window(WINDOW_NAME, args.image_width, args.image_height, 'Camera TensorRT YOLOv3 Demo') vis = BBoxVisualization(cls_dict) loop_and_detect(cam, trt_yolov3, conf_th=0.3, vis=vis) cam.stop() cam.release() cv2.destroyAllWindows()
'Camera TensorRT YOLOv3 Demo') vis = BBoxVisualization(cls_dict) loop_and_detect(cam, trt_yolov3, conf_th=0.3, vis=vis) cam.stop() cam.release() cv2.destroyAllWindows() # if __name__ == '__main__': # main() args = parse_args() cap = cv2.VideoCapture(0) #("rtsp://*****:*****@192.168.10.67:554/1/1") cls_dict = get_cls_dict('coco') yolo_dim = int(args.model.split('-')[-1]) # 416 or 608 trt_yolov3 = TrtYOLOv3(args.model, (yolo_dim, yolo_dim)) vis = BBoxVisualization(cls_dict) full_scrn = False fps = 0.0 tic = time.time() conf_th = 0.3 while True: _, frame = cap.read() time_start = time.time() boxes, confs, clss = trt_yolov3.detect(frame, conf_th) print("--------------tf1----------\n",