mirror of
https://github.com/opencv/opencv.git
synced 2025-06-29 16:11:00 +08:00
Merge pull request #13043 from alalek:compatibility_12623
This commit is contained in:
commit
c72b6b3be8
@ -649,6 +649,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
CV_WRAP VideoCapture(int index);
|
CV_WRAP VideoCapture(int index);
|
||||||
|
|
||||||
|
/** @overload
|
||||||
|
@brief Opens a camera for video capturing
|
||||||
|
|
||||||
|
@param 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)
|
||||||
|
@param 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_V4L2.
|
||||||
|
|
||||||
|
@sa The list of supported API backends cv::VideoCaptureAPIs
|
||||||
|
*/
|
||||||
|
CV_WRAP VideoCapture(int index, int apiPreference);
|
||||||
|
|
||||||
/** @brief Default destructor
|
/** @brief Default destructor
|
||||||
|
|
||||||
The method first calls VideoCapture::release to close the already opened file or camera.
|
The method first calls VideoCapture::release to close the already opened file or camera.
|
||||||
|
@ -75,6 +75,12 @@ VideoCapture::VideoCapture(int index)
|
|||||||
open(index);
|
open(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VideoCapture::VideoCapture(int index, int apiPreference)
|
||||||
|
{
|
||||||
|
CV_TRACE_FUNCTION();
|
||||||
|
open(index, apiPreference);
|
||||||
|
}
|
||||||
|
|
||||||
VideoCapture::~VideoCapture()
|
VideoCapture::~VideoCapture()
|
||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
@ -127,6 +133,17 @@ bool VideoCapture::open(int cameraNum, int apiPreference)
|
|||||||
|
|
||||||
if (isOpened()) release();
|
if (isOpened()) release();
|
||||||
|
|
||||||
|
if (apiPreference == CAP_ANY)
|
||||||
|
{
|
||||||
|
// interpret preferred interface (0 = autodetect)
|
||||||
|
int backendID = (cameraNum / 100) * 100;
|
||||||
|
if (backendID)
|
||||||
|
{
|
||||||
|
cameraNum %= 100;
|
||||||
|
apiPreference = backendID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<VideoBackendInfo> backends = cv::videoio_registry::getAvailableBackends_CaptureByIndex();
|
const std::vector<VideoBackendInfo> backends = cv::videoio_registry::getAvailableBackends_CaptureByIndex();
|
||||||
for (size_t i = 0; i < backends.size(); i++)
|
for (size_t i = 0; i < backends.size(); i++)
|
||||||
{
|
{
|
||||||
@ -156,14 +173,7 @@ bool VideoCapture::open(int index)
|
|||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
|
|
||||||
// interpret preferred interface (0 = autodetect)
|
return open(index, CAP_ANY);
|
||||||
int backendID = (index / 100) * 100;
|
|
||||||
if (backendID)
|
|
||||||
{
|
|
||||||
index %= 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
return open(index, backendID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoCapture::isOpened() const
|
bool VideoCapture::isOpened() const
|
||||||
|
Loading…
Reference in New Issue
Block a user