Skip to content

Commit

Permalink
todo: need to fix the reading of empty path_info
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlib committed Nov 19, 2023
1 parent d36397d commit c6c767d
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 191 deletions.
37 changes: 34 additions & 3 deletions openptv_python/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,42 @@ def assess_new_position(
return valid_cams, targ_pos, cand_inds


# def add_particle(frm: Frame, pos: np.ndarray, cand_inds: np.ndarray) -> None:
# """Add a new particle to the frame buffer."""
# ref_path_inf = Pathinfo(x=pos)
# ref_path_inf.reset_links()

# frm.path_info.append(ref_path_inf)


# ref_corres = Corres()
# ref_targets = frm.targets

# for cam in range(frm.num_cams):
# ref_corres.p[cam] = CORRES_NONE

# # We always take the 1st candidate, apparently. Why did we fetch 4?
# if cand_inds[cam][0] != PT_UNUSED:
# _ix = cand_inds[cam][0]
# ref_targets[cam][_ix].tnr = frm.num_parts
# ref_corres.p[cam] = _ix
# ref_corres.nr = frm.num_parts

# frm.correspond.append(ref_corres)
# frm.num_parts += 1


def add_particle(frm: Frame, pos: np.ndarray, cand_inds: np.ndarray) -> None:
"""Add a new particle to the frame buffer."""
"""Insert a particle at a given position to the end of the frame, along with associated targets.
Arguments:
- frm (frame): The frame to store the particle.
- pos (vec3d): Position of the inserted particle in global coordinates.
- cand_inds (list[list[int]]): Indices of candidate targets for association with this particle.
"""
num_parts = frm.num_parts
ref_path_inf = frm.path_info[num_parts]
ref_path_inf.x = pos
ref_path_inf.x = vec_copy(pos)
ref_path_inf.reset_links()

ref_corres = frm.correspond[num_parts]
Expand All @@ -732,6 +763,7 @@ def add_particle(frm: Frame, pos: np.ndarray, cand_inds: np.ndarray) -> None:
frm.num_parts += 1



def track_forward_start(tr: TrackingRun):
"""Initialize the tracking frame buffer with the first frames.
Expand Down Expand Up @@ -764,7 +796,6 @@ def trackcorr_c_loop(run_info, step):
rr = 0.0

_ix = 0 # For use in any of the complex index expressions below
orig_parts = 0 # avoid infinite loop with particle addition set
num_added = 0
count1 = 0
count2 = 0
Expand Down
3 changes: 2 additions & 1 deletion openptv_python/tracking_frame_buf.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@ def read_path_frame(

# we do not need number of particles, reading till EOF
n_particles = int(filein.readline())
cor_buf = [Corres() for _ in range(n_particles)]
print(f"Reading {n_particles} particles from {fname}")
cor_buf = [Corres() for _ in range(n_particles)] # we do not want empty lists
path_buf = [Pathinfo() for _ in range(n_particles)]

if linkage_file_base != "":
Expand Down
14 changes: 9 additions & 5 deletions tests/test_cavity.py → tests/test_cavity.py.bck
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import unittest
import os
import shutil
import shutil
import unittest
from pathlib import Path

from openptv_python.parameters import read_control_par
from openptv_python.calibration import Calibration, read_calibration
from openptv_python.parameters import read_control_par
from openptv_python.track import (
track_forward_start,
trackcorr_c_finish,
trackcorr_c_loop,
)
from openptv_python.tracking_run import tr_new
from openptv_python.track import track_forward_start, trackcorr_c_loop, trackcorr_c_finish


def remove_directory(directory_path):
Expand Down Expand Up @@ -141,7 +145,7 @@ def test_cavity(self):
self.assertEqual(run.nlinks, 132 + 180 + 149,
f"Was expecting nlinks == 461 found {run.nlinks}")

remove_directory("res/")
remove_directory("img/")

Expand Down
Loading

0 comments on commit c6c767d

Please sign in to comment.