Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV Android: Get camera frames in background without showing on the screen

I have written an optic flow detection application which based on OpenCV for Android tutorials and source code of Barry Thomas's application OpenCV Demo 2. Now I want to make this application a background task so I can pass the detection result to my main activity via listener interface.

All the application samples in OpenCV totorials extends Activity and implements CvCameraViewListener and shows camera input on the scrren. I want to able to capture camera frames and do optic flow detection on frames in background without showing them on the screen.

How can I get frames from camera in background witout showing camera input?

like image 351
Mukaddes Avatar asked Nov 10 '22 07:11

Mukaddes


1 Answers

There are two ways, but you have to keep a Mat in the memory in the method onCameraFrame:

@Override
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    mRgba = inputFrame.rgba();      
    return mRgba;
}

1) make the cameraview invisible 2) make onCameraFrame return null

Both ways you should do your additional work in another view.

like image 170
xMKx Avatar answered Nov 15 '22 00:11

xMKx