当前位置:网站首页>视觉系统设计实例(halcon-winform)-8.匹配查找
视觉系统设计实例(halcon-winform)-8.匹配查找
2022-07-22 05:02:00 【11eleven】
根据图像的轮廓模板标定来进行图像匹配查找检测有无是视觉检测中最为常见的需求之一,
1.进行示例图的局部位置进行轮廓标定生成。
2.设置查找区域,加快查找效率,以及设置一些其他运行参数。
3.进行多图查找试运行。
创建模板
public int Creattemplate()
{
if (templateRegion != null)
{
if (Regionmask != null)
{
HOperatorSet.Difference(templateRegion, Regionmask, out templateRegion);
}
HOperatorSet.ReduceDomain(template, templateRegion, out reducedImage);
}
HTuple areatmp, rowtmp, coltmp;
HOperatorSet.AreaCenter(templateRegion, out areatmp, out rowtmp, out coltmp);
Point benchtmp = new Point(coltmp.D, rowtmp.D);
SetBenchmark(benchtmp);
if (reducedImage != null)
{
try
{
HOperatorSet.CreateScaledShapeModel(reducedImage,
autoNumberlevel ? (HTuple)"auto" : (HTuple)Numberlevel,
((HTuple)startAngle).TupleRad(),
((HTuple)angleRange - startAngle).TupleRad(),
(HTuple)("auto"),
minScale,
maxScale,
"auto",
(HTuple)"auto",
(HTuple)polarity,
(HTuple)"auto" ,
autocontrast ? (HTuple)"auto" : (HTuple)contrast,
out modelID);
HOperatorSet.GetShapeModelContours(out ModelContours, modelID, (HTuple)1);
HTuple _homMat2D;
HOperatorSet.HomMat2dIdentity(out _homMat2D);
//HOperatorSet.HomMat2dRotate(_homMat2D, ((HTuple)(angle)).TupleRad(), (HTuple)templatePose.Point.X, (HTuple)templatePose.Point.Y, out _homMat2D);
HOperatorSet.HomMat2dTranslate(_homMat2D, rowtmp, coltmp, out _homMat2D);
HOperatorSet.AffineTransContourXld(ModelContours, out ModelContours, _homMat2D);
//HOperatorSet.WriteContourXldDxf(ModelContours, "D:/pic/test/ewew.dxf");
HTuple hv_NumLevels = new HTuple();
HTuple hv_AngleStart = new HTuple(), hv_AngleExtent = new HTuple();
HTuple hv_AngleStep = new HTuple(), hv_ScaleMin = new HTuple();
HTuple hv_ScaleMax = new HTuple(), hv_ScaleStep = new HTuple();
HTuple hv_Metric = new HTuple(), hv_MinContrast = new HTuple();
HOperatorSet.GetShapeModelParams(modelID, out hv_NumLevels, out hv_AngleStart,
out hv_AngleExtent, out hv_AngleStep, out hv_ScaleMin, out hv_ScaleMax,
out hv_ScaleStep, out hv_Metric, out hv_MinContrast);
SetNumberlevel(hv_NumLevels.I);
Setcontrast(hv_MinContrast.I);
//HOperatorSet.WriteShapeModel(modelID, "D:/pic/test/shapemodel");
}
catch (Exception ex)
{
if (ex.Message.Contains("#8510:")) //特征过少,Halcon报错编号8510
{
//Frm_MatchTool.Instance.lbl_toolTip.Text = "状态:" + "特征过少,无法完成训练(错误代码:0201)";
return 1;
}
}
}
else
{
status = false;
return -1;
}
return 0;
}
查找匹配
HSystem.SetSystem("temporary_mem_cache", "false");
HOperatorSet.FindScaledShapeModel(image,
modelID,
((HTuple)startAngle).TupleRad(),
((HTuple)angleRange - startAngle).TupleRad(),
minScale,
maxScale,
(HTuple)minScore,
(HTuple)matchNum,
(HTuple)0.5,
(HTuple)"least_squares",
(HTuple)0,
(HTuple)0.9,
out hv_Row,
out hv_Column,
out hv_Angle,
out hv_Scale,
out hv_Score);
HOperatorSet.ClearShapeModel(modelID);
边栏推荐
- High number_ Chapter 3 multiple integration
- 把握机器人教育朝AI智能化发展的趋势
- TensorFlow 各优化器在鸢尾花分类任务中的应用
- CF464E The Classic Problem
- 力扣每日一题-第41天-125. 验证回文串
- Problems encountered in taking over RN project and solutions for self use
- QDataStream
- STM32 tutorial on using various sensors
- Li Kou daily question - day 41 -125. Verify the palindrome string
- [leetcode weekly race -- hash table number pairs] 6164. Maximum sum of digit and equal number pairs
猜你喜欢
UE4 设置夜晚(根据DirectionalLight方向更新SkySphere)
UE4 合并静态网格体
Fundamentals of machine learning (5) image outline
QDataStream
UE4 键盘按键实现开关门
梅科尔工作室——HarmonyOs第二次作业
How to solve the problem of win10? The app store cannot be opened, and the error code is 0x80131500
How to install a pagoda on IBM's free machine
Large file slice upload and breakpoint continuation
[JS] scope and scope chain
随机推荐
The Prospectus has written "yuancosmos" 318 times! Feitian Yundong fights Hong Kong stocks again "yuancosmos first share"“
ARC110E Shorten ABC
关于promise then的连续链式使用问题
[ARC116F] Deque Game
How to solve the problem of win10? The app store cannot be opened, and the error code is 0x80131500
15_额外的模型
Complex network modeling (network robustness)
BUUCTFReservewp(3)
AT4379 [AGC027E] ABBreviate
UE4 通过按键升降电梯
AT1225 かかし
【Unity】 UI跟随3D物体,世界坐标转UI坐标
ES6中的一些新特性
A Mobile Telematics Pattern Recognition Framework for Driving Behavior Extraction
跨域问题(CORS)详细说明和解决
UE4 键盘按键实现开关门
Bryntum Scheduler Pro 5.0.6 \Gantt\Crack
AlterNet Studio 8.1 Crack
还在写增删改查代码?直接一键生成
PHP二维码解码QrReader类|二维码图片转字符串