Skip to Content
Computer Vision with OpenCV 3 and Qt5
book

Computer Vision with OpenCV 3 and Qt5

by Amin Ahmadi Tazehkandi
January 2018
Intermediate to advanced content levelIntermediate to advanced
486 pages
11h 28m
English
Packt Publishing
Content preview from Computer Vision with OpenCV 3 and Qt5

Reading and writing videos in OpenCV

OpenCV provides 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 opening a video from any of the mentioned source types and then use the read function to grab incoming 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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering OpenCV 4 - Third Edition

Mastering OpenCV 4 - Third Edition

Roy Shilkrot, David Millán Escrivá
Hands-On Computer Vision with TensorFlow 2

Hands-On Computer Vision with TensorFlow 2

Benjamin Planche, Eliot Andres
OpenCV 4 with Python Blueprints - Second Edition

OpenCV 4 with Python Blueprints - Second Edition

Dr. Menua Gevorgyan, Michael Beyeler (USD), Arsen Mamikonyan, Michael Beyeler

Publisher Resources

ISBN: 9781788472395Supplemental Content