Seems to me it requires that you scan a paper, then look in precise areas where blocks are either filled in or left untouched.
The program needs to know exactly where to look for each area, and how large it is. It must tally the overall darkness of the pixels. It must distinguish whether it corresponds to the area being filled or not.
The program counts the blocks that are filled when they should not be. And vice-versa.
Beforehand you told it whether to count only right answers, or to subtract wrong answers as well.
From that it computes the test score.