OpenCV453
公開メンバ関数 | 静的公開メンバ関数 | 静的限定公開メンバ関数 | 限定公開変数類 | 全メンバ一覧
cv::VideoWriter クラス

Video writer class. [詳解]

#include <videoio.hpp>

公開メンバ関数

CV_WRAP VideoWriter ()
 Default constructors [詳解]
 
CV_WRAP VideoWriter (const String &filename, int fourcc, double fps, Size frameSize, bool isColor=true)
 
CV_WRAP VideoWriter (const String &filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor=true)
 
CV_WRAP VideoWriter (const String &filename, int fourcc, double fps, const Size &frameSize, const std::vector< int > &params)
 
CV_WRAP VideoWriter (const String &filename, int apiPreference, int fourcc, double fps, const Size &frameSize, const std::vector< int > &params)
 
virtual ~VideoWriter ()
 Default destructor [詳解]
 
virtual CV_WRAP bool open (const String &filename, int fourcc, double fps, Size frameSize, bool isColor=true)
 Initializes or reinitializes video writer. [詳解]
 
CV_WRAP bool open (const String &filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor=true)
 
CV_WRAP bool open (const String &filename, int fourcc, double fps, const Size &frameSize, const std::vector< int > &params)
 
CV_WRAP bool open (const String &filename, int apiPreference, int fourcc, double fps, const Size &frameSize, const std::vector< int > &params)
 
virtual CV_WRAP bool isOpened () const
 Returns true if video writer has been successfully initialized.
 
virtual CV_WRAP void release ()
 Closes the video writer. [詳解]
 
virtual VideoWriteroperator<< (const Mat &image)
 Stream operator to write the next video frame. [詳解]
 
virtual VideoWriteroperator<< (const UMat &image)
 
virtual CV_WRAP void write (InputArray image)
 Writes the next video frame [詳解]
 
virtual CV_WRAP bool set (int propId, double value)
 Sets a property in the VideoWriter. [詳解]
 
virtual CV_WRAP double get (int propId) const
 Returns the specified VideoWriter property [詳解]
 
CV_WRAP String getBackendName () const
 Returns used backend API name [詳解]
 

静的公開メンバ関数

static CV_WRAP int fourcc (char c1, char c2, char c3, char c4)
 Concatenates 4 chars to a fourcc code [詳解]
 

静的限定公開メンバ関数

static Ptr< IVideoWriter > create (const String &filename, int fourcc, double fps, Size frameSize, bool isColor=true)
 

限定公開変数類

Ptr< CvVideoWriterwriter
 
Ptr< IVideoWriter > iwriter
 

詳解

Video writer class.

The class provides C++ API for writing video files or image sequences.

構築子と解体子

◆ VideoWriter() [1/5]

CV_WRAP cv::VideoWriter::VideoWriter ( )

Default constructors

The constructors/functions initialize video writers.

  • On Linux FFMPEG is used to write videos;
  • On Windows FFMPEG or MSWF or DSHOW is used;
  • On MacOSX AVFoundation is used.

◆ VideoWriter() [2/5]

