Run analyse_video() with numpy stack instead of video

Hi all,
I am wondering if there is a way to pass a stack of pre-loaded images (instead of a video path) to analyse_video() function?
I have stack of images stored in HDF5 files and there are thousands of these files so I wish to avoid converting each to .avi file.

Any pointers would be appreciated. I am trying to avoid dismembering the DLC source code but I guess that will be the last resort.

pankaj

Hi,

I think you’d have to re-write some things. Since the code is written to look for video files and check video metadata for information like framerate, number of frames etc. I don’t think there is an easy way to pass arrays instead of videos.

Maybe someone with more experience could pitch in on this.

Hey @pankajgupta, have a look here DeepLabCut/predict_multianimal.py at 5154c336f81ca57a05409c90a08aac7a9451eef9 · DeepLabCut/DeepLabCut · GitHub, it shouldn’t be too hard to replace

    while cap.video.isOpened():
        if counter % step == 0:
            pbar.update(step)
        frame = cap.read_frame(crop=cfg["cropping"])

with iterating over your array. Feel also free to open an issue on GitHub and request the feature (or contribute it) :smiley: