2

I am making a barcode scanner app using the vision.barcodereader API. I was wondering how to set my cameraSource's zoom programattically, so that the zoom camera zoom starts at a specific zoom i.e. 25%. Also, the zoom does not have to be adjustable, so I am only asking how to fix it on a specific zoom. My target API is 24, with the min API at 21, and the following code has not worked so far. If you could possibly answer with a code snippet for zooming the camera as described that would be fantastic. Thanks!

@Override
public void onStart(){
    int maxZoom= parameters.getMaxZoom();
    parameters.setZoom(maxZoom);
    camera.setParameters(parameters);
}
Neekon Saadat
  • 417
  • 6
  • 18

1 Answers1

0

Apparently depends on your API level:

   public class Camera.Parameters
   extends Object
       java.lang.Object
    ↳   android.hardware.Camera.Parameters


    void    setZoom(int value)  //Sets current zoom value. 

Because it was too easy to find in the documentation this way, I guess they had to change it:

This class was deprecated in API level 21. We recommend using the new android.hardware.camera2 API for new applications.

android_jain
  • 788
  • 8
  • 19
Peltier Cooler
  • 157
  • 1
  • 12