【发布时间】:2026-02-17 01:55:02
【问题描述】:
我想在 opencv 中实现词袋。在检测器->检测(img,关键点)之后;检测关键点,当我想使用 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;
}
【问题讨论】:
标签: opencv