Hi, I have trained my own haar cascade classifier using opencv version 3.2 and after checking its performance I tried to use the cuda functions to perform some tests, however I encountered the following error:
terminate called after throwing an instance of 'cv::Exception'what(): OpenCV(4.4.0) /tmp/build_opencv/opencv_contrib/modules/cudalegacy/src/cuda/NCVHaarObjectDetection.cu:2079: error: (-215:Assertion failed) haar.ClassifierSize.height > 0 && haar.ClassifierSize.width > 0 in function 'loadFromXML'
I am currently using opencv version 4.4 and applying the detectMultiScale function as follows:
I tried with an absolute path and other .xml files and the result was the same.
I have also tried the code without the cuda functions and the same .xml file and it works without problems.
Is it possible that there is a formatting problem between the .xml files generated by opencv_traincascade or cascade trainer GUI and what cuda::CascadeClasiffier is looking for?
okay that’s good but now I’m out of ideas. your suspicion, the cuda version being somehow different, sounds plausible. I hope someone with more experience with the CUDA modules will see the issue.
I come back to say that I have solved the problem. It appears to be a compatibility problem. I used opencv version 3.4 and the opencv_traincascade function with its -baseFormatSave argument to train with the old .xml format and it worked.
However, when comparing this classifier in its cpu version (with cv::detectMultiScale) versus gpu (with cv::cuda::detectMultiScale), the detection results are very different between them.