Skip to content
/ omr Public
forked from jansenfelipe/omr

Optical Mark Recognition with PHP

Notifications You must be signed in to change notification settings

hiagodotme/omr

 
 

Repository files navigation

Optical Mark Recognition with PHP

Latest Stable Version Total Downloads Latest Unstable Version MIT license

This is an open source library written in PHP for recognition markings on questionnaires scans

See: https://en.wikipedia.org/wiki/Optical_mark_recognition

How to use

Add library:

$ composer require jansenfelipe/omr

Instantiate the Scanner class responsible for reading the image and enter its path

/*
 * Setup scanner
 */
$scanner = new ImagickScanner();
$scanner->setImagePath($imagePath);

You will need to scan a blank form and create the Target Mapping File to be able to use the library.

After creating the map.json file, enter its path:

/*
 * Setup map
 */
$map = MapJson::create($mapJsonPath);

Now you can scan and get the result

$result = $scanner->scan($map);

Scanners

This library currently has only one scanner class using Imagemagick 6. It has been tested using the following configurations:

  • PHP 7.0
  • Extension imagick-3.4.2
  • imagemagick6

See https://github.com/jansenfelipe/omr/blob/master/src/Scanners/ImagickScanner.php

Target Mapping File

It is a .json file that describes, in addition to the image information, the coordinates of the places (targets) that the script must do the pixel analysis. This file follows the following pattern:

{
    "width": 600,
    "height": 800,
    "targets": [
      {
        "x1": 50,
        "y1": 43,
        "x2": 65,
        "y2": 57,
        "id": "Foo",
        "type": "rectangle",
        "tolerance": 60
      }
    ] 
}

In the examples directory there is a map.json file that determines the targets to be read in the response.png image.

License

The MIT License (MIT)

About

Optical Mark Recognition with PHP

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 97.7%
  • Dockerfile 2.3%