I am using a Haar cascade classifier trained from the MIT cars dataset to detect vehicles in OpenCV (trained using the utilities provided with OpenCV). This works reasonably well when compiled in Debug mode, but when compiled in Release mode the cascade doesn't make any detections at all. Running the following code on the test image below gives a detection in debug mode but nothing in release mode (this behaviour continues through all images in my data sequence).
Can you suggest why this occurs and, more importantly, what I can do to obtain detections when running in Release mode?
Code
cv::Mat testImage = cv::imread("testImage.png",0);
cv::equalizeHist(testImage, testImage);
cv::CascadeClassifier vehicleCascade;
vehicleCascade.load("cars3.xml");
// Detect vehicles
std::vector<cv::Rect> cars;
vehicleCascade.detectMultiScale(
testImage, // Input image
cars, // Output bounding boxes
1.1, // scale factor - how much image size is reduced at each scale
5, // min neighbours - how many neighbours required to maintain rect
0|CV_HAAR_SCALE_IMAGE, // Not used
cv::Size(30,30), // Min poss object size
cv::Size() // Max poss object size
);
std::cout << "Found " << cars.size() << " objects.\n";
for (int i=0; i<cars.size(); ++i)
cv::rectangle(testImage, cars.at(i), CV_RGB(255,0,0), 3);
cv::namedWindow("Haar cascade");
cv::imshow("Haar cascade", testImage);
cv::waitKey(0);
cv::imwrite("output.png", testImage);
TestImage