using HalconDotNet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 填充工作站
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Socket socketwatch = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Socket socketsend;
byte[] sendbyte = new byte[1024];
HObject image = new HObject();
string send = null;
string recv = null;
string imageaddress;
HTuple hv_pointxy = new HTuple();
byte[] receivebyte = new byte[1024];
HTuple wide;
HTuple hight;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "请选取一张图片";
openFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.png, *.gif) | *.jpg; *.jpeg; *.png; *.gif";
openFileDialog.ShowDialog();
imageaddress = openFileDialog.FileName;
ShowMsg(imageaddress);
HOperatorSet.ReadImage(out image, imageaddress);
HOperatorSet.GetImageSize(image, out wide, out hight);
HOperatorSet.SetPart(hWindowControl1.HalconWindow, 0, 0, hight, wide);
HOperatorSet.DispObj(image, hWindowControl1.HalconWindow);
}
public void ShowMsg(string str)
{
if (richTextBox1.InvokeRequired)
{
richTextBox1.Invoke(new MethodInvoker(delegate { richTextBox1.AppendText(str + "\r\n"); }));
}
else
{
richTextBox1.AppendText(str + "\r\n");
}
}
///打开服务器
private void button2_Click(object sender, EventArgs e)
{
IPAddress iP = IPAddress.Parse(textBox1.Text);
int port = int.Parse(textBox2.Text);
IPEndPoint point = new IPEndPoint(iP, port);
socketwatch.Bind(point);
ShowMsg("服务器开启,等待连接");
socketwatch.Listen(100);
Task.Run(() =>
{
socketsend = socketwatch.Accept();
ShowMsg(socketsend.RemoteEndPoint.ToString() + "——连接成功");
Thread th1 = new Thread(receiveprocess);
th1.IsBackground = true;
th1.Start();
});
}
public void receiveprocess()
{
while (true)
{
int r = socketsend.Receive(receivebyte);
recv = Encoding.UTF8.GetString(receivebyte, 0, r);
if (recv != "")
{
ShowMsg(socketsend.RemoteEndPoint +"发来——"+ recv);
}
}
}
private void button3_Click(object sender, EventArgs e)
{
HObject ho_GrayImage, ho_ImageMedian;
HObject ho_Region, ho_RegionFillUp, ho_RegionOpening, ho_RegionClosing;
HObject ho_Rectangle = null, ho_RegionIntersection = null, ho_RegionClosing1 = null;
HObject ho_Cross;
// Local control variables
HTuple hv_Row1 = new HTuple(), hv_Column1 = new HTuple();
HTuple hv_Row2 = new HTuple(), hv_Column2 = new HTuple();
HTuple hv_reclenwidth = new HTuple();
HTuple hv_str = new HTuple(), hv_x = new HTuple(), hv_y = new HTuple();
HTuple hv_n = new HTuple(), hv_Rows = new HTuple(), hv_Columns = new HTuple();
HTuple hv_Length = new HTuple();
// Initialize local and output iconic variables
HOperatorSet.GenEmptyObj(out ho_GrayImage);
HOperatorSet.GenEmptyObj(out ho_ImageMedian);
HOperatorSet.GenEmptyObj(out ho_Region);
HOperatorSet.GenEmptyObj(out ho_RegionFillUp);
HOperatorSet.GenEmptyObj(out ho_RegionOpening);
HOperatorSet.GenEmptyObj(out ho_RegionClosing);
HOperatorSet.GenEmptyObj(out ho_Rectangle);
HOperatorSet.GenEmptyObj(out ho_RegionIntersection);
HOperatorSet.GenEmptyObj(out ho_RegionClosing1);
HOperatorSet.GenEmptyObj(out ho_Cross);
HOperatorSet.Rgb1ToGray(image, out ho_GrayImage);
ho_ImageMedian.Dispose();
HOperatorSet.MedianImage(ho_GrayImage, out ho_ImageMedian, "circle", 1, "mirrored");
ho_Region.Dispose();
HOperatorSet.Threshold(ho_ImageMedian, out ho_Region, 0, 50);
ho_RegionFillUp.Dispose();
HOperatorSet.FillUp(ho_Region, out ho_RegionFillUp);
ho_RegionOpening.Dispose();
HOperatorSet.OpeningCircle(ho_RegionFillUp, out ho_RegionOpening, 30);
ho_RegionClosing.Dispose();
HOperatorSet.ClosingCircle(ho_RegionOpening, out ho_RegionClosing, 30);
hv_Row1.Dispose(); hv_Column1.Dispose(); hv_Row2.Dispose(); hv_Column2.Dispose();
HOperatorSet.SmallestRectangle1(ho_RegionClosing, out hv_Row1, out hv_Column1,
out hv_Row2, out hv_Column2);
hv_reclenwidth.Dispose();
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
hv_reclenwidth = (hv_Column2 - hv_Column1) + 10;
}
hv_pointxy.Dispose();
hv_pointxy = "";
hv_str.Dispose();
hv_str = "";
hv_x.Dispose();
hv_x = new HTuple();
hv_y.Dispose();
hv_y = new HTuple();
HTuple end_val14 = (hv_Row2 - hv_Row1) / 10;
HTuple step_val14 = 1;
for (hv_n = 0; hv_n.Continue(end_val14, step_val14); hv_n = hv_n.TupleAdd(step_val14))
{
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
ho_Rectangle.Dispose();
HOperatorSet.GenRectangle1(out ho_Rectangle, (hv_Row1 + 3) + (hv_n * 10), hv_Column1 - 5,
(hv_Row1 + 3) + (hv_n * 10), hv_Column2 + 5);
}
ho_RegionIntersection.Dispose();
HOperatorSet.Intersection(ho_Rectangle, ho_RegionClosing, out ho_RegionIntersection
);
ho_RegionClosing1.Dispose();
HOperatorSet.ClosingRectangle1(ho_RegionIntersection, out ho_RegionClosing1,
hv_reclenwidth, 1);
hv_Rows.Dispose(); hv_Columns.Dispose();
HOperatorSet.GetRegionPoints(ho_RegionClosing1, out hv_Rows, out hv_Columns);
hv_Length.Dispose();
HOperatorSet.TupleLength(hv_Columns, out hv_Length);
if ((int)(new HTuple(hv_Length.TupleLess(3))) != 0)
{
continue;
}
if ((int)(new HTuple((((hv_n + 1) % 2)).TupleEqual(1))) != 0)
{
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
{
HTuple
ExpTmpLocalVar_pointxy = (((((((hv_pointxy + (hv_Rows.TupleSelect(
0))) + new HTuple(",")) + (hv_Columns.TupleSelect(0))) + new HTuple(",")) + (hv_Rows.TupleSelect(
hv_Length - 1))) + new HTuple(",")) + (hv_Columns.TupleSelect(hv_Length - 1))) + new HTuple(",");
hv_pointxy.Dispose();
hv_poin
没有合适的资源?快使用搜索试试~ 我知道了~
halcon+c#+abb机器人使用socket通讯组成的激光熔覆视觉工作站包
共61个文件
cs:9个
cache:8个
exe:4个
1 下载量 13 浏览量
2024-09-01
10:01:27
上传
评论
收藏 27.68MB RAR 举报
温馨提示
halcon+c#+abb机器人使用socket通讯组成的激光熔覆视觉工作站包
资源推荐
资源详情
资源评论
收起资源包目录
填充工作站包.rar (61个子文件)
ABB代码.txt 3KB
填充工作站halcon程序.hdev 2KB
ABB填充工作站.rsstn 78KB
StationBackups
ABB填充工作站_20240901-095359.rsstn 78KB
填充工作站halcon程序.cs 8KB
c#文件填充工作站
.vs
填充工作站
v16
.suo 54KB
填充工作站
Form1.Designer.cs 12KB
填充工作站.csproj.user 456B
App.config 189B
Form1.cs 12KB
obj
x64
Debug
填充工作站.csproj.FileListAbsolute.txt 2KB
填充工作站.exe 16KB
填充工作站.Form1.resources 180B
填充工作站.Properties.Resources.resources 180B
DesignTimeResolveAssemblyReferencesInput.cache 7KB
填充工作站.csproj.CoreCompileInputs.cache 42B
填充工作站.pdb 42KB
TempPE
填充工作站.exe.manifest 4KB
填充工作站.application 2KB
.NETFramework,Version=v4.7.2.AssemblyAttributes.cs 214B
填充工作站.csproj.GenerateResource.cache 1012B
填充工作站.csproj.AssemblyReference.cache 552B
DesignTimeResolveAssemblyReferences.cache 2KB
Debug
DesignTimeResolveAssemblyReferencesInput.cache 7KB
TempPE
.NETFramework,Version=v4.7.2.AssemblyAttributes.cs 214B
填充工作站.csproj.AssemblyReference.cache 11B
DesignTimeResolveAssemblyReferences.cache 277B
填充工作站.csproj 6KB
bin
Release
x64
Debug
填充工作站.exe 16KB
app.publish
填充工作站.exe 17KB
填充工作站.pdb 42KB
填充工作站.exe.config 189B
hcanvas.dll 3.9MB
halcondotnet.dll 1.51MB
填充工作站.exe.manifest 4KB
填充工作站.application 2KB
halcon.dll 75.55MB
Debug
Properties
Resources.Designer.cs 3KB
Settings.Designer.cs 1KB
Settings.settings 249B
AssemblyInfo.cs 1KB
Resources.resx 5KB
Program.cs 527B
填充工作站_TemporaryKey.pfx 2KB
Form1.resx 7KB
填充工作站.sln 1KB
c#代码.txt 12KB
winform发布文件
.vs
ProjectSettings.json 37B
slnx.sqlite 88KB
填充工作站
v16
.suo 35KB
v17
DocumentLayout.json 549B
.suo 57KB
FileContentIndex
1795d8cc-8071-4b8a-b7c5-538b965f38a6.vsidx 48KB
VSWorkspaceState.json 130B
Application Files
填充工作站_1_0_0_0
填充工作站.exe.deploy 17KB
填充工作站.exe.manifest 8KB
填充工作站.application 6KB
halcondotnet.dll.deploy 1.51MB
填充工作站.exe.config.deploy 189B
填充工作站.application 6KB
setup.exe 551KB
共 61 条
- 1
资源评论
Tianwen_Burning
- 粉丝: 250
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功