Ask Your Question

Revision history [back]

cascade classifier doesnot work for image input

given below is my 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 new=imread("F:\new.jpg"); namedWindow("HAAR"); CascadeClassifier face_cascade;
vector<rect> faces; Mat frame_gray;

cvtColor( new, frame_gray, CV_BGR2GRAY ); equalizeHist( frame_gray, frame_gray ); if( !face_cascade.load( "haarcascade_frontalface_alt.xml") ) { printf("--(!)Error loading\n"); return -1; }; face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) ); for( size_t i = 0; i < faces.size(); i++ ) { Point center( faces[i].x + faces[i].width0.5, faces[i].y + faces[i].height0.5 ); ellipse( frame, center, Size( faces[i].width0.5, faces[i].height0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 ); } imshow("HAAR", frame ); }

MS visual studio 2010 and opencv 2.4.9 are used. no error is displayed build is successful

cascade classifier doesnot work for image input

given below is my code

include "opencv2/objdetect/objdetect.hpp"

code #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp"

#include <iostream>
 #include <stdio.h>

#include <stdio.h> using namespace std; using namespace cv;

cv; int main() { Mat new=imread("F:\new.jpg"); namedWindow("HAAR"); CascadeClassifier face_cascade;
vector<rect>
vector<Rect> faces; Mat frame_gray;

frame_gray; cvtColor( new, frame_gray, CV_BGR2GRAY ); equalizeHist( frame_gray, frame_gray ); if( !face_cascade.load( "haarcascade_frontalface_alt.xml") ) { printf("--(!)Error loading\n"); return -1; }; face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) ); for( size_t i = 0; i < faces.size(); i++ ) { Point center( faces[i].x + faces[i].width0.5, faces[i].width*0.5, faces[i].y + faces[i].height0.5 ); faces[i].height*0.5 ); ellipse( frame, center, Size( faces[i].width0.5, faces[i].height0.5), faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 ); } imshow("HAAR", frame ); }

}

MS visual studio 2010 and opencv 2.4.9 are used. no error is displayed build is successful

cascade classifier doesnot work for image input

given below is my code #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp"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 new=imread("F:\new.jpg");
    namedWindow("HAAR");
    CascadeClassifier face_cascade; 
    vector<Rect> faces;
    Mat frame_gray;

    cvtColor( new, frame_gray, CV_BGR2GRAY );
    equalizeHist( frame_gray, frame_gray );
    if( !face_cascade.load( "haarcascade_frontalface_alt.xml") )
    { 
      printf("--(!)Error loading\n");
      return -1;
    };
    face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
    for( size_t 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( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
    }
    imshow("HAAR", frame );
}

MS visual studio 2010 and opencv 2.4.9 are used. no error is displayed build is successful