opencv - SiftFeatureDetector .detect函数损坏?

我一直在尝试从在线资源中进行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);
我找不到原因。有人可以帮我一下吗。

谢谢

编辑:这是我得到的错误,当它打破:

Unhandled exception at 0x007f0900 in SIFT.exe: 0xC0000005: Access violation reading location 0x00000000.





My setup: Microsoft Visual C++ 2010, OpenCV 2.4.2, Windows XP. All libraries added and linked

最佳答案

使用彩色图像而不是灰度图像,它对我有用。
如果彩色图像也不起作用,也可以尝试跳过“const”。

const Mat input = cv::imread("/tmp/image.jpg");

https://stackoverflow.com/questions/13162074/

相关文章:

opencv - 如何删除 OpenCV FileStorage 对象中的文件节点

matlab - 检测网格方向和属性

opencv - 如何找到两个二进制图像之间的旋转

python - 使用OpenCV人脸检测时出错

opencv - 如何从gpuHog获取描述符?

opencv - OpenCV HoughLines是否使用本文:通过改进的Hough变换投票方案进

opencv - 使用JavaCV开发我们需要安装什么?

python - 将 h264 RTSP 流读入 p​​ython 和 opencv

python - 用向量作为numpy中的条目迭代矩阵的最快方法

python - OpenCV 3.0缺少诸如drawMatches和drawMatchesKNN的