1

大家好,我是 iOS 编程的新手,我正在开发一个 iPad 应用程序,它使用 iOS 内置相机拍照,然后在背景中使用拍摄的照片进行图像处理 (OpenCV)。无需向用户展示图像处理过程。我想在拍摄后处理图像。但是我不知道如何通过刚刚拍摄的照片(照片保存在相机胶卷中并且文件名IMG_XXXX.jpg的编号(XXXX)不断增加)。那么如何检索刚刚拍摄的照片的文件名并将其传递给函数以使用 OpenCV 进行进一步的图像处理?

我使用了以下两个功能来拍摄和保存照片。

// take photo
- (IBAction)captureCamera:(id)sender {
    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
    {
        UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePicker.mediaTypes = @[(NSString *) kUTTypeImage];
        imagePicker.allowsEditing = NO;
        [self presentViewController:imagePicker animated:YES completion:nil];
        _newMedia = YES; // a photo has been taken
    }
}

// save photo
#pragma mark -
#pragma mark UIImagePickerControllerDelegate
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSString *mediaType = info[UIImagePickerControllerMediaType];
    [self dismissViewControllerAnimated:YES completion:nil];
    if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
    {
        UIImage *image = info[UIImagePickerControllerOriginalImage];
        _imageView.image = image;
        if (_newMedia)
            UIImageWriteToSavedPhotosAlbum(image, self,
                                           @selector(image:finishedSavingWithError:contextInfo:),
                                           nil); }

    saveimg = true; // if an image is saved
    if (saveimg == true)
    {
        //imgprocess();    // pass the photo just taken for further image processing
    }

    saveimg = false; // reset it for next photo-taking
}

非常感谢您的帮助!

4

1 回答 1

0

AssetLibrary 可以通过以下方式为您提供资产的枚举功能: enumerateGroupsWithTypes:usingBlock:failureBlock:
但是现在您必须尝试查看它是否提供了最后一个对象路径,即最新保存的路径。

祝你好运

于 2013-05-12T09:41:46.027 回答