ver228 / tierpsy-tracker

Multi-Worm Behaviour Tracker
http://ver228.github.io/tierpsy-tracker/
MIT License
24 stars 40 forks source link

Error during file compression (OpenCV version issue?) #73

Open otlichna opened 4 years ago

otlichna commented 4 years ago

When going through the compression step using an avi file and background subtraction, I get the following error:

20170522_hisAIB_nohisL_nohisC_adp_naive1.avi kept stack Starting video compression. ERROR: AttributeError: 'readVideoCapture' object has no attribute 'frame_max' Traceback (most recent call last): File "/home/pkidd/Apps/tierpsy-tracker/tierpsy/processing/ProcessWorker.py", line 108, in ProcessWorker(args, cmd_original = subprocess.list2cmdline(sys.argv)) File "/home/pkidd/Apps/tierpsy-tracker/tierpsy/processing/ProcessWorker.py", line 38, in init self.execAllPoints() File "/home/pkidd/Apps/tierpsy-tracker/tierpsy/processing/ProcessWorker.py", line 66, in execAllPoints cmd_original = self.cmd_original) File "/home/pkidd/Apps/tierpsy-tracker/tierpsy/processing/trackProvenance.py", line 28, in execThisPoint func(argkws) File "/home/pkidd/Apps/tierpsy-tracker/tierpsy/analysis/compress/processVideo.py", line 142, in processVideo compressVideo(video_file, masked_image_file, **compress_vid_param) File "/home/pkidd/Apps/tierpsy-tracker/tierpsy/analysis/compress/compressVideo.py", line 335, in compressVideo bg_dataset._v_attrs['save_interval'] = vid.frame_max-vid.first_frame + 1 AttributeError: 'readVideoCapture' object has no attribute 'frame_max'

I get similar errors with other file types as well (eg after converting to TIF).

Because I have a pre-existing Python installation (including OpenCV) that I use for other tasks, I didn't use Anaconda, and just installed from the github source with pip install -e. Many of my packages are different versions than recommended in your requirements.txt, in particular I have OpenCV 4.1.2. So I suspect this is an OpenCV version issue? If there's no easy fix I could create a new environment and setup with Anaconda, but I figured I would check here first. Thanks!

Phil

ver228 commented 4 years ago

I am afraid this is really a bug from our part @luigiferiani seems to be the responsable. For the moment the quicker solution is to simply set the flag is_bgnd_subtraction = False. You should be able to do it with the set parameters flag.

A more technical description:

When implemented the reader for loopbio the attributes frame_max and first_frame were added, however this is the only reader that have those attributes so it frames. Since what it is really required in the buggy line is the total number of frames. I will suggest to implement the __len__ method to all the available readers so the line can be changed to : bg_dataset._v_attrs['save_interval'] = len(vid)

Any comment about this @luigiferiani