我在开放式简历中使用BREIF描述符时遇到错误。
错误是BREIF无法提供所有关键点的描述符。它给出的描述符少于预期的关键点数。我得到的错误是
之后的错误。错误仅使用breif描述符。使用SURF和SURF描述符没有错误

OpenCV错误:断言失败(checkMasks文件/ home /中的masks [i] .rows == queryDescriptorsCount && masks [i] .cols == trainDescCollection [i] .rows && masks [i] .type()== CV_8UC1) shashank / Desktop / opencv-2.4.5 / modules / features2d / src / matchers.cpp,第259行
抛出'cv::Exception'实例后终止调用
what():/ home / shashank / Desktop / opencv-2.4.5 / modules / features2d / src / matchers.cpp:259:错误:(-215)masks [i] .rows == queryDescriptorsCount && masks [i]。 cols == trainDescCollection [i] .rows && masks [i] .type()== CV_8UC1在函数checkMasks中

经进一步查询,我们得到
先前图像957中的关键点数
下一个图像910中的关键点编号
breif描述符的大小32X880。应该是32X957
breif描述符的大小32X847。应该是32X910
蒙版[910 x 957]

代码如下

     cv::Ptr<FeatureDetector> detector=new GridAdaptedFeatureDetector(new SurfAdjuster(),keypt,noofbucketinwidth,noofbucketinlength);//surf


 //cv::Ptr<FeatureDetector> detector=new GridAdaptedFeatureDetector(new FastAdjuster(10,true),keypt,noofbucketinwidth,noofbucketinlength); //FAST

     detector->detect(img,keypointimage);
    cout<<"noof keypoint "<<keypointimage.size()<<endl;


    //for descriptor
    Mat descriptor;
     Ptr<DescriptorExtractor> extractdetector=DescriptorExtractor::create("SURF");
     Ptr<DescriptorExtractor> extractdetector=DescriptorExtractor::create("BRIEF");
        extractdetector->compute( img, detectedpoint, descriptor);

    //for matching
    if(FAST_H_prev.empty())
            FAST_H_prev = Mat::eye(3,3,CV_32FC1);

        std::vector<unsigned char> FAST_match_mask;

        if(!currentimagekeypoint.empty())
        {
            std::vector<cv::KeyPoint> test_kpts;
            warpKeypoints(FAST_H_prev.inv(), nextimagekeypoint, test_kpts);

           cv::Mat FAST_mask = windowedMatchingMask( test_kpts, currentimagekeypoint, 25, 25);
                matcher->match(Discriptorofnextimage,Discriptorofcurrentimage, FAST_matches, FAST_mask);
                      matches2points(currentimagekeypoint, nextimagekeypoint, FAST_matches, FAST_train_pts, FAST_query_pts);
            if(FAST_matches.size() > 5)
            {
                cv::Mat H = findHomography(FAST_train_pts, FAST_query_pts, RANSAC, 4, FAST_match_mask);
                if(countNonZero(Mat(FAST_match_mask)) > 15)
                    FAST_H_prev = H;
                else
                    FAST_H_prev = Mat::eye(3,3,CV_32FC1);
                               drawMatchesRelative(currentimagekeypoint, nextimagekeypoint, FAST_matches, currentimage, FAST_match_mask);

            }
        }
    else
    {
        FAST_H_prev = Mat::eye(3,3,CV_32FC1);
    }

最佳答案

在OpenCV实现中,Breif描述符删除了距离边界太近的关键点。

//Remove keypoints very close to the border
KeyPointsFilter::runByImageBorder(keypoints, image.size(), PATCH_SIZE/2 + KERNEL_SIZE/2);

一个解决方案可能是过滤代码中的关键点,然后提取描述符。

关于opencv - Breif错误,轻快的描述符opencv,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28559550/

10-12 23:07