From the course: Introduction to Deep Learning with OpenCV

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Viewing videos in OpenCV

Viewing videos in OpenCV

- So let's get started with viewing videos in OpenCv. So remember to activate your virtual environment, so atom video.py. So we need to import the cv2 and numpy modules as usual, so import numpy as np, import cv2 and we then create a video capture object and read in the input file to check to see that it can open the file. So let's say cap equals cv2.videocapture and then provide the path to the file. So that's in images/shore.mov. Now, if you wanted to use your webcam as input instead, then you'd replace the path with a zero. So let's make sure that we can actually open that file, so if cap.isOpened equals false, you then want to print a message, so print, 'Cannot open file or video stream'. So let's save this file, and let's check out this bit of code. So python, and since we haven't had any prompt here, we know that it can open that file. Next, we need to look through and read and display video frames until either the video is completed or the user quits by typing an escape key so…

Contents