CV_WRAP cv::VideoWriter::VideoWriter ( const String &  filename,
int  fourcc,
double  fps,
Size  frameSize,
bool  isColor = true 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

引数
filenameName of the output video file.
fourcc4-character code of codec used to compress the frames. For example, VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') is a motion-jpeg codec etc. List of codes can be obtained at Video Codecs by FOURCC page. FFMPEG backend with MP4 container natively uses other values as fourcc code: see ObjectType, so you may receive a warning message from OpenCV about fourcc code conversion.
fpsFramerate of the created video stream.
frameSizeSize of the video frames.
isColorIf it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames.

Tips:

  • With some backends fourcc=-1 pops up the codec selection dialog from the system.
  • To save image sequence use a proper filename (eg. img_%02d.jpg) and fourcc=0 OR fps=0. Use uncompressed image format (eg. img_%02d.BMP) to save raw frames.
  • Most codecs are lossy. If you want lossless video file you need to use a lossless codecs (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...)
  • If FFMPEG is enabled, using codec=0; fps=0; you can create an uncompressed (raw) video file.

◆ VideoWriter() [3/5]

CV_WRAP cv::VideoWriter::VideoWriter ( const String &  filename,
int  apiPreference,
int  fourcc,
double  fps,
Size  frameSize,
bool  isColor = true 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。 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.

◆ VideoWriter() [4/5]

CV_WRAP cv::VideoWriter::VideoWriter ( const String &  filename,
int  fourcc,
double  fps,
const Size frameSize,
const std::vector< int > &  params 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。 The params parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::VideoWriterProperties

◆ VideoWriter() [5/5]

CV_WRAP cv::VideoWriter::VideoWriter ( const String &  filename,
int  apiPreference,
int  fourcc,
double  fps,
const Size frameSize,
const std::vector< int > &  params 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

◆ ~VideoWriter()

virtual cv::VideoWriter::~VideoWriter ( )
virtual

Default destructor

The method first calls VideoWriter::release to close the already opened file.

関数詳解

◆ fourcc()

static CV_WRAP int cv::VideoWriter::fourcc ( char  c1,
char  c2,
char  c3,
char  c4 
)
static

Concatenates 4 chars to a fourcc code

戻り値
a fourcc code

This static method constructs the fourcc code of the codec to be used in the constructor VideoWriter::VideoWriter or VideoWriter::open.

◆ get()

virtual CV_WRAP double cv::VideoWriter::get ( int  propId) const
virtual

Returns the specified VideoWriter property

引数
propIdProperty identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of Additional flags for video I/O API backends
戻り値
Value for the specified property. Value 0 is returned when querying a property that is not supported by the backend used by the VideoWriter instance.

◆ getBackendName()

CV_WRAP String cv::VideoWriter::getBackendName ( ) const

Returns used backend API name

覚え書き
Stream should be opened.

◆ open() [1/4]

CV_WRAP bool cv::VideoWriter::open ( const String &  filename,
int  apiPreference,
int  fourcc,
double  fps,
const Size frameSize,
const std::vector< int > &  params 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

◆ open() [2/4]

CV_WRAP bool cv::VideoWriter::open ( const String &  filename,
int  apiPreference,
int  fourcc,
double  fps,
Size  frameSize,
bool  isColor = true 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

◆ open() [3/4]

CV_WRAP bool cv::VideoWriter::open ( const String &  filename,
int  fourcc,
double  fps,
const Size frameSize,
const std::vector< int > &  params 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

◆ open() [4/4]

virtual CV_WRAP bool cv::VideoWriter::open ( const String &  filename,
int  fourcc,
double  fps,
Size  frameSize,
bool  isColor = true 
)
virtual

Initializes or reinitializes video writer.

The method opens video writer. Parameters are the same as in the constructor VideoWriter::VideoWriter.

戻り値
true if video writer has been successfully initialized

The method first calls VideoWriter::release to close the already opened file.

◆ operator<<() [1/2]

virtual VideoWriter & cv::VideoWriter::operator<< ( const Mat image)
virtual

Stream operator to write the next video frame.

参照
write

◆ operator<<() [2/2]

virtual VideoWriter & cv::VideoWriter::operator<< ( const UMat image)
virtual

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

参照
write

◆ release()

virtual CV_WRAP void cv::VideoWriter::release ( )
virtual

Closes the video writer.

The method is automatically called by subsequent VideoWriter::open and by the VideoWriter destructor.

◆ set()

virtual CV_WRAP bool cv::VideoWriter::set ( int  propId,
double  value 
)
virtual

Sets a property in the VideoWriter.

引数
propIdProperty identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of Additional flags for video I/O API backends
valueValue of the property.
戻り値
true if the property is supported by the backend used by the VideoWriter instance.

◆ write()

virtual CV_WRAP void cv::VideoWriter::write ( InputArray  image)
virtual

Writes the next video frame

引数
imageThe written frame. In general, color images are expected in BGR format.

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.


このクラス詳解は次のファイルから抽出されました: