4
私は迅速にCIDetectorを使ってテキスト検出器を作ろうとしています。私は、私の電話をテキストで指していると、それを検出しません。しかし、私の側に電話を回すと、それは動作し、テキストを検出します。正しいカメラ方向でテキストを検出できるように変更するにはどうすればよいですか?ここに私のコードは次のとおりです。CIDetectorの向きを変更するには?
は、テキスト検出機能を準備します
func prepareTextDetector() -> CIDetector {
let options: [String: AnyObject] = [CIDetectorAccuracy: CIDetectorAccuracyHigh, CIDetectorAspectRatio: 1.0]
return CIDetector(ofType: CIDetectorTypeText, context: nil, options: options)
}
テキスト検出機能:
func performTextDetection(image: CIImage) -> CIImage? {
if let detector = detector {
// Get the detections
let features = detector.featuresInImage(image)
for feature in features as! [CITextFeature] {
resultImage = drawHighlightOverlayForPoints(image, topLeft: feature.topLeft, topRight: feature.topRight,
bottomLeft: feature.bottomLeft, bottomRight: feature.bottomRight)
imagex = cropBusinessCardForPoints(resultImage!, topLeft: feature.topLeft, topRight: feature.topRight, bottomLeft: feature.bottomLeft, bottomRight: feature.bottomRight)
}
}
return resultImage
}
それは正しいもののために、左1と同様に重視する場合に動作しますが、ない: