33# define M_PI 3.14159265358979323846
37# define M_PI_2 1.57079632679489661923
40#define DmtxUndefined (-1)
42#define DmtxPassFail unsigned int
46#define DmtxBoolean unsigned int
50#define DmtxFormatMatrix 0
51#define DmtxFormatMosaic 1
53#define DmtxSymbolSquareCount 24
54#define DmtxSymbolRectCount 6
56#define DmtxModuleOff 0x00
57#define DmtxModuleOnRed 0x01
58#define DmtxModuleOnGreen 0x02
59#define DmtxModuleOnBlue 0x04
60#define DmtxModuleOnRGB 0x07
61#define DmtxModuleOn DmtxModuleOnRGB
62#define DmtxModuleUnsure 0x08
63#define DmtxModuleAssigned 0x10
64#define DmtxModuleVisited 0x20
65#define DmtxModuleData 0x40
67#define dmtxLogTrace(...) dmtxLog(DmtxLogTrace, __FILE__, __LINE__, __VA_ARGS__)
68#define dmtxLogDebug(...) dmtxLog(DmtxLogDebug, __FILE__, __LINE__, __VA_ARGS__)
69#define dmtxLogInfo(...) dmtxLog(DmtxLogInfo, __FILE__, __LINE__, __VA_ARGS__)
70#define dmtxLogWarn(...) dmtxLog(DmtxLogWarn, __FILE__, __LINE__, __VA_ARGS__)
71#define dmtxLogError(...) dmtxLog(DmtxLogError, __FILE__, __LINE__, __VA_ARGS__)
72#define dmtxLogFatal(...) dmtxLog(DmtxLogFatal, __FILE__, __LINE__, __VA_ARGS__)
668 extern void dmtxLog(
int level,
const char *file,
int line,
const char *fmt, ...);
DmtxPassFail dmtxMatrix3VMultiply(OUT DmtxVector2 *vOut, DmtxVector2 *vIn, DmtxMatrix3 m)
将向量与矩阵相乘
void dmtxCallbackBuildMatrix(DmtxCallbackBuildMatrix cb)
void dmtxCallbackPlotModule(DmtxCallbackPlotModule cb)
int getSizeIdxFromSymbolDimension(int rows, int cols)
Retrieve symbol index from rows and columns.
struct DmtxTime_struct DmtxTime
void dmtxLogSetQuiet(DmtxBoolean enable)
DmtxBoolean dmtxByteListHasCapacity(DmtxByteList *list)
struct DmtxPointFlow_struct DmtxPointFlow
图像像素点及其梯度流动方向
DmtxRegion * dmtxRegionScanPixel(DmtxDecode *dec, int x, int y)
将坐标点(x,y)作为二维码L型框的边缘点去匹配二维码包围框
double dmtxVector2Cross(const DmtxVector2 *v1, const DmtxVector2 *v2)
二维向量叉积
unsigned char * dmtxDecodeCreateDiagnostic(DmtxDecode *dec, OUT int *totalBytes, OUT int *headerBytes, int style)
void(* DmtxCallbackBuildMatrixRegion)(DmtxRegion *region)
DmtxPassFail dmtxRegionUpdateXfrms(DmtxDecode *dec, DmtxRegion *reg)
@ DmtxPropXmax
ROI X坐标最大值(如果未设置则为图像宽度-1)
@ DmtxPropBytesPerPixel
每像素所需要的byte数
@ DmtxPropXmin
ROI X坐标最小值(如果未设置则为0)
@ DmtxPropRowSizeBytes
每一行(包括填充)在内存中的总字节数
@ DmtxPropImageFlip
图像是否需要翻转,通常用于处理上下颠倒的图像 DmtxFlip
@ DmtxPropYmin
ROI Y坐标最小值(如果未设置则为0)
@ DmtxPropPixelPacking
图像格式类型,像素打包方式 DmtxPackOrder
@ DmtxPropRowPadBytes
每行像素在内存中的填充或对齐字节数
@ DmtxPropChannelCount
图像通道数
@ DmtxPropBitsPerPixel
每像素所需要的bit数
@ DmtxPropYmax
ROI Y坐标最大值(如果未设置则为图像高度-1)
void dmtxMatrix3LineSkewSide(OUT DmtxMatrix3 m, double b0, double b1, double sz)
Generate side line skew transformation.
int dmtxGetSymbolAttribute(int attribute, int sizeIdx)
根据规格索引返回二维码规格各个参数
DmtxTime dmtxTimeNow(void)
Generic 1 second resolution version.
DmtxEncode * dmtxEncodeCreate(void)
Initialize encode struct with default values.
DmtxVector2 * dmtxVector2Scale(OUT DmtxVector2 *vOut, const DmtxVector2 *v, double s)
向量数乘
DmtxRegion * dmtxRegionFindNext(DmtxDecode *dec, DmtxTime *timeout)
寻找下一个二维码区域
struct DmtxByteList_struct DmtxByteList
enum DmtxDirection_enum DmtxDirection
int dmtxSymbolModuleStatus(DmtxMessage *message, int sizeIdx, int symbolRow, int symbolCol)
receives symbol row and col and returns status DmtxModuleOn / !DmtxModuleOn (DmtxModuleOff) DmtxModul...
struct DmtxRay2_struct DmtxRay2
向量表示的直线(线段)
DmtxPassFail dmtxMessageDestroy(DmtxMessage **msg)
Free memory previously allocated for message.
DmtxPassFail dmtxImageSetProp(DmtxImage *img, int prop, int value)
设置图像属性
int dmtxTimeExceeded(DmtxTime timeout)
Determine whether the received timeout has been exceeded.
double DmtxMatrix3[3][3]
DmtxMatrix3 类型定义,表示一个3x3的双精度浮点数矩阵
void dmtxMatrix3Multiply(OUT DmtxMatrix3 mOut, DmtxMatrix3 m0, DmtxMatrix3 m1)
矩阵相乘
struct DmtxTriplet_struct DmtxTriplet
DmtxPassFail dmtxRegionDestroy(DmtxRegion **reg)
Destroy region struct.
DmtxByteList dmtxByteListBuild(DmtxByte *storage, int capacity)
DmtxVector2 * dmtxVector2AddTo(DmtxVector2 *v1, const DmtxVector2 *v2)
DmtxPassFail dmtxImageSetChannel(DmtxImage *img, int channelStart, int bitsPerChannel)
设置图像的颜色通道信息,包括每个通道的起始位和位数。
void dmtxByteListPush(DmtxByteList *list, DmtxByte value, DmtxPassFail *passFail)
int dmtxGetBlockDataSize(int sizeIdx, int blockIdx)
Retrieve data size for a specific symbol size and block number.
@ DmtxSymAttribHorizDataRegions
水平方向区块个数
@ DmtxSymAttribBlockMaxCorrectable
@ DmtxSymAttribBlockErrorWords
@ DmtxSymAttribSymbolErrorWords
@ DmtxSymAttribSymbolRows
二维码码元总行数(包括L形框和点线)
@ DmtxSymAttribVertDataRegions
垂直方向区块个数
@ DmtxSymAttribSymbolDataWords
@ DmtxSymAttribDataRegionCols
单区块二维码数据区码元列数(不包括L形框和点线)
@ DmtxSymAttribSymbolCols
二维码码元总列数(包括L形框和点线)
@ DmtxSymAttribMappingMatrixRows
二维码数据区码元总行数(不包括L形框和点线)
@ DmtxSymAttribDataRegionRows
单区块二维码数据区码元行数(不包括L形框和点线)
@ DmtxSymAttribMappingMatrixCols
二维码数据区码元总列数(不包括L形框和点线)
@ DmtxSymAttribSymbolMaxCorrectable
@ DmtxSymAttribInterleavedBlocks
unsigned char * dmtxDecodeGetCache(DmtxDecode *dec, int x, int y)
Returns xxx.
void dmtxMatrix3LineSkewTop(OUT DmtxMatrix3 m, double b0, double b1, double sz)
生成顶部线倾斜变换矩阵
void dmtxCallbackBuildMatrixRegion(DmtxCallbackBuildMatrixRegion cb)
enum DmtxLogLevel_enum DmtxLogLevel
struct DmtxBestLine_struct DmtxBestLine
DmtxTime dmtxTimeAdd(DmtxTime t, long msec)
Add milliseconds to time t.
enum DmtxScheme_enum DmtxScheme
DmtxPassFail dmtxImageDestroy(DmtxImage **img)
Free libdmtx image memory.
DmtxDecode * dmtxDecodeCreate(DmtxImage *img, int scale)
Initialize decode struct with default values.
DmtxVector2 * dmtxVector2ScaleBy(DmtxVector2 *v, double s)
enum DmtxStatus_enum DmtxStatus
void(* DmtxCallbackBuildMatrix)(DmtxMatrix3 matrix)
void dmtxCallbackXfrmPlotPoint(DmtxCallbackXfrmPlotPoint cb)
struct DmtxImage_struct DmtxImage
DmtxPassFail dmtxEncodeSetProp(DmtxEncode *enc, int prop, int value)
Set encoding behavior property.
DmtxPassFail dmtxPointAlongRay2(OUT DmtxVector2 *point, const DmtxRay2 *r, double t)
计算直线上特定位置的点
void dmtxMatrix3Copy(OUT DmtxMatrix3 m0, DmtxMatrix3 m1)
复制3x3矩阵
void(* DmtxCallbackXfrmPlotPoint)(DmtxVector2 point, DmtxMatrix3 xfrm, int paneNbr, int dispType)
double dmtxVector2Mag(const DmtxVector2 *v)
二维向量的模
void dmtxMatrix3Rotate(OUT DmtxMatrix3 m, double angle)
生成旋转变换矩阵
struct DmtxMessage_struct DmtxMessage
DataMatrix编码内容
DmtxMessage * dmtxDecodeMosaicRegion(DmtxDecode *dec, DmtxRegion *reg, int fix)
Convert fitted Data Mosaic region into a decoded message.
char * dmtxVersion(void)
Use #include to merge the individual .c source files into a single combined file during preprocessing...
double dmtxDistanceFromRay2(const DmtxRay2 *r, const DmtxVector2 *q)
计算点到直线的垂直距离
enum DmtxSymbolSize_enum DmtxSymbolSize
DmtxBoolean dmtxImageContainsInt(DmtxImage *img, int margin, int x, int y)
判断坐标 (x, y) 是否在图像范围内
DmtxPassFail dmtxEncodeDataMosaic(DmtxEncode *enc, int inputSize, unsigned char *inputString)
Convert message into Data Mosaic image.
void dmtxCallbackPlotPoint(DmtxCallbackPlotPoint cb)
DmtxByte dmtxByteListPop(DmtxByteList *list, DmtxPassFail *passFail)
enum DmtxPackOrder_enum DmtxPackOrder
void dmtxByteListCopy(DmtxByteList *dst, const DmtxByteList *src, DmtxPassFail *passFail)
struct DmtxChannelGroup_struct DmtxChannelGroup
struct DmtxVector2_struct DmtxVector2
二维向量
DmtxPassFail dmtxMatrix3VMultiplyBy(INOUT DmtxVector2 *v, DmtxMatrix3 m)
将向量与矩阵相乘
DmtxPassFail dmtxRay2Intersect(OUT DmtxVector2 *point, const DmtxRay2 *p0, const DmtxRay2 *p1)
判断两条直线是否相交,并计算交点。
void dmtxLogSetLevel(int level)
void dmtxMatrix3Translate(OUT DmtxMatrix3 m, double tx, double ty)
生成平移变换矩阵
struct DmtxDecode_struct DmtxDecode
enum DmtxProperty_enum DmtxProperty
enum DmtxSymAttribute_enum DmtxSymAttribute
DmtxRegion * dmtxRegionCreate(DmtxRegion *reg)
Create copy of existing region struct.
void dmtxByteListClear(DmtxByteList *list)
DmtxMessage * dmtxMessageCreate(int sizeIdx, int symbolFormat)
Allocate memory for message.
struct DmtxPixelLoc_struct DmtxPixelLoc
像素坐标
DmtxPassFail dmtxDecodeGetPixelValue(DmtxDecode *dec, int x, int y, int channel, OUT int *value)
获取图像像素
double dmtxVector2Norm(DmtxVector2 *v)
DmtxImage * dmtxImageCreate(unsigned char *pxl, int width, int height, int pack)
libdmtx stores image data as a large one-dimensional array of packed pixels, reading from the array w...
DmtxPassFail dmtxDecodeDestroy(DmtxDecode **dec)
Deinitialize decode struct.
DmtxVector2 * dmtxVector2Add(OUT DmtxVector2 *vOut, const DmtxVector2 *v1, const DmtxVector2 *v2)
向量相加
DmtxMessage * dmtxDecodePopulatedArray(int sizeIdx, INOUT DmtxMessage *msg, int fix)
从DataMatrix数据区二进制矩阵解码,并将结果写入msg->output
void dmtxMatrix3Identity(OUT DmtxMatrix3 m)
生成单位变换矩阵
struct DmtxScanGrid_struct DmtxScanGrid
int dmtxImageGetByteOffset(DmtxImage *img, int x, int y)
根据给定的坐标 (x, y) 计算并返回图像中对应像素的字节偏移量
int dmtxImageGetProp(DmtxImage *img, int prop)
获取图像属性
enum DmtxCornerLoc_enum DmtxCornerLoc
struct DmtxRegion_struct DmtxRegion
二维码区域(包围框)
void(* DmtxCallbackFinal)(DmtxDecode *decode, DmtxRegion *region)
void dmtxMatrix3LineSkewSideInv(OUT DmtxMatrix3 m, double b0, double b1, double sz)
Generate side line skew transformation (inverse)
DmtxPassFail dmtxImageGetPixelValue(DmtxImage *img, int x, int y, int channel, OUT int *value)
DmtxPassFail dmtxDecodeSetProp(DmtxDecode *dec, int prop, int value)
Set decoding behavior property.
void dmtxMatrix3Shear(OUT DmtxMatrix3 m, double shx, double shy)
生成剪切变换矩阵
DmtxPassFail dmtxRegionUpdateCorners(DmtxDecode *dec, DmtxRegion *reg, DmtxVector2 p00, DmtxVector2 p10, DmtxVector2 p11, DmtxVector2 p01)
void(* DmtxCallbackPlotModule)(DmtxDecode *info, DmtxRegion *region, int row, int col, float colorHue)
DmtxVector2 * dmtxVector2SubFrom(DmtxVector2 *v1, const DmtxVector2 *v2)
int dmtxDecodeGetProp(DmtxDecode *dec, int prop)
Get decoding behavior property.
struct DmtxChannel_struct DmtxChannel
void(* DmtxCallbackPlotPoint)(DmtxPixelLoc loc, float colorHue, int paneNbr, int dispType)
DmtxVector2 * dmtxVector2Sub(OUT DmtxVector2 *vOut, const DmtxVector2 *v1, const DmtxVector2 *v2)
向量相减
void dmtxMatrix3Print(DmtxMatrix3 m)
Print matrix contents to STDOUT.
DmtxPassFail dmtxEncodeDestroy(DmtxEncode **enc)
Deinitialize encode struct.
struct DmtxEncodeStream_struct DmtxEncodeStream
void dmtxCallbackFinal(DmtxCallbackFinal cb)
void dmtxMatrix3MultiplyBy(INOUT DmtxMatrix3 m0, DmtxMatrix3 m1)
矩阵相乘
double dmtxDistanceAlongRay2(const DmtxRay2 *r, const DmtxVector2 *q)
double dmtxVector2Dot(const DmtxVector2 *v1, const DmtxVector2 *v2)
二维向量点积
DmtxPassFail dmtxImageSetPixelValue(DmtxImage *img, int x, int y, int channel, int value)
设置指定坐标、通道的像素值
DmtxBoolean dmtxImageContainsFloat(DmtxImage *img, double x, double y)
判断坐标 (x, y) 是否在图像范围内
struct DmtxEncode_struct DmtxEncode
DmtxMessage * dmtxDecodeMatrixRegion(DmtxDecode *dec, DmtxRegion *reg, int fix)
解码拟合的二维码区域
struct DmtxQuadruplet_struct DmtxQuadruplet
void dmtxMatrix3Scale(OUT DmtxMatrix3 m, double sx, double sy)
生成缩放变换矩阵
void dmtxByteListPrint(DmtxByteList *list, char *prefix)
void dmtxByteListInit(DmtxByteList *list, int length, DmtxByte value, DmtxPassFail *passFail)
int dmtxEncodeGetProp(DmtxEncode *enc, int prop)
Get encoding behavior property.
void dmtxLog(int level, const char *file, int line, const char *fmt,...)
DmtxPassFail dmtxEncodeDataMatrix(DmtxEncode *enc, int inputSize, unsigned char *inputString)
Convert message into Data Matrix image.
enum DmtxFlip_enum DmtxFlip
void dmtxMatrix3LineSkewTopInv(OUT DmtxMatrix3 m, double b0, double b1, double sz)
Generate top line skew transformation (inverse)
DmtxPixelLoc locPos
正方向点(线段端点)
DmtxPixelLoc locNeg
负方向点(线段端点)
DmtxByteList Use signed int for length fields instead of size_t to play nicely with RS arithmetic.
unsigned char encodedWords[1558]
unsigned char * inputStop
int outputChainValueCount
int imageFlip
图像是否需要翻转,通常用于处理上下颠倒的图像 DmtxFlip
int pixelPacking
图像格式类型,像素打包方式 DmtxPackOrder
int channelStart[4]
每个通道在像素数据中的起始位置(位偏移)
unsigned char * pxl
实际的像素数据缓冲区
int bytesPerPixel
每个像素的字节数
int rowPadBytes
每行像素在内存中的填充或对齐字节数
int bitsPerChannel[4]
每个通道的位数,描述每个颜色分量的精度
int channelCount
图像的通道数量,如RGB图像为3,CMYK图像为4
int rowSizeBytes
每一行(包括填充)在内存中的总字节数
unsigned char * code
指向码字(数据字和纠错字)的指针
size_t outputSize
Size of buffer used to hold decoded data.
size_t codeSize
编码数据的总大小,包括数据字和纠错字
int outputIdx
Internal index used to store output progress.
unsigned char * array
指向DataMatrix数据区二进制矩阵的指针
int fnc1
表示FNC1或DmtxUndefined的字符
size_t arraySize
二维码数据区码元行数x列数(mappingRows * mappingCols)
unsigned char * output
指向二维码码值的指针
int leftAngle
hough angle of left edge
int bottomKnown
known == 1; unknown == 0
int bottomAngle
hough angle of bottom edge
int rightKnown
known == 1; unknown == 0
DmtxPixelLoc rightLoc
known (arbitrary) location on right edge
DmtxMatrix3 raw2fit
3x3 变换矩阵,从图像坐标系到二维码坐标系
int mappingCols
二维码数据区码元列数
int sizeIdx
二维码类型索引,总共有 DmtxSymbolSquareCount + DmtxSymbolRectCount 种
int mappingRows
二维码数据区码元行数
int leftKnown
known == 1; unknown == 0
DmtxPointFlow flowBegin
搜索起点,十字搜索抛出的点
int symbolRows
二维码码元行数(包括L形框和点线)
int symbolCols
二维码码元列数(包括L形框和点线)
DmtxPixelLoc bottomLoc
known (arbitrary) location on bottom edge
int topKnown
known == 1; unknown == 0
int rightAngle
hough angle of right edge
DmtxPixelLoc leftLoc
known (arbitrary) location on left edge
DmtxPixelLoc locT
remove if stepT works above
DmtxPixelLoc topLoc
known (arbitrary) location on top edge
int topAngle
hough angle of top edge
DmtxPixelLoc locR
remove if stepR works above
DmtxMatrix3 fit2raw
3x3 变换矩阵,从二维码坐标系到图像坐标系
int yMax
ROI Y坐标最大值(如果未设置则为图像高度-1)
int xMin
ROI X坐标最小值(如果未设置则为0)
int yMin
ROI Y坐标最小值(如果未设置则为0)
int xMax
ROI X坐标最大值(如果未设置则为图像宽度-1)