Так что я пытаюсь сделать текстовый детектор, используя CIDetector в swift. Когда я указываю свой телефон на кусок текста, он не обнаруживает его. Однако, если я поворачиваю свой телефон в сторону, он работает и обнаруживает текст. Как я могу изменить его так, чтобы он обнаруживал текст при правильной ориентации камеры? Вот мой код:Как изменить ориентацию 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
}
Он работает при ориентировании как и левая, но не за право одного: