Tutorial 7: Video analysis#

The principles of video analysis and image analysis are similar: instead of images, single video frames are segmented into foreground and background, and the extracted information is processed after all frames have been analyzed (e.g. frame-wise location is converted into trajectories). However, a big advantage is that differences among consecutive frames can be used to train a background model from which the foreground can segmented. This is called foreground-background subtraction.

Currently the tracking module works standalone and uses only few routines of the phenopype core modules. Future releases may feature a better integration with the different phenopype workflows.

https://d33wubrfki0l68.cloudfront.net/6d69afecd164c33c21ebd6b9d7d8789351b5952e/561da/_images/tracking1.gif
https://d33wubrfki0l68.cloudfront.net/27cf0813c1170a64385fbfd836e2510dd7ad3d14/da922/_images/tracking2.png

Fig. 1: The motion tracker module enables the tracking of multiple objects that can be distinguished by size. For example, it is possible to record and separate the movement of both fish (red) and all 20 isopods (green) in this predator-prey interaction experiment.

Further resources related to this tutorial

  • foreground-background subtraction

The motion tracker class#

First, the motion_tracker class needs to be initizalized with a video-path to collect basic information about the input video. Specifying video output is optional: the tracking procedure can be run without saving any record of the tracking-results, but only the results (i.e. just a csv with coordinates and no video). Should the video_ouput method be called then it will save an output video with similar properties (codec, dimensions, fps.) of the input file.

[1]:
import phenopype as pp
import os

os.chdir(r"D:\workspace\git-repos\phenopype\phenopype-tutorials")

video_path =  r"tutorials/data/isopods_fish.mp4"
out_dir =  r"_temp/video"
[2]:
mt = pp.motion_tracker(video_path)


--------------------------------------------------------------
Input video properties - "isopods_fish.mp4":

Frames per second: 29.97000099996667
N frames: 450
Length: 00:15 (mm:ss)
Dimensions: (960, 540)
Colour video: True
FourCC code: avc1
--------------------------------------------------------------
[3]:
mt.video_output(save_suffix="v1",
                dirpath=out_dir)


--------------------------------------------------------------
Output video settings - "isopods_fish.mp4":

Save name: isopods_fish_v1.mp4
Save dir: D:\workspace\git-repos\phenopype\phenopype-tutorials\_temp\video
Frames per second: 29.97000099996667
Dimensions: (960, 540)
Colour video: True
Format (FourCC code): avc1
--------------------------------------------------------------

Tracking settings#

Now the settings for the tracking methods need to be set. Depending on the input video the default settings may work. In that case we don’t have to do everthing and the the run_tracking-method conducts motion tracking with default settings. However, typically adjust some setting will provide cleaner results.

[4]:
mt.detection_settings(skip=5, # only capture every 5th frame (that's still a lot given 30 fps!)
                     start_after=1, # skip the first second of the video
                     threshold=10, # lower values = more sensitive fg-bg subtraction
                     detect_shadows=True, # attempt to detect shadows
                     history=60) # how many seconds can a previously moving pixel sit still


--------------------------------------------------------------
Motion detection settings - "isopods_fish.mp4":

Background-subtractor: MOG
History: 60 seconds
Sensitivity: 10
Read every nth frame: 5
Detect shadows: True
Start after n seconds: 1
Finish after n seconds:  -
--------------------------------------------------------------

If no specific tracking_method see below is selected, the output window will just return the results of the foreground-background subtraction: the foreground mas. Everything that is white will be detected and can be recorded, everything that is gray is identified as shadow (and can be removed), and everything else is background.

Foreground mask

Fig. 2: The output of foreground-background subtraction is a binary mask. Overlaying that mask back onto the original video can be used to extract phenotypic information.

