Skip to main content

· 3 min read
Benjamin Gallois

What is YOLO

YOLO (You Only Look Once) is a real-time object detection algorithm using deep learning. It divides the image into a grid. Each cell of this grid is then responsible for detecting objects within itself. YOLO is well known and used because it is relatively fast and accurate. In this proof of concept, we will use YOLOv5, a family of YOLO object detection architecture pre-trained on the COCO dataset.

Why is it interesting for FastTrack

FastTrack is currently limited to tracking objects in quasi-2-D on very contrasted images with an immobile camera. The software is well adapted for large datasets or datasets with poor quality achieving good accuracy with blazing fast speed. But for users with very detailed datasets, strong 3-D movements, a moving point of view, different types of objects, or complex scenery, FastTrack is limited. Adding a YOLO detector with a pre-or custom-trained model can help these users. They will be able to benefit from a state-of-the-art deep learning detector with the ease and intuitive environment of FastTrack.


To demonstrate the feasibility of using YOLO as a detector for FastTrack, we take a video of running kittens that will first preprocess using YOLOv5 (PyTorch for Python). The resulting video will be tracked using FastTrack GUI.

This video presents quite a challenge to track with 3-D motion, motion blur, occlusions, object deformation, and light kittens on a light background.

The video is processed using YOLOv5x detector pre-trained on the COCO dataset. For each kitten detected, we draw the minimal enclosing image containing the kitten in a white background image. We then repeat the process for all the detected kittens for all the images. This preprocessing simulates what could be done if YOLO was integrated directly inside FastTrack. The direct integration would be much more accurate as each detected object will be processed separately, avoiding object overlap. These images are then tracked using FastTrack, following the standard process.


The implementation of the YOLO detector is relatively straightforward. Currently, the detection is performed using a threshold and then finding the objects in the resulting binary image. The YOLO detection step can be implemented as a class using C++/OpenCV and will return for each image a binary version with the detected objects that will be fed to the FastTrack feature detector. Implementing the YOLO detector will require modifying the GUI by adding a new tab allowing the user to select the specific COCO classes and the detector architecture version. The same modifications will have to be reflected for the CLI with the addition of several command line parameters. Deployment should not cause any problem because the YOLO model files can be deployed with the binary of FastTrack.


Integrating the YOLO detector inside FastTrack will require some work and testing to have the stability to be made into a stable version for any computer OS. The implementation will be split into several chunks and implemented bit by bit because I have to fit it in between paid contracts, as I can't be on it full time. To speed up the implementation, you can support the project at

· 3 min read
Benjamin Gallois

The first round of coding for FastAnalyzer is now over. The first alpha version is distributed as a binary for Windows, Linux, and macOS. The public alpha is restricted to 30 minutes of usage, and can be downloaded at with a test dataset. To access the private alpha with unlimited time, behind the scene coding and direct feedback, become a Supporter. In this first cycle, we implemented several essential features that we will detail below.

Project state


FastAnalyzer interface is an MDI. This interface allows us to see and compare several plots in one glance. That means that each new plot is a unique window inside the interface. Windows can be displayed as tabs or in separate windows (they can be tiled or cascaded). Changes in the data are directly visible in every plot window. alt text

Data loading

Tracking data from FastTrack (.db and .txt) can be loaded in FastAnalyzer. Once loaded, modified tracking data and plots can be saved as a "workspace" saved and can be reloaded next time. It allows the user to switch seamlessly between several analyses.

Data modification

Tracking data can be modified using the Calc window. New columns can be created using columns operation. for example, new = xHead**2 will create a new column named new. Regular Pandas operations are supported like sqrt(), diff(), etc. It is also possible to apply a scale to the tracking data to convert pixels and images in meters and seconds. alt text

Data plotting

