Add rotate 180 correlation sanity check

This commit is contained in:
James R. Barlow
2016-02-08 13:10:11 -08:00
parent 2c7a6e574f
commit 66fc2e9d7d
3 changed files with 12 additions and 2 deletions
+5
View File
@@ -201,6 +201,11 @@ def correlation_binary(pix1, pix2):
return correlation[0]
def rotate180(pix):
pix_rotated = lept.pixRotate180(ffi.NULL, pix)
return ffi.gc(pix_rotated, _pix_destroy)
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Python wrapper to access Leptonica")
+1
View File
@@ -53,6 +53,7 @@ void pixDestroy ( PIX **ppix );
PIX * pixDeskew ( PIX *pixs, l_int32 redsearch );
char * getLeptonicaVersion ( );
l_int32 pixCorrelationBinary(PIX *pix1, PIX *pix2, l_float32 *pval);
PIX *pixRotate180(PIX *pixd, PIX *pixs);
""")
if __name__ == '__main__':
+6 -2
View File
@@ -261,10 +261,14 @@ def test_autorotate(spoof_tesseract_cache, renderer):
xres=100, yres=100, raster_device='pngmono', log=gslog, pageno=1)
pix_ref = leptonica.pixRead(_outfile('reference.png'))
pix_ref_180 = leptonica.rotate180(pix_ref)
correlation = leptonica.correlation_binary(pix_ref, pix_ref_180)
assert correlation < 0.10
for n in range(1, 4+1):
pix_other = leptonica.pixRead(_outfile('cardinal-%i.png' % n))
print(leptonica.correlation_binary(pix_ref, pix_other))
correlation = leptonica.correlation_binary(pix_ref, pix_other)
assert correlation > 0.80
@pytest.mark.parametrize('renderer', [
'hocr',