加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 由KNN计算的图像中的图形匹配对以及Features2DToolbox.Dra

发布时间:2020-12-15 07:50:58 所属栏目:百科 来源:网络整理
导读:我写了一个代码,它通过KNN算法找到K最接近的匹配.在获取matMatch和matchIndices之后,我尝试在两个结果帧之间绘制匹配对. 我将matMask和matchIndices提供给函数Features2DToolbox.DrawMatches: ImageBgr,byte imResult = Features2DToolbox.DrawMatches(imMo
我写了一个代码,它通过KNN算法找到K最接近的匹配.在获取matMatch和matchIndices之后,我尝试在两个结果帧之间绘制匹配对.

我将matMask和matchIndices提供给函数Features2DToolbox.DrawMatches:

Image<Bgr,byte> imResult = Features2DToolbox.DrawMatches(imModelCurr,imModel.keyPoints,imObserPrev,imObser.keyPoints,**matchIndices**,new Bgr(System.Drawing.Color.Yellow),new Bgr(System.Drawing.Color.Red),**matMask**,Features2DToolbox.KeypointDrawType.NOT_DRAW_SINGLE_POINTS);

http://www.emgu.com/wiki/files/2.4.0/document/html/e92d37e6-fe4a-ad09-9304-cd2d2533bfa8.htm但是我注意到它让我在配对之间得??到了错误的绘图:

然后我试着自己实现这样的功能:

for (int i = 0; i < matMask.Rows; ++i)
        {
            if (**matMask[i,0]** > 0) 
            {
                int indForCurrFrm = **matchIndices[i,0]**;
                int indForPrevFrm = i;

                //for frame i-1
                PointF fromFirstFrame = getImgObserved(keyPoints[indForPrevFrm]);

                //for frame i
                PointF NextCorrespondingMatchedFrame = getImModelXY(keyPoints[indForCurrFrm]);

                imColorPrv2.Draw(new CircleF(fromFirstFrame,5),new Bgr(mtchColor),3);// for frame i-1
                imColorShow.Draw(new CircleF(NextCorrespondingMatchedFrame,3); // for frame i

                 // draw line on my own matching
              imResult.Draw(new LineSegment2DF(fromFirstFrame,NextCorrespondingMatchedFrame),new Bgr(System.Drawing.Color.FloralWhite),1);

            }
        }

并获取相应的对点坐标(X,Y)并自己绘制[见快照结果].

一个左下角你可以看到匹配(用白线表示)和每个对应的对用一个相同颜色的圆[由我自己的功能],在另一个侧面 – 右下角,它是由Emgu的DrawMatches函数绘制的结果请注意这两个函数使用相同的matMash和matchIndices.

所以我想知道EMGU的DrawMatches是否有错误或我做错了什么?

解决方法

使用每个相应对的描述符之间的欧几里德距离来过滤来自matchIndices的最佳匹配可能非常有用.
有时,第一个图像中的一个关键点可以匹配第二个图像中的许多关键点,这可能会混淆结果中的绘制线.

过滤可能是这样的:

vector< DMatch > filtered_matches;

 for( int i = 0; i < descriptors_of_model.rows; i++ )
    { 
      if( matchIndices[i].distance < SMALL_THRESHOLD )
          filtered_matches.push_back( matchIndices[i]); 

     }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读