Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jansenfelipe/omr
Optical Mark Recognition with PHP
https://github.com/jansenfelipe/omr
hacktoberfest omr optical-mark-recognition php
Last synced: 3 days ago
JSON representation
Optical Mark Recognition with PHP
- Host: GitHub
- URL: https://github.com/jansenfelipe/omr
- Owner: jansenfelipe
- Created: 2015-12-22T18:47:23.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-10T12:28:57.000Z (10 months ago)
- Last Synced: 2024-09-23T08:19:22.506Z (about 2 months ago)
- Topics: hacktoberfest, omr, optical-mark-recognition, php
- Language: PHP
- Homepage:
- Size: 402 KB
- Stars: 183
- Watchers: 20
- Forks: 75
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Optical Mark Recognition with PHP
[![Latest Stable Version](https://poser.pugx.org/jansenfelipe/omr/v/stable.svg)](https://packagist.org/packages/jansenfelipe/omr)
[![Total Downloads](https://poser.pugx.org/jansenfelipe/omr/downloads.svg)](https://packagist.org/packages/jansenfelipe/omr)
[![Latest Unstable Version](https://poser.pugx.org/jansenfelipe/omr/v/unstable.svg)](https://packagist.org/packages/jansenfelipe/omr)
[![MIT license](https://poser.pugx.org/jansenfelipe/omr/license.svg)](http://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.org/jansenfelipe/omr.svg?branch=master)](https://travis-ci.org/jansenfelipe/omr)This is an open source library written in PHP for recognition markings on questionnaires scans
See: [https://en.wikipedia.org/wiki/Optical_mark_recognition](https://en.wikipedia.org/wiki/Optical_mark_recognition)
# How to use
Add library:
```sh
$ composer require jansenfelipe/omr
```Instantiate the Scanner class responsible for reading the image and enter its path
```php
/*
* 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:
```php
/*
* Setup map
*/
$map = MapJson::create($mapJsonPath);
```Now you can scan and get the result
```php
$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.3
* imagemagick6
* Extension imagick-3.4.4See 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:
```json
{
"width": 600,
"height": 800,
"targets": [
{
"x1": 50,
"y1": 43,
"x2": 65,
"y2": 57,
"id": "Foo",
"type": "rectangle",
"tolerance": 60
}
]
}
```# Example
In the `example` directory there is an image of a completed questionnaire `response.png`. There is also a `map.json` file that gives the coordinates of the image areas that will be analyzed the pixels.
To help with setting up the environment, there is a Dockerfile in the project based on the official PHP 7.3 image that adds composer, imagemagick and the imagick extension to PHP.
That way you can install the dependencies and run the command to process the image without headaches :)
1) Clone this repo:
```ssh
$ git clone https://github.com/jansenfelipe/omr.git
$ cd omr/
```2) Install dependencies:
```ssh
$ docker-compose run php composer install
```2) Process example image:
```ssh
$ docker-compose run php bin/omr scan example/response.png example/map.json
```# License
The MIT License (MIT)