用相机测量物体的大小

问题描述:

我需要做一个方法来测量照片中的物体......我的意思是我可以将物体与卡的大小进行比较以获得物体的大小,但是我不知道如何比较这...任何想法?用相机测量物体的大小

这里是我正在拍照

- (IBAction)takePicture:(id)sender { 
// Create image picker controller 
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 

// Set source to the camera 
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 

// Delegate is self 
imagePicker.delegate = self; 

// Allow editing of image ? 
imagePicker.allowsImageEditing = NO; 

// Show image picker 
[self presentModalViewController:imagePicker animated:YES]; 

    } 

     - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo 
    { 
UIAlertView *alert; 

// Unable to save the image 
if (error) 
    alert = [[UIAlertView alloc] initWithTitle:@"Error" 
             message:@"Unable to save image to Photo Album." 
             delegate:self cancelButtonTitle:@"Ok" 
          otherButtonTitles:nil]; 
else // All is well 
    alert = [[UIAlertView alloc] initWithTitle:@"Success" 
             message:@"Image saved to Photo Album." 
             delegate:self cancelButtonTitle:@"Ok" 
          otherButtonTitles:nil]; 
[alert show]; 
[alert release]; 
} 
+0

您显示的代码是您如何调用图像选择器。这与你的问题有什么关系? – 2013-02-25 15:25:45

+0

是的,我需要拍摄这张照片并从指定区域获得宽度和高度 – Ladessa 2013-02-25 15:26:59

+1

如果我理解正确,那么您将不得不执行一些图像处理以识别此区域,获取其大小并将其转换为一些真实世界措施。 – 2013-02-25 15:33:40

这里的一些内部监督办公室网站移植image processing algorithms。如果您可以检测到图像的外边缘和某个参考对象(并且知道它们处于相同的深度),则您应该能够近似大小。

编辑 - 原来那里没有代码链接。 Here's an SO answer about using OpenCV to do edge detection。无论如何,重点是,您需要图像处理来从照片中提取可测量的特征。