Android utility control custom realistic camera aperture view

Recently, dual cameras have become popular in the mobile phone industry, and the large aperture function has also been applied. The so-called large aperture function is to be able to refocus the photos in the later stage. Its implementation principle is mainly to realize the refocusing effect through the algorithm for the depth pictures obtained during photographing and the images with infinite focus.

There is an aperture operation icon on the large aperture operation interface of a dual camera mobile phone, which can simulate the real effect of aperture adjustment. It feels good, so I want to achieve this effect. Now I'll contribute my implementation method to you. What if your company also wants to make dual camera phones? ( ̄┰ ̄*)

First of all, baidu looks at the aperture picture and observes it. It can be found that the key lies in the position of each aperture blade when calculating different aperture values. In order to simplify the calculation, I take the aperture effect of six straight edge blades as an example (for other forms, such as seven blades, that is, the position calculation is slightly less convenient; for some circular blades, it is only necessary to meet that the circular arc radius on both sides of the blade is the same. Why should the circular arc radius be the same? Careful observation can find that the adjacent two blades should slide each other and maintain the same fit distance, according to my geometry department in this primary school From the experience of full score, it can be judged that the arc with equal diameter is a good drop. Can other advanced curves achieve this effect? Please ask the mathematician ( ̄  ̄ *)! The principles of other parts are the same).

Making renderings:

First, explain the main contents of this custom view: 1 The realization of this effect is to draw six aperture blades 2 on the six corners of the hexagon in the aperture Calculate the size of the inner hexagon according to different aperture values, so as to calculate the vertex position of each hexagon 3 Design blades. It can also be provided by art mm. This scheme is drawn with code. Note that the spacing between the reserved blades and the angle of each blade is 60 ° 4 Define custom attributes such as color and interval 5 Slide up and down to adjust the aperture size 6 Provide monitoring interface for aperture value change

The code can be downloaded on GitHub: https://github.com/willhua/CameraAperture.git

XML for custom attributes:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>