remove change & compile pass
This commit is contained in:
@@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace LibCamera
|
|
||||||
{
|
|
||||||
public delegate void OnImageCollectorMessage(string msg);
|
|
||||||
public delegate void OnImageCollectorInfo(string info);
|
|
||||||
public delegate void OnImageCollectorConnected(string serial);
|
|
||||||
public delegate void OnImageCollectorDisConnected(string serial);
|
|
||||||
public delegate void OnImageCollectorData(byte[] imageData);
|
|
||||||
public interface IImageCollector
|
|
||||||
{
|
|
||||||
event OnImageCollectorMessage OnImageCollectorMessage;
|
|
||||||
event OnImageCollectorInfo OnImageCollectorInfo;
|
|
||||||
event OnImageCollectorConnected OnImageCollectorConnected;
|
|
||||||
event OnImageCollectorDisConnected OnImageCollectorDisConnected;
|
|
||||||
event OnImageCollectorData OnImageCollectorData;
|
|
||||||
void Start();
|
|
||||||
void Stop();
|
|
||||||
void SetPixelFormat(string pixelFormat);
|
|
||||||
void SetExposureTime(double exposureTime);
|
|
||||||
void SetGainRawGain(double gain);
|
|
||||||
void SetAcquisitionMode(string acquisitionMode);
|
|
||||||
void SetTriggerMode(string triggerMode);
|
|
||||||
void StartSoftwareGrabbing();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ThridLibray;
|
|
||||||
|
|
||||||
namespace LibCamera
|
|
||||||
{
|
|
||||||
public class ImageCollector : IImageCollector
|
|
||||||
{
|
|
||||||
public event OnImageCollectorMessage OnImageCollectorMessage;
|
|
||||||
public event OnImageCollectorInfo OnImageCollectorInfo;
|
|
||||||
public event OnImageCollectorConnected OnImageCollectorConnected;
|
|
||||||
public event OnImageCollectorDisConnected OnImageCollectorDisConnected;
|
|
||||||
public event OnImageCollectorData OnImageCollectorData;
|
|
||||||
private IDevice m_dev_cam;
|
|
||||||
private bool m_abort = false;
|
|
||||||
private DateTime m_start = DateTime.Now;
|
|
||||||
private string m_serial;
|
|
||||||
public ImageCollector(string serial)
|
|
||||||
{
|
|
||||||
m_serial = serial;
|
|
||||||
}
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
m_abort = false;
|
|
||||||
Task.Run(() => { ConnectDevice(); });
|
|
||||||
}
|
|
||||||
private void ConnectDevice()
|
|
||||||
{
|
|
||||||
m_start = DateTime.Now.AddSeconds(-6);
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
if (m_abort)
|
|
||||||
return;
|
|
||||||
Thread.Sleep(100);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (m_dev_cam == null || (m_dev_cam.IsOpen == false && ((DateTime.Now - m_start).TotalSeconds >= 5)))
|
|
||||||
{
|
|
||||||
OnImageCollectorDisConnected?.Invoke(m_serial);
|
|
||||||
if (m_dev_cam != null && !m_dev_cam.IsOpen)
|
|
||||||
m_dev_cam.StreamGrabber.ImageGrabbed -= StreamGrabber_ImageGrabbed;
|
|
||||||
m_dev_cam = null;
|
|
||||||
Enumerator.EnumerateDevices();
|
|
||||||
m_dev_cam = Enumerator.GetDeviceByKey(m_serial);
|
|
||||||
if (m_dev_cam == null)
|
|
||||||
continue;
|
|
||||||
m_dev_cam.Open();
|
|
||||||
if (m_dev_cam.IsOpen)
|
|
||||||
{
|
|
||||||
m_dev_cam.StreamGrabber.ImageGrabbed += StreamGrabber_ImageGrabbed;
|
|
||||||
OnImageCollectorInfo?.Invoke($"Device {m_serial} connected.");
|
|
||||||
OnImageCollectorConnected?.Invoke(m_serial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
m_dev_cam = null;
|
|
||||||
OnImageCollectorMessage?.Invoke($"ConnectDevice {m_serial} Exception: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StreamGrabber_ImageGrabbed(object sender, GrabbedEventArgs e)
|
|
||||||
{
|
|
||||||
OnImageCollectorData?.Invoke(e.GrabResult.Image);
|
|
||||||
}
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_abort = true;
|
|
||||||
if (m_dev_cam != null)
|
|
||||||
{
|
|
||||||
m_dev_cam.StreamGrabber.ImageGrabbed -= StreamGrabber_ImageGrabbed;
|
|
||||||
if (m_dev_cam.IsOpen)
|
|
||||||
{
|
|
||||||
m_dev_cam.Close();
|
|
||||||
}
|
|
||||||
m_dev_cam = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
OnImageCollectorMessage?.Invoke($"Stop {m_serial} Exception: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private bool IsDeviceConnected()
|
|
||||||
{
|
|
||||||
return m_dev_cam != null && m_dev_cam.IsOpen;
|
|
||||||
}
|
|
||||||
public void SetPixelFormat(string pixelFormat)
|
|
||||||
{
|
|
||||||
if (!IsDeviceConnected())
|
|
||||||
return;
|
|
||||||
using (IEnumParameter p = m_dev_cam.ParameterCollection[ParametrizeNameSet.ImagePixelFormat])
|
|
||||||
{
|
|
||||||
p.SetValue(pixelFormat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void SetExposureTime(double exposureTime)
|
|
||||||
{
|
|
||||||
if (!IsDeviceConnected())
|
|
||||||
return;
|
|
||||||
using (IFloatParameter p = m_dev_cam.ParameterCollection[ParametrizeNameSet.ExposureTime])
|
|
||||||
{
|
|
||||||
p.SetValue(exposureTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void SetGainRawGain(double gain)
|
|
||||||
{
|
|
||||||
if (!IsDeviceConnected())
|
|
||||||
return;
|
|
||||||
using (IFloatParameter p = m_dev_cam.ParameterCollection[ParametrizeNameSet.GainRaw])
|
|
||||||
{
|
|
||||||
p.SetValue(gain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void SetAcquisitionMode(string acquisitionMode)
|
|
||||||
{
|
|
||||||
if (!IsDeviceConnected())
|
|
||||||
return;
|
|
||||||
using (IEnumParameter p = m_dev_cam.ParameterCollection[ParametrizeNameSet.AcquisitionMode])
|
|
||||||
{
|
|
||||||
p.SetValue(acquisitionMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void SetTriggerMode(string triggerMode)
|
|
||||||
{
|
|
||||||
if (!IsDeviceConnected())
|
|
||||||
return;
|
|
||||||
using (IEnumParameter p = m_dev_cam.ParameterCollection[ParametrizeNameSet.TriggerMode])
|
|
||||||
{
|
|
||||||
p.SetValue(triggerMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void StartSoftwareGrabbing()
|
|
||||||
{
|
|
||||||
if (!IsDeviceConnected())
|
|
||||||
return;
|
|
||||||
m_dev_cam.TriggerSet.Open(TriggerSourceEnum.Software);
|
|
||||||
if (!m_dev_cam.GrabUsingGrabLoopThread())
|
|
||||||
OnImageCollectorMessage("开启采集失败");
|
|
||||||
else
|
|
||||||
OnImageCollectorInfo($"相机{m_serial}加载完毕");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{884C8BB2-78D9-4EED-A2FA-492F075E1F64}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>LibCamera</RootNamespace>
|
|
||||||
<AssemblyName>LibCamera</AssemblyName>
|
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<Deterministic>true</Deterministic>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
|
||||||
<LangVersion>7.3</LangVersion>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
|
||||||
<OutputPath>bin\x64\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
|
||||||
<LangVersion>7.3</LangVersion>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="CLIDelegate">
|
|
||||||
<HintPath>..\dll\CLIDelegate.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
<Reference Include="ThridLibray">
|
|
||||||
<HintPath>..\dll\ThridLibray.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="IImageCollector.cs" />
|
|
||||||
<Compile Include="ImageCollector.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// 有关程序集的一般信息由以下
|
|
||||||
// 控制。更改这些特性值可修改
|
|
||||||
// 与程序集关联的信息。
|
|
||||||
[assembly: AssemblyTitle("LibCamera")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("HP")]
|
|
||||||
[assembly: AssemblyProduct("LibCamera")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © HP 2025")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
|
||||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
|
||||||
//请将此类型的 ComVisible 特性设置为 true。
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
|
||||||
[assembly: Guid("884c8bb2-78d9-4eed-a2fa-492f075e1f64")]
|
|
||||||
|
|
||||||
// 程序集的版本信息由下列四个值组成:
|
|
||||||
//
|
|
||||||
// 主版本
|
|
||||||
// 次版本
|
|
||||||
// 生成号
|
|
||||||
// 修订号
|
|
||||||
//
|
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
using LibCamera;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LibImageService
|
|
||||||
{
|
|
||||||
public class ImageService
|
|
||||||
{
|
|
||||||
IImageCollector m_imageCollectorOCR;
|
|
||||||
IImageCollector m_imageCollectorLocation;
|
|
||||||
//private Dictionary<string, IImageCollector>
|
|
||||||
public ImageService(string serialLocation, string serialOCR)
|
|
||||||
{
|
|
||||||
m_imageCollectorLocation = new ImageCollector(serialLocation);
|
|
||||||
m_imageCollectorOCR = new ImageCollector(serialOCR);
|
|
||||||
m_imageCollectorLocation.OnImageCollectorData += M_imageCollectorLocation_OnImageCollectorData;
|
|
||||||
m_imageCollectorLocation.OnImageCollectorMessage += M_imageCollectorLocation_OnImageCollectorMessage;
|
|
||||||
m_imageCollectorLocation.OnImageCollectorInfo += M_imageCollectorLocation_OnImageCollectorInfo;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void M_imageCollectorLocation_OnImageCollectorInfo(string info)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void M_imageCollectorLocation_OnImageCollectorMessage(string msg)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void M_imageCollectorLocation_OnImageCollectorData(byte[] imageData)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
m_imageCollectorLocation.Start();
|
|
||||||
m_imageCollectorOCR.Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{BC738E23-1B32-497B-A654-569212EF4647}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>LibImageService</RootNamespace>
|
|
||||||
<AssemblyName>LibImageService</AssemblyName>
|
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<Deterministic>true</Deterministic>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
|
||||||
<LangVersion>7.3</LangVersion>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
|
||||||
<OutputPath>bin\x64\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
|
||||||
<LangVersion>7.3</LangVersion>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Drawing" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="ImageService.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\LibCamera\LibCamera.csproj">
|
|
||||||
<Project>{884c8bb2-78d9-4eed-a2fa-492f075e1f64}</Project>
|
|
||||||
<Name>LibCamera</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// 有关程序集的一般信息由以下
|
|
||||||
// 控制。更改这些特性值可修改
|
|
||||||
// 与程序集关联的信息。
|
|
||||||
[assembly: AssemblyTitle("LibImageService")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("HP")]
|
|
||||||
[assembly: AssemblyProduct("LibImageService")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © HP 2025")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
|
||||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
|
||||||
//请将此类型的 ComVisible 特性设置为 true。
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
|
||||||
[assembly: Guid("bc738e23-1b32-497b-a654-569212ef4647")]
|
|
||||||
|
|
||||||
// 程序集的版本信息由下列四个值组成:
|
|
||||||
//
|
|
||||||
// 主版本
|
|
||||||
// 次版本
|
|
||||||
// 生成号
|
|
||||||
// 修订号
|
|
||||||
//
|
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
||||||
@@ -1,14 +1,10 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 18
|
||||||
VisualStudioVersion = 17.14.36518.9 d17.14
|
VisualStudioVersion = 18.0.11123.170 d18.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TetraParkOCR", "TetraParkOCR\TetraParkOCR.csproj", "{533800AA-D6A6-4EF7-825F-AA143B1EE901}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TetraParkOCR", "TetraParkOCR\TetraParkOCR.csproj", "{533800AA-D6A6-4EF7-825F-AA143B1EE901}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibCamera", "LibCamera\LibCamera.csproj", "{884C8BB2-78D9-4EED-A2FA-492F075E1F64}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibImageService", "LibImageService\LibImageService.csproj", "{BC738E23-1B32-497B-A654-569212EF4647}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -31,30 +27,6 @@ Global
|
|||||||
{533800AA-D6A6-4EF7-825F-AA143B1EE901}.Release|x64.Build.0 = Release|x64
|
{533800AA-D6A6-4EF7-825F-AA143B1EE901}.Release|x64.Build.0 = Release|x64
|
||||||
{533800AA-D6A6-4EF7-825F-AA143B1EE901}.Release|x86.ActiveCfg = Release|x86
|
{533800AA-D6A6-4EF7-825F-AA143B1EE901}.Release|x86.ActiveCfg = Release|x86
|
||||||
{533800AA-D6A6-4EF7-825F-AA143B1EE901}.Release|x86.Build.0 = Release|x86
|
{533800AA-D6A6-4EF7-825F-AA143B1EE901}.Release|x86.Build.0 = Release|x86
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{884C8BB2-78D9-4EED-A2FA-492F075E1F64}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{BC738E23-1B32-497B-A654-569212EF4647}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -49,6 +49,10 @@
|
|||||||
<assemblyIdentity name="ExtendedNumerics.BigDecimal" publicKeyToken="65f1315a45ad8949" culture="neutral" />
|
<assemblyIdentity name="ExtendedNumerics.BigDecimal" publicKeyToken="65f1315a45ad8949" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-3001.1.0.233" newVersion="3001.1.0.233" />
|
<bindingRedirect oldVersion="0.0.0.0-3001.1.0.233" newVersion="3001.1.0.233" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Drawing.Common" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -93,16 +93,12 @@ namespace TetraPackOCR
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
string vppdetFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\VPPFile\\liledet.vpp";
|
string vppdetFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\VPPFile\\liledet.vpp";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// OCRVpp文件
|
|
||||||
/// </summary>
|
|
||||||
string vppocrFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\VPPFile\\lileOCR.vpp";
|
|
||||||
/// <summary>
|
|
||||||
/// 存图路径
|
/// 存图路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string SaveImageFileOCR = AppDomain.CurrentDomain.BaseDirectory + "SaveImage\\OCR";//ocr存图
|
string SaveImageFileOCR = AppDomain.CurrentDomain.BaseDirectory + "SaveImage\\OCR";//ocr存图
|
||||||
string SaveImageFileDET = AppDomain.CurrentDomain.BaseDirectory + "SaveImage\\Det";//ocr存图
|
string SaveImageFileDET = AppDomain.CurrentDomain.BaseDirectory + "SaveImage\\Det";//ocr存图
|
||||||
private CogJobManager myJobManager1;//, myJobManager2;
|
private CogJobManager myJobManager1;
|
||||||
private CogJob myJob1;//, myJob2;
|
private CogJob myJob1;
|
||||||
|
|
||||||
private string[] verocr = new string[20];
|
private string[] verocr = new string[20];
|
||||||
|
|
||||||
@@ -144,13 +140,22 @@ namespace TetraPackOCR
|
|||||||
btn_StarDet_manual.Enabled = false;
|
btn_StarDet_manual.Enabled = false;
|
||||||
//asf.controllInitializeSize(this);
|
//asf.controllInitializeSize(this);
|
||||||
log.Info("软件正在加载...");
|
log.Info("软件正在加载...");
|
||||||
|
this.Enabled = false;
|
||||||
Action action = (() =>
|
Action action = (() =>
|
||||||
{
|
{
|
||||||
//InitializeCamer1();
|
InitializeCamer1();
|
||||||
//InitializeCamer2();
|
InitializeCamer2();
|
||||||
InitializePaddleOCR();
|
InitializePaddleOCR();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
myJobManager1 = CogSerializer.LoadObjectFromFile(vppdetFile) as CogJobManager;
|
myJobManager1 = CogSerializer.LoadObjectFromFile(vppdetFile) as CogJobManager;
|
||||||
//myJobManager2 = CogSerializer.LoadObjectFromFile(vppocrFile) as CogJobManager;
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error("定位VPP文件加载失败,请检查文件路径是否正确:" + ex.Message);
|
||||||
|
myJobManager1 = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
InitializeCC24();
|
InitializeCC24();
|
||||||
@@ -165,6 +170,7 @@ namespace TetraPackOCR
|
|||||||
this.btn_manualDet.Enabled = true;
|
this.btn_manualDet.Enabled = true;
|
||||||
check_Autorun.Enabled = true;
|
check_Autorun.Enabled = true;
|
||||||
btn_StarDet_manual.Enabled = true;
|
btn_StarDet_manual.Enabled = true;
|
||||||
|
this.Enabled = true;
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -188,29 +194,21 @@ namespace TetraPackOCR
|
|||||||
TaskFactory tskFactory = new TaskFactory();
|
TaskFactory tskFactory = new TaskFactory();
|
||||||
tskFactory.ContinueWhenAll(tsk.ToArray(), FlashFormView =>
|
tskFactory.ContinueWhenAll(tsk.ToArray(), FlashFormView =>
|
||||||
{
|
{
|
||||||
|
if (myJobManager1 != null)
|
||||||
|
{
|
||||||
myJob1 = myJobManager1.Job(0);
|
myJob1 = myJobManager1.Job(0);
|
||||||
//myJob2 = myJobManager2.Job(0);
|
|
||||||
|
|
||||||
// 注册结果队列事件
|
// 注册结果队列事件
|
||||||
myJobManager1.UserResultAvailable += new CogJobManager.CogUserResultAvailableEventHandler(DetResult);
|
myJobManager1.UserResultAvailable += new CogJobManager.CogUserResultAvailableEventHandler(DetResult);
|
||||||
// myJobManager2.UserResultAvailable += new CogJobManager.CogUserResultAvailableEventHandler(OCRResult);
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
log.Error(ex.Message);
|
log.Error(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 窗体关闭
|
/// 窗体关闭
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -232,33 +230,19 @@ namespace TetraPackOCR
|
|||||||
|
|
||||||
ClossCam();
|
ClossCam();
|
||||||
|
|
||||||
// 注销结果队列事件
|
//// 注销结果队列事件
|
||||||
myJobManager1.UserResultAvailable -= new CogJobManager.CogUserResultAvailableEventHandler(DetResult);
|
myJobManager1.UserResultAvailable -= new CogJobManager.CogUserResultAvailableEventHandler(DetResult);
|
||||||
//myJobManager2.UserResultAvailable -= new CogJobManager.CogUserResultAvailableEventHandler(OCRResult);
|
|
||||||
myJobManager1.Shutdown();
|
myJobManager1.Shutdown();
|
||||||
//myJobManager2.Shutdown();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CloseCC24();
|
CloseCC24();
|
||||||
|
|
||||||
Application.DoEvents();
|
//Application.DoEvents();
|
||||||
System.Environment.Exit(0);
|
//System.Environment.Exit(0);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
ClossCam();
|
|
||||||
|
|
||||||
// 注销结果队列事件
|
|
||||||
myJobManager1.UserResultAvailable -= new CogJobManager.CogUserResultAvailableEventHandler(DetResult);
|
|
||||||
//myJobManager2.UserResultAvailable -= new CogJobManager.CogUserResultAvailableEventHandler(OCRResult);
|
|
||||||
myJobManager1.Shutdown();
|
|
||||||
//myJobManager2.Shutdown();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CloseCC24();
|
|
||||||
|
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
System.Environment.Exit(0);
|
System.Environment.Exit(0);
|
||||||
}
|
}
|
||||||
@@ -293,18 +277,23 @@ namespace TetraPackOCR
|
|||||||
|
|
||||||
#region 相机1 定义为OCR相机
|
#region 相机1 定义为OCR相机
|
||||||
private void InitializeCamer1()
|
private void InitializeCamer1()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
DeviceList = Enumerator.EnumerateDevices(); //发现设备,搜索所有大华相机
|
DeviceList = Enumerator.EnumerateDevices(); //发现设备,搜索所有大华相机
|
||||||
|
|
||||||
// m_dev_cam0 = Enumerator.GetDeviceByIndex(0);//通过索引获取
|
// m_dev_cam0 = Enumerator.GetDeviceByIndex(0);//通过索引获取
|
||||||
m_dev_cam0 = Enumerator.GetDeviceByKey("Machine Vision:CK21686DAK00001");//通过"设备厂商名:设备序列号"获取
|
m_dev_cam0 = Enumerator.GetDeviceByKey("Machine Vision:CK21686DAK00001");//通过"设备厂商名:设备序列号"获取
|
||||||
//m_dev_cam0 = Enumerator.GetDeviceByGigeIP("192.168.20.2");//通过IP地址获取
|
if (m_dev_cam0 == null)
|
||||||
|
{
|
||||||
|
log.Error("未发现OCR相机,请检查相机连接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_dev_cam0.CameraOpened += m_dev0_CameraOpened;
|
m_dev_cam0.CameraOpened += m_dev0_CameraOpened;
|
||||||
m_dev_cam0.CameraClosed += m_dev0_CameraClosed;
|
m_dev_cam0.CameraClosed += m_dev0_CameraClosed;
|
||||||
m_dev_cam0.ConnectionLost += m_dev0_ConnectionLost;
|
m_dev_cam0.ConnectionLost += m_dev0_ConnectionLost;
|
||||||
|
|
||||||
if(!m_dev_cam0.Open())
|
if (!m_dev_cam0.Open())
|
||||||
{
|
{
|
||||||
MessageBox.Show("OCR相机打开失败");
|
MessageBox.Show("OCR相机打开失败");
|
||||||
}
|
}
|
||||||
@@ -350,12 +339,17 @@ namespace TetraPackOCR
|
|||||||
m_dev_cam0.TriggerSet.Open(TriggerSourceEnum.Software);
|
m_dev_cam0.TriggerSet.Open(TriggerSourceEnum.Software);
|
||||||
if (!m_dev_cam0.GrabUsingGrabLoopThread())
|
if (!m_dev_cam0.GrabUsingGrabLoopThread())
|
||||||
{
|
{
|
||||||
|
|
||||||
// 开启采集失败
|
// 开启采集失败
|
||||||
log.Error("开启采集失败");
|
log.Error("开启采集失败");
|
||||||
}
|
}
|
||||||
log.Info("OCR相机加载完毕");
|
log.Info("OCR相机加载完毕");
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error("OCR相机加载失败");
|
||||||
|
m_dev_cam0 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 相机1事件响应
|
#region 相机1事件响应
|
||||||
@@ -405,6 +399,8 @@ namespace TetraPackOCR
|
|||||||
|
|
||||||
#region 相机2 定义为定位相机
|
#region 相机2 定义为定位相机
|
||||||
private void InitializeCamer2()
|
private void InitializeCamer2()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
DeviceList = Enumerator.EnumerateDevices(); //发现设备,搜索所有大华相机
|
DeviceList = Enumerator.EnumerateDevices(); //发现设备,搜索所有大华相机
|
||||||
|
|
||||||
@@ -412,6 +408,11 @@ namespace TetraPackOCR
|
|||||||
m_dev_cam1 = Enumerator.GetDeviceByKey("Machine Vision:BK27185BAK00038");//通过"设备厂商名:设备序列号"获取
|
m_dev_cam1 = Enumerator.GetDeviceByKey("Machine Vision:BK27185BAK00038");//通过"设备厂商名:设备序列号"获取
|
||||||
//m_dev_cam1 = Enumerator.GetDeviceByGigeIP("192.168.10.1");//通过IP地址获取
|
//m_dev_cam1 = Enumerator.GetDeviceByGigeIP("192.168.10.1");//通过IP地址获取
|
||||||
|
|
||||||
|
if (m_dev_cam1 == null)
|
||||||
|
{
|
||||||
|
log.Error("未发现OCR相机,请检查相机连接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_dev_cam1.CameraOpened += m_dev1_CameraOpened;
|
m_dev_cam1.CameraOpened += m_dev1_CameraOpened;
|
||||||
m_dev_cam1.CameraClosed += m_dev1_CameraClosed;
|
m_dev_cam1.CameraClosed += m_dev1_CameraClosed;
|
||||||
m_dev_cam1.ConnectionLost += m_dev1_ConnectionLost;
|
m_dev_cam1.ConnectionLost += m_dev1_ConnectionLost;
|
||||||
@@ -466,6 +467,13 @@ namespace TetraPackOCR
|
|||||||
}
|
}
|
||||||
log.Info("定位相机加载完毕");
|
log.Info("定位相机加载完毕");
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error("定位相机加载失败");
|
||||||
|
m_dev_cam1 = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 相机2事件响应
|
#region 相机2事件响应
|
||||||
@@ -549,26 +557,32 @@ namespace TetraPackOCR
|
|||||||
void ClossCam()
|
void ClossCam()
|
||||||
{
|
{
|
||||||
//注销相机事件
|
//注销相机事件
|
||||||
|
if (m_dev_cam0 != null)
|
||||||
|
{
|
||||||
m_dev_cam0.CameraOpened -= m_dev0_CameraOpened;
|
m_dev_cam0.CameraOpened -= m_dev0_CameraOpened;
|
||||||
m_dev_cam0.CameraClosed -= m_dev0_CameraClosed;
|
m_dev_cam0.CameraClosed -= m_dev0_CameraClosed;
|
||||||
m_dev_cam0.ConnectionLost -= m_dev0_ConnectionLost;
|
m_dev_cam0.ConnectionLost -= m_dev0_ConnectionLost;
|
||||||
|
|
||||||
m_dev_cam1.CameraOpened -= m_dev1_CameraOpened;
|
|
||||||
m_dev_cam1.CameraClosed -= m_dev1_CameraClosed;
|
|
||||||
m_dev_cam1.ConnectionLost -= m_dev1_ConnectionLost;
|
|
||||||
|
|
||||||
m_dev_cam0.ShutdownGrab();
|
m_dev_cam0.ShutdownGrab();
|
||||||
m_dev_cam0.Dispose();
|
m_dev_cam0.Dispose();
|
||||||
m_dev_cam0 = null;
|
m_dev_cam0 = null;
|
||||||
|
}
|
||||||
|
if (m_dev_cam1 != null)
|
||||||
|
{
|
||||||
|
m_dev_cam1.CameraOpened -= m_dev1_CameraOpened;
|
||||||
|
m_dev_cam1.CameraClosed -= m_dev1_CameraClosed;
|
||||||
|
m_dev_cam1.ConnectionLost -= m_dev1_ConnectionLost;
|
||||||
m_dev_cam1.ShutdownGrab();
|
m_dev_cam1.ShutdownGrab();
|
||||||
m_dev_cam1.Dispose();
|
m_dev_cam1.Dispose();
|
||||||
m_dev_cam1 = null;
|
m_dev_cam1 = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region OCR模型参数初始化
|
#region OCR模型参数初始化
|
||||||
private void InitializePaddleOCR()
|
private void InitializePaddleOCR()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
//模型初始化
|
//模型初始化
|
||||||
OCRModelConfig config = new OCRModelConfig(); //创建一个模型参数设置对象
|
OCRModelConfig config = new OCRModelConfig(); //创建一个模型参数设置对象
|
||||||
@@ -595,7 +609,11 @@ namespace TetraPackOCR
|
|||||||
|
|
||||||
//初始化OCR
|
//初始化OCR
|
||||||
Engine = new PaddleOCREngine(config, OcrParameter);
|
Engine = new PaddleOCREngine(config, OcrParameter);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error(ex.Message + ex.StackTrace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -1114,7 +1132,7 @@ namespace TetraPackOCR
|
|||||||
{
|
{
|
||||||
ll[i] = ll[i].Replace(" ", ""); ll[i] = ll[i].Replace("[", ""); ll[i] = ll[i].Replace("]", "");
|
ll[i] = ll[i].Replace(" ", ""); ll[i] = ll[i].Replace("[", ""); ll[i] = ll[i].Replace("]", "");
|
||||||
string[] str = ll[i].Split('-');
|
string[] str = ll[i].Split('-');
|
||||||
rescult = rescult + dd[1]+ str[1] + str[0];
|
rescult = rescult + dd[1] + str[1] + str[0];
|
||||||
}
|
}
|
||||||
return rescult;
|
return rescult;
|
||||||
}
|
}
|
||||||
@@ -1293,7 +1311,7 @@ namespace TetraPackOCR
|
|||||||
private int GetXYRonRightDown(CogPMAlignResults Results)
|
private int GetXYRonRightDown(CogPMAlignResults Results)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i=0;
|
int i = 0;
|
||||||
double[] xx = new double[Results.Count], yy = new double[Results.Count], rr = new double[Results.Count];
|
double[] xx = new double[Results.Count], yy = new double[Results.Count], rr = new double[Results.Count];
|
||||||
//第一次循环将所有坐标取出
|
//第一次循环将所有坐标取出
|
||||||
for (int j = 0; j < Results.Count; j++)
|
for (int j = 0; j < Results.Count; j++)
|
||||||
@@ -1304,20 +1322,20 @@ namespace TetraPackOCR
|
|||||||
}
|
}
|
||||||
if (Results.Count == 1)
|
if (Results.Count == 1)
|
||||||
{
|
{
|
||||||
i= 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
else if (Results.Count == 2)
|
else if (Results.Count == 2)
|
||||||
{
|
{
|
||||||
double Xdist,Ydist;
|
double Xdist, Ydist;
|
||||||
Xdist = Math.Abs(xx[0] - xx[1]);
|
Xdist = Math.Abs(xx[0] - xx[1]);
|
||||||
Ydist = Math.Abs(yy[0] - yy[1]);
|
Ydist = Math.Abs(yy[0] - yy[1]);
|
||||||
if (Xdist>Ydist)
|
if (Xdist > Ydist)
|
||||||
{
|
{
|
||||||
i= Array.IndexOf(xx, xx.Min());
|
i = Array.IndexOf(xx, xx.Min());
|
||||||
}
|
}
|
||||||
else if(Xdist<Ydist)
|
else if (Xdist < Ydist)
|
||||||
{
|
{
|
||||||
i= Array.IndexOf(yy, yy.Max());
|
i = Array.IndexOf(yy, yy.Max());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1486,7 +1504,7 @@ namespace TetraPackOCR
|
|||||||
}
|
}
|
||||||
//lastocr.Add(item.Text);
|
//lastocr.Add(item.Text);
|
||||||
|
|
||||||
pointsList.Add(new Point(item.BoxPoints[0].X, item.BoxPoints[0].Y,item.Text));
|
pointsList.Add(new Point(item.BoxPoints[0].X, item.BoxPoints[0].Y, item.Text));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1557,7 +1575,7 @@ namespace TetraPackOCR
|
|||||||
//新图片路径
|
//新图片路径
|
||||||
String newPath = System.IO.Path.GetExtension(oldPath);
|
String newPath = System.IO.Path.GetExtension(oldPath);
|
||||||
//计算新的文件名,在新文件名后加_new
|
//计算新的文件名,在新文件名后加_new
|
||||||
newPath = oldPath.Substring(0, oldPath.Length - newPath.Length) + "_new"+ mMatchingStr + newPath;
|
newPath = oldPath.Substring(0, oldPath.Length - newPath.Length) + "_new" + mMatchingStr + newPath;
|
||||||
//定义截取矩形
|
//定义截取矩形
|
||||||
System.Drawing.Rectangle cropArea = new System.Drawing.Rectangle(x, y, width, height);
|
System.Drawing.Rectangle cropArea = new System.Drawing.Rectangle(x, y, width, height);
|
||||||
//要截取的区域大小
|
//要截取的区域大小
|
||||||
@@ -1593,12 +1611,12 @@ namespace TetraPackOCR
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GETOCR(List<string> readOCR, string design)
|
private string GETOCR(List<string> readOCR, string design)
|
||||||
{
|
{
|
||||||
string ocrresult="";
|
string ocrresult = "";
|
||||||
string[] d = design.Split('-');
|
string[] d = design.Split('-');
|
||||||
string pattern = @""+d[1]+"[A-Z0-9]{8}";
|
string pattern = @"" + d[1] + "[A-Z0-9]{8}";
|
||||||
for (int i = 0; i < readOCR.Count; i++)
|
for (int i = 0; i < readOCR.Count; i++)
|
||||||
{
|
{
|
||||||
readOCR[i]=readOCR[i].Replace("_", "");
|
readOCR[i] = readOCR[i].Replace("_", "");
|
||||||
readOCR[i] = readOCR[i].Replace(" ", "");
|
readOCR[i] = readOCR[i].Replace(" ", "");
|
||||||
}
|
}
|
||||||
MatchCollection matchResults;
|
MatchCollection matchResults;
|
||||||
@@ -1687,7 +1705,7 @@ namespace TetraPackOCR
|
|||||||
{
|
{
|
||||||
lbl_L1_verOcrRs.BackColor = Color.Red;
|
lbl_L1_verOcrRs.BackColor = Color.Red;
|
||||||
}
|
}
|
||||||
else if(s>0.9 & s<1)
|
else if (s > 0.9 & s < 1)
|
||||||
{
|
{
|
||||||
lbl_L1_verOcrRs.BackColor = Color.Lime;
|
lbl_L1_verOcrRs.BackColor = Color.Lime;
|
||||||
s = 1;
|
s = 1;
|
||||||
@@ -1915,13 +1933,13 @@ namespace TetraPackOCR
|
|||||||
mMatchingStr = Convert.ToInt32(mMatchingStrf);
|
mMatchingStr = Convert.ToInt32(mMatchingStrf);
|
||||||
|
|
||||||
log.Info("PC接收PLC数据:数据内容:" + mMatchingStr);
|
log.Info("PC接收PLC数据:数据内容:" + mMatchingStr);
|
||||||
if (NumberOfLanes+1 == mMatchingStr)
|
if (NumberOfLanes + 1 == mMatchingStr)
|
||||||
{
|
{
|
||||||
if(ocrAcc.Min()<0.95)
|
if (ocrAcc.Min() < 0.95)
|
||||||
{
|
{
|
||||||
MessageBox.Show("当前检测中出现严重错误请注意!",this.Text, MessageBoxButtons.OK,MessageBoxIcon.Error);
|
MessageBox.Show("当前检测中出现严重错误请注意!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
else if(ocrAcc.Min()>0.95 & ocrAcc.Min()<1)
|
else if (ocrAcc.Min() > 0.95 & ocrAcc.Min() < 1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("当前检测中出现可允许误差请注意!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("当前检测中出现可允许误差请注意!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
@@ -2169,15 +2187,15 @@ namespace TetraPackOCR
|
|||||||
if (this.check_Autorun.Checked == false)
|
if (this.check_Autorun.Checked == false)
|
||||||
{
|
{
|
||||||
List<float> d = new List<float>();
|
List<float> d = new List<float>();
|
||||||
for (int i=0;i<l.Count;i++)
|
for (int i = 0; i < l.Count; i++)
|
||||||
{
|
{
|
||||||
if(i ==0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
d.Add(l[i]);
|
d.Add(l[i]);
|
||||||
}
|
}
|
||||||
else if(i%2==1)
|
else if (i % 2 == 1)
|
||||||
{
|
{
|
||||||
d.Add( l[l.Count - i-1]);
|
d.Add(l[l.Count - i - 1]);
|
||||||
d.Add(l[l.Count - i]);
|
d.Add(l[l.Count - i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\OpenCvSharp4.runtime.win.4.11.0.20250507\build\netstandard\OpenCvSharp4.runtime.win.props" Condition="Exists('..\packages\OpenCvSharp4.runtime.win.4.11.0.20250507\build\netstandard\OpenCvSharp4.runtime.win.props')" />
|
||||||
<Import Project="..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props" Condition="Exists('..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props')" />
|
<Import Project="..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props" Condition="Exists('..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props')" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
@@ -199,6 +200,9 @@
|
|||||||
<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
|
<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\OpenCvSharp4.4.11.0.20250507\lib\netstandard2.0\OpenCvSharp.dll</HintPath>
|
<HintPath>..\packages\OpenCvSharp4.4.11.0.20250507\lib\netstandard2.0\OpenCvSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="OpenCvSharp.Extensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\OpenCvSharp4.Extensions.4.11.0.20250507\lib\netstandard2.0\OpenCvSharp.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="PaddleOCRSharp, Version=5.1.0.0, Culture=neutral, processorArchitecture=AMD64">
|
<Reference Include="PaddleOCRSharp, Version=5.1.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||||
<HintPath>..\packages\PaddleOCRSharp.5.1.0\lib\net47\PaddleOCRSharp.dll</HintPath>
|
<HintPath>..\packages\PaddleOCRSharp.5.1.0\lib\net47\PaddleOCRSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -221,6 +225,9 @@
|
|||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.configuration" />
|
<Reference Include="System.configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Drawing.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Drawing.Common.10.0.0-rc.2.25502.107\lib\net462\System.Drawing.Common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Formats.Asn1, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Formats.Asn1, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Formats.Asn1.10.0.0-rc.2.25502.107\lib\net462\System.Formats.Asn1.dll</HintPath>
|
<HintPath>..\packages\System.Formats.Asn1.10.0.0-rc.2.25502.107\lib\net462\System.Formats.Asn1.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -336,12 +343,6 @@
|
|||||||
<None Include="Resources\ON.png" />
|
<None Include="Resources\ON.png" />
|
||||||
<None Include="Resources\OFF.png" />
|
<None Include="Resources\OFF.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\LibImageService\LibImageService.csproj">
|
|
||||||
<Project>{bc738e23-1b32-497b-a654-569212ef4647}</Project>
|
|
||||||
<Name>LibImageService</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
@@ -351,6 +352,7 @@
|
|||||||
<Error Condition="!Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
|
<Error Condition="!Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
|
||||||
<Error Condition="!Exists('..\packages\Paddle.Runtime.win_x64.3.1.0.1\build\Paddle.Runtime.win_x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Paddle.Runtime.win_x64.3.1.0.1\build\Paddle.Runtime.win_x64.targets'))" />
|
<Error Condition="!Exists('..\packages\Paddle.Runtime.win_x64.3.1.0.1\build\Paddle.Runtime.win_x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Paddle.Runtime.win_x64.3.1.0.1\build\Paddle.Runtime.win_x64.targets'))" />
|
||||||
<Error Condition="!Exists('..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props'))" />
|
<Error Condition="!Exists('..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\OpenCvSharp4.runtime.win.4.11.0.20250507\build\netstandard\OpenCvSharp4.runtime.win.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\OpenCvSharp4.runtime.win.4.11.0.20250507\build\netstandard\OpenCvSharp4.runtime.win.props'))" />
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="..\packages\PaddleOCRSharp.5.1.0\build\PaddleOCRSharp.targets" Condition="Exists('..\packages\PaddleOCRSharp.5.1.0\build\PaddleOCRSharp.targets')" />
|
<Import Project="..\packages\PaddleOCRSharp.5.1.0\build\PaddleOCRSharp.targets" Condition="Exists('..\packages\PaddleOCRSharp.5.1.0\build\PaddleOCRSharp.targets')" />
|
||||||
<Import Project="..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets" Condition="Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" />
|
<Import Project="..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets" Condition="Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" />
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
<package id="NPOI" version="2.7.5" targetFramework="net472" />
|
<package id="NPOI" version="2.7.5" targetFramework="net472" />
|
||||||
<package id="NSax" version="1.0.2" targetFramework="net472" />
|
<package id="NSax" version="1.0.2" targetFramework="net472" />
|
||||||
<package id="OpenCvSharp4" version="4.11.0.20250507" targetFramework="net472" />
|
<package id="OpenCvSharp4" version="4.11.0.20250507" targetFramework="net472" />
|
||||||
|
<package id="OpenCvSharp4.Extensions" version="4.11.0.20250507" targetFramework="net472" />
|
||||||
|
<package id="OpenCvSharp4.runtime.win" version="4.11.0.20250507" targetFramework="net472" />
|
||||||
<package id="Paddle.Runtime.win_x64" version="3.1.0.1" targetFramework="net472" />
|
<package id="Paddle.Runtime.win_x64" version="3.1.0.1" targetFramework="net472" />
|
||||||
<package id="PaddleOCRSharp" version="5.1.0" targetFramework="net472" />
|
<package id="PaddleOCRSharp" version="5.1.0" targetFramework="net472" />
|
||||||
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net472" />
|
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net472" />
|
||||||
@@ -21,6 +23,7 @@
|
|||||||
<package id="SixLabors.ImageSharp" version="3.1.11" targetFramework="net472" />
|
<package id="SixLabors.ImageSharp" version="3.1.11" targetFramework="net472" />
|
||||||
<package id="System.Buffers" version="4.6.1" targetFramework="net472" />
|
<package id="System.Buffers" version="4.6.1" targetFramework="net472" />
|
||||||
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net472" />
|
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net472" />
|
||||||
|
<package id="System.Drawing.Common" version="10.0.0-rc.2.25502.107" targetFramework="net472" />
|
||||||
<package id="System.Formats.Asn1" version="10.0.0-rc.2.25502.107" targetFramework="net472" />
|
<package id="System.Formats.Asn1" version="10.0.0-rc.2.25502.107" targetFramework="net472" />
|
||||||
<package id="System.IO.Compression" version="4.3.0" targetFramework="net472" />
|
<package id="System.IO.Compression" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
|
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
|
||||||
|
|||||||
Reference in New Issue
Block a user