无法加载4S拍摄的图像,但可以加载5S
Posted
技术标签:
【中文标题】无法加载4S拍摄的图像,但可以加载5S【英文标题】:Can't load image taken by 4S but can 5S 【发布时间】:2014-05-02 05:09:43 【问题描述】:我的应用程序从UIImagePickerController
接收图像,当图像来自 5S 时,我可以在调试中以快速查看的方式正确加载图像,但是如果图像来自 4S,我无法查看它并且我的应用程序无法正确工作。
这是我的 UIImagePickerController
代码
- (IBAction)scanButton:(UIButton *)sender
_imagePicker = [[UIImagePickerController alloc] init];
_imagePicker.delegate = self;
_imagePicker.sourceType = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] ? UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypePhotoLibrary;
if (_imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera)
//_imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
_imagePicker.showsCameraControls = NO;
CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0); //This slots the preview exactly in the middle of the screen by moving it down 71 points
_imagePicker.cameraViewTransform = translate;
CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
_imagePicker.cameraViewTransform = scale;
CGRect screenRect = [[UIScreen mainScreen]bounds];
_overlay = [[CameraOverlay alloc] initWithFrame:CGRectMake(0, 0, screenRect.size.width, screenRect.size.height)];
[_overlay.shootButton addTarget:self action:@selector(takePhoto) forControlEvents:UIControlEventTouchUpInside];
[_overlay.cancelButton addTarget:self action:@selector(cancelPhoto) forControlEvents:UIControlEventTouchUpInside];
[_overlay.flashButton addTarget:self action:@selector(flashButton) forControlEvents:UIControlEventTouchUpInside];
_imagePicker.cameraOverlayView = _overlay;
_imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
_imagePicker.allowsEditing = NO;
[self presentViewController:_imagePicker animated:YES completion:NULL];
还有我的 didFinish 方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
_image = info[UIImagePickerControllerOriginalImage];
_pickerDismissed = YES;
[self dismissViewControllerAnimated:YES completion:nil];
当我从 5S 查看_image
时,我可以加载图像,但从 4S 我不能。
有人知道为什么会发生这种情况吗?
【问题讨论】:
快速查看可能是硬件的限制 - 您能否提供有关您的应用程序“无法正常工作”的方式的更多信息?在 4s 上?你稍后会用这张图片做什么? 作为旁注,我可以将图像保存到照片中并且保存得很好,但是在代码中处理图像并对其执行操作时,就好像它不存在一样。好吧,对于初学者来说,图像似乎并没有立即起作用。我正在使用OpenCV在图像中查找名片和一些其他操作。当图像来自 5S 时,我可以加载快速查看数据,但在 4S 上我不能,而且似乎来自 4S 的图像被“污染”,不允许 OpenCV 正常工作.. 【参考方案1】:听起来很奇怪,换个 iPhone 4S 试试
【讨论】:
以上是关于无法加载4S拍摄的图像,但可以加载5S的主要内容,如果未能解决你的问题,请参考以下文章