Methods
(async) classification(url) → {Promise.<string>}
Classifies an image by running it through an OCR model.
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
Buffer
|
ArrayBuffer
|
The image to classify. It can be a file path (string) or image data (Buffer). |
Returns:
- Type:
-
Promise.<string>
A promise that resolves to the OCR result, represented as a string of recognized characters.
(async) detection(url) → {Promise.<Array.<Array.<number>>>}
Detects objects in an image by extracting bounding boxes and optionally
visualizing the detection results on the image.
This method reads the image, retrieves bounding boxes, and then optionally
draws the detected bounding boxes on the image if debugging is enabled.
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
Buffer
|
ArrayBuffer
|
The image to classify. It can be a file path (string) or image data (Buffer). |
Returns:
- Type:
-
Promise.<Array.<Array.<number>>>
A promise that resolves to an array of bounding boxes,
where each box is represented as [x1, y1, x2, y2], adjusted to the image size.
enableDebug() → {DdddOcr}
Enables the debug mode and prepares the debug folder.
setOcrMode(mode) → {DdddOcr}
Sets the OCR mode for the instance.
Parameters:
Name | Type | Description |
---|---|---|
mode |
MODEL_TYPE
|
The OCR mode to set. Must be one of the values from `MODEL_TYPE`. |
setRanges(charsetRange) → {DdddOcr}
Sets the range restriction for OCR results.
This method restricts the characters returned by OCR based on the input:
- For `number` input, it applies a predefined character set. See the `CHARSET_RANGE` type for the available options.
- For `string` input, each character in the string is treated as a valid OCR result.
Parameters:
Name | Type | Description |
---|---|---|
charsetRange |
CHARSET_RANGE
|
A number for predefined character sets or a string for a custom character set. |