找传奇、传世资源到传世资源站!

C#与halcon联合编程

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

多模板匹配
from clipboard

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 HalconDotNet;using System.IO;using HalconDemo2;namespace m{ public partial class Form1 : Form { CamParam m_Cam1 = new CamParam("ccd1"); int s1 = 45, s2 = 65, h1 = 350, h2 = 410, h3 = 350, h4 = 400, eh1 = 360, eh2 = 400, eh3 = 350, eh4 = 390;//四角 int th1 = 340, th2 = 380, th3 = 340, th4 = 385;//两角 int kh1 = 350, kh2 = 400, kh3 = 350, kh4 = 400, kth1 = 350, kth2 = 400, kth3 = 350, kth4 = 400, keh1 = 350, keh2 = 400, keh3 = 350, keh4 = 400;//六角 HObject ho_Image1, ho_Regions, ho_Regions1; HObject ho_Regions2, ho_Regions3, ho_Regions4, ho_Rectangle; HObject ho_Rectangle1, ho_Rectangle2, ho_ImageReduced, ho_Image = null; HObject ho_Regions5 = null, ho_Line = null, ho_Regions6 = null; HObject ho_Regions7 = null, ho_Regions8 = null, ho_Regions9 = null; HObject ho_RegionAffineTrans = null, ho_RegionAffineTrans1 = null; // Local control variables HTuple hv_WindowHandle = new HTuple(), hv_Row1 = new HTuple(); HTuple hv_Column1 = new HTuple(), hv_Row2 = new HTuple(); HTuple hv_Column2 = new HTuple(), hv_Row11 = new HTuple(); HTuple hv_Column11 = new HTuple(), hv_Row21 = new HTuple(); HTuple hv_Column21 = new HTuple(), hv_Row12 = new HTuple(); HTuple hv_Column12 = new HTuple(), hv_Row22 = new HTuple(); HTuple hv_Column22 = new HTuple(), hv_Row13 = new HTuple(); HTuple hv_Column13 = new HTuple(), hv_Row23 = new HTuple(); HTuple hv_Column23 = new HTuple(), hv_Row14 = new HTuple(); HTuple hv_Column14 = new HTuple(), hv_Row24 = new HTuple(); HTuple hv_Column24 = new HTuple(), hv_Row = new HTuple(); HTuple hv_Column = new HTuple(), hv_Phi = new HTuple(); HTuple hv_Length1 = new HTuple(), hv_Length2 = new HTuple(); HTuple hv_Row3 = new HTuple(), hv_Column3 = new HTuple(); HTuple hv_Phi1 = new HTuple(), hv_Length11 = new HTuple(); HTuple hv_Length21 = new HTuple(), hv_Row15 = new HTuple(); HTuple hv_Column15 = new HTuple(), hv_Row25 = new HTuple(); HTuple hv_Column25 = new HTuple(), hv_Area = new HTuple(); HTuple hv_Row4 = new HTuple(), hv_Column4 = new HTuple(); HTuple hv_ModelID = new HTuple(), hv_ImageFiles = new HTuple(); HTuple hv_Index = new HTuple(), hv_Row5 = new HTuple(); HTuple hv_Column5 = new HTuple(), hv_Angle = new HTuple(); HTuple hv_Score = new HTuple(), hv_HomMat2D = new HTuple(); HTuple hv_RowTrans = new HTuple(), hv_ColTrans = new HTuple(); HTuple hv_RowTrans1 = new HTuple(), hv_ColTrans1 = new HTuple(); HTuple hv_ResultRow = new HTuple(), hv_ResultColumn = new HTuple(); HTuple hv_Row16 = new HTuple(), hv_Col1 = new HTuple(); HTuple hv_Row26 = new HTuple(), hv_Col2 = new HTuple(); HTuple hv_RowTrans2 = new HTuple(), hv_ColTrans2 = new HTuple(); HTuple hv_RowTrans3 = new HTuple(), hv_ColTrans3 = new HTuple(); HTuple hv_ResultRow1 = new HTuple(), hv_ResultColumn1 = new HTuple(); HTuple hv_Distance = new HTuple(), hv_RowTrans4 = new HTuple(); HTuple hv_ColTrans4 = new HTuple(), hv_RowTrans5 = new HTuple(); HTuple hv_ColTrans5 = new HTuple(), hv_ResultRow2 = new HTuple(); HTuple hv_ResultColumn2 = new HTuple(), hv_Distance1 = new HTuple(); HTuple hv_RowTrans6 = new HTuple(), hv_ColTrans6 = new HTuple(); HTuple hv_RowTrans7 = new HTuple(), hv_ColTrans7 = new HTuple(); HTuple hv_ResultRow3 = new HTuple(), hv_ResultColumn3 = new HTuple(); HTuple hv_Distance2 = new HTuple(), hv_RowTrans8 = new HTuple(); HTuple hv_ColTrans8 = new HTuple(), hv_RowTrans9 = new HTuple(); HTuple hv_ColTrans9 = new HTuple(), hv_ResultRow4 = new HTuple(); HTuple hv_ResultColumn4 = new HTuple(), hv_Distance3 = new HTuple(); HTuple hv_Width = new HTuple(), hv_Height = new HTuple(); HTuple hv_Row6 = new HTuple(), hv_Column6 = new HTuple(); HTuple hv_Phi2 = new HTuple(), hv_Length12 = new HTuple(); HTuple hv_Length22 = new HTuple(), hv_MeasureHandle = new HTuple(); HTuple hv_RowEdgeFirst = new HTuple(), hv_ColumnEdgeFirst = new HTuple(); HTuple hv_AmplitudeFirst = new HTuple(), hv_RowEdgeSecond = new HTuple(); HTuple hv_ColumnEdgeSecond = new HTuple(), hv_AmplitudeSecond = new HTuple(); HTuple hv_IntraDistance = new HTuple(), hv_InterDistance = new HTuple(); HTuple hv_Row7 = new HTuple(), hv_Column7 = new HTuple(); HTuple hv_Phi3 = new HTuple(), hv_Length13 = new HTuple(); HTuple hv_Length23 = new HTuple(), hv_MeasureHandle1 = new HTuple(); HTuple hv_RowEdgeFirst1 = new HTuple(), hv_ColumnEdgeFirst1 = new HTuple(); HTuple hv_AmplitudeFirst1 = new HTuple(), hv_RowEdgeSecond1 = new HTuple(); HTuple hv_ColumnEdgeSecond1 = new HTuple(), hv_AmplitudeSecond1 = new HTuple(); HTuple hv_IntraDistance1 = new HTuple(), hv_InterDistance1 = new HTuple(); HTuple hv_Mean = new HTuple(), hv_Mean1 = new HTuple(); HTuple hv_Mean2 = new HTuple(), hv_Mean3 = new HTuple(); /// <summary> /// /////////////////////////////////////////// /// </summary> /// HTuple s6; HObject ho_Image1e, ho_Regionse, ho_Regions1e; HObject ho_Regions2e, ho_Rectanglee, ho_ImageReducede; HObject ho_Regions3e = null, ho_Linee = null, ho_Regions4e = null; HObject ho_Regions5e = null; // Local control variables HTuple hv_Row1e = new HTuple(); HTuple hv_Column1e = new HTuple(), hv_Row2e = new HTuple(); HTuple hv_Column2e = new HTuple(), hv_Row11e = new HTuple(); HTuple hv_Column11e = new HTuple(), hv_Row21e = new HTuple(); HTuple hv_Column21e = new HTuple(), hv_Row12e = new HTuple(); HTuple hv_Column12e = new HTuple(), hv_Row22e = new HTuple(); HTuple hv_Column22e = new HTuple(), hv_Row13e = new HTuple(); HTuple hv_Column13e = new HTuple(), hv_Row23e = new HTuple(); HTuple hv_Column23e = new HTuple(), hv_Areae = new HTuple(); HTuple hv_Rowe = new HTuple(), hv_Columne = new HTuple(); HTuple hv_ModelIDe = new HTuple(), hv_Row3e = new HTuple(); HTuple hv_Column3e = new HTuple(), hv_Anglee = new HTuple(); HTuple hv_Scoree = new HTuple(), hv_HomMat2De = new HTuple(); HTuple hv_RowTranse = new HTuple(), hv_ColTranse = new HTuple(); HTuple hv_RowTrans1e = new HTuple(), hv_ColTrans1e = new HTuple(); HTuple hv_ResultRowe = new HTuple(), hv_ResultColumne = new HTuple(); HTuple hv_Row14e = new HTuple(), hv_Col1e = new HTuple(); HTuple hv_Row24e = new HTuple(), hv_Col2e = new HTuple(); HTuple hv_RowTrans2e = new HTuple(), hv_ColTrans2e = new HTuple(); HTuple hv_RowTrans3e = new HTuple(), hv_ColTrans3e = new HTuple(); HTuple hv_ResultRow1e = new HTuple(), hv_ResultColumn1e = new HTuple(); HTuple hv_Distancee = new HTuple(), hv_RowTrans4e = new HTuple(); HTuple hv_ColTrans4e = new HTuple(), hv_RowTrans5e = new HTuple(); HTuple hv_ColTrans5e = new HTuple(), hv_ResultRow2e = new HTuple(); HTuple hv_ResultColumn2e = new HTuple(), hv_Distance1e = new HTuple(); HTuple hv_Meane = new HTuple(), hv_Mean1e = new HTuple(); /// <summary> /// ////////////////////////////////// /// /// /// </summary> /// HTuple s; HObject ho_Image1k, ho_Regionsk, ho_Regions1k; HObject ho_Regions2k, ho_Regions3k, ho_Regions4k, ho_Regions5k; HObject ho_Regions6k, ho_Rectanglek, ho_Rectangle1k, ho_Rectangle2k; HObject ho_Rectangle3k, ho_ImageReducedk; HObject ho_Regions7k = null, ho_Linek = null, ho_Regions8k = null; HObject ho_Regions9k = null, ho_Regions10k = null, ho_Regions11k = null; HObject ho_Regions12k = null, ho_Regions13k = null, ho_RegionAffineTransk = null; HObject ho_RegionAffineTrans1k = null, ho_RegionAffineTrans2k = null; // Local control variables HTuple hv_Row1k = new HTuple(); HTuple hv_Column1k = new HTuple(), hv_Row2k = new HTuple(); HTuple hv_Column2k = new HTuple(), hv_Row11k = new HTuple(); HTuple hv_Column11k = new HTuple(), hv_Row21k = new HTuple(); HTuple hv_Column21k = new HTuple(), hv_Row12k = new HTuple(); HTuple hv_Column12k = new HTuple(), hv_Row22k = new HTuple(); HTuple hv_Column22k = new HTuple(), hv_Row13k = new HTuple(); HTuple hv_Column13k = new HTuple(), hv_Row23k = new HTuple(); HTuple hv_Column23k = new HTuple(), hv_Row14k = new HTuple(); HTuple hv_Column14k = new HTuple(), hv_Row24k = new HTuple(); HTuple hv_Column24k = new HTuple(), hv_Row15k = new HTuple(); HTuple hv_Column15k = new HTuple(), hv_Row25k = new HTuple(); HTuple hv_Column25k = new HTuple(), hv_Row16k = new HTuple(); HTuple hv_Column16k = new HTuple(), hv_Row26k = new HTuple(); HTuple hv_Column26k = new HTuple(), hv_Rowk = new HTuple(); HTuple hv_Columnk = new HTuple(), hv_Phik = new HTuple(); HTuple hv_Length1k = new HTuple(), hv_Length2k = new HTuple(); HTuple hv_Row3k = new HTuple(), hv_Column3k = new HTuple(); HTuple hv_Phi1k = new HTuple(), hv_Length11k = new HTuple(); HTuple hv_Length21k = new HTuple(), hv_Row4k = new HTuple(); HTuple hv_Column4k = new HTuple(), hv_Phi2k = new HTuple(); HTuple hv_Length12k = new HTuple(), hv_Length22k = new HTuple(); HTuple hv_Row17k = new HTuple(), hv_Column17k = new HTuple(); HTuple hv_Row27k = new HTuple(), hv_Column27k = new HTuple(); HTuple hv_Areak = new HTuple(), hv_Row5k = new HTuple(); HTuple hv_Column5k = new HTuple(), hv_ModelIDk = new HTuple(); HTuple hv_Row6k = new HTuple(), hv_Column6k = new HTuple(); HTuple hv_Anglek = new HTuple(), hv_Scorek = new HTuple(); HTuple hv_HomMat2Dk = new HTuple(), hv_RowTransk = new HTuple(); HTuple hv_ColTransk = new HTuple(), hv_RowTrans1k = new HTuple(); HTuple hv_ColTrans1k = new HTuple(), hv_ResultRowk = new HTuple(); HTuple hv_ResultColumnk = new HTuple(), hv_Row18k = new HTuple(); HTuple hv_Col1k = new HTuple(), hv_Row28k = new HTuple(); HTuple hv_Col2k = new HTuple(), hv_RowTrans2k = new HTuple(); HTuple hv_ColTrans2k = new HTuple(), hv_RowTrans3k = new HTuple(); HTuple hv_ColTrans3k = new HTuple(), hv_ResultRow1k = new HTuple(); HTuple hv_ResultColumn1k = new HTuple(), hv_Distancek = new HTuple(); HTuple hv_RowTrans4k = new HTuple(), hv_ColTrans4k = new HTuple(); HTuple hv_RowTrans5k = new HTuple(), hv_ColTrans5k = new HTuple(); HTuple hv_ResultRow2k = new HTuple(), hv_ResultColumn2k = new HTuple(); HTuple hv_Distance1k = new HTuple(), hv_RowTrans6k = new HTuple(); HTuple hv_ColTrans6k = new HTuple(), hv_RowTrans7k = new HTuple(); HTuple hv_ColTrans7k = new HTuple(), hv_ResultRow3k = new HTuple(); HTuple hv_ResultColumn3k = new HTuple(), hv_Distance2k = new HTuple(); HTuple hv_RowTrans8k = new HTuple(), hv_ColTrans8k = new HTuple(); HTuple hv_RowTrans9k = new HTuple(), hv_ColTrans9k = new HTuple(); HTuple hv_ResultRow4k = new HTuple(), hv_ResultColumn4k = new HTuple(); HTuple hv_Distance3k = new HTuple(), hv_RowTrans10k = new HTuple(); HTuple hv_ColTrans10k = new HTuple(), hv_RowTrans11k = new HTuple(); HTuple hv_ColTrans11k = new HTuple(), hv_ResultRow5k = new HTuple(); HTuple hv_ResultColumn5k = new HTuple(), hv_Distance4k = new HTuple(); HTuple hv_RowTrans12k = new HTuple(), hv_ColTrans12k = new HTuple(); HTuple hv_RowTrans13k = new HTuple(), hv_ColTrans13k = new HTuple(); HTuple hv_ResultRow6k = new HTuple(), hv_ResultColumn6k = new HTuple(); HTuple hv_Distance5k = new HTuple(), hv_Widthk = new HTuple(); HTuple hv_Heightk = new HTuple(), hv_Row7k = new HTuple(); HTuple hv_Column7k = new HTuple(), hv_Phi3k = new HTuple(); HTuple hv_Length13k = new HTuple(), hv_Length23k = new HTuple(); HTuple hv_MeasureHandlek = new HTuple(), hv_RowEdgeFirstk = new HTuple(); HTuple hv_ColumnEdgeFirstk = new HTuple(), hv_AmplitudeFirstk = new HTuple(); HTuple hv_RowEdgeSecondk = new HTuple(), hv_ColumnEdgeSecondk = new HTuple(); HTuple hv_AmplitudeSecondk = new HTuple(), hv_IntraDistancek = new HTuple(); HTuple hv_InterDistancek = new HTuple(), hv_Row8k = new HTuple(); HTuple hv_Column8k = new HTuple(), hv_Phi4k = new HTuple(); HTuple hv_Length14k = new HTuple(), hv_Length24k = new HTuple(); HTuple hv_MeasureHandle1k = new HTuple(), hv_RowEdgeFirst1k = new HTuple(); HTuple hv_ColumnEdgeFirst1k = new HTuple(), hv_AmplitudeFirst1k = new HTuple(); HTuple hv_RowEdgeSecond1k = new HTuple(), hv_ColumnEdgeSecond1k = new HTuple(); HTuple hv_AmplitudeSecond1k = new HTuple(), hv_IntraDistance1k = new HTuple(); HTuple hv_InterDistance1k = new HTuple(), hv_Row9k = new HTuple(); HTuple hv_Column9k = new HTuple(), hv_Phi5k = new HTuple(); HTuple hv_Length15k = new HTuple(), hv_Length25k = new HTuple(); HTuple hv_MeasureHandle2k = new HTuple(), hv_RowEdgeFirst2k = new HTuple(); HTuple hv_ColumnEdgeFirst2k = new HTuple(), hv_AmplitudeFirst2k = new HTuple(); HTuple hv_RowEdgeSecond2k = new HTuple(), hv_ColumnEdgeSecond2k = new HTuple(); HTuple hv_AmplitudeSecond2k = new HTuple(), hv_IntraDistance2k = new HTuple(); HTuple hv_InterDistance2k = new HTuple(), hv_Meank = new HTuple(); HTuple hv_Mean1k = new HTuple(), hv_Mean2k = new HTuple(); HTuple hv_Mean3k = new HTuple(), hv_Mean4k = new HTuple(); HTuple hv_Mean5k = new HTuple(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { textBox1.Text = Convert.ToString(s1); textBox2.Text = Convert.ToString(s2); textBox3.Text = Convert.ToString(h1); textBox4.Text = Convert.ToString(h2); textBox5.Text = Convert.ToString(h3); textBox6.Text = Convert.ToString(h4); textBox7.Text = Convert.ToString(th1); textBox8.Text = Convert.ToString(th2); textBox9.Text = Convert.ToString(th3); textBox10.Text = Convert.ToString(th4); textBox11.Text = Convert.ToString(eh1); textBox12.Text = Convert.ToString(eh2); textBox13.Text = Convert.ToString(eh3); textBox14.Text = Convert.ToString(eh4); textBox15.Text = Convert.ToString(kh1); textBox16.Text = Convert.ToString(kh2); textBox17.Text = Convert.ToString(kh3); textBox18.Text = Convert.ToString(kh4); textBox19.Text = Convert.ToString(kth1); textBox20.Text = Convert.ToString(kth2); textBox21.Text = Convert.ToString(kth3); textBox22.Text = Convert.ToString(kth4); textBox23.Text = Convert.ToString(keh1); textBox24.Text = Convert.ToString(keh2); textBox25.Text = Convert.ToString(keh3); textBox26.Text = Convert.ToString(keh4); hv_WindowHandle=hWindowControl1.HalconWindow; HOperatorSet.SetSystem("width", 512); HOperatorSet.SetSystem("height", 512); HOperatorSet.SetDraw(hv_WindowHandle, "margin"); HOperatorSet.SetColor(hv_WindowHandle, "red"); HOperatorSet.GenEmptyObj(out ho_Image1); HOperatorSet.GenEmptyObj(out ho_Regions); HOperatorSet.GenEmptyObj(out ho_Regions1); HOperatorSet.GenEmptyObj(out ho_Regions2); HOperatorSet.GenEmptyObj(out ho_Regions3); HOperatorSet.GenEmptyObj(out ho_Regions4); HOperatorSet.GenEmptyObj(out ho_Rectangle); HOperatorSet.GenEmptyObj(out ho_Rectangle1); HOperatorSet.GenEmptyObj(out ho_Rectangle2); HOperatorSet.GenEmptyObj(out ho_ImageReduced); HOperatorSet.GenEmptyObj(out ho_Image); HOperatorSet.GenEmptyObj(out ho_Regions5); HOperatorSet.GenEmptyObj(out ho_Line); HOperatorSet.GenEmptyObj(out ho_Regions6); HOperatorSet.GenEmptyObj(out ho_Regions7); HOperatorSet.GenEmptyObj(out ho_Regions8); HOperatorSet.GenEmptyObj(out ho_Regions9); HOperatorSet.GenEmptyObj(out ho_RegionAffineTrans); HOperatorSet.GenEmptyObj(out ho_RegionAffineTrans1); //////////////////////////// ////////////////////////////// HOperatorSet.GenEmptyObj(out ho_Image1e); HOperatorSet.GenEmptyObj(out ho_Regionse); HOperatorSet.GenEmptyObj(out ho_Regions1e); HOperatorSet.GenEmptyObj(out ho_Regions2e); HOperatorSet.GenEmptyObj(out ho_Rectanglee); HOperatorSet.GenEmptyObj(out ho_ImageReducede); HOperatorSet.GenEmptyObj(out ho_Regions3e); HOperatorSet.GenEmptyObj(out ho_Linee); HOperatorSet.GenEmptyObj(out ho_Regions4e); HOperatorSet.GenEmptyObj(out ho_Regions5e); ////////////////////////////////// /////////////////////////// //////////// HOperatorSet.GenEmptyObj(out ho_Image1k); HOperatorSet.GenEmptyObj(out ho_Regionsk); HOperatorSet.GenEmptyObj(out ho_Regions1k); HOperatorSet.GenEmptyObj(out ho_Regions2k); HOperatorSet.GenEmptyObj(out ho_Regions3k); HOperatorSet.GenEmptyObj(out ho_Regions4k); HOperatorSet.GenEmptyObj(out ho_Regions5k); HOperatorSet.GenEmptyObj(out ho_Regions6k); HOperatorSet.GenEmptyObj(out ho_Rectanglek); HOperatorSet.GenEmptyObj(out ho_Rectangle1k); HOperatorSet.GenEmptyObj(out ho_Rectangle2k); HOperatorSet.GenEmptyObj(out ho_Rectangle3k); HOperatorSet.GenEmptyObj(out ho_ImageReducedk); HOperatorSet.GenEmptyObj(out ho_Image); HOperatorSet.GenEmptyObj(out ho_Regions7k); HOperatorSet.GenEmptyObj(out ho_Linek); HOperatorSet.GenEmptyObj(out ho_Regions8k); HOperatorSet.GenEmptyObj(out ho_Regions9k); HOperatorSet.GenEmptyObj(out ho_Regions10k); HOperatorSet.GenEmptyObj(out ho_Regions11k); HOperatorSet.GenEmptyObj(out ho_Regions12k); HOperatorSet.GenEmptyObj(out ho_Regions13k); HOperatorSet.GenEmptyObj(out ho_RegionAffineTransk); HOperatorSet.GenEmptyObj(out ho_RegionAffineTrans1k); HOperatorSet.GenEmptyObj(out ho_RegionAffineTrans2k); //try //{ // HOperatorSet.CloseAllFramegrabbers(); // //千兆网相机,换相机,需要更新相机名m_Cam1.m_Name // m_Cam1.m_Name = "ccd1"; // HOperatorSet.OpenFramegrabber("GigEvision2", 0, 0, 0, 0, 0, 0, "default", -1, "default", -1, "false", "default", // m_Cam1.m_Name, 0, -1, out m_Cam1.m_AcqHandle); // m_Cam1.m_bCamlsOK = true; //} //catch (Exception ex) //{ // MessageBox.Show("连接相机失败"); // m_Cam1.m_bCamlsOK = false; // m_Cam1.m_AcqHandle = null; //} } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { ho_Image1.Dispose(); ho_Regions.Dispose(); ho_Regions1.Dispose(); ho_Regions2.Dispose(); ho_Regions3.Dispose(); ho_Regions4.Dispose(); ho_Rectangle.Dispose(); ho_Rectangle1.Dispose(); ho_Rectangle2.Dispose(); ho_ImageReduced.Dispose(); ho_Image.Dispose(); ho_Regions5.Dispose(); ho_Line.Dispose(); ho_Regions6.Dispose(); ho_Regions7.Dispose(); ho_Regions8.Dispose(); ho_Regions9.Dispose(); ho_RegionAffineTrans.Dispose(); ho_RegionAffineTrans1.Dispose(); hv_WindowHandle.Dispose(); hv_Row1.Dispose(); hv_Column1.Dispose(); hv_Row2.Dispose(); hv_Column2.Dispose(); hv_Row11.Dispose(); hv_Column11.Dispose(); hv_Row21.Dispose(); hv_Column21.Dispose(); hv_Row12.Dispose(); hv_Column12.Dispose(); hv_Row22.Dispose(); hv_Column22.Dispose(); hv_Row13.Dispose(); hv_Column13.Dispose(); hv_Row23.Dispose(); hv_Column23.Dispose(); hv_Row14.Dispose(); hv_Column14.Dispose(); hv_Row24.Dispose(); hv_Column24.Dispose(); hv_Row.Dispose(); hv_Column.Dispose(); hv_Phi.Dispose(); hv_Length1.Dispose(); hv_Length2.Dispose(); hv_Row3.Dispose(); hv_Column3.Dispose(); hv_Phi1.Dispose(); hv_Length11.Dispose(); hv_Length21.Dispose(); hv_Row15.Dispose(); hv_Column15.Dispose(); hv_Row25.Dispose(); hv_Column25.Dispose(); hv_Area.Dispose(); hv_Row4.Dispose(); hv_Column4.Dispose(); hv_ModelID.Dispose(); hv_ImageFiles.Dispose(); hv_Index.Dispose(); hv_Row5.Dispose(); hv_Column5.Dispose(); hv_Angle.Dispose(); hv_Score.Dispose(); hv_HomMat2D.Dispose(); hv_RowTrans.Dispose(); hv_ColTrans.Dispose(); hv_RowTrans1.Dispose(); hv_ColTrans1.Dispose(); hv_ResultRow.Dispose(); hv_ResultColumn.Dispose(); hv_Row16.Dispose(); hv_Col1.Dispose(); hv_Row26.Dispose(); hv_Col2.Dispose(); hv_RowTrans2.Dispose(); hv_ColTrans2.Dispose(); hv_RowTrans3.Dispose(); hv_ColTrans3.Dispose(); hv_ResultRow1.Dispose(); hv_ResultColumn1.Dispose(); hv_Distance.Dispose(); hv_RowTrans4.Dispose(); hv_ColTrans4.Dispose(); hv_RowTrans5.Dispose(); hv_ColTrans5.Dispose(); hv_ResultRow2.Dispose(); hv_ResultColumn2.Dispose(); hv_Distance1.Dispose(); hv_RowTrans6.Dispose(); hv_ColTrans6.Dispose(); hv_RowTrans7.Dispose(); hv_ColTrans7.Dispose(); hv_ResultRow3.Dispose(); hv_ResultColumn3.Dispose(); hv_Distance2.Dispose(); hv_RowTrans8.Dispose(); hv_ColTrans8.Dispose(); hv_RowTrans9.Dispose(); hv_ColTrans9.Dispose(); hv_ResultRow4.Dispose(); hv_ResultColumn4.Dispose(); hv_Distance3.Dispose(); hv_Width.Dispose(); hv_Height.Dispose(); hv_Row6.Dispose(); hv_Column6.Dispose(); hv_Phi2.Dispose(); hv_Length12.Dispose(); hv_Length22.Dispose(); hv_MeasureHandle.Dispose(); hv_RowEdgeFirst.Dispose(); hv_ColumnEdgeFirst.Dispose(); hv_AmplitudeFirst.Dispose(); hv_RowEdgeSecond.Dispose(); hv_ColumnEdgeSecond.Dispose(); hv_AmplitudeSecond.Dispose(); hv_IntraDistance.Dispose(); hv_InterDistance.Dispose(); hv_Row7.Dispose(); hv_Column7.Dispose(); hv_Phi3.Dispose(); hv_Length13.Dispose(); hv_Length23.Dispose(); hv_MeasureHandle1.Dispose(); hv_RowEdgeFirst1.Dispose(); hv_ColumnEdgeFirst1.Dispose(); hv_AmplitudeFirst1.Dispose(); hv_RowEdgeSecond1.Dispose(); hv_ColumnEdgeSecond1.Dispose(); hv_AmplitudeSecond1.Dispose(); hv_IntraDistance1.Dispose(); hv_InterDistance1.Dispose(); hv_Mean.Dispose(); hv_Mean1.Dispose(); hv_Mean2.Dispose(); hv_Mean3.Dispose(); ////////////// ///////// ////// ho_Image1e.Dispose(); ho_Regionse.Dispose(); ho_Regions1e.Dispose(); ho_Regions2e.Dispose(); ho_Rectanglee.Dispose(); ho_ImageReducede.Dispose(); ho_Regions3e.Dispose(); ho_Linee.Dispose(); ho_Regions4e.Dispose(); ho_Regions5e.Dispose(); hv_Row1e.Dispose(); hv_Column1e.Dispose(); hv_Row2e.Dispose(); hv_Column2e.Dispose(); hv_Row11e.Dispose(); hv_Column11e.Dispose(); hv_Row21e.Dispose(); hv_Column21e.Dispose(); hv_Row12e.Dispose(); hv_Column12e.Dispose(); hv_Row22e.Dispose(); hv_Column22e.Dispose(); hv_Row13e.Dispose(); hv_Column13e.Dispose(); hv_Row23e.Dispose(); hv_Column23e.Dispose(); hv_Areae.Dispose(); hv_Rowe.Dispose(); hv_Columne.Dispose(); hv_ModelIDe.Dispose(); hv_Row3e.Dispose(); hv_Column3e.Dispose(); hv_Anglee.Dispose(); hv_Scoree.Dispose(); hv_HomMat2De.Dispose(); hv_RowTranse.Dispose(); hv_ColTranse.Dispose(); hv_RowTrans1e.Dispose(); hv_ColTrans1e.Dispose(); hv_ResultRowe.Dispose(); hv_ResultColumne.Dispose(); hv_Row14e.Dispose(); hv_Col1e.Dispose(); hv_Row24e.Dispose(); hv_Col2e.Dispose(); hv_RowTrans2e.Dispose(); hv_ColTrans2e.Dispose(); hv_RowTrans3e.Dispose(); hv_ColTrans3e.Dispose(); hv_ResultRow1e.Dispose(); hv_ResultColumn1e.Dispose(); hv_Distancee.Dispose(); hv_RowTrans4e.Dispose(); hv_ColTrans4e.Dispose(); hv_RowTrans5e.Dispose(); hv_ColTrans5e.Dispose(); hv_ResultRow2e.Dispose(); hv_ResultColumn2e.Dispose(); hv_Distance1e.Dispose(); hv_Meane.Dispose(); hv_Mean1e.Dispose(); ///////////// ///////////// /////////// ho_Image1k.Dispose(); ho_Regionsk.Dispose(); ho_Regions1k.Dispose(); ho_Regions2k.Dispose(); ho_Regions3k.Dispose(); ho_Regions4k.Dispose(); ho_Regions5k.Dispose(); ho_Regions6k.Dispose(); ho_Rectanglek.Dispose(); ho_Rectangle1k.Dispose(); ho_Rectangle2k.Dispose(); ho_Rectangle3k.Dispose(); ho_ImageReducedk.Dispose(); ho_Regions7k.Dispose(); ho_Linek.Dispose(); ho_Regions8k.Dispose(); ho_Regions9k.Dispose(); ho_Regions10k.Dispose(); ho_Regions11k.Dispose(); ho_Regions12k.Dispose(); ho_Regions13k.Dispose(); ho_RegionAffineTransk.Dispose(); ho_RegionAffineTrans1k.Dispose(); ho_RegionAffineTrans2k.Dispose(); hv_Row1k.Dispose(); hv_Column1k.Dispose(); hv_Row2k.Dispose(); hv_Column2k.Dispose(); hv_Row11k.Dispose(); hv_Column11k.Dispose(); hv_Row21k.Dispose(); hv_Column21k.Dispose(); hv_Row12k.Dispose(); hv_Column12k.Dispose(); hv_Row22k.Dispose(); hv_Column22k.Dispose(); hv_Row13k.Dispose(); hv_Column13k.Dispose(); hv_Row23k.Dispose(); hv_Column23k.Dispose(); hv_Row14k.Dispose(); hv_Column14k.Dispose(); hv_Row24k.Dispose(); hv_Column24k.Dispose(); hv_Row15k.Dispose(); hv_Column15k.Dispose(); hv_Row25k.Dispose(); hv_Column25k.Dispose(); hv_Row16k.Dispose(); hv_Column16k.Dispose(); hv_Row26k.Dispose(); hv_Column26k.Dispose(); hv_Rowk.Dispose(); hv_Columnk.Dispose(); hv_Phik.Dispose(); hv_Length1k.Dispose(); hv_Length2k.Dispose(); hv_Row3k.Dispose(); hv_Column3k.Dispose(); hv_Phi1k.Dispose(); hv_Length11k.Dispose(); hv_Length21k.Dispose(); hv_Row4k.Dispose(); hv_Column4k.Dispose(); hv_Phi2k.Dispose(); hv_Length12k.Dispose(); hv_Length22k.Dispose(); hv_Row17k.Dispose(); hv_Column17k.Dispose(); hv_Row27k.Dispose(); hv_Column27k.Dispose(); hv_Areak.Dispose(); hv_Row5k.Dispose(); hv_Column5k.Dispose(); hv_ModelIDk.Dispose(); hv_Row6k.Dispose(); hv_Column6k.Dispose(); hv_Anglek.Dispose(); hv_Scorek.Dispose(); hv_HomMat2Dk.Dispose(); hv_RowTransk.Dispose(); hv_ColTransk.Dispose(); hv_RowTrans1k.Dispose(); hv_ColTrans1k.Dispose(); hv_ResultRowk.Dispose(); hv_ResultColumnk.Dispose(); hv_Row18k.Dispose(); hv_Col1k.Dispose(); hv_Row28k.Dispose(); hv_Col2k.Dispose(); hv_RowTrans2k.Dispose(); hv_ColTrans2k.Dispose(); hv_RowTrans3k.Dispose(); hv_ColTrans3k.Dispose(); hv_ResultRow1k.Dispose(); hv_ResultColumn1k.Dispose(); hv_Distancek.Dispose(); hv_RowTrans4k.Dispose(); hv_ColTrans4k.Dispose(); hv_RowTrans5k.Dispose(); hv_ColTrans5k.Dispose(); hv_ResultRow2k.Dispose(); hv_ResultColumn2k.Dispose(); hv_Distance1k.Dispose(); hv_RowTrans6k.Dispose(); hv_ColTrans6k.Dispose(); hv_RowTrans7k.Dispose(); hv_ColTrans7k.Dispose(); hv_ResultRow3k.Dispose(); hv_ResultColumn3k.Dispose(); hv_Distance2k.Dispose(); hv_RowTrans8k.Dispose(); hv_ColTrans8k.Dispose(); hv_RowTrans9k.Dispose(); hv_ColTrans9k.Dispose(); hv_ResultRow4k.Dispose(); hv_ResultColumn4k.Dispose(); hv_Distance3k.Dispose(); hv_RowTrans10k.Dispose(); hv_ColTrans10k.Dispose(); hv_RowTrans11k.Dispose(); hv_ColTrans11k.Dispose(); hv_ResultRow5k.Dispose(); hv_ResultColumn5k.Dispose(); hv_Distance4k.Dispose(); hv_RowTrans12k.Dispose(); hv_ColTrans12k.Dispose(); hv_RowTrans13k.Dispose(); hv_ColTrans13k.Dispose(); hv_ResultRow6k.Dispose(); hv_ResultColumn6k.Dispose(); hv_Distance5k.Dispose(); hv_Widthk.Dispose(); hv_Heightk.Dispose(); hv_Row7k.Dispose(); hv_Column7k.Dispose(); hv_Phi3k.Dispose(); hv_Length13k.Dispose(); hv_Length23k.Dispose(); hv_MeasureHandlek.Dispose(); hv_RowEdgeFirstk.Dispose(); hv_ColumnEdgeFirstk.Dispose(); hv_AmplitudeFirstk.Dispose(); hv_RowEdgeSecondk.Dispose(); hv_ColumnEdgeSecondk.Dispose(); hv_AmplitudeSecondk.Dispose(); hv_IntraDistancek.Dispose(); hv_InterDistancek.Dispose(); hv_Row8k.Dispose(); hv_Column8k.Dispose(); hv_Phi4k.Dispose(); hv_Length14k.Dispose(); hv_Length24k.Dispose(); hv_MeasureHandle1k.Dispose(); hv_RowEdgeFirst1k.Dispose(); hv_ColumnEdgeFirst1k.Dispose(); hv_AmplitudeFirst1k.Dispose(); hv_RowEdgeSecond1k.Dispose(); hv_ColumnEdgeSecond1k.Dispose(); hv_AmplitudeSecond1k.Dispose(); hv_IntraDistance1k.Dispose(); hv_InterDistance1k.Dispose(); hv_Row9k.Dispose(); hv_Column9k.Dispose(); hv_Phi5k.Dispose(); hv_Length15k.Dispose(); hv_Length25k.Dispose(); hv_MeasureHandle2k.Dispose(); hv_RowEdgeFirst2k.Dispose(); hv_ColumnEdgeFirst2k.Dispose(); hv_AmplitudeFirst2k.Dispose(); hv_RowEdgeSecond2k.Dispose(); hv_ColumnEdgeSecond2k.Dispose(); hv_AmplitudeSecond2k.Dispose(); hv_IntraDistance2k.Dispose(); hv_InterDistance2k.Dispose(); hv_Meank.Dispose(); hv_Mean1k.Dispose(); hv_Mean2k.Dispose(); hv_Mean3k.Dispose(); hv_Mean4k.Dispose(); hv_Mean5k.Dispose(); } private void button1_Click(object sender, EventArgs e) { try { ho_Image1.Dispose(); HOperatorSet.ReadImage(out ho_Image1, "C:/Users/HP/Desktop/新建文件夹 (2)/正面 (1).bmp"); HTuple Width, Height; HOperatorSet.GetImageSize(ho_Image1, out Width, out Height); HOperatorSet.SetPart(hv_WindowHandle, 0, 0, Height - 1, Width - 1); HOperatorSet.DispObj(ho_Image1, hv_WindowHandle); ho_Regions.Dispose(); hv_Row1.Dispose(); hv_Column1.Dispose(); hv_Row2.Dispose(); hv_Column2.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions, hv_WindowHandle, 30, 60, 15, out hv_Row1, out hv_Column1, out hv_Row2, out hv_Column2); ho_Regions1.Dispose(); hv_Row11.Dispose(); hv_Column11.Dispose(); hv_Row21.Dispose(); hv_Column21.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions1, hv_WindowHandle, 30, 60, 15, out hv_Row11, out hv_Column11, out hv_Row21, out hv_Column21); ho_Regions2.Dispose(); hv_Row12.Dispose(); hv_Column12.Dispose(); hv_Row22.Dispose(); hv_Column22.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions2, hv_WindowHandle, 30, 60, 15, out hv_Row12, out hv_Column12, out hv_Row22, out hv_Column22); ho_Regions3.Dispose(); hv_Row13.Dispose(); hv_Column13.Dispose(); hv_Row23.Dispose(); hv_Column23.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions3, hv_WindowHandle, 30, 60, 15, out hv_Row13, out hv_Column13, out hv_Row23, out hv_Column23); ho_Regions4.Dispose(); hv_Row14.Dispose(); hv_Column14.Dispose(); hv_Row24.Dispose(); hv_Column24.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions4, hv_WindowHandle, 30, 60, 15, out hv_Row14, out hv_Column14, out hv_Row24, out hv_Column24); hv_Row.Dispose(); hv_Column.Dispose(); hv_Phi.Dispose(); hv_Length1.Dispose(); hv_Length2.Dispose(); hWindowControl1.Focus(); HOperatorSet.DrawRectangle2(hv_WindowHandle, out hv_Row, out hv_Column, out hv_Phi, out hv_Length1, out hv_Length2); ho_Rectangle.Dispose(); HOperatorSet.GenRectangle2(out ho_Rectangle, hv_Row, hv_Column, hv_Phi, hv_Length1, hv_Length2); hv_Row3.Dispose(); hv_Column3.Dispose(); hv_Phi1.Dispose(); hv_Length11.Dispose(); hv_Length21.Dispose(); hWindowControl1.Focus(); HOperatorSet.DrawRectangle2(hv_WindowHandle, out hv_Row3, out hv_Column3, out hv_Phi1, out hv_Length11, out hv_Length21); ho_Rectangle1.Dispose(); HOperatorSet.GenRectangle2(out ho_Rectangle1, hv_Row3, hv_Column3, hv_Phi1, hv_Length11, hv_Length21); hv_Row15.Dispose(); hv_Column15.Dispose(); hv_Row25.Dispose(); hv_Column25.Dispose(); hWindowControl1.Focus(); HOperatorSet.DrawRectangle1(hv_WindowHandle, out hv_Row15, out hv_Column15, out hv_Row25, out hv_Column25); ho_Rectangle2.Dispose(); HOperatorSet.GenRectangle1(out ho_Rectangle2, hv_Row15, hv_Column15, hv_Row25, hv_Column25); hv_Area.Dispose(); hv_Row4.Dispose(); hv_Column4.Dispose(); HOperatorSet.AreaCenter(ho_Rectangle2, out hv_Area, out hv_Row4, out hv_Column4); ho_ImageReduced.Dispose(); HOperatorSet.ReduceDomain(ho_Image1, ho_Rectangle2, out ho_ImageReduced); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ModelID.Dispose(); HOperatorSet.CreateShapeModel(ho_ImageReduced, "auto", (new HTuple(-180)).TupleRad() , (new HTuple(360)).TupleRad(), "auto", "auto", "use_polarity", "auto", "auto", out hv_ModelID); } MessageBox.Show("创建成功"); } catch(Exception ex) { MessageBox.Show(ex.Message); } } public void disp_message(HTuple hv_WindowHandle, HTuple hv_String, HTuple hv_CoordSystem, HTuple hv_Row, HTuple hv_Column, HTuple hv_Color, HTuple hv_Box) { // Local iconic variables // Local control variables HTuple hv_GenParamName = new HTuple(), hv_GenParamValue = new HTuple(); HTuple hv_Color_COPY_INP_TMP = new HTuple(hv_Color); HTuple hv_Column_COPY_INP_TMP = new HTuple(hv_Column); HTuple hv_CoordSystem_COPY_INP_TMP = new HTuple(hv_CoordSystem); HTuple hv_Row_COPY_INP_TMP = new HTuple(hv_Row); // Initialize local and output iconic variables //This procedure displays text in a graphics window. // //Input parameters: //WindowHandle: The WindowHandle of the graphics window, where // the message should be displayed //String: A tuple of strings containing the text message to be displayed //CoordSystem: If set to 'window', the text position is given // with respect to the window coordinate system. // If set to 'image', image coordinates are used. // (This may be useful in zoomed images.) //Row: The row coordinate of the desired text position // A tuple of values is allowed to display text at different // positions. //Column: The column coordinate of the desired text position // A tuple of values is allowed to display text at different // positions. //Color: defines the color of the text as string. // If set to [], '' or 'auto' the currently set color is used. // If a tuple of strings is passed, the colors are used cyclically... // - if |Row| == |Column| == 1: for each new textline // = else for each text position. //Box: If Box[0] is set to 'true', the text is written within an orange box. // If set to' false', no box is displayed. // If set to a color string (e.g. 'white', '#FF00CC', etc.), // the text is written in a box of that color. // An optional second value for Box (Box[1]) controls if a shadow is displayed: // 'true' -> display a shadow in a default color // 'false' -> display no shadow // otherwise -> use given string as color string for the shadow color // //It is possible to display multiple text strings in a single call. //In this case, some restrictions apply: //- Multiple text positions can be defined by specifying a tuple // with multiple Row and/or Column coordinates, i.e.: // - |Row| == n, |Column| == n // - |Row| == n, |Column| == 1 // - |Row| == 1, |Column| == n //- If |Row| == |Column| == 1, // each element of String is display in a new textline. //- If multiple positions or specified, the number of Strings // must match the number of positions, i.e.: // - Either |String| == n (each string is displayed at the // corresponding position), // - or |String| == 1 (The string is displayed n times). // // //Convert the parameters for disp_text. if ((int)((new HTuple(hv_Row_COPY_INP_TMP.TupleEqual(new HTuple()))).TupleOr( new HTuple(hv_Column_COPY_INP_TMP.TupleEqual(new HTuple())))) != 0) { hv_Color_COPY_INP_TMP.Dispose(); hv_Column_COPY_INP_TMP.Dispose(); hv_CoordSystem_COPY_INP_TMP.Dispose(); hv_Row_COPY_INP_TMP.Dispose(); hv_GenParamName.Dispose(); hv_GenParamValue.Dispose(); return; } if ((int)(new HTuple(hv_Row_COPY_INP_TMP.TupleEqual(-1))) != 0) { hv_Row_COPY_INP_TMP.Dispose(); hv_Row_COPY_INP_TMP = 12; } if ((int)(new HTuple(hv_Column_COPY_INP_TMP.TupleEqual(-1))) != 0) { hv_Column_COPY_INP_TMP.Dispose(); hv_Column_COPY_INP_TMP = 12; } // //Convert the parameter Box to generic parameters. hv_GenParamName.Dispose(); hv_GenParamName = new HTuple(); hv_GenParamValue.Dispose(); hv_GenParamValue = new HTuple(); if ((int)(new HTuple((new HTuple(hv_Box.TupleLength())).TupleGreater(0))) != 0) { if ((int)(new HTuple(((hv_Box.TupleSelect(0))).TupleEqual("false"))) != 0) { //Display no box using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_GenParamName = hv_GenParamName.TupleConcat( "box"); hv_GenParamName.Dispose(); hv_GenParamName = ExpTmpLocalVar_GenParamName; } } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_GenParamValue = hv_GenParamValue.TupleConcat( "false"); hv_GenParamValue.Dispose(); hv_GenParamValue = ExpTmpLocalVar_GenParamValue; } } } else if ((int)(new HTuple(((hv_Box.TupleSelect(0))).TupleNotEqual("true"))) != 0) { //Set a color other than the default. using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_GenParamName = hv_GenParamName.TupleConcat( "box_color"); hv_GenParamName.Dispose(); hv_GenParamName = ExpTmpLocalVar_GenParamName; } } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_GenParamValue = hv_GenParamValue.TupleConcat( hv_Box.TupleSelect(0)); hv_GenParamValue.Dispose(); hv_GenParamValue = ExpTmpLocalVar_GenParamValue; } } } } if ((int)(new HTuple((new HTuple(hv_Box.TupleLength())).TupleGreater(1))) != 0) { if ((int)(new HTuple(((hv_Box.TupleSelect(1))).TupleEqual("false"))) != 0) { //Display no shadow. using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_GenParamName = hv_GenParamName.TupleConcat( "shadow"); hv_GenParamName.Dispose(); hv_GenParamName = ExpTmpLocalVar_GenParamName; } } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_GenParamValue = hv_GenParamValue.TupleConcat( "false"); hv_GenParamValue.Dispose(); hv_GenParamValue = ExpTmpLocalVar_GenParamValue; } } } else if ((int)(new HTuple(((hv_Box.TupleSelect(1))).TupleNotEqual("true"))) != 0) { //Set a shadow color other than the default. using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_GenParamName = hv_GenParamName.TupleConcat( "shadow_color"); hv_GenParamName.Dispose(); hv_GenParamName = ExpTmpLocalVar_GenParamName; } } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_GenParamValue = hv_GenParamValue.TupleConcat( hv_Box.TupleSelect(1)); hv_GenParamValue.Dispose(); hv_GenParamValue = ExpTmpLocalVar_GenParamValue; } } } } //Restore default CoordSystem behavior. if ((int)(new HTuple(hv_CoordSystem_COPY_INP_TMP.TupleNotEqual("window"))) != 0) { hv_CoordSystem_COPY_INP_TMP.Dispose(); hv_CoordSystem_COPY_INP_TMP = "image"; } // if ((int)(new HTuple(hv_Color_COPY_INP_TMP.TupleEqual(""))) != 0) { //disp_text does not accept an empty string for Color. hv_Color_COPY_INP_TMP.Dispose(); hv_Color_COPY_INP_TMP = new HTuple(); } // HOperatorSet.DispText(hv_WindowHandle, hv_String, hv_CoordSystem_COPY_INP_TMP, hv_Row_COPY_INP_TMP, hv_Column_COPY_INP_TMP, hv_Color_COPY_INP_TMP, hv_GenParamName, hv_GenParamValue); hv_Color_COPY_INP_TMP.Dispose(); hv_Column_COPY_INP_TMP.Dispose(); hv_CoordSystem_COPY_INP_TMP.Dispose(); hv_Row_COPY_INP_TMP.Dispose(); hv_GenParamName.Dispose(); hv_GenParamValue.Dispose(); return; } public void draw_rake(out HObject ho_Regions, HTuple hv_WindowHandle, HTuple hv_Elements, HTuple hv_DetectHeight, HTuple hv_DetectWidth, out HTuple hv_Row1, out HTuple hv_Column1, out HTuple hv_Row2, out HTuple hv_Column2) { // Stack for temporary objects HObject[] OTemp = new HObject[20]; // Local iconic variables HObject ho_RegionLines, ho_Rectangle = null; HObject ho_Arrow1 = null; // Local control variables HTuple hv_ATan = new HTuple(), hv_Deg = new HTuple(); HTuple hv_i = new HTuple(), hv_RowC = new HTuple(), hv_ColC = new HTuple(); HTuple hv_Distance = new HTuple(), hv_RowL2 = new HTuple(); HTuple hv_RowL1 = new HTuple(), hv_ColL2 = new HTuple(); HTuple hv_ColL1 = new HTuple(); // Initialize local and output iconic variables HOperatorSet.GenEmptyObj(out ho_Regions); HOperatorSet.GenEmptyObj(out ho_RegionLines); HOperatorSet.GenEmptyObj(out ho_Rectangle); HOperatorSet.GenEmptyObj(out ho_Arrow1); hv_Row1 = new HTuple(); hv_Column1 = new HTuple(); hv_Row2 = new HTuple(); hv_Column2 = new HTuple(); disp_message(hv_WindowHandle, new HTuple("点击鼠标左键在对应边缘画一条直线,点击右键确认"), "window", 12, 12, "red", "false"); ho_Regions.Dispose(); HOperatorSet.GenEmptyObj(out ho_Regions); hv_Row1.Dispose(); hv_Column1.Dispose(); hv_Row2.Dispose(); hv_Column2.Dispose(); HOperatorSet.DrawLine(hv_WindowHandle, out hv_Row1, out hv_Column1, out hv_Row2, out hv_Column2); //disp_line (WindowHandle, Row1, Column1, Row2, Column2) ho_RegionLines.Dispose(); HOperatorSet.GenRegionLine(out ho_RegionLines, hv_Row1, hv_Column1, hv_Row2, hv_Column2); { HObject ExpTmpOutVar_0; HOperatorSet.ConcatObj(ho_Regions, ho_RegionLines, out ExpTmpOutVar_0); ho_Regions.Dispose(); ho_Regions = ExpTmpOutVar_0; } //atan2(y,x)所表达的意思是坐标原点为起点,指向(x,y)的射线在坐标平面上与x轴正方向之间的角的角度(-180到180),即等于直线的角度A using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ATan.Dispose(); HOperatorSet.TupleAtan2((-hv_Row2) hv_Row1, hv_Column2 - hv_Column1, out hv_ATan); } //tuple_deg (ATan, Deg1) //将角度变成垂直于直线的角度 using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTuple ExpTmpLocalVar_ATan = hv_ATan ((new HTuple(90)).TupleRad() ); hv_ATan.Dispose(); hv_ATan = ExpTmpLocalVar_ATan; } } hv_Deg.Dispose(); HOperatorSet.TupleDeg(hv_ATan, out hv_Deg); HTuple end_val15 = hv_Elements; HTuple step_val15 = 1; for (hv_i = 1; hv_i.Continue(end_val15, step_val15); hv_i = hv_i.TupleAdd(step_val15)) { hv_RowC.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_RowC = hv_Row1 (((hv_Row2 - hv_Row1) * hv_i) / (hv_Elements 1)); } hv_ColC.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ColC = hv_Column1 (((hv_Column2 - hv_Column1) * hv_i) / (hv_Elements 1)); } if ((int)(new HTuple(hv_Elements.TupleEqual(1))) != 0) { hv_Distance.Dispose(); HOperatorSet.DistancePp(hv_Row1, hv_Column1, hv_Row2, hv_Column2, out hv_Distance); //创建一个有一定角度的矩形轮廓 using (HDevDisposeHelper dh = new HDevDisposeHelper()) { ho_Rectangle.Dispose(); HOperatorSet.GenRectangle2ContourXld(out ho_Rectangle, hv_RowC, hv_ColC, hv_Deg.TupleRad(), hv_DetectHeight / 2, hv_Distance / 2); } } else { using (HDevDisposeHelper dh = new HDevDisposeHelper()) { ho_Rectangle.Dispose(); HOperatorSet.GenRectangle2ContourXld(out ho_Rectangle, hv_RowC, hv_ColC, hv_Deg.TupleRad(), hv_DetectHeight / 2, hv_DetectWidth / 2); } } { HObject ExpTmpOutVar_0; HOperatorSet.ConcatObj(ho_Regions, ho_Rectangle, out ExpTmpOutVar_0); ho_Regions.Dispose(); ho_Regions = ExpTmpOutVar_0; } if ((int)(new HTuple(hv_i.TupleEqual(1))) != 0) { //RowL2 := RowC DetectHeight/2*sin(ATan) //RowL1 := RowC-DetectHeight/2*sin(ATan) //ColL2 := ColC-DetectHeight/2*cos(ATan) //ColL1 := ColC DetectHeight/2*cos(ATan) hv_RowL2.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_RowL2 = hv_RowC ((hv_DetectHeight / 2) * (((-hv_ATan)).TupleSin() )); } hv_RowL1.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_RowL1 = hv_RowC - ((hv_DetectHeight / 2) * (((-hv_ATan)).TupleSin() )); } hv_ColL2.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ColL2 = hv_ColC ((hv_DetectHeight / 2) * (((-hv_ATan)).TupleCos() )); } hv_ColL1.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ColL1 = hv_ColC - ((hv_DetectHeight / 2) * (((-hv_ATan)).TupleCos() )); } ho_Arrow1.Dispose(); gen_arrow_contour_xld(out ho_Arrow1, hv_RowL1, hv_ColL1, hv_RowL2, hv_ColL2, 25, 25); { HObject ExpTmpOutVar_0; HOperatorSet.ConcatObj(ho_Regions, ho_Arrow1, out ExpTmpOutVar_0); ho_Regions.Dispose(); ho_Regions = ExpTmpOutVar_0; } } } ho_RegionLines.Dispose(); ho_Rectangle.Dispose(); ho_Arrow1.Dispose(); hv_ATan.Dispose(); hv_Deg.Dispose(); hv_i.Dispose(); hv_RowC.Dispose(); hv_ColC.Dispose(); hv_Distance.Dispose(); hv_RowL2.Dispose(); hv_RowL1.Dispose(); hv_ColL2.Dispose(); hv_ColL1.Dispose(); return; } // Chapter: XLD / Creation // Short Description: Creates an arrow shaped XLD contour. public void gen_arrow_contour_xld(out HObject ho_Arrow, HTuple hv_Row1, HTuple hv_Column1, HTuple hv_Row2, HTuple hv_Column2, HTuple hv_HeadLength, HTuple hv_HeadWidth) { // Stack for temporary objects HObject[] OTemp = new HObject[20]; // Local iconic variables HObject ho_TempArrow = null; // Local control variables HTuple hv_Length = new HTuple(), hv_ZeroLengthIndices = new HTuple(); HTuple hv_DR = new HTuple(), hv_DC = new HTuple(), hv_HalfHeadWidth = new HTuple(); HTuple hv_RowP1 = new HTuple(), hv_ColP1 = new HTuple(); HTuple hv_RowP2 = new HTuple(), hv_ColP2 = new HTuple(); HTuple hv_Index = new HTuple(); // Initialize local and output iconic variables HOperatorSet.GenEmptyObj(out ho_Arrow); HOperatorSet.GenEmptyObj(out ho_TempArrow); //This procedure generates arrow shaped XLD contours, //pointing from (Row1, Column1) to (Row2, Column2). //If starting and end point are identical, a contour consisting //of a single point is returned. // //input parameteres: //Row1, Column1: Coordinates of the arrows' starting points //Row2, Column2: Coordinates of the arrows' end points //HeadLength, HeadWidth: Size of the arrow heads in pixels // //output parameter: //Arrow: The resulting XLD contour // //The input tuples Row1, Column1, Row2, and Column2 have to be of //the same length. //HeadLength and HeadWidth either have to be of the same length as //Row1, Column1, Row2, and Column2 or have to be a single element. //If one of the above restrictions is violated, an error will occur. // // //Init ho_Arrow.Dispose(); HOperatorSet.GenEmptyObj(out ho_Arrow); // //Calculate the arrow length hv_Length.Dispose(); HOperatorSet.DistancePp(hv_Row1, hv_Column1, hv_Row2, hv_Column2, out hv_Length); // //Mark arrows with identical start and end point //(set Length to -1 to avoid division-by-zero exception) hv_ZeroLengthIndices.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ZeroLengthIndices = hv_Length.TupleFind( 0); } if ((int)(new HTuple(hv_ZeroLengthIndices.TupleNotEqual(-1))) != 0) { if (hv_Length == null) hv_Length = new HTuple(); hv_Length[hv_ZeroLengthIndices] = -1; } // //Calculate auxiliary variables. hv_DR.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_DR = (1.0 * (hv_Row2 - hv_Row1)) / hv_Length; } hv_DC.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_DC = (1.0 * (hv_Column2 - hv_Column1)) / hv_Length; } hv_HalfHeadWidth.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_HalfHeadWidth = hv_HeadWidth / 2.0; } // //Calculate end points of the arrow head. hv_RowP1.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_RowP1 = (hv_Row1 ((hv_Length - hv_HeadLength) * hv_DR)) (hv_HalfHeadWidth * hv_DC); } hv_ColP1.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ColP1 = (hv_Column1 ((hv_Length - hv_HeadLength) * hv_DC)) - (hv_HalfHeadWidth * hv_DR); } hv_RowP2.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_RowP2 = (hv_Row1 ((hv_Length - hv_HeadLength) * hv_DR)) - (hv_HalfHeadWidth * hv_DC); } hv_ColP2.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ColP2 = (hv_Column1 ((hv_Length - hv_HeadLength) * hv_DC)) (hv_HalfHeadWidth * hv_DR); } // //Finally create output XLD contour for each input point pair for (hv_Index = 0; (int)hv_Index <= (int)((new HTuple(hv_Length.TupleLength())) - 1); hv_Index = (int)hv_Index 1) { if ((int)(new HTuple(((hv_Length.TupleSelect(hv_Index))).TupleEqual(-1))) != 0) { //Create_ single points for arrows with identical start and end point using (HDevDisposeHelper dh = new HDevDisposeHelper()) { ho_TempArrow.Dispose(); HOperatorSet.GenContourPolygonXld(out ho_TempArrow, hv_Row1.TupleSelect(hv_Index), hv_Column1.TupleSelect(hv_Index)); } } else { //Create arrow contour using (HDevDisposeHelper dh = new HDevDisposeHelper()) { ho_TempArrow.Dispose(); HOperatorSet.GenContourPolygonXld(out ho_TempArrow, ((((((((((hv_Row1.TupleSelect( hv_Index))).TupleConcat(hv_Row2.TupleSelect(hv_Index)))).TupleConcat( hv_RowP1.TupleSelect(hv_Index)))).TupleConcat(hv_Row2.TupleSelect(hv_Index)))).TupleConcat( hv_RowP2.TupleSelect(hv_Index)))).TupleConcat(hv_Row2.TupleSelect(hv_Index)), ((((((((((hv_Column1.TupleSelect(hv_Index))).TupleConcat(hv_Column2.TupleSelect( hv_Index)))).TupleConcat(hv_ColP1.TupleSelect(hv_Index)))).TupleConcat( hv_Column2.TupleSelect(hv_Index)))).TupleConcat(hv_ColP2.TupleSelect( hv_Index)))).TupleConcat(hv_Column2.TupleSelect(hv_Index))); } } { HObject ExpTmpOutVar_0; HOperatorSet.ConcatObj(ho_Arrow, ho_TempArrow, out ExpTmpOutVar_0); ho_Arrow.Dispose(); ho_Arrow = ExpTmpOutVar_0; } } ho_TempArrow.Dispose(); hv_Length.Dispose(); hv_ZeroLengthIndices.Dispose(); hv_DR.Dispose(); hv_DC.Dispose(); hv_HalfHeadWidth.Dispose(); hv_RowP1.Dispose(); hv_ColP1.Dispose(); hv_RowP2.Dispose(); hv_ColP2.Dispose(); hv_Index.Dispose(); return; } public void pts_to_best_line(out HObject ho_Line, HTuple hv_Rows, HTuple hv_Cols, HTuple hv_ActiveNum, out HTuple hv_Row1, out HTuple hv_Col1, out HTuple hv_Row2, out HTuple hv_Col2) { // Local iconic variables HObject ho_Contour = null; // Local control variables HTuple hv_Length = new HTuple(), hv_Nr = new HTuple(); HTuple hv_Nc = new HTuple(), hv_Dist = new HTuple(), hv_Length1 = new HTuple(); // Initialize local and output iconic variables HOperatorSet.GenEmptyObj(out ho_Line); HOperatorSet.GenEmptyObj(out ho_Contour); hv_Row1 = new HTuple(); hv_Col1 = new HTuple(); hv_Row2 = new HTuple(); hv_Col2 = new HTuple(); hv_Row1.Dispose(); hv_Row1 = 0; hv_Col1.Dispose(); hv_Col1 = 0; hv_Row2.Dispose(); hv_Row2 = 0; hv_Col2.Dispose(); hv_Col2 = 0; ho_Line.Dispose(); HOperatorSet.GenEmptyObj(out ho_Line); hv_Length.Dispose(); HOperatorSet.TupleLength(hv_Cols, out hv_Length); if ((int)((new HTuple(hv_Length.TupleGreaterEqual(hv_ActiveNum))).TupleAnd(new HTuple(hv_ActiveNum.TupleGreater( 1)))) != 0) { ho_Contour.Dispose(); HOperatorSet.GenContourPolygonXld(out ho_Contour, hv_Rows, hv_Cols); hv_Row1.Dispose(); hv_Col1.Dispose(); hv_Row2.Dispose(); hv_Col2.Dispose(); hv_Nr.Dispose(); hv_Nc.Dispose(); hv_Dist.Dispose(); HOperatorSet.FitLineContourXld(ho_Contour, "tukey", hv_ActiveNum, 0, 5, 2, out hv_Row1, out hv_Col1, out hv_Row2, out hv_Col2, out hv_Nr, out hv_Nc, out hv_Dist); hv_Length1.Dispose(); HOperatorSet.TupleLength(hv_Dist, out hv_Length1); if ((int)(new HTuple(hv_Length1.TupleLess(1))) != 0) { ho_Contour.Dispose(); hv_Length.Dispose(); hv_Nr.Dispose(); hv_Nc.Dispose(); hv_Dist.Dispose(); hv_Length1.Dispose(); return; } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { ho_Line.Dispose(); HOperatorSet.GenContourPolygonXld(out ho_Line, hv_Row1.TupleConcat(hv_Row2), hv_Col1.TupleConcat(hv_Col2)); } } ho_Contour.Dispose(); hv_Length.Dispose(); hv_Nr.Dispose(); hv_Nc.Dispose(); hv_Dist.Dispose(); hv_Length1.Dispose(); return; } public void rake(HObject ho_Image, out HObject ho_Regions, HTuple hv_Elements, HTuple hv_DetectHeight, HTuple hv_DetectWidth, HTuple hv_Sigma, HTuple hv_Threshold, HTuple hv_Transition, HTuple hv_Select, HTuple hv_Row1, HTuple hv_Column1, HTuple hv_Row2, HTuple hv_Column2, out HTuple hv_ResultRow, out HTuple hv_ResultColumn) { // Stack for temporary objects HObject[] OTemp = new HObject[20]; // Local iconic variables HObject ho_Rectangle = null, ho_Arrow1 = null; // Local control variables HTuple hv_Width = new HTuple(), hv_Height = new HTuple(); HTuple hv_ATan = new HTuple(), hv_Deg1 = new HTuple(); HTuple hv_Deg = new HTuple(), hv_i = new HTuple(), hv_RowC = new HTuple(); HTuple hv_ColC = new HTuple(), hv_Distance = new HTuple(); HTuple hv_RowL2 = new HTuple(), hv_RowL1 = new HTuple(); HTuple hv_ColL2 = new HTuple(), hv_ColL1 = new HTuple(); HTuple hv_MsrHandle_Measure = new HTuple(), hv_RowEdge = new HTuple(); HTuple hv_ColEdge = new HTuple(), hv_Amplitude = new HTuple(); HTuple hv_tRow = new HTuple(), hv_tCol = new HTuple(); HTuple hv_t = new HTuple(), hv_Number = new HTuple(), hv_j = new HTuple(); HTuple hv_Select_COPY_INP_TMP = new HTuple(hv_Select); HTuple hv_Transition_COPY_INP_TMP = new HTuple(hv_Transition); // Initialize local and output iconic variables HOperatorSet.GenEmptyObj(out ho_Regions); HOperatorSet.GenEmptyObj(out ho_Rectangle); HOperatorSet.GenEmptyObj(out ho_Arrow1); hv_ResultRow = new HTuple(); hv_ResultColumn = new HTuple(); hv_Width.Dispose(); hv_Height.Dispose(); HOperatorSet.GetImageSize(ho_Image, out hv_Width, out hv_Height); ho_Regions.Dispose(); HOperatorSet.GenEmptyObj(out ho_Regions); hv_ResultRow.Dispose(); hv_ResultRow = new HTuple(); hv_ResultColumn.Dispose(); hv_ResultColumn = new HTuple(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ATan.Dispose(); HOperatorSet.TupleAtan2((-hv_Row2) hv_Row1, hv_Column2 - hv_Column1, out hv_ATan); } hv_Deg1.Dispose(); HOperatorSet.TupleDeg(hv_ATan, out hv_Deg1); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTuple ExpTmpLocalVar_ATan = hv_ATan ((new HTuple(90)).TupleRad() ); hv_ATan.Dispose(); hv_ATan = ExpTmpLocalVar_ATan; } } hv_Deg.Dispose(); HOperatorSet.TupleDeg(hv_ATan, out hv_Deg); HTuple end_val13 = hv_Elements; HTuple step_val13 = 1; for (hv_i = 1; hv_i.Continue(end_val13, step_val13); hv_i = hv_i.TupleAdd(step_val13)) { hv_RowC.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_RowC = hv_Row1 (((hv_Row2 - hv_Row1) * hv_i) / (hv_Elements 1)); } hv_ColC.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ColC = hv_Column1 (((hv_Column2 - hv_Column1) * hv_i) / (hv_Elements 1)); } if ((int)((new HTuple((new HTuple((new HTuple(hv_RowC.TupleGreater(hv_Height - 1))).TupleOr( new HTuple(hv_RowC.TupleLess(0))))).TupleOr(new HTuple(hv_ColC.TupleGreater( hv_Width - 1))))).TupleOr(new HTuple(hv_ColC.TupleLess(0)))) != 0) { continue; } if ((int)(new HTuple(hv_Elements.TupleEqual(1))) != 0) { hv_Distance.Dispose(); HOperatorSet.DistancePp(hv_Row1, hv_Column1, hv_Row2, hv_Column2, out hv_Distance); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { ho_Rectangle.Dispose(); HOperatorSet.GenRectangle2ContourXld(out ho_Rectangle, hv_RowC, hv_ColC, hv_Deg.TupleRad(), hv_DetectHeight / 2, hv_Distance / 2); } } else { using (HDevDisposeHelper dh = new HDevDisposeHelper()) { ho_Rectangle.Dispose(); HOperatorSet.GenRectangle2ContourXld(out ho_Rectangle, hv_RowC, hv_ColC, hv_Deg.TupleRad(), hv_DetectHeight / 2, hv_DetectWidth / 2); } } { HObject ExpTmpOutVar_0; HOperatorSet.ConcatObj(ho_Regions, ho_Rectangle, out ExpTmpOutVar_0); ho_Regions.Dispose(); ho_Regions = ExpTmpOutVar_0; } if ((int)(new HTuple(hv_i.TupleEqual(1))) != 0) { //RowL2 := RowC DetectHeight/2*sin(ATan) //RowL1 := RowC-DetectHeight/2*sin(ATan) //ColL2 := ColC-DetectHeight/2*cos(ATan) //ColL1 := ColC DetectHeight/2*cos(ATan) hv_RowL2.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_RowL2 = hv_RowC ((hv_DetectHeight / 2) * (((-hv_ATan)).TupleSin() )); } hv_RowL1.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_RowL1 = hv_RowC - ((hv_DetectHeight / 2) * (((-hv_ATan)).TupleSin() )); } hv_ColL2.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ColL2 = hv_ColC ((hv_DetectHeight / 2) * (((-hv_ATan)).TupleCos() )); } hv_ColL1.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_ColL1 = hv_ColC - ((hv_DetectHeight / 2) * (((-hv_ATan)).TupleCos() )); } ho_Arrow1.Dispose(); gen_arrow_contour_xld(out ho_Arrow1, hv_RowL1, hv_ColL1, hv_RowL2, hv_ColL2, 25, 25); { HObject ExpTmpOutVar_0; HOperatorSet.ConcatObj(ho_Regions, ho_Arrow1, out ExpTmpOutVar_0); ho_Regions.Dispose(); ho_Regions = ExpTmpOutVar_0; } } //Deg 是根据拟合线的角度加上90可得,拟合线的角度在-180到180之间(不包括-180),由开始点到到结束点的角度,例如:(0,0)到,(1,1)就是45度,(1,1)到,(0,0)就是-135度 using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_MsrHandle_Measure.Dispose(); HOperatorSet.GenMeasureRectangle2(hv_RowC, hv_ColC, hv_Deg.TupleRad(), hv_DetectHeight / 2, hv_DetectWidth / 2, hv_Width, hv_Height, "nearest_neighbor", out hv_MsrHandle_Measure); } if ((int)(new HTuple(hv_Transition_COPY_INP_TMP.TupleEqual("negative"))) != 0) { hv_Transition_COPY_INP_TMP.Dispose(); hv_Transition_COPY_INP_TMP = "negative"; } else { if ((int)(new HTuple(hv_Transition_COPY_INP_TMP.TupleEqual("positive"))) != 0) { hv_Transition_COPY_INP_TMP.Dispose(); hv_Transition_COPY_INP_TMP = "positive"; } else { hv_Transition_COPY_INP_TMP.Dispose(); hv_Transition_COPY_INP_TMP = "all"; } } if ((int)(new HTuple(hv_Select_COPY_INP_TMP.TupleEqual("first"))) != 0) { hv_Select_COPY_INP_TMP.Dispose(); hv_Select_COPY_INP_TMP = "first"; } else { if ((int)(new HTuple(hv_Select_COPY_INP_TMP.TupleEqual("last"))) != 0) { hv_Select_COPY_INP_TMP.Dispose(); hv_Select_COPY_INP_TMP = "last"; } else { hv_Select_COPY_INP_TMP.Dispose(); hv_Select_COPY_INP_TMP = "all"; } } hv_RowEdge.Dispose(); hv_ColEdge.Dispose(); hv_Amplitude.Dispose(); hv_Distance.Dispose(); HOperatorSet.MeasurePos(ho_Image, hv_MsrHandle_Measure, hv_Sigma, hv_Threshold, hv_Transition_COPY_INP_TMP, hv_Select_COPY_INP_TMP, out hv_RowEdge, out hv_ColEdge, out hv_Amplitude, out hv_Distance); HOperatorSet.CloseMeasure(hv_MsrHandle_Measure); hv_tRow.Dispose(); hv_tRow = 0; hv_tCol.Dispose(); hv_tCol = 0; hv_t.Dispose(); hv_t = 0; hv_Number.Dispose(); HOperatorSet.TupleLength(hv_RowEdge, out hv_Number); if ((int)(new HTuple(hv_Number.TupleLess(1))) != 0) { continue; } HTuple end_val75 = hv_Number - 1; HTuple step_val75 = 1; for (hv_j = 0; hv_j.Continue(end_val75, step_val75); hv_j = hv_j.TupleAdd(step_val75)) { if ((int)(new HTuple(((((hv_Amplitude.TupleSelect(hv_j))).TupleAbs())).TupleGreater( hv_t))) != 0) { hv_tRow.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_tRow = hv_RowEdge.TupleSelect( hv_j); } hv_tCol.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_tCol = hv_ColEdge.TupleSelect( hv_j); } hv_t.Dispose(); using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_t = ((hv_Amplitude.TupleSelect( hv_j))).TupleAbs(); } } } if ((int)(new HTuple(hv_t.TupleGreater(0))) != 0) { using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_ResultRow = hv_ResultRow.TupleConcat( hv_tRow); hv_ResultRow.Dispose(); hv_ResultRow = ExpTmpLocalVar_ResultRow; } } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { { HTupleExpTmpLocalVar_ResultColumn = hv_ResultColumn.TupleConcat( hv_tCol); hv_ResultColumn.Dispose(); hv_ResultColumn = ExpTmpLocalVar_ResultColumn; } } } } hv_Number.Dispose(); HOperatorSet.TupleLength(hv_ResultRow, out hv_Number); ho_Rectangle.Dispose(); ho_Arrow1.Dispose(); hv_Select_COPY_INP_TMP.Dispose(); hv_Transition_COPY_INP_TMP.Dispose(); hv_Width.Dispose(); hv_Height.Dispose(); hv_ATan.Dispose(); hv_Deg1.Dispose(); hv_Deg.Dispose(); hv_i.Dispose(); hv_RowC.Dispose(); hv_ColC.Dispose(); hv_Distance.Dispose(); hv_RowL2.Dispose(); hv_RowL1.Dispose(); hv_ColL2.Dispose(); hv_ColL1.Dispose(); hv_MsrHandle_Measure.Dispose(); hv_RowEdge.Dispose(); hv_ColEdge.Dispose(); hv_Amplitude.Dispose(); hv_tRow.Dispose(); hv_tCol.Dispose(); hv_t.Dispose(); hv_Number.Dispose(); hv_j.Dispose(); return; } private void button2_Click(object sender, EventArgs e) { try { if (m_Cam1.m_AcqHandle != null) { try { ho_Image.Dispose(); HOperatorSet.GrabImage(out ho_Image, m_Cam1.m_AcqHandle); HTuple Width, Height; HOperatorSet.GetImageSize(ho_Image, out Width, out Height); HOperatorSet.SetPart(hv_WindowHandle, 0, 0, Height - 1, Width - 1); HOperatorSet.DispObj(ho_Image, hv_WindowHandle); } catch (System.Exception ex) { } } hv_Row6k.Dispose(); hv_Column6k.Dispose(); hv_Anglek.Dispose(); hv_Scorek.Dispose(); HOperatorSet.FindShapeModel(ho_Image, hv_ModelIDk, -0.39, 0.79, 0.7, 1, 0.5, "least_squares", 0, 0.9, out hv_Row6k, out hv_Column6k, out hv_Anglek, out hv_Scorek); if ((int)(new HTuple((new HTuple(hv_Row6k.TupleLength())).TupleGreater(0))) != 0) { hv_HomMat2Dk.Dispose(); HOperatorSet.VectorAngleToRigid(hv_Row5k, hv_Column5k, 0, hv_Row6k, hv_Column6k, hv_Anglek, out hv_HomMat2Dk); hv_RowTransk.Dispose(); hv_ColTransk.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row1k, hv_Column1k, out hv_RowTransk, out hv_ColTransk); hv_RowTrans1k.Dispose(); hv_ColTrans1k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row2k, hv_Column2k, out hv_RowTrans1k, out hv_ColTrans1k); ho_Regions7k.Dispose(); hv_ResultRowk.Dispose(); hv_ResultColumnk.Dispose(); rake(ho_Image, out ho_Regions7k, 30, 60, 15, 1, 20, "all", "max", hv_RowTransk, hv_ColTransk, hv_RowTrans1k, hv_ColTrans1k, out hv_ResultRowk, out hv_ResultColumnk); ho_Linek.Dispose(); hv_Row18k.Dispose(); hv_Col1k.Dispose(); hv_Row28k.Dispose(); hv_Col2k.Dispose(); pts_to_best_line(out ho_Linek, hv_ResultRowk, hv_ResultColumnk, 20, out hv_Row18k, out hv_Col1k, out hv_Row28k, out hv_Col2k); hv_RowTrans2k.Dispose(); hv_ColTrans2k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row11k, hv_Column11k, out hv_RowTrans2k, out hv_ColTrans2k); hv_RowTrans3k.Dispose(); hv_ColTrans3k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row21k, hv_Column21k, out hv_RowTrans3k, out hv_ColTrans3k); ho_Regions8k.Dispose(); hv_ResultRow1k.Dispose(); hv_ResultColumn1k.Dispose(); rake(ho_Image, out ho_Regions8k, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans2k, hv_ColTrans2k, hv_RowTrans3k, hv_ColTrans3k, out hv_ResultRow1k, out hv_ResultColumn1k); hv_Distancek.Dispose(); HOperatorSet.DistancePl(hv_ResultRow1k, hv_ResultColumn1k, hv_Row18k, hv_Col1k, hv_Row28k, hv_Col2k, out hv_Distancek); hv_RowTrans4k.Dispose(); hv_ColTrans4k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row12k, hv_Column12k, out hv_RowTrans4k, out hv_ColTrans4k); hv_RowTrans5k.Dispose(); hv_ColTrans5k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row22k, hv_Column22k, out hv_RowTrans5k, out hv_ColTrans5k); ho_Regions9k.Dispose(); hv_ResultRow2k.Dispose(); hv_ResultColumn2k.Dispose(); rake(ho_Image, out ho_Regions9k, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans4k, hv_ColTrans4k, hv_RowTrans5k, hv_ColTrans5k, out hv_ResultRow2k, out hv_ResultColumn2k); hv_Distance1k.Dispose(); HOperatorSet.DistancePl(hv_ResultRow2k, hv_ResultColumn2k, hv_Row18k, hv_Col1k, hv_Row28k, hv_Col2k, out hv_Distance1k); hv_RowTrans6k.Dispose(); hv_ColTrans6k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row13k, hv_Column13k, out hv_RowTrans6k, out hv_ColTrans6k); hv_RowTrans7k.Dispose(); hv_ColTrans7k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row23k, hv_Column23k, out hv_RowTrans7k, out hv_ColTrans7k); ho_Regions10k.Dispose(); hv_ResultRow3k.Dispose(); hv_ResultColumn3k.Dispose(); rake(ho_Image, out ho_Regions10k, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans6k, hv_ColTrans6k, hv_RowTrans7k, hv_ColTrans7k, out hv_ResultRow3k, out hv_ResultColumn3k); hv_Distance2k.Dispose(); HOperatorSet.DistancePl(hv_ResultRow3k, hv_ResultColumn3k, hv_Row18k, hv_Col1k, hv_Row28k, hv_Col2k, out hv_Distance2k); hv_RowTrans8k.Dispose(); hv_ColTrans8k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row14k, hv_Column14k, out hv_RowTrans8k, out hv_ColTrans8k); hv_RowTrans9k.Dispose(); hv_ColTrans9k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row24k, hv_Column24k, out hv_RowTrans9k, out hv_ColTrans9k); ho_Regions11k.Dispose(); hv_ResultRow4k.Dispose(); hv_ResultColumn4k.Dispose(); rake(ho_Image, out ho_Regions11k, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans8k, hv_ColTrans8k, hv_RowTrans9k, hv_ColTrans9k, out hv_ResultRow4k, out hv_ResultColumn4k); hv_Distance3k.Dispose(); HOperatorSet.DistancePl(hv_ResultRow4k, hv_ResultColumn4k, hv_Row18k, hv_Col1k, hv_Row28k, hv_Col2k, out hv_Distance3k); hv_RowTrans10k.Dispose(); hv_ColTrans10k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row15k, hv_Column15k, out hv_RowTrans10k, out hv_ColTrans10k); hv_RowTrans11k.Dispose(); hv_ColTrans11k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row25k, hv_Column25k, out hv_RowTrans11k, out hv_ColTrans11k); ho_Regions12k.Dispose(); hv_ResultRow5k.Dispose(); hv_ResultColumn5k.Dispose(); rake(ho_Image, out ho_Regions12k, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans10k, hv_ColTrans10k, hv_RowTrans11k, hv_ColTrans11k, out hv_ResultRow5k, out hv_ResultColumn5k); hv_Distance4k.Dispose(); HOperatorSet.DistancePl(hv_ResultRow5k, hv_ResultColumn5k, hv_Row18k, hv_Col1k, hv_Row28k, hv_Col2k, out hv_Distance4k); hv_RowTrans12k.Dispose(); hv_ColTrans12k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row16k, hv_Column16k, out hv_RowTrans12k, out hv_ColTrans12k); hv_RowTrans13k.Dispose(); hv_ColTrans13k.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2Dk, hv_Row26k, hv_Column26k, out hv_RowTrans13k, out hv_ColTrans13k); ho_Regions13k.Dispose(); hv_ResultRow6k.Dispose(); hv_ResultColumn6k.Dispose(); rake(ho_Image, out ho_Regions13k, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans12k, hv_ColTrans12k, hv_RowTrans13k, hv_ColTrans13k, out hv_ResultRow6k, out hv_ResultColumn6k); hv_Distance5k.Dispose(); HOperatorSet.DistancePl(hv_ResultRow6k, hv_ResultColumn6k, hv_Row18k, hv_Col1k, hv_Row28k, hv_Col2k, out hv_Distance5k); hv_Widthk.Dispose(); hv_Heightk.Dispose(); HOperatorSet.GetImageSize(ho_Image, out hv_Widthk, out hv_Heightk); ho_RegionAffineTransk.Dispose(); HOperatorSet.AffineTransRegion(ho_Rectanglek, out ho_RegionAffineTransk, hv_HomMat2Dk, "nearest_neighbor"); hv_Row7k.Dispose(); hv_Column7k.Dispose(); hv_Phi3k.Dispose(); hv_Length13k.Dispose(); hv_Length23k.Dispose(); HOperatorSet.SmallestRectangle2(ho_RegionAffineTransk, out hv_Row7k, out hv_Column7k, out hv_Phi3k, out hv_Length13k, out hv_Length23k); hv_MeasureHandlek.Dispose(); HOperatorSet.GenMeasureRectangle2(hv_Row7k, hv_Column7k, hv_Phi3k, hv_Length13k, hv_Length23k, hv_Widthk, hv_Heightk, "nearest_neighbor", out hv_MeasureHandlek); hv_RowEdgeFirstk.Dispose(); hv_ColumnEdgeFirstk.Dispose(); hv_AmplitudeFirstk.Dispose(); hv_RowEdgeSecondk.Dispose(); hv_ColumnEdgeSecondk.Dispose(); hv_AmplitudeSecondk.Dispose(); hv_IntraDistancek.Dispose(); hv_InterDistancek.Dispose(); HOperatorSet.MeasurePairs(ho_Image, hv_MeasureHandlek, 1, 30, "all", "all", out hv_RowEdgeFirstk, out hv_ColumnEdgeFirstk, out hv_AmplitudeFirstk, out hv_RowEdgeSecondk, out hv_ColumnEdgeSecondk, out hv_AmplitudeSecondk, out hv_IntraDistancek, out hv_InterDistancek); ho_RegionAffineTrans1k.Dispose(); HOperatorSet.AffineTransRegion(ho_Rectangle1k, out ho_RegionAffineTrans1k, hv_HomMat2Dk, "nearest_neighbor"); hv_Row8k.Dispose(); hv_Column8k.Dispose(); hv_Phi4k.Dispose(); hv_Length14k.Dispose(); hv_Length24k.Dispose(); HOperatorSet.SmallestRectangle2(ho_RegionAffineTrans1k, out hv_Row8k, out hv_Column8k, out hv_Phi4k, out hv_Length14k, out hv_Length24k); hv_MeasureHandle1k.Dispose(); HOperatorSet.GenMeasureRectangle2(hv_Row8k, hv_Column8k, hv_Phi4k, hv_Length14k, hv_Length24k, hv_Widthk, hv_Heightk, "nearest_neighbor", out hv_MeasureHandle1k); hv_RowEdgeFirst1k.Dispose(); hv_ColumnEdgeFirst1k.Dispose(); hv_AmplitudeFirst1k.Dispose(); hv_RowEdgeSecond1k.Dispose(); hv_ColumnEdgeSecond1k.Dispose(); hv_AmplitudeSecond1k.Dispose(); hv_IntraDistance1k.Dispose(); hv_InterDistance1k.Dispose(); HOperatorSet.MeasurePairs(ho_Image, hv_MeasureHandle1k, 1, 30, "all", "all", out hv_RowEdgeFirst1k, out hv_ColumnEdgeFirst1k, out hv_AmplitudeFirst1k, out hv_RowEdgeSecond1k, out hv_ColumnEdgeSecond1k, out hv_AmplitudeSecond1k, out hv_IntraDistance1k, out hv_InterDistance1k); ho_RegionAffineTrans2k.Dispose(); HOperatorSet.AffineTransRegion(ho_Rectangle2k, out ho_RegionAffineTrans2k, hv_HomMat2Dk, "nearest_neighbor"); hv_Row9k.Dispose(); hv_Column9k.Dispose(); hv_Phi5k.Dispose(); hv_Length15k.Dispose(); hv_Length25k.Dispose(); HOperatorSet.SmallestRectangle2(ho_RegionAffineTrans2k, out hv_Row9k, out hv_Column9k, out hv_Phi5k, out hv_Length15k, out hv_Length25k); hv_MeasureHandle2k.Dispose(); HOperatorSet.GenMeasureRectangle2(hv_Row9k, hv_Column9k, hv_Phi5k, hv_Length15k, hv_Length25k, hv_Widthk, hv_Heightk, "nearest_neighbor", out hv_MeasureHandle2k); hv_RowEdgeFirst2k.Dispose(); hv_ColumnEdgeFirst2k.Dispose(); hv_AmplitudeFirst2k.Dispose(); hv_RowEdgeSecond2k.Dispose(); hv_ColumnEdgeSecond2k.Dispose(); hv_AmplitudeSecond2k.Dispose(); hv_IntraDistance2k.Dispose(); hv_InterDistance2k.Dispose(); HOperatorSet.MeasurePairs(ho_Image, hv_MeasureHandle2k, 1, 30, "all", "all", out hv_RowEdgeFirst2k, out hv_ColumnEdgeFirst2k, out hv_AmplitudeFirst2k, out hv_RowEdgeSecond2k, out hv_ColumnEdgeSecond2k, out hv_AmplitudeSecond2k, out hv_IntraDistance2k, out hv_InterDistance2k); hv_Meank.Dispose(); HOperatorSet.TupleMean(hv_Distancek, out hv_Meank); hv_Mean1k.Dispose(); HOperatorSet.TupleMean(hv_Distance1k, out hv_Mean1k); hv_Mean2k.Dispose(); HOperatorSet.TupleMean(hv_Distance2k, out hv_Mean2k); hv_Mean3k.Dispose(); HOperatorSet.TupleMean(hv_Distance3k, out hv_Mean3k); hv_Mean4k.Dispose(); HOperatorSet.TupleMean(hv_Distance4k, out hv_Mean4k); hv_Mean5k.Dispose(); HOperatorSet.TupleMean(hv_Distance5k, out hv_Mean5k); if (hv_Meank > kh1 && hv_Meank < kh2 && hv_Mean1k > kh3 && hv_Mean1k < kh4 && hv_Mean2k > kth1 && hv_Mean2k < kth2 && hv_Mean3k > kth3 && hv_Mean3k < kth4 && hv_Mean4k > keh1 && hv_Mean4k < keh2 && hv_Mean5k > keh3 && hv_Mean5k < keh4 && hv_IntraDistancek > s1 && hv_IntraDistancek < s2 && hv_IntraDistance1k > s1 && hv_IntraDistance1k < s2 && hv_IntraDistance2k > s1 && hv_IntraDistance2k < s2) { disp_message(hv_WindowHandle, "OK", "window", 0, 0, "green", "false"); disp_message(hv_WindowHandle, "高一" hv_Meank, "image", 593, 1652, "green", "false"); disp_message(hv_WindowHandle, "高二" hv_Mean1k, "image", 712, 1500, "green", "false"); disp_message(hv_WindowHandle, "高三" hv_Mean2k, "image", 630, 1200, "green", "false"); disp_message(hv_WindowHandle, "高四" hv_Mean3k, "image", 755, 1040, "green", "false"); disp_message(hv_WindowHandle, "高五" hv_Mean4k, "image", 570, 610, "green", "false"); disp_message(hv_WindowHandle, "高六" hv_Mean5k, "image", 720, 400, "green", "false"); disp_message(hv_WindowHandle, hv_IntraDistancek, "image", hv_Row7k, hv_Column7k, "green", "false"); disp_message(hv_WindowHandle, hv_IntraDistance1k, "image", hv_Row8k, hv_Column8k, "green", "false"); disp_message(hv_WindowHandle, hv_IntraDistance2k, "image", hv_Row9k, hv_Column9k, "green", "false"); } else { disp_message(hv_WindowHandle, "NG", "window", 0, 0, "red", "false"); disp_message(hv_WindowHandle, "高一" hv_Meank, "image", 593, 1652, "red", "false"); disp_message(hv_WindowHandle, "高二" hv_Mean1k, "image", 712, 1500, "red", "false"); disp_message(hv_WindowHandle, "高三" hv_Mean2k, "image", 630, 1200, "red", "false"); disp_message(hv_WindowHandle, "高四" hv_Mean3k, "image", 755, 1040, "red", "false"); disp_message(hv_WindowHandle, "高五" hv_Mean4k, "image", 570, 610, "red", "false"); disp_message(hv_WindowHandle, "高六" hv_Mean5k, "image", 720, 400, "red", "false"); disp_message(hv_WindowHandle, hv_IntraDistancek, "image", hv_Row7k, hv_Column7k, "red", "false"); disp_message(hv_WindowHandle, hv_IntraDistance1k, "image", hv_Row8k, hv_Column8k, "red", "false"); disp_message(hv_WindowHandle, hv_IntraDistance2k, "image", hv_Row9k, hv_Column9k, "red", "false"); } } else if ((int)(new HTuple((new HTuple(hv_Row6k.TupleLength())).TupleGreater(0))) == 0) { using (HDevDisposeHelper dh = new HDevDisposeHelper()) { hv_Row5.Dispose(); hv_Column5.Dispose(); hv_Angle.Dispose(); hv_Score.Dispose(); HOperatorSet.FindShapeModel(ho_Image, hv_ModelID, (new HTuple(-180)).TupleRad() , (new HTuple(360)).TupleRad(), 0.7, 1, 0.5, "least_squares", 0, 0.9, out hv_Row5, out hv_Column5, out hv_Angle, out hv_Score); } if ((int)(new HTuple((new HTuple(hv_Row5.TupleLength())).TupleGreater(0))) != 0) { hv_HomMat2D.Dispose(); HOperatorSet.VectorAngleToRigid(hv_Row4, hv_Column4, 0, hv_Row5, hv_Column5, hv_Angle, out hv_HomMat2D); hv_RowTrans.Dispose(); hv_ColTrans.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row1, hv_Column1, out hv_RowTrans, out hv_ColTrans); hv_RowTrans1.Dispose(); hv_ColTrans1.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row2, hv_Column2, out hv_RowTrans1, out hv_ColTrans1); ho_Regions5.Dispose(); hv_ResultRow.Dispose(); hv_ResultColumn.Dispose(); rake(ho_Image, out ho_Regions5, 20, 60, 15, 1, 20, "all", "max", hv_RowTrans, hv_ColTrans, hv_RowTrans1, hv_ColTrans1, out hv_ResultRow, out hv_ResultColumn); ho_Line.Dispose(); hv_Row16.Dispose(); hv_Col1.Dispose(); hv_Row26.Dispose(); hv_Col2.Dispose(); pts_to_best_line(out ho_Line, hv_ResultRow, hv_ResultColumn, 20, out hv_Row16, out hv_Col1, out hv_Row26, out hv_Col2); hv_RowTrans2.Dispose(); hv_ColTrans2.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row11, hv_Column11, out hv_RowTrans2, out hv_ColTrans2); hv_RowTrans3.Dispose(); hv_ColTrans3.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row21, hv_Column21, out hv_RowTrans3, out hv_ColTrans3); ho_Regions6.Dispose(); hv_ResultRow1.Dispose(); hv_ResultColumn1.Dispose(); rake(ho_Image, out ho_Regions6, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans2, hv_ColTrans2, hv_RowTrans3, hv_ColTrans3, out hv_ResultRow1, out hv_ResultColumn1); hv_Distance.Dispose(); HOperatorSet.DistancePl(hv_ResultRow1, hv_ResultColumn1, hv_Row16, hv_Col1, hv_Row26, hv_Col2, out hv_Distance); hv_RowTrans4.Dispose(); hv_ColTrans4.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row12, hv_Column12, out hv_RowTrans4, out hv_ColTrans4); hv_RowTrans5.Dispose(); hv_ColTrans5.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row22, hv_Column22, out hv_RowTrans5, out hv_ColTrans5); ho_Regions7.Dispose(); hv_ResultRow2.Dispose(); hv_ResultColumn2.Dispose(); rake(ho_Image, out ho_Regions7, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans4, hv_ColTrans4, hv_RowTrans5, hv_ColTrans5, out hv_ResultRow2, out hv_ResultColumn2); hv_Distance1.Dispose(); HOperatorSet.DistancePl(hv_ResultRow2, hv_ResultColumn2, hv_Row16, hv_Col1, hv_Row26, hv_Col2, out hv_Distance1); hv_RowTrans6.Dispose(); hv_ColTrans6.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row13, hv_Column13, out hv_RowTrans6, out hv_ColTrans6); hv_RowTrans7.Dispose(); hv_ColTrans7.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row23, hv_Column23, out hv_RowTrans7, out hv_ColTrans7); ho_Regions8.Dispose(); hv_ResultRow3.Dispose(); hv_ResultColumn3.Dispose(); rake(ho_Image, out ho_Regions8, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans6, hv_ColTrans6, hv_RowTrans7, hv_ColTrans7, out hv_ResultRow3, out hv_ResultColumn3); hv_Distance2.Dispose(); HOperatorSet.DistancePl(hv_ResultRow3, hv_ResultColumn3, hv_Row16, hv_Col1, hv_Row26, hv_Col2, out hv_Distance2); hv_RowTrans8.Dispose(); hv_ColTrans8.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row14, hv_Column14, out hv_RowTrans8, out hv_ColTrans8); hv_RowTrans9.Dispose(); hv_ColTrans9.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2D, hv_Row24, hv_Column24, out hv_RowTrans9, out hv_ColTrans9); ho_Regions9.Dispose(); hv_ResultRow4.Dispose(); hv_ResultColumn4.Dispose(); rake(ho_Image, out ho_Regions9, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans8, hv_ColTrans8, hv_RowTrans9, hv_ColTrans9, out hv_ResultRow4, out hv_ResultColumn4); hv_Distance3.Dispose(); HOperatorSet.DistancePl(hv_ResultRow4, hv_ResultColumn4, hv_Row16, hv_Col1, hv_Row26, hv_Col2, out hv_Distance3); hv_Width.Dispose(); hv_Height.Dispose(); HOperatorSet.GetImageSize(ho_Image, out hv_Width, out hv_Height); ho_RegionAffineTrans.Dispose(); HOperatorSet.AffineTransRegion(ho_Rectangle, out ho_RegionAffineTrans, hv_HomMat2D, "nearest_neighbor"); hv_Row6.Dispose(); hv_Column6.Dispose(); hv_Phi2.Dispose(); hv_Length12.Dispose(); hv_Length22.Dispose(); HOperatorSet.SmallestRectangle2(ho_RegionAffineTrans, out hv_Row6, out hv_Column6, out hv_Phi2, out hv_Length12, out hv_Length22); hv_MeasureHandle.Dispose(); HOperatorSet.GenMeasureRectangle2(hv_Row6, hv_Column6, hv_Phi2, hv_Length12, hv_Length22, hv_Width, hv_Height, "nearest_neighbor", out hv_MeasureHandle); hv_RowEdgeFirst.Dispose(); hv_ColumnEdgeFirst.Dispose(); hv_AmplitudeFirst.Dispose(); hv_RowEdgeSecond.Dispose(); hv_ColumnEdgeSecond.Dispose(); hv_AmplitudeSecond.Dispose(); hv_IntraDistance.Dispose(); hv_InterDistance.Dispose(); HOperatorSet.MeasurePairs(ho_Image, hv_MeasureHandle, 1, 30, "all", "all", out hv_RowEdgeFirst, out hv_ColumnEdgeFirst, out hv_AmplitudeFirst, out hv_RowEdgeSecond, out hv_ColumnEdgeSecond, out hv_AmplitudeSecond, out hv_IntraDistance, out hv_InterDistance); ho_RegionAffineTrans1.Dispose(); HOperatorSet.AffineTransRegion(ho_Rectangle1, out ho_RegionAffineTrans1, hv_HomMat2D, "nearest_neighbor"); hv_Row7.Dispose(); hv_Column7.Dispose(); hv_Phi3.Dispose(); hv_Length13.Dispose(); hv_Length23.Dispose(); HOperatorSet.SmallestRectangle2(ho_RegionAffineTrans1, out hv_Row7, out hv_Column7, out hv_Phi3, out hv_Length13, out hv_Length23); hv_MeasureHandle1.Dispose(); HOperatorSet.GenMeasureRectangle2(hv_Row7, hv_Column7, hv_Phi3, hv_Length13, hv_Length23, hv_Width, hv_Height, "nearest_neighbor", out hv_MeasureHandle1); hv_RowEdgeFirst1.Dispose(); hv_ColumnEdgeFirst1.Dispose(); hv_AmplitudeFirst1.Dispose(); hv_RowEdgeSecond1.Dispose(); hv_ColumnEdgeSecond1.Dispose(); hv_AmplitudeSecond1.Dispose(); hv_IntraDistance1.Dispose(); hv_InterDistance1.Dispose(); HOperatorSet.MeasurePairs(ho_Image, hv_MeasureHandle1, 1, 30, "all", "all", out hv_RowEdgeFirst1, out hv_ColumnEdgeFirst1, out hv_AmplitudeFirst1, out hv_RowEdgeSecond1, out hv_ColumnEdgeSecond1, out hv_AmplitudeSecond1, out hv_IntraDistance1, out hv_InterDistance1); hv_Mean.Dispose(); HOperatorSet.TupleMean(hv_Distance, out hv_Mean); hv_Mean1.Dispose(); HOperatorSet.TupleMean(hv_Distance1, out hv_Mean1); hv_Mean2.Dispose(); HOperatorSet.TupleMean(hv_Distance2, out hv_Mean2); hv_Mean3.Dispose(); HOperatorSet.TupleMean(hv_Distance3, out hv_Mean3); if (hv_Mean > h1 && hv_Mean < h2 && hv_Mean1 > h3 && hv_Mean1 < h4 && hv_Mean2 > th1 && hv_Mean2 < th2 && hv_Mean3 > th3 && hv_Mean3 < th4 && hv_IntraDistance > s1 && hv_IntraDistance < s2 && hv_IntraDistance1 > s1 && hv_IntraDistance1 < s2) { using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "高一" hv_Mean, "image", 640, 1600, "green", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "高二" hv_Mean1, "image", 580, 1400, "green", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "高三" hv_Mean2, "image", 640, 1150, "green", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "高四" hv_Mean3, "image", 580, 950, "green", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "宽一" hv_IntraDistance, "image", hv_Row6, hv_Column6, "green", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "宽二" hv_IntraDistance1, "image", hv_Row7, hv_Column7, "green", "false"); } disp_message(hv_WindowHandle, "OK", "window", 0, 0, "green", "true"); } else { using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "高一" hv_Mean, "image", 640, 1600, "red", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "高二" hv_Mean1, "image", 580, 1400, "red", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "高三" hv_Mean2, "image", 640, 1150, "red", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "高四" hv_Mean3, "image", 580, 950, "red", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "宽一" hv_IntraDistance, "image", hv_Row6, hv_Column6, "red", "false"); } using (HDevDisposeHelper dh = new HDevDisposeHelper()) { disp_message(hv_WindowHandle, "宽二" hv_IntraDistance1, "image", hv_Row7, hv_Column7, "red", "false"); } disp_message(hv_WindowHandle, "NG", "window", 0, 0, "red", "true"); } } } else { /////////////////////////////////////////////////// ////////////////////////////////////////////////// ///////////////////////////////////////////////// hv_Row3e.Dispose(); hv_Column3e.Dispose(); hv_Anglee.Dispose(); hv_Scoree.Dispose(); HOperatorSet.FindShapeModel(ho_Image, hv_ModelIDe, -0.39, 0.79, 0.7, 1, 0.5, "least_squares", 0, 0.9, out hv_Row3e, out hv_Column3e, out hv_Anglee, out hv_Scoree); if ((int)(new HTuple((new HTuple(hv_Row3e.TupleLength())).TupleGreater(0))) != 0) { hv_HomMat2De.Dispose(); HOperatorSet.VectorAngleToRigid(hv_Rowe, hv_Columne, 0, hv_Row3e, hv_Column3e, hv_Anglee, out hv_HomMat2De); hv_RowTranse.Dispose(); hv_ColTranse.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2De, hv_Row1e, hv_Column1e, out hv_RowTranse, out hv_ColTranse); hv_RowTrans1e.Dispose(); hv_ColTrans1e.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2De, hv_Row2e, hv_Column2e, out hv_RowTrans1e, out hv_ColTrans1e); ho_Regions3e.Dispose(); hv_ResultRowe.Dispose(); hv_ResultColumne.Dispose(); rake(ho_Image, out ho_Regions3e, 30, 60, 15, 1, 20, "all", "max", hv_RowTranse, hv_ColTranse, hv_RowTrans1e, hv_ColTrans1e, out hv_ResultRowe, out hv_ResultColumne); ho_Linee.Dispose(); hv_Row14e.Dispose(); hv_Col1e.Dispose(); hv_Row24e.Dispose(); hv_Col2e.Dispose(); pts_to_best_line(out ho_Linee, hv_ResultRowe, hv_ResultColumne, 20, out hv_Row14e, out hv_Col1e, out hv_Row24e, out hv_Col2e); hv_RowTrans2e.Dispose(); hv_ColTrans2e.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2De, hv_Row11e, hv_Column11e, out hv_RowTrans2e, out hv_ColTrans2e); hv_RowTrans3e.Dispose(); hv_ColTrans3e.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2De, hv_Row21e, hv_Column21e, out hv_RowTrans3e, out hv_ColTrans3e); ho_Regions4e.Dispose(); hv_ResultRow1e.Dispose(); hv_ResultColumn1e.Dispose(); rake(ho_Image, out ho_Regions4e, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans2e, hv_ColTrans2e, hv_RowTrans3e, hv_ColTrans3e, out hv_ResultRow1e, out hv_ResultColumn1e); hv_Distancee.Dispose(); HOperatorSet.DistancePl(hv_ResultRow1e, hv_ResultColumn1e, hv_Row14e, hv_Col1e, hv_Row24e, hv_Col2e, out hv_Distancee); hv_RowTrans4e.Dispose(); hv_ColTrans4e.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2De, hv_Row12e, hv_Column12e, out hv_RowTrans4e, out hv_ColTrans4e); hv_RowTrans5e.Dispose(); hv_ColTrans5e.Dispose(); HOperatorSet.AffineTransPixel(hv_HomMat2De, hv_Row22e, hv_Column22e, out hv_RowTrans5e, out hv_ColTrans5e); ho_Regions5e.Dispose(); hv_ResultRow2e.Dispose(); hv_ResultColumn2e.Dispose(); rake(ho_Image, out ho_Regions5e, 30, 60, 15, 1, 20, "all", "max", hv_RowTrans4e, hv_ColTrans4e, hv_RowTrans5e, hv_ColTrans5e, out hv_ResultRow2e, out hv_ResultColumn2e); hv_Distance1e.Dispose(); HOperatorSet.DistancePl(hv_ResultRow2e, hv_ResultColumn2e, hv_Row14e, hv_Col1e, hv_Row24e, hv_Col2e, out hv_Distance1e); hv_Meane.Dispose(); HOperatorSet.TupleMean(hv_Distancee, out hv_Meane); hv_Mean1e.Dispose(); HOperatorSet.TupleMean(hv_Distance1e, out hv_Mean1e); if (hv_Meane > eh1 && hv_Meane < eh2 && hv_Mean1e > eh3 && hv_Mean1e < eh4) { disp_message(hv_WindowHandle, "OK", "window", 0, 0, "green", "false"); disp_message(hv_WindowHandle, "高一" hv_Meane, "image", 609, 1641, "green", "false"); disp_message(hv_WindowHandle, "高二" hv_Mean1e, "image", 700, 1459, "green", "false"); } else { disp_message(hv_WindowHandle, "高一" hv_Meane, "image", 609, 1641, "red", "false"); disp_message(hv_WindowHandle, "高二" hv_Mean1e, "image", 700, 1459, "red", "false"); disp_message(hv_WindowHandle, "NG", "window", 0, 0, "red", "false"); } } } /////////////////////// ////////////////////// ///////////////////// } catch(Exception ex) { MessageBox.Show(ex.Message); } } private void button3_Click(object sender, EventArgs e) { OpenFileDialog Dlg = new OpenFileDialog(); Dlg.Filter = "(*.bmp;*.png;*.jpg;*.jpeg;*.tif)|*.bmp;*.png;*.jpg;*.jpeg;*.tif"; Dlg.Multiselect = false; if (Dlg.ShowDialog() == DialogResult.OK) { try { ho_Image.Dispose(); HOperatorSet.ReadImage(out ho_Image, Dlg.FileName); //显示全图 HTuple Width, Height; HOperatorSet.GetImageSize(ho_Image, out Width, out Height); //窗口自适应图像 HOperatorSet.SetPart(hv_WindowHandle, 0, 0, Height - 1, Width - 1); HOperatorSet.DispObj(ho_Image, hv_WindowHandle); } catch (Exception) { } } Dlg.Dispose(); } private void button4_Click(object sender, EventArgs e) { try { string wjj = Application.StartupPath "\\Data\\"; if (!Directory.Exists(wjj)) { Directory.CreateDirectory(wjj); } HOperatorSet.WriteTuple(hv_Row1, wjj "1.tup"); HOperatorSet.WriteTuple(hv_Column1, wjj "2.tup"); HOperatorSet.WriteTuple(hv_Row2, wjj "3.tup"); HOperatorSet.WriteTuple(hv_Column2, wjj "4.tup"); HOperatorSet.WriteTuple(hv_Row11, wjj "5.tup"); HOperatorSet.WriteTuple(hv_Column11, wjj "6.tup"); HOperatorSet.WriteTuple(hv_Row21, wjj "7.tup"); HOperatorSet.WriteTuple(hv_Column21, wjj "8.tup"); HOperatorSet.WriteTuple(hv_Row12, wjj "9.tup"); HOperatorSet.WriteTuple(hv_Column12, wjj "10.tup"); HOperatorSet.WriteTuple(hv_Row22, wjj "11.tup"); HOperatorSet.WriteTuple(hv_Column22, wjj "12.tup"); HOperatorSet.WriteTuple(hv_Row13, wjj "13.tup"); HOperatorSet.WriteTuple(hv_Column13, wjj "14.tup"); HOperatorSet.WriteTuple(hv_Row23, wjj "15.tup"); HOperatorSet.WriteTuple(hv_Column23, wjj "16.tup"); HOperatorSet.WriteTuple(hv_Row14, wjj "17.tup"); HOperatorSet.WriteTuple(hv_Column14, wjj "18.tup"); HOperatorSet.WriteTuple(hv_Row24, wjj "19.tup"); HOperatorSet.WriteTuple(hv_Column24, wjj "20.tup"); HOperatorSet.WriteTuple(hv_Row4, wjj "21.tup"); HOperatorSet.WriteTuple(hv_Column4, wjj "22.tup"); HOperatorSet.WriteRegion(ho_Rectangle, wjj "1.reg"); HOperatorSet.WriteRegion(ho_Rectangle1, wjj "2.reg"); HOperatorSet.WriteRegion(ho_Rectangle2, wjj "3.reg"); HOperatorSet.WriteShapeModel(hv_ModelID, wjj "1.shm"); ////////////////////////////////////////// ////////////////////////////////////// /////////////////////////////////////// HOperatorSet.WriteTuple(hv_Row1e, wjj "1e.tup"); HOperatorSet.WriteTuple(hv_Column1e, wjj "2e.tup"); HOperatorSet.WriteTuple(hv_Row2e, wjj "3e.tup"); HOperatorSet.WriteTuple(hv_Column2e, wjj "4e.tup"); HOperatorSet.WriteTuple(hv_Row11e, wjj "5e.tup"); HOperatorSet.WriteTuple(hv_Column11e, wjj "6e.tup"); HOperatorSet.WriteTuple(hv_Row21e, wjj "7e.tup"); HOperatorSet.WriteTuple(hv_Column21e, wjj "8e.tup"); HOperatorSet.WriteTuple(hv_Row12e, wjj "9e.tup"); HOperatorSet.WriteTuple(hv_Column12e, wjj "10e.tup"); HOperatorSet.WriteTuple(hv_Row22e, wjj "11e.tup"); HOperatorSet.WriteTuple(hv_Column22e, wjj "12e.tup"); HOperatorSet.WriteTuple(hv_Rowe, wjj "21e.tup"); HOperatorSet.WriteTuple(hv_Columne, wjj "22e.tup"); HOperatorSet.WriteRegion(ho_Rectanglee, wjj "1e.reg"); HOperatorSet.WriteShapeModel(hv_ModelIDe, wjj "1e.shm"); /////////////////////////// /////////////////////// //////////////////////// HOperatorSet.WriteTuple(hv_Row1k, wjj "1k.tup"); HOperatorSet.WriteTuple(hv_Column1k, wjj "2k.tup"); HOperatorSet.WriteTuple(hv_Row2k, wjj "3k.tup"); HOperatorSet.WriteTuple(hv_Column2k, wjj "4k.tup"); HOperatorSet.WriteTuple(hv_Row11k, wjj "5k.tup"); HOperatorSet.WriteTuple(hv_Column11k, wjj "6k.tup"); HOperatorSet.WriteTuple(hv_Row21k, wjj "7k.tup"); HOperatorSet.WriteTuple(hv_Column21k, wjj "8k.tup"); HOperatorSet.WriteTuple(hv_Row12k, wjj "9k.tup"); HOperatorSet.WriteTuple(hv_Column12k, wjj "10k.tup"); HOperatorSet.WriteTuple(hv_Row22k, wjj "11k.tup"); HOperatorSet.WriteTuple(hv_Column22k, wjj "12k.tup"); HOperatorSet.WriteTuple(hv_Row13k, wjj "13k.tup"); HOperatorSet.WriteTuple(hv_Column13k, wjj "14k.tup"); HOperatorSet.WriteTuple(hv_Row23k, wjj "15k.tup"); HOperatorSet.WriteTuple(hv_Column23k, wjj "16k.tup"); HOperatorSet.WriteTuple(hv_Row14k, wjj "17k.tup"); HOperatorSet.WriteTuple(hv_Column14k, wjj "18k.tup"); HOperatorSet.WriteTuple(hv_Row24k, wjj "19k.tup"); HOperatorSet.WriteTuple(hv_Column24k, wjj "20k.tup"); HOperatorSet.WriteTuple(hv_Row15k, wjj "21k.tup"); HOperatorSet.WriteTuple(hv_Column15k, wjj "22k.tup"); HOperatorSet.WriteTuple(hv_Row25k, wjj "23k.tup"); HOperatorSet.WriteTuple(hv_Column25k, wjj "24k.tup"); HOperatorSet.WriteTuple(hv_Row16k, wjj "25k.tup"); HOperatorSet.WriteTuple(hv_Column16k, wjj "26k.tup"); HOperatorSet.WriteTuple(hv_Row26k, wjj "27k.tup"); HOperatorSet.WriteTuple(hv_Column26k, wjj "28k.tup"); HOperatorSet.WriteTuple(hv_Row5k, wjj "29k.tup"); HOperatorSet.WriteTuple(hv_Column5k, wjj "30k.tup"); HOperatorSet.WriteRegion(ho_Rectanglek, wjj "1k.reg"); HOperatorSet.WriteRegion(ho_Rectangle1k, wjj "2k.reg"); HOperatorSet.WriteRegion(ho_Rectangle2k, wjj "3k.reg"); HOperatorSet.WriteRegion(ho_Rectangle3k, wjj "4k.reg"); HOperatorSet.WriteShapeModel(hv_ModelIDk, wjj "1k.shm"); MessageBox.Show("保存成功"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button5_Click(object sender, EventArgs e) { try { HOperatorSet.ReadImage(out ho_Image1, "C:/Users/HP/Desktop/新建文件夹 (2)/正面 (2).bmp"); HTuple Width, Height; HOperatorSet.GetImageSize(ho_Image1, out Width, out Height); HOperatorSet.SetPart(hv_WindowHandle, 0, 0, Height - 1, Width - 1); HOperatorSet.DispObj(ho_Image1, hv_WindowHandle); string wjj = Application.StartupPath "\\Data\\"; HOperatorSet.ReadTuple(wjj "1.tup", out hv_Row1); HOperatorSet.ReadTuple(wjj "2.tup", out hv_Column1); HOperatorSet.ReadTuple(wjj "3.tup", out hv_Row2); HOperatorSet.ReadTuple(wjj "4.tup", out hv_Column2); HOperatorSet.ReadTuple(wjj "5.tup", out hv_Row11); HOperatorSet.ReadTuple(wjj "6.tup", out hv_Column11); HOperatorSet.ReadTuple(wjj "7.tup", out hv_Row21); HOperatorSet.ReadTuple(wjj "8.tup", out hv_Column21); HOperatorSet.ReadTuple(wjj "9.tup", out hv_Row12); HOperatorSet.ReadTuple(wjj "10.tup", out hv_Column12); HOperatorSet.ReadTuple(wjj "11.tup", out hv_Row22); HOperatorSet.ReadTuple(wjj "12.tup", out hv_Column22); HOperatorSet.ReadTuple(wjj "13.tup", out hv_Row13); HOperatorSet.ReadTuple(wjj "14.tup", out hv_Column13); HOperatorSet.ReadTuple(wjj "15.tup", out hv_Row23); HOperatorSet.ReadTuple(wjj "16.tup", out hv_Column23); HOperatorSet.ReadTuple(wjj "17.tup", out hv_Row14); HOperatorSet.ReadTuple(wjj "18.tup", out hv_Column14); HOperatorSet.ReadTuple(wjj "19.tup", out hv_Row24); HOperatorSet.ReadTuple(wjj "20.tup", out hv_Column24); HOperatorSet.ReadTuple(wjj "21.tup", out hv_Row4); HOperatorSet.ReadTuple(wjj "22.tup", out hv_Column4); HOperatorSet.ReadRegion(out ho_Rectangle, wjj "1.reg"); HOperatorSet.ReadRegion(out ho_Rectangle1, wjj "2.reg"); HOperatorSet.ReadRegion(out ho_Rectangle2, wjj "3.reg"); HOperatorSet.ReadShapeModel(wjj "1.shm", out hv_ModelID); ///////////// //////////// /////////// HOperatorSet.ReadTuple(wjj "1e.tup", out hv_Row1e); HOperatorSet.ReadTuple(wjj "2e.tup", out hv_Column1e); HOperatorSet.ReadTuple(wjj "3e.tup", out hv_Row2e); HOperatorSet.ReadTuple(wjj "4e.tup", out hv_Column2e); HOperatorSet.ReadTuple(wjj "5e.tup", out hv_Row11e); HOperatorSet.ReadTuple(wjj "6e.tup", out hv_Column11e); HOperatorSet.ReadTuple(wjj "7e.tup", out hv_Row21e); HOperatorSet.ReadTuple(wjj "8e.tup", out hv_Column21e); HOperatorSet.ReadTuple(wjj "9e.tup", out hv_Row12e); HOperatorSet.ReadTuple(wjj "10e.tup", out hv_Column12e); HOperatorSet.ReadTuple(wjj "11e.tup", out hv_Row22e); HOperatorSet.ReadTuple(wjj "12e.tup", out hv_Column22e); HOperatorSet.ReadTuple(wjj "21e.tup", out hv_Rowe); HOperatorSet.ReadTuple(wjj "22e.tup", out hv_Columne); HOperatorSet.ReadRegion(out ho_Rectanglee, wjj "1e.reg"); HOperatorSet.ReadShapeModel(wjj "1e.shm", out hv_ModelIDe); ///////////////////// /////////////////// ///////////////// ///////////////////// HOperatorSet.ReadTuple(wjj "1k.tup", out hv_Row1k); HOperatorSet.ReadTuple(wjj "2k.tup", out hv_Column1k); HOperatorSet.ReadTuple(wjj "3k.tup", out hv_Row2k); HOperatorSet.ReadTuple(wjj "4k.tup", out hv_Column2k); HOperatorSet.ReadTuple(wjj "5k.tup", out hv_Row11k); HOperatorSet.ReadTuple(wjj "6k.tup", out hv_Column11k); HOperatorSet.ReadTuple(wjj "7k.tup", out hv_Row21k); HOperatorSet.ReadTuple(wjj "8k.tup", out hv_Column21k); HOperatorSet.ReadTuple(wjj "9k.tup", out hv_Row12k); HOperatorSet.ReadTuple(wjj "10k.tup", out hv_Column12k); HOperatorSet.ReadTuple(wjj "11k.tup", out hv_Row22k); HOperatorSet.ReadTuple(wjj "12k.tup", out hv_Column22k); HOperatorSet.ReadTuple(wjj "13k.tup", out hv_Row13k); HOperatorSet.ReadTuple(wjj "14k.tup", out hv_Column13k); HOperatorSet.ReadTuple(wjj "15k.tup", out hv_Row23k); HOperatorSet.ReadTuple(wjj "16k.tup", out hv_Column23k); HOperatorSet.ReadTuple(wjj "17k.tup", out hv_Row14k); HOperatorSet.ReadTuple(wjj "18k.tup", out hv_Column14k); HOperatorSet.ReadTuple(wjj "19k.tup", out hv_Row24k); HOperatorSet.ReadTuple(wjj "20k.tup", out hv_Column24k); HOperatorSet.ReadTuple(wjj "21k.tup", out hv_Row15k); HOperatorSet.ReadTuple(wjj "22k.tup", out hv_Column15k); HOperatorSet.ReadTuple(wjj "23k.tup", out hv_Row25k); HOperatorSet.ReadTuple(wjj "24k.tup", out hv_Column25k); HOperatorSet.ReadTuple(wjj "25k.tup", out hv_Row16k); HOperatorSet.ReadTuple(wjj "26k.tup", out hv_Column16k); HOperatorSet.ReadTuple(wjj "27k.tup", out hv_Row26k); HOperatorSet.ReadTuple(wjj "28k.tup", out hv_Column26k); HOperatorSet.ReadTuple(wjj "29k.tup", out hv_Row5k); HOperatorSet.ReadTuple(wjj "30k.tup", out hv_Column5k); HOperatorSet.ReadRegion(out ho_Rectanglek, wjj "1k.reg"); HOperatorSet.ReadRegion(out ho_Rectangle1k, wjj "2k.reg"); HOperatorSet.ReadRegion(out ho_Rectangle2k, wjj "3k.reg"); HOperatorSet.ReadRegion(out ho_Rectangle3k, wjj "4k.reg"); HOperatorSet.ReadShapeModel(wjj "1k.shm", out hv_ModelIDk); MessageBox.Show("读取成功"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox1_TextChanged(object sender, EventArgs e) { try { s1 = Convert.ToInt32(textBox1.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox2_TextChanged(object sender, EventArgs e) { try { s2 = Convert.ToInt32(textBox2.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox3_TextChanged(object sender, EventArgs e) { try { h1 = Convert.ToInt32(textBox3.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox4_TextChanged(object sender, EventArgs e) { try { h2 = Convert.ToInt32(textBox4.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox5_TextChanged(object sender, EventArgs e) { try { h3 = Convert.ToInt32(textBox5.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox6_TextChanged(object sender, EventArgs e) { try { h4 = Convert.ToInt32(textBox6.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox7_TextChanged(object sender, EventArgs e) { try { th1 = Convert.ToInt32(textBox7.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox8_TextChanged(object sender, EventArgs e) { try { th2 = Convert.ToInt32(textBox8.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox9_TextChanged(object sender, EventArgs e) { try { th3 = Convert.ToInt32(textBox9.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox10_TextChanged(object sender, EventArgs e) { try { th4 = Convert.ToInt32(textBox10.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { try { int mByte = this.serialPort1.BytesToRead; byte[] mData = new byte[mByte]; this.serialPort1.Read(mData, 0, mByte); string msg = Encoding.ASCII.GetString(mData); if (msg == "A0") { button2_Click(sender, e); } } catch(Exception ex) { MessageBox.Show(ex.Message); } } private void button6_Click(object sender, EventArgs e) { try { serialPort1.Open(); button1.Enabled = false; button2.Enabled = false; button3.Enabled = false; button4.Enabled = false; button5.Enabled = false; button6.Enabled = false; button8.Enabled = false; button9.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button7_Click(object sender, EventArgs e) { try { serialPort1.Close(); button1.Enabled = true; button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; button5.Enabled = true; button6.Enabled = true; button7.Enabled = true; button8.Enabled = true; button9.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button8_Click(object sender, EventArgs e) { try { ho_Image1e.Dispose(); HOperatorSet.ReadImage(out ho_Image1e, "C:/Users/HP/Desktop/新建文件夹 (2)/正面 (2).bmp"); HTuple Width, Height; HOperatorSet.GetImageSize(ho_Image1e, out Width, out Height); HOperatorSet.SetPart(hv_WindowHandle, 0, 0, Height - 1, Width - 1); HOperatorSet.DispObj(ho_Image1e, hv_WindowHandle); ho_Regionse.Dispose(); hv_Row1e.Dispose(); hv_Column1e.Dispose(); hv_Row2e.Dispose(); hv_Column2e.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regionse, hv_WindowHandle, 30, 60, 15, out hv_Row1e, out hv_Column1e, out hv_Row2e, out hv_Column2e); ho_Regions1e.Dispose(); hv_Row11e.Dispose(); hv_Column11e.Dispose(); hv_Row21e.Dispose(); hv_Column21e.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions1e, hv_WindowHandle, 30, 60, 15, out hv_Row11e, out hv_Column11e, out hv_Row21e, out hv_Column21e); ho_Regions2e.Dispose(); hv_Row12e.Dispose(); hv_Column12e.Dispose(); hv_Row22e.Dispose(); hv_Column22e.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions2e, hv_WindowHandle, 30, 60, 15, out hv_Row12e, out hv_Column12e, out hv_Row22e, out hv_Column22e); hv_Row13e.Dispose(); hv_Column13e.Dispose(); hv_Row23e.Dispose(); hv_Column23e.Dispose(); hWindowControl1.Focus(); HOperatorSet.DrawRectangle1(hv_WindowHandle, out hv_Row13e, out hv_Column13e, out hv_Row23e, out hv_Column23e); ho_Rectanglee.Dispose(); HOperatorSet.GenRectangle1(out ho_Rectanglee, hv_Row13e, hv_Column13e, hv_Row23e, hv_Column23e); hv_Areae.Dispose(); hv_Rowe.Dispose(); hv_Columne.Dispose(); HOperatorSet.AreaCenter(ho_Rectanglee, out hv_Areae, out hv_Rowe, out hv_Columne); ho_ImageReducede.Dispose(); HOperatorSet.ReduceDomain(ho_Image1e, ho_Rectanglee, out ho_ImageReducede); hv_ModelIDe.Dispose(); HOperatorSet.CreateShapeModel(ho_ImageReducede, "auto", -0.39, 0.79, "auto", "auto", "use_polarity", "auto", "auto", out hv_ModelIDe); MessageBox.Show("创建成功"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox11_TextChanged(object sender, EventArgs e) { try { eh1 = Convert.ToInt32(textBox11.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox12_TextChanged(object sender, EventArgs e) { try { eh2 = Convert.ToInt32(textBox12.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox13_TextChanged(object sender, EventArgs e) { try { eh3 = Convert.ToInt32(textBox13.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox14_TextChanged(object sender, EventArgs e) { try { eh4 = Convert.ToInt32(textBox14.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button9_Click(object sender, EventArgs e) { try { ho_Image1k.Dispose(); HOperatorSet.ReadImage(out ho_Image1k, "C:/Users/HP/Desktop/新建文件夹 (3)/反面 (1).bmp"); HTuple Width, Height; HOperatorSet.GetImageSize(ho_Image1k, out Width, out Height); HOperatorSet.SetPart(hv_WindowHandle, 0, 0, Height - 1, Width - 1); HOperatorSet.DispObj(ho_Image1k, hv_WindowHandle); ho_Regionsk.Dispose(); hv_Row1k.Dispose(); hv_Column1k.Dispose(); hv_Row2k.Dispose(); hv_Column2k.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regionsk, hv_WindowHandle, 30, 60, 15, out hv_Row1k, out hv_Column1k, out hv_Row2k, out hv_Column2k); ho_Regions1k.Dispose(); hv_Row11k.Dispose(); hv_Column11k.Dispose(); hv_Row21k.Dispose(); hv_Column21k.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions1k, hv_WindowHandle, 30, 60, 15, out hv_Row11k, out hv_Column11k, out hv_Row21k, out hv_Column21k); ho_Regions2k.Dispose(); hv_Row12k.Dispose(); hv_Column12k.Dispose(); hv_Row22k.Dispose(); hv_Column22k.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions2k, hv_WindowHandle, 30, 60, 15, out hv_Row12k, out hv_Column12k, out hv_Row22k, out hv_Column22k); ho_Regions3k.Dispose(); hv_Row13k.Dispose(); hv_Column13k.Dispose(); hv_Row23k.Dispose(); hv_Column23k.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions3k, hv_WindowHandle, 30, 60, 15, out hv_Row13k, out hv_Column13k, out hv_Row23k, out hv_Column23k); ho_Regions4k.Dispose(); hv_Row14k.Dispose(); hv_Column14k.Dispose(); hv_Row24k.Dispose(); hv_Column24k.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions4k, hv_WindowHandle, 30, 60, 15, out hv_Row14k, out hv_Column14k, out hv_Row24k, out hv_Column24k); ho_Regions5k.Dispose(); hv_Row15k.Dispose(); hv_Column15k.Dispose(); hv_Row25k.Dispose(); hv_Column25k.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions5k, hv_WindowHandle, 30, 60, 15, out hv_Row15k, out hv_Column15k, out hv_Row25k, out hv_Column25k); ho_Regions6k.Dispose(); hv_Row16k.Dispose(); hv_Column16k.Dispose(); hv_Row26k.Dispose(); hv_Column26k.Dispose(); hWindowControl1.Focus(); draw_rake(out ho_Regions6k, hv_WindowHandle, 30, 60, 15, out hv_Row16k, out hv_Column16k, out hv_Row26k, out hv_Column26k); hv_Rowk.Dispose(); hv_Columnk.Dispose(); hv_Phik.Dispose(); hv_Length1k.Dispose(); hv_Length2k.Dispose(); hWindowControl1.Focus(); HOperatorSet.DrawRectangle2(hv_WindowHandle, out hv_Rowk, out hv_Columnk, out hv_Phik, out hv_Length1k, out hv_Length2k); ho_Rectanglek.Dispose(); HOperatorSet.GenRectangle2(out ho_Rectanglek, hv_Rowk, hv_Columnk, hv_Phik, hv_Length1k, hv_Length2k); hv_Row3k.Dispose(); hv_Column3k.Dispose(); hv_Phi1k.Dispose(); hv_Length11k.Dispose(); hv_Length21k.Dispose(); hWindowControl1.Focus(); HOperatorSet.DrawRectangle2(hv_WindowHandle, out hv_Row3k, out hv_Column3k, out hv_Phi1k, out hv_Length11k, out hv_Length21k); ho_Rectangle1k.Dispose(); HOperatorSet.GenRectangle2(out ho_Rectangle1k, hv_Row3k, hv_Column3k, hv_Phi1k, hv_Length11k, hv_Length21k); hv_Row4k.Dispose(); hv_Column4k.Dispose(); hv_Phi2k.Dispose(); hv_Length12k.Dispose(); hv_Length22k.Dispose(); hWindowControl1.Focus(); HOperatorSet.DrawRectangle2(hv_WindowHandle, out hv_Row4k, out hv_Column4k, out hv_Phi2k, out hv_Length12k, out hv_Length22k); ho_Rectangle2k.Dispose(); HOperatorSet.GenRectangle2(out ho_Rectangle2k, hv_Row4k, hv_Column4k, hv_Phi2k, hv_Length12k, hv_Length22k); hv_Row17k.Dispose(); hv_Column17k.Dispose(); hv_Row27k.Dispose(); hv_Column27k.Dispose(); hWindowControl1.Focus(); HOperatorSet.DrawRectangle1(hv_WindowHandle, out hv_Row17k, out hv_Column17k, out hv_Row27k, out hv_Column27k); ho_Rectangle3k.Dispose(); HOperatorSet.GenRectangle1(out ho_Rectangle3k, hv_Row17k, hv_Column17k, hv_Row27k, hv_Column27k); hv_Areak.Dispose(); hv_Row5k.Dispose(); hv_Column5k.Dispose(); HOperatorSet.AreaCenter(ho_Rectangle3k, out hv_Areak, out hv_Row5k, out hv_Column5k); ho_ImageReducedk.Dispose(); HOperatorSet.ReduceDomain(ho_Image1k, ho_Rectangle3k, out ho_ImageReducedk); hv_ModelIDk.Dispose(); HOperatorSet.CreateShapeModel(ho_ImageReducedk, "auto", -0.39, 0.79, "auto", "auto", "use_polarity", "auto", "auto", out hv_ModelIDk); MessageBox.Show("创建成功"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox15_TextChanged(object sender, EventArgs e) { try { kh1 = Convert.ToInt32(textBox15.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox16_TextChanged(object sender, EventArgs e) { try { kh2 = Convert.ToInt32(textBox16.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox17_TextChanged(object sender, EventArgs e) { try { kh3 = Convert.ToInt32(textBox17.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox18_TextChanged(object sender, EventArgs e) { try { kh4 = Convert.ToInt32(textBox18.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox19_TextChanged(object sender, EventArgs e) { try { kth1 = Convert.ToInt32(textBox19.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox20_TextChanged(object sender, EventArgs e) { try { kth2 = Convert.ToInt32(textBox20.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox21_TextChanged(object sender, EventArgs e) { try { kth3 = Convert.ToInt32(textBox21.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox22_TextChanged(object sender, EventArgs e) { try { kth4 = Convert.ToInt32(textBox22.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox23_TextChanged(object sender, EventArgs e) { try { keh1 = Convert.ToInt32(textBox23.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox24_TextChanged(object sender, EventArgs e) { try { keh2 = Convert.ToInt32(textBox24.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox25_TextChanged(object sender, EventArgs e) { try { keh3 = Convert.ToInt32(textBox25.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox26_TextChanged(object sender, EventArgs e) { try { keh4 = Convert.ToInt32(textBox26.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复