简体   繁体   中英

Camera API- How to focus on center of a polygon in images?

Whats the issue? I am taking pictures with resolution, let's say 4096x3072. Now, I have a polygon inside this picture with some co-ordinates {(x1,y1),(x2,y2),(x3,y3),(x4,y4)}. I want the focus of my camera in the center of this polygon.

Anything on internet? I have looked over internet but most of them are for finger touch event. They are getting co-ordinates like motion.eventX() and motion.eventY() but these co-ordinates map to screen resolution not the picture resolution.

I am not 100% sure but i think this will work for you: so you have an n number of points that define the polygon. Add all the x and divide them by the number of points: X=(x1+x2+...+xn)/n. Same with the y: Y=(y1+...+yn)/n. The center of the polygon should be (X,Y). I just came up with it and it works for the example i tested it on. If it dosent work on a case and i missthoguht it tell me.

EDIT: red the question wrong, be right back with edit with the actual answer :D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM