28 int scale, smallestFeature;
29 int xExtent, yExtent, maxExtent;
44 xExtent = grid.xMax - grid.xMin;
45 yExtent = grid.yMax - grid.yMin;
46 maxExtent =
max(xExtent, yExtent);
50 for (extent = 1; extent < maxExtent; extent = ((extent + 1) * 2) - 1) {
51 if (extent <= smallestFeature) {
52 grid.minExtent = extent;
56 grid.maxExtent = extent;
58 grid.xOffset = (grid.xMin + grid.xMax - grid.maxExtent) / 2;
59 grid.yOffset = (grid.yMin + grid.yMax - grid.maxExtent) / 2;
63 grid.extent = grid.maxExtent;
97 int count, half, quarter;
104 if (grid->pixelCount >= grid->pixelTotal) {
105 grid->pixelCount = 0;
106 grid->xCenter += grid->jumpSize;
110 if (grid->xCenter > grid->maxExtent) {
111 grid->xCenter = grid->startPos;
112 grid->yCenter += grid->jumpSize;
116 if (grid->yCenter > grid->maxExtent) {
122 if (grid->extent == 0 || grid->extent < grid->minExtent) {
123 locPtr->
x = locPtr->
y = -1;
127 count = grid->pixelCount;
131 if (count == grid->pixelTotal - 1) {
133 loc.
x = grid->xCenter;
134 loc.
y = grid->yCenter;
136 half = grid->pixelTotal / 2;
141 loc.
x = grid->xCenter + ((count < quarter) ? (count - quarter) : (half - count));
142 loc.
y = grid->yCenter;
147 loc.
x = grid->xCenter;
148 loc.
y = grid->yCenter + ((count < quarter) ? (count - quarter) : (half - count));
152 loc.
x += grid->xOffset;
153 loc.
y += grid->yOffset;
157 if (loc.
x < grid->xMin || loc.
x > grid->xMax || loc.
y < grid->yMin || loc.
y > grid->yMax) {
169 grid->jumpSize = grid->extent + 1;
170 grid->pixelTotal = 2 * grid->extent - 1;
171 grid->startPos = grid->extent / 2;
172 grid->pixelCount = 0;
173 grid->xCenter = grid->yCenter = grid->startPos;
libdmtx - Data Matrix Encoding/Decoding Library Copyright 2008, 2009 Mike Laughton.
@ DmtxPropXmax
ROI X坐标最大值(如果未设置则为图像宽度-1)
@ DmtxPropXmin
ROI X坐标最小值(如果未设置则为0)
@ DmtxPropYmin
ROI Y坐标最小值(如果未设置则为0)
@ DmtxPropYmax
ROI Y坐标最大值(如果未设置则为图像高度-1)
int dmtxDecodeGetProp(DmtxDecode *dec, int prop)
Get decoding behavior property.
static DmtxScanGrid initScanGrid(DmtxDecode *dec)
初始化扫描网格
static int getGridCoordinates(DmtxScanGrid *grid, DmtxPixelLoc *locPtr)
Extract current grid position in pixel coordinates and return whether location is good,...
static int popGridLocation(DmtxScanGrid *grid, DmtxPixelLoc *locPtr)
Return the next good location (which may be the current location), and advance grid progress one posi...
static void setDerivedFields(DmtxScanGrid *grid)
Update derived fields based on current state.
libdmtx - Data Matrix Encoding/Decoding Library Copyright 2008, 2009 Mike Laughton.