|
| VideoCapture () |
| Default constructor.
|
|
| VideoCapture (const String &filename, int apiPreference, const std::vector< int > ¶ms) |
| Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters.
|
|
| VideoCapture (const String &filename, int apiPreference=CAP_ANY) |
| Opens a video file or a capturing device or an IP video stream for video capturing with API Preference.
|
|
| VideoCapture (int index, int apiPreference, const std::vector< int > ¶ms) |
| Opens a camera for video capturing with API Preference and parameters.
|
|
| VideoCapture (int index, int apiPreference=CAP_ANY) |
| Opens a camera for video capturing.
|
|
virtual | ~VideoCapture () |
| Default destructor.
|
|
virtual double | get (int propId) const |
| Returns the specified VideoCapture property.
|
|
String | getBackendName () const |
| Returns used backend API name.
|
|
bool | getExceptionMode () const |
| query if exception mode is active
|
|
virtual bool | grab () |
| Grabs the next frame from video file or capturing device.
|
|
virtual bool | isOpened () const |
| Returns true if video capturing has been initialized already.
|
|
virtual bool | open (const String &filename, int apiPreference, const std::vector< int > ¶ms) |
| Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters.
|
|
virtual bool | open (const String &filename, int apiPreference=CAP_ANY) |
| Opens a video file or a capturing device or an IP video stream for video capturing.
|
|
virtual bool | open (int index, int apiPreference, const std::vector< int > ¶ms) |
| Opens a camera for video capturing with API Preference and parameters.
|
|
virtual bool | open (int index, int apiPreference=CAP_ANY) |
| Opens a camera for video capturing.
|
|
virtual VideoCapture & | operator>> (Mat &image) |
| Stream operator to read the next video frame.
|
|
virtual VideoCapture & | operator>> (UMat &image) |
|
virtual bool | read (OutputArray image) |
| Grabs, decodes and returns the next video frame.
|
|
virtual void | release () |
| Closes video file or capturing device.
|
|
virtual bool | retrieve (OutputArray image, int flag=0) |
| Decodes and returns the grabbed video frame.
|
|
virtual bool | set (int propId, double value) |
| Sets a property in the VideoCapture.
|
|
void | setExceptionMode (bool enable) |
|
Class for video capturing from video files, image sequences or cameras.
The class provides C++ API for capturing video from cameras or for reading video files and image sequences.
Here is how the class can be used:
#include <iostream>
#include <stdio.h>
{
int deviceID = 0;
cap.
open(deviceID, apiID);
cerr << "ERROR! Unable to open camera\n";
return -1;
}
cout << "Start grabbing" << endl
<< "Press any key to terminate" << endl;
for (;;)
{
cerr << "ERROR! blank frame grabbed\n";
break;
}
imshow("Live", frame);
if (waitKey(5) >= 0)
break;
}
return 0;
}
n-dimensional dense array class
Definition mat.hpp:829
bool empty() const
Returns true if the array has no elements.
Class for video capturing from video files, image sequences or cameras.
Definition videoio.hpp:747
virtual bool read(OutputArray image)
Grabs, decodes and returns the next video frame.
virtual bool open(const String &filename, int apiPreference=CAP_ANY)
Opens a video file or a capturing device or an IP video stream for video capturing.
virtual bool isOpened() const
Returns true if video capturing has been initialized already.
@ CAP_ANY
Auto detect == 0.
Definition videoio.hpp:96
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3
- Note
- In C API the black-box structure
CvCapture
is used instead of VideoCapture.
-
- (C++) A basic sample on using the VideoCapture interface can be found at
OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cpp
- (Python) A basic sample on using the VideoCapture interface can be found at
OPENCV_SOURCE_CODE/samples/python/video.py
- (Python) A multi threaded video processing sample can be found at
OPENCV_SOURCE_CODE/samples/python/video_threaded.py
- (Python) VideoCapture sample showcasing some features of the Video4Linux2 backend
OPENCV_SOURCE_CODE/samples/python/video_v4l2.py
- Examples
- samples/cpp/camshiftdemo.cpp, samples/cpp/facedetect.cpp, samples/cpp/laplace.cpp, samples/cpp/lkdemo.cpp, samples/cpp/peopledetect.cpp, samples/cpp/polar_transforms.cpp, samples/cpp/segment_objects.cpp, samples/cpp/train_HOG.cpp, samples/cpp/tutorial_code/videoio/video-write/video-write.cpp, samples/cpp/videowriter_basic.cpp, samples/dnn/classification.cpp, samples/dnn/object_detection.cpp, samples/dnn/segmentation.cpp, samples/dnn/text_detection.cpp, and samples/tapi/hog.cpp.
cv::VideoCapture::VideoCapture |
( |
const String & | filename, |
|
|
int | apiPreference, |
|
|
const std::vector< int > & | params ) |
|
explicit |
Python: |
---|
| cv.VideoCapture( | | ) -> | <VideoCapture object> |
| cv.VideoCapture( | filename[, apiPreference] | ) -> | <VideoCapture object> |
| cv.VideoCapture( | filename, apiPreference, params | ) -> | <VideoCapture object> |
| cv.VideoCapture( | index[, apiPreference] | ) -> | <VideoCapture object> |
| cv.VideoCapture( | index, apiPreference, params | ) -> | <VideoCapture object> |
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The params
parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...)
. See cv::VideoCaptureProperties
cv::VideoCapture::VideoCapture |
( |
int | index, |
|
|
int | apiPreference, |
|
|
const std::vector< int > & | params ) |
|
explicit |
Python: |
---|
| cv.VideoCapture( | | ) -> | <VideoCapture object> |
| cv.VideoCapture( | filename[, apiPreference] | ) -> | <VideoCapture object> |
| cv.VideoCapture( | filename, apiPreference, params | ) -> | <VideoCapture object> |
| cv.VideoCapture( | index[, apiPreference] | ) -> | <VideoCapture object> |
| cv.VideoCapture( | index, apiPreference, params | ) -> | <VideoCapture object> |
Opens a camera for video capturing with API Preference and parameters.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The params
parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...)
. See cv::VideoCaptureProperties
virtual bool cv::VideoCapture::grab |
( |
| ) |
|
|
virtual |
Python: |
---|
| cv.VideoCapture.grab( | | ) -> | retval |
Grabs the next frame from video file or capturing device.
- Returns
true
(non-zero) in the case of success.
The method/function grabs the next frame from video file or camera and returns true (non-zero) in the case of success.
The primary use of the function is in multi-camera environments, especially when the cameras do not have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames from different cameras will be closer in time.
Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the correct way of retrieving data from it is to call VideoCapture::grab() first and then call VideoCapture::retrieve() one or more times with different values of the channel parameter.
Using Kinect and other OpenNI compatible depth sensors
virtual bool cv::VideoCapture::open |
( |
const String & | filename, |
|
|
int | apiPreference, |
|
|
const std::vector< int > & | params ) |
|
virtual |
Python: |
---|
| cv.VideoCapture.open( | filename[, apiPreference] | ) -> | retval |
| cv.VideoCapture.open( | filename, apiPreference, params | ) -> | retval |
| cv.VideoCapture.open( | index[, apiPreference] | ) -> | retval |
| cv.VideoCapture.open( | index, apiPreference, params | ) -> | retval |
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The params
parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...)
. See cv::VideoCaptureProperties
- Returns
true
if the file has been successfully opened
The method first calls VideoCapture::release to close the already opened file or camera.
virtual bool cv::VideoCapture::open |
( |
int | index, |
|
|
int | apiPreference, |
|
|
const std::vector< int > & | params ) |
|
virtual |
Python: |
---|
| cv.VideoCapture.open( | filename[, apiPreference] | ) -> | retval |
| cv.VideoCapture.open( | filename, apiPreference, params | ) -> | retval |
| cv.VideoCapture.open( | index[, apiPreference] | ) -> | retval |
| cv.VideoCapture.open( | index, apiPreference, params | ) -> | retval |
Opens a camera for video capturing with API Preference and parameters.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The params
parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...)
. See cv::VideoCaptureProperties
- Returns
true
if the camera has been successfully opened.
The method first calls VideoCapture::release to close the already opened file or camera.
virtual bool cv::VideoCapture::open |
( |
int | index, |
|
|
int | apiPreference = CAP_ANY ) |
|
virtual |
Python: |
---|
| cv.VideoCapture.open( | filename[, apiPreference] | ) -> | retval |
| cv.VideoCapture.open( | filename, apiPreference, params | ) -> | retval |
| cv.VideoCapture.open( | index[, apiPreference] | ) -> | retval |
| cv.VideoCapture.open( | index, apiPreference, params | ) -> | retval |
Opens a camera for video capturing.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)
- Returns
true
if the camera has been successfully opened.
The method first calls VideoCapture::release to close the already opened file or camera.