| | |
| | | "cells": [ |
| | | { |
| | | "cell_type": "code", |
| | | "execution_count": 1, |
| | | "execution_count": 8, |
| | | "metadata": { |
| | | "collapsed": false |
| | | "collapsed": true |
| | | }, |
| | | "outputs": [], |
| | | "source": [ |
| | |
| | | }, |
| | | { |
| | | "cell_type": "code", |
| | | "execution_count": 2, |
| | | "execution_count": 9, |
| | | "metadata": { |
| | | "collapsed": false |
| | | "collapsed": true |
| | | }, |
| | | "outputs": [], |
| | | "source": [ |
| | | "video_path = '../data/video/SWC016_2016_04_08_pivothead_AVI.avi'\n", |
| | | "bbox_path = '../data/video/annotations/SWC016_childface.txt'\n", |
| | | "video_path = '../data/video/jacob_collier_live.mp4'\n", |
| | | "bbox_path = '../data/video/annotations/video-det-fold-jacob_collier_live.txt'\n", |
| | | "\n", |
| | | "annot_path = '../output/video/output-SWC016_normal_1e-5_epoch_20.txt'\n", |
| | | "output_string = 'SWC016_normal_1e-5_epoch_20_smooth'" |
| | | "annot_path = '../output/video/output-jacob_normal_a1.txt'\n", |
| | | "output_string = 'jacob_smooth'" |
| | | ] |
| | | }, |
| | | { |
| | | "cell_type": "code", |
| | | "execution_count": 3, |
| | | "execution_count": 10, |
| | | "metadata": { |
| | | "collapsed": false |
| | | }, |
| | |
| | | "name": "stdout", |
| | | "output_type": "stream", |
| | | "text": [ |
| | | "[ -1.15884 -14.885593 -16.727406 ..., -57.590378 -56.963156 -58.641377]\n", |
| | | "(9322,)\n", |
| | | "(63691,)\n" |
| | | "[ -2.073635 -10.835449 8.318871 ..., -20.763079 -12.68498 19.257992]\n", |
| | | "(19987,)\n", |
| | | "(21373,)\n" |
| | | ] |
| | | } |
| | | ], |
| | |
| | | " list_p.append(float(line[2]))\n", |
| | | " list_r.append(float(line[3]))\n", |
| | | " \n", |
| | | "last_frame = 0\n", |
| | | "for line in bbox:\n", |
| | | " line = line.strip('\\n')\n", |
| | | " line = line.split(' ')\n", |
| | | " frame = int(line[0])\n", |
| | | " x_min, y_min, x_max, y_max = int(line[1]), int(line[2]), int(line[3]), int(line[4])\n", |
| | | " if frame == last_frame:\n", |
| | | " continue\n", |
| | | " last_frame = frame\n", |
| | | " x_min, y_min, x_max, y_max = int(float(line[1])), int(float(line[2])), int(float(line[3])), int(float(line[4]))\n", |
| | | " list_x_min.append(x_min)\n", |
| | | " list_x_max.append(x_max)\n", |
| | | " list_y_min.append(y_min)\n", |
| | |
| | | }, |
| | | { |
| | | "cell_type": "code", |
| | | "execution_count": 4, |
| | | "execution_count": 11, |
| | | "metadata": { |
| | | "collapsed": false |
| | | }, |
| | |
| | | } |
| | | ], |
| | | "source": [ |
| | | "window_len = 7\n", |
| | | "window_len = 1\n", |
| | | "pad = window_len / 2\n", |
| | | "window = 'flat'\n", |
| | | "window_2 = 'flat'\n", |
| | |
| | | }, |
| | | { |
| | | "cell_type": "code", |
| | | "execution_count": 7, |
| | | "execution_count": 14, |
| | | "metadata": { |
| | | "collapsed": false |
| | | }, |
| | |
| | | ], |
| | | "source": [ |
| | | "video = cv2.VideoCapture(video_path)\n", |
| | | "# New cv2\n", |
| | | "width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH)) # float\n", |
| | | "height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT)) # float\n", |
| | | "\n", |
| | | "# Define the codec and create VideoWriter object\n", |
| | | "fourcc = cv2.VideoWriter_fourcc(*'MJPG')\n", |
| | | "out = cv2.VideoWriter('../output/video/output-%s.avi' % output_string, fourcc, 30.0, (width, height))\n", |
| | | "\n", |
| | | "# Old cv2\n", |
| | | "# width = int(video.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)) # float\n", |
| | | "# height = int(video.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)) # float\n", |
| | | "\n", |
| | | "# # Define the codec and create VideoWriter object\n", |
| | | "# fourcc = cv2.cv.CV_FOURCC(*'MJPG')\n", |
| | | "# out = cv2.VideoWriter('../output/video/output-%s.avi' % output_string, fourcc, 30.0, (width, height))\n", |
| | | "\n", |
| | | "txt_out = open('../output/video/output-%s.txt' % output_string, 'w')\n", |
| | | "\n", |
| | |
| | | "\n", |
| | | " # Print new frame with cube and TODO: axis\n", |
| | | " txt_out.write(str(frame_num) + ' %f %f %f\\n' % (yaw_predicted, pitch_predicted, roll_predicted))\n", |
| | | " utils.plot_pose_cube(frame, yaw_predicted, pitch_predicted, roll_predicted, (x_min + x_max) / 2, (y_min + y_max) / 2, size = 200)\n", |
| | | " utils.plot_pose_cube(frame, yaw_predicted, pitch_predicted, roll_predicted, (x_min + x_max) / 2, (y_min + y_max) / 2, size = 80)\n", |
| | | " out.write(frame)\n", |
| | | " else:\n", |
| | | " out.write(frame)\n", |
| | |
| | | "metadata": { |
| | | "anaconda-cloud": {}, |
| | | "kernelspec": { |
| | | "display_name": "Python [conda root]", |
| | | "display_name": "Python [default]", |
| | | "language": "python", |
| | | "name": "conda-root-py" |
| | | "name": "python2" |
| | | }, |
| | | "language_info": { |
| | | "codemirror_mode": { |