Tizen Native API
5.0
|
Barcode module consists of barcode detection and barcode generation submodules.
#include <mv_barcode.h>
This API is related with the following features:
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
Media Vision BarCode contains two submodules:
* Detection submodule, * Generation submodule.
Detection submodule can be used for detecting barcodes on image sources, reading encoded messages, getting barcode types.
This module contains mv_barcode_detect() function and mv_barcode_detected_cb callback. mv_barcode_detect() function can be called for the image determined by mv_source_h handler to detect barcodes. If barcodes were detected, then mv_barcode_detected_cb callback is called. Each detected barcode type, message and location can be processed by this callback. mv_barcode_detect() supports ROI (rectangular region of interest) specification to allow barcode detection only for the region on the image.
Generation submodule can be used for generating the barcodes and QR codes. Different encoding types (see mv_barcode_qr_mode_e), error correction codes (see mv_barcode_qr_ecc_e) and code versions are supported for QRCodes.
This submodule contains mv_barcode_generate_source() function to generate handler to the buffer with row image of barcode, and mv_barcode_generate_image() function to generate image file with barcode. Both functions support the set of parameters which allow API user to configure output barcode. QR codes as well as Barcodes are supported (see mv_barcode_type_e enumeration for full list of supported barcodes). For QR codes it is possible to specify error correction code and encoding mode (see mv_barcode_qr_mode_e). Generation to file supports several formats (see mv_barcode_image_format_e).
Functions | |
int | mv_barcode_detect (mv_source_h source, mv_engine_config_h engine_cfg, mv_rectangle_s roi, mv_barcode_detected_cb detect_cb, void *user_data) |
Detects barcode(s) on source and reads message from it. | |
int | mv_barcode_generate_source (mv_engine_config_h engine_cfg, const char *message, mv_barcode_type_e type, mv_barcode_qr_mode_e qr_enc_mode, mv_barcode_qr_ecc_e qr_ecc, int qr_version, mv_source_h image) |
Generates mv_source_h with barcode image. | |
int | mv_barcode_generate_image (mv_engine_config_h engine_cfg, const char *message, int image_width, int image_height, mv_barcode_type_e type, mv_barcode_qr_mode_e qr_enc_mode, mv_barcode_qr_ecc_e qr_ecc, int qr_version, const char *image_path, mv_barcode_image_format_e image_format) |
Generates image file with barcode. | |
Typedefs | |
typedef void(* | mv_barcode_detected_cb )(mv_source_h source, mv_engine_config_h engine_cfg, const mv_quadrangle_s *barcode_locations, const char *messages[], const mv_barcode_type_e *types, int number_of_barcodes, void *user_data) |
Called when barcode detection is completed. | |
Defines | |
#define | MV_BARCODE_DETECT_ATTR_TARGET "MV_BARCODE_DETECT_ATTR_TARGET" |
Define MV_BARCODE_DETECT_ATTR_TARGET to set target attribute of the engine configuration. | |
#define | MV_BARCODE_GENERATE_ATTR_TEXT "MV_BARCODE_GENERATE_ATTR_TEXT" |
Define MV_BARCODE_GENERATE_ATTR_TEXT to set text attribute of the engine configuration. | |
#define | MV_BARCODE_GENERATE_ATTR_COLOR_FRONT "MV_BARCODE_GENERATE_ATTR_COLOR_FRONT" |
Defines MV_BARCODE_GENERATE_ATTR_COLOR_FRONT to set Barcode's foreground color attribute of the engine configuration. | |
#define | MV_BARCODE_GENERATE_ATTR_COLOR_BACK "MV_BARCODE_GENERATE_ATTR_COLOR_BACK" |
Defines MV_BARCODE_GENERATE_ATTR_COLOR_BACK to set Barcode's background color attribute of the engine configuration. |
#define MV_BARCODE_DETECT_ATTR_TARGET "MV_BARCODE_DETECT_ATTR_TARGET" |
Define MV_BARCODE_DETECT_ATTR_TARGET to set target attribute of the engine configuration.
#define MV_BARCODE_GENERATE_ATTR_COLOR_BACK "MV_BARCODE_GENERATE_ATTR_COLOR_BACK" |
Defines MV_BARCODE_GENERATE_ATTR_COLOR_BACK to set Barcode's background color attribute of the engine configuration.
#define MV_BARCODE_GENERATE_ATTR_COLOR_FRONT "MV_BARCODE_GENERATE_ATTR_COLOR_FRONT" |
Defines MV_BARCODE_GENERATE_ATTR_COLOR_FRONT to set Barcode's foreground color attribute of the engine configuration.
#define MV_BARCODE_GENERATE_ATTR_TEXT "MV_BARCODE_GENERATE_ATTR_TEXT" |
Define MV_BARCODE_GENERATE_ATTR_TEXT to set text attribute of the engine configuration.
typedef void(* mv_barcode_detected_cb)(mv_source_h source, mv_engine_config_h engine_cfg, const mv_quadrangle_s *barcode_locations, const char *messages[], const mv_barcode_type_e *types, int number_of_barcodes, void *user_data) |
Called when barcode detection is completed.
If no barcode is detected then the method will be called, barcodes and states will be equal to NULL, and number_of_barcodes - 0.
[in] | source | The handle to the media source |
[in] | engine_cfg | The handle to the configuration of the engine |
[in] | barcode_locations | The quadrangle locations of detected barcodes |
[in] | messages | The decoded messages of barcodes |
[in] | types | The types of detected barcodes |
[in] | number_of_barcodes | The number of detected barcodes |
[in] | user_data | The user data passed from the mv_barcode_detect() function |
Enumeration for supported image formats for the barcode generating.
enum mv_barcode_qr_ecc_e |
Enumeration for supported QR code error correction level.
enum mv_barcode_qr_mode_e |
Enumeration for supported QR code encoding mode.
enum mv_barcode_type_e |
Enumeration for supported barcode types.
QR codes (versions 1 to 40) and set of 1D barcodes are supported
int mv_barcode_detect | ( | mv_source_h | source, |
mv_engine_config_h | engine_cfg, | ||
mv_rectangle_s | roi, | ||
mv_barcode_detected_cb | detect_cb, | ||
void * | user_data | ||
) |
Detects barcode(s) on source and reads message from it.
[in] | source | The media source handle |
[in] | engine_cfg | The handle to the configuration of the engine |
[in] | roi | Region of interest - rectangular area on the source which will be used for barcode detection Note that roi should be inside area on the source. |
[in] | detect_cb | The callback for result handling |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value MEDIA_VISION_ERROR_NONE | Successful |
MEDIA_VISION_ERROR_INVALID_PARAMETER | Invalid parameter |
MEDIA_VISION_ERROR_NOT_SUPPORTED | Not supported |
MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT | Not supported format |
MEDIA_VISION_ERROR_INTERNAL | Internal error |
int mv_barcode_generate_image | ( | mv_engine_config_h | engine_cfg, |
const char * | message, | ||
int | image_width, | ||
int | image_height, | ||
mv_barcode_type_e | type, | ||
mv_barcode_qr_mode_e | qr_enc_mode, | ||
mv_barcode_qr_ecc_e | qr_ecc, | ||
int | qr_version, | ||
const char * | image_path, | ||
mv_barcode_image_format_e | image_format | ||
) |
Generates image file with barcode.
Pay attention that for EAN-8 and EAN-13 barcode types the barcode type may be selected automatically and this selection depends on the input message length. Also for QR codes the version may be selected as minimum required to generate QR code with the input message length.
[in] | engine_cfg | The handle to the configuration of the engine |
[in] | message | The message to be encoded in the barcode |
[in] | image_width | The width of the generated image |
[in] | image_height | The height of the generated image |
[in] | type | Type of the barcode to be generated |
[in] | qr_enc_mode | Encoding mode for the message (only for QR codes; for 1D barcodes set this parameter to MV_BARCODE_QR_MODE_UNAVAILABLE) |
[in] | qr_ecc | Error correction level (only for QR codes; for 1D barcodes set this parameter to MV_BARCODE_QR_ECC_UNAVAILABLE) |
[in] | qr_version | QR code version (for 1D barcodes set this parameter to 0) |
[in] | image_path | The path to the file that has to be generated |
[in] | image_format | The format of the output image |
0
on success, otherwise a negative error value MEDIA_VISION_ERROR_NONE | Successful |
MEDIA_VISION_ERROR_INVALID_PARAMETER | Invalid parameter |
MEDIA_VISION_ERROR_MSG_TOO_LONG | Too long or short message |
MEDIA_VISION_ERROR_PERMISSION_DENIED | Permission denied |
MEDIA_VISION_ERROR_NOT_SUPPORTED | Not supported |
MEDIA_VISION_ERROR_INVALID_DATA | Invalid data |
MEDIA_VISION_ERROR_INVALID_PATH | Invalid path |
MEDIA_VISION_ERROR_INTERNAL | Internal error |
MEDIA_VISION_ERROR_INVALID_OPERATION | Invalid operation |
int mv_barcode_generate_source | ( | mv_engine_config_h | engine_cfg, |
const char * | message, | ||
mv_barcode_type_e | type, | ||
mv_barcode_qr_mode_e | qr_enc_mode, | ||
mv_barcode_qr_ecc_e | qr_ecc, | ||
int | qr_version, | ||
mv_source_h | image | ||
) |
Generates mv_source_h with barcode image.
Pay attention that for EAN-8 and EAN-13 barcode types the barcode type may be selected automatically and this selection depends on the input message length. Also for QR codes the version may be selected as minimum required to generate QR code with the input message length.
[in] | engine_cfg | The handle to the configuration of the engine |
[in] | message | The message to be encoded in the barcode |
[in] | type | Type of the barcode to be generated |
[in] | qr_enc_mode | Encoding mode for the message (only for QR codes; for 1D barcodes set this parameter to MV_BARCODE_QR_MODE_UNAVAILABLE) |
[in] | qr_ecc | Error correction level (only for QR codes; for 1D barcodes set this parameter to MV_BARCODE_QR_ECC_UNAVAILABLE) |
[in] | qr_version | QR code version (for 1D barcodes set this parameter to 0) |
[in,out] | image | The media source handle which will be used to fill by the buffer with generated image |
0
on success, otherwise a negative error value MEDIA_VISION_ERROR_NONE | Successful |
MEDIA_VISION_ERROR_INVALID_PARAMETER | Invalid parameter |
MEDIA_VISION_ERROR_MSG_TOO_LONG | Too long or short message |
MEDIA_VISION_ERROR_NOT_SUPPORTED | Not supported |
MEDIA_VISION_ERROR_INVALID_DATA | Invalid data |
MEDIA_VISION_ERROR_INTERNAL | Internal error |
MEDIA_VISION_ERROR_INVALID_OPERATION | Invalid operation |