OpenCV a single and extremely easy-to-use class called VideoCapture
for reading videos (or image sequences) from files saved on disk, or from capture devices, cameras, or a network video stream (for instance an RTSP address on the internet). You can simply use the open
function to try a video from any of the mentioned source types and use the read
function to grab video frames into images. Here's an example:
VideoCapture video; video.open("c:/dev/test.avi"); if(video.isOpened()) { Mat frame; while(true) { if(video.read(frame)) { // Process the frame ... } else { break; } } } video.release();
If you want to load an image sequence, you simply need to replace the filename with the file path pattern. For instance, image_%02d.png
will read images with filenames like image_00.png
, image_01.png
, image_02.png
...