Skew Correction Not Working

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);
}

@jordan59961,

Please forward us the sample slightly rotated/shifted scanned images along with sample OMR template file. We will look into it and update you with our findings.

result.jpg (480.3 KB)
original.JPG (696.7 KB)
TemplateFile
I have attached the original and resultant image to this post and have uploaded the template file to a external file hosting site as it will not allow me to upload files with extension “.amr” here. Also, I have just realized that the code I copied into the original post is not runnable as it includes both methods to correct the skew in the image. I was just commenting one method out at a time to see which one would work.

@jordan59961

We have investigated the issue at our end. It was found that Deskew image functionality is not making any change to the sample scanned OMR sheet shared by you. The issue has been logged into system with ID OCRJAVA-769 for your investigation. You will be updated automatically in this forum thread once any update is available.

Furthermore it will be a great help if you share the complete code in form of a project for better understanding.

I am not allowed to share the whole project but if there is a specific part of it you need I can most likely provide it. Basically the program is a scanner that tries to determine whether or not the checkmarks in a 39 question, 6 page survey are selected or not and outputs the values to a CSV file which is then passed to a console application that inputs the values into a website. We have about 1000 surveys we need to input by September so we are trying to automate the whole process, as each one takes ~15 min to input by hand so it is very time consuming. If anyone knows of another method or API that can correct this image shift and/or skew until the Aspose one is fixed please let me know as I am on my own in this one and need to come up with a solution by 6/30.

@jordan59961

We have updated our product team with the information you have shared. We will update you as soon as any feedback is available on this issue.