大家好,我是iOS編程的新手,我正在開發一款使用iOS內置攝像頭的iPad應用程序拍攝照片,然後在背景中使用拍攝的照片進行圖像處理(OpenCV)。不需要向用戶顯示圖像處理。我想在拍攝後處理圖像。但我不知道剛拍攝的照片是如何通過的(照片保存在相機膠捲中,文件名IMG_XXXX.jpg的數字(XXXX)不斷增加)。那麼如何才能檢索剛剛拍攝的照片的文件名,並將其傳遞給使用OpenCV的進一步圖像處理功能?iPad:檢索使用內置攝像頭拍攝的照片的文件名,並將其傳遞給其他功能,以進行進一步的圖像處理
我已經使用了以下兩個功能來拍攝和保存照片。
// 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
}
非常感謝您的幫助!
歡迎的StackOverflow!我已經刪除了Xcode標籤,因爲這個問題與Xcode沒有直接關係。 – 2013-05-12 10:13:58