我一直在试用在线资源的SIFT/SURF,并想自己测试一下。
我首先尝试了不使用以下代码的非空闲库:
int _tmain(int argc, _TCHAR* argv[])
{
Mat img = imread("c:\\car.jpg", 0);
Ptr<FeatureDetector> feature_detector = FeatureDetector::create("SIFT");
vector<KeyPoint> keypoints;
feature_detector->detect(img, keypoints);
Mat output;
drawKeypoints(img, keypoints, output, Scalar(255, 0, 0));
namedWindow("meh", CV_WINDOW_AUTOSIZE);
imshow("meh", output);
waitKey(0);
return 0;}
在这里,如果我一步一步地调试,它就会在feature_detector->detect(img, keypoints);中断
然后,我尝试使用非自由库,并尝试了以下代码:
int main(int argc, char** argv)
{
const Mat input = cv::imread("/tmp/image.jpg", 0); //Load as grayscale
SiftFeatureDetector detector;
vector<KeyPoint> keypoints;
detector.detect(input, keypoints);
// Add results to image and save.
Mat output;
drawKeypoints(input, keypoints, output);
imwrite("/tmp/SIFT_RESULT.jpg", output);
return 0;
}这再次编译而没有错误,但是当运行时,会在以下步骤中断:detector.detect(input, keypoints);
我找不到原因。有人能帮我一下吗。
谢谢
编辑:这是当它崩溃时我会遇到的错误:
在SIFT.exe: 0xC0000005:访问冲突读取位置0x00000000中0x007f0900处的未处理异常。
。
我的设置: Microsoft C++ 2010,OpenCV 2.4.2,Windows。添加和链接的所有库
发布于 2012-11-02 10:03:41
使用彩色图像,而不是灰度,它对我的工作方式。
如果彩色图像也不能工作,您也可以尝试跳过"const“。
const Mat input = cv::imread("/tmp/image.jpg");https://stackoverflow.com/questions/13162074
复制相似问题