gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 17:55:11 28 4
gpt4 key购买 nike

我想在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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com