Skip to content

jackbrucesimpson/BeeUnique

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BeeUnique

Program to track bees with unique tags.

Running the Programs

Execution scripts are located in the bin directory. Instructions for how to modify the variables in them for processing your own data are included below.

You can execute the scripts by running the bash command followed by the script name. For example, if you want to run the track.sh script described below, you can execute it by running bash track.sh in the terminal.

setup.sh

The purpose of this script is to set some default variables for each experiment. You do not have to run this file, as these variables will be imported into the other scripts automatically.

Variable Description
OUTPUT_DIRECTORY Directory path where you want the program output to be written.
EXPERIMENT_NAME Name of your experiment's dataset. Must not have spaces as a directory will be created with this name in the output directory.
REDUCE_IMAGES 1 (True) or 0 (False). Only output tag images which are sufficiantly different from each other.

track.sh

Tracking program that processes videos and creates csvs with tracking data and background images for each video.

Variable Description
VIDEO_DIRECTORY Set to the directory video files are stored in.
TRAINING Can set to 1 (True) or 0 (False). If set to training mode, the program will terminate after processing 2 mins footage from each video. Does not attempt to classify tags - merely sets them to
OVERWRITE_RAW Can set to 1 (True) or 0 (False). Will reprocess previously completed videos whose output is already present in the raw directory.

process_paths.sh

Program goes over the raw files generated by the tracking program and identifies paths based on the consensus classification of the tag.

Variable Description
OVERWRITE_PROCESSED Can set to 1 (True) or 0 (False). Will reprocess previously processed raw data whose output is already present in the processed directory.
OUTPUT_UNKNOWN_TAG_PATH_IMAGES Can set to 1 (True) or 0 (False). Bees paths over a certain length where the consensus classification could not be determined will have their tag images written out as image files.

After each JSON file has been processed, the bash script will then execute create_path_dbs.py which will then create a key-value database where the key is the 'tag_class' and the value is a dictionary containing the strings 'day' and 'night' which map to a list of paths, where each path for a time period takes the form of a dictionary like this:

{'is_gap': False, 'x_path': x_path, 'y_path': y_path, 'num_frames': path_length}
{'is_gap': True, 'prev_next_path_same_loc_disappeared': False, 'num_frames': constants.NUM_FRAMES_IN_VIDEO}

Analysis of these paths in then conducted in the Jupyter Notebook (refer to my PhD_Notebooks repository)

combine_bg.sh

Combines the background images generated by each hour-long video into an averaged image for each night and day time period. Outputs to night_day_background directory.

overlay.sh

Overlays tracking and tag pattern classifications onto a video. You can close the window that appears by pressing 'q'.

Variable Description
VIDEO_FILE_PATH Set to the path of the video you want to see.
RAW Can set to 1 (True) or 0 (False). Determines whether you go off the raw classification data or the processed path data where a consensus tag classification has been made.
CREATE_VIDEO 1 (True) or 0 (False). Outputs a 4K video of overlaid footage but slows down the program.
OUTPUT_VIDEO_FILE Set to the path and filename of the video you wish to output.
ENHANCE_UNTAGGED_BEES Try to increase the visibility of untagged bees in the video

reclassify_raw.sh

Will go over all the raw classification and tracking files that were generated and reclassify all the tags in the files.

output_tags.sh

Will go over all the csvs that were generated and create the tag images. Images will be grouped by bee path and all the bee paths from the same video will be stored in the same directory.

Setup

Dependencies

  • Requires Linux/MacOS
  • Python 2
  • OpenCV 2

Ubuntu Installation

System packages

sudo apt-get install libopencv-dev python-opencv python-pip exfat-fuse git

Python libraries

pip2 install numpy matplotlib pandas scipy sklearn cython networkx h5py tensorflow keras

Building

Compile the tracking library in the bin directory.

bash build.sh

About

Tracking bees with unique tags

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published