Created
August 14, 2012 07:07
-
-
Save jayrambhia/3347099 to your computer and use it in GitHub Desktop.
Utilities for capture in OpenCV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import cv2.cv as cv | |
""" | |
Got the idea from http://newpathprep.wordpress.com/2012/08/13/opencv-forward-and-rewind-avi/ | |
He has done it in C++. | |
""" | |
def start(capture, n): | |
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES, n-1) | |
def rewind(capture): | |
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES, 0) | |
def getFrame(capture, frame): | |
number_frame = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES)) | |
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES, frame-1) | |
img = cv.QueryFrame(capture) | |
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES, number_frame) | |
return img | |
def skipFrames(capture, n): | |
number_frame = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES)) | |
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES, number_frame + n - 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment