Add rotate 180 correlation sanity check
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user