A Computer Vision Project on counting votes from ballot paper that count votes and display the result for Nepali Ballot Papers.
We downloaded a sample ballot paper from election.gov.np and synthesized datasets using PIL library by overlaying swastika symbol on blank ballot paper in order and by randomization. Here is how the process looks like: | | |
1. Read the image
2. Preprocess the image(Gaussian blur, edge detection, thresholding)
3. Apply contour detection( includes all contour including texts)
4. Approximate polygon with the contour and include only if it has 4 corners and satisfy size constraints
5. Sort the rectangular by top to bottom, left to right as they appear on paper
6. Process each rectangular contours and find if there is red pixel inside any of the box
7. Set that index to True if particular index contains red color
8. Check red pixel lies outside the boxes by filling contours with black color and searching for red pixel
9. Valid if there are 39 rectangular contours and no red color in multiple boxes and no red color outside these 39 rectangular boxes
See images below for stepwise illustration:
- numpy 1.16.3
- matplotlib 3.0.3
- opencv 3.4.3
- imutils 0.5.2
- PIL 4.3.0