linux摄像头测距离,android如何测摄像头和被拍摄物体之间的距离??

本文探讨了Android设备中获取相机焦距的API使用问题,通过`getFocusDistances`方法尝试估算距离,但发现返回值经常为无穷大(infinite),这表明在实际应用中获取精确的焦距信息可能存在困难。尽管该API旨在用于估计相机与拍摄对象的距离,但其精度受到硬件、自动对焦算法等多种因素影响,可能导致较大误差,仅适合作为参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://pastebin.com/w3vDGZ2F

查了一圈,很多国外的程序猿也在研究这个,也没个所以然来。

目前唯一的线索就是焦距到底是多少!

google的api也找到了,public void getFocusDistances (float[] output)

Since: API Level 9

Gets the distances from the camera to where an object appears to be in focus. The object is sharpest at the optimal focus distance. The depth of field is the far focus distance minus near focus distance.

Focus distances may change after calling autoFocus(AutoFocusCallback), cancelAutoFocus(), or startPreview(). Applications can call getParameters() and this method anytime to get the latest focus distances. If the focus mode is FOCUS_MODE_CONTINUOUS_VIDEO, focus distances may change from time to time.

This method is intended to estimate the distance between the camera and the subject. After autofocus, the subject distance may be within near and far focus distance. However, the precision depends on the camera hardware, autofocus algorithm, the focus area, and the scene. The error can be large and it should be only used as a reference.

Far focus distance >= optimal focus distance >= near focus distance. If the focus distance is infinity, the value will be Float.POSITIVE_INFINITY.

Parameters

output focus distances in meters. output must be a float array with three elements. Near focus distance, optimal focus distance, and far focus distance will be filled in the array.

See Also

FOCUS_DISTANCE_NEAR_INDEX

FOCUS_DISTANCE_OPTIMAL_INDEX

FOCUS_DISTANCE_FAR_INDEX

得到的数据一直是infinite,奶奶的真坑爹!  看来是测不出了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值