Ask Your Question
0

How to use the cascade.xml generated by traincascade.exe to detect object

asked 2014-02-11 21:57:02 -0600

cv_new gravatar image

updated 2014-02-11 21:58:53 -0600

I have successfully trained a cascade.xml yet using traincascade.exe. However,I cannot detect any car from the target image. Please give me some suggestions. Thank you in advance.

Positive Samples [size: 37*60] Number of positive samples is 600 and the number of negative samples is 2000.

image descriptionimage description

Target Image for detection [size:1024*680]

image description

My detection code.

include "opencv2/objdetect/objdetect.hpp"

include "opencv2/highgui/highgui.hpp"

include "opencv2/imgproc/imgproc.hpp"

include <iostream>

include <stdio.h>

using namespace std; using namespace cv;

int main( ) { Mat image; image = imread("C:\Documents\visual studio 2010\Projects\Carpark_detection\Carpark_detection\Debug\1.jpg", CV_LOAD_IMAGE_COLOR);
namedWindow( "window1", 1 ); imshow( "window1", image );

// Load Face cascade (.xml file)
CascadeClassifier face_cascade;
face_cascade.load( "C:\\Documents\\visual studio 2010\\Projects\\Carpark_detection\\Carpark_detection\\Debug\\cascade.xml" );

// Detect faces
std::vector<Rect> faces;
face_cascade.detectMultiScale( image, faces, 1.1, 1, 0|CV_HAAR_FIND_BIGGEST_OBJECT, Size(30, 80) );

// Draw circles on the detected faces
for( int i = 0; i < faces.size(); i++ )
{
    Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
    ellipse( image, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
}

imshow( "Detected Face", image );

waitKey(0);                   
return 0;

}

edit retag flag offensive close merge delete

Comments

I suggest using latent-svm-detector with the "car" model for cars detection. In my opinion, it will give far better results than haar- cascades.

GilLevi gravatar imageGilLevi ( 2014-02-12 07:28:14 -0600 )edit

Hi cv_new, which version of opencv are using?? and what is the size of opencv_traincascade.exe that is created ?? thanks

ART gravatar imageART ( 2014-02-18 05:59:34 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-02-12 20:25:33 -0600

cv_new gravatar image

Thanks for your suggestion. I am going to try it now.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-02-11 21:57:02 -0600

Seen: 684 times

Last updated: Feb 11 '14