Home > Blockchain >  OpenCV Python Cuda CascadeClassifier Error
OpenCV Python Cuda CascadeClassifier Error

Time:11-17

I am trying to optimize my detector created with OpenCV in python using the GPU. The error I am encountering is the following:

cv2.error: OpenCV(4.5.1) c:\opencv_build\opencv_contrib-4.5.1\modules\cudalegacy\src\cuda\ncvhaarobjectdetection.cu:2079: error: (-215:Assertion failed) haar.ClassifierSize.height > 0 && haar.ClassifierSize.width > 0 in function 'loadFromXML'

The error arises when calling this function:

cv2.cuda.CascadeClassifier_create(r"" cascade_model)

In the CPU version I use this function and it works without any problems:

cv2.CascadeClassifier(r"" cascade_model)

Any idea why this is happening? In case it helps, I'm running it on Windows 10 with an Nvidia GeForce RTX 3070 Ti.

CodePudding user response:

the CUDA cascade classifier cannot read the output from the traincascade tool properly.

you either need to train an LBP cascade (instead of HAAR), or fall back to the 2.x haartraining tool.

see: https://github.com/opencv/opencv_contrib/issues/3106

  • Related