From d0ded5cd9bf5070a120bad58b5be21fe2ac6a4ff Mon Sep 17 00:00:00 2001
From: C3032 <C3032@BC3032>
Date: 星期六, 20 十二月 2025 16:41:09 +0800
Subject: [PATCH] test
---
IDViewer_2D/Program.cs | 266 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 266 insertions(+), 0 deletions(-)
diff --git a/IDViewer_2D/Program.cs b/IDViewer_2D/Program.cs
new file mode 100644
index 0000000..aaf8766
--- /dev/null
+++ b/IDViewer_2D/Program.cs
@@ -0,0 +1,266 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.Ports;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Text;
+using static IDViewerDemo.IDViewerDefines;
+using static IDViewerDemo.IDViewerSDK;
+
+namespace IDViewerDemo
+{
+ delegate void IDViewerCallBack(IntPtr device, IntPtr image, IntPtr decodeInfoHandel);
+ class Program
+ {
+ static string filepath = "D:\\text.bmp";
+
+ static void Main(string[] args)
+ {
+ int option = 0;
+ long result = IDViewerSDK.IDVIEWER_Init_();
+ while (0 == result)
+ {
+ ClearScreen();
+ Console.WriteLine("0) 閫�鍑虹▼搴�");
+ Console.WriteLine("1) 璇荤爜鍣ㄦ搷浣�");
+ if (GetInputOption(ref option) == false) continue;
+ switch (option)
+ {
+ case 0:
+ return;
+ case 1:
+ MenuIDViewer();
+ break;
+ default:
+ break;
+ }
+
+ }
+ }
+
+ static void MenuIDViewer()
+ {
+ int option = 0;
+ while (true)
+ {
+ ClearScreen();
+ Console.WriteLine("0) 杩斿洖涓婁竴绾�");
+ Console.WriteLine("1) 鎵弿鎵�鏈夎鐮佸櫒");
+ Console.WriteLine("2) 閫氳繃SN鍙疯繛鎺ヨ鐮佸櫒");
+ if (GetInputOption(ref option) == false) continue;
+ switch (option)
+ {
+ case 0:
+ return;
+ case 1:
+ DiscoveryIDViewer();
+ system("pause");
+ break;
+ case 2:
+ DiscoveryIDViewer_SN();
+ system("pause");
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+
+
+ static void DiscoveryIDViewer()
+ {
+ IntPtr deviceList = IDVIEWER_DiscoveryDevices_();
+ long length = IDVIEWER_GetDevicesLength_(deviceList);
+ Console.WriteLine("鑾峰彇鍒拌鐮佸櫒涓暟涓猴細" + length);
+ IDDeviceInfo info = new IDDeviceInfo();
+ for (uint i = 0; i < length; i++)
+ {
+ long Inforesult = IDVIEWER_SelectIDDeviceInfo_(deviceList, ref info, i);
+ //Console.WriteLine(Inforesult);
+ Console.WriteLine("*******************************************");
+ if (i >= 0) Console.WriteLine("index锛�" + i);
+ Console.WriteLine("networkIP锛�" + new string(info.networkIP));
+ Console.WriteLine("networkMask锛�" + new string(info.networkMask));
+ Console.WriteLine("networkGateway锛�" + new string(info.networkGateway));
+ Console.WriteLine("cameraIP锛�" + new string(info.cameraIP));
+ Console.WriteLine("cameraSN锛�" + new string(info.cameraSN));
+ Console.WriteLine("cameraType锛�" + new string(info.cameraType));
+ }
+ }
+
+
+ static void DiscoveryIDViewer_SN()
+ {
+ IntPtr device = IntPtr.Zero;
+ IDDeviceInfo info = new IDDeviceInfo();
+ Console.WriteLine("璇疯緭鍏N鍙�");
+ String serialNum = Console.ReadLine();
+ long result = IDVIEWER_CreateDeviceBySN_(serialNum, ref device);
+
+ if (device != IntPtr.Zero)
+ {
+ int option = 0;
+
+ while (true)
+ {
+ ClearScreen();
+ Console.WriteLine("0) 杩斿洖涓婁竴绾�");
+ Console.WriteLine("1) 鎵撳紑");
+ Console.WriteLine("2) 杩愯");
+ Console.WriteLine("3) 杩炴帴鐘舵��");
+ Console.WriteLine("4) 鍏抽棴");
+ if (GetInputOption(ref option) == false) continue;
+
+ if (option == 0)
+ {
+ return;
+ }
+
+ if (option < 1 || option > 10)
+ {
+ continue;
+ }
+
+ switch (option)
+ {
+ case 1:
+ IDDevice_Open(device);
+ break;
+ case 2:
+ Device_StartRunning(device);
+ break;
+ case 3:
+ Device_IsOpen(device);
+ break;
+ case 4:
+ IDDevice_Close(device);
+ break;
+ default:
+ break;
+ }
+ system("pause");
+ }
+ }
+ }
+
+
+ static IDViewerCallBack callbackDelegate;
+ static IDDecodeInfo decodeInfo;
+
+ public static void CallBack(IntPtr device, IntPtr image, IntPtr decodeInfoHandel)
+ {
+ IDDecodeInfo info = new IDDecodeInfo();
+ IDCallback_GetIDDecodeInfo_A(decodeInfoHandel, ref info); //ROI瑙g爜淇℃伅鏁扮粍鐨勯暱搴� 鑾峰彇鍒癛OI鐨勮В鐮佹暟閲�
+
+ if (info.decodeStatus)
+ {
+ for (uint roi = 0; roi < info.IDDecodeROIInfoLength; roi++)
+ {
+ IDDecodeROIInfo IDpecodeROIInfo = IDCallback_GetIDDecodeROIInfo(decodeInfoHandel, 0);
+ if (IDpecodeROIInfo.decodeReusltLength > 0)
+ {
+ IDDecodeResult IDpecodeResult = IDCallback_GetIDDecodeResult(decodeInfoHandel, roi, 0);
+
+ if (IDpecodeResult.dmResultsLength != 0)
+ {
+ for (uint dmSuccessNumber = 0; dmSuccessNumber < IDpecodeResult.dmResultsLength; dmSuccessNumber++)
+ {
+ IDDMCodeResult DMBarCodeResultData = new IDDMCodeResult();
+ long a = IDCallback_GetIDDMCodeResult(decodeInfoHandel, roi, 0, dmSuccessNumber, ref DMBarCodeResultData);
+ Console.WriteLine("ROI锛�" + (roi + 1));
+ Console.WriteLine("SuccessNumber锛�" + (dmSuccessNumber + 1));
+ Console.WriteLine("subType锛�" + new string(DMBarCodeResultData.subType));
+ Console.WriteLine("codeString: " + new string(DMBarCodeResultData.codeString));
+ }
+ }
+ else if (IDpecodeResult.qrResultsLength != 0)
+ {
+ for (uint qrSuccessNumber = 0; qrSuccessNumber < IDpecodeResult.qrResultsLength; qrSuccessNumber++)
+ {
+ IDQRCodeResult QRBarCodeResultData = new IDQRCodeResult();
+ long a = IDCallback_GetID_QR_CODE_Result(decodeInfoHandel, roi, 0, qrSuccessNumber, ref QRBarCodeResultData);
+ Console.WriteLine("ROI锛�" + (roi + 1));
+ Console.WriteLine("SuccessNumber锛�" + (qrSuccessNumber + 1));
+ Console.WriteLine("subType锛�" + new string(QRBarCodeResultData.subType));
+ Console.WriteLine("codeString: " + new string(QRBarCodeResultData.codeString));
+ }
+ }
+ else if (IDpecodeResult.pdf417ResultsLength != 0)
+ {
+ for (uint pdf417SuccessNumber = 0; pdf417SuccessNumber < IDpecodeResult.qrResultsLength; pdf417SuccessNumber++)
+ {
+ IDPDF417CodeResult PDF417BarCodeResultData = new IDPDF417CodeResult();
+ long a = IDCallback_GetIDPDF417CodeResult(decodeInfoHandel, roi, 0, pdf417SuccessNumber, ref PDF417BarCodeResultData);
+ Console.WriteLine("ROI锛�" + (roi + 1));
+ Console.WriteLine("SuccessNumber锛�" + (pdf417SuccessNumber + 1));
+ Console.WriteLine("subType锛�" + new string(PDF417BarCodeResultData.subType));
+ Console.WriteLine("codeString: " + new string(PDF417BarCodeResultData.codeString));
+ }
+ }
+ else if (IDpecodeResult.barcodeResultsLength != 0)
+ {
+ for (uint barcodeSuccessNumber = 0; barcodeSuccessNumber < IDpecodeResult.qrResultsLength; barcodeSuccessNumber++)
+ {
+ IDBarCodeResult IDBarCodeResultData = new IDBarCodeResult();
+ long a = IDCallback_GetIDBarCodeResult(decodeInfoHandel, roi, 0, barcodeSuccessNumber, ref IDBarCodeResultData);
+ Console.WriteLine("ROI锛�" + (roi + 1));
+ Console.WriteLine("SuccessNumber锛�" + (barcodeSuccessNumber + 1));
+ Console.WriteLine("codeString: " + new string(IDBarCodeResultData.codeString));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ static void Device_StartRunning(IntPtr device)
+ {
+
+ IDDevice_StartRunning(device,1);
+ callbackDelegate = new IDViewerCallBack(CallBack);
+ IntPtr functionPointer = Marshal.GetFunctionPointerForDelegate(callbackDelegate);
+ IDCallback_ResultNotify_(device, functionPointer);
+ GC.KeepAlive(callbackDelegate);
+ }
+ static void Device_IsOpen(IntPtr device)
+ {
+ long rel = IDDevice_IsOpen(device);
+ if (rel == 0)
+ {
+ Console.WriteLine("璇荤爜鍣ㄦ湭鎵撳紑");
+ }
+ else
+ {
+ Console.WriteLine("璇荤爜鍣ㄥ凡鎵撳紑");
+ }
+ }
+
+ static bool GetInputOption(ref int option)
+ {
+ int op;
+ try
+ {
+ op = int.Parse(Console.ReadLine());
+ }
+ catch
+ {
+ return false;
+ }
+ option = op;
+ return true;
+ }
+ static void ClearScreen()
+ {
+ system("cls");
+ Console.WriteLine("*******************************************");
+ Console.WriteLine("* IDViewer Demo *");
+ Console.WriteLine("*******************************************");
+ }
+
+ [DllImport("msvcrt.dll", SetLastError = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
+ private extern static void system(string command);
+ }
+}
--
Gitblit v1.9.3