[5]:
coordinates = mt.run_tracking()
Time: 00:00/00:15 - Frames: 1/450
Time: 00:00/00:15 - Frames: 2/450
Time: 00:00/00:15 - Frames: 3/450
Time: 00:00/00:15 - Frames: 4/450
Time: 00:00/00:15 - Frames: 5/450
Time: 00:00/00:15 - Frames: 6/450
Time: 00:00/00:15 - Frames: 7/450
Time: 00:00/00:15 - Frames: 8/450
Time: 00:00/00:15 - Frames: 9/450
Time: 00:00/00:15 - Frames: 10/450
Time: 00:00/00:15 - Frames: 11/450
Time: 00:00/00:15 - Frames: 12/450
Time: 00:00/00:15 - Frames: 13/450
Time: 00:00/00:15 - Frames: 14/450
Time: 00:00/00:15 - Frames: 15/450
Time: 00:00/00:15 - Frames: 16/450
Time: 00:00/00:15 - Frames: 17/450
Time: 00:00/00:15 - Frames: 18/450
Time: 00:00/00:15 - Frames: 19/450
Time: 00:00/00:15 - Frames: 20/450
Time: 00:00/00:15 - Frames: 21/450
Time: 00:00/00:15 - Frames: 22/450
Time: 00:00/00:15 - Frames: 23/450
Time: 00:00/00:15 - Frames: 24/450
Time: 00:00/00:15 - Frames: 25/450
Time: 00:00/00:15 - Frames: 26/450
Time: 00:00/00:15 - Frames: 27/450
Time: 00:00/00:15 - Frames: 28/450
Time: 00:00/00:15 - Frames: 29/450
Time: 00:01/00:15 - Frames: 30/450 - captured
Time: 00:01/00:15 - Frames: 31/450
Time: 00:01/00:15 - Frames: 32/450
Time: 00:01/00:15 - Frames: 33/450
Time: 00:01/00:15 - Frames: 34/450
Time: 00:01/00:15 - Frames: 35/450 - captured
Time: 00:01/00:15 - Frames: 36/450
Time: 00:01/00:15 - Frames: 37/450
Time: 00:01/00:15 - Frames: 38/450
Time: 00:01/00:15 - Frames: 39/450
Time: 00:01/00:15 - Frames: 40/450 - captured
Time: 00:01/00:15 - Frames: 41/450
Time: 00:01/00:15 - Frames: 42/450
Time: 00:01/00:15 - Frames: 43/450
Time: 00:01/00:15 - Frames: 44/450
Time: 00:01/00:15 - Frames: 45/450 - captured
Time: 00:01/00:15 - Frames: 46/450
Time: 00:01/00:15 - Frames: 47/450
Time: 00:01/00:15 - Frames: 48/450
Time: 00:01/00:15 - Frames: 49/450
Time: 00:01/00:15 - Frames: 50/450 - captured
Time: 00:01/00:15 - Frames: 51/450
Time: 00:01/00:15 - Frames: 52/450
Time: 00:01/00:15 - Frames: 53/450
Time: 00:01/00:15 - Frames: 54/450
Time: 00:01/00:15 - Frames: 55/450 - captured
Time: 00:01/00:15 - Frames: 56/450
Time: 00:01/00:15 - Frames: 57/450
Time: 00:01/00:15 - Frames: 58/450
Time: 00:01/00:15 - Frames: 59/450
Time: 00:02/00:15 - Frames: 60/450 - captured
Time: 00:02/00:15 - Frames: 61/450
Time: 00:02/00:15 - Frames: 62/450
Time: 00:02/00:15 - Frames: 63/450
Time: 00:02/00:15 - Frames: 64/450
Time: 00:02/00:15 - Frames: 65/450 - captured
Time: 00:02/00:15 - Frames: 66/450
Time: 00:02/00:15 - Frames: 67/450
Time: 00:02/00:15 - Frames: 68/450
Time: 00:02/00:15 - Frames: 69/450
Time: 00:02/00:15 - Frames: 70/450 - captured
Time: 00:02/00:15 - Frames: 71/450
Time: 00:02/00:15 - Frames: 72/450
Time: 00:02/00:15 - Frames: 73/450
Time: 00:02/00:15 - Frames: 74/450
Time: 00:02/00:15 - Frames: 75/450 - captured
Time: 00:02/00:15 - Frames: 76/450
Time: 00:02/00:15 - Frames: 77/450
Time: 00:02/00:15 - Frames: 78/450
Time: 00:02/00:15 - Frames: 79/450
Time: 00:02/00:15 - Frames: 80/450 - captured
Time: 00:02/00:15 - Frames: 81/450
Time: 00:02/00:15 - Frames: 82/450
Time: 00:02/00:15 - Frames: 83/450
Time: 00:02/00:15 - Frames: 84/450
Time: 00:02/00:15 - Frames: 85/450 - captured
Time: 00:02/00:15 - Frames: 86/450
Time: 00:02/00:15 - Frames: 87/450
Time: 00:02/00:15 - Frames: 88/450
Time: 00:02/00:15 - Frames: 89/450
Time: 00:03/00:15 - Frames: 90/450 - captured
Time: 00:03/00:15 - Frames: 91/450
Time: 00:03/00:15 - Frames: 92/450
Time: 00:03/00:15 - Frames: 93/450
Time: 00:03/00:15 - Frames: 94/450
Time: 00:03/00:15 - Frames: 95/450 - captured
Time: 00:03/00:15 - Frames: 96/450
Time: 00:03/00:15 - Frames: 97/450
Time: 00:03/00:15 - Frames: 98/450
Time: 00:03/00:15 - Frames: 99/450
Time: 00:03/00:15 - Frames: 100/450 - captured
Time: 00:03/00:15 - Frames: 101/450
Time: 00:03/00:15 - Frames: 102/450
Time: 00:03/00:15 - Frames: 103/450
Time: 00:03/00:15 - Frames: 104/450
Time: 00:03/00:15 - Frames: 105/450 - captured
Time: 00:03/00:15 - Frames: 106/450
Time: 00:03/00:15 - Frames: 107/450
Time: 00:03/00:15 - Frames: 108/450
Time: 00:03/00:15 - Frames: 109/450
Time: 00:03/00:15 - Frames: 110/450 - captured
Time: 00:03/00:15 - Frames: 111/450
Time: 00:03/00:15 - Frames: 112/450
Time: 00:03/00:15 - Frames: 113/450
Time: 00:03/00:15 - Frames: 114/450
Time: 00:03/00:15 - Frames: 115/450 - captured
Time: 00:03/00:15 - Frames: 116/450
Time: 00:03/00:15 - Frames: 117/450
Time: 00:03/00:15 - Frames: 118/450
Time: 00:03/00:15 - Frames: 119/450
Time: 00:04/00:15 - Frames: 120/450 - captured
Time: 00:04/00:15 - Frames: 121/450
Time: 00:04/00:15 - Frames: 122/450
Time: 00:04/00:15 - Frames: 123/450
Time: 00:04/00:15 - Frames: 124/450
Time: 00:04/00:15 - Frames: 125/450 - captured
Time: 00:04/00:15 - Frames: 126/450
Time: 00:04/00:15 - Frames: 127/450
Time: 00:04/00:15 - Frames: 128/450
Time: 00:04/00:15 - Frames: 129/450
Time: 00:04/00:15 - Frames: 130/450 - captured
Time: 00:04/00:15 - Frames: 131/450
Time: 00:04/00:15 - Frames: 132/450
Time: 00:04/00:15 - Frames: 133/450
Time: 00:04/00:15 - Frames: 134/450
Time: 00:04/00:15 - Frames: 135/450 - captured
Time: 00:04/00:15 - Frames: 136/450
Time: 00:04/00:15 - Frames: 137/450
Time: 00:04/00:15 - Frames: 138/450
Time: 00:04/00:15 - Frames: 139/450
Time: 00:04/00:15 - Frames: 140/450 - captured
Time: 00:04/00:15 - Frames: 141/450
Time: 00:04/00:15 - Frames: 142/450
Time: 00:04/00:15 - Frames: 143/450
Time: 00:04/00:15 - Frames: 144/450
Time: 00:04/00:15 - Frames: 145/450 - captured
Time: 00:04/00:15 - Frames: 146/450
Time: 00:04/00:15 - Frames: 147/450
Time: 00:04/00:15 - Frames: 148/450
Time: 00:04/00:15 - Frames: 149/450
Time: 00:05/00:15 - Frames: 150/450 - captured
Time: 00:05/00:15 - Frames: 151/450
Time: 00:05/00:15 - Frames: 152/450
Time: 00:05/00:15 - Frames: 153/450
Time: 00:05/00:15 - Frames: 154/450
Time: 00:05/00:15 - Frames: 155/450 - captured
Time: 00:05/00:15 - Frames: 156/450
Time: 00:05/00:15 - Frames: 157/450
Time: 00:05/00:15 - Frames: 158/450
Time: 00:05/00:15 - Frames: 159/450
Time: 00:05/00:15 - Frames: 160/450 - captured
Time: 00:05/00:15 - Frames: 161/450
Time: 00:05/00:15 - Frames: 162/450
Time: 00:05/00:15 - Frames: 163/450
Time: 00:05/00:15 - Frames: 164/450
Time: 00:05/00:15 - Frames: 165/450 - captured
Time: 00:05/00:15 - Frames: 166/450
Time: 00:05/00:15 - Frames: 167/450
Time: 00:05/00:15 - Frames: 168/450
Time: 00:05/00:15 - Frames: 169/450
Time: 00:05/00:15 - Frames: 170/450 - captured
Time: 00:05/00:15 - Frames: 171/450
Time: 00:05/00:15 - Frames: 172/450
Time: 00:05/00:15 - Frames: 173/450
Time: 00:05/00:15 - Frames: 174/450
Time: 00:05/00:15 - Frames: 175/450 - captured
Time: 00:05/00:15 - Frames: 176/450
Time: 00:05/00:15 - Frames: 177/450
Time: 00:05/00:15 - Frames: 178/450
Time: 00:05/00:15 - Frames: 179/450
Time: 00:06/00:15 - Frames: 180/450 - captured
Time: 00:06/00:15 - Frames: 181/450
Time: 00:06/00:15 - Frames: 182/450
Time: 00:06/00:15 - Frames: 183/450
Time: 00:06/00:15 - Frames: 184/450
Time: 00:06/00:15 - Frames: 185/450 - captured
Time: 00:06/00:15 - Frames: 186/450
Time: 00:06/00:15 - Frames: 187/450
Time: 00:06/00:15 - Frames: 188/450
Time: 00:06/00:15 - Frames: 189/450
Time: 00:06/00:15 - Frames: 190/450 - captured
Time: 00:06/00:15 - Frames: 191/450
Time: 00:06/00:15 - Frames: 192/450
Time: 00:06/00:15 - Frames: 193/450
Time: 00:06/00:15 - Frames: 194/450
Time: 00:06/00:15 - Frames: 195/450 - captured
Time: 00:06/00:15 - Frames: 196/450
Time: 00:06/00:15 - Frames: 197/450
Time: 00:06/00:15 - Frames: 198/450
Time: 00:06/00:15 - Frames: 199/450
Time: 00:06/00:15 - Frames: 200/450 - captured
Time: 00:06/00:15 - Frames: 201/450
Time: 00:06/00:15 - Frames: 202/450
Time: 00:06/00:15 - Frames: 203/450
Time: 00:06/00:15 - Frames: 204/450
Time: 00:06/00:15 - Frames: 205/450 - captured
Time: 00:06/00:15 - Frames: 206/450
Time: 00:06/00:15 - Frames: 207/450
Time: 00:06/00:15 - Frames: 208/450
Time: 00:06/00:15 - Frames: 209/450
Time: 00:07/00:15 - Frames: 210/450 - captured
Time: 00:07/00:15 - Frames: 211/450
Time: 00:07/00:15 - Frames: 212/450
Time: 00:07/00:15 - Frames: 213/450
Time: 00:07/00:15 - Frames: 214/450
Time: 00:07/00:15 - Frames: 215/450 - captured
Time: 00:07/00:15 - Frames: 216/450
Time: 00:07/00:15 - Frames: 217/450
Time: 00:07/00:15 - Frames: 218/450
Time: 00:07/00:15 - Frames: 219/450
Time: 00:07/00:15 - Frames: 220/450 - captured
Time: 00:07/00:15 - Frames: 221/450
Time: 00:07/00:15 - Frames: 222/450
Time: 00:07/00:15 - Frames: 223/450
Time: 00:07/00:15 - Frames: 224/450
Time: 00:07/00:15 - Frames: 225/450 - captured
Time: 00:07/00:15 - Frames: 226/450
Time: 00:07/00:15 - Frames: 227/450
Time: 00:07/00:15 - Frames: 228/450
Time: 00:07/00:15 - Frames: 229/450
Time: 00:07/00:15 - Frames: 230/450 - captured
Time: 00:07/00:15 - Frames: 231/450
Time: 00:07/00:15 - Frames: 232/450
Time: 00:07/00:15 - Frames: 233/450
Time: 00:07/00:15 - Frames: 234/450
Time: 00:07/00:15 - Frames: 235/450 - captured
Time: 00:07/00:15 - Frames: 236/450
Time: 00:07/00:15 - Frames: 237/450
Time: 00:07/00:15 - Frames: 238/450
Time: 00:07/00:15 - Frames: 239/450
Time: 00:08/00:15 - Frames: 240/450 - captured
Time: 00:08/00:15 - Frames: 241/450
Time: 00:08/00:15 - Frames: 242/450
Time: 00:08/00:15 - Frames: 243/450
Time: 00:08/00:15 - Frames: 244/450
Time: 00:08/00:15 - Frames: 245/450 - captured
Time: 00:08/00:15 - Frames: 246/450
Time: 00:08/00:15 - Frames: 247/450
Time: 00:08/00:15 - Frames: 248/450
Time: 00:08/00:15 - Frames: 249/450
Time: 00:08/00:15 - Frames: 250/450 - captured
Time: 00:08/00:15 - Frames: 251/450
Time: 00:08/00:15 - Frames: 252/450
Time: 00:08/00:15 - Frames: 253/450
Time: 00:08/00:15 - Frames: 254/450
Time: 00:08/00:15 - Frames: 255/450 - captured
Time: 00:08/00:15 - Frames: 256/450
Time: 00:08/00:15 - Frames: 257/450
Time: 00:08/00:15 - Frames: 258/450
Time: 00:08/00:15 - Frames: 259/450
Time: 00:08/00:15 - Frames: 260/450 - captured
Time: 00:08/00:15 - Frames: 261/450
Time: 00:08/00:15 - Frames: 262/450
Time: 00:08/00:15 - Frames: 263/450
Time: 00:08/00:15 - Frames: 264/450
Time: 00:08/00:15 - Frames: 265/450 - captured
Time: 00:08/00:15 - Frames: 266/450
Time: 00:08/00:15 - Frames: 267/450
Time: 00:08/00:15 - Frames: 268/450
Time: 00:08/00:15 - Frames: 269/450
Time: 00:09/00:15 - Frames: 270/450 - captured
Time: 00:09/00:15 - Frames: 271/450
Time: 00:09/00:15 - Frames: 272/450
Time: 00:09/00:15 - Frames: 273/450
Time: 00:09/00:15 - Frames: 274/450
Time: 00:09/00:15 - Frames: 275/450 - captured
Time: 00:09/00:15 - Frames: 276/450
Time: 00:09/00:15 - Frames: 277/450
Time: 00:09/00:15 - Frames: 278/450
Time: 00:09/00:15 - Frames: 279/450
Time: 00:09/00:15 - Frames: 280/450 - captured
Time: 00:09/00:15 - Frames: 281/450
Time: 00:09/00:15 - Frames: 282/450
Time: 00:09/00:15 - Frames: 283/450
Time: 00:09/00:15 - Frames: 284/450
Time: 00:09/00:15 - Frames: 285/450 - captured
Time: 00:09/00:15 - Frames: 286/450
Time: 00:09/00:15 - Frames: 287/450
Time: 00:09/00:15 - Frames: 288/450
Time: 00:09/00:15 - Frames: 289/450
Time: 00:09/00:15 - Frames: 290/450 - captured
Time: 00:09/00:15 - Frames: 291/450
Time: 00:09/00:15 - Frames: 292/450
Time: 00:09/00:15 - Frames: 293/450
Time: 00:09/00:15 - Frames: 294/450
Time: 00:09/00:15 - Frames: 295/450 - captured
Time: 00:09/00:15 - Frames: 296/450
Time: 00:09/00:15 - Frames: 297/450
Time: 00:09/00:15 - Frames: 298/450
Time: 00:09/00:15 - Frames: 299/450
Time: 00:10/00:15 - Frames: 300/450 - captured
Time: 00:10/00:15 - Frames: 301/450
Time: 00:10/00:15 - Frames: 302/450
Time: 00:10/00:15 - Frames: 303/450
Time: 00:10/00:15 - Frames: 304/450
Time: 00:10/00:15 - Frames: 305/450 - captured
Time: 00:10/00:15 - Frames: 306/450
Time: 00:10/00:15 - Frames: 307/450
Time: 00:10/00:15 - Frames: 308/450
Time: 00:10/00:15 - Frames: 309/450
Time: 00:10/00:15 - Frames: 310/450 - captured
Time: 00:10/00:15 - Frames: 311/450
Time: 00:10/00:15 - Frames: 312/450
Time: 00:10/00:15 - Frames: 313/450
Time: 00:10/00:15 - Frames: 314/450
Time: 00:10/00:15 - Frames: 315/450 - captured
Time: 00:10/00:15 - Frames: 316/450
Time: 00:10/00:15 - Frames: 317/450
Time: 00:10/00:15 - Frames: 318/450
Time: 00:10/00:15 - Frames: 319/450
Time: 00:10/00:15 - Frames: 320/450 - captured
Time: 00:10/00:15 - Frames: 321/450
Time: 00:10/00:15 - Frames: 322/450
Time: 00:10/00:15 - Frames: 323/450
Time: 00:10/00:15 - Frames: 324/450
Time: 00:10/00:15 - Frames: 325/450 - captured
Time: 00:10/00:15 - Frames: 326/450
Time: 00:10/00:15 - Frames: 327/450
Time: 00:10/00:15 - Frames: 328/450
Time: 00:10/00:15 - Frames: 329/450
Time: 00:11/00:15 - Frames: 330/450 - captured
Time: 00:11/00:15 - Frames: 331/450
Time: 00:11/00:15 - Frames: 332/450
Time: 00:11/00:15 - Frames: 333/450
Time: 00:11/00:15 - Frames: 334/450
Time: 00:11/00:15 - Frames: 335/450 - captured
Time: 00:11/00:15 - Frames: 336/450
Time: 00:11/00:15 - Frames: 337/450
Time: 00:11/00:15 - Frames: 338/450
Time: 00:11/00:15 - Frames: 339/450
Time: 00:11/00:15 - Frames: 340/450 - captured
Time: 00:11/00:15 - Frames: 341/450
Time: 00:11/00:15 - Frames: 342/450
Time: 00:11/00:15 - Frames: 343/450
Time: 00:11/00:15 - Frames: 344/450
Time: 00:11/00:15 - Frames: 345/450 - captured
Time: 00:11/00:15 - Frames: 346/450
Time: 00:11/00:15 - Frames: 347/450
Time: 00:11/00:15 - Frames: 348/450
Time: 00:11/00:15 - Frames: 349/450
Time: 00:11/00:15 - Frames: 350/450 - captured
Time: 00:11/00:15 - Frames: 351/450
Time: 00:11/00:15 - Frames: 352/450
Time: 00:11/00:15 - Frames: 353/450
Time: 00:11/00:15 - Frames: 354/450
Time: 00:11/00:15 - Frames: 355/450 - captured
Time: 00:11/00:15 - Frames: 356/450
Time: 00:11/00:15 - Frames: 357/450
Time: 00:11/00:15 - Frames: 358/450
Time: 00:11/00:15 - Frames: 359/450
Time: 00:12/00:15 - Frames: 360/450 - captured
Time: 00:12/00:15 - Frames: 361/450
Time: 00:12/00:15 - Frames: 362/450
Time: 00:12/00:15 - Frames: 363/450
Time: 00:12/00:15 - Frames: 364/450
Time: 00:12/00:15 - Frames: 365/450 - captured
Time: 00:12/00:15 - Frames: 366/450
Time: 00:12/00:15 - Frames: 367/450
Time: 00:12/00:15 - Frames: 368/450
Time: 00:12/00:15 - Frames: 369/450
Time: 00:12/00:15 - Frames: 370/450 - captured
Time: 00:12/00:15 - Frames: 371/450
Time: 00:12/00:15 - Frames: 372/450
Time: 00:12/00:15 - Frames: 373/450
Time: 00:12/00:15 - Frames: 374/450
Time: 00:12/00:15 - Frames: 375/450 - captured
Time: 00:12/00:15 - Frames: 376/450
Time: 00:12/00:15 - Frames: 377/450
Time: 00:12/00:15 - Frames: 378/450
Time: 00:12/00:15 - Frames: 379/450
Time: 00:12/00:15 - Frames: 380/450 - captured
Time: 00:12/00:15 - Frames: 381/450
Time: 00:12/00:15 - Frames: 382/450
Time: 00:12/00:15 - Frames: 383/450
Time: 00:12/00:15 - Frames: 384/450
Time: 00:12/00:15 - Frames: 385/450 - captured
Time: 00:12/00:15 - Frames: 386/450
Time: 00:12/00:15 - Frames: 387/450
Time: 00:12/00:15 - Frames: 388/450
Time: 00:12/00:15 - Frames: 389/450
Time: 00:13/00:15 - Frames: 390/450 - captured
Time: 00:13/00:15 - Frames: 391/450
Time: 00:13/00:15 - Frames: 392/450
Time: 00:13/00:15 - Frames: 393/450
Time: 00:13/00:15 - Frames: 394/450
Time: 00:13/00:15 - Frames: 395/450 - captured
Time: 00:13/00:15 - Frames: 396/450
Time: 00:13/00:15 - Frames: 397/450
Time: 00:13/00:15 - Frames: 398/450
Time: 00:13/00:15 - Frames: 399/450
Time: 00:13/00:15 - Frames: 400/450 - captured
Time: 00:13/00:15 - Frames: 401/450
Time: 00:13/00:15 - Frames: 402/450
Time: 00:13/00:15 - Frames: 403/450
Time: 00:13/00:15 - Frames: 404/450
Time: 00:13/00:15 - Frames: 405/450 - captured
Time: 00:13/00:15 - Frames: 406/450
Time: 00:13/00:15 - Frames: 407/450
Time: 00:13/00:15 - Frames: 408/450
Time: 00:13/00:15 - Frames: 409/450
Time: 00:13/00:15 - Frames: 410/450 - captured
Time: 00:13/00:15 - Frames: 411/450
Time: 00:13/00:15 - Frames: 412/450
Time: 00:13/00:15 - Frames: 413/450
Time: 00:13/00:15 - Frames: 414/450
Time: 00:13/00:15 - Frames: 415/450 - captured
Time: 00:13/00:15 - Frames: 416/450
Time: 00:13/00:15 - Frames: 417/450
Time: 00:13/00:15 - Frames: 418/450
Time: 00:13/00:15 - Frames: 419/450
Time: 00:14/00:15 - Frames: 420/450 - captured
Time: 00:14/00:15 - Frames: 421/450
Time: 00:14/00:15 - Frames: 422/450
Time: 00:14/00:15 - Frames: 423/450
Time: 00:14/00:15 - Frames: 424/450
Time: 00:14/00:15 - Frames: 425/450 - captured
Time: 00:14/00:15 - Frames: 426/450
Time: 00:14/00:15 - Frames: 427/450
Time: 00:14/00:15 - Frames: 428/450
Time: 00:14/00:15 - Frames: 429/450
Time: 00:14/00:15 - Frames: 430/450 - captured
Time: 00:14/00:15 - Frames: 431/450
Time: 00:14/00:15 - Frames: 432/450
Time: 00:14/00:15 - Frames: 433/450
Time: 00:14/00:15 - Frames: 434/450
Time: 00:14/00:15 - Frames: 435/450 - captured
Time: 00:14/00:15 - Frames: 436/450
Time: 00:14/00:15 - Frames: 437/450
Time: 00:14/00:15 - Frames: 438/450
Time: 00:14/00:15 - Frames: 439/450
Time: 00:14/00:15 - Frames: 440/450 - captured
Time: 00:14/00:15 - Frames: 441/450
Time: 00:14/00:15 - Frames: 442/450
Time: 00:14/00:15 - Frames: 443/450
Time: 00:14/00:15 - Frames: 444/450
Time: 00:14/00:15 - Frames: 445/450 - captured
Time: 00:14/00:15 - Frames: 446/450
Time: 00:14/00:15 - Frames: 447/450
Time: 00:14/00:15 - Frames: 448/450

