Camera active area detection in Android application

94 Views Asked by At

Need some help to solve a problem. Maybe someone was working on this and know the solution...

Currently I am designing an Android application that uses a smartphone camera and information from a device received thru the BLE channel to represent the real world positioning of this device on the phone screen. During calculations that allow us to get this representation we are using the camera FOV to indicate if object is visible or is outside the view to the left or to the right, to the top or to the bottom in sense of the phone screen. FOV values by vertical and horizontal could be calculated by the following code:

public static void updateCameraFov(@NonNull CameraCharacteristics characteristics) {//final double vertical, final double horizontal) {
    float[] l_maxFocus = characteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS);
    SizeF l_size = characteristics.get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE);

    if (l_maxFocus != null && l_size != null) {
        double l_x = 2.0f * Math.atan(l_size.getWidth() / (2.0f * l_maxFocus[0])),
               l_y = 2.0f * Math.atan(l_size.getHeight() / (2.0f * l_maxFocus[0]));
        s_cameraThetaV = l_x;
        s_cameraThetaH = l_y;
        Log.d("CAMERA_DEBUG", s_cameraThetaV + "; " + s_cameraThetaH);
    }
}

Actually, FOV values are using the camera matrix physical characteristics, so, theoretically, the calculations should be valid for us. We were executing some experiments to analyze if we have got everything on the right place and device position on the screen is presented more-less correctly without any huge distortions. But according to results that we received using 3 different phones, the calculated FOV from hardware characteristics and the one we have calculated using the results are not equal. As we understand, the active area of the camera matrix could be not equal to the full physical size. But we do not know how to get an information about a position of this active area on a matrix. Is it placed in the center of the matrix, or is it attached more to some corner of the matrix. We cannot hardcode any coefficient to compensate this offset between these two FOVs because every smartphone with camera has got different matrix with different sizes and, probably, the sizes of active areas could be also different. So, the questions is how we can get the real FOV of that active area and how to know how it is placed?

Thanks in advance

0

There are 0 best solutions below