Merge pull request #16766 from VadimLevin:dev/vlevin/video_writer_params_constructor

* feature: Extend VideoWriter to accept vector of parameters

 - Add additional constructor and `open` method for `VideoWriter`
   those accept a vector of parameters
 - Move actual implementation of the `VideoWriter::open` to general method
   which accepts vector of parameters
 - Propagate parsed parameters map up to actual video backend construction

* fix: Change VideoWriter constructor description to suppress doc warning

* refactor: Rollback newlines changes

* feature: Changed VideoWriter parameters workflow

* feature: Log unused parameters in VideoWriter open

* doc: Fix VideoWriter `isColor` parameter description

* fix: int to bool VC++ conversion warning

* doc: Remove information about `isColor` flag usage.
This commit is contained in:
Vadim Levin
2020-04-28 11:38:39 +03:00
committed by GitHub
parent 152e6476d9
commit 7f90f04df2
14 changed files with 217 additions and 35 deletions
+26 -2
View File
@@ -189,7 +189,9 @@ enum VideoCaptureProperties {
enum VideoWriterProperties {
VIDEOWRITER_PROP_QUALITY = 1, //!< Current quality (0..100%) of the encoded videostream. Can be adjusted dynamically in some codecs.
VIDEOWRITER_PROP_FRAMEBYTES = 2, //!< (Read-only): Size of just encoded video frame. Note that the encoding order may be different from representation order.
VIDEOWRITER_PROP_NSTRIPES = 3 //!< Number of stripes for parallel encoding. -1 for auto detection.
VIDEOWRITER_PROP_NSTRIPES = 3, //!< Number of stripes for parallel encoding. -1 for auto detection.
VIDEOWRITER_PROP_IS_COLOR = 4 //!< If it is not zero, the encoder will expect and encode color frames, otherwise it
//!< will work with grayscale frames.
};
//! @} videoio_flags_base
@@ -876,7 +878,7 @@ public:
@param fps Framerate of the created video stream.
@param frameSize Size of the video frames.
@param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it
will work with grayscale frames (the flag is currently supported on Windows only).
will work with grayscale frames.
@b Tips:
- With some backends `fourcc=-1` pops up the codec selection dialog from the system.
@@ -896,6 +898,18 @@ public:
CV_WRAP VideoWriter(const String& filename, int apiPreference, int fourcc, double fps,
Size frameSize, bool isColor = true);
/** @overload
* The `params` parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .)
* see cv::VideoWriterProperties
*/
CV_WRAP VideoWriter(const String& filename, int fourcc, double fps, const Size& frameSize,
const std::vector<int>& params);
/** @overload
*/
CV_WRAP VideoWriter(const String& filename, int apiPreference, int fourcc, double fps,
const Size& frameSize, const std::vector<int>& params);
/** @brief Default destructor
The method first calls VideoWriter::release to close the already opened file.
@@ -918,6 +932,16 @@ public:
CV_WRAP bool open(const String& filename, int apiPreference, int fourcc, double fps,
Size frameSize, bool isColor = true);
/** @overload
*/
CV_WRAP bool open(const String& filename, int fourcc, double fps, const Size& frameSize,
const std::vector<int>& params);
/** @overload
*/
CV_WRAP bool open(const String& filename, int apiPreference, int fourcc, double fps,
const Size& frameSize, const std::vector<int>& params);
/** @brief Returns true if video writer has been successfully initialized.
*/
CV_WRAP virtual bool isOpened() const;