I’m trying to process a human marked paper survey that contains hand written check marks with “Aspose OCR” OMR features. I created a template and everything is working perfectly except for one problem. When the survey is scanned with our Xerox machine, the images come out slightly rotated and/or shifted by about 0.25 - 0.5 inch each time, throwing off the image and resulting in the API not being able to read the values of the checkmarks as they are not perfectly centered in the template I created with the OMR template editor. I tried to use the skew correction algorithm included in the API (code below), but for some reason it is not making any changes to the image other than the fact that it is slightly darker than the original (increase in contrast). I have already checked the documentation online but could not find a solution. If anyone could guide me on what to do, that would be wonderful. Thanks!
https://pastebin.com/wvqSbgpB
Code:
java.awt.Rectangle area = new java.awt.Rectan](https://pastebin.com/wvqSbgpB)gle(0, 0, img2.getWidth(), img2.getHeight()); com.aspose.omr.imageprocessing.GrayscaleAlgorithm gs = new com.aspose.omr.imageprocessing.GrayscaleAlgorithm(); gs.process(img2, area);
// Binarization
com.aspose.omr.imageprocessing.AverageThresholdAlgorithm threshold = new com.aspose.omr.imageprocessing.AverageThresholdAlgorithm();
threshold.process(img2, area);
// Skew correction
com.aspose.omr.imageprocessing.SkewCorrectionAlgorithm skewCorrection = new com.aspose.omr.imageprocessing.SkewCorrectionAlgorithm();
skewCorrection.process(img2, area);
// save image
java.io.File fileObj = new java.io.File(“result.jpg”);
try {
ImageIO.write(img2.asBitmap(), “jpg”, fileObj);
} catch (IOException ex) {
Logger.getLogger(Scanner.class.getName()).log(Level.SEVERE, null, ex);
}
//Get skew degree of the image
double degree = engine.getSkewDegree(img2);
// Rotate image to correct skew
engine.rotateImage(img2, degree);
// Save image
File file = new java.io.File(“result.jpg”);
try {
ImageIO.write(img2.asBitmap(), “jpg”, file);
} catch (IOException ex) {
Logger.getLogger(Scanner.class.getName()).log(Level.SEVERE, null, ex);
}