Note that there are some explanatory texts on larger screens.

plurals
  1. POXML files for Haar Cascades not loading in Visual Studio 2010 using OpenCV 2.4.3
    primarykey
    data
    text
    <p>I am trying to run this simple face detection program that uses haar cascades in Visual Studio 2010 using OpenCV 2.4.3.Now every thing compiles fine but it seems like that the xml files for haar cascades are not loading.I did a lot of finding on Google but couldn't find any solution that works.I have tried every possible way to make them load.I gave absolute paths,I copied them into projects working directory,I used double backslashes as separators in absolute paths but they don't just load.I even downloaded them form other sources thinking may be the ones included with the library may be invalid or corrupt but no success.I know I am making some very basic mistake here.Here is the code I am using.Please help me out.Thank you.</p> <pre><code>&lt;pre&gt;&lt;code&gt; #include "stdio.h" #include "cv.h" #include "highgui.h" #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" using namespace cv; void detectAndDisplay( Mat frame ); /** Global variables */ String face_cascade_name = "E:\Downloads\IDM Downloads\opencv\data\haarcascades\haarcascade_frontalface_alt.xml"; String eyes_cascade_name = "E:\Downloads\IDM Downloads\opencv\data\haarcascades\haarcascade_eye_tree_eyeglasses.xml"; CascadeClassifier eyes_cascade; string window_name = "Capture - Face detection"; RNG rng(12345); CascadeClassifier face_cascade; /** @function main */ int main( int argc, const char** argv ) { // printf(); CvCapture* capture; Mat frame; // face_cascade //-- 1. Load the cascades if(!face_cascade.load( face_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; } if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; } //-- 2. Read the video stream capture = cvCaptureFromCAM( 0 ); if( capture ) { while( true ) { frame = cvQueryFrame( capture ); //-- 3. Apply the classifier to the frame if( !frame.empty() ) { detectAndDisplay( frame ); } else { printf(" --(!) No captured frame -- Break!"); break; } int c = waitKey(10); if( (char)c == 'c' ) { break; } } } return 0; } /** @function detectAndDisplay */ void detectAndDisplay( Mat frame ) { std::vector&lt;Rect&gt; faces; Mat frame_gray; cvtColor( frame, frame_gray, CV_BGR2GRAY ); equalizeHist( frame_gray, frame_gray ); //-- Detect faces face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) ); for( int i = 0; i &lt; 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 ); Mat faceROI = frame_gray( faces[i] ); std::vector&lt;Rect&gt; eyes; //-- In each face, detect eyes eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CV_HAAR_SCALE_IMAGE, Size(30, 30) ); for( int j = 0; j &lt; eyes.size(); j++ ) { Point center( faces[i].x + eyes[j].x + eyes[j].width*0.5, faces[i].y + eyes[j].y + eyes[j].height*0.5 ); int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 ); circle( frame, center, radius, Scalar( 255, 0, 0 ), 4, 8, 0 ); } } //-- Show what you got imshow( window_name, frame ); } &lt;/code&gt;&lt;/pre&gt; The ouput command line window just prints &lt;pre&gt;&lt;code&gt; --(!)Error loading Press any key to continue . . . </code></pre> <p> Which means the xml files are not loading. Here is my project directory listing.I have put the xml files in every folder but still no success.</p> <pre><code> OpenCVTest_2 |___Debug |___ipch |___opencvtest_2-365b6930 |___OpenCVTest_2 |___Debug |___Release |___Release </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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