def _main_(args):
    weights_path = args.weights
    video_path = args.video
    (net_h, net_w) = (416, 416)
    (obj_thresh, nms_thresh) = (0.65, 0.45)
    anchors = [[116, 90, 156, 198, 373, 326], [30, 61, 62, 45, 59, 119], [10, 13, 16, 30, 33, 23]]
    labels = ['person', 'bicycle', 'car', 'motorbike', 'aeroplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'sofa', 'pottedplant', 'bed', 'diningtable', 'toilet', 'tvmonitor', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
    yolov3 = make_yolov3_model()
    weight_reader = WeightReader(weights_path)
    weight_reader.load_weights(yolov3)
    "\n    # set webcam\n    cap = cv2.VideoCapture(1)\n    while(True):\n        ret, image = cap.read()\n        #image_h, image_w, _ = image.shape\n        image_w = cap.get(3)\n        image_h = cap.get(4)\n        if cv2.waitKey(1) & 0xFF == ord(' '):\n            new_image = preprocess_input(image, net_h, net_w)\n            yolos = yolov3.predict(new_image)\n            boxes = []\n            for i in range(len(yolos)):\n                boxes += decode_netout(yolos[i][0], anchors[i], obj_thresh, nms_thresh, net_h, net_w)\n            correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w)\n            do_nms(boxes, nms_thresh)\n            draw_boxes_play_music(image, boxes, labels, obj_thresh)\n        cv2.imshow('frame',image)\n        if cv2.waitKey(1) & 0xFF == ord('q'):\n            break\n    cap.release()\n    cv2.destroyAllWindows()\n    "
    cap = cv2.VideoCapture(video_path)
    print('open video file from', video_path)
    if Path(video_path).is_file():
        print('Video file exists')
    else:
        print('cannot find video file')
    print(cap.isOpened())
    while cap.isOpened():
        (ret, image) = cap.read()
        image_w = cap.get(3)
        image_h = cap.get(4)
        image = cv2.flip(image, 0)
        new_image = preprocess_input(image, net_h, net_w)
        yolos = yolov3.predict(new_image)
        boxes = []
        for i in range(len(yolos)):
            boxes += decode_netout(yolos[i][0], anchors[i], obj_thresh, nms_thresh, net_h, net_w)
        correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w)
        do_nms(boxes, nms_thresh)
        draw_boxes(image, boxes, labels, obj_thresh)
        cv2.imshow('frame', image)
        if ((cv2.waitKey(1) & 255) == ord('q')):
            break
    cap.release()
    cv2.destroyAllWindows()
def _main_(args):
    weights_path = args.weights
    video_path = args.video
    (net_h, net_w) = (416, 416)
    (obj_thresh, nms_thresh) = (0.65, 0.45)
    anchors = [[116, 90, 156, 198, 373, 326], [30, 61, 62, 45, 59, 119], [10, 13, 16, 30, 33, 23]]
    labels = ['person', 'bicycle', 'car', 'motorbike', 'aeroplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'sofa', 'pottedplant', 'bed', 'diningtable', 'toilet', 'tvmonitor', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
    yolov3 = make_yolov3_model()
    weight_reader = WeightReader(weights_path)
    weight_reader.load_weights(yolov3)
    "\n    # set webcam\n    cap = cv2.VideoCapture(1)\n    while(True):\n        ret, image = cap.read()\n        #image_h, image_w, _ = image.shape\n        image_w = cap.get(3)\n        image_h = cap.get(4)\n        if cv2.waitKey(1) & 0xFF == ord(' '):\n            new_image = preprocess_input(image, net_h, net_w)\n            yolos = yolov3.predict(new_image)\n            boxes = []\n            for i in range(len(yolos)):\n                boxes += decode_netout(yolos[i][0], anchors[i], obj_thresh, nms_thresh, net_h, net_w)\n            correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w)\n            do_nms(boxes, nms_thresh)\n            draw_boxes_play_music(image, boxes, labels, obj_thresh)\n        cv2.imshow('frame',image)\n        if cv2.waitKey(1) & 0xFF == ord('q'):\n            break\n    cap.release()\n    cv2.destroyAllWindows()\n    "
    cap = cv2.VideoCapture(video_path)
    print('open video file from', video_path)
    if Path(video_path).is_file():
        print('Video file exists')
    else:
        print('cannot find video file')
    print(cap.isOpened())
    while cap.isOpened():
        (ret, image) = cap.read()
        image_w = cap.get(3)
        image_h = cap.get(4)
        image = cv2.flip(image, 0)
        new_image = preprocess_input(image, net_h, net_w)
        yolos = yolov3.predict(new_image)
        boxes = []
        for i in range(len(yolos)):
            boxes += decode_netout(yolos[i][0], anchors[i], obj_thresh, nms_thresh, net_h, net_w)
        correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w)
        do_nms(boxes, nms_thresh)
        draw_boxes(image, boxes, labels, obj_thresh)
        cv2.imshow('frame', image)
        if ((cv2.waitKey(1) & 255) == ord('q')):
            break
    cap.release()
    cv2.destroyAllWindows()