SiftFeatureDetector .detect函数损坏? [英] SiftFeatureDetector .detect function broken?

查看:757
本文介绍了SiftFeatureDetector .detect函数损坏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试从在线资源中进行SIFT/SURF,并希望自己进行测试.

Ive been trying out SIFT/SURF from online resources and wanted to test it out myself.

我首先尝试使用以下代码在非免费库中进行尝试:

I first tried without the non-free libraries using this code:

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);

Here if I do a step by step debugging it breaks at feature_detector->detect(img, keypoints);

然后我尝试使用非免费库并尝试了以下代码:

Then I tried using the non-free library and tried this code:

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);

This again compiles without errors but when ran, breaks at this step: detector.detect(input, keypoints);

我找不到原因.有人可以帮我吗.

I cannot find the reason why. Can some one please help me out here.

谢谢

这是我在中断时收到的错误:

edit: This is the error I get when it breaks:

SIFT.exe中0x007f0900处未处理的异常:0xC0000005:访问冲突读取位置0x00000000.

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

.

我的设置:Microsoft Visual C ++ 2010,OpenCV 2.4.2,Windows XP.全部 库已添加并链接

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

推荐答案

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

Use color image not grayscale, it works for me that way.
You could try skipping "const" too, if the color image would not work either.

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

这篇关于SiftFeatureDetector .detect函数损坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