Tracking-methods#

So far, the motion tracker has just performed foreground-background subtraction without recording coordinates of objects - the coordinates DataFrame is empty. To record something we have to specify a tracking_method. This can be as simple as:

[6]:
# create fish method
mov = pp.tracking_method(label="movement", min_length=5)

Now we just pass the method to the tracking settings (detection_settings). Using that method will also call all default settings. Afterwards we can run the tracking procedure again:

[7]:
mt.detection_settings(methods=mov)
-----------------------------
Detection method "movement":

{'blur_kernel': 5,
 'label': 'movement',
 'max_area': inf,
 'max_length': inf,
 'min_area': 0,
 'min_length': 5,
 'mode': 'multiple',
 'overlay_colour': (0, 0,
                    255),
 'remove_shadows': True,
 'threshold_value': 127}
-----------------------------




--------------------------------------------------------------
Motion detection settings - "isopods_fish.mp4":

Background-subtractor: MOG
History: 60 seconds
Sensitivity: 10
Read every nth frame: 5
Detect shadows: True
Start after n seconds: 0
Finish after n seconds:  -
--------------------------------------------------------------
[8]:
coordinates = mt.run_tracking()
Time: 00:00/00:15 - Frames: 1/450
Time: 00:00/00:15 - Frames: 2/450
Time: 00:00/00:15 - Frames: 3/450
Time: 00:00/00:15 - Frames: 4/450
Time: 00:00/00:15 - Frames: 5/450 - captured
Time: 00:00/00:15 - Frames: 6/450
Time: 00:00/00:15 - Frames: 7/450
Time: 00:00/00:15 - Frames: 8/450
Time: 00:00/00:15 - Frames: 9/450
Time: 00:00/00:15 - Frames: 10/450 - captured
Time: 00:00/00:15 - Frames: 11/450
Time: 00:00/00:15 - Frames: 12/450
Time: 00:00/00:15 - Frames: 13/450
Time: 00:00/00:15 - Frames: 14/450
Time: 00:00/00:15 - Frames: 15/450 - captured
Time: 00:00/00:15 - Frames: 16/450
Time: 00:00/00:15 - Frames: 17/450
Time: 00:00/00:15 - Frames: 18/450
Time: 00:00/00:15 - Frames: 19/450
Time: 00:00/00:15 - Frames: 20/450 - captured
Time: 00:00/00:15 - Frames: 21/450
Time: 00:00/00:15 - Frames: 22/450
Time: 00:00/00:15 - Frames: 23/450
Time: 00:00/00:15 - Frames: 24/450
Time: 00:00/00:15 - Frames: 25/450 - captured
Time: 00:00/00:15 - Frames: 26/450
Time: 00:00/00:15 - Frames: 27/450
Time: 00:00/00:15 - Frames: 28/450
Time: 00:00/00:15 - Frames: 29/450
Time: 00:01/00:15 - Frames: 30/450 - captured
Time: 00:01/00:15 - Frames: 31/450
Time: 00:01/00:15 - Frames: 32/450
Time: 00:01/00:15 - Frames: 33/450
Time: 00:01/00:15 - Frames: 34/450
Time: 00:01/00:15 - Frames: 35/450 - captured
Time: 00:01/00:15 - Frames: 36/450
Time: 00:01/00:15 - Frames: 37/450
Time: 00:01/00:15 - Frames: 38/450
Time: 00:01/00:15 - Frames: 39/450
Time: 00:01/00:15 - Frames: 40/450 - captured
Time: 00:01/00:15 - Frames: 41/450
Time: 00:01/00:15 - Frames: 42/450
Time: 00:01/00:15 - Frames: 43/450
Time: 00:01/00:15 - Frames: 44/450
Time: 00:01/00:15 - Frames: 45/450 - captured
Time: 00:01/00:15 - Frames: 46/450
Time: 00:01/00:15 - Frames: 47/450
Time: 00:01/00:15 - Frames: 48/450
Time: 00:01/00:15 - Frames: 49/450
Time: 00:01/00:15 - Frames: 50/450 - captured
Time: 00:01/00:15 - Frames: 51/450
Time: 00:01/00:15 - Frames: 52/450
Time: 00:01/00:15 - Frames: 53/450
Time: 00:01/00:15 - Frames: 54/450
Time: 00:01/00:15 - Frames: 55/450 - captured
Time: 00:01/00:15 - Frames: 56/450
Time: 00:01/00:15 - Frames: 57/450
Time: 00:01/00:15 - Frames: 58/450
Time: 00:01/00:15 - Frames: 59/450
Time: 00:02/00:15 - Frames: 60/450 - captured
Time: 00:02/00:15 - Frames: 61/450
Time: 00:02/00:15 - Frames: 62/450
Time: 00:02/00:15 - Frames: 63/450
Time: 00:02/00:15 - Frames: 64/450
Time: 00:02/00:15 - Frames: 65/450 - captured
Time: 00:02/00:15 - Frames: 66/450
Time: 00:02/00:15 - Frames: 67/450
Time: 00:02/00:15 - Frames: 68/450
Time: 00:02/00:15 - Frames: 69/450
Time: 00:02/00:15 - Frames: 70/450 - captured
Time: 00:02/00:15 - Frames: 71/450
Time: 00:02/00:15 - Frames: 72/450
Time: 00:02/00:15 - Frames: 73/450
Time: 00:02/00:15 - Frames: 74/450
Time: 00:02/00:15 - Frames: 75/450 - captured
Time: 00:02/00:15 - Frames: 76/450
Time: 00:02/00:15 - Frames: 77/450
Time: 00:02/00:15 - Frames: 78/450
Time: 00:02/00:15 - Frames: 79/450
Time: 00:02/00:15 - Frames: 80/450 - captured
Time: 00:02/00:15 - Frames: 81/450
Time: 00:02/00:15 - Frames: 82/450
Time: 00:02/00:15 - Frames: 83/450
Time: 00:02/00:15 - Frames: 84/450
Time: 00:02/00:15 - Frames: 85/450 - captured
Time: 00:02/00:15 - Frames: 86/450
Time: 00:02/00:15 - Frames: 87/450
Time: 00:02/00:15 - Frames: 88/450
Time: 00:02/00:15 - Frames: 89/450
Time: 00:03/00:15 - Frames: 90/450 - captured
Time: 00:03/00:15 - Frames: 91/450
Time: 00:03/00:15 - Frames: 92/450
Time: 00:03/00:15 - Frames: 93/450
Time: 00:03/00:15 - Frames: 94/450
Time: 00:03/00:15 - Frames: 95/450 - captured
Time: 00:03/00:15 - Frames: 96/450
Time: 00:03/00:15 - Frames: 97/450
Time: 00:03/00:15 - Frames: 98/450
Time: 00:03/00:15 - Frames: 99/450
Time: 00:03/00:15 - Frames: 100/450 - captured
Time: 00:03/00:15 - Frames: 101/450
Time: 00:03/00:15 - Frames: 102/450
Time: 00:03/00:15 - Frames: 103/450
Time: 00:03/00:15 - Frames: 104/450
Time: 00:03/00:15 - Frames: 105/450 - captured
Time: 00:03/00:15 - Frames: 106/450
Time: 00:03/00:15 - Frames: 107/450
Time: 00:03/00:15 - Frames: 108/450
Time: 00:03/00:15 - Frames: 109/450
Time: 00:03/00:15 - Frames: 110/450 - captured
Time: 00:03/00:15 - Frames: 111/450
Time: 00:03/00:15 - Frames: 112/450
Time: 00:03/00:15 - Frames: 113/450
Time: 00:03/00:15 - Frames: 114/450
Time: 00:03/00:15 - Frames: 115/450 - captured
Time: 00:03/00:15 - Frames: 116/450
Time: 00:03/00:15 - Frames: 117/450
Time: 00:03/00:15 - Frames: 118/450
Time: 00:03/00:15 - Frames: 119/450
Time: 00:04/00:15 - Frames: 120/450 - captured
Time: 00:04/00:15 - Frames: 121/450
Time: 00:04/00:15 - Frames: 122/450
Time: 00:04/00:15 - Frames: 123/450
Time: 00:04/00:15 - Frames: 124/450
Time: 00:04/00:15 - Frames: 125/450 - captured
Time: 00:04/00:15 - Frames: 126/450
Time: 00:04/00:15 - Frames: 127/450
Time: 00:04/00:15 - Frames: 128/450
Time: 00:04/00:15 - Frames: 129/450
Time: 00:04/00:15 - Frames: 130/450 - captured
Time: 00:04/00:15 - Frames: 131/450
Time: 00:04/00:15 - Frames: 132/450
Time: 00:04/00:15 - Frames: 133/450
Time: 00:04/00:15 - Frames: 134/450
Time: 00:04/00:15 - Frames: 135/450 - captured
Time: 00:04/00:15 - Frames: 136/450
Time: 00:04/00:15 - Frames: 137/450
Time: 00:04/00:15 - Frames: 138/450
Time: 00:04/00:15 - Frames: 139/450
Time: 00:04/00:15 - Frames: 140/450 - captured
Time: 00:04/00:15 - Frames: 141/450
Time: 00:04/00:15 - Frames: 142/450
Time: 00:04/00:15 - Frames: 143/450
Time: 00:04/00:15 - Frames: 144/450
Time: 00:04/00:15 - Frames: 145/450 - captured
Time: 00:04/00:15 - Frames: 146/450
Time: 00:04/00:15 - Frames: 147/450
Time: 00:04/00:15 - Frames: 148/450
Time: 00:04/00:15 - Frames: 149/450
Time: 00:05/00:15 - Frames: 150/450 - captured
Time: 00:05/00:15 - Frames: 151/450
Time: 00:05/00:15 - Frames: 152/450
Time: 00:05/00:15 - Frames: 153/450
Time: 00:05/00:15 - Frames: 154/450
Time: 00:05/00:15 - Frames: 155/450 - captured
Time: 00:05/00:15 - Frames: 156/450
Time: 00:05/00:15 - Frames: 157/450
Time: 00:05/00:15 - Frames: 158/450
Time: 00:05/00:15 - Frames: 159/450
Time: 00:05/00:15 - Frames: 160/450 - captured
Time: 00:05/00:15 - Frames: 161/450
Time: 00:05/00:15 - Frames: 162/450
Time: 00:05/00:15 - Frames: 163/450
Time: 00:05/00:15 - Frames: 164/450
Time: 00:05/00:15 - Frames: 165/450 - captured
Time: 00:05/00:15 - Frames: 166/450
Time: 00:05/00:15 - Frames: 167/450
Time: 00:05/00:15 - Frames: 168/450
Time: 00:05/00:15 - Frames: 169/450
Time: 00:05/00:15 - Frames: 170/450 - captured
Time: 00:05/00:15 - Frames: 171/450
Time: 00:05/00:15 - Frames: 172/450
Time: 00:05/00:15 - Frames: 173/450
Time: 00:05/00:15 - Frames: 174/450
Time: 00:05/00:15 - Frames: 175/450 - captured
Time: 00:05/00:15 - Frames: 176/450
Time: 00:05/00:15 - Frames: 177/450
Time: 00:05/00:15 - Frames: 178/450
Time: 00:05/00:15 - Frames: 179/450
Time: 00:06/00:15 - Frames: 180/450 - captured
Time: 00:06/00:15 - Frames: 181/450
Time: 00:06/00:15 - Frames: 182/450
Time: 00:06/00:15 - Frames: 183/450
Time: 00:06/00:15 - Frames: 184/450
Time: 00:06/00:15 - Frames: 185/450 - captured
Time: 00:06/00:15 - Frames: 186/450
Time: 00:06/00:15 - Frames: 187/450
Time: 00:06/00:15 - Frames: 188/450
Time: 00:06/00:15 - Frames: 189/450
Time: 00:06/00:15 - Frames: 190/450 - captured
Time: 00:06/00:15 - Frames: 191/450
Time: 00:06/00:15 - Frames: 192/450
Time: 00:06/00:15 - Frames: 193/450
Time: 00:06/00:15 - Frames: 194/450
Time: 00:06/00:15 - Frames: 195/450 - captured
Time: 00:06/00:15 - Frames: 196/450
Time: 00:06/00:15 - Frames: 197/450
Time: 00:06/00:15 - Frames: 198/450
Time: 00:06/00:15 - Frames: 199/450
Time: 00:06/00:15 - Frames: 200/450 - captured
Time: 00:06/00:15 - Frames: 201/450
Time: 00:06/00:15 - Frames: 202/450
Time: 00:06/00:15 - Frames: 203/450
Time: 00:06/00:15 - Frames: 204/450
Time: 00:06/00:15 - Frames: 205/450 - captured
Time: 00:06/00:15 - Frames: 206/450
Time: 00:06/00:15 - Frames: 207/450
Time: 00:06/00:15 - Frames: 208/450
Time: 00:06/00:15 - Frames: 209/450
Time: 00:07/00:15 - Frames: 210/450 - captured
Time: 00:07/00:15 - Frames: 211/450
Time: 00:07/00:15 - Frames: 212/450
Time: 00:07/00:15 - Frames: 213/450
Time: 00:07/00:15 - Frames: 214/450
Time: 00:07/00:15 - Frames: 215/450 - captured
Time: 00:07/00:15 - Frames: 216/450
Time: 00:07/00:15 - Frames: 217/450
Time: 00:07/00:15 - Frames: 218/450
Time: 00:07/00:15 - Frames: 219/450
Time: 00:07/00:15 - Frames: 220/450 - captured
Time: 00:07/00:15 - Frames: 221/450
Time: 00:07/00:15 - Frames: 222/450
Time: 00:07/00:15 - Frames: 223/450
Time: 00:07/00:15 - Frames: 224/450
Time: 00:07/00:15 - Frames: 225/450 - captured
Time: 00:07/00:15 - Frames: 226/450
Time: 00:07/00:15 - Frames: 227/450
Time: 00:07/00:15 - Frames: 228/450
Time: 00:07/00:15 - Frames: 229/450
Time: 00:07/00:15 - Frames: 230/450 - captured
Time: 00:07/00:15 - Frames: 231/450
Time: 00:07/00:15 - Frames: 232/450
Time: 00:07/00:15 - Frames: 233/450
Time: 00:07/00:15 - Frames: 234/450
Time: 00:07/00:15 - Frames: 235/450 - captured
Time: 00:07/00:15 - Frames: 236/450
Time: 00:07/00:15 - Frames: 237/450
Time: 00:07/00:15 - Frames: 238/450
Time: 00:07/00:15 - Frames: 239/450
Time: 00:08/00:15 - Frames: 240/450 - captured
Time: 00:08/00:15 - Frames: 241/450
Time: 00:08/00:15 - Frames: 242/450
Time: 00:08/00:15 - Frames: 243/450
Time: 00:08/00:15 - Frames: 244/450
Time: 00:08/00:15 - Frames: 245/450 - captured
Time: 00:08/00:15 - Frames: 246/450
Time: 00:08/00:15 - Frames: 247/450
Time: 00:08/00:15 - Frames: 248/450
Time: 00:08/00:15 - Frames: 249/450
Time: 00:08/00:15 - Frames: 250/450 - captured
Time: 00:08/00:15 - Frames: 251/450
Time: 00:08/00:15 - Frames: 252/450
Time: 00:08/00:15 - Frames: 253/450
Time: 00:08/00:15 - Frames: 254/450
Time: 00:08/00:15 - Frames: 255/450 - captured
Time: 00:08/00:15 - Frames: 256/450
Time: 00:08/00:15 - Frames: 257/450
Time: 00:08/00:15 - Frames: 258/450
Time: 00:08/00:15 - Frames: 259/450
Time: 00:08/00:15 - Frames: 260/450 - captured
Time: 00:08/00:15 - Frames: 261/450
Time: 00:08/00:15 - Frames: 262/450
Time: 00:08/00:15 - Frames: 263/450
Time: 00:08/00:15 - Frames: 264/450
Time: 00:08/00:15 - Frames: 265/450 - captured
Time: 00:08/00:15 - Frames: 266/450
Time: 00:08/00:15 - Frames: 267/450
Time: 00:08/00:15 - Frames: 268/450
Time: 00:08/00:15 - Frames: 269/450
Time: 00:09/00:15 - Frames: 270/450 - captured
Time: 00:09/00:15 - Frames: 271/450
Time: 00:09/00:15 - Frames: 272/450
Time: 00:09/00:15 - Frames: 273/450
Time: 00:09/00:15 - Frames: 274/450
Time: 00:09/00:15 - Frames: 275/450 - captured
Time: 00:09/00:15 - Frames: 276/450
Time: 00:09/00:15 - Frames: 277/450
Time: 00:09/00:15 - Frames: 278/450
Time: 00:09/00:15 - Frames: 279/450
Time: 00:09/00:15 - Frames: 280/450 - captured
Time: 00:09/00:15 - Frames: 281/450
Time: 00:09/00:15 - Frames: 282/450
Time: 00:09/00:15 - Frames: 283/450
Time: 00:09/00:15 - Frames: 284/450
Time: 00:09/00:15 - Frames: 285/450 - captured
Time: 00:09/00:15 - Frames: 286/450
Time: 00:09/00:15 - Frames: 287/450
Time: 00:09/00:15 - Frames: 288/450
Time: 00:09/00:15 - Frames: 289/450
Time: 00:09/00:15 - Frames: 290/450 - captured
Time: 00:09/00:15 - Frames: 291/450
Time: 00:09/00:15 - Frames: 292/450
Time: 00:09/00:15 - Frames: 293/450
Time: 00:09/00:15 - Frames: 294/450
Time: 00:09/00:15 - Frames: 295/450 - captured
Time: 00:09/00:15 - Frames: 296/450
Time: 00:09/00:15 - Frames: 297/450
Time: 00:09/00:15 - Frames: 298/450
Time: 00:09/00:15 - Frames: 299/450
Time: 00:10/00:15 - Frames: 300/450 - captured
Time: 00:10/00:15 - Frames: 301/450
Time: 00:10/00:15 - Frames: 302/450
Time: 00:10/00:15 - Frames: 303/450
Time: 00:10/00:15 - Frames: 304/450
Time: 00:10/00:15 - Frames: 305/450 - captured
Time: 00:10/00:15 - Frames: 306/450
Time: 00:10/00:15 - Frames: 307/450
Time: 00:10/00:15 - Frames: 308/450
Time: 00:10/00:15 - Frames: 309/450
Time: 00:10/00:15 - Frames: 310/450 - captured
Time: 00:10/00:15 - Frames: 311/450
Time: 00:10/00:15 - Frames: 312/450
Time: 00:10/00:15 - Frames: 313/450
Time: 00:10/00:15 - Frames: 314/450
Time: 00:10/00:15 - Frames: 315/450 - captured
Time: 00:10/00:15 - Frames: 316/450
Time: 00:10/00:15 - Frames: 317/450
Time: 00:10/00:15 - Frames: 318/450
Time: 00:10/00:15 - Frames: 319/450
Time: 00:10/00:15 - Frames: 320/450 - captured
Time: 00:10/00:15 - Frames: 321/450
Time: 00:10/00:15 - Frames: 322/450
Time: 00:10/00:15 - Frames: 323/450
Time: 00:10/00:15 - Frames: 324/450
Time: 00:10/00:15 - Frames: 325/450 - captured
Time: 00:10/00:15 - Frames: 326/450
Time: 00:10/00:15 - Frames: 327/450
Time: 00:10/00:15 - Frames: 328/450
Time: 00:10/00:15 - Frames: 329/450
Time: 00:11/00:15 - Frames: 330/450 - captured
Time: 00:11/00:15 - Frames: 331/450
Time: 00:11/00:15 - Frames: 332/450
Time: 00:11/00:15 - Frames: 333/450
Time: 00:11/00:15 - Frames: 334/450
Time: 00:11/00:15 - Frames: 335/450 - captured
Time: 00:11/00:15 - Frames: 336/450
Time: 00:11/00:15 - Frames: 337/450
Time: 00:11/00:15 - Frames: 338/450
Time: 00:11/00:15 - Frames: 339/450
Time: 00:11/00:15 - Frames: 340/450 - captured
Time: 00:11/00:15 - Frames: 341/450
Time: 00:11/00:15 - Frames: 342/450
Time: 00:11/00:15 - Frames: 343/450
Time: 00:11/00:15 - Frames: 344/450
Time: 00:11/00:15 - Frames: 345/450 - captured
Time: 00:11/00:15 - Frames: 346/450
Time: 00:11/00:15 - Frames: 347/450
Time: 00:11/00:15 - Frames: 348/450
Time: 00:11/00:15 - Frames: 349/450
Time: 00:11/00:15 - Frames: 350/450 - captured
Time: 00:11/00:15 - Frames: 351/450
Time: 00:11/00:15 - Frames: 352/450
Time: 00:11/00:15 - Frames: 353/450
Time: 00:11/00:15 - Frames: 354/450
Time: 00:11/00:15 - Frames: 355/450 - captured
Time: 00:11/00:15 - Frames: 356/450
Time: 00:11/00:15 - Frames: 357/450
Time: 00:11/00:15 - Frames: 358/450
Time: 00:11/00:15 - Frames: 359/450
Time: 00:12/00:15 - Frames: 360/450 - captured
Time: 00:12/00:15 - Frames: 361/450
Time: 00:12/00:15 - Frames: 362/450
Time: 00:12/00:15 - Frames: 363/450
Time: 00:12/00:15 - Frames: 364/450
Time: 00:12/00:15 - Frames: 365/450 - captured
Time: 00:12/00:15 - Frames: 366/450
Time: 00:12/00:15 - Frames: 367/450
Time: 00:12/00:15 - Frames: 368/450
Time: 00:12/00:15 - Frames: 369/450
Time: 00:12/00:15 - Frames: 370/450 - captured
Time: 00:12/00:15 - Frames: 371/450
Time: 00:12/00:15 - Frames: 372/450
Time: 00:12/00:15 - Frames: 373/450
Time: 00:12/00:15 - Frames: 374/450
Time: 00:12/00:15 - Frames: 375/450 - captured
Time: 00:12/00:15 - Frames: 376/450
Time: 00:12/00:15 - Frames: 377/450
Time: 00:12/00:15 - Frames: 378/450
Time: 00:12/00:15 - Frames: 379/450
Time: 00:12/00:15 - Frames: 380/450 - captured
Time: 00:12/00:15 - Frames: 381/450
Time: 00:12/00:15 - Frames: 382/450
Time: 00:12/00:15 - Frames: 383/450
Time: 00:12/00:15 - Frames: 384/450
Time: 00:12/00:15 - Frames: 385/450 - captured
Time: 00:12/00:15 - Frames: 386/450
Time: 00:12/00:15 - Frames: 387/450
Time: 00:12/00:15 - Frames: 388/450
Time: 00:12/00:15 - Frames: 389/450
Time: 00:13/00:15 - Frames: 390/450 - captured
Time: 00:13/00:15 - Frames: 391/450
Time: 00:13/00:15 - Frames: 392/450
Time: 00:13/00:15 - Frames: 393/450
Time: 00:13/00:15 - Frames: 394/450
Time: 00:13/00:15 - Frames: 395/450 - captured
Time: 00:13/00:15 - Frames: 396/450
Time: 00:13/00:15 - Frames: 397/450
Time: 00:13/00:15 - Frames: 398/450
Time: 00:13/00:15 - Frames: 399/450
Time: 00:13/00:15 - Frames: 400/450 - captured
Time: 00:13/00:15 - Frames: 401/450
Time: 00:13/00:15 - Frames: 402/450
Time: 00:13/00:15 - Frames: 403/450
Time: 00:13/00:15 - Frames: 404/450
Time: 00:13/00:15 - Frames: 405/450 - captured
Time: 00:13/00:15 - Frames: 406/450
Time: 00:13/00:15 - Frames: 407/450
Time: 00:13/00:15 - Frames: 408/450
Time: 00:13/00:15 - Frames: 409/450
Time: 00:13/00:15 - Frames: 410/450 - captured
Time: 00:13/00:15 - Frames: 411/450
Time: 00:13/00:15 - Frames: 412/450
Time: 00:13/00:15 - Frames: 413/450
Time: 00:13/00:15 - Frames: 414/450
Time: 00:13/00:15 - Frames: 415/450 - captured
Time: 00:13/00:15 - Frames: 416/450
Time: 00:13/00:15 - Frames: 417/450
Time: 00:13/00:15 - Frames: 418/450
Time: 00:13/00:15 - Frames: 419/450
Time: 00:14/00:15 - Frames: 420/450 - captured
Time: 00:14/00:15 - Frames: 421/450
Time: 00:14/00:15 - Frames: 422/450
Time: 00:14/00:15 - Frames: 423/450
Time: 00:14/00:15 - Frames: 424/450
Time: 00:14/00:15 - Frames: 425/450 - captured
Time: 00:14/00:15 - Frames: 426/450
Time: 00:14/00:15 - Frames: 427/450
Time: 00:14/00:15 - Frames: 428/450
Time: 00:14/00:15 - Frames: 429/450
Time: 00:14/00:15 - Frames: 430/450 - captured
Time: 00:14/00:15 - Frames: 431/450
Time: 00:14/00:15 - Frames: 432/450
Time: 00:14/00:15 - Frames: 433/450
Time: 00:14/00:15 - Frames: 434/450
Time: 00:14/00:15 - Frames: 435/450 - captured
Time: 00:14/00:15 - Frames: 436/450
Time: 00:14/00:15 - Frames: 437/450
Time: 00:14/00:15 - Frames: 438/450
Time: 00:14/00:15 - Frames: 439/450
Time: 00:14/00:15 - Frames: 440/450 - captured
Time: 00:14/00:15 - Frames: 441/450
Time: 00:14/00:15 - Frames: 442/450
Time: 00:14/00:15 - Frames: 443/450
Time: 00:14/00:15 - Frames: 444/450
Time: 00:14/00:15 - Frames: 445/450 - captured
Time: 00:14/00:15 - Frames: 446/450
Time: 00:14/00:15 - Frames: 447/450
Time: 00:14/00:15 - Frames: 448/450

Now all the movement in the video is being tracked, which is not what we want. Instead, we will construct two tracking methods that will distinguish both animals in the video. mode will determine which objects are retrieved: "single" tracks the single largest objects, "multiple" tracks all objects.

[9]:
fish = pp.tracking_method(label="fish",
                          remove_shadows=True,
                          min_length=30,
                          overlay_colour="red",
                          mode="single")
isopod = pp.tracking_method(label="isopod",
                          remove_shadows=True,
                          max_length=30,
                          overlay_colour="green",
                          mode="multiple")
mt.detection_settings(methods=[fish, isopod])
-----------------------------
Detection method "fish":

{'blur_kernel': 5,
 'label': 'fish',
 'max_area': inf,
 'max_length': inf,
 'min_area': 0,
 'min_length': 30,
 'mode': 'single',
 'overlay_colour': (0, 0,
                    255),
 'remove_shadows': True,
 'threshold_value': 127}
-----------------------------


-----------------------------
Detection method "isopod":

{'blur_kernel': 5,
 'label': 'isopod',
 'max_area': inf,
 'max_length': 30,
 'min_area': 0,
 'min_length': 0,
 'mode': 'multiple',
 'overlay_colour': (0, 128,
                    0),
 'remove_shadows': True,
 'threshold_value': 127}
-----------------------------




--------------------------------------------------------------
Motion detection settings - "isopods_fish.mp4":

