umyelab/LabGym

Error while analyzing a video using a Trained Categorizer

Closed this issue · 2 comments

Hey Guys,

Just tried analyzing a video today using a Categorizer I trained using v.2.4.0 with the mode of detection as background subtraction. However, even after upgrading to the most recent version, the error still persists, and I remain unable to go ahead with the analysis of the video. Can you please guide me as to what I might be doing wrong since this error popped up in the previous version (v2.3.5) as well. The error is as follows:

PS C:\Users\BLab> LabGym
Unable to check for new versions of LabGym!
Please check https://github.com/umyelab/LabGym for updates.

The user interface initialized!
Preparation started...
2024-03-26 18:52:42.217479
Video fps: 30
The original video framesize: 1080 X 1080
Extracting the static background...
Background extraction completed!
Estimating the animal size...
2024-03-26 19:01:04.789547
Traceback (most recent call last):
  File "C:\Users\BLab\AppData\Local\pipx\pipx\venvs\labgym\lib\site-packages\LabGym\gui\analysis\analyze_behaviors.py", line 1186, in analyze_behaviors
    AA.prepare_analysis(
  File "C:\Users\BLab\AppData\Local\pipx\pipx\venvs\labgym\lib\site-packages\LabGym\analyzebehaviors.py", line 200, in prepare_analysis
    self.animal_area = estimate_animal_area(
  File "C:\Users\BLab\AppData\Local\pipx\pipx\venvs\labgym\lib\site-packages\LabGym\tools.py", line 467, in estimate_animal_area
    foreground = cv2.absdiff(frame, background)
cv2.error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\core\src\arithm.cpp:674: error: (-5:Bad argument) When the input arrays in add/subtract/multiply/divide functions have different types, the output array type must be explicitly specified in function 'cv::arithm_op'

There's indeed a bug in the new versions and we will fix it.
In the meantime, you can downgrade LabGym to stable version v2.2.2 to avoid the bug (python3 -m pip install LabGym==2.2.2). Most functions in v2.2.2 are same as newer versions.

Alright, Thanks. Will do so in the meanwhile.