Scanbot SDK
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
Scanbot C SDK Barcode Recognizer

Classes

struct  scanbotsdk_barcode_recognizer_init_params_t
 Barcode recognizer initialization parameters. More...
 

Typedefs

typedef enum scanbotsdk_barcode_format_t scanbotsdk_barcode_format_t
 Barcode format, also called symbology.
 
typedef enum scanbotsdk_barcode_engine_mode_t scanbotsdk_barcode_engine_mode_t
 Barcode recognition engine modes.
 
typedef struct scanbotsdk_barcode_recognizer_init_params_t scanbotsdk_barcode_recognizer_init_params_t
 Barcode recognizer initialization parameters.
 
typedef struct scanbotsdk_barcode_recognizer_t scanbotsdk_barcode_recognizer_t
 Represents an instance of the barcode recognizer.
 
typedef struct scanbotsdk_barcode_result_t scanbotsdk_barcode_result_t
 Represents the result of a call to scanbotsdk_barcode_recognizer_recognize.
 

Enumerations

enum  scanbotsdk_barcode_format_t {
  SCANBOTSDK_BARCODE_FORMAT_UNKNOWN = 0 ,
  SCANBOTSDK_BARCODE_FORMAT_AZTEC ,
  SCANBOTSDK_BARCODE_FORMAT_CODABAR ,
  SCANBOTSDK_BARCODE_FORMAT_CODE_39 ,
  SCANBOTSDK_BARCODE_FORMAT_CODE_93 ,
  SCANBOTSDK_BARCODE_FORMAT_CODE_128 ,
  SCANBOTSDK_BARCODE_FORMAT_DATA_MATRIX ,
  SCANBOTSDK_BARCODE_FORMAT_EAN_8 ,
  SCANBOTSDK_BARCODE_FORMAT_EAN_13 ,
  SCANBOTSDK_BARCODE_FORMAT_ITF ,
  SCANBOTSDK_BARCODE_FORMAT_PDF_417 ,
  SCANBOTSDK_BARCODE_FORMAT_QR_CODE ,
  SCANBOTSDK_BARCODE_FORMAT_RSS_14 ,
  SCANBOTSDK_BARCODE_FORMAT_RSS_EXPANDED ,
  SCANBOTSDK_BARCODE_FORMAT_UPC_A ,
  SCANBOTSDK_BARCODE_FORMAT_UPC_E ,
  SCANBOTSDK_BARCODE_FORMAT_UPC_EAN_EXTENSION ,
  SCANBOTSDK_BARCODE_FORMAT_MSI_PLESSEY ,
  SCANBOTSDK_BARCODE_FORMAT_IATA_2_OF_5 ,
  SCANBOTSDK_BARCODE_FORMAT_INDUSTRIAL_2_OF_5 ,
  SCANBOTSDK_BARCODE_FORMAT_ONE_D
}
 Barcode format, also called symbology. More...
 
enum  scanbotsdk_barcode_engine_mode_t {
  SCANBOTSDK_BARCODE_ENGINE_MODE_LEGACY_FAST = 0 ,
  SCANBOTSDK_BARCODE_ENGINE_MODE_FASTEST ,
  SCANBOTSDK_BARCODE_ENGINE_MODE_FAST ,
  SCANBOTSDK_BARCODE_ENGINE_MODE_BALANCED ,
  SCANBOTSDK_BARCODE_ENGINE_MODE_BEST
}
 Barcode recognition engine modes. More...
 

Functions

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_recognizer_create (const scanbotsdk_barcode_recognizer_init_params_t *params, scanbotsdk_barcode_recognizer_t **recognizer)
 Creates a new instance of the barcode recognizer.
 
SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_recognizer_free (scanbotsdk_barcode_recognizer_t *recognizer)
 Destroys the barcode recognizer instance.
 
SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_recognizer_recognize (scanbotsdk_barcode_recognizer_t *recognizer, const scanbotsdk_image_t *input, scanbotsdk_barcode_result_t **result)
 Recognize barcodes in an image.
 
SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_free (scanbotsdk_barcode_result_t *result)
 Destroys the barcode result instance.
 
SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_count (const scanbotsdk_barcode_result_t *result, int *count)
 Returns the count of detected barcodes in a result.
 
SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_format (const scanbotsdk_barcode_result_t *result, int index, scanbotsdk_barcode_format_t *format)
 Returns the barcode format of a the given barcode in a result.
 
SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_text (const scanbotsdk_barcode_result_t *result, int index, const char **text)
 Returns the barcode text as a null-terminated UTF8-encoded string of the given barcode in a result.
 
SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_quad (const scanbotsdk_barcode_result_t *result, int barcode_index, int *quad)
 Returns the coordinates in pixel space of the four corners of a given barcode in the result.
 
SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_raw_bytes (const scanbotsdk_barcode_result_t *result, int index, const unsigned char **raw_bytes, int *length)
 Returns the raw bytes of a given barcode from the result.
 

Detailed Description


Class Documentation

◆ scanbotsdk_barcode_recognizer_init_params_t

struct scanbotsdk_barcode_recognizer_init_params_t

Barcode recognizer initialization parameters.

Public Attributes

scanbotsdk_barcode_engine_mode_t engine_mode
 The barcode recognition engine mode.
 
const scanbotsdk_barcode_format_tformats
 An array of barcode formats to be detected. If null or empty, all formats will be recognized.
 
int formats_count
 If formats is a valid pointer, set this field to the number of elements in the array.
 
bool use_tensorrt
 If true, the barcode recognizer will use the TensorRT backend for GPU acceleration.
 
int tensorrt_max_input_width
 The maximum input width in pixels for TensorRT. If 0, the default value will be used.
 
int tensorrt_max_input_height
 The maximum input height in pixels for TensorRT. If 0, the default value will be used.
 
size_t tensorrt_max_workspace_size
 The maximum workspace size in bytes for TensorRT. If 0, the default value will be used.
 

Member Data Documentation

◆ use_tensorrt

bool use_tensorrt

If true, the barcode recognizer will use the TensorRT backend for GPU acceleration.

When enabling TensorRT, use the smallest input image size that fits your use case. The bigger the image size, the more memory is required model at runtime. It takes around 3 minutes to build the TensorRT engine for the first time. The engine is then cached on disk and reused. The cached engine can be copied to other devices with the same device model, Jetpack version, CUDA version and TensorRT version.

Typedef Documentation

◆ scanbotsdk_barcode_engine_mode_t

Barcode recognition engine modes.

The engine mode controls the trade-off between speed and recall. Faster modes are not guaranteed to recognize all barcodes in the image.

◆ scanbotsdk_barcode_format_t

Barcode format, also called symbology.

The values are used both to set the barcode formats to be recognized, and to indicate the format of a recognized barcode.

◆ scanbotsdk_barcode_recognizer_t

Represents an instance of the barcode recognizer.

Must be destroyed with scanbotsdk_barcode_recognizer_free after use.

◆ scanbotsdk_barcode_result_t

Represents the result of a call to scanbotsdk_barcode_recognizer_recognize.

Must be destroyed with scanbotsdk_barcode_result_free after use.

Enumeration Type Documentation

◆ scanbotsdk_barcode_engine_mode_t

Barcode recognition engine modes.

The engine mode controls the trade-off between speed and recall. Faster modes are not guaranteed to recognize all barcodes in the image.

Enumerator
SCANBOTSDK_BARCODE_ENGINE_MODE_LEGACY_FAST 

Legacy recognition mode, optimized for extremely slow, low memory devices

SCANBOTSDK_BARCODE_ENGINE_MODE_FASTEST 

Live recognition mode, optimized for low memory devices.

The default maximum input image size is 1280x1280 pixels when TensorRT is enabled. The default maximum workspace size is 16MB.

SCANBOTSDK_BARCODE_ENGINE_MODE_FAST 

Live recognition mode with higher accuracy.

The default maximum input image size is 1280x1280 pixels when TensorRT is enabled. The default maximum workspace size is 16MB.

SCANBOTSDK_BARCODE_ENGINE_MODE_BALANCED 

Single-shot recognition mode for static images.

The default maximum input image size is 1920x1920 pixels when TensorRT is enabled. The default maximum workspace size is 64MB.

SCANBOTSDK_BARCODE_ENGINE_MODE_BEST 

Single-shot recognition mode for static images, slower with higher accuracy.

The default maximum input image size is 1920x1920 pixels when TensorRT is enabled. The default maximum workspace size is 64MB.

◆ scanbotsdk_barcode_format_t

Barcode format, also called symbology.

The values are used both to set the barcode formats to be recognized, and to indicate the format of a recognized barcode.

Enumerator
SCANBOTSDK_BARCODE_FORMAT_ONE_D 

