Joshua Martinez
Newbie
Using WebCamTexture in your Unity3D program (as a way of cross-platform accessing the camera of devices) unfortunately messes with your Android device focus mode, so it requires a manual fix, hence my trying to write a small Android plug-in for Unity3D, in order to set my Android device camera auto-focus manually for scanning and character recognition (i.e. constant sharp focus).
I am, however, finding it difficult to get used to the new camera2 API. I need a little help turning the old Camera API code (commented out bit at the bottom) into the new camera2 compatible program, just so I can then turn this Android program into a plug-in and then call it from within a Unity3D C# program.
My variable declarations are obviously fine, but the other 3 lines are all underlined red as error. Could someone please help me get this right?
I am, however, finding it difficult to get used to the new camera2 API. I need a little help turning the old Camera API code (commented out bit at the bottom) into the new camera2 compatible program, just so I can then turn this Android program into a plug-in and then call it from within a Unity3D C# program.
My variable declarations are obviously fine, but the other 3 lines are all underlined red as error. Could someone please help me get this right?
Code:
package com.example.ocrfocusunityplugin;
import android.hardware.camera2.*;
import java.util.List;
public class OcrFocusPluginClass
{
public void EnableAutofocus()
{
String cameraId; // camera ID -> 0 for Back and 1 for Front
CameraDevice camera;
CameraManager manager;
CameraCaptureSession session;
CameraDevice.StateCallback callback;
cameraId = manager.getCameraIdList()[0];
manager.openCamera(cameraId, callback, null);
CameraCharacteristics.get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES);
/*
camera = Camera.open();
Camera.Parameters parameters = camera.getParameters();
List<String> focusModes = parameters.getSupportedFocusModes();
if ( focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO) )
{
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
camera.setParameters(parameters);
*/
}
}