Nataniel Ruiz
2019-03-04 cd27a07f60e1896e93554f4e91152e61cf40b2b2
code/test_on_video_dlib.py
@@ -98,9 +98,13 @@
    # fourcc = cv2.cv.CV_FOURCC(*'MJPG')
    # out = cv2.VideoWriter('output/video/output-%s.avi' % args.output_string, fourcc, 30.0, (width, height))
    txt_out = open('output/video/output-%s.txt' % args.output_string, 'w')
    frame_num = 1
    while frame_num <= args.n_frames:
        print frame_num
        ret,frame = video.read()
        if ret == False:
            break
@@ -112,18 +116,17 @@
        for idx, det in enumerate(dets):
            # Get x_min, y_min, x_max, y_max, conf
            x_min = d.rect.left()
            y_min = d.rect.top()
            x_max = d.rect.right()
            y_max = d.rect.bottom()
            conf = d.confidence
            print x_min, y_min, x_max, y_max, conf
            x_min = det.rect.left()
            y_min = det.rect.top()
            x_max = det.rect.right()
            y_max = det.rect.bottom()
            conf = det.confidence
            if conf > 0.95:
            if conf > 1.0:
                bbox_width = abs(x_max - x_min)
                bbox_height = abs(y_max - y_min)
                x_min -= 3 * bbox_width / 4
                x_max += 3 * bbox_width / 4
                x_min -= 2 * bbox_width / 4
                x_max += 2 * bbox_width / 4
                y_min -= 3 * bbox_height / 4
                y_max += bbox_height / 4
                x_min = max(x_min, 0); y_min = max(y_min, 0)
@@ -155,8 +158,8 @@
                # Plot expanded bounding box
                # cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), (0,255,0), 1)
            out.write(frame)
            frame_num += 1
        out.write(frame)
        frame_num += 1
    out.release()
    video.release()