diff --git a/EyeTab/EyeTab.cpp b/EyeTab/EyeTab.cpp index df207c6..3d86372 100644 --- a/EyeTab/EyeTab.cpp +++ b/EyeTab/EyeTab.cpp @@ -32,7 +32,7 @@ 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; @@ -40,16 +40,12 @@ int main(int argc, const char** argv) // 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; } } diff --git a/EyeTab/videos/output.avi b/EyeTab/videos/output.avi new file mode 100644 index 0000000..275dbc1 Binary files /dev/null and b/EyeTab/videos/output.avi differ diff --git a/EyeTab/videos/sample_video.avi b/EyeTab/videos/sample_video.avi new file mode 100644 index 0000000..ea42953 Binary files /dev/null and b/EyeTab/videos/sample_video.avi differ diff --git a/EyeTab/videos/video_flipper.py b/EyeTab/videos/video_flipper.py new file mode 100644 index 0000000..e73af19 --- /dev/null +++ b/EyeTab/videos/video_flipper.py @@ -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 \ No newline at end of file