Remove unused functions
This commit is contained in:
parent
af9966c986
commit
00f187d94a
1 changed files with 4 additions and 134 deletions
138
lib/identify.c
138
lib/identify.c
|
@ -537,95 +537,12 @@ static void find_leftmost_to_line(void *user_data, int y, int left, int right)
|
|||
}
|
||||
}
|
||||
|
||||
/* Do a Bresenham scan from one point to another and count the number
|
||||
* of black/white transitions.
|
||||
*/
|
||||
static int timing_scan(const struct quirc *q,
|
||||
const struct quirc_point *p0,
|
||||
const struct quirc_point *p1)
|
||||
{
|
||||
int n = p1->x - p0->x;
|
||||
int d = p1->y - p0->y;
|
||||
int x = p0->x;
|
||||
int y = p0->y;
|
||||
int *dom, *nondom;
|
||||
int dom_step;
|
||||
int nondom_step;
|
||||
int a = 0;
|
||||
int i;
|
||||
int zero_run_length = 0;
|
||||
int non_zero_run_length = 0;
|
||||
int count = 0;
|
||||
|
||||
if (p0->x < 0 || p0->y < 0 || p0->x >= q->w || p0->y >= q->h)
|
||||
return -1;
|
||||
if (p1->x < 0 || p1->y < 0 || p1->x >= q->w || p1->y >= q->h)
|
||||
return -1;
|
||||
|
||||
if (abs(n) > abs(d)) {
|
||||
int swap = n;
|
||||
|
||||
n = d;
|
||||
d = swap;
|
||||
|
||||
dom = &x;
|
||||
nondom = &y;
|
||||
} else {
|
||||
dom = &y;
|
||||
nondom = &x;
|
||||
}
|
||||
|
||||
if (n < 0) {
|
||||
n = -n;
|
||||
nondom_step = -1;
|
||||
} else {
|
||||
nondom_step = 1;
|
||||
}
|
||||
|
||||
if (d < 0) {
|
||||
d = -d;
|
||||
dom_step = -1;
|
||||
} else {
|
||||
dom_step = 1;
|
||||
}
|
||||
|
||||
x = p0->x;
|
||||
y = p0->y;
|
||||
for (i = 0; i <= d; i++) {
|
||||
int pixel;
|
||||
|
||||
if (y < 0 || y >= q->h || x < 0 || x >= q->w)
|
||||
break;
|
||||
|
||||
pixel = q->pixels[y * q->w + x];
|
||||
|
||||
if (pixel) {
|
||||
non_zero_run_length++;
|
||||
if ((zero_run_length >= 2) && (non_zero_run_length >= 2)) {
|
||||
count++;
|
||||
zero_run_length = 0;
|
||||
}
|
||||
} else {
|
||||
zero_run_length++;
|
||||
non_zero_run_length = 0;
|
||||
}
|
||||
|
||||
a += n;
|
||||
*dom += dom_step;
|
||||
if (a >= d) {
|
||||
*nondom += nondom_step;
|
||||
a -= d;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static double distance(struct quirc_point a, struct quirc_point b)
|
||||
{
|
||||
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
|
||||
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
|
||||
}
|
||||
|
||||
/* Estimate grid size by determing distance between capstones
|
||||
*/
|
||||
static void measure_grid_size(struct quirc *q, int index)
|
||||
{
|
||||
struct quirc_grid *qr = &q->grids[index];
|
||||
|
@ -647,50 +564,6 @@ static void measure_grid_size(struct quirc *q, int index)
|
|||
qr->grid_size = 4*((int)(grid_size_estimate - 17.0 + 2.0) / 4) + 17;
|
||||
}
|
||||
|
||||
/* Try the measure the timing pattern for a given QR code. This does
|
||||
* not require the global perspective to have been set up, but it
|
||||
* does require that the capstone corners have been set to their
|
||||
* canonical rotation.
|
||||
*
|
||||
* For each capstone, we find a point in the middle of the ring band
|
||||
* which is nearest the centre of the code. Using these points, we do
|
||||
* a horizontal and a vertical timing scan.
|
||||
*/
|
||||
static int measure_timing_pattern(struct quirc *q, int index)
|
||||
{
|
||||
struct quirc_grid *qr = &q->grids[index];
|
||||
int i;
|
||||
int scan;
|
||||
int ver;
|
||||
int size;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
static const double us[] = {6.5, 6.5, 0.5};
|
||||
static const double vs[] = {0.5, 6.5, 6.5};
|
||||
struct quirc_capstone *cap = &q->capstones[qr->caps[i]];
|
||||
|
||||
perspective_map(cap->c, us[i], vs[i], &qr->tpep[i]);
|
||||
}
|
||||
|
||||
int hscan = timing_scan(q, &qr->tpep[1], &qr->tpep[2]);
|
||||
int vscan = timing_scan(q, &qr->tpep[1], &qr->tpep[0]);
|
||||
|
||||
scan = hscan;
|
||||
if (vscan > scan)
|
||||
scan = vscan;
|
||||
|
||||
/* If neither scan worked, we can't go any further. */
|
||||
if (scan < 0)
|
||||
return -1;
|
||||
|
||||
/* Choose the nearest allowable grid size */
|
||||
size = scan * 2 + 13;
|
||||
ver = (size - 15) / 4;
|
||||
qr->grid_size = ver * 4 + 17;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read a cell from a grid using the currently set perspective
|
||||
* transform. Returns +/- 1 for black/white, 0 for cells which are
|
||||
* out of image bounds.
|
||||
|
@ -952,12 +825,9 @@ static void record_qr_grid(struct quirc *q, int a, int b, int c)
|
|||
cap->qr_grid = qr_index;
|
||||
}
|
||||
|
||||
/* Check the timing pattern. This doesn't require a perspective
|
||||
/* Check the timing pattern by measuring grid size. This doesn't require a perspective
|
||||
* transform.
|
||||
*/
|
||||
//if (measure_timing_pattern(q, qr_index) < 0)
|
||||
// goto fail;
|
||||
|
||||
measure_grid_size(q, qr_index);
|
||||
/* Make an estimate based for the alignment pattern based on extending
|
||||
* lines from capstones A and C.
|
||||
|
|
Loading…
Reference in a new issue