3 ms·
Start by looking for the words YEA, NAY, ABSENT and PRESENT using simple OCR or pattern matching. Clip the images into 4 vertical columns the same width as the
by dagw 11y ago
Start by looking for the words YEA, NAY, ABSENT and PRESENT using simple OCR or pattern matching. Clip the images into 4 vertical columns the same width as the text, starting just below the text. Use a horizontal line detection algorithm to try to find the boundary of each 'box'. Clip out each box and count the number of black pixels. If it's greater than some level, then that box contains a tick.
OpenCV should be able to do all these things.
- dagw 11y agoActually forget OCR. Just find the y and x coordinates of each horizontal and vertical line, and then clip out each box in the grid using those coordinates. Count black pixels and done. I hacked together something in python (because I had laundry to do :) ) and it seems to work pretty well.
- dagw 11y agoQuick hack, badly tested, but seems to work: https://gist.github.com/dwastberg/9faea8a4ceb6dc05b52e https://gist.github.com/dwastberg/9faea8a4ceb6dc05b52e
- dagw 11y agoOf course this code breaks if the scan isn't straight.
- semiquaver 11y agoYou're already using imagemagick's `convert` in that script - there's also `textcleaner -u`[1] which among other things automatically straightens slightly crooked text in scans (less than 5 degrees). [1] http://www.fmwconcepts.com/imagemagick/textcleaner/ http://www.fmwconcepts.com/imagemagick/textcleaner/