Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Camera1 to realize focusing and photometry in Android

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces how to use Camera1 to achieve focus and photometry in Android. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Focus mode

When using a specific focus mode, you must make sure that the camera supports this mode, which can be obtained through the Parameters#getFocusMode interface:

The commonly used focus modes are:

/ / continuous autofocus caf, automatically focus Camera.Parameters.foCUS _ MODE_CONTINUOUS_VIDEO Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE / / single autofocus af when previewing scene changes, and focus Camera.Parameters.FOCUS_MODE_AUTO for each request.

Focus region

When the focus mode is caf or af, you can specify the focus area. If it is not set, the driver will select the focus target itself. See a picture from the official website that describes the focus coordinate system:

As shown in the figure, whether the screen is horizontal or vertical, the coordinates of the center point of the preview view are (0meme0), the upper left corner is (- 1000), and the lower right corner is (1000).

When calculating the focusRect from the UI click coordinates in the screen coordinate system to the focus area of the sensor focusing coordinate system, you also need to consider the rotation angle and the front image of the preview. The calculation process is roughly as follows:

When setting the focus area, you need to query the maximum number of focus areas that can be set:

/ / when 0 is returned, the focus region is not supported. Usually, 1 1~1000Parameters#getMaxNumFocusAreas is returned / when the number of returns is greater than 1, the list of focus regions can be set. / / the weight of each focus region can be set, and the weight range is set.

Switching scenes of common focus modes

When taking a single shot, focus first and then take a picture, and then switch to caf after the photo is taken.

For continuous shooting, focus first and then take pictures, and then switch to caf at the end of continuous shooting.

After focusing the TouchAF on the touchscreen, you can lock the focus, change it to caf; or set the timeout mechanism when the scene changes, and change from af to caf after 3-5 seconds. The strategies chosen in the system cameras of different mobile phones are different, and there are probably two mainstream strategies.

When af switches to caf, you need to switch between focus mode and callback, and switch from af to caf:

Parameters.setFocusMode (Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); camera.setAutoFocusMoveCallback (cafCallback)

Switch from caf to af:

Parameters.setFocusMode (Camera.Parameters.FOCUS_MODE_AUTO); camera.autoFocus (afCallback)

Focus frame logic

AutoFocus process: five states, three types of UI

/ / three types of UI: White box in focus, green / yellow box in focus success, red box in failure / / five states IDEL / / focus is not activeFOCUSING / / focus is in progressFOCUSING_SNAP_ON_FINISH / / will take picture after focus finishSUCCESS / / focus finished and successFAIL / / focus finished and fails

AutoFocusMoving process: three states, two types of UI

/ / White boxes are drawn when two types of UI:moving are used, green / yellow boxes are drawn successfully in focus, and the three states of UI// MOVING_START / / caf startMOVING_END / / caf endTIMEOUT / / time out are cleared directly after timeout.

The above display strategy is very clear to show the focus status, but the current mainstream cameras app will not be so complicated. For example, my iPhone and Xiaomi phone system cameras do not have so many color switches.

Photometry

The coordinate system and use process of photometry are the same as focus, so it is not described in detail.

In TouchAF, the metering area can be the same as the focus area, or the center point of the region can be the same, but the size of the frame is different, or the focus area and the metering area can be set to different areas. this function of focal side separation is generally provided in the professional mode of the camera app. Just choose a different strategy considering the user experience.

Common photometric methods

Note: Redmi K305G version system camera professional mode

Point photometry: the small area of the picture (1.5%-3% of the total area) is measured, regardless of the surrounding environment brightness, the picture detected by the light measuring point is very small, and the result is more accurate. This kind of photometric mode is suitable for use when the contrast of the scene light is large, or when the proportion of the main body in the picture is small.

Central focus photometry: photometry focuses on about 75% of the area in the center of the picture. In the case of large chromatic contrast of light, this photometric mode is easier to control the effect than matrix photometry.

Average photometry: also known as matrix photometry, after the detection and analysis of the light intensity and color of the whole area of the picture, an average and more scientific photometric value is obtained. This photometric mode is suitable for use when the contrast of light, color, etc., is small in the scene.

On how to use Camera1 in Android to achieve focus and photometry is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report