Finding Closest Pair of Points

I’m trying the find the closest pair of points from one frame to another, so as to be able to tag an object. I’ve been following the simple object tracking algorithm, as provided by pyimagesearch. Unfortunately I seem to have hit a snag as the function, cdist is not available, line 81 of the provided code. I’ve attempted to replicate the output by using, “np.linalg.norm(a[:, None, :] - b[None, :, :], axis=2)”. As ulab appears to have linalg.norm, but unfortunately the method does not appear to be available on openmv. Any other fast and efficient method of finding the closest point to another is most welcome.

Huh, ulab should be fully enabled on the OpenMV Cam.

Can you post this issue here: ulab integration into openmv · Issue #881 · openmv/openmv · GitHub

alright, I’ve done so.

Thanks, the creator is on that thread. Maybe it’s just that the latest release doesn’t have the newest version of Ulab where that method is implemented.

One other thing while going through the code for the centroid tracking algorithm I stumbled across this line of code, “D.argmin(axis=1)[rows]”. I’ve absolutely no idea how it works or what it does. I’d like to convert it into a ulab compatible code if possible. Any help is welcomed.

Um, I don’t know what code you are talking about.

The centroid is just the average of the x and y locations of points.

Its the tutorial from Simple object tracking with OpenCV - PyImageSearch, specifically line 93.