Background-subtractor: MOG
History: 60 seconds
Sensitivity: 10
Read every nth frame: 5
Detect shadows: True
Start after n seconds: 0
Finish after n seconds:  -
--------------------------------------------------------------
[10]:
coordinates = mt.run_tracking()
Time: 00:00/00:15 - Frames: 1/450
Time: 00:00/00:15 - Frames: 2/450
Time: 00:00/00:15 - Frames: 3/450
Time: 00:00/00:15 - Frames: 4/450
Time: 00:00/00:15 - Frames: 5/450 - captured
Time: 00:00/00:15 - Frames: 6/450
Time: 00:00/00:15 - Frames: 7/450
Time: 00:00/00:15 - Frames: 8/450
Time: 00:00/00:15 - Frames: 9/450
Time: 00:00/00:15 - Frames: 10/450 - captured
Time: 00:00/00:15 - Frames: 11/450
Time: 00:00/00:15 - Frames: 12/450
Time: 00:00/00:15 - Frames: 13/450
Time: 00:00/00:15 - Frames: 14/450
Time: 00:00/00:15 - Frames: 15/450 - captured
Time: 00:00/00:15 - Frames: 16/450
Time: 00:00/00:15 - Frames: 17/450
Time: 00:00/00:15 - Frames: 18/450
Time: 00:00/00:15 - Frames: 19/450
Time: 00:00/00:15 - Frames: 20/450 - captured
Time: 00:00/00:15 - Frames: 21/450
Time: 00:00/00:15 - Frames: 22/450
Time: 00:00/00:15 - Frames: 23/450
Time: 00:00/00:15 - Frames: 24/450
Time: 00:00/00:15 - Frames: 25/450 - captured
Time: 00:00/00:15 - Frames: 26/450
Time: 00:00/00:15 - Frames: 27/450
Time: 00:00/00:15 - Frames: 28/450
Time: 00:00/00:15 - Frames: 29/450
Time: 00:01/00:15 - Frames: 30/450 - captured
Time: 00:01/00:15 - Frames: 31/450
Time: 00:01/00:15 - Frames: 32/450
Time: 00:01/00:15 - Frames: 33/450
Time: 00:01/00:15 - Frames: 34/450
Time: 00:01/00:15 - Frames: 35/450 - captured
Time: 00:01/00:15 - Frames: 36/450
Time: 00:01/00:15 - Frames: 37/450
Time: 00:01/00:15 - Frames: 38/450
Time: 00:01/00:15 - Frames: 39/450
Time: 00:01/00:15 - Frames: 40/450 - captured
Time: 00:01/00:15 - Frames: 41/450
Time: 00:01/00:15 - Frames: 42/450
Time: 00:01/00:15 - Frames: 43/450
Time: 00:01/00:15 - Frames: 44/450
Time: 00:01/00:15 - Frames: 45/450 - captured
Time: 00:01/00:15 - Frames: 46/450
Time: 00:01/00:15 - Frames: 47/450
Time: 00:01/00:15 - Frames: 48/450
Time: 00:01/00:15 - Frames: 49/450
Time: 00:01/00:15 - Frames: 50/450 - captured
Time: 00:01/00:15 - Frames: 51/450
Time: 00:01/00:15 - Frames: 52/450
Time: 00:01/00:15 - Frames: 53/450
Time: 00:01/00:15 - Frames: 54/450
Time: 00:01/00:15 - Frames: 55/450 - captured
Time: 00:01/00:15 - Frames: 56/450
Time: 00:01/00:15 - Frames: 57/450
Time: 00:01/00:15 - Frames: 58/450
Time: 00:01/00:15 - Frames: 59/450
Time: 00:02/00:15 - Frames: 60/450 - captured
Time: 00:02/00:15 - Frames: 61/450
Time: 00:02/00:15 - Frames: 62/450
Time: 00:02/00:15 - Frames: 63/450
Time: 00:02/00:15 - Frames: 64/450
Time: 00:02/00:15 - Frames: 65/450 - captured
Time: 00:02/00:15 - Frames: 66/450
Time: 00:02/00:15 - Frames: 67/450
Time: 00:02/00:15 - Frames: 68/450
Time: 00:02/00:15 - Frames: 69/450
Time: 00:02/00:15 - Frames: 70/450 - captured
Time: 00:02/00:15 - Frames: 71/450
Time: 00:02/00:15 - Frames: 72/450
Time: 00:02/00:15 - Frames: 73/450
Time: 00:02/00:15 - Frames: 74/450
Time: 00:02/00:15 - Frames: 75/450 - captured
Time: 00:02/00:15 - Frames: 76/450
Time: 00:02/00:15 - Frames: 77/450
Time: 00:02/00:15 - Frames: 78/450
Time: 00:02/00:15 - Frames: 79/450
Time: 00:02/00:15 - Frames: 80/450 - captured
Time: 00:02/00:15 - Frames: 81/450
Time: 00:02/00:15 - Frames: 82/450
Time: 00:02/00:15 - Frames: 83/450
Time: 00:02/00:15 - Frames: 84/450
Time: 00:02/00:15 - Frames: 85/450 - captured
Time: 00:02/00:15 - Frames: 86/450
Time: 00:02/00:15 - Frames: 87/450
Time: 00:02/00:15 - Frames: 88/450
Time: 00:02/00:15 - Frames: 89/450
Time: 00:03/00:15 - Frames: 90/450 - captured
Time: 00:03/00:15 - Frames: 91/450
Time: 00:03/00:15 - Frames: 92/450
Time: 00:03/00:15 - Frames: 93/450
Time: 00:03/00:15 - Frames: 94/450
Time: 00:03/00:15 - Frames: 95/450 - captured
Time: 00:03/00:15 - Frames: 96/450
Time: 00:03/00:15 - Frames: 97/450
Time: 00:03/00:15 - Frames: 98/450
Time: 00:03/00:15 - Frames: 99/450
Time: 00:03/00:15 - Frames: 100/450 - captured
Time: 00:03/00:15 - Frames: 101/450
Time: 00:03/00:15 - Frames: 102/450
Time: 00:03/00:15 - Frames: 103/450
Time: 00:03/00:15 - Frames: 104/450
Time: 00:03/00:15 - Frames: 105/450 - captured
Time: 00:03/00:15 - Frames: 106/450
Time: 00:03/00:15 - Frames: 107/450
Time: 00:03/00:15 - Frames: 108/450
Time: 00:03/00:15 - Frames: 109/450
Time: 00:03/00:15 - Frames: 110/450 - captured
Time: 00:03/00:15 - Frames: 111/450
Time: 00:03/00:15 - Frames: 112/450
Time: 00:03/00:15 - Frames: 113/450
Time: 00:03/00:15 - Frames: 114/450
Time: 00:03/00:15 - Frames: 115/450 - captured
Time: 00:03/00:15 - Frames: 116/450
Time: 00:03/00:15 - Frames: 117/450
Time: 00:03/00:15 - Frames: 118/450
Time: 00:03/00:15 - Frames: 119/450
Time: 00:04/00:15 - Frames: 120/450 - captured
Time: 00:04/00:15 - Frames: 121/450
Time: 00:04/00:15 - Frames: 122/450
Time: 00:04/00:15 - Frames: 123/450
Time: 00:04/00:15 - Frames: 124/450
Time: 00:04/00:15 - Frames: 125/450 - captured
Time: 00:04/00:15 - Frames: 126/450
Time: 00:04/00:15 - Frames: 127/450
Time: 00:04/00:15 - Frames: 128/450
Time: 00:04/00:15 - Frames: 129/450
Time: 00:04/00:15 - Frames: 130/450 - captured
Time: 00:04/00:15 - Frames: 131/450
Time: 00:04/00:15 - Frames: 132/450
Time: 00:04/00:15 - Frames: 133/450
Time: 00:04/00:15 - Frames: 134/450
Time: 00:04/00:15 - Frames: 135/450 - captured
Time: 00:04/00:15 - Frames: 136/450
Time: 00:04/00:15 - Frames: 137/450
Time: 00:04/00:15 - Frames: 138/450
Time: 00:04/00:15 - Frames: 139/450
Time: 00:04/00:15 - Frames: 140/450 - captured
Time: 00:04/00:15 - Frames: 141/450
Time: 00:04/00:15 - Frames: 142/450
Time: 00:04/00:15 - Frames: 143/450
Time: 00:04/00:15 - Frames: 144/450
Time: 00:04/00:15 - Frames: 145/450 - captured
Time: 00:04/00:15 - Frames: 146/450
Time: 00:04/00:15 - Frames: 147/450
Time: 00:04/00:15 - Frames: 148/450
Time: 00:04/00:15 - Frames: 149/450
Time: 00:05/00:15 - Frames: 150/450 - captured
Time: 00:05/00:15 - Frames: 151/450
Time: 00:05/00:15 - Frames: 152/450
Time: 00:05/00:15 - Frames: 153/450
Time: 00:05/00:15 - Frames: 154/450
Time: 00:05/00:15 - Frames: 155/450 - captured
Time: 00:05/00:15 - Frames: 156/450
Time: 00:05/00:15 - Frames: 157/450
Time: 00:05/00:15 - Frames: 158/450
Time: 00:05/00:15 - Frames: 159/450
Time: 00:05/00:15 - Frames: 160/450 - captured
Time: 00:05/00:15 - Frames: 161/450
Time: 00:05/00:15 - Frames: 162/450
Time: 00:05/00:15 - Frames: 163/450
Time: 00:05/00:15 - Frames: 164/450
Time: 00:05/00:15 - Frames: 165/450 - captured
Time: 00:05/00:15 - Frames: 166/450
Time: 00:05/00:15 - Frames: 167/450
Time: 00:05/00:15 - Frames: 168/450
Time: 00:05/00:15 - Frames: 169/450
Time: 00:05/00:15 - Frames: 170/450 - captured
Time: 00:05/00:15 - Frames: 171/450
Time: 00:05/00:15 - Frames: 172/450
Time: 00:05/00:15 - Frames: 173/450
Time: 00:05/00:15 - Frames: 174/450
Time: 00:05/00:15 - Frames: 175/450 - captured
Time: 00:05/00:15 - Frames: 176/450
Time: 00:05/00:15 - Frames: 177/450
Time: 00:05/00:15 - Frames: 178/450
Time: 00:05/00:15 - Frames: 179/450
Time: 00:06/00:15 - Frames: 180/450 - captured
Time: 00:06/00:15 - Frames: 181/450
Time: 00:06/00:15 - Frames: 182/450
Time: 00:06/00:15 - Frames: 183/450
Time: 00:06/00:15 - Frames: 184/450
Time: 00:06/00:15 - Frames: 185/450 - captured
Time: 00:06/00:15 - Frames: 186/450
Time: 00:06/00:15 - Frames: 187/450
Time: 00:06/00:15 - Frames: 188/450
Time: 00:06/00:15 - Frames: 189/450
Time: 00:06/00:15 - Frames: 190/450 - captured
Time: 00:06/00:15 - Frames: 191/450
Time: 00:06/00:15 - Frames: 192/450
Time: 00:06/00:15 - Frames: 193/450
Time: 00:06/00:15 - Frames: 194/450
Time: 00:06/00:15 - Frames: 195/450 - captured
Time: 00:06/00:15 - Frames: 196/450
Time: 00:06/00:15 - Frames: 197/450
Time: 00:06/00:15 - Frames: 198/450
Time: 00:06/00:15 - Frames: 199/450
Time: 00:06/00:15 - Frames: 200/450 - captured
Time: 00:06/00:15 - Frames: 201/450
Time: 00:06/00:15 - Frames: 202/450
Time: 00:06/00:15 - Frames: 203/450
Time: 00:06/00:15 - Frames: 204/450
Time: 00:06/00:15 - Frames: 205/450 - captured
Time: 00:06/00:15 - Frames: 206/450
Time: 00:06/00:15 - Frames: 207/450
Time: 00:06/00:15 - Frames: 208/450
Time: 00:06/00:15 - Frames: 209/450
Time: 00:07/00:15 - Frames: 210/450 - captured
Time: 00:07/00:15 - Frames: 211/450
Time: 00:07/00:15 - Frames: 212/450
Time: 00:07/00:15 - Frames: 213/450
Time: 00:07/00:15 - Frames: 214/450
Time: 00:07/00:15 - Frames: 215/450 - captured
Time: 00:07/00:15 - Frames: 216/450
Time: 00:07/00:15 - Frames: 217/450
Time: 00:07/00:15 - Frames: 218/450
Time: 00:07/00:15 - Frames: 219/450
Time: 00:07/00:15 - Frames: 220/450 - captured
Time: 00:07/00:15 - Frames: 221/450
Time: 00:07/00:15 - Frames: 222/450
Time: 00:07/00:15 - Frames: 223/450
Time: 00:07/00:15 - Frames: 224/450
Time: 00:07/00:15 - Frames: 225/450 - captured
Time: 00:07/00:15 - Frames: 226/450
Time: 00:07/00:15 - Frames: 227/450
Time: 00:07/00:15 - Frames: 228/450
Time: 00:07/00:15 - Frames: 229/450
Time: 00:07/00:15 - Frames: 230/450 - captured
Time: 00:07/00:15 - Frames: 231/450
Time: 00:07/00:15 - Frames: 232/450
Time: 00:07/00:15 - Frames: 233/450
Time: 00:07/00:15 - Frames: 234/450
Time: 00:07/00:15 - Frames: 235/450 - captured
Time: 00:07/00:15 - Frames: 236/450
Time: 00:07/00:15 - Frames: 237/450
Time: 00:07/00:15 - Frames: 238/450
Time: 00:07/00:15 - Frames: 239/450
Time: 00:08/00:15 - Frames: 240/450 - captured
Time: 00:08/00:15 - Frames: 241/450
Time: 00:08/00:15 - Frames: 242/450
Time: 00:08/00:15 - Frames: 243/450
Time: 00:08/00:15 - Frames: 244/450
Time: 00:08/00:15 - Frames: 245/450 - captured
Time: 00:08/00:15 - Frames: 246/450
Time: 00:08/00:15 - Frames: 247/450
Time: 00:08/00:15 - Frames: 248/450
Time: 00:08/00:15 - Frames: 249/450
Time: 00:08/00:15 - Frames: 250/450 - captured
Time: 00:08/00:15 - Frames: 251/450
Time: 00:08/00:15 - Frames: 252/450
Time: 00:08/00:15 - Frames: 253/450
Time: 00:08/00:15 - Frames: 254/450
Time: 00:08/00:15 - Frames: 255/450 - captured
Time: 00:08/00:15 - Frames: 256/450
Time: 00:08/00:15 - Frames: 257/450
Time: 00:08/00:15 - Frames: 258/450
Time: 00:08/00:15 - Frames: 259/450
Time: 00:08/00:15 - Frames: 260/450 - captured
Time: 00:08/00:15 - Frames: 261/450
Time: 00:08/00:15 - Frames: 262/450
Time: 00:08/00:15 - Frames: 263/450
Time: 00:08/00:15 - Frames: 264/450
Time: 00:08/00:15 - Frames: 265/450 - captured
Time: 00:08/00:15 - Frames: 266/450
Time: 00:08/00:15 - Frames: 267/450
Time: 00:08/00:15 - Frames: 268/450
Time: 00:08/00:15 - Frames: 269/450
Time: 00:09/00:15 - Frames: 270/450 - captured
Time: 00:09/00:15 - Frames: 271/450
Time: 00:09/00:15 - Frames: 272/450
Time: 00:09/00:15 - Frames: 273/450
Time: 00:09/00:15 - Frames: 274/450
Time: 00:09/00:15 - Frames: 275/450 - captured
Time: 00:09/00:15 - Frames: 276/450
Time: 00:09/00:15 - Frames: 277/450
Time: 00:09/00:15 - Frames: 278/450
Time: 00:09/00:15 - Frames: 279/450
Time: 00:09/00:15 - Frames: 280/450 - captured
Time: 00:09/00:15 - Frames: 281/450
Time: 00:09/00:15 - Frames: 282/450
Time: 00:09/00:15 - Frames: 283/450
Time: 00:09/00:15 - Frames: 284/450
Time: 00:09/00:15 - Frames: 285/450 - captured
Time: 00:09/00:15 - Frames: 286/450
Time: 00:09/00:15 - Frames: 287/450
Time: 00:09/00:15 - Frames: 288/450
Time: 00:09/00:15 - Frames: 289/450
Time: 00:09/00:15 - Frames: 290/450 - captured
Time: 00:09/00:15 - Frames: 291/450
Time: 00:09/00:15 - Frames: 292/450
Time: 00:09/00:15 - Frames: 293/450
Time: 00:09/00:15 - Frames: 294/450
Time: 00:09/00:15 - Frames: 295/450 - captured
Time: 00:09/00:15 - Frames: 296/450
Time: 00:09/00:15 - Frames: 297/450
Time: 00:09/00:15 - Frames: 298/450
Time: 00:09/00:15 - Frames: 299/450
Time: 00:10/00:15 - Frames: 300/450 - captured
Time: 00:10/00:15 - Frames: 301/450
Time: 00:10/00:15 - Frames: 302/450
Time: 00:10/00:15 - Frames: 303/450
Time: 00:10/00:15 - Frames: 304/450
Time: 00:10/00:15 - Frames: 305/450 - captured
Time: 00:10/00:15 - Frames: 306/450
Time: 00:10/00:15 - Frames: 307/450
Time: 00:10/00:15 - Frames: 308/450
Time: 00:10/00:15 - Frames: 309/450
Time: 00:10/00:15 - Frames: 310/450 - captured
Time: 00:10/00:15 - Frames: 311/450
Time: 00:10/00:15 - Frames: 312/450
Time: 00:10/00:15 - Frames: 313/450
Time: 00:10/00:15 - Frames: 314/450
Time: 00:10/00:15 - Frames: 315/450 - captured
Time: 00:10/00:15 - Frames: 316/450
Time: 00:10/00:15 - Frames: 317/450
Time: 00:10/00:15 - Frames: 318/450
Time: 00:10/00:15 - Frames: 319/450
Time: 00:10/00:15 - Frames: 320/450 - captured
Time: 00:10/00:15 - Frames: 321/450
Time: 00:10/00:15 - Frames: 322/450
Time: 00:10/00:15 - Frames: 323/450
Time: 00:10/00:15 - Frames: 324/450
Time: 00:10/00:15 - Frames: 325/450 - captured
Time: 00:10/00:15 - Frames: 326/450
Time: 00:10/00:15 - Frames: 327/450
Time: 00:10/00:15 - Frames: 328/450
Time: 00:10/00:15 - Frames: 329/450
Time: 00:11/00:15 - Frames: 330/450 - captured
Time: 00:11/00:15 - Frames: 331/450
Time: 00:11/00:15 - Frames: 332/450
Time: 00:11/00:15 - Frames: 333/450
Time: 00:11/00:15 - Frames: 334/450
Time: 00:11/00:15 - Frames: 335/450 - captured
Time: 00:11/00:15 - Frames: 336/450
Time: 00:11/00:15 - Frames: 337/450
Time: 00:11/00:15 - Frames: 338/450
Time: 00:11/00:15 - Frames: 339/450
Time: 00:11/00:15 - Frames: 340/450 - captured
Time: 00:11/00:15 - Frames: 341/450
Time: 00:11/00:15 - Frames: 342/450
Time: 00:11/00:15 - Frames: 343/450
Time: 00:11/00:15 - Frames: 344/450
Time: 00:11/00:15 - Frames: 345/450 - captured
Time: 00:11/00:15 - Frames: 346/450
Time: 00:11/00:15 - Frames: 347/450
Time: 00:11/00:15 - Frames: 348/450
Time: 00:11/00:15 - Frames: 349/450
Time: 00:11/00:15 - Frames: 350/450 - captured
Time: 00:11/00:15 - Frames: 351/450
Time: 00:11/00:15 - Frames: 352/450
Time: 00:11/00:15 - Frames: 353/450
Time: 00:11/00:15 - Frames: 354/450
Time: 00:11/00:15 - Frames: 355/450 - captured
Time: 00:11/00:15 - Frames: 356/450
Time: 00:11/00:15 - Frames: 357/450
Time: 00:11/00:15 - Frames: 358/450
Time: 00:11/00:15 - Frames: 359/450
Time: 00:12/00:15 - Frames: 360/450 - captured
Time: 00:12/00:15 - Frames: 361/450
Time: 00:12/00:15 - Frames: 362/450
Time: 00:12/00:15 - Frames: 363/450
Time: 00:12/00:15 - Frames: 364/450
Time: 00:12/00:15 - Frames: 365/450 - captured
Time: 00:12/00:15 - Frames: 366/450
Time: 00:12/00:15 - Frames: 367/450
Time: 00:12/00:15 - Frames: 368/450
Time: 00:12/00:15 - Frames: 369/450
Time: 00:12/00:15 - Frames: 370/450 - captured
Time: 00:12/00:15 - Frames: 371/450
Time: 00:12/00:15 - Frames: 372/450
Time: 00:12/00:15 - Frames: 373/450
Time: 00:12/00:15 - Frames: 374/450
Time: 00:12/00:15 - Frames: 375/450 - captured
Time: 00:12/00:15 - Frames: 376/450
Time: 00:12/00:15 - Frames: 377/450
Time: 00:12/00:15 - Frames: 378/450
Time: 00:12/00:15 - Frames: 379/450
Time: 00:12/00:15 - Frames: 380/450 - captured
Time: 00:12/00:15 - Frames: 381/450
Time: 00:12/00:15 - Frames: 382/450
Time: 00:12/00:15 - Frames: 383/450
Time: 00:12/00:15 - Frames: 384/450
Time: 00:12/00:15 - Frames: 385/450 - captured
Time: 00:12/00:15 - Frames: 386/450
Time: 00:12/00:15 - Frames: 387/450
Time: 00:12/00:15 - Frames: 388/450
Time: 00:12/00:15 - Frames: 389/450
Time: 00:13/00:15 - Frames: 390/450 - captured
Time: 00:13/00:15 - Frames: 391/450
Time: 00:13/00:15 - Frames: 392/450
Time: 00:13/00:15 - Frames: 393/450
Time: 00:13/00:15 - Frames: 394/450
Time: 00:13/00:15 - Frames: 395/450 - captured
Time: 00:13/00:15 - Frames: 396/450
Time: 00:13/00:15 - Frames: 397/450
Time: 00:13/00:15 - Frames: 398/450
Time: 00:13/00:15 - Frames: 399/450
Time: 00:13/00:15 - Frames: 400/450 - captured
Time: 00:13/00:15 - Frames: 401/450
Time: 00:13/00:15 - Frames: 402/450
Time: 00:13/00:15 - Frames: 403/450
Time: 00:13/00:15 - Frames: 404/450
Time: 00:13/00:15 - Frames: 405/450 - captured
Time: 00:13/00:15 - Frames: 406/450
Time: 00:13/00:15 - Frames: 407/450
Time: 00:13/00:15 - Frames: 408/450
Time: 00:13/00:15 - Frames: 409/450
Time: 00:13/00:15 - Frames: 410/450 - captured
Time: 00:13/00:15 - Frames: 411/450
Time: 00:13/00:15 - Frames: 412/450
Time: 00:13/00:15 - Frames: 413/450
Time: 00:13/00:15 - Frames: 414/450
Time: 00:13/00:15 - Frames: 415/450 - captured
Time: 00:13/00:15 - Frames: 416/450
Time: 00:13/00:15 - Frames: 417/450
Time: 00:13/00:15 - Frames: 418/450
Time: 00:13/00:15 - Frames: 419/450
Time: 00:14/00:15 - Frames: 420/450 - captured
Time: 00:14/00:15 - Frames: 421/450
Time: 00:14/00:15 - Frames: 422/450
Time: 00:14/00:15 - Frames: 423/450
Time: 00:14/00:15 - Frames: 424/450
Time: 00:14/00:15 - Frames: 425/450 - captured
Time: 00:14/00:15 - Frames: 426/450
Time: 00:14/00:15 - Frames: 427/450
Time: 00:14/00:15 - Frames: 428/450
Time: 00:14/00:15 - Frames: 429/450
Time: 00:14/00:15 - Frames: 430/450 - captured
Time: 00:14/00:15 - Frames: 431/450
Time: 00:14/00:15 - Frames: 432/450
Time: 00:14/00:15 - Frames: 433/450
Time: 00:14/00:15 - Frames: 434/450
Time: 00:14/00:15 - Frames: 435/450 - captured
Time: 00:14/00:15 - Frames: 436/450
Time: 00:14/00:15 - Frames: 437/450
Time: 00:14/00:15 - Frames: 438/450
Time: 00:14/00:15 - Frames: 439/450
Time: 00:14/00:15 - Frames: 440/450 - captured
Time: 00:14/00:15 - Frames: 441/450
Time: 00:14/00:15 - Frames: 442/450
Time: 00:14/00:15 - Frames: 443/450
Time: 00:14/00:15 - Frames: 444/450
Time: 00:14/00:15 - Frames: 445/450 - captured
Time: 00:14/00:15 - Frames: 446/450
Time: 00:14/00:15 - Frames: 447/450
Time: 00:14/00:15 - Frames: 448/450

