|
OpenCV 2.4.2 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opencv.highgui.VideoCapture
public class VideoCapture
Class for video capturing from video files or cameras. The class provides C++ API for capturing video from cameras or for reading video files. Here is how the class can be used:
Note: In C API the black-box structure CvCapture
is used instead
of VideoCapture
.
Field Summary | |
---|---|
protected long |
nativeObj
|
Constructor Summary | |
---|---|
|
VideoCapture()
VideoCapture constructors. |
|
VideoCapture(int device)
VideoCapture constructors. |
protected |
VideoCapture(long addr)
|
Method Summary | |
---|---|
protected void |
finalize()
|
double |
get(int propId)
Returns the specified "VideoCapture" property Note: When querying a property that is not supported by the backend used by the "VideoCapture" class, value 0 is returned. |
java.util.List<Size> |
getSupportedPreviewSizes()
|
boolean |
grab()
Grabs the next frame from video file or capturing device. |
boolean |
isOpened()
Returns true if video capturing has been initialized already. |
boolean |
open(int device)
Open video file or a capturing device for video capturing The methods first call "VideoCapture.release" to close the already opened file or camera. |
boolean |
read(Mat image)
Grabs, decodes and returns the next video frame. |
void |
release()
Closes video file or capturing device. |
boolean |
retrieve(Mat image)
Decodes and returns the grabbed video frame. |
boolean |
retrieve(Mat image,
int channel)
Decodes and returns the grabbed video frame. |
boolean |
set(int propId,
double value)
Sets a property in the "VideoCapture". |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final long nativeObj
Constructor Detail |
---|
public VideoCapture()
VideoCapture constructors.
Note: In C API, when you finished working with video, release
CvCapture
structure with cvReleaseCapture()
, or use
Ptr
that calls cvReleaseCapture()
automatically in the destructor.
public VideoCapture(int device)
VideoCapture constructors.
Note: In C API, when you finished working with video, release
CvCapture
structure with cvReleaseCapture()
, or use
Ptr
that calls cvReleaseCapture()
automatically in the destructor.
device
- id of the opened video capturing device (i.e. a camera index).
If there is a single camera connected, just pass 0.protected VideoCapture(long addr)
Method Detail |
---|
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public double get(int propId)
propId
- Property identifier. It can be one of the following:
* CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.
* CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream.public java.util.List<Size> getSupportedPreviewSizes()
public boolean grab()
Grabs the next frame from video file or capturing device.
The methods/functions grab the next frame from video file or camera and return 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. See
http://code.opencv.org/svn/opencv/trunk/opencv/samples/cpp/kinect_maps.cpp
public boolean isOpened()
Returns true if video capturing has been initialized already.
If the previous call to VideoCapture
constructor or
VideoCapture.open
succeeded, the method returns true.
public boolean open(int device)
Open video file or a capturing device for video capturing
The methods first call "VideoCapture.release" to close the already opened file or camera.
device
- id of the opened video capturing device (i.e. a camera index).public boolean read(Mat image)
Grabs, decodes and returns the next video frame.
The methods/functions combine "VideoCapture.grab" and "VideoCapture.retrieve" in one call. This is the most convenient method for reading video files or capturing data from decode and return the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the methods return false and the functions return NULL pointer.
Note: OpenCV 1.x functions cvRetrieveFrame
and cv.RetrieveFrame
return image stored inside the video capturing structure. It is not allowed
to modify or release the image! You can copy the frame using "cvCloneImage"
and then do whatever you want with the copy.
image
- a imagepublic void release()
Closes video file or capturing device.
The methods are automatically called by subsequent "VideoCapture.open" and
by VideoCapture
destructor.
The C function also deallocates memory and clears *capture
pointer.
public boolean retrieve(Mat image)
Decodes and returns the grabbed video frame.
The methods/functions decode and return the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the methods return false and the functions return NULL pointer.
Note: OpenCV 1.x functions cvRetrieveFrame
and cv.RetrieveFrame
return image stored inside the video capturing structure. It is not allowed
to modify or release the image! You can copy the frame using "cvCloneImage"
and then do whatever you want with the copy.
image
- a imagepublic boolean retrieve(Mat image, int channel)
Decodes and returns the grabbed video frame.
The methods/functions decode and return the just grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the methods return false and the functions return NULL pointer.
Note: OpenCV 1.x functions cvRetrieveFrame
and cv.RetrieveFrame
return image stored inside the video capturing structure. It is not allowed
to modify or release the image! You can copy the frame using "cvCloneImage"
and then do whatever you want with the copy.
image
- a imagechannel
- a channelpublic boolean set(int propId, double value)
propId
- Property identifier. It can be one of the following:
* CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.
* CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream.value
- Value of the property.
|
Official OpenCV 2.4 Documentation | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |