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
f1c16f42
Commit
f1c16f42
authored
Jun 14, 2017
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
video: add one more constructor for VideoWriter
parent
26e9b42a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
39 deletions
+87
-39
videoio.hpp
modules/videoio/include/opencv2/videoio.hpp
+20
-1
videoio_c.h
modules/videoio/include/opencv2/videoio/videoio_c.h
+2
-1
cap.cpp
modules/videoio/src/cap.cpp
+61
-37
precomp.hpp
modules/videoio/src/precomp.hpp
+4
-0
No files found.
modules/videoio/include/opencv2/videoio.hpp
View file @
f1c16f42
...
@@ -114,7 +114,8 @@ enum VideoCaptureAPIs {
...
@@ -114,7 +114,8 @@ enum VideoCaptureAPIs {
CAP_GSTREAMER
=
1800
,
//!< GStreamer
CAP_GSTREAMER
=
1800
,
//!< GStreamer
CAP_FFMPEG
=
1900
,
//!< Open and record video file or stream using the FFMPEG library
CAP_FFMPEG
=
1900
,
//!< Open and record video file or stream using the FFMPEG library
CAP_IMAGES
=
2000
,
//!< OpenCV Image Sequence (e.g. img_%02d.jpg)
CAP_IMAGES
=
2000
,
//!< OpenCV Image Sequence (e.g. img_%02d.jpg)
CAP_ARAVIS
=
2100
//!< Aravis SDK
CAP_ARAVIS
=
2100
,
//!< Aravis SDK
CAP_OCV_MJPEG
=
2200
//!< Built-in MotionJPEG codec
};
};
/** @brief %VideoCapture generic properties identifier.
/** @brief %VideoCapture generic properties identifier.
...
@@ -849,6 +850,13 @@ public:
...
@@ -849,6 +850,13 @@ public:
CV_WRAP
VideoWriter
(
const
String
&
filename
,
int
fourcc
,
double
fps
,
CV_WRAP
VideoWriter
(
const
String
&
filename
,
int
fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
=
true
);
Size
frameSize
,
bool
isColor
=
true
);
/** @overload
The `apiPreference` parameter allows to specify 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_GSTREAMER.
*/
CV_WRAP
VideoWriter
(
int
apiPreference
,
const
String
&
filename
,
int
fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
=
true
);
/** @brief Default destructor
/** @brief Default destructor
The method first calls VideoWriter::release to close the already opened file.
The method first calls VideoWriter::release to close the already opened file.
...
@@ -866,6 +874,17 @@ public:
...
@@ -866,6 +874,17 @@ public:
CV_WRAP
virtual
bool
open
(
const
String
&
filename
,
int
fourcc
,
double
fps
,
CV_WRAP
virtual
bool
open
(
const
String
&
filename
,
int
fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
=
true
);
Size
frameSize
,
bool
isColor
=
true
);
/** @brief Initializes or reinitializes video writer.
The method opens video writer. Parameters are the same as in the constructor
VideoWriter::VideoWriter.
@return `true` if video writer has been successfully initialized
The method first calls VideoWriter::release to close the already opened file.
*/
CV_WRAP
bool
open
(
int
apiPreference
,
const
String
&
filename
,
int
fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
=
true
);
/** @brief Returns true if video writer has been successfully initialized.
/** @brief Returns true if video writer has been successfully initialized.
*/
*/
CV_WRAP
virtual
bool
isOpened
()
const
;
CV_WRAP
virtual
bool
isOpened
()
const
;
...
...
modules/videoio/include/opencv2/videoio/videoio_c.h
View file @
f1c16f42
...
@@ -124,7 +124,8 @@ enum
...
@@ -124,7 +124,8 @@ enum
CV_CAP_FFMPEG
=
1900
,
// FFMPEG
CV_CAP_FFMPEG
=
1900
,
// FFMPEG
CV_CAP_IMAGES
=
2000
,
// OpenCV Image Sequence (e.g. img_%02d.jpg)
CV_CAP_IMAGES
=
2000
,
// OpenCV Image Sequence (e.g. img_%02d.jpg)
CV_CAP_ARAVIS
=
2100
// Aravis GigE SDK
CV_CAP_ARAVIS
=
2100
,
// Aravis GigE SDK
CV_CAP_OCV_MJPEG
=
2200
// Built-in MotionJPEG codec
};
};
/** @brief start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*)
/** @brief start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*)
...
...
modules/videoio/src/cap.cpp
View file @
f1c16f42
...
@@ -371,47 +371,59 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
...
@@ -371,47 +371,59 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
CV_IMPL
CvVideoWriter
*
cvCreateVideoWriter
(
const
char
*
filename
,
int
fourcc
,
CV_IMPL
CvVideoWriter
*
cvCreateVideoWriter
(
const
char
*
filename
,
int
fourcc
,
double
fps
,
CvSize
frameSize
,
int
is_color
)
double
fps
,
CvSize
frameSize
,
int
is_color
)
{
{
// If none of the writers is used
return
cvCreateVideoWriterWithPreference
(
CV_CAP_ANY
,
filename
,
fourcc
,
fps
,
frameSize
,
is_color
);
// these statements suppress 'unused parameter' warnings.
}
CvVideoWriter
*
cvCreateVideoWriterWithPreference
(
int
apiPreference
,
const
char
*
filename
,
int
fourcc
,
double
fps
,
CvSize
frameSize
,
int
is_color
)
{
CV_UNUSED
(
frameSize
);
CV_UNUSED
(
frameSize
);
CV_UNUSED
(
is_color
);
CV_UNUSED
(
is_color
);
//CV_FUNCNAME( "cvCreateVideoWriter" );
CvVideoWriter
*
result
=
0
;
CvVideoWriter
*
result
=
0
;
if
(
!
fourcc
||
!
fps
)
if
(
!
fourcc
||
!
fps
)
TRY_OPEN
(
result
,
cvCreateVideoWriter_Images
(
filename
))
TRY_OPEN
(
result
,
cvCreateVideoWriter_Images
(
filename
))
#ifdef HAVE_FFMPEG
switch
(
apiPreference
)
TRY_OPEN
(
result
,
cvCreateVideoWriter_FFMPEG_proxy
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
{
#endif
default
:
//exit if the specified API is unavaliable
#ifdef HAVE_VFW
if
(
apiPreference
!=
CV_CAP_ANY
)
break
;
TRY_OPEN
(
result
,
cvCreateVideoWriter_VFW
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
#ifdef HAVE_FFMPEG
#endif
case
CV_CAP_FFMPEG
:
TRY_OPEN
(
result
,
cvCreateVideoWriter_FFMPEG_proxy
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
#ifdef HAVE_MSMF
if
(
apiPreference
!=
CV_CAP_ANY
)
break
;
TRY_OPEN
(
result
,
cvCreateVideoWriter_MSMF
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
#endif
#endif
#ifdef HAVE_VFW
case
CV_CAP_VFW
:
/* #ifdef HAVE_XINE
TRY_OPEN
(
result
,
cvCreateVideoWriter_VFW
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
TRY_OPEN(result, cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color))
if
(
apiPreference
!=
CV_CAP_ANY
)
break
;
#endif
#endif
*/
#ifdef HAVE_MSMF
#ifdef HAVE_AVFOUNDATION
case
CV_CAP_MSMF
:
TRY_OPEN
(
result
,
cvCreateVideoWriter_AVFoundation
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
TRY_OPEN
(
result
,
cvCreateVideoWriter_MSMF
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
#endif
if
(
apiPreference
!=
CV_CAP_ANY
)
break
;
#endif
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
#ifdef HAVE_AVFOUNDATION
TRY_OPEN
(
result
,
cvCreateVideoWriter_QT
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
case
CV_CAP_AVFOUNDATION
:
#endif
TRY_OPEN
(
result
,
cvCreateVideoWriter_AVFoundation
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
if
(
apiPreference
!=
CV_CAP_ANY
)
break
;
#ifdef HAVE_GSTREAMER
#endif
TRY_OPEN
(
result
,
cvCreateVideoWriter_GStreamer
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
#endif
case
(
CV_CAP_QT
):
TRY_OPEN
(
result
,
cvCreateVideoWriter_QT
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
TRY_OPEN
(
result
,
cvCreateVideoWriter_Images
(
filename
))
if
(
apiPreference
!=
CV_CAP_ANY
)
break
;
#endif
#ifdef HAVE_GSTREAMER
case
CV_CAP_GSTREAMER
:
TRY_OPEN
(
result
,
cvCreateVideoWriter_GStreamer
(
filename
,
fourcc
,
fps
,
frameSize
,
is_color
))
if
(
apiPreference
!=
CV_CAP_ANY
)
break
;
#endif
case
CV_CAP_IMAGES
:
TRY_OPEN
(
result
,
cvCreateVideoWriter_Images
(
filename
))
if
(
apiPreference
!=
CV_CAP_ANY
)
break
;
}
return
result
;
return
result
;
}
}
...
@@ -543,10 +555,11 @@ static Ptr<IVideoCapture> IVideoCapture_create(const String& filename)
...
@@ -543,10 +555,11 @@ static Ptr<IVideoCapture> IVideoCapture_create(const String& filename)
return
Ptr
<
IVideoCapture
>
();
return
Ptr
<
IVideoCapture
>
();
}
}
static
Ptr
<
IVideoWriter
>
IVideoWriter_create
(
const
String
&
filename
,
int
_fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
)
static
Ptr
<
IVideoWriter
>
IVideoWriter_create
(
int
apiPreference
,
const
String
&
filename
,
int
_fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
)
{
{
Ptr
<
IVideoWriter
>
iwriter
;
Ptr
<
IVideoWriter
>
iwriter
;
if
(
_fourcc
==
CV_FOURCC
(
'M'
,
'J'
,
'P'
,
'G'
)
)
if
(
(
apiPreference
==
CAP_OCV_MJPEG
||
apiPreference
==
CAP_ANY
)
&&
_fourcc
==
CV_FOURCC
(
'M'
,
'J'
,
'P'
,
'G'
)
)
iwriter
=
createMotionJpegWriter
(
filename
,
fps
,
frameSize
,
isColor
);
iwriter
=
createMotionJpegWriter
(
filename
,
fps
,
frameSize
,
isColor
);
return
iwriter
;
return
iwriter
;
}
}
...
@@ -725,6 +738,12 @@ VideoWriter::VideoWriter(const String& filename, int _fourcc, double fps, Size f
...
@@ -725,6 +738,12 @@ VideoWriter::VideoWriter(const String& filename, int _fourcc, double fps, Size f
open
(
filename
,
_fourcc
,
fps
,
frameSize
,
isColor
);
open
(
filename
,
_fourcc
,
fps
,
frameSize
,
isColor
);
}
}
VideoWriter
::
VideoWriter
(
int
apiPreference
,
const
String
&
filename
,
int
_fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
)
{
open
(
apiPreference
,
filename
,
_fourcc
,
fps
,
frameSize
,
isColor
);
}
void
VideoWriter
::
release
()
void
VideoWriter
::
release
()
{
{
iwriter
.
release
();
iwriter
.
release
();
...
@@ -737,14 +756,19 @@ VideoWriter::~VideoWriter()
...
@@ -737,14 +756,19 @@ VideoWriter::~VideoWriter()
}
}
bool
VideoWriter
::
open
(
const
String
&
filename
,
int
_fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
)
bool
VideoWriter
::
open
(
const
String
&
filename
,
int
_fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
)
{
return
open
(
CAP_ANY
,
filename
,
_fourcc
,
fps
,
frameSize
,
isColor
);
}
bool
VideoWriter
::
open
(
int
apiPreference
,
const
String
&
filename
,
int
_fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
)
{
{
CV_INSTRUMENT_REGION
()
CV_INSTRUMENT_REGION
()
if
(
isOpened
())
release
();
if
(
isOpened
())
release
();
iwriter
=
IVideoWriter_create
(
filename
,
_fourcc
,
fps
,
frameSize
,
isColor
);
iwriter
=
IVideoWriter_create
(
apiPreference
,
filename
,
_fourcc
,
fps
,
frameSize
,
isColor
);
if
(
!
iwriter
.
empty
())
if
(
!
iwriter
.
empty
())
return
true
;
return
true
;
writer
.
reset
(
cvCreateVideoWriter
(
filename
.
c_str
(),
_fourcc
,
fps
,
frameSize
,
isColor
));
writer
.
reset
(
cvCreateVideoWriter
WithPreference
(
apiPreference
,
filename
.
c_str
(),
_fourcc
,
fps
,
frameSize
,
isColor
));
return
isOpened
();
return
isOpened
();
}
}
...
...
modules/videoio/src/precomp.hpp
View file @
f1c16f42
...
@@ -163,6 +163,10 @@ CvCapture * cvCreateCameraCapture_Unicap (const int index);
...
@@ -163,6 +163,10 @@ CvCapture * cvCreateCameraCapture_Unicap (const int index);
CvCapture
*
cvCreateCameraCapture_PvAPI
(
const
int
index
);
CvCapture
*
cvCreateCameraCapture_PvAPI
(
const
int
index
);
CvVideoWriter
*
cvCreateVideoWriter_GStreamer
(
const
char
*
filename
,
int
fourcc
,
CvVideoWriter
*
cvCreateVideoWriter_GStreamer
(
const
char
*
filename
,
int
fourcc
,
double
fps
,
CvSize
frameSize
,
int
is_color
);
double
fps
,
CvSize
frameSize
,
int
is_color
);
CvVideoWriter
*
cvCreateVideoWriterWithPreference
(
int
api
,
const
char
*
filename
,
int
fourcc
,
double
fps
,
CvSize
frame_size
,
int
is_color
CV_DEFAULT
(
1
));
namespace
cv
namespace
cv
{
{
...
...
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