Permalink
Browse files

Added python script to flip reverse portrait vids

  • Loading branch information...
1 parent 164ee25 commit f2dc9293b70c74ecdd577ce697d4c01cb3d85401 @errollw committed Feb 25, 2014
View
@@ -32,24 +32,20 @@ int main(int argc, const char** argv)
gaze_smoothing_init();
// start reading in camera frames (720p video)
- VideoCapture cap("videos\\sample_video.mp4");
+ VideoCapture cap("videos\\sample_video.avi");
// setup image files used in the capture process
Mat captureFrame, grayscaleFrame, smallFrame;
// create a window to present the results
namedWindow("output", 1);
- // main loop
- while(true)
- {
+ // main loop, terminates when out of frames
+ while(cap.isOpened()) {
clock_t start = clock();
// read in a new image frame
cap >> captureFrame;
- // captureFrame = imread("images\\SS_0.jpg", CV_LOAD_IMAGE_COLOR);
-
- flip(captureFrame, captureFrame, -1);
// convert captured image to equalized gray scale
cvtColor(captureFrame, grayscaleFrame, CV_BGR2GRAY);
@@ -65,12 +61,12 @@ int main(int argc, const char** argv)
// Show the output
imshow("output", captureFrame);
- switch (waitKey(5)){
- case 's':
- screenshot_filename = "SS_" + to_string(num_screenshots++);
- imwrite(screenshot_filename + ".jpg", captureFrame);
- break;
- case 'q': return 0;
+ switch (waitKey(1)){
+ case 's':
+ screenshot_filename = "SS_" + to_string(num_screenshots++);
+ imwrite(screenshot_filename + ".jpg", captureFrame);
+ break;
+ case 'q': return 0;
}
}
View
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,18 @@
+import cv2, numpy as np
+
+# initialize the input video
+vid = cv2.VideoCapture('input.mp4')
+ret, frame = vid.read()
+
+# video to write the flipped input video to
+out = cv2.VideoWriter('output.avi', cv2.cv.CV_FOURCC(*'XVID'), 20.0, (1280,720))
+
+while ret:
+ frame = cv2.flip(frame,-1) # flip frame on both axes
+ out.write(frame) # write it out
+ cv2.imshow('frame',frame) # show for debugging
+
+ ret, frame = vid.read() # read in a new frame
+
+ if cv2.waitKey(1) & 0xFF == ord('q'):
+ break

0 comments on commit f2dc929

Please sign in to comment.