Distance to “point of interest” in iphone auto focus

我的梦境 提交于 2019-12-09 12:09:31

问题


In iphone, I want to calculate the distance from the camera to the subject.

I was wondering maybe iphone camera's "Active Auto Focus" provide me the distance to the subject (point of interest)??

many thanks in advance.

p.s. guys if you think it is not possible plz let me know ;)


回答1:


As far as I'm aware, it's not possible - see here for more info on what you can and can't do. You can tell when the camera is autofocusing, but nothing more.

I'm sure there is probably some more info you can get on focus/distance using a private API call - but unless you're not worried about getting on the App Store, it's not really an option.

That doesn't mean there's not another way though. Looks like a good discussion on the topic here: Distance using OpenCV (you can compile openCV for iOS!)




回答2:


I've been investigating the ability of the camera to measure short distances and not finding anything yet I came up with this shot in the dark. I haven't tried it yet, but the docs make me think this might work:

  • Create and configure an AVCaptureDevice representing the camera
  • Through the AVCaptureSession, capture the AVCaptureStillImageOutput
  • From the AVCaptureStillImageOutput object check the Exif properties for kCGImagePropertyExifSubjectDistance

Love to hear if anyone has been able to use a methodology like this to be able to make accurate (less than 1 foot) distance measurements.



来源:https://stackoverflow.com/questions/6524998/distance-to-point-of-interest-in-iphone-auto-focus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!