Using BayesianTracker with bounding box input #200
-
Hi all, I have a question about using BayesianTracker with bounding box input. I have bounding boxes around the objects I want to track for images in a time series. I am wondering how to import these bounding boxes (or their centroids) into a PyTrackObject to create a MotionModel (or whatever other model is appropriate in this case). The data are germinating pollen grains, example attached. I hope to track both the pollen grains (cyan, green, blue, magenta bounding boxes) and the pollen tube tips (orange bounding boxes). Thanks for your help! pollen_germination_time_series.mov |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @cedarwarman - this looks super cool. I'm assuming that your bounding boxes are coming from a Pytorch FasterRCNN. If so, the following code snippet should help: from btrack.btypes import PyTrackObject
objects = []
for t, img in enumerate(movie):
# grab the detections from the frame of the movie
detections = detector.predict(img)
detections = torch.cat(
[
detections["boxes"],
detections["scores"][:, None],
detections["labels"][:, None],
# detections["features"],
], axis=-1
).cpu().numpy()
# now convert each detection to a btrack object for tracking
for detection in detections:
obj_data = {
"ID": id_counter,
"t": t,
"x": np.mean(detection[0:3:2]),
"y": np.mean(detection[1:4:2]),
"z": 0.,
"rpn_score": detection[4],
"rpn_obj_type": int(detection[5]),
"rpn_box": detection[:4],
}
obj = PyTrackObject.from_dict(obj_data)
objects.append(obj)
id_counter +=1 LMK if this helps (or doesn't!). |
Beta Was this translation helpful? Give feedback.
-
Thanks for this snippet, I think I am getting closer. My data comes from a Tensorflow Object Detection API model, so for the tracking I have extracted the coordinates of the bounding boxes, the classes, and the confidence scores. I can pull out the actual image data as well, if necessary. For now I am trying to do just a motion model, without the visual information, but I am curious how including the visual information would improve the tracking. I have a few more questions based on the code snippet:
The Pandas DataFrame looks like this:
It looks like the PyTrackObjects are being created and the model is running successfully:
And here is how the tracks look overlayed on the final image: Overall I think it is doing really well for a first pass. The question is, do you have any configuration advice for fixing some of the problems with track joining? I used the configuration file here as a starting point, but I would be interested to hear if you have any tips that would improve the model for these data. Thanks again for your help! |
Beta Was this translation helpful? Give feedback.
-
Looks awesome! Did you try the |
Beta Was this translation helpful? Give feedback.
Hi @cedarwarman - this looks super cool. I'm assuming that your bounding boxes are coming from a Pytorch FasterRCNN. If so, the following code snippet should help: