title: Using 'CvHaarClassifierCascade*' in facedetect program using opencv and eclipse
body: <p>I am trying to detect faces using opencv2 in eclipse.
  I am using the following program for the same...</p>
  
  <pre><code>#include &lt;cv.h&gt;
  #include"opencv2/highgui/highgui.hpp"
  #include"opencv2/core/core.hpp"
  #include"opencv2/imgproc/imgproc.hpp"
  using namespace cv;
  using namespace std;
  
  CvRect detectFaceInImage(IplImage *inputImg, CvHaarClassifierCascade* cascade);
  String face_cascade_name = "src/haarcascade_frontalface_alt.xml";
  CvHaarClassifierCascade* cascade;
  
  int main(int argc, const char* argv[])
  {
       CvCapture* capture =0;
  
       capture = cvCaptureFromCAM(0);
       IplImage* inputImg=0;
  
      if( !cascade.load( face_cascade_name ) ){ printf("--(!)Error loading\n"); return   -1; };
  
  while(true)
  {
      inputImg = cvQueryFrame(capture);
      if(!inputImg) break;
  
      namedWindow("My_capture",CV_WINDOW_AUTOSIZE);
  
      CvRect outputImg;
  
      outputImg = detectFaceInImage(inputImg, cascade);
  }
  
   return 0;
  }
  // Perform face detection on the input image, using the given Haar Cascade.
  // Returns a rectangle for the detected region in the given image.
  CvRect detectFaceInImage(IplImage *inputImg, CvHaarClassifierCascade* cascade)
  {
      // Smallest face size.
      CvSize minFeatureSize = cvSize(20, 20);
      // Only search for 1 face.
      int flags = CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_DO_ROUGH_SEARCH;
      // How detailed should the search be.
      float search_scale_factor = 1.1f;
      IplImage *detectImg;
      IplImage *greyImg = 0;
      CvMemStorage* storage;
      CvRect rc;
      double t;
      CvSeq* rects;
      CvSize size;
      int ms, nFaces;
      storage = cvCreateMemStorage(0);
      cvClearMemStorage( storage );
      // If the image is color, use a greyscale copy of the image.
      detectImg = (IplImage*)inputImg;
      if (inputImg-&gt;nChannels &gt; 1)
      {
          size = cvSize(inputImg-&gt;width, inputImg-&gt;height);
          greyImg = cvCreateImage(size, IPL_DEPTH_8U, 1 );
          cvCvtColor( inputImg, greyImg, CV_BGR2GRAY );
          detectImg = greyImg;    // Use the greyscale image.
      }
  
      // Detect all the faces in the greyscale image.
      t = (double)cvGetTickCount();
      rects = cvHaarDetectObjects( detectImg, cascade, storage,search_scale_factor, 3, flags, minFeatureSize);
      t = (double)cvGetTickCount() - t;
      ms = cvRound( t / ((double)cvGetTickFrequency() * 1000.0) );
      nFaces = rects-&gt;total;
      printf("Face Detection took %d ms and found %d objects\n", ms, nFaces);
          // Get the first detected face (the biggest).
      if (nFaces &gt; 0)
          rc = *(CvRect*)cvGetSeqElem( rects, 0 );
      else
          rc = cvRect(-1,-1,-1,-1);   // Couldn't find the face.
          if (greyImg)
          cvReleaseImage( &amp;greyImg );
          cvReleaseMemStorage( &amp;storage );
          //cvReleaseHaarClassifierCascade( &amp;cascade );
  return rc;  // Return the biggest face found, or (-1,-1,-1,-1).
  }
  </code></pre>
  
  <p>But I am getting this error...</p>
  
  <p><code>../src/test3.cpp:28:15: error: request for member ‘load’ in ‘cascade’, which is of non-class type ‘CvHaarClassifierCascade*’</code></p>
  
  <p>I have already added the "haarcascade_frontalface_alt.xml" in the source folder. When i am defining cascade as CascadeClassifier, it show some compatibility error.</p>
  
  <p>I am actually new to opencv... so plz help</p>