| | |
| | | "cells": [ |
| | | { |
| | | "cell_type": "code", |
| | | "execution_count": 1, |
| | | "metadata": {}, |
| | | "execution_count": 24, |
| | | "metadata": { |
| | | "collapsed": true |
| | | }, |
| | | "outputs": [], |
| | | "source": [ |
| | | "import numpy as np\n", |
| | |
| | | }, |
| | | { |
| | | "cell_type": "code", |
| | | "execution_count": 3, |
| | | "metadata": {}, |
| | | "execution_count": 25, |
| | | "metadata": { |
| | | "collapsed": true |
| | | }, |
| | | "outputs": [], |
| | | "source": [ |
| | | "video_path = '../data/video/SGT036_2016_07_25_pivothead_AVI.avi'\n", |
| | | "bbox_path = '../data/video/annotations/SGT036_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-SGT036_set4_normal_a1_epoch_25.txt'\n", |
| | | "output_string = 'SGT036_set4_normal_a1_epoch_25_smooth'" |
| | | "annot_path = '../output/video/output-jacob_normal_a1.txt'\n", |
| | | "output_string = 'jacob_smooth'" |
| | | ] |
| | | }, |
| | | { |
| | | "cell_type": "code", |
| | | "execution_count": 4, |
| | | "metadata": {}, |
| | | "execution_count": 26, |
| | | "metadata": { |
| | | "collapsed": false |
| | | }, |
| | | "outputs": [ |
| | | { |
| | | "name": "stdout", |
| | | "output_type": "stream", |
| | | "text": [ |
| | | "[ 2.843239 6.065323 6.614468 ..., -0.936905 -1.396786 -3.20248 ]\n", |
| | | "(8508,)\n", |
| | | "(53464,)\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": 5, |
| | | "metadata": {}, |
| | | "execution_count": 27, |
| | | "metadata": { |
| | | "collapsed": false |
| | | }, |
| | | "outputs": [ |
| | | { |
| | | "name": "stdout", |
| | |
| | | "source": [ |
| | | "window_len = 3\n", |
| | | "pad = window_len / 2\n", |
| | | "window = 'flat'\n", |
| | | "window = 'hanning'\n", |
| | | "window_2 = 'flat'\n", |
| | | "window_len_2 = 7\n", |
| | | "pad_2 = window_len_2 / 2\n", |
| | |
| | | }, |
| | | { |
| | | "cell_type": "code", |
| | | "execution_count": 7, |
| | | "metadata": {}, |
| | | "execution_count": 30, |
| | | "metadata": { |
| | | "collapsed": false |
| | | }, |
| | | "outputs": [ |
| | | { |
| | | "name": "stdout", |
| | |
| | | "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' % args.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", |
| | | "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.cv.CV_FOURCC(*'MJPG')\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", |
| | | "for frame_num in xrange(10000):\n", |
| | | "for frame_num in xrange(20000):\n", |
| | | " ret,frame = video.read()\n", |
| | | " if ret == False:\n", |
| | | " out.release()\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 2", |
| | | "display_name": "Python [default]", |
| | | "language": "python", |
| | | "name": "python2" |
| | | }, |
| | |
| | | "name": "python", |
| | | "nbconvert_exporter": "python", |
| | | "pygments_lexer": "ipython2", |
| | | "version": "2.7.13" |
| | | "version": "2.7.12" |
| | | } |
| | | }, |
| | | "nbformat": 4, |