In Android, what is really used to focus the weight area parameter?

Android API 14 has the ability to focus with the camera in a specific area. The API indicates that weight can be delivered, but after reading the description several times, I still can’t understand how to use it and what value to set, or what factors should take into account the weight value for use, can someone please explain to me how to use this option when it comes to focus? Thanks

Quote from SDK Help

Each area consists of a rectangle with an indication of its boundaries and a weight that determines its importance . Ratings relate to the current field of view of the camera. The coordinates are displayed so that (-1000, -1000) is always the upper left corner of the current field of view, and (1000, 1000) is always the lower right corner of the current field of view. Settings Areas with boundaries outside this range are not allowed. Areas with zero or negative width or height are not allowed. The weight must be between 1 and 1000 and represents the weight for each pixel in the area. This means that a larger measuring area with the same weight as a smaller area will have a greater effect as a result of the measurement . Measurement areas can overlap, and the driver adds weight to the overlap area.

+4
source share
1 answer

Try the following:

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void setMeteringAndFocusArea (int x1, int y1, int x2, int y2, Camera camera){ Camera.Parameters camParam = camera.getParameters(); if (cameraParameters.getMaxNumMeteringAreas() > 0){ List<Camera.Area> areas = new ArrayList<Camera.Area>(); Rect areaRect = new Rect(x1, x2, y1, y2); areas.add(new Camera.Area(areaRect, 1000)); camParam.setMeteringAreas(areas); //You can use only Focus Areas if you don't care for metering. camParam.setFocusAreas(areas); camera.setParameters(camParam); } } 

And don't forget to use

camera.autoFocus ();

before taking a picture, otherwise setFocusAreas () will not have any effect. See this link posted in this question for a pleasant implementation.

+1
source

Source: https://habr.com/ru/post/1494757/


All Articles