Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
22154c4
this change breaks the test from 58 to 57 successful tests
alexlib Mar 22, 2019
580ec30
added test_burgers with 5 known particles and clear trajectories
alexlib Sep 5, 2020
893328c
updated 2to3
alexlib Sep 12, 2020
35dbbc9
removed py27
alexlib Sep 12, 2020
47efc78
Update appveyor.yml
alexlib Sep 12, 2020
5283b7e
Merge pull request #195 from alexlib/2to3
alexlib Sep 16, 2020
3bab613
return cmake testing using libcheck
alexlib Sep 19, 2020
de3e60d
Merge pull request #193 from OpenPTV/new_test_burgers
alexlib Sep 19, 2020
2d56515
cherry_picked the old track with candsearch_in_pix_rest and all tests…
alexlib Sep 20, 2020
4aed9bb
added test_candsearch_in_pix_rest
alexlib Sep 19, 2020
ccb00d8
changed back to candsearch_in_pix as the tracking failed completely
alexlib Sep 20, 2020
8cafbb9
cherry-picked burgers test case
alexlib Sep 20, 2020
9adec34
cherry-picked burgers test case
alexlib Sep 20, 2020
d29df4f
trying some idea
alexlib Sep 20, 2020
a73cf22
candsearch_in_pix_rest now finds and returns only one candidate
alexlib Sep 20, 2020
67af373
burgers now is a real test at least in print
alexlib Sep 20, 2020
805022b
test is now real with failing on wrong number of links w/o tpar->add
alexlib Sep 20, 2020
670d67d
except track_cavity, all tests are real now
alexlib Sep 20, 2020
4a47e69
test_cavity is great too
alexlib Sep 20, 2020
cf087fa
452 links, not 17
alexlib Sep 20, 2020
e58af3e
Update .travis.yml
alexlib Sep 20, 2020
72d35ed
updated test_tracker.py
alexlib Sep 20, 2020
343aabd
flake8
alexlib Sep 20, 2020
790bbb1
fixed also test_burgers.py
alexlib Sep 20, 2020
d5133f6
Merge pull request #199 from OpenPTV/travis_yml_patch
alexlib Sep 20, 2020
6bdb31a
Merge pull request #42 from OpenPTV/master
alexlib Sep 20, 2020
a486c2c
Merge pull request #198 from alexlib/testing_different_reset_targ_pos
alexlib Oct 12, 2020
9494845
Bump pyyaml from 5.1 to 5.4 in /py_bind
dependabot[bot] Mar 25, 2021
b220e88
Update setup.py
alexlib Mar 27, 2021
7636dce
Update requirements.txt
alexlib Mar 27, 2021
9d82e63
Merge branch 'master' into dependabot/pip/py_bind/pyyaml-5.4
alexlib Mar 27, 2021
e747648
Merge pull request #201 from OpenPTV/dependabot/pip/py_bind/pyyaml-5.4
alexlib Mar 28, 2021
c249337
Update todo.md
alexlib Mar 11, 2022
923e876
Merge remote-tracking branch 'upstream/master' into track_breaks_add_…
alexlib Apr 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ matrix:
services:
- docker
env:
- CIBW_SKIP="*manylinux1_i686* cp34-*"
- CIBW_SKIP="*manylinux1_i686* cp34-* cp35-* cp2*"
- CIBW_BEFORE_BUILD="pip install -r requirements.txt && python setup.py prepare
--liboptv-dir liboptv-src"
- PIP=pip
- os: osx
language: generic
env:
- PIP=pip2
- PIP=pip3
- CIBW_BEFORE_BUILD="cd py_bind && pip install -r requirements.txt && python setup.py
prepare --liboptv-dir liboptv-src"
- CIBW_SKIP=cp34-*
- CIBW_SKIP="cp34-* cp35-* cp2*"

script:
- "$PIP install cibuildwheel==0.10.2"
Expand All @@ -30,4 +30,4 @@ deploy:
file: wheelhouse/*
on:
tags: true
branch: master
branch: master
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
environment:
CIBW_SKIP: "*manylinux1_i686* cp34-*"
CIBW_SKIP: "*manylinux1_i686* cp34-* cp27-*"
CIBW_BEFORE_BUILD: "cd py_bind && pip install -r requirements.txt && python setup.py prepare"

build_script:
Expand Down
3 changes: 0 additions & 3 deletions docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ done gradually, ask on the mailing list and we'll come up with a good plan.
3. Show that liboptv can be done in C++ and used in C.


## C-Tcl/Tk
1. Break C from Tcl/Tk

## Python
1. Try Cmake on top of autoconf/automake to have a unified build system

Expand Down
4 changes: 2 additions & 2 deletions liboptv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set (CMAKE_INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
project(OpenPTV)
# enable_testing()
enable_testing()
add_subdirectory(src)
# add_subdirectory(tests)
add_subdirectory(tests)

INSTALL(DIRECTORY include/ DESTINATION include/optv/)

Expand Down
4 changes: 2 additions & 2 deletions liboptv/include/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ 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_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 candsearch_in_pix_rest(target next[], int num_targets, double x, double y,
double dl, double dr, double du, double dd, int p[], 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], \
double yu[4], track_par *tpar, control_par *cpar, Calibration **cal);
Expand Down
171 changes: 163 additions & 8 deletions liboptv/src/track.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#include <math.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 +263,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 != -1 ) {
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) {
Expand Down Expand Up @@ -302,6 +305,147 @@ int candsearch_in_pix (target next[], int num_targets, double cent_x, double cen
return (counter);
}

/* candsearch_in_pix searches of four (4) near candidates in 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 - 3
*/

int candsearch_in_pix (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);

/* 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[], control_par *cpar)
{

int j, j0, dj;
int counter = 0;
double d, dmin = 1e20, xmin, xmax, ymin, ymax;
// double d1, d2, d3, d4;

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;

p[0] = 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;
p[0] = j;
}
}
}
}

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 @@ -571,14 +715,24 @@ int assess_new_position(vec3d pos, vec2d targ_pos[],
double right, left, down, up; /* search rectangle limits */

left = right = up = down = ADD_PART;
// Alex version
// for (cam = 0; cam < frm->num_cams; cam++) {

// older version
for (cam = 0; cam < TR_MAX_CAMS; cam++) {
targ_pos[cam][0] = targ_pos[cam][1] = COORD_UNUSED;
}

for (cam = 0; cam < run->cpar->num_cams; cam++) {
// up to here
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 (frm->targets[cam], frm->num_targets[cam],
num_cands = candsearch_in_pix_rest (frm->targets[cam], frm->num_targets[cam],
pixel[0], pixel[1], left, right, up, down,
cand_inds[cam], run->cpar);

// printf("num_cands after pix_rest is %d\n",num_cands);

if (num_cands > 0) {
_ix = cand_inds[cam][0]; // first nearest neighbour
Expand All @@ -588,7 +742,7 @@ int assess_new_position(vec3d pos, vec2d targ_pos[],
}

valid_cams = 0;
for (cam = 0; cam < run->cpar->num_cams; cam++) {
for (cam = 0; cam < frm->num_cams; cam++) {
if ((targ_pos[cam][0] != COORD_UNUSED) && \
(targ_pos[cam][1] != COORD_UNUSED))
{
Expand Down Expand Up @@ -722,7 +876,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] == -1) {
if (curr_corres->p[j] == CORRES_NONE) {
point_to_pixel (v1[j], X[2], cal[j], cpar);
} else {
_ix = curr_corres->p[j];
Expand Down Expand Up @@ -1026,8 +1180,9 @@ 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);

// 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 @@ -1173,7 +1328,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",
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
Loading