🤖 AIによる機械翻訳(非公式) — これは OpenCV 4.13.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。
Package org.opencv.videoio
クラス VideoCapture
- java.lang.Object
-
- org.opencv.videoio.VideoCapture
-
public class VideoCapture extends java.lang.ObjectClass for video capturing from video files, image sequences or cameras. The class provides C++ API for capturing video from cameras or for reading video files and image sequences. Here is how the class can be used: INCLUDE: samples/cpp/videocapture_basic.cpp 覚え書き: In REF: videoio_c "C API" the black-box structureCvCaptureis used instead of %VideoCapture. 覚え書き:- (C++) %VideoCapture インターフェースの使用に関する基本的なサンプルは
OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cppにある - (Python) %VideoCapture インターフェースの使用に関する基本的なサンプルは
OPENCV_SOURCE_CODE/samples/python/video.pyにある - (Python) マルチスレッドでの動画処理のサンプルは
OPENCV_SOURCE_CODE/samples/python/video_threaded.pyにある - (Python) Video4Linux2 バックエンドのいくつかの機能を紹介する %VideoCapture サンプル
OPENCV_SOURCE_CODE/samples/python/video_v4l2.py
- (C++) %VideoCapture インターフェースの使用に関する基本的なサンプルは
-
-
フィールドの要約
フィールド Modifier and Type Field Description protected longnativeObj
-
コンストラクタの要約
コンストラクタ Modifier Constructor Description VideoCapture()Default constructor 覚え書き: In REF: videoio_c "C API", when you finished working with video, release CvCapture structure with cvReleaseCapture(), or use Ptr<CvCapture> that calls cvReleaseCapture() automatically in the destructor.VideoCapture​(int index)Opens a camera for video capturingVideoCapture​(int index, int apiPreference)Opens a camera for video capturingVideoCapture​(int index, int apiPreference, MatOfInt params)Opens a camera for video capturing with API Preference and parameters Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...).protectedVideoCapture​(long addr)VideoCapture​(java.lang.String filename)Opens a video file or a capturing device or an IP video stream for video capturing with API PreferenceVideoCapture​(java.lang.String filename, int apiPreference)Opens a video file or a capturing device or an IP video stream for video capturing with API PreferenceVideoCapture​(java.lang.String filename, int apiPreference, MatOfInt params)Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...).VideoCapture​(IStreamReader source, int apiPreference, MatOfInt params)Opens a video using data stream.
-
メソッドの要約
すべてのメソッド 静的メソッド インスタンスメソッド 具象メソッド Modifier and Type Method Description static VideoCapture__fromPtr__​(long addr)doubleget​(int propId)Returns the specified VideoCapture propertyjava.lang.StringgetBackendName()Returns used backend API name 覚え書き: Stream should be opened.booleangetExceptionMode()longgetNativeObjAddr()booleangrab()Grabs the next frame from video file or capturing device.booleanisOpened()Returns true if video capturing has been initialized already.booleanopen​(int index)Opens a camera for video capturing Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)booleanopen​(int index, int apiPreference)Opens a camera for video capturing Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)booleanopen​(int index, int apiPreference, MatOfInt params)Opens a camera for video capturing with API Preference and parameters Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...).booleanopen​(java.lang.String filename)Opens a video file or a capturing device or an IP video stream for video capturing.booleanopen​(java.lang.String filename, int apiPreference)Opens a video file or a capturing device or an IP video stream for video capturing.booleanopen​(java.lang.String filename, int apiPreference, MatOfInt params)Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...).booleanopen​(IStreamReader source, int apiPreference, MatOfInt params)Opens a video using data stream.booleanread​(Mat image)Grabs, decodes and returns the next video frame.voidrelease()Closes video file or capturing device.booleanretrieve​(Mat image)Decodes and returns the grabbed video frame.booleanretrieve​(Mat image, int flag)Decodes and returns the grabbed video frame.booleanset​(int propId, double value)Sets a property in the VideoCapture.voidsetExceptionMode​(boolean enable)Switches exceptions mode methods raise exceptions if not successful instead of returning an error code
-
-
-
コンストラクタの詳細
-
VideoCapture
protected VideoCapture​(long addr)
-
VideoCapture
public VideoCapture()
Default constructor 覚え書き: In REF: videoio_c "C API", when you finished working with video, release CvCapture structure with cvReleaseCapture(), or use Ptr<CvCapture> that calls cvReleaseCapture() automatically in the destructor.
-
VideoCapture
public VideoCapture​(java.lang.String filename, int apiPreference)Opens a video file or a capturing device or an IP video stream for video capturing with API Preference- 引数:
filename- it can be:- ビデオファイル名(例:
video.avi) - または画像シーケンス(例:
img_%02d.jpg。これはimg_00.jpg, img_01.jpg, img_02.jpg, ...のようなサンプルを読み込む) - またはビデオストリームのURL(例:
protocol://host:port/script_name?script_params|auth) - またはGStreamerをバックエンドとして使用する場合は、gst-launchツール形式のGStreamerパイプライン文字列。各ビデオストリームやIPカメラのフィードには、それぞれ独自のURLスキームがあることに注意。正しいURLを知るには、ソースストリームのドキュメントを参照すること。
- ビデオファイル名(例:
apiPreference- 使用するキャプチャAPIバックエンドの優先指定。複数利用可能な場合に特定のリーダー実装を強制するために使用できる。例: cv::CAP_FFMPEG, cv::CAP_IMAGES, cv::CAP_DSHOW。SEE: cv::VideoCaptureAPIs
-
VideoCapture
public VideoCapture​(java.lang.String filename)
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference- 引数:
filename- it can be:- ビデオファイル名(例:
video.avi) - または画像シーケンス(例:
img_%02d.jpg。これはimg_00.jpg, img_01.jpg, img_02.jpg, ...のようなサンプルを読み込む) - またはビデオストリームのURL(例:
protocol://host:port/script_name?script_params|auth) - またはGStreamerをバックエンドとして使用する場合は、gst-launchツール形式のGStreamerパイプライン文字列。各ビデオストリームやIPカメラのフィードには、それぞれ独自のURLスキームがあることに注意。正しいURLを知るには、ソースストリームのドキュメントを参照すること。
- ビデオファイル名(例:
-
VideoCapture
public VideoCapture​(java.lang.String filename, int apiPreference, MatOfInt params)Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties- 引数:
filename- 自動生成apiPreference- 自動生成params- 自動生成
-
VideoCapture
public VideoCapture​(int index, int apiPreference)Opens a camera for video capturing- 引数:
index- 開くビデオキャプチャデバイスのID。デフォルトのバックエンドでデフォルトのカメラを開くには 0 を渡すだけでよい(後方互換性のため、apiPreference が CAP_ANY の場合は camera_id + domain_offset (CAP_*) の使用も有効)apiPreference- 使用するキャプチャAPIバックエンドの優先指定。複数利用可能な場合に特定のリーダー実装を強制するために使用できる。例: cv::CAP_DSHOW, cv::CAP_MSMF, cv::CAP_V4L。SEE: cv::VideoCaptureAPIs
-
VideoCapture
public VideoCapture​(int index)
Opens a camera for video capturing- 引数:
index- 開くビデオキャプチャデバイスのID。デフォルトのバックエンドでデフォルトのカメラを開くには 0 を渡すだけでよい(後方互換性のため、apiPreference が CAP_ANY の場合は camera_id + domain_offset (CAP_*) の使用も有効)。複数利用可能な場合の実装。例: cv::CAP_DSHOW, cv::CAP_MSMF, cv::CAP_V4L。SEE: cv::VideoCaptureAPIs
-
VideoCapture
public VideoCapture​(int index, int apiPreference, MatOfInt params)Opens a camera for video capturing with API Preference and parameters Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties- 引数:
index- 自動生成apiPreference- 自動生成params- 自動生成
-
VideoCapture
public VideoCapture​(IStreamReader source, int apiPreference, MatOfInt params)
Opens a video using data stream. Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties- 引数:
source- 自動生成apiPreference- 自動生成params- 自動生成
-
-
メソッドの詳細
-
getNativeObjAddr
public long getNativeObjAddr()
-
__fromPtr__
public static VideoCapture __fromPtr__​(long addr)
-
open
public boolean open​(java.lang.String filename, int apiPreference)Opens a video file or a capturing device or an IP video stream for video capturing. Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY)- 引数:
filename- 自動生成apiPreference- 自動生成- 戻り値:
- ファイルが正常に開かれた場合は
true。このメソッドはまず VideoCapture::release を呼び出して、すでに開かれているファイルまたはカメラを閉じる。
-
open
public boolean open​(java.lang.String filename)
Opens a video file or a capturing device or an IP video stream for video capturing. Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY)- 引数:
filename- 自動生成- 戻り値:
- ファイルが正常に開かれた場合は
true。このメソッドはまず VideoCapture::release を呼び出して、すでに開かれているファイルまたはカメラを閉じる。
-
open
public boolean open​(java.lang.String filename, int apiPreference, MatOfInt params)Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties- 引数:
filename- 自動生成apiPreference- 自動生成params- 自動生成- 戻り値:
- ファイルが正常に開かれた場合は
true。このメソッドはまず VideoCapture::release を呼び出して、すでに開かれているファイルまたはカメラを閉じる。
-
open
public boolean open​(int index, int apiPreference)Opens a camera for video capturing Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)- 引数:
index- 自動生成apiPreference- 自動生成- 戻り値:
- カメラが正常に開かれた場合は
true。このメソッドはまず VideoCapture::release を呼び出して、すでに開かれているファイルまたはカメラを閉じる。
-
open
public boolean open​(int index)
Opens a camera for video capturing Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)- 引数:
index- 自動生成- 戻り値:
- カメラが正常に開かれた場合は
true。このメソッドはまず VideoCapture::release を呼び出して、すでに開かれているファイルまたはカメラを閉じる。
-
open
public boolean open​(int index, int apiPreference, MatOfInt params)Opens a camera for video capturing with API Preference and parameters Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties- 引数:
index- 自動生成apiPreference- 自動生成params- 自動生成- 戻り値:
- カメラが正常に開かれた場合は
true。このメソッドはまず VideoCapture::release を呼び出して、すでに開かれているファイルまたはカメラを閉じる。
-
open
public boolean open​(IStreamReader source, int apiPreference, MatOfInt params)
Opens a video using data stream. Theparamsparameter allows to specify extra parameters encoded as pairs(paramId_1, paramValue_1, paramId_2, paramValue_2, ...). See cv::VideoCaptureProperties- 引数:
source- 自動生成apiPreference- 自動生成params- 自動生成- 戻り値:
- ファイルが正常に開かれた場合は
true。このメソッドはまず VideoCapture::release を呼び出して、すでに開かれているファイルまたはカメラを閉じる。
-
isOpened
public boolean isOpened()
Returns true if video capturing has been initialized already. If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns true.- 戻り値:
- 自動生成
-
release
public void release()
Closes video file or capturing device. The method is automatically called by subsequent VideoCapture::open and by VideoCapture destructor. The C function also deallocates memory and clears \*capture pointer.
-
grab
public boolean grab()
Grabs the next frame from video file or capturing device.- 戻り値:
- 成功した場合は
true(非ゼロ)。このメソッド/関数はビデオファイルまたはカメラから次のフレームを取得し、成功した場合は true(非ゼロ)を返す。この関数の主な用途は、特にカメラがハードウェア同期を持たないマルチカメラ環境である。すなわち、各カメラに対して VideoCapture::grab() を呼び出し、その後に低速なメソッド VideoCapture::retrieve() を呼び出して各カメラのフレームをデコードして取得する。この方法により、デモザイクやモーションJPEG伸張などのオーバーヘッドが排除され、異なるカメラから取得したフレームの時刻がより近くなる。また、接続されたカメラがマルチヘッド(例えばステレオカメラやKinectデバイス)の場合、正しいデータ取得方法は、まず VideoCapture::grab() を呼び出し、その後 channel 引数の異なる値で VideoCapture::retrieve() を1回以上呼び出すことである。REF: tutorial_kinect_openni
-
retrieve
public boolean retrieve​(Mat image, int flag)
Decodes and returns the grabbed video frame.- 引数:
flag- フレームのインデックスまたはドライバ固有のフラグでありうるimage- 自動生成- 戻り値:
- フレームが取得されていない場合は
false。このメソッドは取得したばかりのフレームをデコードして返す。フレームが取得されていない場合(カメラが切断された、またはビデオファイルにこれ以上フレームがない場合)、メソッドは false を返し、関数は空の画像を返す(%cv::Mat の場合、Mat::empty() でテストする)。SEE: read() 覚え書き: REF: videoio_c "C API" では、関数 cvRetrieveFrame() および cv.RetrieveFrame() はビデオキャプチャ構造体内に格納された画像を返す。この画像を変更または解放することは許可されていない! フレームをコピーするには cvCloneImage を使用し、そのコピーに対して任意の処理を行うこと。
-
retrieve
public boolean retrieve​(Mat image)
Decodes and returns the grabbed video frame.- 引数:
image- 自動生成- 戻り値:
- フレームが取得されていない場合は
false。このメソッドは取得したばかりのフレームをデコードして返す。フレームが取得されていない場合(カメラが切断された、またはビデオファイルにこれ以上フレームがない場合)、メソッドは false を返し、関数は空の画像を返す(%cv::Mat の場合、Mat::empty() でテストする)。SEE: read() 覚え書き: REF: videoio_c "C API" では、関数 cvRetrieveFrame() および cv.RetrieveFrame() はビデオキャプチャ構造体内に格納された画像を返す。この画像を変更または解放することは許可されていない! フレームをコピーするには cvCloneImage を使用し、そのコピーに対して任意の処理を行うこと。
-
read
public boolean read​(Mat image)
Grabs, decodes and returns the next video frame.- 引数:
image- 自動生成- 戻り値:
- フレームが取得されていない場合は
false。このメソッド/関数は VideoCapture::grab() と VideoCapture::retrieve() を1回の呼び出しに統合する。これはビデオファイルの読み込みや、取得したばかりのフレームをデコードして返すデータのキャプチャに最も便利なメソッドである。フレームが取得されていない場合(カメラが切断された、またはビデオファイルにこれ以上フレームがない場合)、メソッドは false を返し、関数は空の画像を返す(%cv::Mat の場合、Mat::empty() でテストする)。覚え書き: REF: videoio_c "C API" では、関数 cvRetrieveFrame() および cv.RetrieveFrame() はビデオキャプチャ構造体内に格納された画像を返す。この画像を変更または解放することは許可されていない! フレームをコピーするには cvCloneImage を使用し、そのコピーに対して任意の処理を行うこと。
-
set
public boolean set​(int propId, double value)Sets a property in the VideoCapture.- 引数:
propId- cv::VideoCaptureProperties のプロパティ識別子(例: cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)、または REF: videoio_flags_others のいずれかvalue- プロパティの値。- 戻り値:
- プロパティが VideoCapture インスタンスで使用されているバックエンドによってサポートされている場合は
true。覚え書き:trueが返されても、プロパティ値がキャプチャデバイスに受け入れられたことを保証するものではない。VideoCapture::get() の注記を参照のこと
-
get
public double get​(int propId)
Returns the specified VideoCapture property- 引数:
propId- cv::VideoCaptureProperties のプロパティ識別子(例: cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)、または REF: videoio_flags_others のいずれか- 戻り値:
- 指定されたプロパティの値。VideoCapture インスタンスで使用されているバックエンドがサポートしていないプロパティを問い合わせた場合は値 0 が返される。覚え書き: プロパティの読み書きには多くの層が関与する。このチェーンに沿って予期しない結果が生じる場合がある。
VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware返される値は、デバイスが実際に使用している値と異なる場合や、デバイス依存の規則(例: ステップ単位やパーセンテージ)でエンコードされている場合がある。実際の挙動はデバイスドライバとAPIバックエンドに依存する
-
getBackendName
public java.lang.String getBackendName()
Returns used backend API name 覚え書き: Stream should be opened.- 戻り値:
- 自動生成
-
setExceptionMode
public void setExceptionMode​(boolean enable)
Switches exceptions mode methods raise exceptions if not successful instead of returning an error code- 引数:
enable- 自動生成
-
getExceptionMode
public boolean getExceptionMode()
-
-