IMPORTANT NOTE: There seems now to be a FicTrac installer, you could give it a try or else follow the instructions below. Note that the installer is pre-built to work with point grey USB3 cameras, so if you plan on using GigE, a different camera brand, or need to customize aspects of the installation (for example, changing the config window size), follow the instructions to build from source, below.

FicTrac is a software than enables you to track the fly’s projected motion as it ’navigates’ while tethered to a ball. The software has a relatively active reddit forum with some questions and answers that may assist debugging: https://www.reddit.com/r/fictrac/

The FicTrac source code can be built for both Windows, Linux (e.g. Ubuntu) operating systems, or from within a virtual machine on any operating system. For the current version of FicTrac (v2.1) used by the lab, it is recommended that the source code be built on Windows x64. Instructions for installing the previous version of FicTrac (v2.0) can be found here.

Note that default connection protocol changed from TCP to UDP in v2.1, which makes it easier to run FicTrac since you don’t have to wait for the receiving side to be ready. There might be a way to change this in v2.0 but I think you can’t specify in the config.txt but you need to modify the C++ code.

This guide is a compilation of notes from Matt Collie, Alexandra Moore, Melanie Basnak, Yvette Fisher, Elena Westeinde, Tatsuo Okubo, Alex Bates, and RJD Moore’s FicTrac guide.

Note that some of the screenshots below uses forward slash because I’m using git bash on windows .


Installing Necessary Software#

  1. Clone or download the FicTrac repository

  2. Download and install required build tools and dependencies:

  3. Cmake v3.16 build system (Windows win64-x64 Installer) 1. Select the option to add cmake to your system path.

  4. Download for Visual Studio 1. Include “Desktop development with C++” in the Installer or under Tools > Get Tools and Features… 1. Note: you should not need any additional packages 1. Note: VS Community 2019 version has worked for multiple people.

  5. Spinnaker 1. Install with the ‘Application Development’ option. 1. Note: Some folks have reported problems building fictrac with the most recent versions of Spinnaker. Consider downloading the 2.3.0.77 version instead (below installation page)

  6. Download the Vcpkg and install software packages as follows:

  7. First, download and bootstrap vcpkg itself (Bootstrap means you run a file that you initially downloaded to download even more files. The following .bat file execute commands in Windows Command Prompt.) It can be helpful to install vcpkg to either C:\src\vcpkg or C:\dev\vcpkg to avoid path issues for some port build systems. Run the following command in Command Prompt:

> .\vcpkg\bootstrap-vcpkg.bat

Note: if powershell.exe is not recognized, try entering *%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ **into the command line first *

  1. Integrate vcpkg with Visual Studio

> .\vcpkg\vcpkg integrate install

Pay attention to the last two lines (CMake projects should use:). You will need this path later.

  1. Install the following software libraries (OpenCV, NLopt, Boost::asio, and FFmpeg) for your project using vcpkg (this can take up to ~30 mins, it might look like the program stopped at “building…” but don’t close the command prompt and hang in there!):.

> .\vcpkg\vcpkg install opencv[ffmpeg]:x64-windows nlopt:x64-windows boost-asio:x64-windows ffmpeg:x64-windows

Just showing the last bit. Notice the total elapsed time!

  1. All installed libraries are immediately ready to be included and used in your project without additional configuration.

  2. At this point, you should ensure that you have downloaded/cloned FicTrac to your computer, as we will need to update the toolchain used to build FicTrac in the next section. You can either do this with the CMake Settings Editor, or Visual Studio.

  1. Open Visual Studio and load the fictrac folder under “File > Open > Folder…”

Note: the following two steps may not be completely necessary. If you do not see a dropdown menu you may be able to skip this step and build Fictrac without specifying the toolchain path.

  1. If your FicTrac folder contains the CMakeLists.txt file, the following configuration drop down menu should become available in the upper toolbar:

  1. To set vcpkg as your toolchain, select “Manage Configurations…” from the drop down menu (shown above) and set the following under the setting titled CMake toolchain file:

> [vcpkg root]/scripts/buildsystems/vcpkg.cmake

i.e. C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake

Note: “/” seems backwards from typical windows directories format but this is correct.  You can also navigate to the file using the […] button on the right.

