Start a new topic

Android Camera Zoom

 Hi,

I have the same problem with camera zoom on Android device.

config.setLicenseKey(WikitudeSDKConstants.WIKITUDE_SDK_KEY );
config.setFeatures(Features.Geo);
config.setCameraResolution(CameraSettings.CameraResolution.FULL_HD_1920x1080);
config.setCameraFocusMode(CameraSettings.CameraFocusMode.CONTINUOUS);
config.setCamera2Enabled(true);
this.architectView.onCreate( config );

this
.architectView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
try {

CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
CameraCharacteristics characteristics = manager.getCameraCharacteristics(mCameraId);
float maxzoom = (characteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM))*10;

Rect m = characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
int action = event.getAction();
float current_finger_spacing;

if (event.getPointerCount() > 1) {
// Multi touch logic
current_finger_spacing = getFingerSpacing(event);

if(finger_spacing != 0){
if(current_finger_spacing > finger_spacing && maxzoom > zoom_level){
zoom_level++;
}
else if (current_finger_spacing < finger_spacing && zoom_level > 1){
zoom_level--;
}
int minW = (int) (m.width() / maxzoom);
int minH = (int) (m.height() / maxzoom);
int difW = m.width() - minW;
int difH = m.height() - minH;
int cropW = difW /100 *(int)zoom_level;
int cropH = difH /100 *(int)zoom_level;
cropW -= cropW & 3;
cropH -= cropH & 3;
Rect zoom = new Rect(cropW, cropH, m.width() - cropW, m.height() - cropH);
mPreviewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoom);
}
finger_spacing = current_finger_spacing;
}
else{
if (action == MotionEvent.ACTION_UP) {
//single touch logic
}
}
});




Hi Kirill,


the information you provide is inconsistent. The code you added is using the Wikitude JS SDK, while in the later reply you said you are using the Native SDK.


Since you have some custom camera code, are you using an InputPlugin?


Best Regards,

Alex

1)sdk version: 7.2.1

2)Native API

3)No

4) Problem with camera zoom on Android device.  Not work old camera API(config.setCamera2Enabled(false))

camera = Camera.open();
Camera.Parameters parameters = camera.getParameters();
if(parameters .isZoomSupported())
      {       int maxZoom= parameters.getMaxZoom();
              parameters.setZoom(maxZoom);
              camera.setParameters(parameters);
          }


 And not work camera2 API. 


It happens with my own app.


How can I implement camera zoom on android device?

Where can I download a sample app for android?


Hello Kirill,


Could you please provide some further information:

  • Which version of the SDK are you using?
  • Are you using the JS API?
  • Are you using any of our Extensions (Titanium, Cordova, Xamarin, Unity)? If yes, which version are you using?
  • Please describe your issue in details
  • What device does this happen with (os Version and model)?
  • is this happening with the sample app or in your own app? If it happens with your own app, does the sample app work on your device?

Thanks

Eva

Login or Signup to post a comment