megamanexp -1 Newbie Poster

Hi there,

i am also currently working a project on the face detection using OpenCV but is using the Borland C++ to do the programming. Could anyone guide me i need help thank you and if possible can anyone send a example file that working and how do i really made it work with the webcam. Plus i would like to ask what does it mean by adding filter to the face detection

Best regards

By the way i would like to ask is this the type of coding for facedetection???

IplImage* small_img;
//  small_img = cvLoadImage("Photo358.jpg", 1);
//  main_try11(small_img);
}
void main_try11(IplImage* img)
{
CvMemStorage* storage = cvCreateMemStorage(0);
const char* cascade_name = "haarcascade_frontalface_default.xml";
const char* nested_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";

//static CvMemStorage* storage = cvCreateMemStorage(0);
static CvHaarClassifierCascade* cascade = (CvHaarClassifierCascade*)cvLoad( cascade_name, 0, 0, 0 );
static CvHaarClassifierCascade* nested_cascade;


  double scale =  1.0;
  static CvScalar colors[] ={
  {{0,0,255}}, {{0,128,255}}, {{0,255,255}}, {{0,255,0}},
  {{255,128,0}}, {{255,255,0}}, {{255,0,0}}, {{255,0,255}}
  };//Just some pretty colors to draw with

  int count = 0;
//  cascade =
//  nested_cascade = (CvHaarClassifierCascade*)cvLoad( nested_cascade_name, 0, 0, 0 );

  //IMAGE PREPARATION:
  IplImage* gray_try = cvCreateImage( cvSize( img->width, img->height ), 8,1);
    cvCvtColor(img, gray_try, CV_BGR2GRAY);

  //DETECT items IF ANY
  //cvClearMemStorage( storage );
  CvSeq* objects = cvHaarDetectObjects(img, cascade, storage, 1.2, 2, 0, cvSize(20, 20));

  //LOOP THROUGH FOUND OBJECTS AND DRAW BOXES AROUND THEM
  for(int i = 0; i < (objects ? objects->total : 0); i++)
  {
    CvRect* r = ( CvRect*)cvGetSeqElem(objects, i);
    cvRectangle( img, cvPoint( r->x,r->y), cvPoint(r->x + r->width,r->y+r->height),colors[i%8]);

  }

  //cvNamedWindow("draw & detect",1);
  //if(objects->total > 0)
  //cvShowImage("draw & detect",img);
  cvReleaseImage(&gray_try);
  //cvReleaseImage(&img);

  return;