Closed sunshineo closed 8 years ago
Maybe this is my own problem. When I use the library, I have to rotate the image left before pass to it.
let image2: UIImage = UIImage(CGImage: imageRef, scale: image.scale, orientation: UIImageOrientation.Left)
Otherwise, it cannot recognize properly. I'm taking a photo with iphone vertically, so maybe that is the problem. I only realized this after I created the pull request.
@sunshineo, as I remember, the framework can rotate images if they contain the rotation info. Do you do any image preprocessing, which removes rotation info from the image?
@ws233 No pre-processing. Straight out of the camera and into Tesseract. It did not work at first at all. Later I discovered that if I took the picture horizontally and pass to Tesseract it works. So since my app will always took the picture vertically (My app does not have a horizontal mode), I programmatically rotated it left as shown above in the Swift code. And then I ran into this problem when I try to use imageWithBlocks. All the blocks are in the right place, but the image is upside down, unless I do that fix to rotate it right.
I just discovered that if the thresholded is set to true, this rotation is not needed. I'm going to close this one and create a new pull request.
The issue is that nevermind of the orientation of the device, the pixels in the image are always located in the same order. Only the imageOriantation
tells how to draw the image on the screen.
imageWithBlocks
doesn't consider the imageOriantation
property of the image.
So you'd better fix the drawing code there.
In the case of the thresholding, the image is preprocessed for you automatically. And if I remember correctly, the preprocessing considers the imageRotation. Therefore you have a correct result after the preprocessing.
Hi @ws233 , could you help me understand your comments? The imageOriantation
is a property on UIImage?
By "So you'd better fix the drawing code there.", where do you mean exactly? The imageWithBlocks
function?
Thank you very much!
Yes it's. Twice :)
Thank you! I'm copying your comments to the newer pull request I created.
You may work in this PR if you wish
…ws upside down.