没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ViewWindow;
using HalconDotNet;
using System.Threading;
namespace OCR_Matching_Correlation_Based_Read_Image_SD
{
public partial class Form1 : Form
{
//声明变量
HObject template_Image = null;
HObject gray_template_Image = null;
HObject model_ROI = null;
HObject reduced_Image = null;
HObject AcqImage = null;
HObject ho_Image = null;
HObject snap_Image = null;
HObject gray_ho_Image = null;
HObject current_model_Image = null;
HTuple Row = null, Column = null, Angle = null, Score = null;
HTuple CenterRow, CenterColumn, Phi, Length1, Length2;
HTuple Row1, Column1, Row2, Column2;
HTuple ImageWidth = null, ImageHeight = null;
HTuple RecWidth = null, RecHeight = null;
HTuple ModelID = null;
private HalconWindow wch = new HalconWindow();
HOperatorSet ho = new HOperatorSet();
Double MatchingScore = 0.0;
Double[] ArrayScore = new Double[10];
Double ZoomRatio = 0.0;
Double WindowWidth = 0.0;
HTuple AcqHandle = null;
int SnapCMD = 0;
bool StartMatchingCMD = false;
String TemplatePath;
String ModelPath;
HalconWindow hw = new HalconWindow();
Thread Thread1;
public Form1() //窗体 1 构造函数
{
InitializeComponent();
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
hWindowControl1.HalconWindow.SetColor("red");
hWindowControl1.HalconWindow.SetDraw("margin");
hWindowControl2.HalconWindow.SetColor("red");
hWindowControl2.HalconWindow.SetDraw("margin");
hWindowControl3.HalconWindow.SetColor("red");
hWindowControl3.HalconWindow.SetDraw("margin");
WindowWidth = Convert.ToDouble(WinSizeBox.Text);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void OpenCameraButton_Click(object sender, EventArgs e) //打开相机
按钮操作
{
Thread1 = new Thread(OpenFrame);
Thread1.Start();
}
void OpenFrame() //采集图像
{
HOperatorSet.GenEmptyObj(out AcqImage);
AcqImage.Dispose();
HOperatorSet.OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8,
"rgb", -1, "false", "default", "[0] Camera MV-U300#FC345154-3", 0, -1, out AcqHandle);
//MindVision USB2.0 相机
//HOperatorSet.OpenFramegrabber("GigEVision", 0, 0, 0, 0, 0, 0, "default", -1,
"default", -1, "false", "default", "Cam0", 0, -1, out AcqHandle); //大恒水星 GigE 相机
//HOperatorSet.SetFramegrabberParam(AcqHandle, "ExposureTime", 1000.0);
HOperatorSet.GrabImageStart(AcqHandle, -1);
while (true)
{
HOperatorSet.GrabImageAsync(out AcqImage, AcqHandle, -1);
HOperatorSet.GetImageSize(AcqImage, out ImageWidth, out
ImageHeight);
hWindowControl2.HalconWindow.SetPart((HTuple)0, (HTuple)0,
ImageHeight - 1, ImageWidth - 1);
HOperatorSet.DispObj(AcqImage, hWindowControl2.HalconWindow);
if(SnapCMD == 1) //截取当前图片
{
SnapCMD = 0;
HOperatorSet.GenEmptyObj(out snap_Image);
snap_Image.Dispose();
HOperatorSet.CopyImage(AcqImage, out snap_Image);
HOperatorSet.GenEmptyObj(out template_Image);
HOperatorSet.GenEmptyObj(out gray_template_Image);
template_Image.Dispose();
剩余11页未读,继续阅读
AI_DL_CODE
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页