The methods work, and clearly separate out the two species. However, we can still improve a few things:

First, for each method, we can separately increase the sensitivity by using a combination of larger blur-kernels and higher threshold values.

[11]:
fish = pp.tracking_method(label="fish", remove_shadows=True, min_length=30,
                          overlay_colour="red", mode="single",
                          blur=15, threshold=200)
isopod = pp.tracking_method(label="isopod", remove_shadows=True, max_length=30,
                          overlay_colour="green", mode="multiple",
                         blur=9, threshold=180)
mt.detection_settings(methods=[fish, isopod])
-----------------------------
Detection method "fish":

{'blur_kernel': 15,
 'label': 'fish',
 'max_area': inf,
 'max_length': inf,
 'min_area': 0,
 'min_length': 30,
 'mode': 'single',
 'overlay_colour': (0, 0,
                    255),
 'remove_shadows': True,
 'threshold_value': 200}
-----------------------------


-----------------------------
Detection method "isopod":

{'blur_kernel': 9,
 'label': 'isopod',
 'max_area': inf,
 'max_length': 30,
 'min_area': 0,
 'min_length': 0,
 'mode': 'multiple',
 'overlay_colour': (0, 128,
                    0),
 'remove_shadows': True,
 'threshold_value': 180}
-----------------------------




--------------------------------------------------------------
Motion detection settings - "isopods_fish.mp4":

Background-subtractor: MOG
History: 60 seconds
Sensitivity: 10
Read every nth frame: 5
Detect shadows: True
Start after n seconds: 0
Finish after n seconds:  -
--------------------------------------------------------------

Canvas masking and consecutive masking#

Second, we also need to exclude some of the particles that are floating around outside the actual arena. We can do this with phenopype’s core create_mask method, which also accepts motion_tracker objects. The masks are automatically applied when running the tracking routine.

Canvas masking

Fig. 3: We can also specify multiple masks, one the one hand, to exclude unwanted areas, on the other hand, to see when which particle or animal stays in which area.

[12]:
masks = pp.preprocessing.create_mask(mt.image, label="full", annotation_id="a")
masks = pp.preprocessing.create_mask(mt.image, label="center", annotations=masks, annotation_id="b")

Consecutive masking needs to be activated in the detection settings (c_mask=True). This option will prohibit repeated detection of objects when several tracking methods are applied. For example, inside the detected fish-area sometimes isopod objects are detected, due to artifacts or incomplete subtraction results. Consecutive masking will “block” an area after the first method has been applied - the order by which methods are applied matters. The following settings will create a mask around the fish (which is detected first) in the shape of a rectangle + pixels around the detected contour.

[13]:
mt.detection_settings(methods=[fish, isopod],
                     c_mask=True,
                     c_mask_shape="rect",
                     c_mask_size=200,
                     masks=masks)
-----------------------------
Detection method "fish":

{'blur_kernel': 15,
 'label': 'fish',
 'max_area': inf,
 'max_length': inf,
 'min_area': 0,
 'min_length': 30,
 'mode': 'single',
 'overlay_colour': (0, 0,
                    255),
 'remove_shadows': True,
 'threshold_value': 200}
