leptonica icon indicating copy to clipboard operation
leptonica copied to clipboard

Method findSkew returns incorrectr angle

Open atgorvi opened this issue 2 years ago • 1 comments

Before doing OCR i need to detect angle of text, and possibly rotate image but using findSkew function i get incorrect angle, what do I do wrong?

val skewImage: Pix = Binarize.otsuAdaptiveThreshold(Convert.convertTo8(ReadFile.readBitmap(bitmap))) val skew: Float = Skew.findSkew(skewImage) Log.i("skew", skew.toString()

findSkew_Issue Screenshot_20220525-083146_DocScanner )

atgorvi avatar May 25 '22 05:05 atgorvi

The method works on binary images, typically text or graphics. pixFindSkew, by default, only finds skew angles between -7 and +7 degrees. It may have failed in your case either because the image wasn't binarized properly to extract the inverted text (white text on dark background), or because the skew angle is larger than 7 degrees (it is), or both.

DanBloomberg avatar May 25 '22 06:05 DanBloomberg