2016-12-07 6 views
3

iOS用のGoogleMobileVisionを使用しているときに問題が発生しました。 UIImagePickerControllerでGoogle Mobile Vision for iOSのソースイメージサイズにはどのような制限がありますか?

この

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.allowsEditing = YES;すべてが完璧に動作します!

質問:画像サイズに理由はありますか? picker.allowsEditing

XCodeのvのデフォルト値のサイズiPhone 6S上の750x750と1932x2576のpicker.allowsEditing = YES;リターンイメージ。8.1 iPhone 6SのiOS 10.1.1 GoogleMobileVisionのV 1.0.4

+0

これについて何かお知りになりましたか? –

+0

小さいサイズの食べてみましたが、それでもうまくいきませんでしたので、確かにサイズに関するものではありません。 –

答えて

2

だけthis

を用いて画像の向きを正規化
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! 
} 

出力イメージをフィーチャー(:、options :)に送信します。

0

problem-画像をクロッピングした後ピッカーから取られるたび

(picker.allowsEditing = YES;)トリミングが行われていない場合、それはしかし、動作しない作品(picker.allowsEditing = NO)。画像はpicker.allowsEditingを用いてトリミングされるたび

Obeseration-

は= YES ;, imageOrientationは、最大に設定されています。

Assumption-

Googleモバイルのビジョンは、最大指向の画像を最高の仕事ができることになります。 しかし、その後、私はことが判明

LETオプション= [GMVDetectorImageOrientation:GMVImageOrientation.leftTop.rawValue](:画像、オプション:ゼロで)として// rightTopも はfaces =のfaceDetector.features聞かせて動作しますか? [GMVFaceFeature] これは、どのGMO画像がどのimageOrientationに設定されるのか、かなり混乱しています。そこで私はthisを使って向きを正規化しました。

画像に画像を送信するときには(:、options :)画像をimage.imageByNormalizingOrientation()として送信してください。

これは私のために働いた。

関連する問題