| | |
| | | parser.add_argument('--face_model', dest='face_model', help='Path of DLIB face detection model.', |
| | | default='', type=str) |
| | | parser.add_argument('--video', dest='video_path', help='Path of video') |
| | | parser.add_argument('--bboxes', dest='bboxes', help='Bounding box annotations of frames') |
| | | parser.add_argument('--output_string', dest='output_string', help='String appended to output file') |
| | | parser.add_argument('--n_frames', dest='n_frames', help='Number of frames', type=int) |
| | | parser.add_argument('--fps', dest='fps', help='Frames per second of source video', type=float, default=30.) |
| | |
| | | # 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 |
| | |
| | | |
| | | 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 |
| | |
| | | # utils.plot_pose_cube(frame, yaw_predicted, pitch_predicted, roll_predicted, (x_min + x_max) / 2, (y_min + y_max) / 2, size = bbox_width) |
| | | utils.draw_axis(frame, yaw_predicted, pitch_predicted, roll_predicted, tdx = (x_min + x_max) / 2, tdy= (y_min + y_max) / 2, size = bbox_height/2) |
| | | # Plot expanded bounding box |
| | | # cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), (0,255,0), 1) |
| | | 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() |