|
|
@ -20,13 +20,14 @@ class GeneratedBindings { |
|
|
|
: _lookup = lookup; |
|
|
|
: _lookup = lookup; |
|
|
|
|
|
|
|
|
|
|
|
/// @brief Enables or disables the logging of the library. |
|
|
|
/// @brief Enables or disables the logging of the library. |
|
|
|
|
|
|
|
/// @param enable Whether to enable or disable the logging. |
|
|
|
/// |
|
|
|
/// |
|
|
|
/// @param enabled |
|
|
|
/// @param enabled |
|
|
|
void setLogEnabled( |
|
|
|
void setLogEnabled( |
|
|
|
int enabled, |
|
|
|
int enable, |
|
|
|
) { |
|
|
|
) { |
|
|
|
return _setLogEnabled( |
|
|
|
return _setLogEnabled( |
|
|
|
enabled, |
|
|
|
enable, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -47,15 +48,16 @@ class GeneratedBindings { |
|
|
|
late final _version = |
|
|
|
late final _version = |
|
|
|
_versionPtr.asFunction<ffi.Pointer<ffi.Char> Function()>(); |
|
|
|
_versionPtr.asFunction<ffi.Pointer<ffi.Char> Function()>(); |
|
|
|
|
|
|
|
|
|
|
|
/// @brief Reads barcode from image. |
|
|
|
/// @brief Read barcode from image bytes. |
|
|
|
/// @param bytes Image bytes. |
|
|
|
/// @param bytes Image bytes. |
|
|
|
/// @param format The format of the barcode |
|
|
|
/// @param format Specify a set of BarcodeFormats that should be searched for. |
|
|
|
/// @param width Image width. |
|
|
|
/// @param width Image width in pixels. |
|
|
|
/// @param height Image height. |
|
|
|
/// @param height Image height in pixels. |
|
|
|
/// @param cropWidth Crop width. |
|
|
|
/// @param cropWidth Crop width. |
|
|
|
/// @param cropHeight Crop height. |
|
|
|
/// @param cropHeight Crop height. |
|
|
|
/// @param logEnabled Log enabled. |
|
|
|
/// @param tryHarder Spend more time to try to find a barcode; optimize for accuracy, not speed. |
|
|
|
/// @return Barcode result. |
|
|
|
/// @param tryRotate Also try detecting code in 90, 180 and 270 degree rotated images. |
|
|
|
|
|
|
|
/// @return The barcode result. |
|
|
|
CodeResult readBarcode( |
|
|
|
CodeResult readBarcode( |
|
|
|
ffi.Pointer<ffi.Char> bytes, |
|
|
|
ffi.Pointer<ffi.Char> bytes, |
|
|
|
int format, |
|
|
|
int format, |
|
|
@ -63,6 +65,8 @@ class GeneratedBindings { |
|
|
|
int height, |
|
|
|
int height, |
|
|
|
int cropWidth, |
|
|
|
int cropWidth, |
|
|
|
int cropHeight, |
|
|
|
int cropHeight, |
|
|
|
|
|
|
|
int tryHarder, |
|
|
|
|
|
|
|
int tryRotate, |
|
|
|
) { |
|
|
|
) { |
|
|
|
return _readBarcode( |
|
|
|
return _readBarcode( |
|
|
|
bytes, |
|
|
|
bytes, |
|
|
@ -71,25 +75,29 @@ class GeneratedBindings { |
|
|
|
height, |
|
|
|
height, |
|
|
|
cropWidth, |
|
|
|
cropWidth, |
|
|
|
cropHeight, |
|
|
|
cropHeight, |
|
|
|
|
|
|
|
tryHarder, |
|
|
|
|
|
|
|
tryRotate, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
late final _readBarcodePtr = _lookup< |
|
|
|
late final _readBarcodePtr = _lookup< |
|
|
|
ffi.NativeFunction< |
|
|
|
ffi.NativeFunction< |
|
|
|
CodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int, |
|
|
|
CodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int, |
|
|
|
ffi.Int, ffi.Int)>>('readBarcode'); |
|
|
|
ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcode'); |
|
|
|
late final _readBarcode = _readBarcodePtr.asFunction< |
|
|
|
late final _readBarcode = _readBarcodePtr.asFunction< |
|
|
|
CodeResult Function(ffi.Pointer<ffi.Char>, int, int, int, int, int)>(); |
|
|
|
CodeResult Function( |
|
|
|
|
|
|
|
ffi.Pointer<ffi.Char>, int, int, int, int, int, int, int)>(); |
|
|
|
|
|
|
|
|
|
|
|
/// @brief Reads barcodes from image. |
|
|
|
/// @brief Read barcodes from image bytes. |
|
|
|
/// @param bytes Image bytes. |
|
|
|
/// @param bytes Image bytes. |
|
|
|
/// @param format The format of the barcode |
|
|
|
/// @param format Specify a set of BarcodeFormats that should be searched for. |
|
|
|
/// @param width Image width. |
|
|
|
/// @param width Image width in pixels. |
|
|
|
/// @param height Image height. |
|
|
|
/// @param height Image height in pixels. |
|
|
|
/// @param cropWidth Crop width. |
|
|
|
/// @param cropWidth Crop width. |
|
|
|
/// @param cropHeight Crop height. |
|
|
|
/// @param cropHeight Crop height. |
|
|
|
/// @param logEnabled Log enabled. |
|
|
|
/// @param tryHarder Spend more time to try to find a barcode, optimize for accuracy, not speed. |
|
|
|
/// @return Barcode results. |
|
|
|
/// @param tryRotate Also try detecting code in 90, 180 and 270 degree rotated images. |
|
|
|
|
|
|
|
/// @return The barcode results. |
|
|
|
CodeResults readBarcodes( |
|
|
|
CodeResults readBarcodes( |
|
|
|
ffi.Pointer<ffi.Char> bytes, |
|
|
|
ffi.Pointer<ffi.Char> bytes, |
|
|
|
int format, |
|
|
|
int format, |
|
|
@ -97,6 +105,8 @@ class GeneratedBindings { |
|
|
|
int height, |
|
|
|
int height, |
|
|
|
int cropWidth, |
|
|
|
int cropWidth, |
|
|
|
int cropHeight, |
|
|
|
int cropHeight, |
|
|
|
|
|
|
|
int tryHarder, |
|
|
|
|
|
|
|
int tryRotate, |
|
|
|
) { |
|
|
|
) { |
|
|
|
return _readBarcodes( |
|
|
|
return _readBarcodes( |
|
|
|
bytes, |
|
|
|
bytes, |
|
|
@ -105,23 +115,25 @@ class GeneratedBindings { |
|
|
|
height, |
|
|
|
height, |
|
|
|
cropWidth, |
|
|
|
cropWidth, |
|
|
|
cropHeight, |
|
|
|
cropHeight, |
|
|
|
|
|
|
|
tryHarder, |
|
|
|
|
|
|
|
tryRotate, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
late final _readBarcodesPtr = _lookup< |
|
|
|
late final _readBarcodesPtr = _lookup< |
|
|
|
ffi.NativeFunction< |
|
|
|
ffi.NativeFunction< |
|
|
|
CodeResults Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int, |
|
|
|
CodeResults Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int, |
|
|
|
ffi.Int, ffi.Int)>>('readBarcodes'); |
|
|
|
ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcodes'); |
|
|
|
late final _readBarcodes = _readBarcodesPtr.asFunction< |
|
|
|
late final _readBarcodes = _readBarcodesPtr.asFunction< |
|
|
|
CodeResults Function(ffi.Pointer<ffi.Char>, int, int, int, int, int)>(); |
|
|
|
CodeResults Function( |
|
|
|
|
|
|
|
ffi.Pointer<ffi.Char>, int, int, int, int, int, int, int)>(); |
|
|
|
|
|
|
|
|
|
|
|
/// @brief Encode a string into a barcode |
|
|
|
/// @brief Encode a string into a barcode |
|
|
|
/// @param contents The string to encode |
|
|
|
/// @param contents The string to encode |
|
|
|
/// @param width The width of the barcode |
|
|
|
/// @param width The width of the barcode in pixels. |
|
|
|
/// @param height The height of the barcode |
|
|
|
/// @param height The height of the barcode in pixels. |
|
|
|
/// @param format The format of the barcode |
|
|
|
/// @param format The format of the barcode |
|
|
|
/// @param margin The margin of the barcode |
|
|
|
/// @param margin The margin of the barcode |
|
|
|
/// @param logEnabled Log enabled. |
|
|
|
|
|
|
|
/// @param eccLevel The error correction level of the barcode. Used for Aztec, PDF417, and QRCode only, [0-8]. |
|
|
|
/// @param eccLevel The error correction level of the barcode. Used for Aztec, PDF417, and QRCode only, [0-8]. |
|
|
|
/// @return The barcode data |
|
|
|
/// @return The barcode data |
|
|
|
EncodeResult encodeBarcode( |
|
|
|
EncodeResult encodeBarcode( |
|
|
@ -150,6 +162,7 @@ class GeneratedBindings { |
|
|
|
EncodeResult Function(ffi.Pointer<ffi.Char>, int, int, int, int, int)>(); |
|
|
|
EncodeResult Function(ffi.Pointer<ffi.Char>, int, int, int, int, int)>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// @brief Format Enumerates barcode formats known to this package. |
|
|
|
abstract class Format { |
|
|
|
abstract class Format { |
|
|
|
/// < Used as a return value if no valid barcode has been detected |
|
|
|
/// < Used as a return value if no valid barcode has been detected |
|
|
|
static const int None = 0; |
|
|
|
static const int None = 0; |
|
|
@ -206,64 +219,88 @@ abstract class Format { |
|
|
|
static const int Any = 65535; |
|
|
|
static const int Any = 65535; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// @brief Pos is a position of a barcode in a image. |
|
|
|
class Pos extends ffi.Struct { |
|
|
|
class Pos extends ffi.Struct { |
|
|
|
|
|
|
|
/// < x coordinate of top left corner of barcode |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int topLeftX; |
|
|
|
external int topLeftX; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < y coordinate of top left corner of barcode |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int topLeftY; |
|
|
|
external int topLeftY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < x coordinate of top right corner of barcode |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int topRightX; |
|
|
|
external int topRightX; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < y coordinate of top right corner of barcode |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int topRightY; |
|
|
|
external int topRightY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < x coordinate of bottom left corner of barcode |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int bottomLeftX; |
|
|
|
external int bottomLeftX; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < y coordinate of bottom left corner of barcode |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int bottomLeftY; |
|
|
|
external int bottomLeftY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < x coordinate of bottom right corner of barcode |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int bottomRightX; |
|
|
|
external int bottomRightX; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < y coordinate of bottom right corner of barcode |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int bottomRightY; |
|
|
|
external int bottomRightY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// @brief The CodeResult class encapsulates the result of decoding a barcode within an image. |
|
|
|
class CodeResult extends ffi.Struct { |
|
|
|
class CodeResult extends ffi.Struct { |
|
|
|
|
|
|
|
/// < Whether the barcode was successfully decoded |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int isValid; |
|
|
|
external int isValid; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < The decoded text |
|
|
|
external ffi.Pointer<ffi.Char> text; |
|
|
|
external ffi.Pointer<ffi.Char> text; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < The format of the barcode |
|
|
|
@ffi.Int32() |
|
|
|
@ffi.Int32() |
|
|
|
external int format; |
|
|
|
external int format; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < The position of the barcode within the image |
|
|
|
external ffi.Pointer<Pos> pos; |
|
|
|
external ffi.Pointer<Pos> pos; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// @brief The CodeResults class encapsulates the result of decoding multiple barcodes within an image. |
|
|
|
class CodeResults extends ffi.Struct { |
|
|
|
class CodeResults extends ffi.Struct { |
|
|
|
|
|
|
|
/// < The number of barcodes detected |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int count; |
|
|
|
external int count; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < The results of the barcode decoding |
|
|
|
external ffi.Pointer<CodeResult> results; |
|
|
|
external ffi.Pointer<CodeResult> results; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// @brief EncodeResult encapsulates the result of encoding a barcode. |
|
|
|
class EncodeResult extends ffi.Struct { |
|
|
|
class EncodeResult extends ffi.Struct { |
|
|
|
|
|
|
|
/// < Whether the barcode was successfully encoded |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int isValid; |
|
|
|
external int isValid; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < The encoded text |
|
|
|
external ffi.Pointer<ffi.Char> text; |
|
|
|
external ffi.Pointer<ffi.Char> text; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < The format of the barcode |
|
|
|
@ffi.Int32() |
|
|
|
@ffi.Int32() |
|
|
|
external int format; |
|
|
|
external int format; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < The encoded data |
|
|
|
external ffi.Pointer<ffi.UnsignedInt> data; |
|
|
|
external ffi.Pointer<ffi.UnsignedInt> data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < The length of the encoded data |
|
|
|
@ffi.Int() |
|
|
|
@ffi.Int() |
|
|
|
external int length; |
|
|
|
external int length; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// < The error message |
|
|
|
external ffi.Pointer<ffi.Char> error; |
|
|
|
external ffi.Pointer<ffi.Char> error; |
|
|
|
} |
|
|
|
} |
|
|
|