Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Android opencv-2.4.4: how do I select the front camera?

Hi

I can't find any good reference on how to change the 2.4.4 tutorials to work with the front facing camera. Can someone point me in the right direction please?

With this in the manifest:

<uses-feature android:name="android.hardware.camera.front" android:required="true"/>

And this in onCreate:

mOpenCvCameraView.selectCamera(1);

... I get images from the default camera - same if I omit that line. But if I use selectCamera(0) I get a message saying, "It seems that you [sic] device does not support camera (or it is locked). Application will be closed."

Any pointers to good info on this would be welcomed.

Many thanks

Barry

click to hide/show revision 2
expanded code section

Android opencv-2.4.4: how do I select the front camera?

Hi

I can't find any good reference on how to change the 2.4.4 tutorials to work with the front facing camera. Can someone point me in the right direction please?

With this in the manifest:

<uses-feature android:name="android.hardware.camera.front" android:required="true"/>

And this in onCreate:

mOpenCvCameraView.selectCamera(1);

Which calls in OpenCVDemo2View:

public void selectCamera (int i) {
    mOpenCvCameraView.releaseCamera();
    mCamera.open(i);
    }

... I get images from the default camera - same if I omit that line. don't try to select a camera. But if I use selectCamera(0) I get a message saying, "It seems that you [sic] device does not support camera (or it is locked). Application will be closed."

Any pointers to good info on this would be welcomed.

Many thanks

Barry