Google Mobile Vision for iOS对源图像大小有限制吗?
我在使用GoogleMobileVision进行iOS操作时遇到了一些问题 UIImagePickerController的设置如下Google Mobile Vision for iOS对源图像大小有限制吗?,ios,face-detection,apple-vision,google-ios-vision,Ios,Face Detection,Apple Vision,Google Ios Vision,我在使用GoogleMobileVision进行iOS操作时遇到了一些问题 UIImagePickerController的设置如下 UIImagePickerController* picker = [[UIImagePickerController alloc]init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.cameraDevice = UI
UIImagePickerController* picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
[self presentViewController:picker animated:YES completion:^
{
self.faceImageView.layer.sublayers = nil; // drawing and re-drawing some lines...
}];
和探测器:
[super viewDidLoad];
NSDictionary* options = @{
GMVDetectorFaceLandmarkType : @(GMVDetectorFaceLandmarkAll),
GMVDetectorFaceClassificationType : @(GMVDetectorFaceClassificationAll),
GMVDetectorFaceTrackingEnabled : @(NO),
//GMVDetectorFaceMode : @(GMVDetectorFaceAccurateMode) // Accurate mode detects face, but with wrong orientation; Fast mode can't detect faces!
};
self.faceDetector = [GMVDetector detectorOfType:GMVDetectorTypeFace options:options];
但是,如果使用:picker.allowsdediting=YES代码>一切都很完美
问题:图像大小是否有原因<代码>picker.allowsEditing=是
在iPhone 6s和1932x2576上返回750x750大小的图像作为默认值选取器。allowsEditing
XCode v。8.1
iPhone 6S iOS 10.1.1
GoogleMobileVersion V1.0.4只需使用 然后将输出图像发送到功能(in:,options:)。问题- 无论何时在裁剪后从picker(picker.allowsEditing=YES;)获取图像,如果裁剪未完成(picker.allowsEditing=NO;),图像都会工作,但不会工作 敬拜- 每当使用picker.allowsEditing=YES;,裁剪图像时;,imageOrientation设置为“设置” 假设- Google mobile vision看起来最适合处理向上的图像。 但后来我发现 让options=[GMVDetectorImageOrientation:GMVImageOrientation.leftTop.rawValue]//rightTop也可以工作 让faces=faceDetector.features(in:image,options:nil)作为?[GMVFaceFeature] 但是,对于要为哪个imageOrientation设置哪个GMVImageOrientation,这是相当混乱的。然后,我通过使用将方向标准化 因此,在将图像发送到功能(在:,选项:)时,只需将图像作为image.imageByNormalizingOrientation()发送即可
这对我很有效。你发现了什么吗?肯定不是关于大小的问题,因为我试着喂小一些的,但还是不起作用。
func imageByNormalizingOrientation() -> UIImage {
if imageOrientation == .up {
return self
}
UIGraphicsBeginImageContextWithOptions(size, false, scale)
draw(in: CGRect(origin: CGPoint.zero, size: size))
let normalizedImage: UIImage? = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return normalizedImage!
}