저는 Swift 3을 사용하고 사용자가 사진을 찍고 Tesseract OCR을 사용하여 텍스트를 인식하는 응용 프로그램을 개발 중입니다.Swift 3 - Tesseract는 이미지 조작에 대한 던지기 오류를 인식합니다.
다음 코드 블록이 작동합니다.
Error in pixCreateHeader: depth must be {1, 2, 4, 8, 16, 24, 32}
Error in pixCreateNoInit: pixd not made
Error in pixCreate: pixd not made
Error in pixGetData: pix not defined
Error in pixGetWpl: pix not defined
2017-03-13 11:13:05.336796 ProjectName[35238:9127211] Cannot convert image to Pix with bpp = 64
Error in pixSetYRes: pix not defined
Error in pixGetDimensions: pix not defined
Error in pixGetColormap: pix not defined
Error in pixClone: pixs not defined
Error in pixGetDepth: pix not defined
Error in pixGetWpl: pix not defined
Error in pixGetYRes: pix not defined
Please call SetImage before attempting recognition.Please call SetImage before attempting recognition.2017-03-13 11:13:05.343568 EOB-Reader[35238:9127211] No recognized text. Check that -[Tesseract setImage:] is passed an image bigger than 0x0.
나는 사진을 회전하는 조작 할 몇 가지 :
나는 모든 (stillPicture.image!
)에서 사진을 조작하려고하면
func processPhoto() {
if let tesseract = G8Tesseract(language: "eng") {
tesseract.delegate = self
// this is the resulting picture gotten after running the capture delegate
tesseract.image = stillPicture.image!
tesseract.recognize()
}
}
그러나, 나는 다음과 같은 오류가 발생합니다
// Rotate taken picture
let orig_image = stillPicture.image!
let new_image_canvas = UIGraphicsImageRenderer(size: CGSize(width: stillPicture.image!.size.height,
height: stillPicture.image!.size.width))
let new_image = new_image_canvas.image { _ in
let curr_context = UIGraphicsGetCurrentContext()!
curr_context.translateBy(x: 0, y: stillPicture.image!.size.width)
curr_context.rotate(by: -.pi/2)
stillPicture.image!.draw(at: .zero)
}
tesseract.image = new_image
내가 그렇게하면 붐! 위의 오류가 발생합니다.
내가하는 또 다른 조작은 이미지의 일부를 잘라내는 것입니다.
let finalImage : UIImage
let crop_section = CGRect(x: 590.0, y: 280.0, width: 950.0, height: 550.0)
let cg_image = stillPicture.image!.cgImage?.cropping(to: crop_section)
finalImage = UIImage(cgImage: cg_image!)
tesseract.image = final_image
또 다시, 붐! 오류가 나타납니다. 왜 이런 일이 일어나고 내 이미지 조작으로 인해 문제가 발생하는지 생각해보십시오. 당신의 도움을 주셔서 감사합니다!
답변 해 주셔서 감사합니다. 실제로, 나는 그것을 고칠 수있는 것을 모르지만, 나는 내 사진 회전을 한 코드를 꺼내었고, 사진은 여전히 (어떤 이유로) 회전되어 있고 더 이상 오류가 없다. : / – noblerare