我写了一个代码,它通过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是否有错误或我做错了什么?
解决方法
原文地址:https://www.jb51.cc/csharp/99675.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。