-1

I have a case where i need to use ML Kit from firebase for barcode scanning. By default it is using back camera. How can i change it to front facing camera ? I have searched in google firebase ML KIT documentation and couldn't find any answer.

l33t.erna
  • 1
  • 2
  • Could you share some code for how you are starting the camera? – Quinn Feb 18 '20 at 19:29
  • @Quinn I am using the sample app from Google repo https://github.com/firebase/mlkit-material-android/blob/master/app/src/main/java/com/google/firebase/ml/md/java/LiveBarcodeScanningActivity.java – l33t.erna Feb 18 '20 at 21:21

1 Answers1

0

Seems like the mlkit example project you linked is using deprecated camera code, but if you look at the CameraSource class on line 175 there is the createCamera method. Try replacing the following line:

val camera = Camera.open() ?: throw IOException("There is no back-facing camera.")

with

val camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT) ?: throw IOException("There is no front-facing camera.")
Quinn
  • 3,896
  • 2
  • 22
  • 45