Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
4395c1b9
Commit
4395c1b9
authored
Nov 04, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
videoio: backport "VideoCapture(int index, int apiPreference)" interface
parent
d9b8a9d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
videoio.hpp
modules/videoio/include/opencv2/videoio.hpp
+12
-0
cap.cpp
modules/videoio/src/cap.cpp
+18
-8
No files found.
modules/videoio/include/opencv2/videoio.hpp
View file @
4395c1b9
...
...
@@ -649,6 +649,18 @@ public:
*/
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
The method first calls VideoCapture::release to close the already opened file or camera.
...
...
modules/videoio/src/cap.cpp
View file @
4395c1b9
...
...
@@ -75,6 +75,12 @@ VideoCapture::VideoCapture(int index)
open
(
index
);
}
VideoCapture
::
VideoCapture
(
int
index
,
int
apiPreference
)
{
CV_TRACE_FUNCTION
();
open
(
index
,
apiPreference
);
}
VideoCapture
::~
VideoCapture
()
{
CV_TRACE_FUNCTION
();
...
...
@@ -127,6 +133,17 @@ bool VideoCapture::open(int cameraNum, int apiPreference)
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
();
for
(
size_t
i
=
0
;
i
<
backends
.
size
();
i
++
)
{
...
...
@@ -156,14 +173,7 @@ bool VideoCapture::open(int index)
{
CV_TRACE_FUNCTION
();
// interpret preferred interface (0 = autodetect)
int
backendID
=
(
index
/
100
)
*
100
;
if
(
backendID
)
{
index
%=
100
;
}
return
open
(
index
,
backendID
);
return
open
(
index
,
CAP_ANY
);
}
bool
VideoCapture
::
isOpened
()
const
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment