Take a picture of a "Grade-it" math worksheet and AutoMark will automatically grade it!
This project is intended as a proof-of-concept (that automatically grading math worksheets is feasable) prior to creating a website that generates worksheets and an app that grades them.
AutoMark reads a "Grade-it" QR code/form code and uses that to get the associated answer key. It then reads students' handwritten responses. It displays a color coded worksheet showing which problems the student got right and wrong.
Adapted from SnapSuduku by Prajwal
-
Python 3
- Download from here
-
PyZBar
sudo apt-get install libzbar0
-
All other requirements can be installed using:
pip install -r requirements.txt
git clone https://github.com/tutordelphia/AutoMark.git
cd AutoMark/AutoMark
python automark.py <path-to-input-image>
Here's a image of a "Grade-it" worksheet from a smartphone:
The current code gives this output:
The student filled in 9 problems correctly and 5 problems incorrectly.
The program correctly marked 12 problems (8 correct in green and 4 incorrect in red).
The program marked 2 problems as unknown (with a yellow box and black text). It was unable to segment the connected digits on problem #2 and unable to read the student's handwriting on problem #10.
- Basic image preprocessing - Thresholding.
- Crop out the worksheet.
- Warp the perspective of the worksheet (to make it rectangular).
- Read the form code from the QR Code (using PyZBar)
- Get the boxes where the student entered their handwritten answers (filtering contours).
- Segment the handwritten digit string (this needs to be improved, currently contours are used which don't work when digits touch)
- Transform the segmented digits to MNIST's standards
- Look up the answer key from the form code.
- Predict the value of the handwritten digits using a pretrained model from Keras's example Convolutional Neural Network for MNIST.
- Display the graded result on the worksheet.
Two images are shown at some steps. The various steps perform best with different preprocessing so rather than keeping one preprocessed image, the original image is also cropped and kept.
After Preprocessing:
Crop out the largest contour:
Warp perspective to a letter sized rectangle:
Crop out the cells:
Remove the borders:
Apply thresholding and use contours to segment digit strings
Note this process will not work when digits touch (like the 2 and 3 below):
Segmented the digits:
Format the digits to match MNIST specs:
Final Result:
- Test AutoMark with a larger variety of images from different cameras.
- Improve digit string segmentation (watershed?).
- Implement a form code database.
Grade-it: A math worksheet generator
Thank you to the creators and contributors of SnapSuduku
Thank you to octagonaltree for the mentorship and guidance.
Thank you to Chris Lowen for the feedback.