C++ עם openCV

C++ עם openCV

שלום, אני מנסה ליצור תוכנית יחד עם הקוד של openCV ב- C++ולינוקס. תוכנית שתזהה פרצופים בתמונה ותסמן את הפנים בריבוע. זה בעיקרון הקוד: #include "../include/imageloader.h" #include "cv.h" #include "highgui.h" #include <stdlib.h> const char* cascade_name = "wii_frontalface4.xml"; int main(int argc, char **argv) { ImageLoader img("me.jpg"); img.displayImage(); /* Load the classifier data from the .xml file */ CvHaarClassifierCascade* cascade = (CvHaarClassifierCascade*)cvLoad( cascade_name); /* create a window with handle result */ cvNamedWindow( "result" ); /* read the input image */ IplImage* image = cvLoadImage( argv[1], 1 ); /* create a b&w image of the same size object as a placeholder for now - cvSize(width, height) is the object representing dimensions of the image - 8 stands for 8-bit depth - 1 means one-channel (b&w) Hence a 24bit RGB image of size 800x600 would be created with cvCreateImage( cvSize(800, 600), 8, 3); */ IplImage* gray = cvCreateImage( cvSize(image->width,image->height), 8, 1 ); /* now convert the input image into b&w and store it in the placeholder */ cvCvtColor( image, gray, CV_BGR2GRAY ); /* create memory storage to be used by cvHaarDetectObjects */ CvMemStorage* storage = cvCreateMemStorage(); /* used cvHaarDetectObjects */ /* 8-bit depth RGB representation of color red */ static CvScalar RED = {0, 0, 255}; /* go through all the detected faces, and draw them into the input image */ for (int i = 0; i < (faces ? faces->total : 0); i++) { CvRect *r = (CvRect*)cvGetSeqElem( faces, i ); CvPoint ul; CvPoint lr; ul.x = r->x; ul.y = r->y; lr.x = r->x + r->width; lr.y = r->y + r->height; /* draws a rectangle with given coordinates of the upper left and lower right corners into an image */ cvRectangle(image, ul, lr, RED, 3, 8, 0); } /* free up the memory */ cvReleaseImage( &gray ); /* show the result and wait for a keystroke form user before finishing */ cvShowImage( "result", image ); cvWaitKey(0); cvReleaseImage( &image ); cvDestroyWindow("result"); return 0; } הבעיה היא כשאני מקמפלת זה רושם לי את השגיאה הזאת: error: ‘faces’ was not declared in this scope מה אני אמורה לעשות? מה צריך לשנות/להוסיף? תודה!
 
למעלה