1. Products
  2.   OMR
  3.   PHP
  4.   FormRead
 
  

Free PHP OMR API to Parse Scanned Forms and Images Online

Open source Optical Mark Recognition PHP Library Designed for Parsing Scanned Forms and Detecting Marked Answers from Predefined Zones inside PHP Application.

What is FormRead?

In today's digital world, automating data extraction from forms is crucial for businesses, educational institutions, and research organizations. In the field of data collection, Optical Mark Recognition (OMR) remains a trusted method for scanning and interpreting marked data on forms, surveys, tests, and ballots. FormRead, an open-source PHP OMR (Optical Mark Recognition) API, provides a powerful solution for reading and processing marked forms efficiently. It is a PHP-based OMR API designed to detect and interpret marked areas on scanned forms, surveys, or answer sheets. It is particularly useful for automating data collection from paper-based forms, reducing manual entry errors, and improving efficiency.

FormRead is an open source Optical Mark Recognition library written in PHP. It supports a variety of field types commonly found in OMR forms, such as checkboxes, text, choice and group. The library is specifically designed for parsing scanned forms and detecting marked answers from predefined zones—ideal for use cases like MCQ exams, feedback forms, voting ballots, or any form-based data collection. The library allows developers to define zones (or “grids”) on a form image and then detect which of those zones are marked (filled) by users. There are several important features part of the library, such as flexible form definition, load and process the image, threshold sensitivity handling, various image format support, customizable templates, Barcode & QR Code support, and many more. FormRead is a versatile PHP OMR API that simplifies automated form processing. Whether you're grading exams, processing surveys, or digitizing records, it offers a flexible and efficient solution.

Previous Next

Getting Started with FormRead

The recommend way to install PHP FormRead Library is using Composer. Please use the following command for a smooth installation.

Install OFormReadMR via Composer

 composer require mojv/formread
 

Install FormRead via GitHub

git clone https://github.com/mojv/FormRead.git
cd FormRead 

Processing the Scanned Form with PHP

The open source FormRead library makes it easy for software developers to load and process the scanned forms and images inside PHP applications. First, you would have a scanned image of the completed form, let's call it filled_form.jpg. The following PHP script uses FormRead to process this image by calling the processImage() method with the path to the scanned form. The results are then encoded as a nicely formatted JSON and printed.

How to Process a Scanned Form inside PHP Apps?

require 'vendor/autoload.php';

use FormRead\FormRead;

// Path to the form definition and the scanned image
$formJsonPath = 'path/to/your/form.json';
$imagePath = 'path/to/your/filled_form.jpg';

try {
    // Create a new FormRead instance
    $formRead = new FormRead($formJsonPath);

    // Process the image
    $results = $formRead->processImage($imagePath);

    // Output the results as JSON
    header('Content-Type: application/json');
    echo json_encode($results, JSON_PRETTY_PRINT);

} catch (Exception $e) {
    // Handle any errors
    echo 'Error: ' . $e->getMessage();
}

Custom Field Coordinate Mapping

The FormRead library has provided complete support for custom form fields coordinate mapping inside PHP applications. Software developers can define the exact location of each checkbox or bubble using pixel coordinates (x, y), width, and height. This is essential because every form layout is different. The following example shows how to define custom form with the exact locations via PHP API.

How to Define Custom Form Fields with the Exact Locations via PHP API?

$fields = [
    ['x' => 100, 'y' => 200, 'width' => 20, 'height' => 20],  // Question 1 - Option A
    ['x' => 130, 'y' => 200, 'width' => 20, 'height' => 20],  // Question 1 - Option B
    ['x' => 160, 'y' => 200, 'width' => 20, 'height' => 20],  // Question 1 - Option C
    // Add more fields as needed...
];

Bulk Forms Processing via PHP API?

Thanks to its simple design and use of efficient image processing techniques, the open source FormRead library can process forms in batches with ease. Due to this powerful form processing, making it suitable for exam grading systems or bulk survey imports. The following example demonstrates how software developers can perform batch forms processing using PHP commands.

How to Perform Batch Form Processing using PHP Library?

$scans = ['form1.jpg', 'form2.jpg', 'form3.jpg'];

foreach ($scans as $form) {
    $results = FormRead::read($form, $fields);
    // Save to DB or evaluate result
    echo "Form $form: " . implode(',', $results) . "\n";
}