Plotting data is the main feature implemented in FastAnalyzer. It supports univariate and bivariate distributions (kdeplot, displot, histplot), and descriptive plot (boxplot, violinplot, boxenplot, swarmplot). Simple features like title, labels, and label size are directly modifiable in the interface. For more advanced users, it is possible to write in the interface a Python dictionary that will be passed in the plot function to call directly advanced features. For example, changing the color palette can be done by writing {"palette": "pastel"} in the lowLevelApi field. alt text

Data statistical significance

P-values calculation using several standard tests are implemented. Choose the test, write the pair where you want to test, for example, (0,1), (0,2), and FastAnalyzer will directly draw the result on the plot and the detail of the test in the interface. alt text


The first round of development of FastAnalyzer already offers a software that can produce standard academic plots with statistical significance tests, adjustable titles, and labels. After some first feedback from users, the second round of development will tackle the software performance and robustness with the development of a test suite.

· One min read
Benjamin Gallois

Tracking objects from video recording is generally only the first step of any scientific analysis. The second task, the trajectory analysis, can be quite daunting. Numerous tools are available, from scripting languages to complete user interface environments that require various learning curves.

FastTrack allows an easy and fast tracking from any video recording. To make the trajectory analysis as fast and easy as possible, we started the development of FastAnalyzer. FastAnalyzer is built on top of the Python scientific ecosystem (SciPy, NumPy, Matplotlib and Seaborn) and of the existing FastAnalysis library.

The goal is to integrate the power and versatility of the Python ecosystem in an intuitive user interface tailored to process result file from FastTrack.

The road map to version alpha is as follows:

  1. Interface design
  2. Basic plot capability
  3. Session managment to save and recover plots
  4. Master plot theming
  5. Statistical analysis

You can see below preview of the software in the current state of development.

· 2 min read
Benjamin Gallois

As mentioned in previous posts, FastTrack on Windows is slow compared to the Linux and macOS versions. Since version 6.2.5, the tracking speed dramatically improved on Windows.


One user reported a bug involving a memory leak on Windows for a specific video format. We investigated this bug and were able to find that it came from the OpenCL library. OpenCL was unable to share a buffer leading to multiple deep copies of images and ultimately a RAM overload. This bug was restricted to the tracking class and reproducible only with a specific video. A hotfix was deployed by deactivating OpenCL.
As usual, we run the performance benchmark and no changes were seen... except for Windows (see graph). Surprisingly, deactivating OpenCL increases tracking performance by 52% on Windows.


"OpenCL (Open Computing Language) is a framework for writing programs that execute across heterogeneous platforms" CPUs, GPUs, DSPs, and FPGAs. OpenCV uses OpenCL by the mean of the transparent API that adds hardware acceleration with a minimal change in the code (use UMat instead of Mat to store images). Using hardware acceleration can increase performance when expensive operations are applied to the image, otherwise, the overhead time to moving the data to the GPU dominate.
There is numerous posts (1,2) on the internet that talk about performance issues with OpenCL. Only one thing is certain, deactivating OpenCL in FastTrack leads to consistent performance across platforms.

· 3 min read
Benjamin Gallois

In this post, we will use Hyperfine to compare the performance of several versions of FastTrack to see how FastTrack performance has improved or degraded over time.


We will automate the benchmark with a python script that will:

  1. Select the FastTrack version.
  2. Compile FastTrack.
  3. Run hyperfine.
  1 import os
3 def compile(versions, cmd):
4 for i in versions:
5 os.system("make distclean -s")
6 os.system("git checkout -f v{}".format(i))
7 if i[0] == "6": # Choose qt version
8 os.system("qmake6 CONFIG+=release src/")
9 elif i[0] == "5":
10 os.system("qmake CONFIG+=release src/")
11 os.system("make")
12 os.system("make clean")
13 os.system("mv build_cli {}".format(i))
14 cmd += "\'{}/fasttrack-cli --path test/dataSet/images/frame_000001.pgm --cfg test/dataSet/images/Groundtruth/Tracking_Result/cfg.toml\' ".format(i)
14 return cmd
16 versions = ["6.2.4", "6.2.3", "6.2.1", "6.2.0", "6.1.2", "6.0.0", "5.3.5", "5.2.3"]
17 cmd = compile(versions, "hyperfine -w 20 -m 100 ")
18 os.system("git checkout -f master")
19 os.system(cmd + "--export-markdown")


