libdmtx 0.7.8.7
libdmtx is a software library that enables programs to read and write Data Matrix barcodes of the modern ECC200 variety.
|
libdmtx - Data Matrix Encoding/Decoding Library Copyright 2008, 2009 Mike Laughton. More...
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "dmtx.h"
#include "dmtxstatic.h"
Go to the source code of this file.
Macros | |
#define | DMTX_HOUGH_RES 180 |
Functions | |
DmtxRegion * | dmtxRegionCreate (DmtxRegion *reg) |
Create copy of existing region struct. | |
DmtxPassFail | dmtxRegionDestroy (DmtxRegion **reg) |
Destroy region struct. | |
DmtxRegion * | dmtxRegionFindNext (DmtxDecode *dec, DmtxTime *timeout) |
寻找下一个二维码区域 | |
DmtxRegion * | dmtxRegionScanPixel (DmtxDecode *dec, int x, int y) |
将坐标点(x,y)作为二维码L型框的边缘点去匹配二维码包围框 | |
static DmtxPointFlow | matrixRegionSeekEdge (DmtxDecode *dec, DmtxPixelLoc loc) |
寻找指定像素位置梯度流向,并检查该点是否能形成闭环。如果成功暂定该点在DataMatrix的'L'型边上 | |
static DmtxPassFail | matrixRegionOrientation (DmtxDecode *dec, DmtxRegion *reg, DmtxPointFlow begin) |
确定数据矩阵区域的方向和关键边界 | |
static long | distanceSquared (DmtxPixelLoc a, DmtxPixelLoc b) |
计算两个像素点之间的欧几里得距离的平方 | |
DmtxPassFail | dmtxRegionUpdateCorners (DmtxDecode *dec, DmtxRegion *reg, DmtxVector2 p00, DmtxVector2 p10, DmtxVector2 p11, DmtxVector2 p01) |
DmtxPassFail | dmtxRegionUpdateXfrms (DmtxDecode *dec, DmtxRegion *reg) |
static double | rightAngleTrueness (DmtxVector2 c0, DmtxVector2 c1, DmtxVector2 c2, double angle) |
static int | readModuleColor (DmtxDecode *dec, DmtxRegion *reg, int symbolRow, int symbolCol, int sizeIdx, int colorPlane) |
读取模块(码元)颜色值 | |
static DmtxPassFail | matrixRegionFindSize (DmtxDecode *dec, DmtxRegion *reg) |
确定二维码尺寸(点线中黑白点的总数) | |
static int | countJumpTally (DmtxDecode *dec, DmtxRegion *reg, int xStart, int yStart, DmtxDirection dir) |
计算一个方向上颜色跳变次数 | |
static DmtxPointFlow | getPointFlow (DmtxDecode *dec, int colorPlane, DmtxPixelLoc loc, int arrive) |
从像素坐标寻找其在指定颜色平面的梯度方向 | |
static DmtxPointFlow | findStrongestNeighbor (DmtxDecode *dec, DmtxPointFlow center, int sign) |
static DmtxFollow | followSeek (DmtxDecode *dec, DmtxRegion *reg, int seek) |
根据指定步数从当前区域的起始点追踪到新位置 | |
static DmtxFollow | followSeekLoc (DmtxDecode *dec, DmtxPixelLoc loc) |
根据指定像素坐标初始化追踪起始信息 | |
static DmtxFollow | followStep (DmtxDecode *dec, DmtxRegion *reg, DmtxFollow followBeg, int sign) |
寻找followBeg的下一个点 | |
static DmtxFollow | followStep2 (DmtxDecode *dec, DmtxFollow followBeg, int sign) |
static DmtxPassFail | trailBlazeContinuous (DmtxDecode *dec, DmtxRegion *reg, DmtxPointFlow flowBegin, int maxDiagonal) |
从flowBegin点出发,分别从正负方向寻找连续的边界线 | |
static int | trailBlazeGapped (DmtxDecode *dec, DmtxRegion *reg, DmtxBresLine line, int streamDir) |
recives bresline, and follows strongest neighbor unless it involves ratcheting bresline inward or backward (although back + outward is allowed). | |
static int | trailClear (DmtxDecode *dec, DmtxRegion *reg, int clearMask) |
static DmtxBestLine | findBestSolidLine (DmtxDecode *dec, DmtxRegion *reg, int step0, int step1, int streamDir, int houghAvoid) |
查找最佳实线 | |
static DmtxBestLine | findBestSolidLine2 (DmtxDecode *dec, DmtxPixelLoc loc0, int tripSteps, int sign, int houghAvoid) |
static DmtxPassFail | findTravelLimits (DmtxDecode *dec, DmtxRegion *reg, DmtxBestLine *line) |
static DmtxPassFail | matrixRegionAlignCalibEdge (DmtxDecode *dec, DmtxRegion *reg, int edgeLoc) |
static DmtxBresLine | bresLineInit (DmtxPixelLoc loc0, DmtxPixelLoc loc1, DmtxPixelLoc locInside) |
static DmtxPassFail | bresLineGetStep (DmtxBresLine line, DmtxPixelLoc target, int *travel, int *outward) |
static DmtxPassFail | bresLineStep (DmtxBresLine *line, int travel, int outward) |
libdmtx - Data Matrix Encoding/Decoding Library Copyright 2008, 2009 Mike Laughton.
All rights reserved. Copyright 2012-2016 Vadim A. Misbakh-Soloviov. All rights reserved. Copyright 2016 Tim Zaman. All rights reserved.
See LICENSE file in the main project directory for full terms of use and distribution.
Contact: Vadim A. Misbakh-Soloviov dmtx@.nosp@m.mva..nosp@m.name Mike Laughton mike@.nosp@m.drag.nosp@m.onfly.nosp@m.logi.nosp@m.c.com
Detect barcode regions
Definition in file dmtxregion.c.
#define DMTX_HOUGH_RES 180 |
Definition at line 26 of file dmtxregion.c.
|
static |
Definition at line 1922 of file dmtxregion.c.
|
static |
Definition at line 1856 of file dmtxregion.c.
|
static |
Definition at line 1944 of file dmtxregion.c.
|
static |
计算一个方向上颜色跳变次数
此函数遍历图像中的一行或一列,统计从亮模块到暗模块或反之的转换次数。
dec | 解码上下文,提供解码环境信息 |
reg | 区域对象,包含当前分析区域的属性 |
xStart | 开始搜索的坐标X位置 |
yStart | 开始搜索的坐标Y位置 |
dir | 搜索方向,向右(DmtxDirRight)或向上(DmtxDirUp) |
Definition at line 919 of file dmtxregion.c.
|
static |
计算两个像素点之间的欧几里得距离的平方
Definition at line 407 of file dmtxregion.c.
|
extern |
Create copy of existing region struct.
Definition at line 32 of file dmtxregion.c.
|
extern |
|
extern |
寻找下一个二维码区域
dec | Pointer to DmtxDecode information struct |
timeout | 超时时间 (如果为NULL则不限时) |
Definition at line 69 of file dmtxregion.c.
|
extern |
将坐标点(x,y)作为二维码L型框的边缘点去匹配二维码包围框
Definition at line 100 of file dmtxregion.c.
|
extern |
Definition at line 421 of file dmtxregion.c.
|
extern |
Definition at line 528 of file dmtxregion.c.
|
static |
查找最佳实线
该函数用于在给定的解码上下文和区域内,根据霍夫变换找到最佳实线。 它考虑了路径流的方向,并尝试避免指定的角度。
dec | 解码上下文 |
reg | 区域信息 |
step0 | 起始步长 |
step1 | 结束步长 |
streamDir | 流的方向 |
houghAvoid | 霍夫变换中要避免的角度 |
Definition at line 1471 of file dmtxregion.c.
|
static |
Definition at line 1590 of file dmtxregion.c.
|
static |
Definition at line 1051 of file dmtxregion.c.
|
static |
Definition at line 1679 of file dmtxregion.c.
|
static |
根据指定步数从当前区域的起始点追踪到新位置
此函数从数据矩阵区域的起始追踪点出发,按照给定的步数(正向或负向), 逐步调用FollowStep
函数进行追踪,并返回达到的新位置信息。此功能 支持快速跳转到区域内的指定追踪步骤,用于优化和控制追踪流程。
dec | 解码上下文,用于缓存访问 |
reg | 当前数据矩阵区域信息,包含追踪起始位置、步数上限等 |
seek | 相对于起始点的追踪步数,正值表示正向追踪,负值表示反向追踪 |
Definition at line 1113 of file dmtxregion.c.
|
static |
根据指定像素坐标初始化追踪起始信息
Definition at line 1138 of file dmtxregion.c.
|
static |
寻找followBeg的下一个点
dec | 解码上下文,包含缓存访问等信息 |
reg | 当前处理的区域信息,包括追踪步数、跳跃目标位置等 |
followBeg | 起始点 |
sign | 追踪方向,+1 表示正向追踪,-1 表示负向追踪 |
Definition at line 1159 of file dmtxregion.c.
|
static |
Definition at line 1203 of file dmtxregion.c.
|
static |
从像素坐标寻找其在指定颜色平面的梯度方向
Definition at line 974 of file dmtxregion.c.
|
static |
Definition at line 1781 of file dmtxregion.c.
|
static |
确定二维码尺寸(点线中黑白点的总数)
此函数遍历可能的条形码尺寸,通过计算校准模块上的对比度来确定最佳尺寸索引。 它还会验证找到的尺寸索引是否与条形码图像的边缘和空白空间相匹配。
[in] | dec | 解码上下文,包含解码设置和图像信息 |
reg | 区域结构,用于存储找到的区域信息 |
以左上角水平往右检查
TL-—XX-—XX-----> XX 01 02 03 04 XX XX 05 06 07 08 XX 09 10 11 12 XX XX 13 14 15 16 XX XX XX XX XX XX
以右下角角竖直往上检查
^ |
XX XX XX | XX 01 02 03 04 XX XX 05 06 07 08 | XX 09 10 11 12 XX XX 13 14 15 16 | XX XX XX XX XX BR
以左下角水平往右检查
XX XX XX XX 01 02 03 04 XX XX 05 06 07 08 XX 09 10 11 12 XX XX 13 14 15 16 BL XX XX XX XX XX-->
以左下角竖直往上检查
^ | XX XX XX XX 01 02 03 04 XX XX 05 06 07 08 XX 09 10 11 12 XX XX 13 14 15 16 BL XX XX XX XX XX
分析DataMatrix周围的空间
XX XX XX XX 01 02 03 04 XX XX 05 06 07 08 XX 09 10 11 12 XX XX 13 14 15 16 XX XX XX XX XX XX 00----------------->
^ | | XX XX XX | XX 01 02 03 04 XX | XX 05 06 07 08 | XX 09 10 11 12 XX | XX 13 14 15 16 00 XX XX XX XX XX XX
00-----------------> XX XX XX XX 01 02 03 04 XX XX 05 06 07 08 XX 09 10 11 12 XX XX 13 14 15 16 XX XX XX XX XX XX
^ |
XX XX XX | XX 01 02 03 04 XX | XX 05 06 07 08 | XX 09 10 11 12 XX | XX 13 14 15 16 | XX XX XX XX XX XX 00
Definition at line 688 of file dmtxregion.c.
|
static |
确定数据矩阵区域的方向和关键边界
此函数分析并确定给定解码上下文中数据矩阵区域的方向性、极性和关键坐标点。 它通过跟随边缘、查找最佳直线、评估交叉点等步骤来实现对区域的精确定位。
dec | 解码上下文,包含了解码设置和辅助信息 |
reg | 待分析的数据矩阵区域结构体,用于存储识别结果 |
begin | 起始追踪点,用于初始化追踪过程 |
DmtxPass | 成功确定区域方向 |
DmtxFail | 未能成功确定区域方向或区域不符合预期条件 |
Definition at line 240 of file dmtxregion.c.
|
static |
寻找指定像素位置梯度流向,并检查该点是否能形成闭环。如果成功暂定该点在DataMatrix的'L'型边上
该函数分析指定像素位置的各颜色通道,以确定哪个通道展现了最明显的边缘特征。 然后,它通过分析正负方向上的邻近像素强度,精确定位并返回最强边缘的方向向量。 如果找不到清晰的边缘特征,则返回表示空白边缘(dmtxBlankEdge)的默认值。
dec | 解码上下文,包含图像数据和解码设置。 |
loc | 待分析的像素位置。 |
Definition at line 176 of file dmtxregion.c.
|
static |
读取模块(码元)颜色值
dec | 解码上下文,包含解码所需的状态信息。 |
reg | 当前处理的区域信息,用于定位和变换。 |
symbolRow | 二维码坐标系下的行坐标 |
symbolCol | 二维码坐标系下的列坐标 |
sizeIdx | 二维码种类索引 |
colorPlane | 需要读取的颜色平面索引 |
Definition at line 646 of file dmtxregion.c.
|
static |
Definition at line 620 of file dmtxregion.c.
|
static |
从flowBegin点出发,分别从正负方向寻找连续的边界线
0x80 v = visited bit 0x40 a = assigned bit 0x38 u = 3 bits points upstream 0-7 0x07 d = 3 bits points downstream 0-7
Definition at line 1234 of file dmtxregion.c.
|
static |
recives bresline, and follows strongest neighbor unless it involves ratcheting bresline inward or backward (although back + outward is allowed).
Definition at line 1341 of file dmtxregion.c.
|
static |
Definition at line 1436 of file dmtxregion.c.