首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >检测器->检测(img,keypoint);错误

检测器->检测(img,keypoint);错误
EN

Stack Overflow用户
提问于 2011-08-13 12:05:10
回答 1查看 1.2K关注 0票数 0

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

“在0x011f45bb处未处理的异常( BOW.exe: 0xC0000005:访问冲突读取位置0x42ebe098.)”

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

代码的一部分

代码语言:javascript
复制
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;
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-14 02:36:59

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

尽管这可能不是问题所在,但这肯定不是一个好的做法。我会立即修复这个问题,并更新你问题上的代码。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7050290

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档