Blob comparison trough different frames

So I’m using the frame difference example with the find_blobs() function to track an object and count whenever it goes in/out from the camera field of view, it works pretty good but my question is : how do I compare the blobs found in the n frame and the blobs found the n+1 frame? so I can assign an ID for each object.
I was thinking to get the color for each blob and do an comparison (or maybe by size) but I don’t know if it’s the best way.

Yeah, so, you’d want to make a list with attributes collected from each blob and then you’d make a custom distance function that’s able to compare two blobs to see how “close/similar” they are.

You’d keep the list of blobs from one frame and then use that with the next list of blobs from the next frame. Then you’d write python code to iterate over those two lists and you’d use your distance function to compare blobs to each other. Ones with a score below a threshold you set are then the same and you’d consider those then the tracked blobs between frames.

Oh ok, so I need to check if they’re close and similar enough, I already have the part if they’re pretty close by comparing the center of the blob between the frames (if it’s correct?), but how do I check if they’re pretty similar? I tried to check the documentation of the Blob class and I was thinking to use the blob.code() method or maybe use the pixel count method and compare the pixel count of the blob, but is there a way to get the LAB code of the blob? So I can compare the color of the blobs.
Or there’s a better way to check the similarity of the blobs?
I understood the concept of storing the info of the blobs in two lists and then do the comparison in python.

how is possible to determine a blob if it has the same color?
the distance method is the one that works i think too.
the distance between 2 frames will be some pixels…
on the other hand the second blob will be far away!

so the distance method should be enough? for the color I was thinking to get the LAB code of the ROI of the blobs and if they are pretty similar I can say that it’s the same blob but from different frames

Use get_stats() with the ROI of the blob as the argument to get_stats() such that it only grabs color info from where the blob is.

Note, your distance function can be whatever you like. You can take multiple variables and make up a function which compares two things to another. This is what machine learning at it’s heart is. A CNN is just a very complex array of weights which does this across a very large vector space.