| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 895 人关注过本帖
标题:词袋模型中计算特征点(compute)出错
只看楼主 加入收藏
nicole_hf
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-8-15
结帖率:0
收藏
已结贴  问题点数:10 回复次数:3 
词袋模型中计算特征点(compute)出错
错误如图:
[local]1[/local]
程序代码:
Mat dictionary,uDictionary; 
    FileStorage fs("dictionary.yml", FileStorage::READ);
    fs["vocabulary"] >> dictionary;
    fs.release();    

    //create a nearest neighbor matcher
    Ptr<DescriptorMatcher> matcher(new FlannBasedMatcher);
    //create Sift feature point extracter
    Ptr<FeatureDetector> detector(new SiftFeatureDetector());
    //create Sift descriptor extractor
    Ptr<DescriptorExtractor> extractor(new SiftDescriptorExtractor);    
    //create BoF (or BoW) descriptor extractor
    BOWImgDescriptorExtractor bowDE(extractor,matcher);
    //Set the dictionary with the vocabulary we created in the first step

    //dictionary.convertTo(uDictionary, CV_8UC1);

    cout<<"setVocabulary……"<<endl;
    bowDE.setVocabulary(dictionary);
    cout<<"setVocabulary over !"<<endl;
    //To store the image file name
    char * filename = new char[100];
    //To store the image tag name - only for save the descriptor in a file
    char * imageTag = new char[10];

    //open the file to write the resultant descriptor
    cout<<"file storing ……"<<endl;
    FileStorage fs1("descriptor.yml", FileStorage::WRITE);    
    cout<<"file storage over !"<<endl;
    //the image file with the location. change it according to your image file location
    sprintf(filename,"E:\\nicole_hf\\picture\\gps\\20141010_123726.jpg");        
    //read the image
    cout<<"filename:"<<filename<<endl;
    Mat img=imread(filename,CV_LOAD_IMAGE_GRAYSCALE);        
    //To store the keypoints that will be extracted by SIFT
    vector<KeyPoint> keypoints; 
    //Detect SIFT keypoints (or feature points)
    detector->detect(img,keypoints);
    cout<<"--keypoints.size:"<<keypoints.size()<<endl;
    cout<<"detect over !"<<endl;
    //To store the BoW (or BoF) representation of the image
    Mat bowDescriptor;        
    //extract BoW (or BoF) descriptor from given image
    cout<<"computing……"<<endl;
    (img,keypoints,bowDescriptor);//----------------出错的地方----------------------

    cout<<"compute over !"<<endl;
    cout<<"--bowDescriptor:"<<bowDescriptor<<endl;
    //prepare the yml (some what similar to xml) file
    sprintf(imageTag,"img1");
    //write the new BoF descriptor to the file
    fs1 << imageTag << bowDescriptor;        

    //You may use this descriptor for classifying the image.

    //release the file storage
    fs1.release();
搜索更多相关主题的帖子: dictionary 模型 
2014-10-23 16:26
nicole_hf
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-8-15
收藏
得分:0 
额 图片显示不出来,重新贴上来哈,错误信息如下:
Assertion failed: queries.cols == veclen()
2014-10-23 16:30
walikb
Rank: 2
等 级:论坛游民
帖 子:1
专家分:10
注 册:2014-10-25
收藏
得分:10 
回复 2 楼 nicole_hf
你好,我也遇到了这个问题,请问你解决了么?我的扣扣63462889,希望能交流一下解决办法
2014-10-25 20:20
nicole_hf
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-8-15
收藏
得分:0 
  不好意思  好久没上来了  没看到  是因为OpenCV版本的问题  低版本的OpenCV里面的compute方法里面是空的  换个高版本的就可以了  我之前用的是OpenCV2.2  后来换成OpenCV4.6就好了
2015-01-05 18:11
快速回复:词袋模型中计算特征点(compute)出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039150 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved