opencv - 检测器->检测(img,关键点);错误

我想在opencv中实现一揽子单词。在检测器之后-> detect(img,keypoint);当我想使用keypoint.clear()清理关键点时,会检测到关键点;或者当函数想要返回时,将出现以下错误。

在BOW.exe中的0x011f45bb处未处理的异常:0xC0000005:访问冲突读取位置0x42ebe098。

并且检测到的关键点具有奇怪的点坐标,例如cv::Point_ pt {x = -1.5883997e + 038y = -1.5883997e + 038}

部分代码

Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("FlannBased");
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();
Ptr<FeatureDetector> detector = new SurfFeatureDetector(2000);
    void extractTrainingVocabulary() {
        IplImage *img;
        int i,j;
         CvSeq *imageKeypoints = 0;
        for(j=1;j<=60;j++)
        for(i=1;i<=60;i++){
            sprintf( ch,"%d%s%d%s",j," (",i,").jpg");
                        const char* imageName = ch;
                        Mat img = imread(ch);
                        vector<KeyPoint> keypoint;
                        detector->detect(img, keypoint);
                        Mat features;
                        extractor->compute(img, keypoint, features);
                        bowTrainer.add(features);
                        keypoint.clear();//problem
        }
    return;
    }

最佳答案

我注意到了一些关于您的代码的信息,在extractTrainingVocabulary()上声明了IplImage* img;,在循环内声明了另一个具有相同名称(但类型不同)的变量:Mat img = imread(ch);

即使这可能不是问题,但这也不是一个好习惯。我会立即修复该问题并更新您问题的代码。

关于opencv - 检测器->检测(img,关键点);错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7050290/

相关文章:

opencv - OpenCV-CirclesGridFinder的文档

python - 'import cv' 之后的 `Fatal Python error: PyTh

python - 无法在 OpenCV2.1 上导入 cv

docker - 与 WORKDIR 相关的映射卷

docker - chown : changing ownership of '/var/lib/m

visual-studio-2010 - 如何在VS2010 Windows 7中安装tbb_ded

opencv - 段错误 OpenCV/Facedetect.c/CentOS 6 64Bit

exception - openNI干扰cvCreateCameraCapture()

vb.net - 如何从VB.net轻松调用IronPython函数?

image-processing - 以下用于图像调整大小的 c++ 双三次插值代码有什么问题