So I’ve been playing with video tracking code in python for a while. In my first week as a post-doc I bashed together some code to automatically track chickadees doing captive trials. I’ve also tracked several crickets in various test arenas. These systems are steadily getting better, and now we’re hoping to ramp up the cricket work, both here and at Carleton University. Additionally, we’re hoping to potentially do something with tracking the chickadee captive trials..
Clearly at this stage, I can’t just send undergrads and volunteers my code. It’s too specialised for each particular problem and I can’t be everywhere at once. It therefore felt like it was time to perhaps starting sticking a graphical user interface on these things.
I had come up with a few quality of life improving pieces of code before. I’d written a script that automatically downloaded RFID data from an SD card, sorted it into it’s appropriate folder and then removed it from the SD card. That still looked like a command prompt though, even if all you had to do was hit enter.
I hadn’t really had any experience with coding user interfaces before, but TKinter seemed the way to go in terms of putting a friendly face on my python code. So I sat down and sketched out what I needed my software to do initially.
- I needed it to be able to automatically load videos from a file structure, based on whatever variables the user had chosen.
- I needed users to be able to refer it to a datafile containing data such as the time to start tracking, end tracking or find a clean background plate.
- I needed users to be able to define areas of interest in the video such as maze arms or trees.
- I needed a button to start tracking videos.
This seemed like a simple enough initial list. The first thing I decided was to have separate programs for doing the video tracking and defining the areas of interest, though they would share features. I decided to start with this “polygon clicker” as I referred to it. I had written some basic code to let me do this in the past, but it was set up to only work for a particular problem, and I wanted something far more generalised and user friendly.
I started pulling together a GUI, selecting a base folder, selecting variable names, automatically generating the required list of trials based on those variables, etc.
I quickly learnt that there were always more features to add. The first thing I bolted on was a config file so that I didn’t have to click through all the dialogues every time I wanted to test. This of course required a whole set of extra functions to save it and load it when the program was opened and closed.
Eventually I got to the stage where I could add the code to define polygons. This wasn’t without a few hiccups though.
Accidental modern art?
Finally I had the program in a form that I was happy with.
Now it’s time to work on the video tracker.
Once again I had some code ready, but there were always more features to add. What about cropping? What about the fact that our cricket videos had two trials going on in the same frame? What about the ability to copy and paste polygons? Or assign polygons based on a variable rather than on a trial by trial basis? What about making sure it works on a Mac?What about shiny progress bars?
I have to confess I like shiny progress bars:
Progress shall continue.
If this works well, I’ll hopefully make it public. I’m sure it might have some applications for other people!
Oh, in other news, it was my birthday!
As I have advanced in years, I have been granted WISDOM by this bird. Admittedly it was mainly “CAWWW”, but every little helps..