Ask Your Question

Revision history [back]

How to load old format cascade on OpenCV 2.4.10?

I am currently trying to use cv::ocl::OclCascadeClassifier, but It uses oldCascade only which is NULL (so I got invalid cascade cv exception).

Method isOldFormatCascade() returns false, method load() returns true.

If I use cv::CascadeClassifier, all works fine (because there are 2 branches in its implementation: for old format and for new format cascades).

cv::Mat image = cv::Mat::zeros(cv::Size(2000, 700), CV_8UC1);
cv::ocl::oclMat image_igpu;
image_igpu.upload(image);
cv::Size min_size(50, 10);
cv::Size max_size(100, 20);

cv::CascadeClassifier cascade_cpu;
cv::ocl::OclCascadeClassifier cascade_igpu;
cascade_cpu.load("cascade.xml");
cascade_igpu.load("cascade.xml");

std::cout << cascade_igpu.isOldFormatCascade() << std::endl;//prints 0 (false), same as cascade_cpu.isOldFormatCascade()


std::vector<cv::Rect> objs;
cascade_cpu.detectMultiScale(image, objs, 1.1, 0, 0, min_size, max_size);//works fine
cascade_igpu.detectMultiScale(image_igpu, objs, 1.1, 0, 0, min_size, max_size);//OpenCV Error: Null pointer (Invalid classifier cascade) in oclHaarDetectObjects