Note that there are some explanatory texts on larger screens.

plurals
  1. PODifferent results with Haar cascade when in release/debug mode
    primarykey
    data
    text
    <p>I am using a Haar cascade classifier trained from the <a href="http://cbcl.mit.edu/software-datasets/CarData.html" rel="nofollow noreferrer">MIT cars dataset</a> 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).</p> <p>Can you suggest why this occurs and, more importantly, what I can do to obtain detections when running in Release mode?</p> <p><strong><a href="http://db.tt/cnpuh8r3" rel="nofollow noreferrer">Cascade File</a></strong></p> <p><strong>Code</strong> </p> <pre><code>cv::Mat testImage = cv::imread("testImage.png",0); cv::equalizeHist(testImage, testImage); cv::CascadeClassifier vehicleCascade; vehicleCascade.load("cars3.xml"); // Detect vehicles std::vector&lt;cv::Rect&gt; 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 &lt;&lt; "Found " &lt;&lt; cars.size() &lt;&lt; " objects.\n"; for (int i=0; i&lt;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); </code></pre> <p><strong>TestImage</strong></p> <p><img src="https://i.stack.imgur.com/oK7ZO.jpg" alt="testImage"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload