Equations

Friday, June 7, 2013

Frame Capture Issue with OpenCV under Windows 7

A serious issue that arises when using OpenCV under windows 7 is the use of opencv_highgui or openCVFrameGrabber for capturing frames from WebCam or a video file. In this case, OpenCv uses video for windows codec which isn’t always working well under windows 7.


A solution to this problem is to use VideoInputFrameGrabber for WebCam which uses DirectShow and FFmpegFrameGrabber with a version of FFmpeg codec to read video files.

Javacv code sample:

FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(new File(video_file_path));
try {
    grabber.start();
    for (int i = 0; i < 10; i++) {
        opencv_core.IplImage currentFrame = grabber.grab();
        ......
    }
} catch (Exception ex) {
    .....
}

No comments:

Post a Comment