Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:54:25+00:00 2026-06-17T10:54:25+00:00

I am using a Haar cascade classifier trained from the MIT cars dataset to

  • 0

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?

Cascade File

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

testImage

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:54:26+00:00Added an answer on June 17, 2026 at 10:54 am
    1. It’s strange, but for me you code is working fine in both modes. I’m using Visual Studio 2010 on Windows 7 32bit. Here is my project – https://www.dropbox.com/s/5kubn5tlu7k6ziy/opencvhw.rar, so you can check executables(Release and Debug directories). If you are using visual studio and want to build it on your own you will have to change paths to library and include directories for both modes(include directories path is the same, library directories path is different). (project -> … properties -> configuration properties -> vc++ directories)

    2. Generally i would recommend to check really carefully project configuration. It’s really easy to make small mistake which can cause very weird behavior. Sometimes the best option is to configure everything from the scratch once again.

    3. OpenCV have very strange bugs – it’s nothing new 🙂 For example i can’t use some codecs while debugging – if i run program in debug mode, but without debugging everything is fine, but if i try to debug – each frame readed from file is empty(but its size is correct).
      It’s possible that you have just encountered something a bit similar. Try to convert image to different format(i think that bmp is the best choice for test – it’s should always work without any additional libraries).

    4. Also note that you have uploaded jpg file so i had to rename and convert it on my own – maybe during conversions something in this file have changed so we are not testing your code on exactly the same files – upload you png file on dropbox so i can test it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to detect the face from the webcam using opencv python on
I'm trying to make a hand detection program by using OpenCV and Haar cascade.
I have been successfully working with the Haar algorithm in OpenCV-2.1.0 (cvHaarDetectObjects) to detect
I am using OpenCV Haar Algorithm to track the Head and overlay an image
I have to code an object detector (in this case, a ball) using OpenCV.
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library
I am using the following code from the samples folder of OpenCV for face-detection
I am trying to use the OpenCV's cascade classifier based on Histogram of Oriented
I am using haar cascade for profile face, but i have noticed that it
I am using opencv sharp, and haar cascaes for profile face, but i wanna

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.