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
f1fdfa1a
Commit
f1fdfa1a
authored
Oct 11, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12623 from sturkmen72:videoio-4
parents
0f3fe957
59bf2a34
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
81 deletions
+48
-81
videoio.hpp
modules/videoio/include/opencv2/videoio.hpp
+20
-42
cap.cpp
modules/videoio/src/cap.cpp
+24
-33
hog.cpp
samples/tapi/hog.cpp
+4
-6
No files found.
modules/videoio/include/opencv2/videoio.hpp
View file @
f1fdfa1a
...
...
@@ -617,14 +617,7 @@ public:
CV_WRAP
VideoCapture
();
/** @overload
@brief Open video file or a capturing device or a IP video stream for video capturing
Same as VideoCapture(const String& filename, int apiPreference) but using default Capture API backends
*/
CV_WRAP
VideoCapture
(
const
String
&
filename
);
/** @overload
@brief Open video file or a capturing device or a IP video stream for video capturing with API Preference
@brief Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
@param filename it can be:
- name of video file (eg. `video.avi`)
...
...
@@ -636,18 +629,19 @@ public:
implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
@sa The list of supported API backends cv::VideoCaptureAPIs
*/
CV_WRAP
VideoCapture
(
const
String
&
filename
,
int
apiPreference
);
CV_WRAP
VideoCapture
(
const
String
&
filename
,
int
apiPreference
=
CAP_ANY
);
/** @overload
@brief Open a camera for video capturing
@brief Open
s
a camera for video capturing
@param index camera_id + domain_offset (CAP_*) id of the video capturing device to open. To open default camera using default backend just pass 0.
Use a `domain_offset` to enforce a specific reader implementation if multiple are available like cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
e.g. to open Camera 1 using the MS Media Foundation API use `index = 1 + cv::CAP_MSMF`
@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_V4L.
@sa The list of supported API backends cv::VideoCaptureAPIs
*/
CV_WRAP
VideoCapture
(
int
index
);
CV_WRAP
VideoCapture
(
int
index
,
int
apiPreference
=
CAP_ANY
);
/** @brief Default destructor
...
...
@@ -655,37 +649,27 @@ public:
*/
virtual
~
VideoCapture
();
/** @brief Open
video file or a capturing device or a IP video stream for video capturing
/** @brief Open
s a video file or a capturing device or an IP video stream for video capturing.
@overload
Parameters are same as the constructor VideoCapture(const String& filename)
Parameters are same as the constructor VideoCapture(const String& filename
, int apiPreference = CAP_ANY
)
@return `true` if the file has been successfully opened
The method first calls VideoCapture::release to close the already opened file or camera.
*/
CV_WRAP
virtual
bool
open
(
const
String
&
filename
);
CV_WRAP
virtual
bool
open
(
const
String
&
filename
,
int
apiPreference
=
CAP_ANY
);
/** @brief Open a camera for video capturing
/** @brief Open
s
a camera for video capturing
@overload
Parameters are same as the constructor VideoCapture(int index)
Parameters are same as the constructor VideoCapture(int index
, int apiPreference = CAP_ANY
)
@return `true` if the camera has been successfully opened.
The method first calls VideoCapture::release to close the already opened file or camera.
*/
CV_WRAP
virtual
bool
open
(
int
index
);
/** @brief Open a camera for video capturing
@overload
Parameters are similar as the constructor VideoCapture(int index),except it takes an additional argument apiPreference.
Definitely, is same as open(int index) where `index=cameraNum + apiPreference`
@return `true` if the camera has been successfully opened.
*/
CV_WRAP
bool
open
(
int
cameraNum
,
int
apiPreference
);
CV_WRAP
virtual
bool
open
(
int
index
,
int
apiPreference
=
CAP_ANY
);
/** @brief Returns true if video capturing has been initialized already.
...
...
@@ -798,17 +782,6 @@ public:
*/
CV_WRAP
virtual
double
get
(
int
propId
)
const
;
/** @brief Open video file or a capturing device or a IP video stream for video capturing with API Preference
@overload
Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference)
@return `true` if the file has been successfully opened
The method first calls VideoCapture::release to close the already opened file or camera.
*/
CV_WRAP
virtual
bool
open
(
const
String
&
filename
,
int
apiPreference
);
/** @brief Returns used backend API name
@note Stream should be opened.
...
...
@@ -915,6 +888,11 @@ public:
*/
virtual
VideoWriter
&
operator
<<
(
const
Mat
&
image
);
/** @overload
@sa write
*/
virtual
VideoWriter
&
operator
<<
(
const
UMat
&
image
);
/** @brief Writes the next video frame
@param image The written frame. In general, color images are expected in BGR format.
...
...
@@ -922,7 +900,7 @@ public:
The function/method writes the specified image to video file. It must have the same size as has
been specified when opening the video writer.
*/
CV_WRAP
virtual
void
write
(
const
Mat
&
image
);
CV_WRAP
virtual
void
write
(
InputArray
image
);
/** @brief Sets a property in the VideoWriter.
...
...
modules/videoio/src/cap.cpp
View file @
f1fdfa1a
...
...
@@ -59,16 +59,10 @@ VideoCapture::VideoCapture(const String& filename, int apiPreference)
open
(
filename
,
apiPreference
);
}
VideoCapture
::
VideoCapture
(
const
String
&
filenam
e
)
VideoCapture
::
VideoCapture
(
int
index
,
int
apiPreferenc
e
)
{
CV_TRACE_FUNCTION
();
open
(
filename
,
CAP_ANY
);
}
VideoCapture
::
VideoCapture
(
int
index
)
{
CV_TRACE_FUNCTION
();
open
(
index
);
open
(
index
,
apiPreference
);
}
VideoCapture
::~
VideoCapture
()
...
...
@@ -110,19 +104,23 @@ bool VideoCapture::open(const String& filename, int apiPreference)
return
false
;
}
bool
VideoCapture
::
open
(
const
String
&
filename
)
{
CV_TRACE_FUNCTION
();
return
open
(
filename
,
CAP_ANY
);
}
bool
VideoCapture
::
open
(
int
cameraNum
,
int
apiPreference
)
{
CV_TRACE_FUNCTION
();
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
++
)
{
...
...
@@ -148,20 +146,6 @@ bool VideoCapture::open(int cameraNum, int apiPreference)
return
false
;
}
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
);
}
bool
VideoCapture
::
isOpened
()
const
{
if
(
!
icap
.
empty
())
...
...
@@ -268,7 +252,7 @@ VideoCapture& VideoCapture::operator >> (UMat& image)
bool
VideoCapture
::
set
(
int
propId
,
double
value
)
{
CV_CheckNE
(
propId
,
(
int
)
CAP_PROP_BACKEND
,
"Can set read-only property"
);
CV_CheckNE
(
propId
,
(
int
)
CAP_PROP_BACKEND
,
"Can
't
set read-only property"
);
if
(
!
icap
.
empty
())
return
icap
->
setProperty
(
propId
,
value
);
...
...
@@ -367,7 +351,7 @@ bool VideoWriter::isOpened() const
bool
VideoWriter
::
set
(
int
propId
,
double
value
)
{
CV_CheckNE
(
propId
,
(
int
)
CAP_PROP_BACKEND
,
"Can set read-only property"
);
CV_CheckNE
(
propId
,
(
int
)
CAP_PROP_BACKEND
,
"Can
't
set read-only property"
);
if
(
!
iwriter
.
empty
())
return
iwriter
->
setProperty
(
propId
,
value
);
...
...
@@ -403,7 +387,7 @@ String VideoWriter::getBackendName() const
return
cv
::
videoio_registry
::
getBackendName
((
VideoCaptureAPIs
)
api
);
}
void
VideoWriter
::
write
(
const
Mat
&
image
)
void
VideoWriter
::
write
(
InputArray
image
)
{
CV_INSTRUMENT_REGION
();
...
...
@@ -411,7 +395,7 @@ void VideoWriter::write(const Mat& image)
iwriter
->
write
(
image
);
else
{
IplImage
_img
=
cvIplImage
(
image
);
IplImage
_img
=
cvIplImage
(
image
.
getMat
()
);
cvWriteFrame
(
writer
,
&
_img
);
}
}
...
...
@@ -424,6 +408,13 @@ VideoWriter& VideoWriter::operator << (const Mat& image)
return
*
this
;
}
VideoWriter
&
VideoWriter
::
operator
<<
(
const
UMat
&
image
)
{
CV_INSTRUMENT_REGION
();
write
(
image
);
return
*
this
;
}
// FIXIT OpenCV 4.0: make inline
int
VideoWriter
::
fourcc
(
char
c1
,
char
c2
,
char
c3
,
char
c4
)
{
...
...
samples/tapi/hog.cpp
View file @
f1fdfa1a
...
...
@@ -64,7 +64,7 @@ int main(int argc, char** argv)
"{ v video | ../data/vtest.avi | use video as input }"
"{ g gray | | convert image to gray one or not}"
"{ s scale | 1.0 | resize the image before detect}"
"{ o output |
| specify output path when input is images}"
;
"{ o output |
output.avi
| specify output path when input is images}"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
has
(
"help"
))
{
...
...
@@ -175,8 +175,7 @@ void App::run()
throw
runtime_error
(
string
(
"can't open image file: "
+
img_source
));
}
UMat
img_aux
,
img
;
Mat
img_to_show
;
UMat
img_aux
,
img
,
img_to_show
;
// Iterate over all frames
while
(
running
&&
!
frame
.
empty
())
...
...
@@ -209,8 +208,7 @@ void App::run()
// Draw positive classified windows
for
(
size_t
i
=
0
;
i
<
found
.
size
();
i
++
)
{
Rect
r
=
found
[
i
];
rectangle
(
img_to_show
,
r
.
tl
(),
r
.
br
(),
Scalar
(
0
,
255
,
0
),
3
);
rectangle
(
img_to_show
,
found
[
i
],
Scalar
(
0
,
255
,
0
),
3
);
}
putText
(
img_to_show
,
ocl
::
useOpenCL
()
?
"Mode: OpenCL"
:
"Mode: CPU"
,
Point
(
5
,
25
),
FONT_HERSHEY_SIMPLEX
,
1.
,
Scalar
(
255
,
100
,
0
),
2
);
...
...
@@ -241,7 +239,7 @@ void App::run()
if
(
make_gray
)
cvtColor
(
img_to_show
,
img
,
COLOR_GRAY2BGR
);
else
cvtColor
(
img_to_show
,
img
,
COLOR_BGRA2BGR
);
video_writer
<<
img
.
getMat
(
ACCESS_READ
)
;
video_writer
<<
img
;
}
}
...
...
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