Detect and correct imperfections from scanned documents with Filestack’s Document Detection

Filestack’s Document Detection automatically generates a bounded box to fit the entire document and preprocesses it to increase the OCR (Optical Character Recognition) accuracy.

A paper Screwfix receipt on the left and a cleaned-up digital version of the same receipt on the right, both showing order details, payment, VAT breakdown, and collection info. A blue arrow points from left receipt to right.
A printed receipt from Pumpkin at Oxford Station shows a subtotal of £2.45 for a 675ml latte. The date is 21/12/2010, and change given is £0.05. The receipt rests on a wooden surface.

Why Should You Use Filestack’s Document Detection?

With Filestack’s state-of-the-art preprocessing solution, you can easily detect rotated, folded or wrinkled documents that you upload. This means you can spend your development time on the core components of your application instead of correcting document detection issues.

Best OCR API for Document Detection Coupled with Intuitive Preprocessing Solutions

Filestack document detection maximizes its optical character recognition accuracy with the help of both supervised and unsupervised machine learning algorithms. These methods help our Document Detection package remain one of the most advanced options available on the market today.
Learn More

A flowchart showing the process from image upload and preprocessing to document detection using intelligent and supervised methods, ending with OCR, bounding boxes overlay, and JSON output as the final result.

How Does Document Detection Work?

1 Generate the detected mask of the document in the image for segmentation using our custom designed deep neural network that has trained on sets of thousands of image files.

2 Find the most accurate circumscribed polygon over the detected mask. This part would find the predicted perspective edges of the document within the image.

3 Warp the predicted document in the image to fit the whole image, all while keeping its aspect ratio. This part would fix any rotation, etc. in the document.

4 Denoising the warped image, fixing the distortions, and generating the final result.

A diagram showing steps in OCR preprocessing: detecting the document outline, warping the image to correct angle, and producing a clean, dewarped output of printed and handwritten text.

Filestack process in finding the most accurate document within the original image.

Empower your business with an accurate, fast, and reliable document detection solution.

A flowchart shows a photo of a magazine at the top, leading to three outputs: detected coordinates in JSON, a transformed and aligned magazine cover, and a grayscale preprocessed version. Blue arrows connect the images.

Multiple endpoints map in Document Detection.

How Can Document Detection Benefit Your Application?

Based on how you set the coords and preprocess options, Filestack will return one of three different outputs:

1 Detect the document in the actual image and return its coordinates.

2 Detect the document in the image, find the coordinates, transform the document based on its corners to fit the largest rectangle, also known as warping.

3 Detect the document in the image, find the corners, warp the document, and apply preprocessing filters to make it cleaner for OCR.

This would give you more degrees of freedom in leveraging Filestack’s Document Detection in your business without having to create custom logic in your existing application. Filestack handles all the heavy lifting for you.

Popular Use Cases

Orange line drawing of a file folder with several documents inside, resting in a document tray or box.

DOCUMENT ARCHIVING

An orange outline icon of a smartphone displaying a receipt with lines representing text, a large dollar sign in a circle, and a jagged edge at the bottom of the receipt.

INVOICE PROCESSING

Red outline icon of an identification card featuring a shield symbol, lines indicating text, and a generic person silhouette inside a photo box on the right side.

PASSPORT & ID CARD RECOGNITION

An orange outline icon of a legal document with text lines, a seal in the lower corner, and a judge’s gavel overlapping the page, symbolizing law or legal proceedings.

LEGAL CONTRACT REDACTION

SendGrid logo with stylized gray text and overlapping square shapes on the left.
Zenefits logo featuring a stylized hummingbird icon to the left of the word “ZENEFITS” in uppercase, sans-serif letters.
The word teachable is written in all lowercase, sans-serif letters with a colon between teach and able, in a light purple color on a light background.
Large, bold, purple letters spelling TED on a white background.
The image shows the classic Coca-Cola logo in a cursive script font.
The word MONSTER is written in large, bold, uppercase letters using a grayish-purple font on a light background.

Use Filestack’s Document Detection with Workflows

Chain together tasks in our simple Workflows User Interface to auto-detect your client’s document content. Filestack simplifies the process by scanning every file on upload while generating a CDN link for every file you upload so that you can create workflows to manipulate said files. Set rules and conditional logic for handling file coordinates or size and decide how to transform and deliver your files.

Use-Case

Accountant uploads a user’s documents (Word doc, PDF, image, etc.)

A receipt icon represents a document, followed by arrows pointing to Workflow Step 1: OCR tagging of document type, then to Workflow Step 2: storage categorization by form type, with icons of organized receipt stacks.

CONNECT YOUR APP TO FILES FROM OVER 20 SOURCES. SEE THEM ALL

Icon of a computer monitor displaying a pencil symbol, with a keyboard underneath, all in a simple dark outline style on a light gray circular background.
A blue circle with a white lowercase f in the center, representing the Facebook logo, on a light gray circular background.
Blue circle with a white, geometric, open box design in the center, resembling the Dropbox logo, on a light gray background.
Blue box logo in lowercase letters centered on a light gray circular background.
A circular icon with a black silhouette of a cat’s head and shoulders, resembling the GitHub logo, set against a light gray background.

WAY MORE THAN A FILE UPLOADER WIDGET: A COMPLETE INTELLIGENT UPLOAD SYSTEM.

What Filestack Can Do For You

A black silhouette of a walking cat is shown above a black rectangle with the word CAT written in white, all on a light background.

OBJECT RECOGNITION

How valuable would it be to “see” what is in every image? With our image auto-tagging service, you can easily abstract what objects appear in your uploaded images. People, animals, transportation, and thousand of other categories are at your disposal.

Icon of a document with a corner folded, overlaid by a black label displaying the white text NSFW, indicating content that is not safe for work.

EXPLICIT CONTENT DETECTION

Moderate your images to ensure you are only showing content that comply with your rules and boundaries. By implementing “safe for work” and a “not safe for work” score, our image tagging service can help you automate content moderation so you can focus on your core business.

A simple black silhouette of a dog standing inside four right-angle corner brackets on a light background, suggesting focus or selection.

OBJECT DETECTION

Sometimes knowing which objects are in your photos isn’t enough — you need to know where they are, too. Filestack Object Detection uses state-of-the-art neural networks to detect and locate common objects in photos.

Let’s Get Started.

Talk to us about how simple it can be to instantly and automatically transform any file or image.

Just One Integration, One Time…

Filestack connects you with a multitude of services with one simple integration. You never have to worry about updating API integrations again. Uploading Files is our raison d’etre. We update for other API changes, and will never depreciate our API or force unwarranted changes on you.

Libraries & SDKs
Choose from our SDKs to get started: Javascript, Ruby, PHP, Python, Swift, Android

No maintenance required
Once you integrate, you’re done. Never worry about changing APIs disrupting your file workflow again.

Dev-to-dev support
Your files are always our #1 concern. We are always here to help you get up and running and assure the best performance.

import * as filestack from 'filestack-js';
const client = filestack.init('YOUR API KEY');
client.upload(fileObject).then(data =>console.log(data.url));
gem 'filestack'
client = FilestackClient.new('YOUR_API_KEY', security: security_object)
filelink = client.upload(filepath: '/path/to/file')
$ composer require --prefer-dist filestack/filestack-php

use Filestack\FilestackClient;

$client = new FilestackClient('YOUR_API_KEY');
$filelink = $client-upload('/path/to/file');
$ pip install filestack-python

from filestack import Client client = Client("")

params = {'mimetype': 'image/png'}
new_filelink = client.upload(filepath="path/to/file", params=params)
print(new_filelink.url)
A man with a short beard wearing a red and beige baseball cap looks upward against a dark background.

“Being smart here, in my opinion, is seriously looking at Filestack to give you a fantastic uploading experience, while you spend your time on your product vision, not already-solved problems.”

— CHRIS COYIER, FOUNDER OF CSS-TRICKS & CODEPEN