DeepLabCut / DeepLabCut-live

SDK for running DeepLabCut on a live video stream
https://elifesciences.org/articles/61909
Other
192 stars 50 forks source link

Output of dlc.getpose when object is not in view #77

Closed ReiniertB closed 2 years ago

ReiniertB commented 2 years ago

I want to track an object using DLC-live, but when the object is not in view, I want some kind of message that says "Object is not in view right now". I know this is easily built using a if statement, but I do not know what the output of dlc.getposeI(img) is when an object is not in view. Could someone tell me this so I can build in an if statement in my code? Thanks in advance!

sneakers-the-rat commented 2 years ago

return value of get_pose is an n_parts x 3 array, where the columns arey_position, x_position, probability (i'm pretty sure it's y then x since images are [row, column] indexed, but doesn't rly matter in this case anyway)

So when an object isn't in view with a reasonably accurate model you'd have a very low probability (third column).

So, say you only have one part you're tracking (return value has shape 1 x 3) Your if statement could look like:

threshold = 0.1
pose = dlc.get_pose(image)
if pose[0,2] < threshold:
    print('part not in frame!')

lmk if that doesn't work

ReiniertB commented 2 years ago

Ah yes, of course. Thank you very much!