1

在开发用于面部认证的 C++ 应用程序时,我遇到了一个错误:

C3861: 'cropImage'*: identifier not found

这是的签名cropImage

IplImage* cropImage(IplImage *img,CvRect region);

我尝试在以下函数中调用它:

IplImage *cropFace(IplImage * image, CvPoint eye_left, CvPoint eye_right, double offset_pct[2], CvSize dest_sz)
{//calculate offsets in original image
    ...
    //matrice de rotation
    cv::Mat affine_matrix;
    affine_matrix = cv::getRotationMatrix2D(eye_left, rotation, scale);
    //mtx est la conversion de image IplImage* en matrice mtx
    cv::Mat mtx = cv::Mat(image, true);
    cv::Mat mtx2;
    cv::warpAffine(mtx, mtx2, affine_matrix, mtx.size(), cv::INTER_LINEAR,       cv::BORDER_CONSTANT, cv::Scalar::all(255));
    //mtx est la conversion de matrice mtx2 en image IplImage*
    IplImage image1 = mtx2;
    //crop the rotated image
    double crop_x = eye_left.x - scale * offset_h;
    double crop_y = eye_left.y - scale * offset_v;
    double crop_size0 = dest_sz.width * scale;
    double crop_size1 = dest_sz.height * scale;
    CvRect region;
    region.x = cvFloor(crop_y);
    region.y = cvFloor(crop_y);
    region.width = cvFloor(crop_size0);
    region.height = cvFloor(crop_size1);
    //the problem in this ligne,it seems it has not known cropImage !! :(
    IplImage *image2 = cropImage(&image1, region);
    IplImage *image3 = resizeImage(image2, dest_sz.width, dest_sz.width);
    return image3;
}      

我认为 IplImage* 和 Mat 之间的转换导致了这个问题。

4

1 回答 1

1

问题似乎是你指出来的。&即使image已经是指针类型,您也正在使用符号取消引用它,从而产生双指针。您应该简单地尝试:

IplImage *image2 = cropImage(image1, region);
于 2012-05-04T21:42:52.567 回答