2024-05-31 10:14:57 +08:00
using DVPCameraType ;
using Microsoft.VisualBasic.Logging ;
using OpenCvSharp ;
using OpenCvSharp.Dnn ;
using OpenCvSharp.Extensions ;
using OpenCvSharp.XFeatures2D ;
2024-06-11 11:40:47 +08:00
using System ;
2024-05-31 10:14:57 +08:00
using System.Data ;
2024-06-11 11:40:47 +08:00
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder ;
using System.Data.SQLite ;
2024-05-31 10:14:57 +08:00
using System.Diagnostics ;
2024-06-11 11:40:47 +08:00
using System.Diagnostics.Eventing.Reader ;
2024-05-31 10:14:57 +08:00
using System.Drawing ;
using System.Drawing.Drawing2D ;
using System.Net ;
using System.Numerics ;
2024-06-11 11:40:47 +08:00
using System.Text ;
2024-05-31 10:14:57 +08:00
using System.Text.RegularExpressions ;
using System.Windows.Forms ;
using XKRS.Device.SimboVision.SimboHelper ;
using static HisenceYoloDetection . MainForm ;
using static System . Runtime . InteropServices . JavaScript . JSType ;
using static System . Windows . Forms . VisualStyles . VisualStyleElement ;
2024-06-11 11:40:47 +08:00
using static System . Windows . Forms . VisualStyles . VisualStyleElement . ListView ;
2024-05-31 10:14:57 +08:00
namespace HisenceYoloDetection
{
public partial class MainForm : Form
{
public MainForm ( )
{
InitializeComponent ( ) ;
}
MGSCameraDriver Cam1 = new MGSCameraDriver ( ) ;
MGSCameraDriver Cam2 = new MGSCameraDriver ( ) ;
2024-06-17 11:02:28 +08:00
// HikCameraDriver Cam1 = new HikCameraDriver();
//HikCameraDriver Cam2 = new HikCameraDriver();
2024-05-31 10:14:57 +08:00
SQLiteHelper sqlhelper = new SQLiteHelper ( ) ;
TCPClienDriver Scanner = new TCPClienDriver ( ) ;
MelsecPLCTCPDriver melsecPLCTCPDriver = new MelsecPLCTCPDriver ( ) ;
SimboObjectDetection simboObjectDetection = new SimboObjectDetection ( ) ;
2024-06-11 11:40:47 +08:00
SimboObjectDetection simboObjectDetButton = new SimboObjectDetection ( ) ;
2024-06-17 11:02:28 +08:00
// CheckDiffSciHelper checkDiffSciHelper = new CheckDiffSciHelper();
2024-06-11 11:40:47 +08:00
// ManagerModelHelper managerModelHelper = new ManagerModelHelper();
2024-05-31 10:14:57 +08:00
PaddleOcrModel paddleOcrModel = new PaddleOcrModel ( ) ;
PaddleOcrModelCountry paddleOcrModelCountry = new PaddleOcrModelCountry ( ) ;
List < XKHisence > xKHisences = new List < XKHisence > ( ) ;
static AutoResetEvent myResetEvent = new AutoResetEvent ( false ) ;
bool PLC545 = false ;
bool PLC548 = false ;
string m_sKEYENCEBar ;
string IfChangeLanguage = "" ; //<2F> Ƿ<EFBFBD> <C7B7> <EFBFBD> ϴ<EFBFBD> »<EFBFBD> <C2BB> <EFBFBD> <EFBFBD> ͺ <EFBFBD>
bool bTriger = true ; //<2F> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> Դ<EFBFBD> <D4B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bool bBarTriger = false ; //<2F> <> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> ɺ<EFBFBD> <C9BA> <EFBFBD> <EFBFBD> ܴ<EFBFBD> <DCB4> <EFBFBD> <EFBFBD> ڶ<EFBFBD> <DAB6> <EFBFBD> λ<EFBFBD> <CEBB>
bool bBar = false ; //<2F> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> Է<EFBFBD> <D4B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bool IfCam1OneTriger = false ; //<2F> <> <EFBFBD> <EFBFBD> 1<EFBFBD> <31> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bool IfCam1TwoTriger = false ; //<2F> <> <EFBFBD> <EFBFBD> 1<EFBFBD> <31> 2<EFBFBD> <32> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bool IfCam2Triger = false ; //<2F> <> <EFBFBD> <EFBFBD> 2<EFBFBD> <32> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Mat Cam1ImgOne = new Mat ( ) ; //ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD> 1<EFBFBD> <31> <EFBFBD> <EFBFBD> Ƭ
Mat Cam1ImgTwo = new Mat ( ) ; //ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD> 1<EFBFBD> <31> <EFBFBD> <EFBFBD> Ƭ
Mat Cam2ImgShowBar = new Mat ( ) ; //ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD> 2<EFBFBD> <32> <EFBFBD> <EFBFBD> Ƭ <20> <> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
XKHisence xKNow ; //<2F> <> <EFBFBD> ݿ<EFBFBD> <DDBF> е <EFBFBD> ϴ<EFBFBD> »<EFBFBD> <C2BB> <EFBFBD> <EFBFBD> <EFBFBD>
2024-06-11 11:40:47 +08:00
XK_HisenceWord xK_HisenceSQLWord = new XK_HisenceWord ( ) ;
2024-05-31 10:14:57 +08:00
bool bOn = false ;
////////////////////////////
public static int m_CamCount = 0 ;
public int m_n_dev_count = 0 ;
public static dvpCameraInfo [ ] m_info = new dvpCameraInfo [ 16 ] ;
bool ifXZeroValue = false ;
bool ifYZeroValue = false ;
bool ifZZeroValue = false ;
bool ifXForward = false ;
bool ifYForward = false ;
bool ifZForward = false ;
bool ifXBackward = false ;
bool ifYBackward = false ;
bool ifZBackward = false ;
2024-06-11 11:40:47 +08:00
string LablePath = "" ;
2024-05-31 10:14:57 +08:00
//¼<> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD>
string BarPath = "" ;
string Cam1OnePath = "" ;
string Cam1TwoPath = "" ;
string ModelChangePath = "" ;
/// <summary>
/// <20> 鿴<EFBFBD> <E9BFB4> <EFBFBD> <EFBFBD> <EFBFBD> б <EFBFBD>
/// </summary>
public void InitDevList ( )
{
dvpStatus status ;
uint i , n = 0 ;
dvpCameraInfo dev_info = new dvpCameraInfo ( ) ;
// "n" represents the number of cameras that is enumerated successfully, the drop-down list contains each camera's FriendlyName.
DevNameCombo . Items . Clear ( ) ;
// Get the number of cameras that has been connected to a computer.
status = DVPCamera . dvpRefresh ( ref n ) ;
Debug . Assert ( status = = dvpStatus . DVP_STATUS_OK ) ;
m_n_dev_count = ( int ) n ;
if ( status = = dvpStatus . DVP_STATUS_OK )
{
m_CamCount = 0 ;
for ( i = 0 ; i < n ; i + + )
{
// Acquire each camera's information one by one.
status = DVPCamera . dvpEnum ( i , ref dev_info ) ;
Debug . Assert ( status = = dvpStatus . DVP_STATUS_OK ) ;
if ( status = = dvpStatus . DVP_STATUS_OK )
{
m_info [ m_CamCount ] = dev_info ;
int item = - 1 ;
// add User Define Name
item = DevNameCombo . Items . Add ( dev_info . UserID ) ;
if ( item = = 0 )
{
DevNameCombo . SelectedIndex = item ;
}
m_CamCount + + ;
if ( item = = 0 )
{
DevNameCombo . SelectedIndex = item ;
}
}
}
}
}
System . Timers . Timer SpeedTimer = new System . Timers . Timer ( ) ;
System . Timers . Timer PostionTimer = new System . Timers . Timer ( ) ;
public delegate void MyDelegateUI ( ) ; //<2F> <> <EFBFBD> <EFBFBD> ί<EFBFBD> <CEAF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
MyDelegateUI myDelegateUI ; //<2F> <> <EFBFBD> <EFBFBD> ί<EFBFBD> ж<EFBFBD> <D0B6> <EFBFBD>
public delegate void MyPosDelegateUI ( ) ; //<2F> <> <EFBFBD> <EFBFBD> ί<EFBFBD> <CEAF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
MyPosDelegateUI myPosDelegateUI ; //<2F> <> <EFBFBD> <EFBFBD> ί<EFBFBD> ж<EFBFBD> <D0B6> <EFBFBD>
public delegate void MyLogDelegateUI ( ) ; //<2F> <> <EFBFBD> <EFBFBD> ί<EFBFBD> <CEAF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
MyLogDelegateUI myLogDelegateUI ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ־ί<D6BE> ж<EFBFBD> <D0B6> <EFBFBD>
private void Application_ThreadException ( Exception e )
{
string msg = e . Message ;
using ( StreamWriter sw = new StreamWriter ( "D://ThreadException.log" , true ) )
{
sw . WriteLine ( "================================" ) ;
sw . WriteLine ( DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss.fff" ) ) ;
sw . WriteLine ( msg ) ;
sw . Flush ( ) ;
}
}
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainForm_Load ( object sender , EventArgs e )
{
2024-06-11 11:40:47 +08:00
2024-06-17 11:02:28 +08:00
2024-06-11 11:40:47 +08:00
string vBarPath = "D:\\Hisence\\<5C> <> <EFBFBD> <EFBFBD> \\Lp\\202452414231.jpg" ;
string vCam1OnePath = "D:\\Hisence\\<5C> <> <EFBFBD> <EFBFBD> \\Lp\\001.jpg" ;
string vCam1TwoPath = "D:\\Hisence\\<5C> <> <EFBFBD> <EFBFBD> \\Lp\\002.jpg" ;
2024-05-31 10:14:57 +08:00
string vModelChangePath = "D:\\Hisence\\config\\chinese.json" ;
2024-06-11 11:40:47 +08:00
string LablePathstr = "D:\\Hisence\\ClassName.txt" ; //<2F> <> ǩ·<C7A9> <C2B7>
string LablePathButtonstr = "D:\\Hisence\\ClassNameButton.txt" ; //<2F> <> ǩ·<C7A9> <C2B7>
2024-06-17 11:02:28 +08:00
//Mat cameraMat = Cv2.ImRead(vCam1TwoPath);
// canvas1.ImagePath = vCam1TwoPath;
// DefetShow.ImaMAt = cameraMat;
2024-06-11 11:40:47 +08:00
if ( File . Exists ( LablePathButtonstr ) & & File . Exists ( vBarPath ) & & File . Exists ( vCam1OnePath ) & & File . Exists ( vCam1TwoPath ) & & File . Exists ( vModelChangePath ) )
2024-05-31 10:14:57 +08:00
{
2024-06-11 11:40:47 +08:00
2024-05-31 10:14:57 +08:00
BarPath = vBarPath ;
Cam1OnePath = vCam1OnePath ;
Cam1TwoPath = vCam1TwoPath ;
ModelChangePath = vModelChangePath ;
}
ifXZeroValue = XZerorbx . Checked ;
ifYZeroValue = YZerorbx . Checked ;
InitDevList ( ) ;
this . WindowState = FormWindowState . Maximized ;
string Dectionstr = "D:\\Hisence\\best.onnx" ;
2024-06-11 11:40:47 +08:00
string DectionButtonstr = "D:\\Hisence\\HisenceButton.onnx" ;
2024-05-31 10:14:57 +08:00
string CountryStr = "D:\\Hisence\\config\\chinese.json" ;
2024-06-11 11:40:47 +08:00
if ( File . Exists ( LablePathstr ) & & File . Exists ( Dectionstr ) & & File . Exists ( CountryStr ) & & File . Exists ( DectionButtonstr ) )
2024-05-31 10:14:57 +08:00
{
2024-06-11 11:40:47 +08:00
LablePath = LablePathstr ;
2024-05-31 10:14:57 +08:00
}
else
{
2024-06-11 11:40:47 +08:00
MessageBox . Show ( "<22> <> <EFBFBD> <EFBFBD> " + Dectionstr + " " + CountryStr + " " + LablePathstr + "ģ<> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
2024-05-31 10:14:57 +08:00
return ;
}
//<2F> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
simboObjectDetection . Load ( Dectionstr , "CPU" , "images" , 640 , 640 ) ;
2024-06-11 11:40:47 +08:00
simboObjectDetButton . Load ( DectionButtonstr , "CPU" , "images" , 640 , 640 ) ;
2024-05-31 10:14:57 +08:00
paddleOcrModelCountry . Load ( CountryStr , "CPU" ) ;
paddleOcrModel . Load ( CountryStr , "CPU" ) ;
IfChangeLanguage = CountryStr ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
StartDecBtn . Enabled = false ;
myDelegateUI = new MyDelegateUI ( initAll ) ; //<2F> <> <EFBFBD> <EFBFBD> ί<EFBFBD> <CEAF>
myPosDelegateUI = new MyPosDelegateUI ( initAll2 ) ; //<2F> <> <EFBFBD> <EFBFBD> ί<EFBFBD> <CEAF>
myLogDelegateUI = new MyLogDelegateUI ( initAll3 ) ; //<2F> <> <EFBFBD> <EFBFBD> ί<EFBFBD> <CEAF>
//<2F> <> ʼ <EFBFBD> <CABC> PLC
melsecPLCTCPDriver . Start ( ) ;
melsecPLCTCPDriver . Heartbeat - = PLcHeratAdress ;
melsecPLCTCPDriver . Heartbeat + = PLcHeratAdress ;
OnSpeedShow ( ) ; //<2F> ߳̿<DFB3> <CCBF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ٶ<EFBFBD> <D9B6> <EFBFBD> ʾ <EFBFBD> ڽ<EFBFBD> <DABD> <EFBFBD> <EFBFBD> <EFBFBD>
OnPostionShow ( ) ; //<2F> ߳̿<DFB3> <CCBF> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> ʾ <EFBFBD> ڽ<EFBFBD> <DABD> <EFBFBD> <EFBFBD> <EFBFBD>
}
private void initAll ( ) //<2F> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
//richTextBox1.AppendText("TEST line \r");
if ( HspeedList . Count = = 33 )
{
lnEditmiXHS . Text = HspeedList [ 1 ] . ToString ( ) ;
lnEditmiYHS . Text = HspeedList [ 6 ] . ToString ( ) ;
lnEditmiZHS . Text = HspeedList [ 11 ] . ToString ( ) ;
//<2F> <> λ<EFBFBD> ٶ<EFBFBD>
lnEditmiXS . Text = HspeedList [ 0 ] . ToString ( ) ;
lnEditmiYS . Text = HspeedList [ 5 ] . ToString ( ) ;
lnEditmiZS . Text = HspeedList [ 10 ] . ToString ( ) ;
}
if ( disShow ! = 0 )
{
//TODOʵʱ<CAB5> <CAB1> ʽ ֪<> <D6AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƶ<EFBFBD> <C6B6> <EFBFBD> <EFBFBD> <EFBFBD>
double disreal = disShow * ( - 0.54054 ) + 1324.3232 ;
DistanceShow . Text = Math . Ceiling ( disreal ) . ToString ( ) ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ Ԫһ <D4AA> <D2BB> <EFBFBD> <EFBFBD>
//y = -0.54054x + 1324.3232
}
}
private void initAll2 ( ) //<2F> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
if ( relPosStrList . Count = = 31 )
{
// XPostion.Text = "";
XPostion . Text = relPosStrList [ 0 ] . ToString ( ) ;
//YPostion.Text = "";
YPostion . Text = relPosStrList [ 5 ] . ToString ( ) ;
// ZPostion.Text = "";
ZPostion . Text = relPosStrList [ 10 ] . ToString ( ) ;
}
}
string Logtxt = "" ;
private void initAll3 ( ) //<2F> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
richTextBox1 . AppendText ( Logtxt ) ;
AllDSum . Text = AllDsums . ToString ( ) ;
OKDNum . Text = OKDsums . ToString ( ) ;
NGDNum . Text = NGDsums . ToString ( ) ;
using ( StreamWriter stream = new StreamWriter ( "D://information.log" , true ) )
{
stream . WriteLine ( Logtxt ) ;
stream . Flush ( ) ;
}
}
private void OnSpeedShow ( )
{
Task . Run ( ( ) = >
{
while ( true )
{
try
{
UpDatePlcValue ( 600 , 2 ) ;
//<2F> <> 404 <20> <> ַ <20> <> 33<33> <33> <EFBFBD> <EFBFBD> ַ
UpDatePlcValue ( 404 , 33 ) ;
if ( HspeedList . Count = = 33 )
{
//<2F> ֶ<EFBFBD> <D6B6> ٶ<EFBFBD>
this . Invoke ( myDelegateUI ) ; //richTextBox1.AppendText("TEST line \r");
Application . DoEvents ( ) ;
}
if ( disShow ! = 0 )
{
this . Invoke ( myDelegateUI ) ; //richTextBox1.AppendText("TEST line \r");
Application . DoEvents ( ) ;
}
}
catch ( Exception ex )
{
}
Thread . Sleep ( 200 ) ;
}
} ) ;
}
private void OnPostionShow ( )
{
Task . Run ( ( ) = >
{
while ( true )
{
try
{
UpDatePlcValue ( 102 , 31 ) ;
if ( relPosStrList . Count = = 31 )
{
this . Invoke ( myPosDelegateUI ) ; //richTextBox1.AppendText("TEST line \r");
Application . DoEvents ( ) ;
}
}
catch ( Exception ex )
{
}
Thread . Sleep ( 200 ) ;
}
} ) ;
}
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CamOpenBtn_Click ( object sender , EventArgs e )
{
Cam1 . Start ( "Cam1" ) ;
bnGetParam . Enabled = true ;
SetCtrlWhenOpen ( ) ;
Cam1OpenBtn . BackColor = Color . Green ;
}
private void SetCtrlWhenOpen ( )
{
tbExposure . Enabled = true ;
tbGain . Enabled = true ;
// tbFrameRate.Enabled = true;
bnGetParam . Enabled = true ;
bnSetParam . Enabled = true ;
}
private void bnGetParam_Click ( object sender , EventArgs e )
{
2024-06-17 11:02:28 +08:00
// tbExposure.Text = Cam1.dvpGetExposure().ToString();
// tbGain.Text = Cam1.dvpGetAnalogGain().ToString();
2024-05-31 10:14:57 +08:00
}
private void bnGetParam2_Click ( object sender , EventArgs e )
{
//tbExposure2.Text = Cam1.dvpGetExposure().ToString();
//tbGain2.Text = Cam1.dvpGetAnalogGain().ToString();
}
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> 2<EFBFBD> <32> <EFBFBD> <EFBFBD>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Cam2OpenBtn_Click ( object sender , EventArgs e )
{
// Cam2.Start("Cam2");
// bnGetParam2.Enabled = true;
// Cam2OpenBtn.BackColor = Color.Green;
}
private void button2_Click ( object sender , EventArgs e )
{
Cam1 . Stop ( ) ;
SetCtrlWhenClose ( ) ;
}
private void SetCtrlWhenClose ( )
{
tbExposure . Enabled = false ;
tbGain . Enabled = false ;
// tbFrameRate.Enabled = false;
bnGetParam . Enabled = false ;
bnSetParam . Enabled = false ;
}
private void button3_Click ( object sender , EventArgs e )
{
Cam2 . Stop ( ) ;
}
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> 1<EFBFBD> <31> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SnapshotCam1_Click ( object sender , EventArgs e )
{
Cam1 . Snapshot ( ) ;
}
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> 2<EFBFBD> <32> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SnapshotCam2_Click ( object sender , EventArgs e )
{
//Cam2.Snapshot();
}
int TimesCalled = 0 ;
Bitmap OKbitmap = new Bitmap ( "OK.jpg" ) ;
Bitmap NGbitmap = new Bitmap ( "NG.jpg" ) ;
/// <summary>
/// <20> <> <EFBFBD> ̵߳<DFB3> <CCB5> <EFBFBD>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void InitMachine_Click ( object sender , EventArgs e )
{
try
{
//<2F> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
DataSet dataSet = SQLiteHelper . Query ( "select * from XK_HisenceDet" ) ;
2024-06-17 11:02:28 +08:00
//dataGridView1.DataSource = dataSet.Tables[0];
2024-05-31 10:14:57 +08:00
Cam1 . Start ( "Cam1" ) ;
if ( Cam1 . IfSuccess )
{
myLog ( "Cam1<6D> <31> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
Cam2 . Start ( "Cam2" ) ;
if ( Cam2 . IfSuccess )
{
myLog ( "Cam2<6D> <32> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
Cam1 . OnHImageOutput - = OnCameraMatOutPut ;
Cam1 . OnHImageOutput + = OnCameraMatOutPut ;
Cam2 . OnHImageOutput - = OnCameraMatOutPut2 ;
Cam2 . OnHImageOutput + = OnCameraMatOutPut2 ;
OKOrNGShow . Image = OKbitmap ;
//<2F> <> ʼ <EFBFBD> <CABC> ɨ<EFBFBD> <C9A8> ǹ
//Scanner.Strart();
//Scanner.OnClientDataReceived -= OnDataReceived;
//Scanner.OnClientDataReceived += OnDataReceived;
//Scanner.btnSendMsg("LON\r");//<2F> <> <EFBFBD> Ϳ <EFBFBD> <CDBF> <EFBFBD> ָ<EFBFBD> <D6B8>
//myLog("<22> <> <EFBFBD> Ͷ<EFBFBD> ʿɨ<CABF> <C9A8> ǹ<EFBFBD> <C7B9> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> ", DateTime.Now);
//PLCʹ <43> ܿ<EFBFBD> <DCBF> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "581" , 0 ) ; //<2F> <> λ<EFBFBD> ɿ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "504" , 0 ) ; //<2F> <> λ<EFBFBD> ɿ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "514" , 0 ) ; //<2F> <> λ<EFBFBD> ɿ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "524" , 0 ) ; //<2F> <> λ<EFBFBD> ɿ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "406" , 60000 ) ; //д<> <D0B4> <EFBFBD> ֶ<EFBFBD> <D6B6> ٶ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "416" , 8000 ) ;
2024-06-17 11:02:28 +08:00
melsecPLCTCPDriver . WriteInt ( "426" , 10000 ) ;
2024-05-31 10:14:57 +08:00
melsecPLCTCPDriver . WriteInt ( "404" , 100000 ) ; //д<> 붨λ<EBB6A8> ٶ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "414" , 8000 ) ;
2024-06-17 11:02:28 +08:00
melsecPLCTCPDriver . WriteInt ( "424" , 10000 ) ;
2024-05-31 10:14:57 +08:00
melsecPLCTCPDriver . WriteInt ( "500" , 0 ) ;
melsecPLCTCPDriver . WriteInt ( "500" , 1 ) ;
Thread . Sleep ( 200 ) ;
bOn = true ;
melsecPLCTCPDriver . WriteInt ( "580" , 0 ) ; //<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "580" , 1 ) ; //<2F> <> <EFBFBD> <EFBFBD>
Thread . Sleep ( 200 ) ;
melsecPLCTCPDriver . WriteInt ( "580" , 0 ) ;
Thread . Sleep ( 200 ) ;
while ( true )
{
int IfXZeros = melsecPLCTCPDriver . ReadInt ( "102" ) ;
int IfYZeros = melsecPLCTCPDriver . ReadInt ( "112" ) ;
int IfZZeros = melsecPLCTCPDriver . ReadInt ( "122" ) ;
2024-05-31 11:16:22 +08:00
if ( IfXZeros < = 140 & & IfYZeros < = 140 & & IfZZeros < = 140 )
2024-05-31 10:14:57 +08:00
{
StartDecBtn . Enabled = true ;
break ;
}
Thread . Sleep ( 10 ) ;
}
myLog ( "<22> 豸ȫ<E8B1B8> <C8AB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
catch ( Exception ex )
{
Application_ThreadException ( ex ) ;
}
}
2024-06-11 11:40:47 +08:00
2024-05-31 10:14:57 +08:00
/// <summary>
/// ȫͼϴ<CDBC> »<EFBFBD> <20> ü<EFBFBD> ֮<EFBFBD> <D6AE> OCRʶ<52> <CAB6> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
/// </summary>
2024-05-31 11:16:22 +08:00
/// <param name="currentMatC">ȫͼͼƬ</param>
/// <param name="cam1TwoML">ȫ<> <C8AB> ͼƬ<CDBC> ϵ<EFBFBD> Ŀ<EFBFBD> 궨λ<EAB6A8> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> ο <EFBFBD> <CEBF> <EFBFBD> </param>
/// <param name="strMatListList"><3E> <> <EFBFBD> صĶ<D8B5> λ<EFBFBD> <CEBB> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD> </param>
2024-06-11 11:40:47 +08:00
private void InsertSqlRunData2 ( ref Mat currentMatC , MLResult cam1TwoML , ref List < string > strMatListList , ref PaddleOcrModel IOcrModel )
2024-05-31 10:14:57 +08:00
{
2024-06-11 11:40:47 +08:00
2024-05-31 10:14:57 +08:00
2024-05-31 11:16:22 +08:00
#if true
2024-06-11 11:40:47 +08:00
try
2024-05-31 10:14:57 +08:00
{
List < Mat > mats = new List < Mat > ( ) ;
Mat mResultCut = currentMatC . Clone ( ) ;
string OcrTextinsert = "" ;
for ( int i = 0 ; i < cam1TwoML . ResultDetails . Count ; i + + )
{
Mat mResultCuti = mResultCut . Clone ( ) ;
int rectsx = cam1TwoML . ResultDetails [ i ] . Rect . X ;
int rectsy = cam1TwoML . ResultDetails [ i ] . Rect . Y ;
int rectsWidth = cam1TwoML . ResultDetails [ i ] . Rect . Width ;
int rectsHeight = cam1TwoML . ResultDetails [ i ] . Rect . Height ;
Rect area = new Rect ( rectsx , rectsy , rectsWidth , rectsHeight ) ;
Mat matroi = new Mat ( mResultCuti , area ) ;
mats . Add ( matroi ) ;
//OCRʶ<52> <CAB6> <EFBFBD> ü<EFBFBD> ͼƬ
MLRequest reqcut = new MLRequest ( ) ;
reqcut . currentMat = matroi . Clone ( ) ;
2024-06-11 11:40:47 +08:00
MLResult mLcut = IOcrModel . RunInferenceFixed ( reqcut ) ;
2024-05-31 10:14:57 +08:00
for ( int j = 0 ; j < mLcut . ResultDetails . Count ; j + + )
{
string jdetial = mLcut . ResultDetails [ j ] . LabelDisplay ;
2024-06-11 11:40:47 +08:00
string result = Regex . Replace ( jdetial , "[ \\[ \\] \\^ \\-_*<2A> <> <EFBFBD> D<EFBFBD> D(^)$%~!@#$<24> <> &%<25> <> <EFBFBD> <EFBFBD> +=<><3E> <> <EFBFBD> <EFBFBD> !<21> <> ??<3F> <> :<3A> <> ?`<60> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ,.;/\"<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> -]" , "" ) ;
strMatListList . Add ( result ) ;
OcrTextinsert + = result + "##" ;
2024-05-31 10:14:57 +08:00
}
}
}
catch ( Exception ex )
{
}
#endif
}
/// <summary>
/// <20> <> <EFBFBD> ݿ<EFBFBD> <DDBF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ<EFBFBD> <D3A6> OCR<43> ı <EFBFBD> <C4B1> Ƿ<EFBFBD> <C7B7> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD>
/// </summary>
/// <param name="WashBar"></param>
/// <param name="DetMatstrList"></param>
/// <returns></returns>
private bool IsMatchOcrText ( string WashBar , List < string > DetMatstrList )
{
try
{
2024-06-11 11:40:47 +08:00
2024-05-31 10:14:57 +08:00
List < string > strMatListListB = new List < string > ( ) ;
2024-06-11 11:40:47 +08:00
if ( WashBar . Contains ( "##" ) )
2024-05-31 10:14:57 +08:00
{
2024-06-11 11:40:47 +08:00
string [ ] sArray = Regex . Split ( WashBar , "##" , RegexOptions . IgnoreCase ) ;
2024-05-31 10:14:57 +08:00
for ( int i = 0 ; i < sArray . Count ( ) ; i + + )
{
if ( sArray [ i ] ! = "" )
{
strMatListListB . Add ( sArray [ i ] ) ;
}
}
}
var firstNotSecond = DetMatstrList . Except ( strMatListListB , StringComparer . OrdinalIgnoreCase ) . ToList ( ) ;
var secondNotFirst = strMatListListB . Except ( DetMatstrList , StringComparer . OrdinalIgnoreCase ) . ToList ( ) ;
if ( firstNotSecond . Count ( ) = = 0 & & secondNotFirst . Count ( ) = = 0 )
{
return true ;
}
return false ;
}
catch ( Exception ex )
{
return false ;
}
}
2024-06-11 11:40:47 +08:00
private bool IsFuzzyMatchOcrText ( string WashBar , List < string > DetMatstrList )
{
try
{
List < string > strMatListListB = new List < string > ( ) ;
if ( WashBar . Contains ( "##" ) )
{
string [ ] sArray = Regex . Split ( WashBar , "##" , RegexOptions . IgnoreCase ) ;
for ( int i = 0 ; i < sArray . Count ( ) ; i + + )
{
if ( sArray [ i ] ! = "" )
{
strMatListListB . Add ( sArray [ i ] ) ;
}
}
}
var firstNotSecond = DetMatstrList . Intersect ( strMatListListB , StringComparer . OrdinalIgnoreCase ) . ToList ( ) ;
//var secondNotFirst = strMatListListB.Except(DetMatstrList, StringComparer.OrdinalIgnoreCase).ToList();
if ( firstNotSecond . Count ( ) > ( strMatListListB . Count ) / 2 )
{
return true ;
}
return false ;
}
catch ( Exception ex )
{
return false ;
}
}
2024-05-31 10:14:57 +08:00
/// <summary>
/// ʵʱ<CAB5> ƶ<EFBFBD> ģ<EFBFBD> <C4A3>
/// </summary>
public void MoveToP ( int currentXP , int currentYP , int currentZP )
{
melsecPLCTCPDriver . WriteInt ( "581" , 0 ) ;
melsecPLCTCPDriver . WriteInt ( "402" , currentXP ) ;
melsecPLCTCPDriver . WriteInt ( "412" , currentYP ) ;
melsecPLCTCPDriver . WriteInt ( "422" , currentZP ) ;
melsecPLCTCPDriver . WriteInt ( "581" , 1 ) ;
Thread . Sleep ( 200 ) ;
melsecPLCTCPDriver . WriteInt ( "581" , 0 ) ;
while ( true )
{
int IfXZeros = melsecPLCTCPDriver . ReadInt ( "102" ) ;
int IfYZeros = melsecPLCTCPDriver . ReadInt ( "112" ) ;
int IfZZeros = melsecPLCTCPDriver . ReadInt ( "122" ) ;
if ( ( IfXZeros < currentXP + 20 ) & & ( IfXZeros > currentXP - 20 ) & & ( IfYZeros < = currentYP + 20 ) & & ( IfYZeros > = currentYP - 20 ) & & ( IfZZeros < = currentZP + 20 ) & & ( IfZZeros > = currentZP - 20 ) ) //TODO:<3A> <> <EFBFBD> õ<EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB>
{
break ;
}
Thread . Sleep ( 10 ) ;
}
}
public int disShow = new int ( ) ;
public List < int > MonitorValues { get ; set ; } = new List < int > ( ) ;
public List < int > relPosStrList { get ; set ; } = new List < int > ( ) ;
public List < int > HspeedList { get ; set ; } = new List < int > ( ) ;
/// <summary>
/// ʵʱˢ<CAB1> <CBA2> PLC<4C> <43> ַ<EFBFBD> <D6B7> ֵ
/// </summary>
///
public void UpDatePlcValue ( int Address , int length )
{
//Task.Run(() =>
//{
// while (true)
// {
try
{
//ʵʱˢ<CAB1> »<EFBFBD> е <EFBFBD> ֵ<EFBFBD> λ<EFBFBD> <CEBB>
List < int > newValues = melsecPLCTCPDriver . GetMonitorValues ( Address , length ) ;
if ( newValues = = null | | newValues . Count = = 0 )
return ;
Stopwatch sw = new Stopwatch ( ) ;
sw . Start ( ) ;
if ( Address = = 600 )
{
disShow = melsecPLCTCPDriver . ReadInt ( Convert . ToString ( Address ) ) ;
}
if ( Address = = 102 ) //<2F> <> <EFBFBD> <EFBFBD> ʼ <EFBFBD> <CABC> ַΪ102
{
if ( relPosStrList . Count = = newValues . Count )
{
var tempNew = new List < int > ( newValues ) ;
var tempOld = new List < int > ( relPosStrList ) ;
//MonitorCheckAndInvoke(tempNew, tempOld);
}
relPosStrList = new List < int > ( newValues ) ;
// relPosStrList = MonitorValues;
//ʵʱ<CAB5> <CAB1> ʾ <EFBFBD> ڽ<EFBFBD> <DABD> <EFBFBD> <EFBFBD> <EFBFBD>
}
if ( Address = = 404 )
{
if ( HspeedList . Count = = newValues . Count )
{
var tempNew = new List < int > ( newValues ) ;
var tempOld = new List < int > ( HspeedList ) ;
//MonitorCheckAndInvoke(tempNew, tempOld);
}
HspeedList = new List < int > ( newValues ) ;
//HspeedList = MonitorValues;
//ʵʱ<CAB5> <CAB1> ʾ <EFBFBD> ڽ<EFBFBD> <DABD> <EFBFBD> <EFBFBD> <EFBFBD>
}
sw . Stop ( ) ;
if ( sw . ElapsedMilliseconds > 20 )
{
//LogAsync(DateTime.Now, LogLevel.Detail, $"{this.Name}<7D> <> ѯʱ<D1AF> 䣺{sw.ElapsedMilliseconds}");
}
Thread . Sleep ( 20 ) ;
}
catch ( Exception ex )
{
}
// }
//});
}
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> ϴ<EFBFBD> »<EFBFBD> 545<34> Ƿ<C7B7> <F1B4A5B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 䴫<EFBFBD> <E4B4AB> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
/// </summary>
public void TrigerCamera1 ( )
{
//<2F> <> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> ̼߳<DFB3> <CCBC> <EFBFBD> PLC<4C> <43> ֵ
Task . Run ( ( ) = >
{
int iNum1 = 0 ;
int iNum0 = 0 ;
while ( true )
{
// myResetEvent.Set();
PLC545 = true ;
int m_iCureent545 = melsecPLCTCPDriver . ReadInt ( "545" ) ;
////int m_iCureent545 = CMPLC.SLMPReadD(545);
if ( m_iCureent545 ! = 1 )
{
iNum0 + + ;
}
else
{
iNum0 = 0 ;
}
if ( iNum0 > = 5 )
{
while ( true )
{
m_iCureent545 = melsecPLCTCPDriver . ReadInt ( "545" ) ;
if ( m_iCureent545 = = 1 )
{
iNum1 + + ;
}
else
{
iNum1 = 0 ;
}
if ( iNum1 > = 5 )
{
//Console.WriteLine("<22> ڶ<EFBFBD> <DAB6> βɼ<CEB2> ͼ<EFBFBD> <CDBC> ");
//Cam1.Snapshot();
//Cam2.Snapshot();
//IfCam1Triger = false;
//IfCam2Triger = false;
iNum0 = 0 ;
iNum1 = 0 ;
break ;
}
}
}
Thread . Sleep ( 100 ) ;
}
} ) ;
}
/// <summary>
/// <20> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> ʿ<EFBFBD> <CABF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͺ <EFBFBD>
/// </summary>
public void OnGetBar ( )
{
Task . Run ( ( ) = >
{
int iNum0 = 0 ;
int iNum1 = 0 ;
// const char pCR[4] = { 0x4C, 0x4F, 0x4E, 0x0D };<3B> <> <EFBFBD> <EFBFBD>
//const char pOFF[5] = { 0x4C, 0x4F, 0x46, 0x46, 0x0D };<3B> ر<EFBFBD>
Thread . CurrentThread . Priority = ThreadPriority . Highest ;
while ( true )
{
//545<34> <35> <EFBFBD> <EFBFBD> ʱΪ0
// myResetEvent.Set();
PLC545 = true ;
int m_iCureent545 = melsecPLCTCPDriver . ReadInt ( "545" ) ;
if ( m_iCureent545 ! = 1 )
{
iNum0 + + ;
}
else
{
iNum0 = 0 ;
}
if ( iNum0 > = 1 )
{
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8>
while ( true )
{
bTriger = false ;
//<2F> <> <EFBFBD> <EFBFBD> 544һ ֱ<D2BB> <D6B1> 1<EFBFBD> <31> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> s <20> <> <EFBFBD> <EFBFBD>
m_iCureent545 = melsecPLCTCPDriver . ReadInt ( "545" ) ;
if ( m_iCureent545 = = 1 )
{
iNum1 + + ;
}
else
{
iNum1 = 0 ;
}
if ( iNum1 > = 2 )
{
if ( bBar )
{
bBarTriger = true ; //<2F> ij<DEB8> <C4B3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ջ<EFBFBD> ȡ<EFBFBD> ͺ <EFBFBD>
Cam2 . SnapshotCount = 0 ;
Cam2 . Snapshot ( ) ;
xKNow = GetModeFromBar ( "VWJ070633V0WW80F0120356" ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> <DDBF> в<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
//xKNow = GetModeFromBar(m_sKEYENCEBar);//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> <DDBF> в<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
if ( Regex . IsMatch ( xKNow . MoveX . ToString ( ) , @"^[0-9]+$" ) & & Regex . IsMatch ( xKNow . MoveY . ToString ( ) , @"^[0-9]+$" ) & & Regex . IsMatch ( xKNow . MoveZ . ToString ( ) , @"^[0-9]+$" ) )
{
myLog ( "<22> ͺ <EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> ɹ<EFBFBD> " + m_sKEYENCEBar , DateTime . Now ) ;
bBarTriger = true ;
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC<4C> <43> <EFBFBD> Ƶ<EFBFBD> <C6B5> <EFBFBD> <EFBFBD> ƶ<EFBFBD> <C6B6> <EFBFBD> <EFBFBD> <EFBFBD>
}
break ;
}
Thread . Sleep ( 2 ) ;
bBar = false ;
}
}
}
}
Thread . Sleep ( 10 ) ;
} ) ;
}
2024-06-17 11:02:28 +08:00
int YPos = 6715 ;
int ZPos = 18857 ;
2024-05-31 10:14:57 +08:00
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> ϴ<EFBFBD> »<EFBFBD> 544<34> Ƿ<C7B7> <F1B4A5B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 䴫<EFBFBD> <E4B4AB> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
/// </summary>
public void TriggerCameral2 ( )
{
//<2F> <> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> ̼߳<DFB3> <CCBC> <EFBFBD> PLC<4C> <43> ֵ
Task . Run ( ( ) = >
{
try
{
int iNum1 = 0 ;
int iNum0 = 0 ;
Thread . CurrentThread . Priority = ThreadPriority . Highest ;
while ( true )
{
// myResetEvent.Set();
PLC548 = true ;
int m_iCureent548 = melsecPLCTCPDriver . ReadInt ( "548" ) ;
if ( m_iCureent548 ! = 0 )
{
iNum0 + + ;
}
else
{
iNum0 = 0 ;
}
if ( iNum0 > = 1 )
{
while ( true )
{
bTriger = false ;
//<2F> <> <EFBFBD> <EFBFBD> 544һ ֱ<D2BB> <D6B1> 1<EFBFBD> <31> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> s <20> <> <EFBFBD> <EFBFBD>
m_iCureent548 = melsecPLCTCPDriver . ReadInt ( "548" ) ;
if ( m_iCureent548 = = 0 )
{
iNum1 + + ;
}
else
{
iNum1 = 0 ;
}
if ( iNum1 > = 2 )
{
//if (bBarTriger)
{
myLog ( "<22> <> һ <EFBFBD> βɼ<CEB2> ͼ<EFBFBD> <CDBC> " , DateTime . Now ) ;
//<2F> ƶ<EFBFBD> ģ<EFBFBD> <C4A3> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> β<EFBFBD> <CEB2> <EFBFBD> <EFBFBD> ĵ<EFBFBD> ַ <20> <> <EFBFBD> Ƿ<EFBFBD> <C7B7> <EFBFBD> ǰ<EFBFBD> ƶ<EFBFBD>
2024-06-17 11:02:28 +08:00
MoveToP ( 5815 , YPos , ZPos ) ;
2024-06-11 11:40:47 +08:00
// Thread.Sleep(2000);//ɾ
2024-05-31 11:16:22 +08:00
2024-05-31 10:14:57 +08:00
List < int > DisList = new List < int > ( ) ;
for ( int i = 0 ; i < 5 ; i + + )
{
int m600 = melsecPLCTCPDriver . ReadInt ( "600" ) ;
DisList . Add ( m600 ) ;
}
DisList . Remove ( DisList . Max ( ) ) ;
DisList . Remove ( DisList . Min ( ) ) ;
// <20> <> <EFBFBD> <EFBFBD> ʣ<EFBFBD> <CAA3> ֵ<EFBFBD> <D6B5> ƽ <EFBFBD> <C6BD> <EFBFBD> <EFBFBD>
double average = DisList . Average ( ) ;
double disreal = average * ( - 0.54054 ) + 1324.3232 ;
2024-05-31 11:16:22 +08:00
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> -<2D> <> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> =Ҫ<> ƶ<EFBFBD> <C6B6> ľ<EFBFBD> <C4BE> <EFBFBD>
double dismove = disreal - 876 ;
2024-06-11 11:40:47 +08:00
if ( dismove > 0 & & dismove < 4000 )
2024-05-31 11:16:22 +08:00
{
2024-06-17 11:02:28 +08:00
MoveToP ( 5815 , YPos , ZPos + ( int ) ( dismove ) ) ;
2024-05-31 11:16:22 +08:00
}
2024-06-17 11:02:28 +08:00
//Thread.Sleep(2000);//ɾ
// Thread.Sleep(500);
2024-05-31 10:14:57 +08:00
Cam1 . SnapshotCount = 0 ;
Cam1 . Snapshot ( ) ;
2024-06-11 11:40:47 +08:00
IfCam2Triger = true ;
2024-05-31 10:14:57 +08:00
Cam2 . SnapshotCount = 0 ;
Cam2 . Snapshot ( ) ;
2024-06-11 11:40:47 +08:00
myLog ( "<22> ڶ<EFBFBD> <DAB6> βɼ<CEB2> ͼ<EFBFBD> <CDBC> " , DateTime . Now ) ;
2024-05-31 10:14:57 +08:00
//if (xKNow != null)
//{
// MoveToP(xKNow.MoveTwoX, xKNow.MoveTwoY, xKNow.MoveTwoZ);
//}
2024-06-11 11:40:47 +08:00
//currentXP = 54964;
//Thread.Sleep(2000);//ɾ
2024-06-17 11:02:28 +08:00
MoveToP ( 51043 , YPos , ZPos + ( int ) ( dismove ) ) ;
2024-05-31 10:14:57 +08:00
Cam1 . Snapshot ( ) ;
2024-06-17 11:02:28 +08:00
MoveToP ( 5815 , YPos , ZPos ) ;
2024-05-31 10:14:57 +08:00
//if (xKNow != null)
//{
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
//}
myLog ( "<22> ɼ<EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> ɹ<EFBFBD> " , DateTime . Now ) ;
//ģ<> 鸴λ
bTriger = true ; //<2F> <> <EFBFBD> Խ<EFBFBD> <D4BD> м<EFBFBD> <D0BC> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD>
bBarTriger = false ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Բ<EFBFBD> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
iNum0 = 0 ;
iNum1 = 0 ;
break ;
}
}
}
}
Thread . Sleep ( 10 ) ;
}
}
catch ( Exception e )
{
}
} ) ;
}
/// <summary>
/// PLC<4C> <43> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
/// </summary>
/// <param name="ifPlcHeart"></param>
public void PLcHeratAdress ( int ifPlcHeart )
{
if ( ifPlcHeart = = 1 )
{
myLog ( "PLC<4C> <43> <EFBFBD> <EFBFBD> ʧ<EFBFBD> <CAA7> " , DateTime . Now ) ;
}
else
{
}
}
/// <summary>
/// <20> <> 1<EFBFBD> <31> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ļص<C4BB>
/// </summary>
/// <param name="dt"></param>
/// <param name="cameraMat"></param>
/// <param name="SnapshotCount"></param>
public void OnCameraMatOutPut ( DateTime dt , Mat cameraMat , int SnapshotCount )
{
string fitImageFolder = "D://cam1//" ;
if ( ! Directory . Exists ( fitImageFolder ) )
{
Directory . CreateDirectory ( fitImageFolder ) ;
}
//<2F> <> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( SnapshotCount = = 1 )
{
2024-06-11 11:40:47 +08:00
// Mat mat = Cv2.ImRead("D:\\Hisence\\1\\202451716511.jpg");
//Mat mat = Cv2.ImRead("D:\\Hisence\\<5C> <> <EFBFBD> <EFBFBD> \\Lp\\2024517171911.jpg");
//Cam1ImgOne = mat;
2024-05-31 10:14:57 +08:00
Cam1ImgOne = cameraMat ;
2024-05-31 11:16:22 +08:00
IfCam1OneTriger = true ;
2024-05-31 10:14:57 +08:00
originMatShow . Image = cameraMat . ToBitmap ( ) ;
//pictureBox1.Image = cameraMat.ToBitmap();
}
//<2F> ڶ<EFBFBD> <DAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( SnapshotCount = = 2 )
{
2024-06-11 11:40:47 +08:00
// Mat mat = Cv2.ImRead("D:\\Hisence\\1\\2024517164541.jpg");
//Mat mat = Cv2.ImRead("D:\\Hisence\\<5C> <> <EFBFBD> <EFBFBD> \\Lp\\002.jpg");
//Cam1ImgTwo = mat;
2024-05-31 10:14:57 +08:00
Cam1ImgTwo = cameraMat ;
IfCam1TwoTriger = true ;
originMatShow2 . Image = cameraMat . ToBitmap ( ) ;
//pictureBox1.Image = cameraMat.ToBitmap();
}
2024-06-17 11:02:28 +08:00
CamShow1 . ImaMAt = cameraMat ;
2024-05-31 10:14:57 +08:00
cameraMat . ImWrite ( fitImageFolder + dt . Year . ToString ( ) + dt . Month . ToString ( ) + dt . Day . ToString ( ) + dt . Hour . ToString ( ) + dt . Minute . ToString ( ) + dt . Millisecond . ToString ( ) + "1.jpg" ) ;
}
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> 2<EFBFBD> <32> <EFBFBD> <EFBFBD> <EFBFBD> ص<EFBFBD>
/// </summary>
/// <param name="dt"></param>
/// <param name="cameraMat"></param>
/// <param name="SnapshotCount"></param>
public void OnCameraMatOutPut2 ( DateTime dt , Mat cameraMat , int SnapshotCount )
{
string fitImageFolder = "D://cam2//" ;
if ( ! Directory . Exists ( fitImageFolder ) )
{
Directory . CreateDirectory ( fitImageFolder ) ;
}
2024-06-11 11:40:47 +08:00
// Mat mat = Cv2.ImRead("F:\\<5C> <> <EFBFBD> <EFBFBD> ϴ<EFBFBD> »<EFBFBD> \\cam1\\2024517161641.jpg");
Cam2ImgShowBar = cameraMat ;
IfCam2Triger = true ;
2024-06-17 11:02:28 +08:00
originMat2Show . BackgroundImage = cameraMat . ToBitmap ( ) ;
//originMat2Show.Image = cameraMat.ToBitmap();
2024-06-11 11:40:47 +08:00
//pictureBox1.Image = cameraMat.ToBitmap();
2024-05-31 10:14:57 +08:00
2024-06-17 11:02:28 +08:00
CamShow2 . ImaMAt = cameraMat ;
2024-05-31 10:14:57 +08:00
cameraMat . ImWrite ( fitImageFolder + dt . Year . ToString ( ) + dt . Month . ToString ( ) + dt . Day . ToString ( ) + dt . Hour . ToString ( ) + dt . Minute . ToString ( ) + dt . Millisecond . ToString ( ) + "1.jpg" ) ;
}
public volatile int AllDsums = 0 ;
public volatile int NGDsums = 0 ;
public volatile int OKDsums = 0 ;
/// <summary>
/// <20> <> ʼ ʶ<CABC> <CAB6>
/// </summary>
public void ReadyDetect ( )
{
2024-06-11 11:40:47 +08:00
Task . Run ( ( Action ) ( ( ) = >
2024-05-31 10:14:57 +08:00
{
Thread . CurrentThread . Priority = ThreadPriority . Highest ;
while ( true )
{
try
{
//<2F> <> <EFBFBD> <EFBFBD> 2<EFBFBD> <32> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( IfCam2Triger )
{
//OCRʶ<52> <CAB6>
MLRequest req = new MLRequest ( ) ;
req . currentMat = Cam2ImgShowBar ;
2024-06-17 11:02:28 +08:00
// req.currentMat = Cv2.ImRead("D:\\Hisence\\<5C> <> <EFBFBD> <EFBFBD> \\Lp\\202453015229201.jpg");
2024-06-11 11:40:47 +08:00
MLResult mL = paddleOcrModelCountry . RunInferenceFixed ( req ) ;
//<2F> <> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD>
string IOcrBAr = "" ;
for ( int v = 0 ; v < Enumerable . Count < DetectionResultDetail > ( mL . ResultDetails ) ; v + + )
{
2024-06-17 11:02:28 +08:00
if ( mL . ResultDetails . Count ( ) > 0 )
{
if ( mL . ResultDetails . Count ( ) > 0 )
{
string iv = mL . ResultDetails [ 0 ] . LabelDisplay ;
string result = Regex . Replace ( iv , "[ \\[ \\] \\^ \\-_*<2A> <> <EFBFBD> D<EFBFBD> D(^)$%~!@#$<24> <> &%<25> <> <EFBFBD> <EFBFBD> +=<><3E> <> <EFBFBD> <EFBFBD> !<21> <> ??<3F> <> :<3A> <> ?`<60> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ,.;/\"<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> -]" , "" ) ;
2024-06-11 11:40:47 +08:00
2024-06-17 11:02:28 +08:00
IOcrBAr = result ;
}
}
}
DateTime dt = DateTime . Now ;
using ( StreamWriter sw = new StreamWriter ( "D://Hisence//logsBar.log" , true ) )
{
string filename = dt . Year . ToString ( ) + dt . Month . ToString ( ) + dt . Day . ToString ( ) + dt . Hour . ToString ( ) + dt . Minute . ToString ( ) + dt . Millisecond . ToString ( ) ;
sw . WriteLine ( filename + "\n" ) ;
sw . WriteLine ( IOcrBAr + "\n" ) ;
sw . Flush ( ) ;
2024-06-11 11:40:47 +08:00
}
2024-06-17 11:02:28 +08:00
IOcrBAr = "BatchW81XBModelWNHA62SASUASNVWJ060501V0WW81XB120024" ;
2024-06-11 11:40:47 +08:00
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> <DDBF> ȶ<EFBFBD>
xKNow = GetModeFromBar ( IOcrBAr ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> <DDBF> в<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
List < XK_HisenceWord > xkWordList = ManagerModelHelper . GetModeWordFromBar ( IOcrBAr ) ;
if ( xkWordList . Count ( ) = = 1 )
{
xK_HisenceSQLWord = xkWordList [ 0 ] ;
}
2024-05-31 10:14:57 +08:00
if ( xKNow . OcrBar = = null )
{
myLog ( "δƥ<CEB4> <C6A5> <EFBFBD> ɹ<EFBFBD> " + IfChangeLanguage , DateTime . Now ) ;
break ;
}
2024-06-17 11:02:28 +08:00
if ( xKNow . Detect ! = "" )
2024-05-31 10:14:57 +08:00
{
//<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> е <EFBFBD> ϴ<EFBFBD> »<EFBFBD> <C2BB> Ǻ<EFBFBD> ֮ǰһ <C7B0> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3>
2024-06-11 11:40:47 +08:00
if ( IfChangeLanguage = = IOcrBAr )
2024-05-31 10:14:57 +08:00
{
}
else
{
//<2F> <> <EFBFBD> ش<EFBFBD> <D8B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> OCR.josn<73> <6E> <EFBFBD> <EFBFBD>
if ( File . Exists ( xKNow . OcrParm ) )
{
paddleOcrModel . Load ( xKNow . OcrParm , "CPU" ) ;
2024-06-11 11:40:47 +08:00
IfChangeLanguage = IOcrBAr ;
2024-05-31 10:14:57 +08:00
}
}
myLog ( "<22> ͺ <EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> ɹ<EFBFBD> " + IfChangeLanguage , DateTime . Now ) ;
bBarTriger = true ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> <DDBF> <EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> <EFBFBD> ſ <EFBFBD> <C5BF> Խ<EFBFBD> <D4BD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> ƶ<EFBFBD>
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͺ ź<CDBA> <C5BA> ϴε<CFB4> <CEB5> ͺ <EFBFBD> һ <EFBFBD> <D2BB> <20> Ͳ<EFBFBD> <CDB2> û<EFBFBD> ʶ<EFBFBD> <CAB6> ģ<EFBFBD> <C4A3> ll
IfCam2Triger = false ;
}
//<2F> <> <EFBFBD> <EFBFBD> 1<EFBFBD> ڶ<EFBFBD> <DAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( IfCam1TwoTriger & & bBarTriger )
{
2024-06-11 11:40:47 +08:00
XK_HisenceWord xK_MatchDet = new XK_HisenceWord ( ) ;
xK_MatchDet . TwoIFWhile = xK_HisenceSQLWord . TwoIFWhile ;
2024-05-31 10:14:57 +08:00
AllDsums + + ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
MLRequest req = new MLRequest ( ) ;
req . currentMat = Cam1ImgOne ;
req . ResizeWidth = 640 ;
req . ResizeHeight = 640 ;
req . Score = 0.3f ;
2024-06-11 11:40:47 +08:00
req . in_lable_path = LablePath ; //<2F> <> ǩ·<C7A9> <C2B7>
2024-05-31 10:14:57 +08:00
req . confThreshold = 0.3f ; //ģ<> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD>
req . iouThreshold = 0.4f ; //<2F> <> <EFBFBD> <EFBFBD> IOU
req . out_node_name = "output" ;
MLResult mL = simboObjectDetection . RunInferenceFixed ( req ) ;
2024-06-11 11:40:47 +08:00
MLResult mLButton = simboObjectDetButton . RunInferenceFixed ( req ) ;
2024-06-17 11:02:28 +08:00
DateTime dt = DateTime . Now ;
2024-05-31 10:14:57 +08:00
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> е Ŀ<D0B5> <C4BF> ü<EFBFBD> ʶ<> <CAB6> <EFBFBD> ַ<EFBFBD> <D6B7> Ա<EFBFBD> <D4B1> ַ<EFBFBD> <D6B7> <EFBFBD>
2024-06-11 11:40:47 +08:00
List < string > strMatListOne = new List < string > ( ) ;
List < string > strMatFuzzyListOne = new List < string > ( ) ;
2024-05-31 10:14:57 +08:00
Mat mResultCut = req . currentMat . Clone ( ) ;
2024-06-11 11:40:47 +08:00
Mat mCut = new Mat ( ) ;
2024-06-17 11:02:28 +08:00
ManagerModelHelper . InsertSqlRunDataButton ( false , ref mCut , ref mResultCut , mL , mLButton , ref xK_MatchDet , ref strMatListOne , ref strMatFuzzyListOne , ref paddleOcrModel ) ;
2024-05-31 10:14:57 +08:00
2024-06-17 11:02:28 +08:00
if ( mL . ResultMap ! = null )
2024-06-11 11:40:47 +08:00
{
mL . ResultMap . Save ( "D://cam1//" + dt . Year . ToString ( ) + dt . Month . ToString ( ) + dt . Day . ToString ( ) + dt . Hour . ToString ( ) + dt . Minute . ToString ( ) + dt . Millisecond . ToString ( ) + "1result.jpg" ) ;
ResultMatShow . Image = mL . ResultMap ;
2024-05-31 10:14:57 +08:00
2024-06-11 11:40:47 +08:00
}
2024-05-31 10:14:57 +08:00
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
MLRequest req2 = new MLRequest ( ) ;
req2 . currentMat = Cam1ImgTwo ;
req2 . ResizeWidth = 640 ;
req2 . ResizeHeight = 640 ;
req2 . Score = 0.3f ;
2024-06-11 11:40:47 +08:00
req2 . in_lable_path = LablePath ; //<2F> <> ǩ·<C7A9> <C2B7>
2024-05-31 10:14:57 +08:00
req2 . confThreshold = 0.3f ; //ģ<> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD>
req2 . iouThreshold = 0.4f ; //<2F> <> <EFBFBD> <EFBFBD> IOU
req2 . out_node_name = "output" ;
MLResult mL2 = simboObjectDetection . RunInferenceFixed ( req2 ) ;
2024-06-11 11:40:47 +08:00
List < string > strMatListTwo = new List < string > ( ) ;
List < string > strMatFuzzyListTwo = new List < string > ( ) ;
2024-05-31 10:14:57 +08:00
Mat mResultCut2 = req2 . currentMat . Clone ( ) ;
2024-06-11 11:40:47 +08:00
ManagerModelHelper . InsertSqlRunData ( false , ref mResultCut2 , mL2 , ref xK_MatchDet , /*ref strMatListTwo, ref strMatFuzzyListTwo,*/ ref paddleOcrModel ) ;
if ( mL2 . ResultMap ! = null )
{
mL2 . ResultMap . Save ( "D://cam1//" + dt . Year . ToString ( ) + dt . Month . ToString ( ) + dt . Day . ToString ( ) + dt . Hour . ToString ( ) + dt . Minute . ToString ( ) + dt . Millisecond . ToString ( ) + "2result.jpg" ) ;
ResultMatShow2 . Image = mL2 . ResultMap ;
}
2024-05-31 10:14:57 +08:00
2024-06-11 11:40:47 +08:00
//ִ<> ж<EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
2024-05-31 10:14:57 +08:00
string [ ] listLabels = xKNow . Detect . Split ( "," ) ;
MLResult MLsum = mL ;
for ( int i = 0 ; i < mL2 . ResultDetails . Count ; i + + )
{
2024-06-11 11:40:47 +08:00
MLsum . ResultDetails . Add ( ( DetectionResultDetail ) mL2 . ResultDetails [ i ] ) ;
2024-05-31 10:14:57 +08:00
}
string [ ] RealLabels = new string [ MLsum . ResultDetails . Count ] ;
string detstr = "" ;
for ( int i = 0 ; i < MLsum . ResultDetails . Count ; i + + )
{
RealLabels [ i ] = MLsum . ResultDetails [ i ] . LabelName ;
if ( i < MLsum . ResultDetails . Count - 1 )
{
detstr + = RealLabels [ i ] + "," ;
}
else
{
detstr + = RealLabels [ i ] ;
}
}
2024-06-11 11:40:47 +08:00
///ִ<> б ȶ<D0B1> Сͼ
bool MatchStr = ManagerModelHelper . IsMatchSQLText ( ref mCut , ref xK_HisenceSQLWord , ref xK_MatchDet ) ;
2024-05-31 10:14:57 +08:00
IfCam1TwoTriger = false ;
bBarTriger = false ;
2024-06-17 11:02:28 +08:00
2024-05-31 10:14:57 +08:00
2024-06-11 11:40:47 +08:00
if ( MatchStr )
2024-05-31 10:14:57 +08:00
{
OKDsums + + ;
myLog ( "ƥ<> <C6A5> <EFBFBD> ɹ<EFBFBD> " , DateTime . Now ) ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʾ
2024-06-17 11:02:28 +08:00
// InsertXK_HisenceWordMatchData(xK_MatchDet, true);
this . Invoke ( new Action ( ( ) = >
{
OKOrNGShow . Image = OKbitmap ;
} ) ) ;
2024-05-31 10:14:57 +08:00
}
else
{
NGDsums + + ;
myLog ( "ƥ<> <C6A5> ʧ<EFBFBD> <CAA7> " , DateTime . Now ) ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʾ
2024-06-17 11:02:28 +08:00
// InsertXK_HisenceWordMatchData(xK_MatchDet, false);
this . Invoke ( new Action ( ( ) = >
{
OKOrNGShow . Image = NGbitmap ;
} ) ) ;
2024-05-31 10:14:57 +08:00
}
}
}
catch ( Exception e )
{
}
finally
{
}
Thread . Sleep ( 10 ) ;
}
2024-06-11 11:40:47 +08:00
} ) ) ;
2024-05-31 10:14:57 +08:00
}
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> <DDBF> л<EFBFBD> ȡ<EFBFBD> ͺ <EFBFBD>
/// </summary>
/// <param name="SkBar"></param>
/// <returns></returns>
public XKHisence GetModeFromBar ( string SkBar )
{
//<2F> <> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
DataSet ds = SQLiteHelper . Query ( $"select * from XK_Hisence where OCRBar='{SkBar}' " ) ;
2024-06-11 11:40:47 +08:00
2024-05-31 10:14:57 +08:00
XKHisence XK_hisence = new XKHisence ( ) ;
//cbx.DataSource = ds;
DataTableReader rdr = ds . CreateDataReader ( ) ;
2024-06-11 11:40:47 +08:00
//autxRecords = new List<AuxRecord>();
2024-05-31 10:14:57 +08:00
//cbx.Rows.Clear();
while ( rdr . Read ( ) ) //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
// xKOCROfficeWord.ID = (int)rdr["ID"];
XK_hisence . Type = ( string ) rdr [ "Type" ] ;
XK_hisence . OcrBar = ( string ) rdr [ "OcrBar" ] ;
XK_hisence . MoveX = ( int ) rdr [ "MoveX" ] ;
XK_hisence . MoveY = ( int ) rdr [ "MoveY" ] ;
XK_hisence . MoveZ = ( int ) rdr [ "MoveZ" ] ;
XK_hisence . Detect = ( string ) rdr [ "Detect" ] ;
XK_hisence . OcrText = ( string ) rdr [ "OcrText" ] ;
XK_hisence . MoveTwoX = ( int ) rdr [ "MoveTwoX" ] ;
XK_hisence . MoveTwoY = ( int ) rdr [ "MoveTwoY" ] ;
XK_hisence . MoveTwoZ = ( int ) rdr [ "MoveTwoZ" ] ;
XK_hisence . OcrParm = ( string ) rdr [ "OcrParm" ] ;
XK_hisence . Language = ( string ) rdr [ "Language" ] ;
2024-06-11 11:40:47 +08:00
XK_hisence . FuzzyOcrText = ( string ) rdr [ "FuzzyOcrText" ] ;
2024-05-31 10:14:57 +08:00
//xKHisences.Add(XK_hisence);
return XK_hisence ;
//additem(XK_hisence);
}
return XK_hisence ;
}
/// <summary>
/// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ļص<C4BB> <D8B5> <EFBFBD> <EFBFBD> <EFBFBD>
/// </summary>
/// <param name="data"></param>
public void OnDataReceived ( byte [ ] data )
{
//
if ( data . Length > 10 )
{
m_sKEYENCEBar = System . Text . Encoding . UTF8 . GetString ( data ) ;
// myLog("<22> ͺ <EFBFBD> Ocr" + m_sKEYENCEBar, DateTime.Now);
bBar = true ;
}
}
/// <summary>
/// PLC<4C> ij<EFBFBD> ʼ <EFBFBD> <CABC>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button4_Click ( object sender , EventArgs e )
{
melsecPLCTCPDriver . Start ( ) ;
myLog ( "<22> <> <EFBFBD> <EFBFBD> PLC<4C> ɹ<EFBFBD> " , DateTime . Now ) ;
}
/// <summary>
/// <20> <> ־
/// </summary>
/// <param name="txt"></param>
/// <param name="date"></param>
private void myLog ( string txt , DateTime date )
{
Logtxt = txt + " ʱ<> 䣺" + date . ToString ( ) + "\n" ;
this . Invoke ( myLogDelegateUI ) ; //richTextBox1.AppendText("TEST line \r");
Application . DoEvents ( ) ;
}
private void readAdress_Click ( object sender , EventArgs e )
{
if ( Regex . IsMatch ( readPLc . Text . ToString ( ) , @"^[0-9]+$" ) )
{
int m_iCureent545 = melsecPLCTCPDriver . ReadInt ( readPLc . Text . ToString ( ) ) ;
showPLC . Text = m_iCureent545 . ToString ( ) ;
myLog ( "<22> <> ȡ" + readPLc . Text . ToString ( ) + "<22> <> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void wirteAdress_Click ( object sender , EventArgs e )
{
try
{
if ( Regex . IsMatch ( WriteAdress . Text . ToString ( ) , @"^[0-9]+$" ) & & Regex . IsMatch ( PLCValue . Text . ToString ( ) , @"^[0-9]+$" ) )
{
melsecPLCTCPDriver . WriteInt ( WriteAdress . Text . ToString ( ) , Convert . ToInt16 ( PLCValue . Text ) ) ;
myLog ( "д" + WriteAdress . Text . ToString ( ) + "<22> <> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
catch ( Exception ex ) { }
}
private void ScanDevList_Click ( object sender , EventArgs e )
{
InitDevList ( ) ;
}
private void PLCPowerON_Click ( object sender , EventArgs e )
{
if ( bOn = = true )
{
melsecPLCTCPDriver . WriteInt ( "500" , 0 ) ;
// PLCcontrol->WritePlc(500, 0);
bOn = false ;
PLCPowerON . Text = "ʹ <> <CAB9> On" ;
myLog ( "ʹ <> <CAB9> On<4F> <6E> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
melsecPLCTCPDriver . WriteInt ( "500" , 1 ) ;
bOn = true ;
PLCPowerON . Text = "ʹ <> <CAB9> Off" ;
myLog ( "ʹ <> <CAB9> Off" , DateTime . Now ) ;
}
}
bool IfPLCDiskZero = false ;
bool IfPLCPostion = false ;
private void PLCDiskZero_Click ( object sender , EventArgs e )
{
//if (!IfPLCDiskZero)
//{
melsecPLCTCPDriver . WriteInt ( "580" , 0 ) ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "580" , 1 ) ;
Thread . Sleep ( 200 ) ;
melsecPLCTCPDriver . WriteInt ( "580" , 0 ) ;
IfPLCDiskZero = true ;
this . txtSetValue . Text = "1" ;
myLog ( "580<38> <30> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
//}
//else
//{
// melsecPLCTCPDriver.WriteInt("580", 0);
// IfPLCDiskZero = false;
// this.txtSetValue.Text = "0";
// myLog("580ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> ", DateTime.Now);
//}
}
private void PLCPostion_Click ( object sender , EventArgs e )
{
//if (!IfPLCPostion)
//{
try
{
if ( Regex . IsMatch ( lnEditmiXOP . Text . ToString ( ) , @"^[0-9]+$" ) & & Regex . IsMatch ( lnEditmiYOP . Text . ToString ( ) , @"^[0-9]+$" ) & & Regex . IsMatch ( lnEditmiZOP . Text . ToString ( ) , @"^[0-9]+$" ) )
{
if ( lnEditmiXOP . Text ! = "" & & lnEditmiYOP . Text ! = "" & & lnEditmiZOP . Text ! = "" )
{
//ͨ<> <CDA8> <EFBFBD> <EFBFBD> ȡ<EFBFBD> ༭<EFBFBD> <E0BCAD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ <20> <> ΪĿ<CEAA> <C4BF> λ<EFBFBD> <CEBB>
int iXTPosition = Convert . ToInt16 ( lnEditmiXOP . Text ) ; //<2F> <> λX<CEBB> <58> λ<EFBFBD> <CEBB>
int iYTPosition = Convert . ToInt16 ( lnEditmiYOP . Text ) ;
int iZTPosition = Convert . ToInt16 ( lnEditmiZOP . Text ) ;
//<2F> <> Ҫ<EFBFBD> <D2AA> λ<EFBFBD> <CEBB> λ<EFBFBD> <CEBB> д<EFBFBD> <D0B4>
melsecPLCTCPDriver . WriteInt ( "402" , iXTPosition ) ;
melsecPLCTCPDriver . WriteInt ( "412" , iYTPosition ) ;
melsecPLCTCPDriver . WriteInt ( "422" , iZTPosition ) ;
string logs = "д<> 붨λλ<CEBB> <CEBB> X" + iXTPosition + "Y:" + iYTPosition + "Z:" + iZTPosition + " " ;
myLog ( logs , DateTime . Now ) ;
}
}
melsecPLCTCPDriver . WriteInt ( "581" , 1 ) ;
Thread . Sleep ( 1000 ) ;
melsecPLCTCPDriver . WriteInt ( "581" , 0 ) ;
IfPLCPostion = true ;
this . txtSetValue . Text = "1" ;
myLog ( "XYZ<59> <5A> ʼ <EFBFBD> <CABC> λ581" , DateTime . Now ) ;
}
catch ( Exception ex )
{
}
//}
//else
//{
// melsecPLCTCPDriver.WriteInt("581", 0);
// IfPLCPostion = false;
// this.txtSetValue.Text = "0";
// myLog("XYZֹͣ581", DateTime.Now);
//}
}
private void StartDecBtn_Click ( object sender , EventArgs e )
{
//OnGetBar();
TriggerCameral2 ( ) ;
ReadyDetect ( ) ;
myLog ( "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̳ɹ<CCB3> " , DateTime . Now ) ;
}
private void InsertSqlBtn_Click ( object sender , EventArgs e )
{
2024-06-17 11:02:28 +08:00
2024-05-31 10:14:57 +08:00
}
private void RefeshData_Click ( object sender , EventArgs e )
{
DataSet dataSet = SQLiteHelper . Query ( "select * from XK_HisenceDet" ) ;
2024-06-17 11:02:28 +08:00
//dataGridView1.DataSource = dataSet.Tables[0];
2024-05-31 10:14:57 +08:00
}
private void panel8_Paint ( object sender , PaintEventArgs e )
{
}
private void SetHandleSpeed_Click ( object sender , EventArgs e )
{
if ( Regex . IsMatch ( lnEditmiXHS . Text . ToString ( ) , @"^[0-9]+$" ) & & Regex . IsMatch ( lnEditmiYHS . Text . ToString ( ) , @"^[0-9]+$" ) & & Regex . IsMatch ( lnEditmiZHS . Text . ToString ( ) , @"^[0-9]+$" ) )
{
if ( SetlnEditmiXH . Text ! = "" & & SetlnEditmiYH . Text ! = "" & & SetlnEditmiZH . Text ! = "" )
{
int XHspeed = Convert . ToInt32 ( SetlnEditmiXH . Text ) ; //X<> <58> <EFBFBD> ֶ<EFBFBD> <D6B6> ٶ<EFBFBD>
int YHspeed = Convert . ToInt32 ( SetlnEditmiYH . Text ) ; //Y<> <59> <EFBFBD> ֶ<EFBFBD> <D6B6> ٶ<EFBFBD>
int ZHspeed = Convert . ToInt32 ( SetlnEditmiZH . Text ) ; //Z<> <5A> <EFBFBD> ֶ<EFBFBD> <D6B6> ٶ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "406" , XHspeed ) ; //д<> <D0B4> <EFBFBD> ֶ<EFBFBD> <D6B6> ٶ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "416" , YHspeed ) ;
melsecPLCTCPDriver . WriteInt ( "426" , ZHspeed ) ;
string logs = "д<> <D0B4> <EFBFBD> ֶ<EFBFBD> <D6B6> ٶ<EFBFBD> X" + XHspeed + "Y:" + YHspeed + "Z:" + ZHspeed + " " ;
myLog ( logs , DateTime . Now ) ;
}
}
}
private void SetAutoSpeed_Click ( object sender , EventArgs e )
{
if ( Regex . IsMatch ( lnEditmiXS . Text . ToString ( ) , @"^[0-9]+$" ) & & Regex . IsMatch ( lnEditmiYS . Text . ToString ( ) , @"^[0-9]+$" ) & & Regex . IsMatch ( lnEditmiZS . Text . ToString ( ) , @"^[0-9]+$" ) )
{
if ( SetlnEditmiXOP . Text ! = "" & & SetlnEditmiYOP . Text ! = "" & & SetlnEditmiZOP . Text ! = "" )
{
int Xspeed = Convert . ToInt32 ( SetlnEditmiXOP . Text ) ; //X<> ᶨλ<E1B6A8> ٶ<EFBFBD>
int Yspeed = Convert . ToInt32 ( SetlnEditmiYOP . Text ) ; //Y<> ᶨλ<E1B6A8> ٶ<EFBFBD>
int Zspeed = Convert . ToInt32 ( SetlnEditmiZOP . Text ) ; //Z<> ᶨλ<E1B6A8> ٶ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "404" , Xspeed ) ; //д<> 붨λ<EBB6A8> ٶ<EFBFBD>
melsecPLCTCPDriver . WriteInt ( "414" , Yspeed ) ;
melsecPLCTCPDriver . WriteInt ( "424" , Zspeed ) ;
string logs = "д<> 붨λ<EBB6A8> ٶ<EFBFBD> X" + Xspeed + "Y:" + Yspeed + "Z:" + Zspeed + " " ;
myLog ( logs , DateTime . Now ) ;
}
}
}
//<2F> <> <EFBFBD> <EFBFBD> ״̬<D7B4> <CCAC> ʶ
private bool m_btnState ;
private void radioButton1_Click ( object sender , EventArgs e )
{
if ( ! ifXZeroValue )
{
this . XZerorbx . Checked = true ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "503" , 1 ) ;
ifXZeroValue = true ;
this . txtSetValue . Text = "1" ;
myLog ( "X<> Ὺʼ <E1BFAA> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
this . XZerorbx . Checked = false ;
melsecPLCTCPDriver . WriteInt ( "503" , 0 ) ;
ifXZeroValue = false ;
this . txtSetValue . Text = "0" ;
myLog ( "X<> <58> ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void YZerorbx_Click ( object sender , EventArgs e )
{
if ( ! ifYZeroValue )
{
this . YZerorbx . Checked = true ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "513" , 1 ) ;
ifYZeroValue = true ;
this . txtSetValue . Text = "1" ;
myLog ( "Y<> Ὺʼ <E1BFAA> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
this . YZerorbx . Checked = false ;
melsecPLCTCPDriver . WriteInt ( "513" , 0 ) ;
ifYZeroValue = false ;
this . txtSetValue . Text = "0" ;
myLog ( "Y<> <59> ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void ZZerorbx_Click ( object sender , EventArgs e )
{
if ( ! ifZZeroValue )
{
this . ZZerorbx . Checked = true ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "523" , 1 ) ;
ifZZeroValue = true ;
this . txtSetValue . Text = "1" ;
myLog ( "Z<> Ὺʼ <E1BFAA> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
this . ZZerorbx . Checked = false ;
melsecPLCTCPDriver . WriteInt ( "523" , 0 ) ;
ifZZeroValue = false ;
this . txtSetValue . Text = "0" ;
myLog ( "Z<> <5A> ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void XForwardrbx_Click ( object sender , EventArgs e )
{
if ( ! ifXForward )
{
this . XForwardrbx . Checked = true ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "502" , 1 ) ;
ifXForward = true ;
this . txtSetValue . Text = "1" ;
myLog ( "X<> Ὺʼ <E1BFAA> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
this . XForwardrbx . Checked = false ;
melsecPLCTCPDriver . WriteInt ( "502" , 0 ) ;
ifXForward = false ;
this . txtSetValue . Text = "0" ;
myLog ( "X<> <58> ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void YForwardrbx_Click ( object sender , EventArgs e )
{
if ( ! ifYForward )
{
this . YForwardrbx . Checked = true ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "512" , 1 ) ;
ifYForward = true ;
this . txtSetValue . Text = "1" ;
myLog ( "Y<> Ὺʼ <E1BFAA> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
this . YForwardrbx . Checked = false ;
melsecPLCTCPDriver . WriteInt ( "512" , 0 ) ;
ifYForward = false ;
this . txtSetValue . Text = "0" ;
myLog ( "Y<> <59> ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void ZForwardrbx_Click ( object sender , EventArgs e )
{
if ( ! ifZForward )
{
this . ZForwardrbx . Checked = true ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "522" , 1 ) ;
ifZForward = true ;
this . txtSetValue . Text = "1" ;
myLog ( "Z<> Ὺʼ <E1BFAA> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
this . ZForwardrbx . Checked = false ;
melsecPLCTCPDriver . WriteInt ( "522" , 0 ) ;
ifZForward = false ;
this . txtSetValue . Text = "0" ;
myLog ( "Z<> <5A> ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void XBackwardrbx_Click ( object sender , EventArgs e )
{
if ( ! ifXBackward )
{
this . XBackwardrbx . Checked = true ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "501" , 1 ) ;
ifXBackward = true ;
this . txtSetValue . Text = "1" ;
myLog ( "X<> Ὺʼ <E1BFAA> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
this . XBackwardrbx . Checked = false ;
melsecPLCTCPDriver . WriteInt ( "501" , 0 ) ;
ifXBackward = false ;
this . txtSetValue . Text = "0" ;
myLog ( "X<> <58> ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void YBackwardrbx_Click ( object sender , EventArgs e )
{
if ( ! ifYBackward )
{
this . YBackwardrbx . Checked = true ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "511" , 1 ) ;
ifYBackward = true ;
this . txtSetValue . Text = "1" ;
myLog ( "Y<> Ὺʼ <E1BFAA> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
this . YBackwardrbx . Checked = false ;
melsecPLCTCPDriver . WriteInt ( "511" , 0 ) ;
ifYBackward = false ;
this . txtSetValue . Text = "0" ;
myLog ( "Y<> <59> ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void ZBackwardrbx_Click ( object sender , EventArgs e )
{
if ( ! ifZBackward )
{
this . ZBackwardrbx . Checked = true ;
//<2F> <> <EFBFBD> <EFBFBD>
melsecPLCTCPDriver . WriteInt ( "521" , 1 ) ;
ifZBackward = true ;
this . txtSetValue . Text = "1" ;
myLog ( "Z<> Ὺʼ <E1BFAA> <CABC> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
else
{
this . ZBackwardrbx . Checked = false ;
melsecPLCTCPDriver . WriteInt ( "521" , 0 ) ;
ifZBackward = false ;
this . txtSetValue . Text = "0" ;
myLog ( "Z<> <5A> ֹͣ<CDA3> <D6B9> <EFBFBD> <EFBFBD> " , DateTime . Now ) ;
}
}
private void button1_Click ( object sender , EventArgs e )
{
string ss = "BB0VA5E0000BCQ5L0114" ;
}
private void Cam2OpenBtn_Click_1 ( object sender , EventArgs e )
{
Cam2 . Start ( "Cam2" ) ;
bnGetParam2 . Enabled = true ;
//SetCtrlWhenOpen();
Cam2OpenBtn . BackColor = Color . Green ;
}
private void button4_Click_1 ( object sender , EventArgs e )
{
OpenFileDialog openFileDialog = new OpenFileDialog ( ) ;
openFileDialog . Title = "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼƬ" ;
if ( openFileDialog . ShowDialog ( ) = = DialogResult . OK )
{
string fName = openFileDialog . FileName ;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
DetectBArMatbox . Text = fName ;
BarPath = fName ;
}
}
private void InsertBtn_Click ( object sender , EventArgs e )
{
2024-06-17 11:02:28 +08:00
2024-06-11 11:40:47 +08:00
2024-05-31 10:14:57 +08:00
try
{
string type = TypeBox . Text ;
string OcrBar = OcrBarBox . Text ;
string moveX = moveXbox . Text ;
string moveY = moveYbox . Text ;
string moveZ = moveZbox . Text ;
string Detect = DetectBArMatbox . Text ;
string movetwoX = moveTwoXbox . Text ;
string movetwoY = moveTwoYbox . Text ;
string movetwoZ = moveTwoZbox . Text ;
2024-06-11 11:40:47 +08:00
bool whiteBan = true ;
if ( WhiteBanCbx . CheckState = = CheckState . Checked ) //ѡ <> <D1A1>
{
whiteBan = true ;
2024-06-17 11:02:28 +08:00
2024-06-11 11:40:47 +08:00
}
else if ( WhiteBanCbx . CheckState = = CheckState . Unchecked ) //ûѡ <C3BB> <D1A1>
{
whiteBan = false ;
}
else
{
whiteBan = false ;
}
2024-05-31 10:14:57 +08:00
if ( ! Regex . IsMatch ( moveX , @"^[0-9]+$" ) )
{
MessageBox . Show ( "<22> <> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƶ<EFBFBD> <C6B6> <EFBFBD> Xֻ<58> <D6BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
return ;
}
if ( ! Regex . IsMatch ( moveY , @"^[0-9]+$" ) )
{
MessageBox . Show ( "<22> <> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƶ<EFBFBD> <C6B6> <EFBFBD> Yֻ<59> <D6BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
return ;
}
if ( ! Regex . IsMatch ( moveZ , @"^[0-9]+$" ) )
{
MessageBox . Show ( "<22> <> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƶ<EFBFBD> <C6B6> <EFBFBD> Zֻ<5A> <D6BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
return ;
}
if ( ! Regex . IsMatch ( movetwoX , @"^[0-9]+$" ) )
{
MessageBox . Show ( "<22> ڶ<EFBFBD> <DAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƶ<EFBFBD> <C6B6> <EFBFBD> Xֻ<58> <D6BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
return ;
}
if ( ! Regex . IsMatch ( movetwoY , @"^[0-9]+$" ) )
{
MessageBox . Show ( "<22> ڶ<EFBFBD> <DAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƶ<EFBFBD> <C6B6> <EFBFBD> Yֻ<59> <D6BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
return ;
}
if ( ! Regex . IsMatch ( movetwoZ , @"^[0-9]+$" ) )
{
MessageBox . Show ( "<22> ڶ<EFBFBD> <DAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƶ<EFBFBD> <C6B6> <EFBFBD> Zֻ<5A> <D6BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
return ;
}
2024-06-11 11:40:47 +08:00
if ( Detect ! = "" & & BarPath ! = "" & & Cam1OnePath ! = "" & & Cam1TwoPath ! = "" & & ModelChangePath ! = "" )
2024-05-31 10:14:57 +08:00
{
int HmoveX = ( int ) Convert . ToInt64 ( moveX ) ;
int HmoveY = ( int ) Convert . ToInt64 ( moveY ) ;
int HmoveZ = ( int ) Convert . ToInt64 ( moveZ ) ;
int HmovetwoX = ( int ) Convert . ToInt64 ( movetwoX ) ;
int HmovetwoY = ( int ) Convert . ToInt64 ( movetwoY ) ;
int HmovetwoZ = ( int ) Convert . ToInt64 ( movetwoZ ) ;
2024-06-17 11:02:28 +08:00
InsertXK_Hisence ( whiteBan , HmoveX , HmoveY , HmoveZ , HmovetwoX , HmovetwoY , HmovetwoZ ) ;
2024-05-31 10:14:57 +08:00
}
else
{
MessageBox . Show ( "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݲ<EFBFBD> <DDB2> <EFBFBD> ΪNULL" ) ;
}
}
catch ( Exception es )
{
2024-06-11 11:40:47 +08:00
MessageBox . Show ( es . Message ) ;
2024-05-31 10:14:57 +08:00
}
}
2024-06-17 11:02:28 +08:00
public void InsertXK_Hisence ( bool ifwhiteBan , int MoveX , int MoveY , int MoveZ , int MoveTwoX , int MoveTwoY , int MoveTwoZ )
2024-05-31 10:14:57 +08:00
{
PaddleOcrModel IpaddleOcrModel = new PaddleOcrModel ( ) ;
IpaddleOcrModel . Load ( ModelChangePath , "CPU" ) ;
2024-06-11 11:40:47 +08:00
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
2024-05-31 10:14:57 +08:00
MLRequest OcrBari = new MLRequest ( ) ;
OcrBari . currentMat = Cv2 . ImRead ( BarPath ) ;
2024-06-11 11:40:47 +08:00
MLResult mL2 = paddleOcrModelCountry . RunInferenceFixed ( OcrBari ) ;
2024-05-31 10:14:57 +08:00
string IOcrBAr = "" ;
for ( int v = 0 ; v < mL2 . ResultDetails . Count ( ) ; v + + )
{
2024-06-11 11:40:47 +08:00
string ivi = mL2 . ResultDetails [ v ] . LabelDisplay ;
string result = Regex . Replace ( ivi , "[ \\[ \\] \\^ \\-_*<2A> <> <EFBFBD> D<EFBFBD> D(^)$%~!@#$<24> <> &%<25> <> <EFBFBD> <EFBFBD> +=<><3E> <> <EFBFBD> <EFBFBD> !<21> <> ??<3F> <> :<3A> <> ?`<60> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ,.;/\"<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> -]" , "" ) ;
IOcrBAr + = result ;
2024-05-31 10:14:57 +08:00
}
2024-06-11 11:40:47 +08:00
OcrBarBox . Text = IOcrBAr ;
XK_HisenceWord xkWord = new XK_HisenceWord ( ) ;
xkWord . OcrBar = IOcrBAr ;
xkWord . TwoIFWhile = ifwhiteBan ;
2024-05-31 10:14:57 +08:00
using ( StreamWriter sw = new StreamWriter ( "D://123.log" , true ) )
{
sw . WriteLine ( "\n" ) ;
sw . WriteLine ( IOcrBAr ) ;
sw . Flush ( ) ;
}
2024-06-11 11:40:47 +08:00
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> е Ŀ<D0B5> <C4BF> ü<EFBFBD> ʶ<> <CAB6> <EFBFBD> ַ<EFBFBD> <D6B7> Ա<EFBFBD> <D4B1> ַ<EFBFBD> <D6B7> <EFBFBD>
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//<2F> ӵ<EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȫͼ<C8AB> <CDBC> Χ <EFBFBD> <CEA7> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȼ<EFBFBD> <C8BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> OCRʶ<52> <CAB6>
2024-05-31 10:14:57 +08:00
MLRequest CamOneI = new MLRequest ( ) ;
CamOneI . currentMat = Cv2 . ImRead ( Cam1OnePath ) ;
CamOneI . ResizeWidth = 640 ;
CamOneI . ResizeHeight = 640 ;
CamOneI . Score = 0.3f ;
2024-06-11 11:40:47 +08:00
CamOneI . in_lable_path = LablePath ; //<2F> <> ǩ·<C7A9> <C2B7>
2024-05-31 10:14:57 +08:00
CamOneI . confThreshold = 0.3f ; //ģ<> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD>
CamOneI . iouThreshold = 0.4f ; //<2F> <> <EFBFBD> <EFBFBD> IOU
CamOneI . out_node_name = "output" ;
MLResult mL3 = simboObjectDetection . RunInferenceFixed ( CamOneI ) ;
2024-06-11 11:40:47 +08:00
MLResult mLButton = simboObjectDetButton . RunInferenceFixed ( CamOneI ) ;
//if (mL3.IsSuccess)
//{
// DateTime dt = DateTime.Now;
// mL3.ResultMap.Save("D:\\Hisence\\detImages\\" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
2024-05-31 10:14:57 +08:00
2024-06-11 11:40:47 +08:00
//}
List < string > strMatListOne = new List < string > ( ) ;
List < string > strMatFuzzyListOne = new List < string > ( ) ;
2024-05-31 10:14:57 +08:00
Mat mResultCut = CamOneI . currentMat . Clone ( ) ;
2024-06-11 11:40:47 +08:00
Mat mCut = new Mat ( ) ;
2024-06-17 11:02:28 +08:00
ManagerModelHelper . InsertSqlRunDataButton ( true , ref mCut , ref mResultCut , mL3 , mLButton , ref xkWord , ref strMatListOne , ref strMatFuzzyListOne , ref paddleOcrModel ) ;
2024-06-11 11:40:47 +08:00
2024-05-31 10:14:57 +08:00
MLRequest CamTwoI = new MLRequest ( ) ;
CamTwoI . currentMat = Cv2 . ImRead ( Cam1TwoPath ) ;
CamTwoI . ResizeWidth = 640 ;
CamTwoI . ResizeHeight = 640 ;
CamTwoI . Score = 0.3f ;
2024-06-11 11:40:47 +08:00
CamTwoI . in_lable_path = LablePath ; //<2F> <> ǩ·<C7A9> <C2B7>
2024-05-31 10:14:57 +08:00
CamTwoI . confThreshold = 0.3f ; //ģ<> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD>
CamTwoI . iouThreshold = 0.4f ; //<2F> <> <EFBFBD> <EFBFBD> IOU
CamTwoI . out_node_name = "output" ;
MLResult mL4 = simboObjectDetection . RunInferenceFixed ( CamTwoI ) ;
2024-06-11 11:40:47 +08:00
//if (mL4.IsSuccess)
//{
// DateTime dt = DateTime.Now;
// mL4.ResultMap.Save("D:\\Hisence\\detImages\\" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
2024-05-31 10:14:57 +08:00
2024-06-11 11:40:47 +08:00
//}
List < string > strMatListTwo = new List < string > ( ) ;
List < string > strMatFuzzyListTwo = new List < string > ( ) ;
Mat mResultCut2 = CamTwoI . currentMat . Clone ( ) ;
ManagerModelHelper . InsertSqlRunData ( true , ref mResultCut2 , mL4 , ref xkWord , /* ref strMatListTwo, ref strMatFuzzyListTwo,*/ ref paddleOcrModel ) ;
2024-05-31 10:14:57 +08:00
2024-06-17 11:02:28 +08:00
InsertXKHisenceWordData ( xkWord ) ; //<2F> <> <EFBFBD> ؼ<EFBFBD> <D8BC> ֱ<EFBFBD> <D6B1> в<EFBFBD> <D0B2> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
2024-05-31 10:14:57 +08:00
//<2F> ı <EFBFBD> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD>
2024-06-11 11:40:47 +08:00
List < string > bingji = strMatListOne . Union ( strMatListTwo ) . ToList ( ) ; //<2F> <> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD>
List < string > Fuzzybingji = strMatFuzzyListOne . Union ( strMatFuzzyListTwo ) . ToList ( ) ; //<2F> <> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD>
string OcrTextone = bingji . Join ( "##" ) ;
string OcrTextTwo = Fuzzybingji . Join ( "##" ) ;
//string OcrTextinsert = "";
//List<string> bingji = strMatListListOne.Union(strMatListListTwo).ToList();//<2F> <> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD>
//for (int j = 0; j < bingji.Count; j++)
//{
// string jdetial = bingji[j];
// OcrTextinsert += jdetial + "##";
//}
2024-05-31 10:14:57 +08:00
string detstr = "" ;
2024-06-11 11:40:47 +08:00
//<2F> ҵ<EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
MLResult MLsum = mL3 ;
2024-05-31 10:14:57 +08:00
for ( int v = 0 ; v < mL4 . ResultDetails . Count ; v + + )
{
MLsum . ResultDetails . Add ( mL4 . ResultDetails [ v ] ) ;
}
for ( int v = 0 ; v < MLsum . ResultDetails . Count ; v + + )
{
if ( v < MLsum . ResultDetails . Count - 1 )
{
detstr + = MLsum . ResultDetails [ v ] . LabelName + "," ;
}
else
{
2024-06-11 11:40:47 +08:00
detstr + = MLsum . ResultDetails [ v ] . LabelName ;
2024-05-31 10:14:57 +08:00
}
}
2024-06-11 11:40:47 +08:00
DateTime dt2 = DateTime . Now ;
XKHisence xK = new XKHisence ( "1" , IOcrBAr , MoveX , MoveY , MoveZ , detstr , OcrTextone , MoveTwoX , MoveTwoY , MoveTwoZ , ModelChangePath , "" , OcrTextTwo ) ;
//string log="D:\\Hisence\\detImages\\" + dt2.Year.ToString() + dt2.Month.ToString() + dt2.Day.ToString() + dt2.Hour.ToString() + dt2.Minute.ToString() + dt2.Millisecond.ToString() + "2result.log";
// using (StreamWriter sw=new StreamWriter(log, true))
// {
// // sw.WriteLine(xK.OcrBar+"\n");
// sw.WriteLine(xK.OcrText);
// sw.WriteLine(xK.FuzzyOcrText);
// }
2024-05-31 10:14:57 +08:00
//IpaddleOcrModel.FreeModel();
2024-06-11 11:40:47 +08:00
string sql = "insert into XK_Hisence VALUES('" + xK . Type + "','" + xK . OcrBar + "'," + xK . MoveX + "," + xK . MoveY + "," + xK . MoveZ + ",'" + xK . Detect + "','" + xK . OcrText + "'," + xK . MoveTwoX + "," + xK . MoveTwoY + "," + xK . MoveTwoZ + ",'" + xK . OcrParm + "','" + xK . Language + "','" + xK . FuzzyOcrText + "')" ;
2024-05-31 10:14:57 +08:00
int i = SQLiteHelper . ExecuteSql ( sql ) ;
if ( i = = 1 )
{
2024-06-11 11:40:47 +08:00
MessageBox . Show ( "XK_Hisence<63> <65> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
2024-05-31 10:14:57 +08:00
}
//bool ismatch = IsMatchOcrText("WF3S7021BB", strMatListListOne);
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ص<EFBFBD>
}
2024-06-11 11:40:47 +08:00
public void InsertXKHisenceWordData ( XK_HisenceWord xkWord )
{
StringBuilder strSql = new StringBuilder ( ) ;
strSql . Append ( "insert into XK_HisenceWord(" ) ;
strSql . Append ( "OcrBar,OneblockPath,OneblockMainWord,OneblockText,TwoRect,TwoIFWhile,TwoblockPath,TwoblockMainWord,TwoblockText,ThreeblockPath," +
"ThreeblockMainWord,ThreeblockText,FourblockPath,FourblockMainWord,FourblockText,FiveblockPath,FiveblockMainWord,FiveblockText," +
"SixblockPath,SixblockMainWord,SixblockText,SevenblockPath,SevenblockMainWord,SevenblockText,EightblockPath,EightblockMainWord,EightblockText)" ) ;
strSql . Append ( " values (" ) ;
strSql . Append ( "@OcrBar,@OneblockPath,@OneblockMainWord,@OneblockText,@TwoRect,@TwoIFWhile,@TwoblockPath,@TwoblockMainWord,@TwoblockText,@ThreeblockPath," +
"@ThreeblockMainWord,@ThreeblockText,@FourblockPath,@FourblockMainWord,@FourblockText,@FiveblockPath,@FiveblockMainWord,@FiveblockText," +
"@SixblockPath,@SixblockMainWord,@SixblockText,@SevenblockPath,@SevenblockMainWord,@SevenblockText,@EightblockPath,@EightblockMainWord,@EightblockText)" ) ;
SQLiteParameter [ ] parameters = {
new SQLiteParameter ( "@OcrBar" , DbType . String ) ,
new SQLiteParameter ( "@OneblockPath" , DbType . String ) ,
new SQLiteParameter ( "@OneblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@OneblockText" , DbType . String ) ,
new SQLiteParameter ( "@TwoRect" , DbType . String ) ,
new SQLiteParameter ( "@TwoIFWhile" , DbType . String ) ,
new SQLiteParameter ( "@TwoblockPath" , DbType . String ) ,
new SQLiteParameter ( "@TwoblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@TwoblockText" , DbType . String ) ,
new SQLiteParameter ( "@ThreeblockPath" , DbType . String ) ,
new SQLiteParameter ( "@ThreeblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@ThreeblockText" , DbType . String ) ,
new SQLiteParameter ( "@FourblockPath" , DbType . String ) ,
new SQLiteParameter ( "@FourblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@FourblockText" , DbType . String ) ,
new SQLiteParameter ( "@FiveblockPath" , DbType . String ) ,
new SQLiteParameter ( "@FiveblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@FiveblockText" , DbType . String ) ,
new SQLiteParameter ( "@SixblockPath" , DbType . String ) ,
new SQLiteParameter ( "@SixblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@SixblockText" , DbType . String ) ,
new SQLiteParameter ( "@SevenblockPath" , DbType . String ) ,
new SQLiteParameter ( "@SevenblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@SevenblockText" , DbType . String ) ,
new SQLiteParameter ( "@EightblockPath" , DbType . String ) ,
new SQLiteParameter ( "@EightblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@EightblockText" , DbType . String ) } ;
2024-06-17 11:02:28 +08:00
2024-06-11 11:40:47 +08:00
parameters [ 0 ] . Value = xkWord . OcrBar ;
parameters [ 1 ] . Value = xkWord . OneblockPath ;
parameters [ 2 ] . Value = xkWord . OneblockMainWord ;
parameters [ 3 ] . Value = xkWord . OneblockText ;
parameters [ 4 ] . Value = xkWord . TwoRect ;
parameters [ 5 ] . Value = xkWord . TwoIFWhile ;
parameters [ 6 ] . Value = xkWord . TwoblockPath ;
parameters [ 7 ] . Value = xkWord . TwoblockMainWord ;
parameters [ 8 ] . Value = xkWord . TwoblockText ;
parameters [ 9 ] . Value = xkWord . ThreeblockPath ;
parameters [ 10 ] . Value = xkWord . ThreeblockMainWord ;
parameters [ 11 ] . Value = xkWord . ThreeblockText ;
parameters [ 12 ] . Value = xkWord . FourblockPath ;
parameters [ 13 ] . Value = xkWord . FourblockMainWord ;
parameters [ 14 ] . Value = xkWord . FourblockText ;
parameters [ 15 ] . Value = xkWord . FiveblockPath ;
parameters [ 16 ] . Value = xkWord . FiveblockMainWord ;
parameters [ 17 ] . Value = xkWord . FiveblockText ;
parameters [ 18 ] . Value = xkWord . SixblockPath ;
parameters [ 19 ] . Value = xkWord . SixblockMainWord ;
parameters [ 20 ] . Value = xkWord . SixblockText ;
parameters [ 21 ] . Value = xkWord . SevenblockPath ;
parameters [ 22 ] . Value = xkWord . SevenblockMainWord ;
parameters [ 23 ] . Value = xkWord . SevenblockText ;
parameters [ 24 ] . Value = xkWord . EightblockPath ;
parameters [ 25 ] . Value = xkWord . EightblockMainWord ;
parameters [ 26 ] . Value = xkWord . EightblockText ;
int iv = SQLiteHelper . ExecuteSql ( strSql . ToString ( ) , parameters ) ;
if ( iv = = 1 )
{
MessageBox . Show ( "<22> ؼ<EFBFBD> <D8BC> <EFBFBD> XK_HisenceWord<72> <64> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
}
}
2024-06-17 11:02:28 +08:00
public void InsertXK_HisenceWordMatchData ( XK_HisenceWord xkWord , bool ifMatch )
2024-06-11 11:40:47 +08:00
{
StringBuilder strSql = new StringBuilder ( ) ;
strSql . Append ( "insert into XK_HisenceWordMatch(" ) ;
strSql . Append ( "OcrBar,OneblockPath,OneblockMainWord,OneblockText,TwoRect,TwoIFWhile,TwoblockPath,TwoblockMainWord,TwoblockText,ThreeblockPath," +
"ThreeblockMainWord,ThreeblockText,FourblockPath,FourblockMainWord,FourblockText,FiveblockPath,FiveblockMainWord,FiveblockText," +
"SixblockPath,SixblockMainWord,SixblockText,SevenblockPath,SevenblockMainWord,SevenblockText,EightblockPath,EightblockMainWord,EightblockText,Datetime,IfMatch)" ) ;
strSql . Append ( " values (" ) ;
strSql . Append ( "@OcrBar,@OneblockPath,@OneblockMainWord,@OneblockText,@TwoRect,@TwoIFWhile,@TwoblockPath,@TwoblockMainWord,@TwoblockText,@ThreeblockPath," +
"@ThreeblockMainWord,@ThreeblockText,@FourblockPath,@FourblockMainWord,@FourblockText,@FiveblockPath,@FiveblockMainWord,@FiveblockText," +
"@SixblockPath,@SixblockMainWord,@SixblockText,@SevenblockPath,@SevenblockMainWord,@SevenblockText,@EightblockPath,@EightblockMainWord,@EightblockText,@Datetime,@IfMatch)" ) ;
SQLiteParameter [ ] parameters = {
new SQLiteParameter ( "@OcrBar" , DbType . String ) ,
new SQLiteParameter ( "@OneblockPath" , DbType . String ) ,
new SQLiteParameter ( "@OneblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@OneblockText" , DbType . String ) ,
new SQLiteParameter ( "@TwoRect" , DbType . String ) ,
new SQLiteParameter ( "@TwoIFWhile" , DbType . String ) ,
new SQLiteParameter ( "@TwoblockPath" , DbType . String ) ,
new SQLiteParameter ( "@TwoblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@TwoblockText" , DbType . String ) ,
new SQLiteParameter ( "@ThreeblockPath" , DbType . String ) ,
new SQLiteParameter ( "@ThreeblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@ThreeblockText" , DbType . String ) ,
new SQLiteParameter ( "@FourblockPath" , DbType . String ) ,
new SQLiteParameter ( "@FourblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@FourblockText" , DbType . String ) ,
new SQLiteParameter ( "@FiveblockPath" , DbType . String ) ,
new SQLiteParameter ( "@FiveblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@FiveblockText" , DbType . String ) ,
new SQLiteParameter ( "@SixblockPath" , DbType . String ) ,
new SQLiteParameter ( "@SixblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@SixblockText" , DbType . String ) ,
new SQLiteParameter ( "@SevenblockPath" , DbType . String ) ,
new SQLiteParameter ( "@SevenblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@SevenblockText" , DbType . String ) ,
new SQLiteParameter ( "@EightblockPath" , DbType . String ) ,
new SQLiteParameter ( "@EightblockMainWord" , DbType . String ) ,
new SQLiteParameter ( "@EightblockText" , DbType . String ) ,
new SQLiteParameter ( "@Datetime" , DbType . String ) ,
new SQLiteParameter ( "@IfMatch" , DbType . Boolean ) } ;
parameters [ 0 ] . Value = xkWord . OcrBar ;
parameters [ 1 ] . Value = xkWord . OneblockPath ;
parameters [ 2 ] . Value = xkWord . OneblockMainWord ;
parameters [ 3 ] . Value = xkWord . OneblockText ;
parameters [ 4 ] . Value = xkWord . TwoRect ;
parameters [ 5 ] . Value = xkWord . TwoIFWhile ;
parameters [ 6 ] . Value = xkWord . TwoblockPath ;
parameters [ 7 ] . Value = xkWord . TwoblockMainWord ;
parameters [ 8 ] . Value = xkWord . TwoblockText ;
parameters [ 9 ] . Value = xkWord . ThreeblockPath ;
parameters [ 10 ] . Value = xkWord . ThreeblockMainWord ;
parameters [ 11 ] . Value = xkWord . ThreeblockText ;
parameters [ 12 ] . Value = xkWord . FourblockPath ;
parameters [ 13 ] . Value = xkWord . FourblockMainWord ;
parameters [ 14 ] . Value = xkWord . FourblockText ;
parameters [ 15 ] . Value = xkWord . FiveblockPath ;
parameters [ 16 ] . Value = xkWord . FiveblockMainWord ;
parameters [ 17 ] . Value = xkWord . FiveblockText ;
parameters [ 18 ] . Value = xkWord . SixblockPath ;
parameters [ 19 ] . Value = xkWord . SixblockMainWord ;
parameters [ 20 ] . Value = xkWord . SixblockText ;
parameters [ 21 ] . Value = xkWord . SevenblockPath ;
parameters [ 22 ] . Value = xkWord . SevenblockMainWord ;
parameters [ 23 ] . Value = xkWord . SevenblockText ;
parameters [ 24 ] . Value = xkWord . EightblockPath ;
parameters [ 25 ] . Value = xkWord . EightblockMainWord ;
parameters [ 26 ] . Value = xkWord . EightblockText ;
2024-06-17 11:02:28 +08:00
2024-06-11 11:40:47 +08:00
parameters [ 27 ] . Value = DateTime . Now ;
parameters [ 28 ] . Value = ifMatch ;
int iv = SQLiteHelper . ExecuteSql ( strSql . ToString ( ) , parameters ) ;
if ( iv = = 1 )
{
MessageBox . Show ( "<22> ؼ<EFBFBD> <D8BC> <EFBFBD> XK_HisenceWordMatch<63> <68> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
}
}
public void InsertXKHisenceDET ( XKHisence xkWord )
{
StringBuilder strSql = new StringBuilder ( ) ;
strSql . Append ( "insert into XKHisenceDet(" ) ;
strSql . Append ( "Type,OcrBar,MoveX,MoveY,MoveZ,Detect,OcrText,MoveTwoX,MoveTwoY,MoveTwoZ,Datetime,IfMatch)" ) ;
strSql . Append ( " values (" ) ;
strSql . Append ( "@Type,@OcrBar,@MoveX,@MoveY,@MoveZ,@Detect,@OcrText,@MoveTwoX,@MoveTwoY,@MoveTwoZ,@Datetime,@IfMatch)" ) ;
SQLiteParameter [ ] parameters = {
new SQLiteParameter ( "@OcrBar" , DbType . String ) ,
new SQLiteParameter ( "@MoveX" , DbType . String ) ,
new SQLiteParameter ( "@MoveY" , DbType . String ) ,
new SQLiteParameter ( "@MoveZ" , DbType . String ) ,
new SQLiteParameter ( "@Detect" , DbType . String ) ,
new SQLiteParameter ( "@OcrText" , DbType . String ) ,
new SQLiteParameter ( "@MoveTwoX" , DbType . String ) ,
new SQLiteParameter ( "@MoveTwoY" , DbType . String ) ,
new SQLiteParameter ( "@MoveTwoZ" , DbType . String ) ,
new SQLiteParameter ( "@Datetime" , DbType . String ) ,
new SQLiteParameter ( "@IfMatch" , DbType . String ) } ;
parameters [ 0 ] . Value = xkWord . OcrBar ;
parameters [ 1 ] . Value = xkWord . MoveX ;
parameters [ 2 ] . Value = xkWord . MoveY ;
parameters [ 3 ] . Value = xkWord . MoveZ ;
parameters [ 4 ] . Value = xkWord . Detect ;
parameters [ 5 ] . Value = xkWord . OcrText ;
parameters [ 6 ] . Value = xkWord . MoveTwoX ;
parameters [ 7 ] . Value = xkWord . MoveTwoY ;
parameters [ 8 ] . Value = xkWord . MoveTwoZ ;
2024-06-17 11:02:28 +08:00
2024-06-11 11:40:47 +08:00
int iv = SQLiteHelper . ExecuteSql ( strSql . ToString ( ) , parameters ) ;
if ( iv = = 1 )
{
MessageBox . Show ( "<22> ؼ<EFBFBD> <D8BC> <EFBFBD> XK_HisenceWord<72> <64> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
}
}
2024-05-31 10:14:57 +08:00
private void queryALLBtn_Click ( object sender , EventArgs e )
{
try
{
DataSet dataSet = SQLiteHelper . Query ( "select * from XK_Hisence" ) ;
InsertDataDgv . DataSource = dataSet . Tables [ 0 ] ;
}
catch ( Exception es )
{
}
}
private void QueryoneBtn_Click ( object sender , EventArgs e )
{
try
{
string type = TypeBox . Text ;
string OcrBar = OcrBarBox . Text ;
string moveX = moveXbox . Text ;
string moveY = moveYbox . Text ;
string moveZ = moveZbox . Text ;
string Detect = DetectBArMatbox . Text ;
string movetwoX = moveTwoXbox . Text ;
string movetwoY = moveTwoYbox . Text ;
string movetwoZ = moveTwoZbox . Text ;
string sql = "select * from XK_Hisence where type='" + type + "' or OcrBar='" + OcrBar + "'" ;
DataSet dataSet = SQLiteHelper . Query ( sql ) ;
InsertDataDgv . DataSource = dataSet . Tables [ 0 ] ;
}
catch ( Exception es )
{
}
}
private void OpenDirBtn_Click ( object sender , EventArgs e )
{
OpenFileDialog openFileDialog = new OpenFileDialog ( ) ;
openFileDialog . Title = "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼƬ" ;
if ( openFileDialog . ShowDialog ( ) = = DialogResult . OK )
{
string fName = openFileDialog . FileName ;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
Cam1MatCbx . Text = fName ;
Cam1OnePath = fName ;
}
}
private void OpenTwoDirBtn_Click ( object sender , EventArgs e )
{
OpenFileDialog openFileDialog = new OpenFileDialog ( ) ;
openFileDialog . Title = "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼƬ" ;
if ( openFileDialog . ShowDialog ( ) = = DialogResult . OK )
{
string fName = openFileDialog . FileName ;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
Cam2MatCbx . Text = fName ;
Cam1TwoPath = fName ;
}
}
private void openModelBtn_Click ( object sender , EventArgs e )
{
OpenFileDialog openFileDialog = new OpenFileDialog ( ) ;
openFileDialog . Title = "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> json" ;
if ( openFileDialog . ShowDialog ( ) = = DialogResult . OK )
{
string fName = openFileDialog . FileName ;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
modelChangeCbx . Text = fName ;
ModelChangePath = fName ;
}
}
private void SnapshotCam2_Click_1 ( object sender , EventArgs e )
{
Cam2 . Snapshot ( ) ;
}
private void bnGetParam2_Click_1 ( object sender , EventArgs e )
{
2024-06-17 11:02:28 +08:00
// tbExposure2.Text = Cam2.dvpGetExposure().ToString();
//tbGain2.Text = Cam2.dvpGetAnalogGain().ToString();
2024-05-31 10:14:57 +08:00
}
2024-06-11 11:40:47 +08:00
private void panel2_Paint ( object sender , PaintEventArgs e )
{
}
2024-06-17 11:02:28 +08:00
private void bnSetParam_Click ( object sender , EventArgs e )
{
}
private void groupBox2_Enter ( object sender , EventArgs e )
{
}
2024-05-31 10:14:57 +08:00
}
}