[−][src]Struct opencv::videoio::VideoCapture
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 samples/cpp/videocapture_basic.cpp
Note: In @ref videoio_c "C API" the black-box structure CvCapture
is used instead of %VideoCapture.
Note:
- (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
Implementations
impl VideoCapture
[src]
pub fn as_raw_VideoCapture(&self) -> *const c_void
[src]
pub fn as_raw_mut_VideoCapture(&mut self) -> *mut c_void
[src]
impl VideoCapture
[src]
pub fn default() -> Result<VideoCapture>
[src]
Default constructor
Note: In @ref videoio_c "C API", when you finished working with video, release CvCapture structure with cvReleaseCapture(), or use Ptr<CvCapture> that calls cvReleaseCapture() automatically in the destructor.
pub fn from_file(filename: &str, api_preference: i32) -> Result<VideoCapture>
[src]
Default constructor
Note: In @ref videoio_c "C API", when you finished working with video, release CvCapture structure with cvReleaseCapture(), or use Ptr<CvCapture> that calls cvReleaseCapture() automatically in the destructor.
Overloaded parameters
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
Parameters
- filename: it can be:
- name of video file (eg.
video.avi
) - or image sequence (eg.
img_%02d.jpg
, which will read samples likeimg_00.jpg, img_01.jpg, img_02.jpg, ...
) - or URL of video stream (eg.
protocol://host:port/script_name?script_params|auth
) - or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend Note that each video stream or IP camera feed has its own URL scheme. Please refer to the documentation of source stream to know the right URL.
- name of video file (eg.
- apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
See also
cv::VideoCaptureAPIs
C++ default parameters
- api_preference: CAP_ANY
pub fn new(index: i32, api_preference: i32) -> Result<VideoCapture>
[src]
Default constructor
Note: In @ref videoio_c "C API", when you finished working with video, release CvCapture structure with cvReleaseCapture(), or use Ptr<CvCapture> that calls cvReleaseCapture() automatically in the destructor.
Overloaded parameters
Opens a camera for video capturing
Parameters
- index: id of the video capturing device to open. To open default camera using default backend just pass 0. (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)
- apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.
See also
cv::VideoCaptureAPIs
C++ default parameters
- api_preference: CAP_ANY
pub fn wait_any(
streams: &Vector<VideoCapture>,
ready_index: &mut Vector<i32>,
timeout_ns: i64
) -> Result<bool>
[src]
streams: &Vector<VideoCapture>,
ready_index: &mut Vector<i32>,
timeout_ns: i64
) -> Result<bool>
Wait for ready frames from VideoCapture.
Parameters
- streams: input video streams
- readyIndex: stream indexes with grabbed frames (ready to use .retrieve() to fetch actual frame)
- timeoutNs: number of nanoseconds (0 - infinite)
Returns
true
if streamReady is not empty
@throws Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported
The primary use of the function is in multi-camera environments. The method fills the ready state vector, grabs video frame, if camera is ready.
After this call use VideoCapture::retrieve() to decode and fetch frame data.
C++ default parameters
- timeout_ns: 0
Trait Implementations
impl Boxed for VideoCapture
[src]
pub unsafe fn from_raw(ptr: *mut c_void) -> Self
[src]
pub fn into_raw(self) -> *mut c_void
[src]
pub fn as_raw(&self) -> *const c_void
[src]
pub fn as_raw_mut(&mut self) -> *mut c_void
[src]
impl Drop for VideoCapture
[src]
impl Send for VideoCapture
[src]
impl VectorElement for VideoCapture where
Vector<VideoCapture>: VectorExtern<VideoCapture>,
[src]
Vector<VideoCapture>: VectorExtern<VideoCapture>,
pub fn opencv_vector_to_vec(v: &Vector<VideoCapture>) -> Vec<VideoCapture>
[src]
impl VideoCaptureTrait for VideoCapture
[src]
pub fn as_raw_VideoCapture(&self) -> *const c_void
[src]
pub fn as_raw_mut_VideoCapture(&mut self) -> *mut c_void
[src]
pub fn open_file(&mut self, filename: &str, api_preference: i32) -> Result<bool>
[src]
pub fn open(&mut self, index: i32, api_preference: i32) -> Result<bool>
[src]
pub fn is_opened(&self) -> Result<bool>
[src]
pub fn release(&mut self) -> Result<()>
[src]
pub fn grab(&mut self) -> Result<bool>
[src]
pub fn retrieve(
&mut self,
image: &mut dyn ToOutputArray,
flag: i32
) -> Result<bool>
[src]
&mut self,
image: &mut dyn ToOutputArray,
flag: i32
) -> Result<bool>
pub fn read(&mut self, image: &mut dyn ToOutputArray) -> Result<bool>
[src]
pub fn set(&mut self, prop_id: i32, value: f64) -> Result<bool>
[src]
pub fn get(&self, prop_id: i32) -> Result<f64>
[src]
pub fn get_backend_name(&self) -> Result<String>
[src]
pub fn set_exception_mode(&mut self, enable: bool) -> Result<()>
[src]
pub fn get_exception_mode(&mut self) -> Result<bool>
[src]
Auto Trait Implementations
impl RefUnwindSafe for VideoCapture
[src]
impl !Sync for VideoCapture
[src]
impl Unpin for VideoCapture
[src]
impl UnwindSafe for VideoCapture
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,