Skip to content

Commit 23f4bff

Browse files
committed
videoio: update VideoWriter apiPreference parameter position
1 parent cc021e5 commit 23f4bff

File tree

3 files changed

+17
-26
lines changed

3 files changed

+17
-26
lines changed

modules/videoio/include/opencv2/videoio.hpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ class CV_EXPORTS_W VideoWriter
855855
The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation
856856
if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER.
857857
*/
858-
CV_WRAP VideoWriter(int apiPreference, const String& filename, int fourcc, double fps,
858+
CV_WRAP VideoWriter(const String& filename, int apiPreference, int fourcc, double fps,
859859
Size frameSize, bool isColor = true);
860860

861861
/** @brief Default destructor
@@ -875,15 +875,9 @@ class CV_EXPORTS_W VideoWriter
875875
CV_WRAP virtual bool open(const String& filename, int fourcc, double fps,
876876
Size frameSize, bool isColor = true);
877877

878-
/** @brief Initializes or reinitializes video writer.
879-
880-
The method opens video writer. Parameters are the same as in the constructor
881-
VideoWriter::VideoWriter.
882-
@return `true` if video writer has been successfully initialized
883-
884-
The method first calls VideoWriter::release to close the already opened file.
878+
/** @overload
885879
*/
886-
CV_WRAP bool open(int apiPreference, const String& filename, int fourcc, double fps,
880+
CV_WRAP bool open(const String& filename, int apiPreference, int fourcc, double fps,
887881
Size frameSize, bool isColor = true);
888882

889883
/** @brief Returns true if video writer has been successfully initialized.

modules/videoio/src/cap.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,7 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
368368
* Videowriter dispatching method: it tries to find the first
369369
* API that can write a given stream.
370370
*/
371-
CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
372-
double fps, CvSize frameSize, int is_color )
373-
{
374-
return cvCreateVideoWriterWithPreference(CV_CAP_ANY, filename, fourcc, fps, frameSize, is_color);
375-
}
376-
377-
CvVideoWriter* cvCreateVideoWriterWithPreference(int apiPreference, const char* filename, int fourcc,
371+
static CvVideoWriter* cvCreateVideoWriterWithPreference(const char* filename, int apiPreference, int fourcc,
378372
double fps, CvSize frameSize, int is_color )
379373
{
380374
CV_UNUSED(frameSize);
@@ -428,6 +422,12 @@ CvVideoWriter* cvCreateVideoWriterWithPreference(int apiPreference, const char*
428422
return result;
429423
}
430424

425+
CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
426+
double fps, CvSize frameSize, int is_color )
427+
{
428+
return cvCreateVideoWriterWithPreference(filename, CV_CAP_ANY, fourcc, fps, frameSize, is_color);
429+
}
430+
431431
CV_IMPL int cvWriteFrame( CvVideoWriter* writer, const IplImage* image )
432432
{
433433
return writer ? writer->writeFrame(image) : 0;
@@ -563,7 +563,7 @@ static Ptr<IVideoCapture> IVideoCapture_create(const String& filename)
563563
return Ptr<IVideoCapture>();
564564
}
565565

566-
static Ptr<IVideoWriter> IVideoWriter_create(int apiPreference, const String& filename, int _fourcc, double fps, Size frameSize, bool isColor)
566+
static Ptr<IVideoWriter> IVideoWriter_create(const String& filename, int apiPreference, int _fourcc, double fps, Size frameSize, bool isColor)
567567
{
568568
Ptr<IVideoWriter> iwriter;
569569
#ifdef HAVE_MFX
@@ -757,9 +757,9 @@ VideoWriter::VideoWriter(const String& filename, int _fourcc, double fps, Size f
757757
}
758758

759759

760-
VideoWriter::VideoWriter(int apiPreference, const String& filename, int _fourcc, double fps, Size frameSize, bool isColor)
760+
VideoWriter::VideoWriter(const String& filename, int apiPreference, int _fourcc, double fps, Size frameSize, bool isColor)
761761
{
762-
open(apiPreference, filename, _fourcc, fps, frameSize, isColor);
762+
open(filename, apiPreference, _fourcc, fps, frameSize, isColor);
763763
}
764764

765765
void VideoWriter::release()
@@ -775,18 +775,18 @@ VideoWriter::~VideoWriter()
775775

776776
bool VideoWriter::open(const String& filename, int _fourcc, double fps, Size frameSize, bool isColor)
777777
{
778-
return open(CAP_ANY, filename, _fourcc, fps, frameSize, isColor);
778+
return open(filename, CAP_ANY, _fourcc, fps, frameSize, isColor);
779779
}
780780

781-
bool VideoWriter::open(int apiPreference, const String& filename, int _fourcc, double fps, Size frameSize, bool isColor)
781+
bool VideoWriter::open(const String& filename, int apiPreference, int _fourcc, double fps, Size frameSize, bool isColor)
782782
{
783783
CV_INSTRUMENT_REGION()
784784

785785
if (isOpened()) release();
786-
iwriter = IVideoWriter_create(apiPreference, filename, _fourcc, fps, frameSize, isColor);
786+
iwriter = IVideoWriter_create(filename, apiPreference, _fourcc, fps, frameSize, isColor);
787787
if (!iwriter.empty())
788788
return true;
789-
writer.reset(cvCreateVideoWriterWithPreference(apiPreference, filename.c_str(), _fourcc, fps, frameSize, isColor));
789+
writer.reset(cvCreateVideoWriterWithPreference(filename.c_str(), apiPreference, _fourcc, fps, frameSize, isColor));
790790
return isOpened();
791791
}
792792

modules/videoio/src/precomp.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ CvCapture * cvCreateCameraCapture_Unicap (const int index);
162162
CvCapture * cvCreateCameraCapture_PvAPI (const int index);
163163
CvVideoWriter* cvCreateVideoWriter_GStreamer( const char* filename, int fourcc,
164164
double fps, CvSize frameSize, int is_color );
165-
CvVideoWriter* cvCreateVideoWriterWithPreference(int api, const char* filename, int fourcc,
166-
double fps, CvSize frame_size,
167-
int is_color CV_DEFAULT(1));
168165

169166

170167
namespace cv

0 commit comments

Comments
 (0)