-----------------------------


-----------------------------
Detection method "isopod":

{'blur_kernel': 9,
 'label': 'isopod',
 'max_area': inf,
 'max_length': 30,
 'min_area': 0,
 'min_length': 0,
 'mode': 'multiple',
 'overlay_colour': (0, 128,
                    0),
 'remove_shadows': True,
 'threshold_value': 180}
-----------------------------




--------------------------------------------------------------
Motion detection settings - "isopods_fish.mp4":

Background-subtractor: MOG
History: 60 seconds
Sensitivity: 10
Read every nth frame: 5
Detect shadows: True
Start after n seconds: 0
Finish after n seconds:  -
--------------------------------------------------------------
[14]:
coordinates = mt.run_tracking()
Time: 00:00/00:15 - Frames: 1/450
Time: 00:00/00:15 - Frames: 2/450
Time: 00:00/00:15 - Frames: 3/450
Time: 00:00/00:15 - Frames: 4/450
Time: 00:00/00:15 - Frames: 5/450 - captured
Time: 00:00/00:15 - Frames: 6/450
Time: 00:00/00:15 - Frames: 7/450
Time: 00:00/00:15 - Frames: 8/450
Time: 00:00/00:15 - Frames: 9/450
Time: 00:00/00:15 - Frames: 10/450 - captured
Time: 00:00/00:15 - Frames: 11/450
Time: 00:00/00:15 - Frames: 12/450
Time: 00:00/00:15 - Frames: 13/450
Time: 00:00/00:15 - Frames: 14/450
Time: 00:00/00:15 - Frames: 15/450 - captured
Time: 00:00/00:15 - Frames: 16/450
Time: 00:00/00:15 - Frames: 17/450
Time: 00:00/00:15 - Frames: 18/450
Time: 00:00/00:15 - Frames: 19/450
Time: 00:00/00:15 - Frames: 20/450 - captured
Time: 00:00/00:15 - Frames: 21/450
Time: 00:00/00:15 - Frames: 22/450
Time: 00:00/00:15 - Frames: 23/450
Time: 00:00/00:15 - Frames: 24/450
Time: 00:00/00:15 - Frames: 25/450 - captured
Time: 00:00/00:15 - Frames: 26/450
Time: 00:00/00:15 - Frames: 27/450
Time: 00:00/00:15 - Frames: 28/450
Time: 00:00/00:15 - Frames: 29/450
Time: 00:01/00:15 - Frames: 30/450 - captured
Time: 00:01/00:15 - Frames: 31/450
Time: 00:01/00:15 - Frames: 32/450
Time: 00:01/00:15 - Frames: 33/450
Time: 00:01/00:15 - Frames: 34/450
Time: 00:01/00:15 - Frames: 35/450 - captured
Time: 00:01/00:15 - Frames: 36/450
Time: 00:01/00:15 - Frames: 37/450
Time: 00:01/00:15 - Frames: 38/450
Time: 00:01/00:15 - Frames: 39/450
Time: 00:01/00:15 - Frames: 40/450 - captured
Time: 00:01/00:15 - Frames: 41/450
Time: 00:01/00:15 - Frames: 42/450
Time: 00:01/00:15 - Frames: 43/450
Time: 00:01/00:15 - Frames: 44/450
Time: 00:01/00:15 - Frames: 45/450 - captured
Time: 00:01/00:15 - Frames: 46/450
Time: 00:01/00:15 - Frames: 47/450
Time: 00:01/00:15 - Frames: 48/450
Time: 00:01/00:15 - Frames: 49/450
Time: 00:01/00:15 - Frames: 50/450 - captured
Time: 00:01/00:15 - Frames: 51/450
Time: 00:01/00:15 - Frames: 52/450
Time: 00:01/00:15 - Frames: 53/450
Time: 00:01/00:15 - Frames: 54/450
Time: 00:01/00:15 - Frames: 55/450 - captured
Time: 00:01/00:15 - Frames: 56/450
Time: 00:01/00:15 - Frames: 57/450
Time: 00:01/00:15 - Frames: 58/450
Time: 00:01/00:15 - Frames: 59/450
Time: 00:02/00:15 - Frames: 60/450 - captured
Time: 00:02/00:15 - Frames: 61/450
Time: 00:02/00:15 - Frames: 62/450
Time: 00:02/00:15 - Frames: 63/450
Time: 00:02/00:15 - Frames: 64/450
Time: 00:02/00:15 - Frames: 65/450 - captured
Time: 00:02/00:15 - Frames: 66/450
Time: 00:02/00:15 - Frames: 67/450
Time: 00:02/00:15 - Frames: 68/450
Time: 00:02/00:15 - Frames: 69/450
Time: 00:02/00:15 - Frames: 70/450 - captured
Time: 00:02/00:15 - Frames: 71/450
Time: 00:02/00:15 - Frames: 72/450
Time: 00:02/00:15 - Frames: 73/450
Time: 00:02/00:15 - Frames: 74/450
Time: 00:02/00:15 - Frames: 75/450 - captured
Time: 00:02/00:15 - Frames: 76/450
Time: 00:02/00:15 - Frames: 77/450
Time: 00:02/00:15 - Frames: 78/450
Time: 00:02/00:15 - Frames: 79/450
Time: 00:02/00:15 - Frames: 80/450 - captured
Time: 00:02/00:15 - Frames: 81/450
Time: 00:02/00:15 - Frames: 82/450
Time: 00:02/00:15 - Frames: 83/450
Time: 00:02/00:15 - Frames: 84/450
Time: 00:02/00:15 - Frames: 85/450 - captured
Time: 00:02/00:15 - Frames: 86/450
Time: 00:02/00:15 - Frames: 87/450
Time: 00:02/00:15 - Frames: 88/450
Time: 00:02/00:15 - Frames: 89/450
Time: 00:03/00:15 - Frames: 90/450 - captured
Time: 00:03/00:15 - Frames: 91/450
Time: 00:03/00:15 - Frames: 92/450
Time: 00:03/00:15 - Frames: 93/450
Time: 00:03/00:15 - Frames: 94/450
Time: 00:03/00:15 - Frames: 95/450 - captured
Time: 00:03/00:15 - Frames: 96/450
Time: 00:03/00:15 - Frames: 97/450
Time: 00:03/00:15 - Frames: 98/450
Time: 00:03/00:15 - Frames: 99/450
Time: 00:03/00:15 - Frames: 100/450 - captured
Time: 00:03/00:15 - Frames: 101/450
Time: 00:03/00:15 - Frames: 102/450
Time: 00:03/00:15 - Frames: 103/450
Time: 00:03/00:15 - Frames: 104/450
Time: 00:03/00:15 - Frames: 105/450 - captured
Time: 00:03/00:15 - Frames: 106/450
Time: 00:03/00:15 - Frames: 107/450
Time: 00:03/00:15 - Frames: 108/450
Time: 00:03/00:15 - Frames: 109/450
Time: 00:03/00:15 - Frames: 110/450 - captured
Time: 00:03/00:15 - Frames: 111/450
Time: 00:03/00:15 - Frames: 112/450
Time: 00:03/00:15 - Frames: 113/450
Time: 00:03/00:15 - Frames: 114/450
Time: 00:03/00:15 - Frames: 115/450 - captured
Time: 00:03/00:15 - Frames: 116/450
Time: 00:03/00:15 - Frames: 117/450
Time: 00:03/00:15 - Frames: 118/450
Time: 00:03/00:15 - Frames: 119/450
Time: 00:04/00:15 - Frames: 120/450 - captured
Time: 00:04/00:15 - Frames: 121/450
Time: 00:04/00:15 - Frames: 122/450
Time: 00:04/00:15 - Frames: 123/450
Time: 00:04/00:15 - Frames: 124/450
Time: 00:04/00:15 - Frames: 125/450 - captured
Time: 00:04/00:15 - Frames: 126/450
Time: 00:04/00:15 - Frames: 127/450
Time: 00:04/00:15 - Frames: 128/450
Time: 00:04/00:15 - Frames: 129/450
Time: 00:04/00:15 - Frames: 130/450 - captured
Time: 00:04/00:15 - Frames: 131/450
Time: 00:04/00:15 - Frames: 132/450
Time: 00:04/00:15 - Frames: 133/450
Time: 00:04/00:15 - Frames: 134/450
Time: 00:04/00:15 - Frames: 135/450 - captured
Time: 00:04/00:15 - Frames: 136/450
Time: 00:04/00:15 - Frames: 137/450
Time: 00:04/00:15 - Frames: 138/450
Time: 00:04/00:15 - Frames: 139/450
Time: 00:04/00:15 - Frames: 140/450 - captured
Time: 00:04/00:15 - Frames: 141/450
Time: 00:04/00:15 - Frames: 142/450
Time: 00:04/00:15 - Frames: 143/450
Time: 00:04/00:15 - Frames: 144/450
Time: 00:04/00:15 - Frames: 145/450 - captured
Time: 00:04/00:15 - Frames: 146/450
Time: 00:04/00:15 - Frames: 147/450
Time: 00:04/00:15 - Frames: 148/450
Time: 00:04/00:15 - Frames: 149/450
Time: 00:05/00:15 - Frames: 150/450 - captured
Time: 00:05/00:15 - Frames: 151/450
Time: 00:05/00:15 - Frames: 152/450
Time: 00:05/00:15 - Frames: 153/450
Time: 00:05/00:15 - Frames: 154/450
Time: 00:05/00:15 - Frames: 155/450 - captured
Time: 00:05/00:15 - Frames: 156/450
Time: 00:05/00:15 - Frames: 157/450
Time: 00:05/00:15 - Frames: 158/450
Time: 00:05/00:15 - Frames: 159/450
Time: 00:05/00:15 - Frames: 160/450 - captured
Time: 00:05/00:15 - Frames: 161/450
Time: 00:05/00:15 - Frames: 162/450
Time: 00:05/00:15 - Frames: 163/450
Time: 00:05/00:15 - Frames: 164/450
Time: 00:05/00:15 - Frames: 165/450 - captured
Time: 00:05/00:15 - Frames: 166/450
Time: 00:05/00:15 - Frames: 167/450
Time: 00:05/00:15 - Frames: 168/450
Time: 00:05/00:15 - Frames: 169/450
Time: 00:05/00:15 - Frames: 170/450 - captured
Time: 00:05/00:15 - Frames: 171/450
Time: 00:05/00:15 - Frames: 172/450
Time: 00:05/00:15 - Frames: 173/450
Time: 00:05/00:15 - Frames: 174/450
Time: 00:05/00:15 - Frames: 175/450 - captured
Time: 00:05/00:15 - Frames: 176/450
Time: 00:05/00:15 - Frames: 177/450
Time: 00:05/00:15 - Frames: 178/450
Time: 00:05/00:15 - Frames: 179/450
Time: 00:06/00:15 - Frames: 180/450 - captured
Time: 00:06/00:15 - Frames: 181/450
Time: 00:06/00:15 - Frames: 182/450
Time: 00:06/00:15 - Frames: 183/450
Time: 00:06/00:15 - Frames: 184/450
Time: 00:06/00:15 - Frames: 185/450 - captured
Time: 00:06/00:15 - Frames: 186/450
Time: 00:06/00:15 - Frames: 187/450
Time: 00:06/00:15 - Frames: 188/450
Time: 00:06/00:15 - Frames: 189/450
Time: 00:06/00:15 - Frames: 190/450 - captured
Time: 00:06/00:15 - Frames: 191/450
Time: 00:06/00:15 - Frames: 192/450
Time: 00:06/00:15 - Frames: 193/450
Time: 00:06/00:15 - Frames: 194/450
Time: 00:06/00:15 - Frames: 195/450 - captured
Time: 00:06/00:15 - Frames: 196/450
Time: 00:06/00:15 - Frames: 197/450
Time: 00:06/00:15 - Frames: 198/450
Time: 00:06/00:15 - Frames: 199/450
Time: 00:06/00:15 - Frames: 200/450 - captured
Time: 00:06/00:15 - Frames: 201/450
Time: 00:06/00:15 - Frames: 202/450
Time: 00:06/00:15 - Frames: 203/450
Time: 00:06/00:15 - Frames: 204/450
Time: 00:06/00:15 - Frames: 205/450 - captured
Time: 00:06/00:15 - Frames: 206/450
Time: 00:06/00:15 - Frames: 207/450
Time: 00:06/00:15 - Frames: 208/450
Time: 00:06/00:15 - Frames: 209/450
Time: 00:07/00:15 - Frames: 210/450 - captured
Time: 00:07/00:15 - Frames: 211/450
Time: 00:07/00:15 - Frames: 212/450
Time: 00:07/00:15 - Frames: 213/450
Time: 00:07/00:15 - Frames: 214/450
Time: 00:07/00:15 - Frames: 215/450 - captured
Time: 00:07/00:15 - Frames: 216/450
Time: 00:07/00:15 - Frames: 217/450
Time: 00:07/00:15 - Frames: 218/450
Time: 00:07/00:15 - Frames: 219/450
Time: 00:07/00:15 - Frames: 220/450 - captured
Time: 00:07/00:15 - Frames: 221/450
Time: 00:07/00:15 - Frames: 222/450
Time: 00:07/00:15 - Frames: 223/450
Time: 00:07/00:15 - Frames: 224/450
Time: 00:07/00:15 - Frames: 225/450 - captured
Time: 00:07/00:15 - Frames: 226/450
Time: 00:07/00:15 - Frames: 227/450
Time: 00:07/00:15 - Frames: 228/450
Time: 00:07/00:15 - Frames: 229/450
Time: 00:07/00:15 - Frames: 230/450 - captured
Time: 00:07/00:15 - Frames: 231/450
Time: 00:07/00:15 - Frames: 232/450
Time: 00:07/00:15 - Frames: 233/450
Time: 00:07/00:15 - Frames: 234/450
Time: 00:07/00:15 - Frames: 235/450 - captured
Time: 00:07/00:15 - Frames: 236/450
Time: 00:07/00:15 - Frames: 237/450
Time: 00:07/00:15 - Frames: 238/450
Time: 00:07/00:15 - Frames: 239/450
Time: 00:08/00:15 - Frames: 240/450 - captured
Time: 00:08/00:15 - Frames: 241/450
Time: 00:08/00:15 - Frames: 242/450
Time: 00:08/00:15 - Frames: 243/450
Time: 00:08/00:15 - Frames: 244/450
Time: 00:08/00:15 - Frames: 245/450 - captured
Time: 00:08/00:15 - Frames: 246/450
Time: 00:08/00:15 - Frames: 247/450
Time: 00:08/00:15 - Frames: 248/450
Time: 00:08/00:15 - Frames: 249/450
Time: 00:08/00:15 - Frames: 250/450 - captured
Time: 00:08/00:15 - Frames: 251/450
Time: 00:08/00:15 - Frames: 252/450
Time: 00:08/00:15 - Frames: 253/450
Time: 00:08/00:15 - Frames: 254/450
Time: 00:08/00:15 - Frames: 255/450 - captured
Time: 00:08/00:15 - Frames: 256/450
Time: 00:08/00:15 - Frames: 257/450
Time: 00:08/00:15 - Frames: 258/450
Time: 00:08/00:15 - Frames: 259/450
Time: 00:08/00:15 - Frames: 260/450 - captured
Time: 00:08/00:15 - Frames: 261/450
Time: 00:08/00:15 - Frames: 262/450
Time: 00:08/00:15 - Frames: 263/450
Time: 00:08/00:15 - Frames: 264/450
Time: 00:08/00:15 - Frames: 265/450 - captured
Time: 00:08/00:15 - Frames: 266/450
Time: 00:08/00:15 - Frames: 267/450
Time: 00:08/00:15 - Frames: 268/450
Time: 00:08/00:15 - Frames: 269/450
Time: 00:09/00:15 - Frames: 270/450 - captured
Time: 00:09/00:15 - Frames: 271/450
Time: 00:09/00:15 - Frames: 272/450
Time: 00:09/00:15 - Frames: 273/450
Time: 00:09/00:15 - Frames: 274/450
Time: 00:09/00:15 - Frames: 275/450 - captured
Time: 00:09/00:15 - Frames: 276/450
Time: 00:09/00:15 - Frames: 277/450
Time: 00:09/00:15 - Frames: 278/450
Time: 00:09/00:15 - Frames: 279/450
Time: 00:09/00:15 - Frames: 280/450 - captured
Time: 00:09/00:15 - Frames: 281/450
Time: 00:09/00:15 - Frames: 282/450
Time: 00:09/00:15 - Frames: 283/450
Time: 00:09/00:15 - Frames: 284/450
Time: 00:09/00:15 - Frames: 285/450 - captured
Time: 00:09/00:15 - Frames: 286/450
Time: 00:09/00:15 - Frames: 287/450
Time: 00:09/00:15 - Frames: 288/450
Time: 00:09/00:15 - Frames: 289/450
Time: 00:09/00:15 - Frames: 290/450 - captured
Time: 00:09/00:15 - Frames: 291/450
Time: 00:09/00:15 - Frames: 292/450
Time: 00:09/00:15 - Frames: 293/450
Time: 00:09/00:15 - Frames: 294/450
Time: 00:09/00:15 - Frames: 295/450 - captured
Time: 00:09/00:15 - Frames: 296/450
Time: 00:09/00:15 - Frames: 297/450
Time: 00:09/00:15 - Frames: 298/450
Time: 00:09/00:15 - Frames: 299/450
Time: 00:10/00:15 - Frames: 300/450 - captured
Time: 00:10/00:15 - Frames: 301/450
Time: 00:10/00:15 - Frames: 302/450
Time: 00:10/00:15 - Frames: 303/450
Time: 00:10/00:15 - Frames: 304/450
Time: 00:10/00:15 - Frames: 305/450 - captured
Time: 00:10/00:15 - Frames: 306/450
Time: 00:10/00:15 - Frames: 307/450
Time: 00:10/00:15 - Frames: 308/450
Time: 00:10/00:15 - Frames: 309/450
Time: 00:10/00:15 - Frames: 310/450 - captured
Time: 00:10/00:15 - Frames: 311/450
Time: 00:10/00:15 - Frames: 312/450
Time: 00:10/00:15 - Frames: 313/450
Time: 00:10/00:15 - Frames: 314/450
Time: 00:10/00:15 - Frames: 315/450 - captured
Time: 00:10/00:15 - Frames: 316/450
Time: 00:10/00:15 - Frames: 317/450
Time: 00:10/00:15 - Frames: 318/450
Time: 00:10/00:15 - Frames: 319/450
Time: 00:10/00:15 - Frames: 320/450 - captured
Time: 00:10/00:15 - Frames: 321/450
Time: 00:10/00:15 - Frames: 322/450
Time: 00:10/00:15 - Frames: 323/450
Time: 00:10/00:15 - Frames: 324/450
Time: 00:10/00:15 - Frames: 325/450 - captured
Time: 00:10/00:15 - Frames: 326/450
Time: 00:10/00:15 - Frames: 327/450
Time: 00:10/00:15 - Frames: 328/450
Time: 00:10/00:15 - Frames: 329/450
Time: 00:11/00:15 - Frames: 330/450 - captured
Time: 00:11/00:15 - Frames: 331/450
Time: 00:11/00:15 - Frames: 332/450
Time: 00:11/00:15 - Frames: 333/450
Time: 00:11/00:15 - Frames: 334/450
Time: 00:11/00:15 - Frames: 335/450 - captured
Time: 00:11/00:15 - Frames: 336/450
Time: 00:11/00:15 - Frames: 337/450
Time: 00:11/00:15 - Frames: 338/450
Time: 00:11/00:15 - Frames: 339/450
Time: 00:11/00:15 - Frames: 340/450 - captured
Time: 00:11/00:15 - Frames: 341/450
Time: 00:11/00:15 - Frames: 342/450
Time: 00:11/00:15 - Frames: 343/450
Time: 00:11/00:15 - Frames: 344/450
Time: 00:11/00:15 - Frames: 345/450 - captured
Time: 00:11/00:15 - Frames: 346/450
Time: 00:11/00:15 - Frames: 347/450
Time: 00:11/00:15 - Frames: 348/450
Time: 00:11/00:15 - Frames: 349/450
Time: 00:11/00:15 - Frames: 350/450 - captured
Time: 00:11/00:15 - Frames: 351/450
Time: 00:11/00:15 - Frames: 352/450
Time: 00:11/00:15 - Frames: 353/450
Time: 00:11/00:15 - Frames: 354/450
Time: 00:11/00:15 - Frames: 355/450 - captured
Time: 00:11/00:15 - Frames: 356/450
Time: 00:11/00:15 - Frames: 357/450
Time: 00:11/00:15 - Frames: 358/450
Time: 00:11/00:15 - Frames: 359/450
Time: 00:12/00:15 - Frames: 360/450 - captured
Time: 00:12/00:15 - Frames: 361/450
Time: 00:12/00:15 - Frames: 362/450
Time: 00:12/00:15 - Frames: 363/450
Time: 00:12/00:15 - Frames: 364/450
Time: 00:12/00:15 - Frames: 365/450 - captured
Time: 00:12/00:15 - Frames: 366/450
Time: 00:12/00:15 - Frames: 367/450
Time: 00:12/00:15 - Frames: 368/450
Time: 00:12/00:15 - Frames: 369/450
Time: 00:12/00:15 - Frames: 370/450 - captured
Time: 00:12/00:15 - Frames: 371/450
Time: 00:12/00:15 - Frames: 372/450
Time: 00:12/00:15 - Frames: 373/450
Time: 00:12/00:15 - Frames: 374/450
Time: 00:12/00:15 - Frames: 375/450 - captured
Time: 00:12/00:15 - Frames: 376/450
Time: 00:12/00:15 - Frames: 377/450
Time: 00:12/00:15 - Frames: 378/450
Time: 00:12/00:15 - Frames: 379/450
Time: 00:12/00:15 - Frames: 380/450 - captured
Time: 00:12/00:15 - Frames: 381/450
Time: 00:12/00:15 - Frames: 382/450
Time: 00:12/00:15 - Frames: 383/450
Time: 00:12/00:15 - Frames: 384/450
Time: 00:12/00:15 - Frames: 385/450 - captured
Time: 00:12/00:15 - Frames: 386/450
Time: 00:12/00:15 - Frames: 387/450
Time: 00:12/00:15 - Frames: 388/450
Time: 00:12/00:15 - Frames: 389/450
Time: 00:13/00:15 - Frames: 390/450 - captured
Time: 00:13/00:15 - Frames: 391/450
Time: 00:13/00:15 - Frames: 392/450
Time: 00:13/00:15 - Frames: 393/450
Time: 00:13/00:15 - Frames: 394/450
Time: 00:13/00:15 - Frames: 395/450 - captured
Time: 00:13/00:15 - Frames: 396/450
Time: 00:13/00:15 - Frames: 397/450
Time: 00:13/00:15 - Frames: 398/450
Time: 00:13/00:15 - Frames: 399/450
Time: 00:13/00:15 - Frames: 400/450 - captured
Time: 00:13/00:15 - Frames: 401/450
Time: 00:13/00:15 - Frames: 402/450
Time: 00:13/00:15 - Frames: 403/450
Time: 00:13/00:15 - Frames: 404/450
Time: 00:13/00:15 - Frames: 405/450 - captured
Time: 00:13/00:15 - Frames: 406/450
Time: 00:13/00:15 - Frames: 407/450
Time: 00:13/00:15 - Frames: 408/450
Time: 00:13/00:15 - Frames: 409/450
Time: 00:13/00:15 - Frames: 410/450 - captured
Time: 00:13/00:15 - Frames: 411/450
Time: 00:13/00:15 - Frames: 412/450
Time: 00:13/00:15 - Frames: 413/450
Time: 00:13/00:15 - Frames: 414/450
Time: 00:13/00:15 - Frames: 415/450 - captured
Time: 00:13/00:15 - Frames: 416/450
Time: 00:13/00:15 - Frames: 417/450
Time: 00:13/00:15 - Frames: 418/450
Time: 00:13/00:15 - Frames: 419/450
Time: 00:14/00:15 - Frames: 420/450 - captured
Time: 00:14/00:15 - Frames: 421/450
Time: 00:14/00:15 - Frames: 422/450
Time: 00:14/00:15 - Frames: 423/450
Time: 00:14/00:15 - Frames: 424/450
Time: 00:14/00:15 - Frames: 425/450 - captured
Time: 00:14/00:15 - Frames: 426/450
Time: 00:14/00:15 - Frames: 427/450
Time: 00:14/00:15 - Frames: 428/450
Time: 00:14/00:15 - Frames: 429/450
Time: 00:14/00:15 - Frames: 430/450 - captured
Time: 00:14/00:15 - Frames: 431/450
Time: 00:14/00:15 - Frames: 432/450
Time: 00:14/00:15 - Frames: 433/450
Time: 00:14/00:15 - Frames: 434/450
Time: 00:14/00:15 - Frames: 435/450 - captured
Time: 00:14/00:15 - Frames: 436/450
Time: 00:14/00:15 - Frames: 437/450
Time: 00:14/00:15 - Frames: 438/450
Time: 00:14/00:15 - Frames: 439/450
Time: 00:14/00:15 - Frames: 440/450 - captured
Time: 00:14/00:15 - Frames: 441/450
Time: 00:14/00:15 - Frames: 442/450
Time: 00:14/00:15 - Frames: 443/450
Time: 00:14/00:15 - Frames: 444/450
Time: 00:14/00:15 - Frames: 445/450 - captured
Time: 00:14/00:15 - Frames: 446/450
Time: 00:14/00:15 - Frames: 447/450
Time: 00:14/00:15 - Frames: 448/450

