Adding cropping to pose_estimation_pytorch/apis/analyze_videos.py by YankoFelipe · Pull Request #2737 · DeepLabCut/DeepLabCut
@YankoFelipe this is awesome, thank you for implementing the cropping feature!
There are a few changes that I think should be made to match the tensorflow implementation of cropping.
As is done in the tensorflow implementation, I would read the cropping parameters from the project configuration file if no cropping parameters were passed (e.g., in analyze_videos, after the if batch_size is None: batch_size = cfg.get("batch_size", 1) lines ):
if cropping is None and cfg.get("cropping", False): cropping = cfg["x1"], cfg["x2"], cfg["y1"], cfg["y2"]
When calling metadata = _generate_metadata(, I would also pass the cropping parameters that were used (this can be done through a VideoIterator object instead of passing a VideoReader) so they can be stored in the video analysis metadata file.