The results of the benchmark are displayed in the graph below with horizontally the version of FastTrack (left is the more recent), and vertically the mean time to perform 50 tracking analyses of the test dataset (less time is better). We can see two interesting breakpoints of performance.

The fastest version is by far the 6.2.4 (latest at the time of writing). This is due to the optimized rewriting of a core function of the tracking. This function computes the object's direction and is used ~nObject*nImage times. A slight gain can greatly impact the overall performance.

We see a degradation of performance between versions 6.0.0 and 6.1.2. This degradation was introduced when FastTrack started to use the SQLite database as a backend. In version 6.0.0 and prior, tracking data were directly saved as a plain text file. This was fine for the tracking but loading the data for reviewing was consuming a lot of RAM and was very slow. Version 6.1.0 and later introduced an SQLite database to store the tracking data but still keep the plain text file for compatibility. This development choice increased performance for the tracking review but slightly degraded the tracking time. Inserting data in the database is faster but generating and writing the text file needed to keep the compatibility introduces a small time overhead degrading the tracking performance. Overall, tracking plus reviewing was faster.

Less significantly, we see a slight increase in performance between versions 6.1.2 and 6.2.3 caused by small optimizations in the code. We see also that migrating from Qt5 (FastTrack 5.3.5 and prior) to Qt6 (FastTrack 5.3.5 and later) doesn't change the performance.


A tracking analysis is the repetition of a few functions on a lot of images. Marginal gains on these functions can cumulate to a large increase in tracking speed. We work to increase the overall performance with each release of FastTrack and there is still gain to be found.

· 2 min read
Benjamin Gallois

Since version 6.2.0, FastTrack has been compilated using MinGW_w64 instead of MSVC2019. MinGW_w64 is a fork of the MinGW project that provides the GCC compiler for Windows. With a "better-conforming and faster math support compared to VisualStudio's" and a pthreads library, this compiler yields better performance for the OpenCV library and thus for FastTrack.

Compiling FastTrack using MinGW_w64 provides several improvements. First, it provides the getopt.h header necessary to the FastTrack-Cli. From version 6.2.0, the command line interface of FastTrack is available natively on Windows. Secondly, OpenCV compiled using MinGW_w64 is more performant than with MSVC and Qt seems more responsive. Finally, the bundle (executable plus DLLs) is lighter than its MSVC counterpart (42,7 MB vs 62.8 MB).

Compiling FastTrack using MinGW_w64 comes with some challenges. The main dependency of FastTrack is OpenCV and it does not provide pre-built binaries for MinGW_w64, therefore, we need to compile OpenCV from sources. This compilation is done one time in this GitHub repository and files are downloaded at compile time to save processing energy. Conveniently, Qt provides pre-built binaries and the whole MinGW_w64 toolchains in its archives. Installing Qt and MinWG_w64 can be done very easily without external sources. The windeployqt Qt tool takes care of the DLLs (Qt and MinGW_x64) needed at runtime and the resulting bundle is very light. MinGW_w64 version of Qt does not provide the QtWebEngine, thus, the in software documentation is not available anymore.

To conclude, MinGW_w64 version of FastTrack has better performance, a lighter footprint with only one drawback: recompile OpenCV when newer versions will be available. For developers, the environment is easier to set up with only three commands necessary.

· 4 min read
Benjamin Gallois
Copyright (C)  FastTrack.
Permission is granted to copy, distribute and/or modify this document. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

FastTrack performance comparison between Linux and Windows

FastTrack is a multi-platform application available for Linux, macOS, and Windows. In this post, we will compare the performance of the Linux and Windows versions. We will see that the performance depends a lot on how OpenCV was built and how to build it for performance.