You probably noticed that the objects outside the masks were still detected and drawn onto the overlay - that is BY DESIGN: if you check the coordinates files you will see that every object will now have a boolean variable that will indicate whether its center of mass wass inside the mask. For example, center = True and full = True indicates that an object was in the center of the arena, which means that it also has to be in the full arena. On the other hand, center = False and full = False indicates that the object isn’t inside any of the specified masks, and you may chose to filter this row out during data analysis.

[15]:
coordinates[50:60]
[15]:
frame_abs frame mins secs x y label full center
50 110 22 00 03 263.0 65.0 isopod True False
51 115 23 00 03 540.0 309.0 fish True True
52 115 23 00 03 309.0 310.0 isopod True False
53 115 23 00 03 193.0 225.0 isopod True False
54 115 23 00 03 192.0 156.0 isopod True False
55 115 23 00 03 783.0 0.0 isopod False False
56 120 24 00 04 535.0 314.0 fish True True
57 120 24 00 04 194.0 227.0 isopod True False
58 120 24 00 04 191.0 156.0 isopod True False
59 125 25 00 04 512.0 314.0 fish True True

If we are happy with the tracking results, we can save and analyze them in Python, R, or elsewhere. Then next step would be to assign particles to a trajectory, so we can investigate the behavior of isopods in the presence of fish. An efficient option in Python is the trackpy library, which is good at filtering and calculating trajectories (for an applied example check the phenopype gallery: https://www.phenopype.org/gallery/example_4).

[16]:
coordinates.to_csv(os.path.join(out_dir, mt.name + "coordinates.csv"), sep=',', index=False)
coordinates
[16]:
frame_abs frame mins secs x y label full center
0 30 6 00 01 608.0 345.0 isopod True True
1 30 6 00 01 546.0 249.0 isopod True True
2 35 7 00 01 575.0 306.0 isopod True True
3 45 9 00 01 843.0 315.0 isopod False False
4 45 9 00 01 193.0 305.0 isopod True False
... ... ... ... ... ... ... ... ... ...
558 445 89 00 14 544.0 191.0 isopod True True
559 445 89 00 14 189.0 127.0 isopod False False
560 445 89 00 14 208.0 129.0 isopod True False
561 445 89 00 14 748.0 111.0 isopod True False
562 445 89 00 14 106.0 88.0 isopod False False

563 rows × 9 columns

[ ]: