資源簡介
MvCodeReaderSDKNet海康相機(jī)SDK二次開發(fā),讀取快遞包裹一維碼 及XY坐標(biāo)
代碼片段和文件信息
using?System;
using?System.Drawing;
using?System.Windows.Forms;
using?MvCodeReaderSDKNet;
using?System.Runtime.InteropServices;
using?System.Threading;
using?System.IO;
using?System.Drawing.Imaging;
using?System.Drawing.Drawing2D;
using?System.Text;
namespace?Atovo_Sorter_20220521
{
????public?partial?class?Form1?:?Form
????{
????????MvCodeReader.MV_CODEREADER_DEVICE_INFO_LIST?m_stDeviceList?=?new?MvCodeReader.MV_CODEREADER_DEVICE_INFO_LIST();
????????private?MvCodeReader?m_MyCamera?=?new?MvCodeReader();
????????bool?m_bGrabbing?=?false;
????????Thread?m_hReceiveThread?=?null;
????????MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2?m_stframeInfo?=?new?MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2();
????????byte[]?m_BufForDriver?=?new?byte[1024?*?1024?*?20];?//?ch:用于從驅(qū)動獲取圖像的緩存?|?en:Buffer?for?getting?image?from?driver
????????#region?顯示
????????Bitmap?bmp?=?null;
????????Graphics?gra?=?null;
????????Pen?pen?=?new?Pen(Color.Blue?3);???????????????????//?畫筆顏色
????????Point[]?stPointList?=?new?Point[4];?????????????????//?條碼位置的4個點(diǎn)坐標(biāo)
????????GraphicsPath?WayShapePath?=?new?GraphicsPath();?????//?圖形路徑,內(nèi)部變量?
????????GraphicsPath?OcrShapePath?=?new?GraphicsPath();?????//?圖形路徑,內(nèi)部變量
????????Matrix?stRotateWay?=?new?Matrix();
????????Matrix?stRotateM?=?new?Matrix();
????????Pen?penOcr?=?new?Pen(Color.Yellow?3);
????????Pen?penWay?=?new?Pen(Color.Red?3);?
????????//條碼信息加條碼質(zhì)量列表?
????????Pen?pen1?=?new?Pen(Color.Red?2);???????????????????//?畫筆顏色
????????Font?drawFont?=?new?Font(“Arial“?16);//顯示的字符串使用的字體
????????SolidBrush?drawBrush?=?new?SolidBrush(Color.Yellow);//寫字符串用的刷子
????????PointF?drawPoint1?=?new?PointF(20.0F?20.0F);//顯示的字符串左上角的坐標(biāo)?
????????PointF?drawPoint2?=?new?PointF(20.0F?40.0F);//顯示的字符串左上角的坐標(biāo)?
????????PointF?drawPointCode?=?new?PointF(20.0F?60.0F);//顯示的字符串左上角的坐標(biāo)?
????????int?CentreX_X;
????????int?CentreX_Y;
????????#endregion
????????public?Form1()
????????{
????????????InitializeComponent();
????????????Control.CheckForIllegalCrossThreadCalls?=?false;
????????????pictureBox1.Show();
????????????gra?=?pictureBox1.CreateGraphics();
????????}
????????#region?窗體打開關(guān)閉觸發(fā)事件
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????m_bGrabbing?=?false;
????????????if?(null?!=?m_hReceiveThread)
????????????{
????????????????m_hReceiveThread.Join();
????????????}
????????}
????????private?void?Form1_FormClosed(object?sender?FormClosedEventArgs?e)
????????{
????????????m_bGrabbing?=?false;
????????????if?(null?!=?m_hReceiveThread)
????????????{
????????????????m_hReceiveThread.Join();
????????????}
????????????CloseCamera();//關(guān)閉設(shè)備
????????}
????????#endregion
????????#region?將Byte轉(zhuǎn)換為結(jié)構(gòu)體類型
????????public?static?object?ByteToStruct(byte[]?bytes?Type?type)
????????{
????????????int?size?=?Marshal.SizeOf(type);
????????????if?(size?>?bytes.Length)
????????????{
????????????????return?null;
????????????}
????????????//分配結(jié)構(gòu)體內(nèi)存空間
????????????IntPtr?struct
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????19074??2022-05-24?08:14??test?Sorter\.vs\Atovo?Sorter?20220521\FileContentIndex\4ad7bb16-b2c9-4299-a322-668e4c2749d9.vsidx
?????文件??????66518??2022-05-24?08:14??test?Sorter\.vs\Atovo?Sorter?20220521\FileContentIndex\85f86981-e11a-449a-bab5-10a2da40e68a.vsidx
?????文件??????18583??2022-05-24?08:14??test?Sorter\.vs\Atovo?Sorter?20220521\FileContentIndex\8b205826-38ff-4fc0-bbfb-501cb09734f8.vsidx
?????文件??????67657??2022-05-24?08:14??test?Sorter\.vs\Atovo?Sorter?20220521\FileContentIndex\fec022ce-f0a2-49f2-851e-3ee9b72749d4.vsidx
?????文件??????????0??2022-05-21?16:38??test?Sorter\.vs\Atovo?Sorter?20220521\FileContentIndex\read.lock
????..A..H.?????81920??2022-05-24?08:18??test?Sorter\.vs\Atovo?Sorter?20220521\v17\.suo
?????文件????????189??2022-05-21?16:37??test?Sorter\App.config
?????文件???????1145??2022-05-24?08:16??test?Sorter\Atovo?Sorter?20220521.sln
?????文件??????28672??2022-05-23?22:57??test?Sorter\bin\Debug\Atovo?Sorter?20220521.exe
?????文件????????189??2022-05-21?16:37??test?Sorter\bin\Debug\Atovo?Sorter?20220521.exe.config
?????文件??????56832??2022-05-23?22:57??test?Sorter\bin\Debug\Atovo?Sorter?20220521.pdb
?????文件??????35840??2022-03-10?10:45??test?Sorter\bin\Debug\MvCodeReaderSDK.Net.dll
?????文件????2224022??2022-05-24?08:17??test?Sorter\bin\Debug\MvCodeReaderSdk_00.log
?????文件???10485889??2022-05-24?08:13??test?Sorter\bin\Debug\MvCodeReaderSdk_01.log
?????文件??????38131??2022-05-23?22:57??test?Sorter\Form1.cs
?????文件??????22376??2022-05-23?20:38??test?Sorter\Form1.Designer.cs
?????文件???????6011??2022-05-23?20:38??test?Sorter\Form1.resx
?????文件????????214??2022-05-21?16:37??test?Sorter\obj\Debug\.NETfr
?????文件???????8816??2022-05-24?08:14??test?Sorter\obj\Debug\Atovo?Sorter?20220521.csproj.AssemblyReference.cache
?????文件??????????0??2022-05-21?17:21??test?Sorter\obj\Debug\Atovo?Sorter?20220521.csproj.CopyComplete
?????文件?????????42??2022-05-23?21:57??test?Sorter\obj\Debug\Atovo?Sorter?20220521.csproj.CoreCompileInputs.cache
?????文件???????1964??2022-05-23?22:39??test?Sorter\obj\Debug\Atovo?Sorter?20220521.csproj.FileListAbsolute.txt
?????文件????????126??2022-05-23?20:38??test?Sorter\obj\Debug\Atovo?Sorter?20220521.csproj.GenerateResource.cache
?????文件??????????0??2022-05-21?16:43??test?Sorter\obj\Debug\Atovo?Sorter?20220521.csproj.SuggestedBindingRedirects.cache
?????文件??????28672??2022-05-23?22:57??test?Sorter\obj\Debug\Atovo?Sorter?20220521.exe
?????文件??????56832??2022-05-23?22:57??test?Sorter\obj\Debug\Atovo?Sorter?20220521.pdb
?????文件????????180??2022-05-23?21:57??test?Sorter\obj\Debug\Atovo_Sorter_20220521.Form1.resources
?????文件????????180??2022-05-23?21:57??test?Sorter\obj\Debug\Atovo_Sorter_20220521.Properties.Resources.resources
?????文件???????2397??2022-05-21?17:34??test?Sorter\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????7250??2022-05-24?08:15??test?Sorter\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
............此處省略28個文件信息
評論
共有 條評論