Ask Your Question
2

Is it possible to switch between Front camera and Back camera at runtime?

asked 2013-04-29 02:19:28 -0600

s4eed gravatar image

updated 2020-10-26 14:33:35 -0600

I've created a Native camera view like this :

<org.opencv.android.NativeCameraView
            android:id="@+id/tutorial1_activity_native_surface_view"
            android:layout_width="350px"
            android:layout_height="350px"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            opencv:camera_id="front" />

Now I have 2 questions.

  1. How can I switch from front camera to back camera at run time?
  2. How can I turn off and on the camera at run time ?
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-04-29 03:14:17 -0600

All *CameraView classes have disableView and enableView methods. You need to disable view, set mCameraIndex field of View object and enable view again. mCameraView is protected method, so the only solution is to implement view subclass and setters/getters. See tutorial-3 example for more details.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-04-29 02:19:28 -0600

Seen: 1,537 times

Last updated: Apr 29 '13