• Stars
    star
    183
  • Rank 210,154 (Top 5 %)
  • Language
    PHP
  • Created almost 9 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Optical Mark Recognition with PHP

Optical Mark Recognition with PHP

Latest Stable Version Total Downloads Latest Unstable Version MIT license Build Status

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.3
  • imagemagick6
  • Extension imagick-3.4.4

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
      }
    ] 
}

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:
$ git clone https://github.com/jansenfelipe/omr.git
$ cd omr/
  1. Install dependencies:
$ docker-compose run php composer install
  1. Process example image:
$ docker-compose run php bin/omr scan example/response.png example/map.json

License

The MIT License (MIT)

More Repositories

1

cpf-gratis

Com esse pacote você poderá realizar consultas de CPF no site da Receita Federal do Brasil gratuitamente.
PHP
177
star
2

cnpj-gratis

Com esse pacote você poderá consultar, gratuitamente, CNPJ diretamente no site da receita
PHP
162
star
3

androidmask

AndroidMask: Add mask on your EditText components
Java
88
star
4

nfephp-serialize

Transforme NFe(xml) em objetos PHP e vice-versa
PHP
69
star
5

cep-gratis

Com esse pacote você poderá realizar consultas de CEP gratuitamente.
HTML
65
star
6

utils

Uma simples classe utilitária com métodos que podem salvar sua vida (ou não)
PHP
62
star
7

cidades-gratis

Com esse pacote você poderá consultar, gratuitamente, Cidades diretamente no site do IBGE.
PHP
40
star
8

faker-br

Provider do Faker para gerar dados brasileiros falsos com o intuito de testar softwares
PHP
33
star
9

cadastro-empresa

Este é um projeto simples escrito em PHP para exemplificar o uso do package jansenfelipe/cnpj-gratis
PHP
29
star
10

sintegra-php

Com esse pacote você poderá gerar gratuitamente o arquivo Sintegra para envio a Sefaz.
PHP
14
star
11

fipe-gratis

Com esse pacote você poderá consultar dados atualizados da tabela FIPE
PHP
10
star
12

ncm

Lista atualizada de Nomeclatura Comum do Mercosul
9
star
13

nfe-gratis

Com esse pacote você poderá consultar, gratuitamente, NFe diretamente no site da receita.
PHP
8
star
14

laravel-angular-material

Projeto de exemplo utilizando Laravel + AngularJS + Material Design
PHP
8
star
15

loggi-php

Abstraction layer PHP to integrate with a Loggi API
PHP
5
star
16

laraeditable

Edit images and texts in Laravel Views
PHP
4
star
17

sdaps-php

Integration Sdaps with PHP - http://sdaps.org/
PHP
4
star
18

phpstring

Create objects filling attribute classes with string data
PHP
4
star
19

exemplo-laravel-listar-registros

Projeto para exemplificar a listagem de registros com o Laravel
PHP
3
star
20

cfop

Lista atualizada de Código Fiscal de Operação e Prestação
1
star
21

phpgratis

CSS
1
star
22

contactMe

Tutorial para Iniciantes - Laravel 5
PHP
1
star