Skip to main content

CipherLab OCR

On CipherLab devices, the integrated OCR solution can be used directly in TheFlex. In addition to the integration via the Function Key, it is also possible as a developer to trigger the OCR scan manually, parse the result, and then use it in the app.

cipherlab

In the following example, the recognized text is locally processed on the webpage and each recognized text segment is dynamically displayed in new gray lines.

Warning

This example only works on webpages opened on CipherLab devices in TheFlex.

Usage

To use the OCR plugin on your website, make sure to follow these points:

Optional Parameters

From the parameter limit_area, all subsequent parameters are optional. If you do not need to limit the capture area, set limit_area to 0. The subsequent parameters can then be set to 0 or omitted:

  • limit_area_width_for_portrait
  • limit_area_height_for_portrait
  • limit_area_width_for_landscape
  • limit_area_height_for_landscape
  • limit_area_width_for_real_time
  • limit_area_height_for_real_time
  • limit_area_width_for_reader_camera
  • limit_area_height_for_reader_camera
  • limit_area_width_for_reader_camera_real_time
  • limit_area_height_for_reader_camera_real_time

In addition, you can adjust or remove text_rules if no custom text recognition rules are required.

Error Handling

Implement appropriate error handling to catch possible OCR errors and provide helpful feedback to the user.

Compatibility

Make sure to test your website on CipherLab devices, as the OCR functionality was specifically developed for this environment.

Example Usage

To use the OCR plugin, you can use the following JavaScript code:

var config = {
enable_settings: true,
reader_camera_mode: 0,
action_mode: 1,
text_recognition_mode: 1,
remove_blank_chars: 1,
zoom_ratio: 1.5,
save_picture: 0,
limit_area: 1, // Set to 0 if no limit is needed
limit_area_width_for_portrait: 0.8, // Optional
limit_area_height_for_portrait: 0.1, // Optional
limit_area_width_for_landscape: 0.6, // Optional
limit_area_height_for_landscape: 0.3, // Optional
limit_area_width_for_real_time: 0.8, // Optional
limit_area_height_for_real_time: 0.1, // Optional
limit_area_width_for_reader_camera: 0.8, // Optional
limit_area_height_for_reader_camera: 0.1, // Optional
limit_area_width_for_reader_camera_real_time: 0.8, // Optional
limit_area_height_for_reader_camera_real_time: 0.1, // Optional
text_rules: [ // Optional
"([0-9])([0-9])([0-9])([0-9])([-|/])([0-1])([0-9])([-|/])([0-3])([0-9])",
"^[-+]{0,1}[0-9]*$"
]
};

flxOcrTrigger.triggerOCR(config, function(result) {
console.log("OCR Result:", result);
}, function(error) {
console.error("OCR Error:", error);
});