This special value can be passed to the BarcodeRecognizer constructor to enable recognition of all 1D barcode formats. This value will never be returned as a result of barcode recognition.

Function Documentation

◆ scanbotsdk_barcode_recognizer_create()

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_recognizer_create ( const scanbotsdk_barcode_recognizer_init_params_t params,
scanbotsdk_barcode_recognizer_t **  recognizer 
)

Creates a new instance of the barcode recognizer.

Parameters
paramsThe barcode recognizer initialization parameters
recognizerPointer to a variable that will be set to the new barcode recognizer instance.
Returns
: Error code, SCANBOTSDK_OK if creation was successful

◆ scanbotsdk_barcode_recognizer_free()

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_recognizer_free ( scanbotsdk_barcode_recognizer_t recognizer)

Destroys the barcode recognizer instance.

Parameters
recognizerPointer to the barcode recognizer

◆ scanbotsdk_barcode_recognizer_recognize()

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_recognizer_recognize ( scanbotsdk_barcode_recognizer_t recognizer,
const scanbotsdk_image_t input,
scanbotsdk_barcode_result_t **  result 
)

Recognize barcodes in an image.

Parameters
recognizerPointer to the barcode recognizer
inputPointer to the input image data
resultPointer to a variable that will be set to the barcode result
Returns
: Error code, SCANBOTSDK_OK if no errors were encountered

◆ scanbotsdk_barcode_result_free()

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_free ( scanbotsdk_barcode_result_t result)

Destroys the barcode result instance.

Parameters
resultPointer to the barcode result instance
Returns
: Error code, SCANBOTSDK_OK if no errors were encountered

◆ scanbotsdk_barcode_result_get_count()

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_count ( const scanbotsdk_barcode_result_t result,
int *  count 
)

Returns the count of detected barcodes in a result.

Parameters
resultPointer to the barcode result
countPointer to an int variable to hold the count of detected barcodes
Returns
: Error code, SCANBOTSDK_OK if no errors were encountered

◆ scanbotsdk_barcode_result_get_format()

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_format ( const scanbotsdk_barcode_result_t result,
int  index,
scanbotsdk_barcode_format_t format 
)

Returns the barcode format of a the given barcode in a result.

Parameters
resultPointer to the barcode result
indexThe index of the barcode in the result, must be in the range [0, count - 1]
formatPointer to a scanbotsdk_barcode_format_t variable to hold the returned barcode format.
Returns
: Error code, SCANBOTSDK_OK if no errors were encountered

◆ scanbotsdk_barcode_result_get_quad()

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_quad ( const scanbotsdk_barcode_result_t result,
int  barcode_index,
int *  quad 
)

Returns the coordinates in pixel space of the four corners of a given barcode in the result.

The coordinates are returned in the following order:

  • 0 : top-left-x,
  • 1 : top-left-y,
  • 2 : top-right-x,
  • 3 : top-right-y,
  • 4 : bottom-right-x,
  • 5 : bottom-right-y,
  • 6 : bottom-left-x,
  • 7 : bottom-left-y
Parameters
resultPointer to the barcode result
barcode_indexThe index of the barcode
quadAn int[8] array to hold the returned coordinates.
Returns
: Error code, SCANBOTSDK_OK if no errors were encountered

◆ scanbotsdk_barcode_result_get_raw_bytes()

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_raw_bytes ( const scanbotsdk_barcode_result_t result,
int  index,
const unsigned char **  raw_bytes,
int *  length 
)

Returns the raw bytes of a given barcode from the result.

Parameters
resultPointer to the barcode result
indexThe index of the barcode
raw_bytesPointer to a const unsigned char* var to hold the returned barcode raw bytes
lengthPointer to an int variable to hold the length of the returned barcode raw bytes
Returns
: Error code, SCANBOTSDK_OK if no errors were encountered

◆ scanbotsdk_barcode_result_get_text()

SBSDK_API scanbotsdk_error_code_t scanbotsdk_barcode_result_get_text ( const scanbotsdk_barcode_result_t result,
int  index,
const char **  text 
)

Returns the barcode text as a null-terminated UTF8-encoded string of the given barcode in a result.

Parameters
resultPointer to the barcode result
indexThe index of the barcode in the result, must be in the range [0, count - 1]
textPointer to a const char* variable to hold the returned barcode text. The returned pointer is only valid until the barcode result is destroyed.
Returns
: Error code, SCANBOTSDK_OK if no errors were encountered