Crop video before using DLC

I have the need to crop videos before using DLC. Due to environment conditions my videos contains a lot more then the animal i want to analys with DLC (including multiple animals).

I did not find any easy-to-use tool, but while searching i put together some python-code that did the trick for me. I thought it could be useful for others in the process of exploring DLC.

This is what it does:

  • Let the user select a video file, and then shows first frame of the video.
  • User uses mouse to select an area as input parameters to crop
  • The selected video is cropped and saved as .avi with a suffix added to original filename

With the cropped video i was able to get much better result with DLC.

Feel free to explore the code here

Thanks for sharing! Just to let you, and perhaps others, know though, that when you run extract frames you can set cropping to true, and a GUI pops up that lets you draw a bounding box to crop the video(s). See docs here:

Hi, i know you can, but then you need to know x and y values.
I wanted to use the mouse for selecting the area :slight_smile:

you can just use the mouse:

1 Like