Skip to content

Commit 8fa0adf

Browse files
committed
updated tests pass
1 parent e12d029 commit 8fa0adf

19 files changed

Lines changed: 19922 additions & 3470 deletions

src/openptv_python/_native_compat.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,28 @@ def get_multimedia_par(control_params: Any) -> Any:
241241
return converted
242242

243243

244+
def get_image_size(control_params: Any) -> tuple[int, int]:
245+
"""Return the image size from either backend's control parameter object."""
246+
247+
getter = getattr(control_params, "get_image_size", None)
248+
if callable(getter):
249+
imx, imy = getter()
250+
return int(imx), int(imy)
251+
252+
return int(getattr(control_params, "imx")), int(getattr(control_params, "imy"))
253+
254+
255+
def get_pixel_size(control_params: Any) -> tuple[float, float]:
256+
"""Return the pixel size from either backend's control parameter object."""
257+
258+
getter = getattr(control_params, "get_pixel_size", None)
259+
if callable(getter):
260+
pix_x, pix_y = getter()
261+
return float(pix_x), float(pix_y)
262+
263+
return float(getattr(control_params, "pix_x")), float(getattr(control_params, "pix_y"))
264+
265+
244266
# Initialize once so the default preference is explicit and optv availability
245267
# is reported immediately in sessions where it is missing.
246268
set_engine(DEFAULT_ENGINE, warn_once=True)

src/openptv_python/find_candidate.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .parameters import ControlPar, VolumePar
1111
from .tracking_frame_buf import Target
1212
from .trafo import correct_brown_affine
13+
from ._native_compat import get_image_size, get_pixel_size
1314

1415

1516
def find_candidate(
@@ -63,10 +64,13 @@ def find_candidate(
6364
# The image space is the image plane of the camera. The image space is
6465
# given in millimeters of sensor size and the origin is in the center of the sensor.
6566

66-
xmin = (-1) * cpar.pix_x * cpar.imx / 2
67-
xmax = cpar.pix_x * cpar.imx / 2
68-
ymin = (-1) * cpar.pix_y * cpar.imy / 2
69-
ymax = cpar.pix_y * cpar.imy / 2
67+
imx, imy = get_image_size(cpar)
68+
pix_x, pix_y = get_pixel_size(cpar)
69+
70+
xmin = (-1) * pix_x * imx / 2
71+
xmax = pix_x * imx / 2
72+
ymin = (-1) * pix_y * imy / 2
73+
ymax = pix_y * imy / 2
7074
xmin -= cal.int_par.xh
7175
ymin -= cal.int_par.yh
7276
xmax -= cal.int_par.xh

src/openptv_python/track.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ def trackcorr_c_loop(run_info, step):
856856
count2 += 1
857857
mm = 0
858858
# counter1-loop
859-
while w[mm].ftnr != TR_UNUSED and len(fb.buf[2].path_info) > w[mm].ftnr:
859+
while mm < w.shape[0] and w[mm].ftnr != TR_UNUSED and len(fb.buf[2].path_info) > w[mm].ftnr:
860860
# search for found corr of current the corr in next_frame with predicted location
861861

862862
# found 3D-position
@@ -883,7 +883,9 @@ def trackcorr_c_loop(run_info, step):
883883
count3 += 1
884884
kk = 0
885885
while (
886-
wn[kk].ftnr != TR_UNUSED and len(fb.buf[3].path_info) > wn[kk].ftnr
886+
kk < wn.shape[0]
887+
and wn[kk].ftnr != TR_UNUSED
888+
and len(fb.buf[3].path_info) > wn[kk].ftnr
887889
):
888890
# print(f" inside wn[{kk}].ftnr {wn[kk].ftnr}")
889891
ref_path_inf = fb.buf[3].path_info[wn[kk].ftnr]
@@ -1175,7 +1177,7 @@ def trackback_c(run_info: TrackingRun):
11751177
count2 += 1
11761178

11771179
i = 0
1178-
while w[i].ftnr != TR_UNUSED:
1180+
while i < w.shape[0] and w[i].ftnr != TR_UNUSED:
11791181
ref_path_inf = fb.buf[2].path_info[w[i].ftnr]
11801182
X[3] = vec_copy(ref_path_inf.x)
11811183

tests/testing_folder/test_cavity/img/cam1.10000_targets

Lines changed: 830 additions & 830 deletions
Large diffs are not rendered by default.

tests/testing_folder/test_cavity/img/cam1.10002_targets

Lines changed: 1147 additions & 0 deletions
Large diffs are not rendered by default.

tests/testing_folder/test_cavity/img/cam1.10003_targets

Lines changed: 1229 additions & 0 deletions
Large diffs are not rendered by default.

tests/testing_folder/test_cavity/img/cam1.10004_targets

Lines changed: 1160 additions & 0 deletions
Large diffs are not rendered by default.

tests/testing_folder/test_cavity/img/cam2.10000_targets

Lines changed: 810 additions & 810 deletions
Large diffs are not rendered by default.

tests/testing_folder/test_cavity/img/cam2.10002_targets

Lines changed: 1105 additions & 0 deletions
Large diffs are not rendered by default.

tests/testing_folder/test_cavity/img/cam2.10003_targets

Lines changed: 1112 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)