The setup

The benchmark will be performed using FastTrack version 6.1.1 on a computer with an Intel(R) Core(TM) i7-8565U and 16Go of RAM.
The Linux version was compiled using the GCC compiler with the default release flag of Qt. We used two Windows compilers: MSVC 2019 used for the FastTrack stable release, and MinGW_64 (GCC for Windows. MinGW_64 is not used for binary releases because it lacks the QtWebEngine package but a lighter version of FastTrack can be compiled using the NO_WEB compilation flag). We use OpenCV 4.5.5 and Qt 6.2.2 to perform the benchmark. We chose the test dataset of FastTrack ZFJ_001 with the parameters included with it and the PAR_001 from the two-dimensional dataset.


The results of the benchmark are displayed in Figure.1 for ZFJ_001 and Figure.2 for PAR_001. We see that the tracking is significantly slower on Windows than on Linux and that the MinGW_64 compiler yield better performance than MSVC2019.

alt text
Figure 1. Benchmark for ZFJ_001.
alt text
Figure 2. Benchmark for PAR_001.

These results can be explained by several factors. First, compiler optimizations are not the same and it seems that out-of-the-box Qt and OpenCV are generally faster with GCC. Another point is that FastTrack writes heavily on the disk using both the SQLite database and plain text files. I/O performance varies widely depending on operating system and hardware and is generally better on Linux.

In our case, we can pinpoint a large part of the performance difference to the core operations of the tracking (object detection and ellipse computation) powered by OpenCV that are significantly slower on Windows.

What we can do

Performance can be improved by tweaking compiler optimization flags and compiling OpenCV using system-specific optimizations if available.

Figure.3 presents the performance for the pre-built OpenCV library and the optimized version compiled with MSVC2019. Optimized OpenCV was compiled with TBB, OpenMP, and IPP enabled and is 1.7 times faster than the pre-built version but still 1.6 times slower than the Linux version.

alt text
Figure 3. Pre-built vs omptimized OpenCV library (PAR_001).

On Linux, OpenCV is compilated as packaged by the Linux distribution. For example, ArchLinux and Ubuntu are not packaged with the same flags enabled and there is still room for performance improvement. In Figure.4, we compare the performance of the AppImage packaged on Ubuntu with the ArchLinux version available on AUR. We see that the native package is slightly faster than the AppImage but still performing very well.

alt text
Figure 4. AppImage vs Arch Linux package from AUR (PAR_001).

Final words

Pre-built binaries of FastTrack will most likely perform better on Linux than on Windows for equivalent hardware. Most Linux distributions will provide a pre-built OpenCV library well optimized whereas FastTrack for Windows is built against the pre-built OpenCV library for MSVC. A custom compilation of OpenCV and FastTrack with platform-specific optimizations will provide maximum performance in any case.
Ultimately, switching to MinGW_64 will be the only way to start to fill the performance gap on Windows. In the next post, we will see how to compile OpenCV and (light) FastTrack with MinGW_64 and if it is possible to have performance as best as the standard Linux version.


OpenCV compilation flags

· 2 min read
Benjamin Gallois
Copyright (C)  FastTrack.
Permission is granted to copy, distribute and/or modify this document.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Case study #1

Objective: track multiple D. Melanogaster and determine the time spent in the upper area of the experimental apparatus. Dataset:

Import the data

import fastanalysis as fa
import seaborn as sns
import numpy as np
import matplotlib as mpl"fivethirtyeight")
import warnings
data = fa.Load("tracking.txt")

Explore the tracking data

# Distribution of vertical positions for all the objects
p0 = sns.histplot(data=data.getDataframe(), x="yBody", kde=True);
p0.set_xlabel("Vertical position");


# Distribution of vertical positions for each individual
p1 = sns.displot(data=data.getDataframe(), x="yBody", hue="id", kind="kde");"Vertical position");


