🤖 AIによる機械翻訳(非公式) — これは OpenCV 4.13.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。
Package org.opencv.videoio
クラス VideoWriter
- java.lang.Object
-
- org.opencv.videoio.VideoWriter
public class VideoWriter extends java.lang.Objectビデオライタークラス。動画ファイルまたは画像シーケンスを書き出すためのC++ APIを提供する。
-
-
フィールドの要約
フィールド Modifier and Type Field Description protected longnativeObj
-
コンストラクタの要約
コンストラクタ Modifier Constructor Description VideoWriter()Default constructors The constructors/functions initialize video writers.protectedVideoWriter​(long addr)VideoWriter​(java.lang.String filename, int fourcc, double fps, Size frameSize)VideoWriter​(java.lang.String filename, int fourcc, double fps, Size frameSize, boolean isColor)VideoWriter​(java.lang.String filename, int fourcc, double fps, Size frameSize, MatOfInt params)Theparamsparameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...VideoWriter​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize)TheapiPreferenceparameter allows to specify API backends to use.VideoWriter​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize, boolean isColor)TheapiPreferenceparameter allows to specify API backends to use.VideoWriter​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize, MatOfInt params)
-
メソッドの要約
すべてのメソッド 静的メソッド インスタンスメソッド 具象メソッド Modifier and Type Method Description static VideoWriter__fromPtr__​(long addr)static intfourcc​(char c1, char c2, char c3, char c4)Concatenates 4 chars to a fourcc codedoubleget​(int propId)Returns the specified VideoWriter propertyjava.lang.StringgetBackendName()Returns used backend API name 覚え書き: Stream should be opened.longgetNativeObjAddr()booleanisOpened()Returns true if video writer has been successfully initialized.booleanopen​(java.lang.String filename, int fourcc, double fps, Size frameSize)Initializes or reinitializes video writer.booleanopen​(java.lang.String filename, int fourcc, double fps, Size frameSize, boolean isColor)Initializes or reinitializes video writer.booleanopen​(java.lang.String filename, int fourcc, double fps, Size frameSize, MatOfInt params)booleanopen​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize)booleanopen​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize, boolean isColor)booleanopen​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize, MatOfInt params)voidrelease()Closes the video writer.booleanset​(int propId, double value)Sets a property in the VideoWriter.voidwrite​(Mat image)Writes the next video frame
-
-
-
コンストラクタの詳細
-
VideoWriter
protected VideoWriter​(long addr)
-
VideoWriter
public VideoWriter()
Default constructors The constructors/functions initialize video writers.- Linuxでは動画の書き込みにFFMPEGが使われる。
- WindowsではFFMPEG、MSWF、またはDSHOWが使われる。
- MacOSXではAVFoundationが使われる。
-
VideoWriter
public VideoWriter​(java.lang.String filename, int fourcc, double fps, Size frameSize, boolean isColor)- 引数:
filename- 出力する動画ファイルの名前。fourcc- フレームの圧縮に使用するコーデックの4文字コード。例えば、VideoWriter::fourcc('P','I','M','1') はMPEG-1コーデック、VideoWriter::fourcc('M','J','P','G') はmotion-jpegコーデックなどである。コードの一覧は [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) ページ、またはより完全な一覧についてはfourccサイトの [page](https://fourcc.org/codecs.php) で入手できる。MP4コンテナを使用するFFMPEGバックエンドは、fourccコードとしてネイティブに別の値を使用する([ObjectType](http://mp4ra.org/#/codecs) を参照)。そのため、fourccコードの変換に関する警告メッセージがOpenCVから出力されることがある。fps- 作成する動画ストリームのフレームレート。frameSize- 動画フレームのサイズ。isColor- If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames. Tips:- 一部のバックエンドでは、
fourcc=-1を指定するとシステムのコーデック選択ダイアログが表示される。 - 画像シーケンスを保存するには、適切なファイル名(例:
img_%02d.jpg)とfourcc=0またはfps=0を使う。生のフレームを保存するには非圧縮の画像フォーマット(例:img_%02d.BMP)を使う。 - ほとんどのコーデックは非可逆である。可逆な動画ファイルが必要な場合は、可逆コーデック(例: FFMPEG FFV1、Huffman HFYU、Lagarith LAGS など)を使う必要がある。
- FFMPEGが有効な場合、
codec=0; fps=0;を使うと非圧縮(生)の動画ファイルを作成できる。 - FFMPEGを使う場合、幅または高さが奇数のフレームも許可されるが、この場合は一番右の列または一番下の行を切り捨てる。本来はもっとスマートに処理すべきだが、FFMPEG内部のswscaleの一部の関数は偶数の幅/高さを必要とする。
- 一部のバックエンドでは、
-
VideoWriter
public VideoWriter​(java.lang.String filename, int fourcc, double fps, Size frameSize)- 引数:
filename- 出力する動画ファイルの名前。fourcc- フレームの圧縮に使用するコーデックの4文字コード。例えば、VideoWriter::fourcc('P','I','M','1') はMPEG-1コーデック、VideoWriter::fourcc('M','J','P','G') はmotion-jpegコーデックなどである。コードの一覧は [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) ページ、またはより完全な一覧についてはfourccサイトの [page](https://fourcc.org/codecs.php) で入手できる。MP4コンテナを使用するFFMPEGバックエンドは、fourccコードとしてネイティブに別の値を使用する([ObjectType](http://mp4ra.org/#/codecs) を参照)。そのため、fourccコードの変換に関する警告メッセージがOpenCVから出力されることがある。fps- 作成する動画ストリームのフレームレート。frameSize- Size of the video frames. will work with grayscale frames. Tips:- 一部のバックエンドでは、
fourcc=-1を指定するとシステムのコーデック選択ダイアログが表示される。 - 画像シーケンスを保存するには、適切なファイル名(例:
img_%02d.jpg)とfourcc=0またはfps=0を使う。生のフレームを保存するには非圧縮の画像フォーマット(例:img_%02d.BMP)を使う。 - ほとんどのコーデックは非可逆である。可逆な動画ファイルが必要な場合は、可逆コーデック(例: FFMPEG FFV1、Huffman HFYU、Lagarith LAGS など)を使う必要がある。
- FFMPEGが有効な場合、
codec=0; fps=0;を使うと非圧縮(生)の動画ファイルを作成できる。 - FFMPEGを使う場合、幅または高さが奇数のフレームも許可されるが、この場合は一番右の列または一番下の行を切り捨てる。本来はもっとスマートに処理すべきだが、FFMPEG内部のswscaleの一部の関数は偶数の幅/高さを必要とする。
- 一部のバックエンドでは、
-
VideoWriter
public VideoWriter​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize, boolean isColor)TheapiPreferenceparameter 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.- 引数:
filename- 自動生成apiPreference- 自動生成fourcc- 自動生成fps- 自動生成frameSize- 自動生成isColor- 自動生成
-
VideoWriter
public VideoWriter​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize)TheapiPreferenceparameter 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.- 引数:
filename- 自動生成apiPreference- 自動生成fourcc- 自動生成fps- 自動生成frameSize- 自動生成
-
VideoWriter
public VideoWriter​(java.lang.String filename, int fourcc, double fps, Size frameSize, MatOfInt params)Theparamsparameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::VideoWriterProperties- 引数:
filename- 自動生成fourcc- 自動生成fps- 自動生成frameSize- 自動生成params- 自動生成
-
-
メソッドの詳細
-
getNativeObjAddr
public long getNativeObjAddr()
-
__fromPtr__
public static VideoWriter __fromPtr__​(long addr)
-
open
public boolean open​(java.lang.String filename, int fourcc, double fps, Size frameSize, boolean isColor)Initializes or reinitializes video writer. The method opens video writer. Parameters are the same as in the constructor VideoWriter::VideoWriter.- 引数:
filename- 自動生成fourcc- 自動生成fps- 自動生成frameSize- 自動生成isColor- 自動生成- 戻り値:
- ビデオライターが正常に初期化された場合は
true。このメソッドはまず VideoWriter::release を呼び出して、すでに開いているファイルを閉じる。
-
open
public boolean open​(java.lang.String filename, int fourcc, double fps, Size frameSize)Initializes or reinitializes video writer. The method opens video writer. Parameters are the same as in the constructor VideoWriter::VideoWriter.- 引数:
filename- 自動生成fourcc- 自動生成fps- 自動生成frameSize- 自動生成- 戻り値:
- ビデオライターが正常に初期化された場合は
true。このメソッドはまず VideoWriter::release を呼び出して、すでに開いているファイルを閉じる。
-
open
public boolean open​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize, boolean isColor)
-
open
public boolean open​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize)
-
open
public boolean open​(java.lang.String filename, int fourcc, double fps, Size frameSize, MatOfInt params)
-
open
public boolean open​(java.lang.String filename, int apiPreference, int fourcc, double fps, Size frameSize, MatOfInt params)
-
isOpened
public boolean isOpened()
Returns true if video writer has been successfully initialized.- 戻り値:
- 自動生成
-
release
public void release()
Closes the video writer. The method is automatically called by subsequent VideoWriter::open and by the VideoWriter destructor.
-
write
public void write​(Mat image)
Writes the next video frame- 引数:
image- 書き出すフレーム。一般に、カラー画像はBGR形式であることが想定される。この関数/メソッドは指定された画像を動画ファイルに書き出す。画像はビデオライターを開いた際に指定したものと同じサイズでなければならない。
-
set
public boolean set​(int propId, double value)Sets a property in the VideoWriter.- 引数:
propId- cv::VideoWriterProperties のプロパティ識別子(例:cv::VIDEOWRITER_PROP_QUALITY)、または REF: videoio_flags_others のいずれか。value- プロパティの値。- 戻り値:
- VideoWriter インスタンスが使用しているバックエンドがそのプロパティをサポートしている場合は
true。
-
get
public double get​(int propId)
Returns the specified VideoWriter property- 引数:
propId- cv::VideoWriterProperties のプロパティ識別子(例:cv::VIDEOWRITER_PROP_QUALITY)、または REF: videoio_flags_others のいずれか。- 戻り値:
- 指定したプロパティの値。VideoWriter インスタンスが使用しているバックエンドがサポートしていないプロパティを問い合わせた場合は値0が返される。
-
fourcc
public static int fourcc​(char c1, char c2, char c3, char c4)Concatenates 4 chars to a fourcc code- 引数:
c1- 自動生成c2- 自動生成c3- 自動生成c4- 自動生成- 戻り値:
- fourccコード。この静的メソッドは、コンストラクタ VideoWriter::VideoWriter または VideoWriter::open で使用するコーデックのfourccコードを構築する。
-
getBackendName
public java.lang.String getBackendName()
Returns used backend API name 覚え書き: Stream should be opened.- 戻り値:
- 自動生成
-
-