我需要做一个从照片中测量对象的方法......我的意思是我可以将对象与卡片的大小进行比较以从对象中获取大小,但我不知道如何比较它......有什么想法吗?
以下是我拍摄照片的方式
- (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 :(得分:3)
这是一个网站,其中一些ios已移植image processing algorithms。如果你可以检测到图像的外边缘和一些参考物体(并且知道它们处于相同的深度),你应该能够近似大小。
编辑 - 原来那个链接没有代码。 Here's an SO answer about using OpenCV to do edge detection。无论如何,重点是,您需要图像处理来从照片中提取可测量的特征。