资源简介
c#联合halcon颜色识别
代码片段和文件信息
using HalconDotNet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 颜色识别
{
public partial class Form1 : Form
{
string picModel_Path;
string picDist_Path;
Hobject[] OTemp = new Hobject[20];
// Local iconic variables
Hobject ho_Classes ho_Image ho_ROI_0 ho_ROI_1;
Hobject ho_ROI_2 ho_ROI_3 ho_Image1 ho_ClassRegions;
Hobject ho_objectsSelected = null ho_RegionClosing = null;
Hobject ho_ConnectedRegions = null ho_SelectedRegions = null;
Hobject ho_RegionFillUp = null ho_RegionTrans = null;
// Local control variables
HTuple hv_FuseColors = new HTuple() hv_Width = new HTuple();
HTuple hv_Height = new HTuple() hv_WindowHandle = new HTuple();
HTuple hv_Row1 = new HTuple() hv_Column1 = new HTuple();
HTuple hv_Row2 = new HTuple() hv_Column2 = new HTuple();
HTuple hv_Row21 = new HTuple() hv_Column21 = new HTuple();
HTuple hv_Row12 = new HTuple() hv_Column12 = new HTuple();
HTuple hv_Row22 = new HTuple() hv_Column22 = new HTuple();
HTuple hv_Row13 = new HTuple() hv_Column13 = new HTuple();
HTuple hv_Row23 = new HTuple() hv_Column23 = new HTuple();
HTuple hv_GMMHandle = new HTuple() hv_Centers = new HTuple();
HTuple hv_Iter = new HTuple() hv_ClassLUTHandle = new HTuple();
HTuple hv_Fuse = new HTuple() hv_Area = new HTuple();
HTuple hv_Row = new HTuple() hv_Column = new HTuple();
HTuple hv_Number = new HTuple() hv_j = new HTuple();
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender EventArgs e)
{
HOperatorSet.GenEmptyObj(out ho_ROI_0);
HOperatorSet.GenEmptyObj(out ho_ROI_1);
HOperatorSet.GenEmptyObj(out ho_ROI_2);
HOperatorSet.GenEmptyObj(out ho_ROI_3);
if (HDevWindowStack.IsOpen())
{
HOperatorSet.SetDraw(HDevWindowStack.GetActive() “margin“);
}
//设置颜色为黑色
if (HDevWindowStack.IsOpen())
{
HOperatorSet.SetColor(HDevWindowStack.GetActive() “black“);
}
//设置字体样式
set_display_font(hv_WindowHandle 14 “mono“ “true“ “false“);
//在图片上显示消息
disp_message(hv_WindowHandle “使用鼠标左键框选红色,并按鼠标右键确定选择“
“window“ 12 12 “black“ “false“);
//画一个平行于坐标轴的矩形,包含图片中红色部分
hv_Row1.Dispose(); hv_Column1.Dispose(); hv_Row2.Dispose(); hv_Column2.Dispose();
HOperatorSet.DrawRectangle1(hv_WindowHandle out hv_Row1 out hv_Column1 out hv_Row2
out hv_Column2);
//用刚才选中的区域创建一个与坐标轴平行的矩形
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4438 2020-04-01 12:00 颜色识别\1.png
文件 2793 2020-04-01 12:00 颜色识别\2.png
文件 2875 2020-04-01 13:40 颜色识别\3.png
文件 4438 2020-04-01 12:00 颜色识别\bin\Debug\1.png
文件 2793 2020-04-01 12:00 颜色识别\bin\Debug\2.png
文件 2875 2020-04-01 13:40 颜色识别\bin\Debug\3.png
文件 1516040 2019-05-28 17:36 颜色识别\bin\Debug\halcondotnet.dll
文件 4555857 2019-05-28 17:16 颜色识别\bin\Debug\halcondotnet.xm
文件 20992 2020-04-01 13:50 颜色识别\bin\Debug\颜色识别.exe
文件 32256 2020-04-01 13:50 颜色识别\bin\Debug\颜色识别.pdb
文件 21680 2020-04-01 13:50 颜色识别\bin\Debug\颜色识别.vshost.exe
文件 490 2014-01-13 21:31 颜色识别\bin\Debug\颜色识别.vshost.exe.manifest
文件 33438 2020-04-01 13:45 颜色识别\Form1.cs
文件 6391 2020-04-01 13:45 颜色识别\Form1.Designer.cs
文件 6022 2020-04-01 13:45 颜色识别\Form1.resx
文件 10795 2020-04-01 11:16 颜色识别\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7535 2020-04-01 13:40 颜色识别\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 1144 2020-04-01 13:50 颜色识别\obj\Debug\颜色识别.csproj.FileListAbsolute.txt
文件 847 2020-04-01 13:45 颜色识别\obj\Debug\颜色识别.csproj.GenerateResource.Cache
文件 13029 2020-03-30 08:36 颜色识别\obj\Debug\颜色识别.csprojResolveAssemblyReference.cache
文件 20992 2020-04-01 13:50 颜色识别\obj\Debug\颜色识别.exe
文件 180 2020-04-01 13:50 颜色识别\obj\Debug\颜色识别.Form1.resources
文件 32256 2020-04-01 13:50 颜色识别\obj\Debug\颜色识别.pdb
文件 180 2020-04-01 13:50 颜色识别\obj\Debug\颜色识别.Properties.Resources.resources
文件 493 2020-03-30 08:15 颜色识别\Program.cs
文件 1332 2020-03-30 08:15 颜色识别\Properties\AssemblyInfo.cs
文件 2837 2020-03-30 08:15 颜色识别\Properties\Resources.Designer.cs
文件 5612 2020-03-30 08:15 颜色识别\Properties\Resources.resx
文件 1099 2020-03-30 08:15 颜色识别\Properties\Settings.Designer.cs
文件 249 2020-03-30 08:15 颜色识别\Properties\Settings.settings
............此处省略12个文件信息
- 上一篇:飞行棋游戏-开发笔记(附源码)
- 下一篇:简单tcp 通讯网口工具客户端
评论
共有 条评论