Skip to content

Commit

Permalink
Merge pull request #179 from OpenPTV/compare_yosefm
Browse files Browse the repository at this point in the history
revert changes to track branch to @yosefm last commit
  • Loading branch information
alexlib authored Mar 27, 2019
2 parents 35416bd + 2da7568 commit eb6b2c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 84 deletions.
2 changes: 1 addition & 1 deletion liboptv/include/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ foundpix;

int candsearch_in_pix(target next[], int num_targets, double x, double y,
double dl, double dr, double du, double dd, int p[4], control_par *cpar);
int candsearch_in_pix_rest(target next[], int num_targets, double x, double y,
int candsearch_in_pixrest(target next[], int num_targets, double x, double y,
double dl, double dr, double du, double dd, int p[4], control_par *cpar);
int sort_candidates_by_freq (foundpix item[16], int num_cams);
void searchquader(vec3d point, double xr[4], double xl[4], double yd[4], \
Expand Down
91 changes: 8 additions & 83 deletions liboptv/src/track.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#include <stdlib.h>
#include <stdio.h>

#define _USE_MATH_DEFINES
#include <math.h>

/* internal-use defines, not needed by the outside world. */
#define TR_UNUSED -1

Expand Down Expand Up @@ -260,7 +257,7 @@ int candsearch_in_pix (target next[], int num_targets, double cent_x, double cen

j0 -= 12; if (j0 < 0) j0 = 0; /* due to trunc */
for (j = j0; j<num_targets; j++) { /* candidate search */
if (next[j].tnr != TR_UNUSED ) {
if (next[j].tnr != -1 ) {
if (next[j].y > ymax ) break; /* finish search */
if (next[j].x > xmin && next[j].x < xmax \
&& next[j].y > ymin && next[j].y < ymax) {
Expand Down Expand Up @@ -302,79 +299,6 @@ int candsearch_in_pix (target next[], int num_targets, double cent_x, double cen
return (counter);
}

/* candsearch_in_pix_rest searches for a nearest candidate in unmatched target list
*
* Arguments:
* target next[] - array of targets (pointer, x,y, n, nx,ny, sumg, track ID),
* assumed to be y sorted.
* int num_targets - target array length.
* double cent_x, cent_y - image coordinates of the position of a particle [pixel]
* double dl, dr, du, dd - respectively the left, right, up, down distance to
* the search area borders from its center, [pixel]
* int p[] - indices in ``next`` of the candidates found.
* control_par *cpar array of parameters (cpar->imx,imy are needed)
*
* Returns:
* int, the number of candidates found, between 0 - 1
*/

int candsearch_in_pix_rest (target next[], int num_targets, double cent_x, double cent_y,
double dl, double dr, double du, double dd, int p[4], control_par *cpar) {

int j, j0, dj;
int counter = 0, p1, p2, p3, p4;
double d, dmin = 1e20, xmin, xmax, ymin, ymax;

xmin = cent_x - dl; xmax = cent_x + dr; ymin = cent_y - du; ymax = cent_y + dd;

if(xmin<0.0) xmin = 0.0;
if(xmax > cpar->imx)
xmax = cpar->imx;
if(ymin<0.0) ymin = 0.0;
if(ymax > cpar->imy)
ymax = cpar->imy;

for (j = 0; j<4; j++) ( p[j] = PT_UNUSED );
p1 = p2 = p3 = p4 = PT_UNUSED;

if (cent_x >= 0.0 && cent_x <= cpar->imx ) {
if (cent_y >= 0.0 && cent_y <= cpar->imy ) {

/* binarized search for start point of candidate search */
for (j0 = num_targets/2, dj = num_targets/4; dj>1; dj /= 2)
{
if (next[j0].y < ymin) j0 += dj;
else j0 -= dj;
}

j0 -= 12; if (j0 < 0) j0 = 0; /* due to trunc */
for (j = j0; j<num_targets; j++) { /* candidate search */
if (next[j].tnr == TR_UNUSED ) {
if (next[j].y > ymax ) break; /* finish search */
if (next[j].x > xmin && next[j].x < xmax \
&& next[j].y > ymin && next[j].y < ymax) {
d = sqrt ((cent_x-next[j].x)*(cent_x-next[j].x) + \
(cent_y-next[j].y)*(cent_y-next[j].y));

if (d < dmin) {
dmin = d;
p1 = j;
}
}
}
}

p[0] = p1;
p[1] = p2;
p[2] = p3;
p[3] = p4;

if ( p[0] != PT_UNUSED ) counter++;
} /* if y is within the image boundaries */
} /* if x is within the image boundaries */
return (counter);
}

/* searchquader defines the search region, using tracking parameters
* dvxmin, ... dvzmax (but within the image boundaries), per camera
* Its primary objective is to provide a safe search region in each camera
Expand Down Expand Up @@ -644,12 +568,12 @@ int assess_new_position(vec3d pos, vec2d targ_pos[],
double right, left, down, up; /* search rectangle limits */

left = right = up = down = ADD_PART;
for (cam = 0; cam < frm->num_cams; cam++) {
for (cam = 0; cam < run->cpar->num_cams; cam++) {
point_to_pixel(pixel, pos, run->cal[cam], run->cpar);
targ_pos[cam][0] = targ_pos[cam][1] = COORD_UNUSED;

/* here we shall use only the 1st neigbhour */
num_cands = candsearch_in_pix_rest (frm->targets[cam], frm->num_targets[cam],
num_cands = candsearch_in_pix (frm->targets[cam], frm->num_targets[cam],
pixel[0], pixel[1], left, right, up, down,
cand_inds[cam], run->cpar);

Expand All @@ -661,7 +585,7 @@ int assess_new_position(vec3d pos, vec2d targ_pos[],
}

valid_cams = 0;
for (cam = 0; cam < frm->num_cams; cam++) {
for (cam = 0; cam < run->cpar->num_cams; cam++) {
if ((targ_pos[cam][0] != COORD_UNUSED) && \
(targ_pos[cam][1] != COORD_UNUSED))
{
Expand Down Expand Up @@ -795,7 +719,7 @@ void trackcorr_c_loop (tracking_run *run_info, int step) {
} else {
vec_copy(X[2], X[1]);
for (j = 0; j < fb->num_cams; j++) {
if (curr_corres->p[j] == CORRES_NONE) {
if (curr_corres->p[j] == -1) {
point_to_pixel (v1[j], X[2], cal[j], cpar);
} else {
_ix = curr_corres->p[j];
Expand Down Expand Up @@ -1026,7 +950,6 @@ void trackcorr_c_loop (tracking_run *run_info, int step) {
}
/* end of creation of links with decision check */


printf ("step: %d, curr: %d, next: %d, links: %d, lost: %d, add: %d\n",
step, fb->buf[1]->num_parts, fb->buf[2]->num_parts, count1,
fb->buf[1]->num_parts - count1, num_added);
Expand Down Expand Up @@ -1100,6 +1023,8 @@ double trackback_c (tracking_run *run_info)

/* sequence loop */
for (step = seq_par->last - 1; step > seq_par->first; step--) {
printf ("Time step: %d, seqnr: %d:\n",
step - seq_par->first, step);

for (h = 0; h < fb->buf[1]->num_parts; h++) {
curr_path_inf = &(fb->buf[1]->path_info[h]);
Expand Down Expand Up @@ -1245,7 +1170,7 @@ double trackback_c (tracking_run *run_info)
if (curr_path_inf->prev != PREV_NONE ) count1++;
} /* end of creation of links with decision check */

printf ("step: %d, curr: %d, next: %d, links: %d, lost: %d, add: %d\n",
printf ("step: %d, curr: %d, next: %d, links: %d, lost: %d, add: %d",
step, fb->buf[1]->num_parts, fb->buf[2]->num_parts, count1,
fb->buf[1]->num_parts - count1, num_added);

Expand Down

0 comments on commit eb6b2c6

Please sign in to comment.