📹 Blob tracking visualization
This notebook creates visualizations of blob-tracking results using CSV files produced by SimBA. The visualization overlays shapes, centers, and other body parts of detected blobs onto the original videos.
In this notebook, we will create visualizations from the CSV files created by the blob tracking method.
The prerequisits for this to work is that you have:
Blob tracking data in CSV files. You can find a notebook for creating blob tracking results [HERE]. You can find tutorials for creating blob tracking data in the SimBA GUI [HERE] and [HERE].
The original videos that where used to create the blob tracking CSV files.
Prerequisites
Make sure you have:
Blob tracking data stored as CSV files.You can create blob tracking data using the notebook HERE or the SimBA GUI tutorials HERE.
Original video files that were used to generate the blob tracking CSVs. These are needed to overlay the visualizations.
[3]:
# IMPORT REQUIRED FUNCTIONS
from simba.plotting.blob_visualizer import BlobVisualizer
[4]:
#Adjust the following paths and settings to match your local setup.
# Path to the CSV file or directory containing blob tracking results
DATA_PATH = r'C:\troubleshooting\blob_track\results'
# Path to the original video file or directory of videos used to generate the CSVs
VIDEO_PATH = r'C:\troubleshooting\blob_track\videos'
# Output directory for saving the visualized videos
SAVE_DIR = r'C:\troubleshooting\blob_track\out_videos'
# Number of CPU cores to use (-1 uses all available cores)
CORE_COUNT = -1
# Visualization parameters
SHAPE_OPACITY = 0.5 # Opacity of the blob overlay (0 = transparent, 1 = opaque)
BACKGROUND_OPACITY = 1.0 # Opacity of the background (0 = transparent, 1 = opaque)
CIRCLE_SIZE = None # Optional circle radius for body parts. Set to None for auto-scaling.
# Overlay color settings (BGR format). Set any to None to disable.
HULL = (178, 102, 255)
CENTER = (0, 165, 255)
ANTERIOR = None
POSTERIOR = None
LEFT = None
RIGHT = None
[5]:
#Initialize the Visualizer
visualizer = BlobVisualizer(data_path=DATA_PATH,
video_path=VIDEO_PATH,
save_dir=SAVE_DIR,
core_cnt=CORE_COUNT,
shape_opacity=SHAPE_OPACITY,
bg_opacity=BACKGROUND_OPACITY,
circle_size=CIRCLE_SIZE,
hull=HULL,
anterior=ANTERIOR,
posterior=POSTERIOR,
left=LEFT,
right=RIGHT,
center=CENTER)
[ ]:
#Run the Visualizer
# This will generate videos with visualized blob tracking overlays.
# Progress will be printed in the terminal.
visualizer.run()
Running blob visualization for 7 video(s) (start time: 12:14:24)...
Running blob visualization for video F12_coc_364_fps_15...
Section 0/32 complete...
Section 1/32 complete...
Section 2/32 complete...
Section 3/32 complete...
Section 4/32 complete...
Section 5/32 complete...
Section 6/32 complete...
Section 7/32 complete...
Section 8/32 complete...
Section 9/32 complete...
Section 10/32 complete...
Section 11/32 complete...
Section 12/32 complete...
Section 13/32 complete...
Section 14/32 complete...
Section 15/32 complete...
Section 16/32 complete...
Section 17/32 complete...
Section 18/32 complete...
Section 19/32 complete...
Section 20/32 complete...
Section 21/32 complete...
Section 22/32 complete...
Section 23/32 complete...
Section 24/32 complete...
Section 25/32 complete...
Section 26/32 complete...
Section 27/32 complete...
Section 28/32 complete...
Section 29/32 complete...
Section 30/32 complete...
Section 31/32 complete...
Joining F12_coc_364_fps_15 geometry video...
SIMBA COMPLETE: Video concatenated (elapsed time: 16.6269s) complete
SIMBA COMPLETE: Geometry video C:\troubleshooting\blob_track\out_videos\F12_coc_364_fps_15.mp4 complete! (elapsed time: 116.5597s) complete
Running blob visualization for video F12_sal_380_fps_15...
Section 0/32 complete...
Section 1/32 complete...
Section 2/32 complete...
Section 3/32 complete...
Section 4/32 complete...
Section 5/32 complete...
Section 6/32 complete...
Section 7/32 complete...
Section 8/32 complete...
Section 9/32 complete...
Section 10/32 complete...
Section 11/32 complete...
Section 12/32 complete...
Section 13/32 complete...
Section 14/32 complete...
Section 15/32 complete...
Section 16/32 complete...
Section 17/32 complete...
Section 18/32 complete...
Section 19/32 complete...
Section 20/32 complete...
Section 21/32 complete...
Section 22/32 complete...
Section 23/32 complete...
Section 24/32 complete...
Section 25/32 complete...
Section 26/32 complete...
Section 27/32 complete...
Section 28/32 complete...
Section 29/32 complete...
Section 30/32 complete...
Section 31/32 complete...
Joining F12_sal_380_fps_15 geometry video...
SIMBA COMPLETE: Video concatenated (elapsed time: 16.5622s) complete
SIMBA COMPLETE: Geometry video C:\troubleshooting\blob_track\out_videos\F12_sal_380_fps_15.mp4 complete! (elapsed time: 121.7675s) complete
Running blob visualization for video F16_sal_400_fps_15...
Section 0/32 complete...
Section 1/32 complete...
Section 2/32 complete...
Section 3/32 complete...
Section 4/32 complete...
Section 5/32 complete...
Section 6/32 complete...
Section 7/32 complete...
Section 8/32 complete...
Section 9/32 complete...
Section 10/32 complete...
Section 11/32 complete...
Section 12/32 complete...
Section 13/32 complete...
Section 14/32 complete...
Section 15/32 complete...
Section 16/32 complete...
Section 17/32 complete...
Section 18/32 complete...
Section 19/32 complete...
Section 20/32 complete...
Section 21/32 complete...
Section 22/32 complete...
Section 23/32 complete...
Section 24/32 complete...
Section 25/32 complete...
Section 26/32 complete...
Section 27/32 complete...
Section 28/32 complete...
Section 29/32 complete...
Section 30/32 complete...
Section 31/32 complete...
Joining F16_sal_400_fps_15 geometry video...
SIMBA COMPLETE: Video concatenated (elapsed time: 17.169s) complete
SIMBA COMPLETE: Geometry video C:\troubleshooting\blob_track\out_videos\F16_sal_400_fps_15.mp4 complete! (elapsed time: 139.3649s) complete
Running blob visualization for video M1_sal_380_fps_15...
Section 0/32 complete...
Section 1/32 complete...
Section 2/32 complete...
Section 3/32 complete...
Section 4/32 complete...
Section 5/32 complete...
Section 6/32 complete...
Section 7/32 complete...
Section 8/32 complete...
Section 9/32 complete...
Section 10/32 complete...
Section 11/32 complete...
Section 12/32 complete...
Section 13/32 complete...
Section 14/32 complete...
Section 15/32 complete...
Section 16/32 complete...
Section 17/32 complete...
Section 18/32 complete...
Section 19/32 complete...
Section 20/32 complete...
Section 21/32 complete...
Section 22/32 complete...
Section 23/32 complete...
Section 24/32 complete...
Section 25/32 complete...
Section 26/32 complete...
Section 27/32 complete...
Section 28/32 complete...
Section 29/32 complete...
Section 30/32 complete...
Section 31/32 complete...
Joining M1_sal_380_fps_15 geometry video...
SIMBA COMPLETE: Video concatenated (elapsed time: 14.4002s) complete
SIMBA COMPLETE: Geometry video C:\troubleshooting\blob_track\out_videos\M1_sal_380_fps_15.mp4 complete! (elapsed time: 129.3775s) complete
Running blob visualization for video M2_coc_380_fps_15...
[ ]: