-
Notifications
You must be signed in to change notification settings - Fork 24
This is the API reference of FormVision. It lists all functions that can be called, documents the parameters and provides small code snippets to facilitate learning. Its a good idea to scan text at 300dpi or higher and require DocumentVision along with FormVision:
dv = require('dv');
fv = require('fv');Note: Since the API is far from final, this page is a work in progress.
Functions in fv.filters provide image filters for pre-processing. A filter will not modify its source image. In case those filters do not meet your requirements you should take a look at DocumentVision's Image.
This filter converts the specified image to black and white using a computed threshold.
This filter select gray-ish pixel blobs of an approximated font size and darkens them. Saturated and large pixels are left unmodified.
This filter tries to estimate and remove the skew of an image by analyzing the horizontal and vertical projection.
This filter removes gray-ish background while protecting pixel blobs with approximate font size.
This filter removes red-ish color (pre-print) from the image while protecting gray-ish pixels.
A fv.FormReader object composes text, barcode and checkbox reading.
Initializes a form reader with the specified Tesseract language and image as input.
Accessor for the input image this barcode reader operates on.
Accessor for the used dv.Tesseract object. Useful if you want to set tesseract configuration variables.
Accessor for the used dv.ZXing object. Useful if you want to restrict barcode reading.
Returns a Form object after raw recognition.
A fv.Form represents raw form data after recognition.
Matches this raw form data to the specified schema, calling cb(err, result) when done. A schema has the following format:
schema = {
// Bounding Box of the expected page in schema coordinates.
"page": dv.Box,
// Words at specified locations, that may be used for estimation of a projection.
"words": [ {
"text": String
"box": dv.Box
} ],
// Array of expected form fields.
"fields": [ {
// A fully qualified name of the field (e.g. "group1.field1")
"path": String,
// Type of data (text, barcode, checkbox)
"type": String,
// Expected relative location on the page.
"box": dv.Box,
// Function used for field validation (e.g. "is this a date?")
"fieldValidator": function(value) {return Boolean;},
// Function used for field selection, if ambiguous (e.g. "pick 1.1.1900 instead of 111900")
"fieldSelector": function(choices) {return 0;},
// Function used for async. form validation (e.g. "auto-complete field A from field B and C or fail otherwise")
"formValidator": function(formData, done) {done(err);}
} ]
}Most matching is content- and position-sensitive. Conflict resolution during matching does not exploit inference to prevent cascading errors.
A result has the following format:
result = {
"group1": {
"field1": {
// The actual value.
"value": Any
// Confidence between 0..100%.
"confidence": Number
// Location on the page.
"box": dv.Box
// Paths of other fields also claiming ownership on this value.
"conflicts": [Path]
}
}
}Returns raw form data as object:
{
// ZXing Barcode.
"barcodes": [ {
"box": dv.Box,
// see result of dv.ZXing#findCode()
} ],
// Tesseract Word.
"text": [ {
"box": dv.Box,
// see result of dv.Tesseract#findWords()
} ],
// Checkbox.
"checkboxes": [
"box": dv.Box,
"checked": Boolean,
"confidence": Number
]
}Returns an annotated image for visual debugging.