项目编号:【181427】
利用C# winform .net framework结合opencvsharp开发基于灰度匹配与基于形状匹配算法,还需要有找圆、找矩形与找线功能,还需要blob分析,需要适当的图像预处理,例如图像偏黑与偏亮不影响匹配效果、膨胀、腐蚀、……等常用的预处理,需要提供设置界面,例如基于形状匹配设置时,需要显示边界线以及添加或删除边界线,右键确定等常规的操作,是否启用角度匹配、是否启用多目标匹配,预处理项的启用与先后顺序的设置等。需要效率、稳定性与精度兼顾
现有的图像处理调用格式如下:
public short MatchFinder(byte[] btSearch, TTemplateData templateData, RectangleF srcRect, int W, int H, ref TMatchRet MatchRet, string TempPath, int count, bool bSave = false)
{
if (templateData.MatchType == 1)
{
byte[] path = System.Text.Encoding.Default.GetBytes(TempPath);
int l = (int)Math.Round(templateData.rectSearch.X * W);
int t = (int)Math.Round(templateData.rectSearch.Y * H);
int r = (int)Math.Round(templateData.rectSearch.Width * W) + l;
int d = (int)Math.Round(templateData.rectSearch.Height * H) + t;
double resultX = 0, resultY = 0, angle = 0;
bool bOk = DLL.FindShapeModel(l, t, r, d, W, H, btSearch, path, ref resultX, ref resultY, ref angle);//基于形状的模板匹配
if (bSave)//mark点在外面设置的,当设置参数时,需要这个save值来确定模板定位与mark之间的相对位置
{
MatchRet.X = (float)resultX;
MatchRet.Y = (float)resultY;
}
else
{
MatchRet.X = (float)resultX + (templateData.ptMark.X - templateData.rectTemplate.X) * W;
MatchRet.Y = (float)resultY + (templateData.ptMark.Y - templateData.rectTemplate.Y) * H;
}
MatchRet.Ang = (float)angle;
MatchRet.Rst = bOk;
}
else
{
GrayMatch grayMatch = new GrayMatch();
grayMatch.PerformGrayMatch(btSearch, W, H, templateData, srcRect, ref MatchRet);
}
需要提供源代码