Udayraj123 / OMRChecker

Evaluate OMR sheets fast and accurately using a scanner 🖨 or your phone 🤳.
MIT License
732 stars 304 forks source link

[Enhancement][Core] New approaches for Page/Template Alignment #196

Open Udayraj123 opened 1 month ago

Udayraj123 commented 1 month ago

The template alignment problem is one of the central problems which currently remains unsolved for a general OMR sheet. This issue tracks various issues that we have noticed over a period of time in various samples.

Shifts during scanning

Despite fixing page curvature, we may still face the template alignment problem. Sometimes a scanner may malfunction at minute levels, we have seen uneven stretching of the page when using a basic scanner. The boxes need to be close to the bubbles otherwise the output is not reliable for any OMR checking software. Example:

image

Curvature during bulk scanning

Sometimes the scan itself seems to be curved. we can see that the instructions text is not in a straight horizontal line. Example:

image

The scans need to be straightened before applying template detection.

PDF-printed vs Photocopied misalignment

We have also seen shifts upto 10 pixels between scans of pdf-printed vs photocopied sheets. Link to an explainer: Google Drive

Describe the solution you'd like Rough notes (ref):

- **Get all control-destination points **
    - From SIFT: 
        - Filter list: Slide a 10px(windowSize) window on the image and pick the point with max score
        - Filter list: pick the points with reasonable shifts(maxDisplacement)
    - This way we can scale to any set of feature detectors like ORB or custom detectors from the ScanZones. Just need a set of control-destination pairs.

- **Align the points **
    - Approach 1: 
        - Loop over each field, find 4 nearest anchor points and
        - apply the transform on the field box using findHomography
    - Approach 2: 
        - Triangulate the whole image based on the anchor points and 
        - perform affine transform on each triangle(all pixels get transformed)
image image

Describe alternatives you've considered There are many other approaches that can be tried:

Additional context NA