New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rotateRadians and osd output are incorrect #859
Comments
Adding to this.... when adding the Example
Results in..
When running in
UPDATE |
Thanks for reporting. It sounds like we need to improve documentation and/or recognition output for auto-rotate and orientation detection, and perhaps adding an output field for total page angle. The reason why Orientation detection detects how the page is oriented, with 4 discrete options: 0/90/180/270. The angle used by auto-rotate is calculated using the slope of the lines of text Tesseract identifies just prior to recognition (after orientation has been corrected). Auto-rotate is intended to adjust the image +/- 10 degrees and improves results for pages that have been photographed/scanned at an angle. To calculate the total angle of the page, as it stands, both the angle reported by orientation detection and auto-rotate would need to be combined. |
I was able to replicate the incorrect
I believe that the |
The following snippet contains a minimal test site that reports the total angle of the page, including both orientation and page rotation.
</head>
<body>
<input type="file" id="uploader" multiple>
<script type="module">
const worker = await Tesseract.createWorker("eng", 2);
worker.setParameters({tessedit_pageseg_mode: '3'})
const recognize = async function(evt){
const files = evt.target.files;
for (let i=0; i<files.length; i++) {
const ret = await worker.recognize(files[i], {rotateAuto: true}, {osd: true});
const osdAngle = parseFloat(ret.data.osd.match(/Orientation in degrees: (\d+)/)?.[1]) || 0;
const autoRotateAngle = ret.data.rotateRadians * (180 / Math.PI) * -1;
const totalAngle = osdAngle + autoRotateAngle;
console.log("osdAngle: " + osdAngle + " (degrees)");
console.log("autoRotateAngle: " + autoRotateAngle + " (degrees)");
console.log("totalAngle: " + totalAngle + " (degrees)");
console.log(ret.data.text);
}
}
const elm = document.getElementById('uploader');
elm.addEventListener('change', recognize);
</script>
</body>
</html>
">
This test image is rotated exactly 95 degrees clockwise. Results:
|
Version 5.03
When asking for
rotateRadians
from the recognize api, the radians returned are incorrect. See attached image for example. The correct text is pulled, and the image is clearly 90 degrees (or 270, or -90 however you put it), but the radians value returned is-0.010256410576403141
, which converting back to degrees, comes out to roughly-0.58
degrees.Tested the below with both PSM modes of
PSM.SPARSE_TEXT_OSD
andPSM.AUTO_OSD
Example to reproduce
When calling it directly on tesseract, Tesseract reports correct orientation
The text was updated successfully, but these errors were encountered: