59template <
typename T>  rectangle*  
cvDetectObjects(cv::CascadeClassifier cascade, 
MSGraph<T>* vp, 
int& num, 
int sz=0, 
double scale=1.0)
 
   63    cv::Mat imag = copyMSGraph2CvMat<uByte>(vp);
 
   64    cv::equalizeHist(imag, imag);
 
   68        simg = cv::Mat_<uByte>((
int)(imag.rows/scale), (
int)(imag.cols/scale));
 
   69        cv::resize(imag, simg, simg.size(), 0, 0, cv::INTER_LINEAR);
 
   73    std::vector<cv::Rect> faces;
 
   74    if (sz>1) cascade.detectMultiScale(simg, faces, 1.1, 3, 0, cv::Size(sz, sz));
 
   75    else      cascade.detectMultiScale(simg, faces);
 
   77    num = (int)faces.size();
 
   78    if (num==0) 
return NULL;
 
   80    int len = 
sizeof(rectangle)*num;
 
   81    rectangle* data = (rectangle*)malloc(len);
 
   82    if (data==NULL) 
return NULL;
 
   86    std::vector<cv::Rect>::const_iterator r;    
 
   87    for (r=faces.begin(); r!=faces.end(); r++) {
 
   88        data[n].x     = (int)(r->x*scale);
 
   89        data[n].y     = (int)(r->y*scale);
 
   90        data[n].xsize = (int)(r->width *scale); 
 
   91        data[n].ysize = (int)(r->height*scale); 
 
 
  207    if (mat.channels()==1) {
 
  208        if      (mat.depth()==CV_8U)  vp = _getMSGraph_CvMat_C1<T, uByte>(mat);
 
  209        else if (mat.depth()==CV_8S)  vp = _getMSGraph_CvMat_C1<T, sByte>(mat);
 
  210        else if (mat.depth()==CV_16U) vp = _getMSGraph_CvMat_C1<T, uWord>(mat);
 
  211        else if (mat.depth()==CV_16S) vp = _getMSGraph_CvMat_C1<T, sWord>(mat);
 
  212        else if (mat.depth()==CV_32S) vp = _getMSGraph_CvMat_C1<T, int>(mat);
 
  217    else if (mat.channels()==3) {
 
  218        if      (mat.depth()==CV_8U)  vp = _getMSGraph_CvMat_C3<T, uByte>(mat);
 
  219        else if (mat.depth()==CV_8S)  vp = _getMSGraph_CvMat_C3<T, sByte>(mat);
 
  220        else if (mat.depth()==CV_16U) vp = _getMSGraph_CvMat_C3<T, uWord>(mat);
 
  221        else if (mat.depth()==CV_16S) vp = _getMSGraph_CvMat_C3<T, sWord>(mat);
 
  222        else if (mat.depth()==CV_32S) vp = _getMSGraph_CvMat_C3<T, int>(mat);