メモ:画面表示せずカメラキャプチャ / Camera capture without view display – OpenCV for Android

You can capture the camera on Android adding listener on SurfaceView by OpenCV.
OpenCV では、SurfaceView にリスナーをつけて、Androidカメラのキャプチャーを行うことができます。

But some we don’t need to display the captured image.
しかし、時には表示を行わないこともありますよね。

This is a code memo for capturing camera without any view display.
以下は、ビューへの表示を行わずにカメラキャプチャーを行うコードのメモです。

private VideoCapture        m_videoCapture;

 初期化 (initialization)

m_videoCapture = new VideoCapture(Highgui.CV_CAP_ANDROID);
if (m_videoCapture.isOpened());
m_videoCapture.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, 320);
m_videoCapture.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, 240);
}

キャプチャー (capture)

Mat m_rgbaMat = new Mat();
m_videoCapture.grab();
m_videoCapture.retrieve( m_rgbaMat, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);

終了 (cleanup)

m_videoCapture.release();

コメントを残す