Skip to content

Commit 742c3da

Browse files
committed
fixed few bugs from pyptv
1 parent f54f098 commit 742c3da

4 files changed

Lines changed: 21 additions & 13 deletions

File tree

openptv_python/constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Constants used in the Python version of OpenPTV."""
2-
NMAX = 202400 # correspondences
3-
MAXCAND = 20 # assuming a maximum capacity of MAXCAND candidates
2+
NMAX = 10000 # correspondences
3+
MAXCAND = 40 # assuming a maximum capacity of MAXCAND candidates
44
PT_UNUSED = -999
55

66
COORD_UNUSED = -1e10
@@ -22,7 +22,7 @@
2222
TR_UNUSED = -1
2323
TR_BUFSPACE = 4 # 4 frames in the buffer to track
2424
TR_MAX_CAMS = 4 # 4 cameras in the imaging system
25-
MAX_TARGETS = 2048 # maximum number of targets
25+
MAX_TARGETS = 20480 # maximum number of targets
2626
MAX_CANDS = 4
2727
ADD_PART = 3
2828

openptv_python/correspondences.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ def __init__(self, targs, cpar, cal, tol=0.00001, reset_numbers=True):
4747
self.buf = np.empty(self._num_pts, \
4848
dtype=np.dtype([('x', np.float64), ('y', np.float64), ('pnr', np.int32)]))
4949

50-
for tnum in range(self._num_pts):
51-
targ = targs._tarr[tnum]
50+
for tnum, targ in enumerate(targs):
51+
targ = targs[tnum]
5252
if reset_numbers:
5353
targ.pnr = tnum
5454

5555
self.buf[tnum]['x'], self.buf[tnum]['y'] = pixel_to_metric(
56-
targ.x, targ.y, cpar._control_par
57-
)
56+
targ.x, targ.y, cpar)
57+
5858
self.buf[tnum]['x'], self.buf[tnum]['y'] = dist_to_flat(
59-
self.buf[tnum]['x'], self.buf[tnum]['y'], cal._calibration, tol
59+
self.buf[tnum]['x'], self.buf[tnum]['y'], cal, tol
6060
)
6161
self.buf[tnum]['pnr'] = targ.pnr
6262

@@ -244,7 +244,7 @@ def three_camera_matching(
244244
for i in range(target_counts[i1]):
245245
for i2 in range(i1 + 1, num_cams - 1):
246246
p1 = corr_list[i1][i2][i].p1
247-
if p1 > nmax or tusage[i1][p1] > 0:
247+
if p1 >= nmax or tusage[i1][p1] > 0:
248248
continue
249249

250250
# print(f"p1 {p1} candidates {corr_list[i1][i2][i].n } ")
@@ -323,14 +323,14 @@ def consistent_pair_matching(
323323
for i2 in range(i1 + 1, num_cams):
324324
for i in range(target_counts[i1]):
325325
p1 = corr_list[i1][i2][i].p1
326-
if p1 > nmax or tusage[i1][p1] > 0:
326+
if p1 >= nmax or tusage[i1][p1] > 0:
327327
continue
328328

329329
if corr_list[i1][i2][i].n != 1:
330330
continue
331331

332332
p2 = corr_list[i1][i2][i].p2[0]
333-
if p2 > nmax or tusage[i2][p2] > 0:
333+
if p2 >= nmax or tusage[i2][p2] > 0:
334334
continue
335335

336336
corr = corr_list[i1][i2][i].corr[0] / corr_list[i1][i2][i].dist[0]
@@ -423,6 +423,7 @@ def match_pairs(
423423

424424
# search for a conjugate point in corrected[i2]
425425
# cand = [Correspond() for _ in range(MAXCAND)]
426+
426427
cand = find_candidate(
427428
corrected[i2],
428429
frm.targets[i2],
@@ -682,7 +683,7 @@ def correspondences(
682683
683684
684685
"""
685-
nmax = 1000 # NMAX
686+
nmax = NMAX
686687

687688
# Allocation of scratch buffers for internal tasks and return-value space
688689
con0 = [n_tupel() for _ in range(nmax * cpar.num_cams)]

openptv_python/parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ class PftVersionPar(Parameters):
836836
def from_file(cls, file_path: str):
837837
"""Read from pft_version.par file."""
838838
with open(file_path, 'r', encoding="utf-8") as file:
839-
pft_version = bool(file.readline().strip())
839+
pft_version = bool(int(file.readline().strip()))
840840
return cls(pft_version)
841841

842842
@classmethod

openptv_python/tracking_frame_buf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ def write_targets(
214214
targets: List[Target], num_targets: int, file_base: str, frame_num: int) -> bool:
215215
"""Write targets to a file."""
216216
success = False
217+
218+
# fix old-type names, that are like cam1.# or just cam1.
219+
if "%" not in file_base:
220+
file_base = file_base + "%05d"
221+
if '#' in file_base:
222+
file_base = file_base.replace('#', '%05d')
223+
217224
file_name = (
218225
file_base + "_targets"
219226
if frame_num == 0

0 commit comments

Comments
 (0)