p2 = sns.boxplot(data=data.getDataframe(), x="id", y="yBody");
p2.set_ylabel("Vertical position");


Compute the preference

# For each individual computes a preference index
pi = []
for i in range(data.getObjectNumber()):
dat = data.getObjects(i)
dat.loc[:, "diffTime"] = dat.imageNumber.diff().values
up = dat[dat.yBody > 100]
down = dat[dat.yBody <= 100]
pi.append((up.diffTime.sum() - down.diffTime.sum())/(up.diffTime.sum() + down.diffTime.sum()))
p3 = sns.boxplot(y=pi)
p3.set_ylim(-1, 1)
p3.set_ylabel("Preference index");
p3.set_title("Objects preference to the upper side");


p4 = sns.kdeplot(data=data.getDataframe(), x=np.random.normal(size=data.getDataframe().values.shape[0]), y="yBody", fill=True);
p4.set_xlabel("Horizontal position randomized");
p4.set_ylabel("Vertical position");
p4.set_title("Distribution of presence");


pi = []
for i in range(data.getObjectNumber()):
dat = data.getObjects(i)
dat.loc[:, "diffTime"] = dat.imageNumber.diff().values
pref = []
for l, __ in enumerate(dat.yBody.values):
up = dat[0:l][dat[0:l].yBody.values > 100]
down = dat[0:l][dat[0:l].yBody.values <= 100]
pref.append((up.diffTime.sum() - down.diffTime.sum())/(up.diffTime.sum() + down.diffTime.sum()))
for i, j in enumerate(pi):
p5= sns.lineplot(x=np.arange(len(j)), y=j, label=str(i))
p5.set_xlabel("Time (images)");
p5.set_ylabel("Preference index");
p5.set_title("Preference index function of time");
p5.legend(title="id", bbox_to_anchor=(1.05, 1));


· 11 min read
Benjamin Gallois
Copyright (C)  FastTrack.
Permission is granted to copy, distribute and/or modify this document.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Get started with FastAnalysis

FastAnalysis is a python library that simplifies the importation of a tracking analysis performed with FastTrack. Easily select data for a given object or a given timepoint.

Package installation

The FastAnalysis package can be installed following the provided instruction at

import sys
!{sys.executable} -m pip install fastanalysis

Package usage

import fastanalysis as fa

Load the tracking data and get the basic information.

data = fa.Load("tracking.txt")
print("Total objects: ", data.getObjectNumber())
Total objects:  14
print("Keys: ", data.getKeys())
Keys:  ['xHead', 'yHead', 'tHead', 'xTail', 'yTail', 'tTail', 'xBody', 'yBody', 'tBody', 'curvature', 'areaBody', 'perimeterBody', 'headMajorAxisLength', 'headMinorAxisLength', 'headExcentricity', 'tailMajorAxisLength', 'tailMinorAxisLength', 'tailExcentricity', 'bodyMajorAxisLength', 'bodyMinorAxisLength', 'bodyExcentricity', 'imageNumber', 'id']

Select the tracking data for a given object


190 rows × 23 columns

Select the tracking data for a list of objects

data.getObjects([0, 2, 4])

544 rows × 23 columns

Select the tracking data for a given image


12 rows × 23 columns

Select the tracking data for a list of images

data.getFrames([100, 102])

26 rows × 23 columns

Select the tracking data for a list of images and a list of objects

data.getObjectsInFrames(ids=[0,2,4], indexes=[100,102])

6 rows × 23 columns

Check if a list of objects is in a frame

data.isObjectsInFrame(ids=[0,2,4], index=100)
[True, True, True]

Basic plotting

  • Plot the velocity distribution for given objects
import matplotlib.pyplot as plt
%matplotlib inline

plotObj = fa.Plot(data)
plotObj.velocityDistribution(ids=[0, 1], key="Body", pooled=False, subplots=True);


plotObj.velocityDistribution(ids=[0, 1], key="Body", pooled=False, subplots=False);


