我使用 OpenCV 在 C++ 中有这个函数:
vector<KeyPoint> test(Mat img)
{
int minHessian = 400;
SurfFeatureDetector detector( minHessian );
vector<KeyPoint> vKeypoints;
detector.detect( img, vKeypoints );
return vKeypoints;
}
当我在主方法中调用此函数时,一切正常。
int main( int, char** argv )
{
// path to a image-file
char* input = "image.jpg";
// read image into Mat img
Mat img = imread( input, CV_LOAD_IMAGE_GRAYSCALE );
// call function test
test(img);
waitKey(0);
return 0;
}
但是,一旦我两次调用此方法...
int main( int, char** argv )
{
// path to a image-file
char* input = "image.jpg";
// read image into Mat img
Mat img = imread( input, CV_LOAD_IMAGE_GRAYSCALE );
// call function test
test(img);
test(img); // <-- !!! second call
waitKey(0);
return 0;
}
...我收到以下错误:
谁能告诉我我的错误在哪里以及如何解决这个问题?我需要使用两个不同的图像两次调用此函数,但每次我这样做时都会收到此错误。
我正在使用 Visual Studio 2012。