At this point you should have the necessary software and dependencies to build FicTrac. These steps should only need to be completed once and should not be repeated if/when rebuilding FicTrac.


**Building FicTrac **#

You should have already downloaded FicTrac in the previous section. However, you can always rebuild FicTrac at any time by redownloading or cloning the FicTrac repository and executing the following steps:

  1.  First, navigate to your FicTrac folder in a terminal, and create a build directory:

> cd dev/fictrac

> mkdir build

> cd build

  1. Run Cmake to prepare the necessary build files for FicTrac. Here, we will need to provide the path to the Cmake toolchain file that was installed by Vcpkg (this path is printed to terminal when you run the Vcpkg system-wide integration step). Don’t forget two periods at the end!

  2. For Flycapture SDK:

> cmake -G "Visual Studio 16 2019" -D CMAKE_TOOLCHAIN_FILE=<vcpkg root>\scripts\buildsystems\vcpkg.cmake -D PGR_USB2=ON -D PGR_DIR="<path to> \Flycapture" ..

     b.   For Spinnaker SDK (recommended):

> cmake -G "Visual Studio 16 2019" -D CMAKE_TOOLCHAIN_FILE=<vcpkg root>\scripts\buildsystems\vcpkg.cmake -D PGR_USB3=ON -D PGR_DIR="C:\Program Files\FLIR Systems\Spinnaker" ..

So for example, your command might look like:

cmake -G "Visual Studio 16 2019" -D CMAKE_TOOLCHAIN_FILE=C:\dev\vcpkg\scripts\buildsystems\vcpkg.cmake -D PGR_USB3=ON -D PGR_DIR="C:\Program Files\FLIR Systems\Spinnaker" ..

Note: If you get an error similar to: CMake Error at CMakeLists.txt:79 (get_filename_component), your issue may stem from not having the development version of Spinnaker. You need to select the ‘Application Development’ option when installing Spinnaker in the installation Wizard. You should be able to see the file Spinnaker/lib64/vs2015/Spinnaker_v140.lib

*Note: If the command prompt does not recognize cmake as a viable function, try adding it to the path: set PATH="C:\Program Files\CMake\bin\";%PATH%

Note: The path to the Spinnaker folder should be under Program Files/FLIR Systems/Spinnaker or else Program Files/Point Grey Research/Spinnaker, it does not have to be a specific subfolder or directory within the Spinnaker program file. You can change this path if you need to.*

Note: Given that the “build” path and “source” path are different, cmake may be unable to find the toolchain file located above your build directory in the main fictrac-master folder. To resolve this, you can add a line that specifies the source directory as different from the build path:

> -S <path to fictrac-master folder>

Note: If a particular package fails (e.g. Could not find a package configuration file provided by “NLopt” with any of the following names), just reinstall that package using vcpkg as in Step 5.

  1. Finally, build and install FicTrac:

> cmake --build . --config Release -j 4

If everything went well, the executables for FicTrac and a configuration utility will be placed under the bin directory in the FicTrac project folder.

An example output including a few warnings.


Testing FicTrac#

In general, FicTrac requires two files to run properly. The first is a text configuration file under fictrac/sample that sets a variety of acquisition parameters (such as the camera port, client port, frame rate, etc). The second is a python script under fictrac/script transforms data collected by FicTrac into usable voltage outputs from the Phidget device.

FicTrac can process either live footage from your camera or a saved video clip. The fictrac repository includes a exampleconfig.txt file and ball video. Be default, the provided config file is designed to use the sample video as is input (src_fn). To test FicTrac on the sample footage to ensure that everything is working properly:

  1. Open a command terminal and type the following to check the configuration file:

> cd <path to>\fictrac-master\sample

> ..\bin\Release\configGui.exe config.txt

  1. To run FicTrac on the sample footage, simply type:

> ..\bin\Release\fictrac.exe config.txt

More details about how to configure FicTrac according to your experiment are provided in the configuration guide.


Keeping FicTrac Up-To-Date#

You should consider updating FicTrac every occasionally, as the program is still under development and fixes/improvements are still being made implemented.

To do so, just delete the fictrac folder and re-download/re-clone fictrac from the official github repository. At this point, you should re-build fictrac (part 2) but do NOT need to re-install of the necessary software (part 1).