Skip to content

Commit df6bfb2

Browse files
committed
Update pyptv backend shim
1 parent 4d01bc4 commit df6bfb2

2 files changed

Lines changed: 65 additions & 91 deletions

File tree

src/pyptv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 771061cfece8e50075c07b6b0e89eef34ceeaf6e
1+
Subproject commit 360dbb46d2ca145c8298be6c3f70c553984c4ac0

src/track.py

Lines changed: 64 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323
from .imgcoord import img_coord
2424
from .orientation import point_position
25-
from .parameters import ControlPar, TrackParTuple, convert_track_par_to_tuple
25+
from .parameters import ControlPar, SequencePar, TrackPar, TrackParTuple, VolumePar, convert_track_par_to_tuple
2626
from .tracking_frame_buf import Frame, Pathinfo, Target
2727
from .tracking_run import TrackingRun
2828
from .trafo import dist_to_flat, metric_to_pixel, pixel_to_metric
@@ -1340,92 +1340,66 @@ def trackback_c(run_info: TrackingRun):
13401340
}
13411341

13421342

1343-
# class Tracker:
1344-
# """
1345-
# Workflow: instantiate, call restart() to initialize the frame buffer, then.
1346-
1347-
# call either ``step_forward()`` while it still return True, then call
1348-
# ``finalize()`` to finish the run. Alternatively, ``full_forward()`` will
1349-
# do all this for you.
1350-
# """
1351-
1352-
# def __init__(
1353-
# self,
1354-
# cpar: ControlPar,
1355-
# vpar: VolumePar,
1356-
# tpar: TrackPar,
1357-
# spar: SequencePar,
1358-
# cals: List[Calibration],
1359-
# naming: dict,
1360-
# flatten_tol: float = 0.0001,
1361-
# ):
1362-
# """
1363-
# Initialize the tracker.
1364-
1365-
# Arguments:
1366-
# ---------
1367-
# ControlPar cpar, VolumePar vpar, TrackPar tpar,
1368-
# SequencePar spar - the usual parameter objects, as read from
1369-
# anywhere.
1370-
# cals - a list of Calibratiopn objects.
1371-
# dict naming - a dictionary with naming rules for the frame buffer
1372-
# files. See the ``default_naming`` member (which is the default).
1373-
# """
1374-
# # We need to keep a reference to the Python objects so that their
1375-
# # allocations are not freed.
1376-
# self._keepalive = (cpar, vpar, tpar, spar, cals)
1377-
1378-
# self.run_info = TrackingRun(
1379-
# spar,
1380-
# tpar,
1381-
# vpar,
1382-
# cpar,
1383-
# TR_BUFSPACE,
1384-
# MAX_TARGETS,
1385-
# naming["corres"],
1386-
# naming["linkage"],
1387-
# naming["prio"],
1388-
# cals,
1389-
# flatten_tol,
1390-
# )
1391-
# self.step = self.run_info.seq_par.first
1392-
1393-
# def restart(self):
1394-
# """
1395-
# Prepare a tracking run. Sets up initial buffers and performs the.
1396-
1397-
# one-time calculations used throughout the loop.
1398-
# """
1399-
# self.step = self.run_info.seq_par.first
1400-
# track_forward_start(self.run_info)
1401-
1402-
# def step_forward(self):
1403-
# """Perform one tracking step for the current frame of iteration."""
1404-
# if self.step >= self.run_info.seq_par.last:
1405-
# return False
1406-
1407-
# trackcorr_c_loop(self.run_info, self.step)
1408-
# self.step += 1
1409-
# return True
1410-
1411-
# def finalize(self):
1412-
# """Finish a tracking run."""
1413-
# trackcorr_c_finish(self.run_info, self.step)
1414-
1415-
# def full_forward(self):
1416-
# """Do a full tracking run from restart to finalize."""
1417-
# track_forward_start(self.run_info)
1418-
# for step in range(self.run_info.seq_par.first, self.run_info.seq_par.last):
1419-
# trackcorr_c_loop(self.run_info, step)
1420-
# trackcorr_c_finish(self.run_info, self.run_info.seq_par.last)
1421-
1422-
# def full_backward(self):
1423-
# """Do a full backward run on existing tracking results. so make sure.
1424-
1425-
# results exist or it will explode in your face.
1426-
# """
1427-
# trackback_c(self.run_info)
1428-
1429-
# def current_step(self):
1430-
# """Return the current step."""
1431-
# return self.step
1343+
class Tracker:
1344+
"""Compatibility wrapper for the legacy Tracker workflow."""
1345+
1346+
def __init__(
1347+
self,
1348+
cpar: ControlPar,
1349+
vpar: VolumePar,
1350+
tpar: TrackPar,
1351+
spar: SequencePar,
1352+
cals: List[Calibration],
1353+
naming: dict,
1354+
flatten_tol: float = 0.0001,
1355+
):
1356+
# Keep references to the input objects alive for the lifetime of the run.
1357+
self._keepalive = (cpar, vpar, tpar, spar, cals)
1358+
1359+
self.run_info = TrackingRun(
1360+
spar,
1361+
tpar,
1362+
vpar,
1363+
cpar,
1364+
TR_BUFSPACE,
1365+
MAX_TARGETS,
1366+
naming["corres"],
1367+
naming["linkage"],
1368+
naming["prio"],
1369+
cals,
1370+
flatten_tol,
1371+
)
1372+
self.step = self.run_info.seq_par.first
1373+
1374+
def restart(self):
1375+
"""Prepare a tracking run."""
1376+
self.step = self.run_info.seq_par.first
1377+
track_forward_start(self.run_info)
1378+
1379+
def step_forward(self):
1380+
"""Perform one tracking step for the current frame."""
1381+
if self.step >= self.run_info.seq_par.last:
1382+
return False
1383+
1384+
trackcorr_c_loop(self.run_info, self.step)
1385+
self.step += 1
1386+
return True
1387+
1388+
def finalize(self):
1389+
"""Finish a tracking run."""
1390+
trackcorr_c_finish(self.run_info, self.step)
1391+
1392+
def full_forward(self):
1393+
"""Do a full tracking run from restart to finalize."""
1394+
track_forward_start(self.run_info)
1395+
for step in range(self.run_info.seq_par.first, self.run_info.seq_par.last):
1396+
trackcorr_c_loop(self.run_info, step)
1397+
trackcorr_c_finish(self.run_info, self.run_info.seq_par.last)
1398+
1399+
def full_backward(self):
1400+
"""Do a full backward run on existing tracking results."""
1401+
trackback_c(self.run_info)
1402+
1403+
def current_step(self):
1404+
"""Return the current step."""
1405+
return self.step

0 commit comments

Comments
 (0)