Miscellaneous Topics¶
Preprocess videos¶
Analysing results¶
GUI applications¶
Working with HPC¶
This section introduce how I use FishPy on the supercomputer, typically the “BlueCrystal” in the university of Bristol to extract 3D trajectories from videos.
Organise the Experimental Results¶
we need some auxiliary files for the tracking. And I organise my files like the follows. Here all the data is stored in a folder named observe_20190729_fish_20_small.
observe_20190729_fish_20_small/
├── arduino
│ ├── arduino.ino (arduino script for generating camera signals)
│ └── build (the folder generated by the arduino IDE)
│
├── calib_ext (folder for images to get extrinsic camera parameters)
│ ├── cam-1-1.tiff
│ ├── cam-2-1.tiff
│ ├── cam-3-1.tiff
│ ├── cam-1-2.tiff
│ ├── cam-2-2.tiff
│ ├── cam-3-2.tiff
│ └── ...
│
├── calib_int (folder for images to get intrinsic camera parameters)
│ ├── cam-1-1.tiff
│ ├── cam-2-1.tiff
│ ├── cam-3-1.tiff
│ ├── cam-1-2.tiff
│ ├── cam-2-2.tiff
│ ├── cam-3-2.tiff
│ └── ...
│
├── video_1
│ ├── cam-1.mp4
│ ├── cam-2.mp4
│ ├── cam-3.mp4
│ └── readme.md (notes about the experimental condition)
│
└── video_2
├── cam-1.mp4
├── cam-2.mp4
├── cam-3.mp4
└── readme.md (notes about the experimental condition)
Upload the folder to the HPC¶
I use the following command to upload my folder to the HPC.
scp -r observe_20190729_fish_20_small ab12345@bluecrystalp3.bris.ac.uk:~/fish_data
Start the project¶
I wrote a lot of helper scripts for setting up the tracking projects. They are stored in the folder Fishpy/script/bin. I added this folder to my $HOME variable to use these script convinently. For starting a new tracking project, I would typically use the following command
fishpy-create-project
what this command would do is copying the folder Fishpy/script/auto_process_* to our project folder. Typically, the script will scan through the current folders and find those whose names are started with video.
Typically, we have the following two folders
video-1
video-2
Therefor, the command will generate the two following new folders.
auto_process_1
auto_process_2
(running the fishpy-create-project again will not overwrite the existing folders.)
Configuring the Project¶
To get the trajectories from video_1, we have to make several changes in the folder auto_process_1.
In the file configure.sh should be modified. Here is an example. There are horribly lot of parameters. But the important ones will be highlighted.
# Specifying files
script_folder="script"
video_folder="../video_1" # <<<< This must match the folder that holds videos
cam_1_internal="database/cam_1_int.pkl" # <<<< The intrinsic camera parameters
cam_2_internal="database/cam_2_int.pkl"
cam_3_internal="database/cam_3_int.pkl"
# Calibration Spec
calib_folder="../calib-ext"
calib_format="tiff"
order_json="../calib-ext/calib-orders.json"
grid_size=16 # <<<< The size of square on the calibration board, unit: mm
corner_number="23, 15" # <<<< The number of inner corners in the row, column
# ... the rest of the file is ignored
Executing the Tracking¶
If the configuration is good, I track the fish with the following three commands. On an hpc, I would typically submit these three jobs.
qsub auto_track_2d.sh
qsub auto_track_3d.sh
qsub auto_link.sh
I also implemented another tracking algoritm called [GReTA](http://ieeexplore.ieee.org/document/7062911/). The workflow for GReTA is,
qsub auto_track_2d.sh
qsub auto_track_greta.sh
See the Result¶
If you get very lucky and obtained the final result, you can use the following command to visualise the 3D trajectories.
python see_trajs.py linking # if not using GReTA
python see_trajs.py greta # if using GReTA
this command would generate a file callend trajs.png. You can see the image with this command.
display trajs.png
Similarly, I wrote a script to conveniently see the distribution of the trajectories lengths. Typically I would use the folloing command.
python stat_trajs.py linking # if not using GReTA
python stat_trajs.py greta # if using GReTA
display traj-stat.png