故事:想法如何測量從相機使用opencv IOS檢測到的對象的距離?
我已經是人臉檢測的應用程序建立與iPhone的SDK 6.0的每一件事情OpenCV的工作我可以使用前CAMER和「相機背面」還我可以打開/關閉的火炬我可以顯示我現在有多少fps(直播)。
,但現在我想添加一個附加功能,你可以看到如何票價遠是這張臉
是有一些公式或一些好的想法或埃文從一家親的解決方案? (如果你需要一些代碼什麼的,我可以告訴你,你需要的每一件事情)
THX的幫助,快速解答!^^
聽到的是爲每一個目標C翻譯
-(double) faceDistance{
const NSInteger kFaceWidth = 10;
const NSInteger kPicWidth = 640;
CGPoint p1 = CGPointMake(10, 10);
CGPoint p2 = CGPointMake(100, 70);
int facePixelWidth;
int slope = (p2.y - p1.y)/(p2.x - p1.x);
double propOfPic = kPicWidth/facePixelWidth;
double surfSize = propOfPic * kFaceWidth;
double dist = surfSize/slope;
return dist;
}
我這裏有更新我的代碼是目標C
對於類似的問題請參閱此鏈接(http://stackoverflow.com/questions/8698889/how-to-measure-height-width-and-distance-of-object-using-camera)在stackoverflow ,可能有幫助... – Haris