plotObj.velocityDistribution(ids=[0, 1], key="Body", pooled=True);


Using seaborn on extracted data

  • Plot the distribution of positions.
import seaborn as sns

data_object_0 = data.getObjects(0)
sns.jointplot(data=data_object_0, x="xBody", y="yBody");


# All objects pooled
sns.kdeplot(data=data.getObjects(list(range(data.getObjectNumber()))), x="xBody", y="yBody", shade=True);


  • Compare the distributions of displacements.
tmp = data.getObjects([0,2,4])
tmp["displacement"] = (tmp["xBody"]**2 + tmp["yBody"]**2)**0.5
sns.violinplot(data=tmp, x="id", y="displacement");


sns.boxplot(data=tmp, x="id", y="displacement");


sns.boxenplot(data=tmp, x="id", y="displacement");


· 3 min read
Benjamin Gallois
Copyright (C)  FastTrack.
Permission is granted to copy, distribute and/or modify this document.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Data analysis using Julia


The Julia documentation and installation guide can be found at We provide here a simple example that details how to import the tracking.txt file from FastTrack, and how to extract basic information like the number of objects, the number of images etc...

using DataFrames
using CSV
using PyPlot
using Plots
using StatsPlots


We are going to import the tracking file in a DataFrames. Note that the user needs to provide the full path to the tracking.txt file.

data ="tracking.txt", delim='\t', DataFrame)

2,475 rows × 23 columns (omitted printing of 14 columns)


Basic information

We are going to extract the basic tracking information:

  • Object's id
  • Number of objects
  • Number of images
  • Number of images with at least one object detected
objects = Set(
print("Objects id: ", objects)
Objects id: Set([10, 5, 9, 8, 13, 4, 1, 0, 12, 7, 11, 2, 3, 6])
numObjects = length(objects)
print("Number of objects: ", numObjects)
Number of objects: 14
numImages = maximum(data.imageNumber) + 1 # Image index starting at 0
print("Number of images: ", numImages)
Number of images: 200
numDetected = length(Set(data.imageNumber))
print("Number of images with at least one object detected: ", numDetected)
Number of images with at least one object detected: 200

Basic plots

We are going to make basic plots using Plots, StatsPlots and the PyPlot (that require a valid matplotlib installation) modules. For more information about plotting see

objectsByImage = zeros(numImages)
for i in 1:numImages
objectsByImage[i] = length(Set([data.imageNumber .== i-1]))
Plots.plot(1:numImages, objectsByImage; title="Number of detected objects by frame", xlabel="Frames", ylabel="Objects", label=false)


dataObject0 = data[ .== 0, :]
distance = sqrt.(diff(dataObject0.xBody).^2 + diff(dataObject0.yBody).^2)
framerate = 25
time = diff(dataObject0.imageNumber)/framerate
velocity = distance./time

fig, ax = PyPlot.subplots(1, 2)
fig.subplots_adjust(right = 2)

ax[1] = PyPlot.subplot(121)
plot = ax[1].scatter(dataObject0.xBody[1:end-1], dataObject0.yBody[1:end-1], c=velocity, s=40)
ax[1].set_title("Object displacement")
bar = fig.colorbar(plot)

ax[2] = PyPlot.subplot(122, projection="polar")
ax[2].scatter(1:length(dataObject0.tBody), dataObject0.tBody, s=40)
ax[2].set_title("Object direction")


PyObject Text(0.5, 1.0715488215488216, 'Object direction')
velocities = Any[]
for i in 1:numObjects
distance = sqrt.(diff(data.xBody[ .== i-1]).^2 + diff(data.yBody[ .== i-1]).^2)
time = diff(data.imageNumber[ .== i-1])/25
velocity = distance./time
append!(velocities, [velocity])
StatsPlots.boxplot(velocities, label=false, title="Velocity distributions", ylabel="Velocity (px/s)", xlabel="Objects")