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]
Target Image for detection [size:1024*680]
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;
}