Assignment 1: Name and Roll-Number Detection from Exam Sheets


EC331 Computer Vision
Department of Computer Science
University of the Punjab
Author: Nazar Khan

Sample Input Sample Output

Write a program to detect student names and roll-numbers from exam cover sheets. A sample image is shown above. You are given a dataset of 101 images.

Your program should draw green rectangles around each detected name and roll-number, and save the resulting image in the results/ folder.

Your program should also save the pixel coordinates of the top-left and bottom-right of each rectangle along with the image name in a CSV file called boxes.csv. For example, for the 101 images, the boxes.csv file should contain 101 lines as follows.

image1.jpg 266 268 317 483 244 684 293 864
image2.jpg 249 283 302 506 235 693 282 858

image101.jpg 270 255 331 460 267 659 303 881

Each line contains 9 items in the following order:

  1. Name of the image file
  2. Row coordinate of top-left corner of box detected around the student's roll-number.
  3. Column coordinate of top-left corner of box detected around the student's roll-number.
  4. Row coordinate of bottom-right corner of box detected around the student's roll-number.
  5. Column coordinate of bottom-right corner of box detected around the student's roll-number.
  6. Row coordinate of top-left corner of box detected around the student's name.
  7. Column coordinate of top-left corner of box detected around the student's name.
  8. Row coordinate of bottom-right corner of box detected around the student's name.
  9. Column coordinate of bottom-right corner of box detected around the student's name.

If any box is not detected, then its coordinates should be replaced by 0 0 0 0. For example, if for image2.jpg, only the student's name was detected, then you will save this result as
image2.jpg 0 0 0 0 235 693 282 858

Similarly, for other cases with missing boxes.

Directory Structure:

The assignment will be graded automatically. The grading script assumes the following directory and file structure.

- top_halves/           <-- Contains the 101 images
- A1_solution/          <-- The folder containing your solution
  - results/                <-- Will contain your results on 101 images showing the detected boxes in green
  - A1_solution.py          <-- Your solution. Running 'python A1_solution.py' should populate the 'results/' folder and generate 'boxes.csv'
  - template.jpg            <-- The image region used as a template IN CASE your solution uses template matching.
  - boxes.csv               <-- The coordinates of all detected boxes.

Submission:

Hints: