Skip to content

Commit

Permalink
fixes to matching and utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ronshnapp committed Oct 23, 2024
1 parent 9c7d966 commit f3d8e8c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
10 changes: 0 additions & 10 deletions myptv/particle_matching_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,9 @@ def find_candidates_with_two_cameras(self, camNum1, camNum2, frame):
blob pairs in two given cameras. The points that are found are then
returned.
'''
<<<<<<< HEAD

# if there are no blobs in this frame, return empty list
if frame not in self.blobs[camNum1].keys():
return []

if frame not in self.blobs[camNum2].keys():
return []
=======
# ensure the cameras have blobs in this frame
if frame not in list(self.blobs[camNum1].keys()): return []
if frame not in list(self.blobs[camNum2].keys()): return []
>>>>>>> bug fix regarding frames with no blobs in matching

# fetching the cameras and the blobs
cam1 = self.imsys.cameras[camNum1] ; cam2 = self.imsys.cameras[camNum2]
Expand Down
23 changes: 22 additions & 1 deletion myptv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def __init__(self, camera, blob_fname, target_file_fname):
self.cam = camera
self.blobs = loadtxt(blob_fname)
self.targets = loadtxt(target_file_fname)
self.get_neighbor_separation()


def pair_points(self):
Expand All @@ -250,14 +251,34 @@ def pair_points(self):
d_min = d
j_min = j

if d_min < 30:
if d_min < self.dmin/2:
blob_point_pair = NPappend(self.blobs[i][1::-1],
self.targets[j_min])
point_pairs.append(blob_point_pair)

self.point_pairs = point_pairs


def get_neighbor_separation(self):
'''
returns an estimate for the minimum separation distance between blobs.
'''
bxy = self.blobs[:,1::-1]
dmin = 1e20
N = len(bxy)
i=0

for i in range(min([N,20])):
for j in range(N):
if j==i: continue
d = sum((bxy[i] - bxy[j])**2)**0.5
if d<dmin:
dmin = d
print('dmin: ', dmin)
self.dmin = dmin



def save_results(self, fname):
'''
Saves the pairs of blobs and target points in a given file name.
Expand Down

0 comments on commit f3d8e8c

Please sign in to comment.