Giter Club home page Giter Club logo

omr's Introduction

omr

Python application

omr is a small Python 3 optical mark recognition script. It takes as input an image of an answered answer sheet and outputs which alternatives were marked. The project is generally optimized for conciseness and teachability, and the goal is to provide a reasonable starting point for learning and hopefully building more powerful applications.

Usage

$ python omr.py --help
usage: omr.py [-h] --input INPUT [--output OUTPUT] [--show]

optional arguments:
  -h, --help       show this help message and exit
  --input INPUT    Input image filename
  --output OUTPUT  Output annotated image filename
  --show           Displays annotated image

Example

$ python omr.py --input img/answered-sheet-photo.jpg  --output /tmp/results.png --show

Q1: A
Q2: C
Q3: C
Q4: E
Q5: N/A
Q6: N/A
Q7: A
Q8: N/A
Q9: N/A
Q10: N/A

In this case, we used the following image as input:

Input

And got the following output:

Output

Installation

Using pipenv with pyenv

Install pyenv

$ git clone https://github.com/rbaron/omr
$ cd omr/
$ pyenv install 3.7.5
$ pyenv local 3.7.5
$ pipenv --python 3.7.5
$ pipenv install
$ pipenv shell
$ py.test

Using virtualenv

$ git clone https://github.com/rbaron/omr
$ cd omr/
$ virtualenv --python=`which python3` venv
$ source venv/bin/activate
(venv) $ pip install -r requirements.txt
(venv) $ python omr.py --help

Anwer Sheet

The answer sheet is available in the sheet/ directory.

Development

Run unit tests

test_omr.py contains unit tests that can be run using:

$ py.test
=========================================================== test session starts ===========================================================
platform darwin -- Python 3.7.5, pytest-5.2.4, py-1.8.0, pluggy-0.13.0
collected 1 item

test_omr.py .                                                                                                                       [100%]

============================================================ 1 passed in 0.31s ============================================================

omr's People

Contributors

chapatiyaq avatar dependabot[bot] avatar rbaron avatar ridaayed avatar scls19fr avatar xettri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

omr's Issues

How Other Then sample sheet be evaluated

Dear Sir I am facing problem when I give some sheet other then sample give in project How I fix this kindly guide me. Suppose I want to evaluate 100 number of question sheet. And It Produce correct result only when diagonal sample page given to it he I fix it?

Python 3

Hello,

It will be great to have a Python 3 version of this script.
#7 is an unsuccessful attempt to convert from Python 2 to Python 3.

Kind regards

Column issue

H rbaron,
I'm having some trouble when trying to make some more Column in your code.
Please help!

Enable continuous integration

Hello,

Continuous integration should be enabled (Travis-CI for example)

CI could run unit tests but could also check (using flake8 for example) that code respect PEP8.

Best regards

error while compiling in Windows

Traceback (most recent call last):
File "omr.py", line 251, in
main()
File "omr.py", line 234, in main
answers, im = get_answers(args.input)
File "omr.py", line 189, in get_answers
contours = get_contours(im)
File "omr.py", line 27, in get_contours
image_gray, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: need more than 2 values to unpack

90% fail rate on scanned sheet.pdf

Nice work, thank you. Maybe you can see something I missed while testing with the scanned sheet.pdf

$ python omr.py --input ./scan_2022-01-07-162351_001.jpg  --output /tmp/results.png --show

Q1: A
Q2: C
Q3: C
Q4: E
Q5: N/A
Q6: N/A
Q7: A
Q8: N/A
Q9: N/A
Q10: N/A

scan_2022-01-07-162351_001.jpg (using sheet.pdf):
scan_2022-01-07-162351_001

results.png
results

perspective transform is not done correctly

Hi,
Instead of detecting the corners as in the picture here, the calculation is made over the corners of the largest rectangle containing the contours (corner.png). How can we do this so that it detects the corners of each corner.png.
I think we should develop this project. this project is one of the nice omr (made with python) projects on github.
https://camo.githubusercontent.com/b3272c76cfe1dbd447255e330e5e7f8d4425621b26853b2724455b6b30502554/687474703a2f2f692e696d6775722e636f6d2f346e39664b46462e706e67

wrong project

hi

when i want to use this project the python said

SyntaxError: invalid syntax

please help me

Different bubblesheet

It is simple and good code.
If we want to create different type of bubblesheets, What changes need to done in the code. Can you add documents or some tutorial for the same.

Hi rbaron different sheet

Hello dear Baron. I want to use a different sheet, but i can't do this. I changed fixed dimension (height of each question is 40) because i used 20 questions. What changes need to done in the code?

No matching distribution found for opencv-python==4.2.0.32

[ra@x omr]$ virtualenv --python=`which python3` venv         

created virtual environment CPython3.10.1.final.0-64 in 229ms
  creator CPython3Posix(dest=/home/ra/src/omr/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/ra/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==60.1.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

[ra@x omr]$ source venv/bin/activate

(venv) [ra@x omr]$ pip install -r requirements.txt                  

Collecting atomicwrites==1.3.0
  Using cached atomicwrites-1.3.0-py2.py3-none-any.whl (5.9 kB)
Collecting attrs==19.3.0
  Using cached attrs-19.3.0-py2.py3-none-any.whl (39 kB)
Collecting importlib-metadata==0.23
  Using cached importlib_metadata-0.23-py2.py3-none-any.whl (28 kB)
Collecting more-itertools==7.2.0
  Using cached more_itertools-7.2.0-py3-none-any.whl (57 kB)
Collecting numpy==1.17.4
  Using cached numpy-1.17.4.zip (6.4 MB)
  Preparing metadata (setup.py) ... done
ERROR: Could not find a version that satisfies the requirement opencv-python==4.2.0.32 (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62)
ERROR: No matching distribution found for opencv-python==4.2.0.32

(venv) [ra@x omr]$ python -V
Python 3.10.1

answer sheet coordinate settings

Hi, can you explain in detail all the settings below to create a new answer sheet? For example, why is the answer sheet 740x1049 according to which unit?
or why ANSWER_PATCH_HEIGHT_WITH_MARGIN what does 80 represent and in what unit?
Thanks..
ANSWER_SHEET_WIDTH = 740
ANSWER_SHEET_HEIGHT = 1049

ANSWER_PATCH_HEIGHT = 50
ANSWER_PATCH_HEIGHT_WITH_MARGIN = 80
ANSWER_PATCH_LEFT_MARGIN = 200
ANSWER_PATCH_RIGHT_MARGIN = 90
FIRST_ANSWER_PATCH_TOP_Y = 200

ALTERNATIVE_HEIGHT = 50
ALTERNATIVE_WIDTH = 50
ALTERNATIVE_WIDTH_WITH_MARGIN = 100

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.