Commit 58a42d46 SK

merge

2 个父辈 1c96f805 0fdda9d7
......@@ -8,13 +8,17 @@ using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace AOI
{
public class AoiProject
{
private AoiProject()
{
}
public AoiProject(Image theImage)
{
this.standardImage = theImage;
......@@ -102,27 +106,49 @@ namespace AOI
/// 加载项目
/// </summary>
/// <param name="filePath"></param>
public void Load(string filePath)
public static AoiProject Load(string filePath, out string msg)
{
Dictionary<string, string> projectMap = JsonUtil.DeserializeJsonToObjectFromFile<Dictionary<string, string>>(filePath);
string base64Img = projectMap["base64Img"];
this.standardImage = Base64Util.ToImage(base64Img);
string methodMapJson = projectMap["methodMap"];
var jsonMap = JsonUtil.DeserializeJsonToObject<Dictionary<string, string>>(methodMapJson);
foreach(var item in jsonMap)
Thread.Sleep(1);
GC.Collect();
msg = "";
Thread.Sleep(1);
AoiProject aoiProject = new AoiProject();
try
{
Dictionary<string, string> projectMap = JsonUtil.DeserializeJsonToObjectFromFile<Dictionary<string, string>>(filePath);
string base64Img = projectMap["base64Img"];
aoiProject.standardImage = Base64Util.ToImage(base64Img);
string methodMapJson = projectMap["methodMap"];
var jsonMap = JsonUtil.DeserializeJsonToObject<Dictionary<string, string>>(methodMapJson);
foreach (var item in jsonMap)
{
JObject obj = JObject.Parse(item.Value);
string fullTypeName = obj.Value<string>("FullTypeName");
Type t = Type.GetType(fullTypeName);
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(item.Value);
object o = serializer.Deserialize(new JsonTextReader(sr), t);
AoiMethod aoiMethod = (AoiMethod)o;
string PathDataStr = obj.Value<string>("PathDataStr");
PathData pathData = JsonUtil.DeserializeJsonToObject<PathData>(PathDataStr);
aoiMethod.RoiPath = new GraphicsPath(pathData.Points, pathData.Types);
aoiProject.methodMap.Add(item.Key, aoiMethod);
Thread.Sleep(1);
}
return aoiProject;
}
catch (Exception ex)
{
JObject obj = JObject.Parse(item.Value);
string fullTypeName = obj.Value<string>("FullTypeName");
Type t = Type.GetType(fullTypeName);
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(item.Value);
object o = serializer.Deserialize(new JsonTextReader(sr), t);
AoiMethod aoiMethod = (AoiMethod)o;
string PathDataStr = obj.Value<string>("PathDataStr");
PathData pathData = JsonUtil.DeserializeJsonToObject<PathData>(PathDataStr);
aoiMethod.RoiPath = new GraphicsPath(pathData.Points, pathData.Types);
methodMap.Add(item.Key, aoiMethod);
if (aoiProject.standardImage != null)
{
aoiProject.standardImage.Dispose();
}
aoiProject = null;
msg = ex.ToString();
return null;
}
}
......
......@@ -120,6 +120,7 @@ namespace AOI
}
return false;
}).ToList();
blobList = resultBlobs;
return resultBlobs.Count;
}
}
......
......@@ -31,28 +31,34 @@ namespace AOI
/// <returns></returns>
public GraphicsPath GetSearchPath()
{
if(RoiPath != null && SearchPathZoom > 0)
try
{
GraphicsPath SearchPath = new GraphicsPath(RoiPath.PathPoints, RoiPath.PathTypes);
Matrix matrix = new Matrix();
matrix.Scale(SearchPathZoom, SearchPathZoom);
SearchPath.Transform(matrix);
if (RoiPath != null && SearchPathZoom > 0)
{
GraphicsPath SearchPath = new GraphicsPath(RoiPath.PathPoints, RoiPath.PathTypes);
Matrix matrix = new Matrix();
matrix.Scale(SearchPathZoom, SearchPathZoom);
SearchPath.Transform(matrix);
var oldBounds = this.RoiPath.GetBounds();
var newBounds = SearchPath.GetBounds();
var oldCenterX = oldBounds.X + oldBounds.Width / 2;
var oldCenterY = oldBounds.Y + oldBounds.Height / 2;
var oldBounds = this.RoiPath.GetBounds();
var newBounds = SearchPath.GetBounds();
var oldCenterX = oldBounds.X + oldBounds.Width / 2;
var oldCenterY = oldBounds.Y + oldBounds.Height / 2;
var newCenterX = newBounds.X + newBounds.Width / 2;
var newCenterY = newBounds.Y + newBounds.Height / 2;
var newCenterX = newBounds.X + newBounds.Width / 2;
var newCenterY = newBounds.Y + newBounds.Height / 2;
matrix.Reset();
matrix.Translate(oldCenterX - newCenterX, oldCenterY - newCenterY);
SearchPath.Transform(matrix);
matrix.Reset();
matrix.Translate(oldCenterX - newCenterX, oldCenterY - newCenterY);
SearchPath.Transform(matrix);
return SearchPath;
}
return RoiPath;
return SearchPath;
}
return RoiPath;
}catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}return null;
}
/// <summary>
......@@ -69,6 +75,7 @@ namespace AOI
if(resultImage != null)
{
resultBean.result = true;
resultBean.currentRoiImage = resultImage;
}
return resultBean;
}
......@@ -94,7 +101,7 @@ namespace AOI
//double same = Cv2.MatchShapes(grayMarkMat, graySearchMat, ShapeMatchModes.I1);
//Console.WriteLine("===============" + same);
Mat result = new Mat(searchMat.Cols - markMat.Cols + 1, searchMat.Rows - markMat.Cols + 1, MatType.CV_32FC1);
Mat result = new Mat(searchMat.Cols - markMat.Cols + 1, searchMat.Rows - markMat.Rows + 1, MatType.CV_32FC1);
//进行匹配(1母图,2模版子图,3返回的result,4匹配模式_这里的算法比opencv少,具体可以看opencv的相关资料说明)
Cv2.MatchTemplate(searchMat, markMat, result, TemplateMatchModes.CCoeffNormed);
......@@ -152,10 +159,10 @@ namespace AOI
Mat fixedMat = new Mat();
Cv2.WarpAffine(matToCheck, fixedMat, affine,new OpenCvSharp.Size(standardImage.Width, standardImage.Height));
//var fixedMat = FixImage(affine, matToCheck);
Image markImage = GetRoiImage(ImageUtil.ToImage(fixedMat), RoiPath, true);
//Cv2.ImShow("Fixed", ImageUtil.ToMat(markImage));
//return ImageUtil.ToImage(fixedMat);
return markImage;
//Image markImage = GetRoiImage(ImageUtil.ToImage(fixedMat), RoiPath, true);
// return markImage;
// Cv2.ImShow("Fixed", ImageUtil.ToMat(markImage));
return ImageUtil.ToImage(fixedMat);
}
//bool needCut = false;
////标准图中的Mart区域
......
......@@ -58,24 +58,30 @@ namespace AOI
//搜索区域
Image searchImage = GetRoiImage(imageToCheck, RoiPath, needCut);
cutImg = searchImage;
//searchImage = imageToCheck;
if (templateImage != null && searchImage != null)
try
{
Mat searchMat = ImageUtil.ToMat(new Bitmap(searchImage));
Mat templateMat = ImageUtil.ToMat(new Bitmap(templateImage));
//searchImage = imageToCheck;
if (templateImage != null && searchImage != null)
{
Mat searchMat = ImageUtil.ToMat(new Bitmap(searchImage));
Mat templateMat = ImageUtil.ToMat(new Bitmap(templateImage));
Mat result = new Mat(searchMat.Cols - templateMat.Cols + 1, searchMat.Rows - templateMat.Cols + 1, MatType.CV_32FC1);
Mat result = new Mat(searchMat.Cols - templateMat.Cols + 1, searchMat.Rows - templateMat.Rows + 1, MatType.CV_32FC1);
//进行匹配(1母图,2模版子图,3返回的result,4匹配模式_这里的算法比opencv少,具体可以看opencv的相关资料说明)
Cv2.MatchTemplate(searchMat, templateMat, result, TemplateMatchModes.CCoeffNormed);
//进行匹配(1母图,2模版子图,3返回的result,4匹配模式_这里的算法比opencv少,具体可以看opencv的相关资料说明)
Cv2.MatchTemplate(searchMat, templateMat, result, TemplateMatchModes.CCoeffNormed);
//对结果进行归一化(这里我测试的时候没有发现有什么用,但在opencv的书里有这个操作,应该有什么神秘加成,这里也加上)
//Cv2.Normalize(result, result, 1, 0, NormTypes.MinMax, -1);
/// 通过函数 minMaxLoc 定位最匹配的位置
/// (这个方法在opencv里有5个参数,这里我写的时候发现在有3个重载,看了下可以直接写成拿到起始坐标就不取最大值和最小值了)
/// minLocation和maxLocation根据匹配调用的模式取不同的点
Cv2.MinMaxLoc(result, out double minVal, out double maxVal, out OpenCvSharp.Point minLocation, out OpenCvSharp.Point maxLocation);
return maxVal * 100;
//对结果进行归一化(这里我测试的时候没有发现有什么用,但在opencv的书里有这个操作,应该有什么神秘加成,这里也加上)
//Cv2.Normalize(result, result, 1, 0, NormTypes.MinMax, -1);
/// 通过函数 minMaxLoc 定位最匹配的位置
/// (这个方法在opencv里有5个参数,这里我写的时候发现在有3个重载,看了下可以直接写成拿到起始坐标就不取最大值和最小值了)
/// minLocation和maxLocation根据匹配调用的模式取不同的点
Cv2.MinMaxLoc(result, out double minVal, out double maxVal, out OpenCvSharp.Point minLocation, out OpenCvSharp.Point maxLocation);
return maxVal * 100;
}
}catch(Exception ex)
{
Console.Write(ex.ToString());
}
return 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>{ACE00C09-176E-4AE7-92D1-3D58080E1561}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AOIProject</RootNamespace>
<AssemblyName>AOIProject</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Asa.Theme">
<HintPath>..\dll\Asa.Theme.dll</HintPath>
</Reference>
<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\lib\net40\OpenCvSharp.dll</HintPath>
</Reference>
<Reference Include="OpenCvSharp.Blob, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\lib\net40\OpenCvSharp.Blob.dll</HintPath>
</Reference>
<Reference Include="OpenCvSharp.Extensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\lib\net40\OpenCvSharp.Extensions.dll</HintPath>
</Reference>
<Reference Include="OpenCvSharp.UserInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\lib\net40\OpenCvSharp.UserInterface.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.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AccAOI\AccAOI.csproj">
<Project>{81d116dc-69c9-4b3b-ab7b-e324af18ca3e}</Project>
<Name>AccAOI</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
using AccAOI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AOIProject
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string path = "E:\\VSSource\\TSAV-智能组装机\\Line-TSAV-AOI\\TSA-V\\bin\\Debug\\config\\AOIConfig\\";
string filename = "E:\\VSSource\\TSAV-智能组装机\\Line-TSAV-AOI\\TSA-V\\bin\\Debug\\config\\AOIConfig\\aaaaa.data";
//string path = "F:\\Data\\";
//string filename = "F:\\Data\\11111.data";
AccAOI.camera.CameraManager.LoadCamera();
Application.Run(new FrmAoiSetting(filename, null,path));
AccAOI.camera.CameraManager.CloseCamera();
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AOIProject")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AOIProject")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("ace00c09-176e-4ae7-92d1-3d58080e1561")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AOIProject.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AOIProject.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AOIProject.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
......@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccImageBox", "ImageBox\Acc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AOI", "AOI\AOI.csproj", "{529F3829-BD91-42A7-95AF-9DEA2DC409CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AOIProject", "AOIProject\AOIProject.csproj", "{ACE00C09-176E-4AE7-92D1-3D58080E1561}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -27,6 +29,10 @@ Global
{529F3829-BD91-42A7-95AF-9DEA2DC409CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{529F3829-BD91-42A7-95AF-9DEA2DC409CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{529F3829-BD91-42A7-95AF-9DEA2DC409CB}.Release|Any CPU.Build.0 = Release|Any CPU
{ACE00C09-176E-4AE7-92D1-3D58080E1561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ACE00C09-176E-4AE7-92D1-3D58080E1561}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ACE00C09-176E-4AE7-92D1-3D58080E1561}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ACE00C09-176E-4AE7-92D1-3D58080E1561}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccAOI
{
class AOIFormUtil
{
public static int GetIntValue(Asa.Theme.FlatText text)
{
int value = 0;
try
{
value = int.Parse(text.Text);
}
catch (Exception ex)
{
value = 0;
}
return value;
}
}
}
......@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{81D116DC-69C9-4B3B-AB7B-E324AF18CA3E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<OutputType>Library</OutputType>
<RootNamespace>AccAOI</RootNamespace>
<AssemblyName>AccAOI</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
......@@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......@@ -31,10 +32,16 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Asa.Theme">
<HintPath>..\dll\Asa.Theme.dll</HintPath>
</Reference>
<Reference Include="MvCameraControl.Net">
<HintPath>..\dll\MvCameraControl.Net.dll</HintPath>
</Reference>
<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\lib\net40\OpenCvSharp.dll</HintPath>
......@@ -63,6 +70,15 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AOIFormUtil.cs" />
<Compile Include="camera\CameraManager.cs" />
<Compile Include="ControlUtil.cs" />
<Compile Include="control\AioTempMatchControl.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="control\AioTempMatchControl.Designer.cs">
<DependentUpon>AioTempMatchControl.cs</DependentUpon>
</Compile>
<Compile Include="control\AioMarkControl.cs">
<SubType>Form</SubType>
</Compile>
......@@ -93,9 +109,12 @@
<Compile Include="FrmAoiSetting.Designer.cs">
<DependentUpon>FrmAoiSetting.cs</DependentUpon>
</Compile>
<Compile Include="FormUtil.cs" />
<Compile Include="camera\HIKCamera.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="control\AioTempMatchControl.resx">
<DependentUpon>AioTempMatchControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="control\AioMarkControl.resx">
<DependentUpon>AioMarkControl.cs</DependentUpon>
</EmbeddedResource>
......
using AccAOI.control;
using AOI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccAOI
{
public class ControlUtil
{
public static AoiMethod GetMethod(string type)
{
AoiMethod methodInfo = null;
if (type.Equals(ControlType.Mark))
{
methodInfo = new AoiMarkMethod();
}
else if (type.Equals(ControlType.AOIBlob))
{
methodInfo = new AoiBlobMethod();
}
else if (type.Equals(ControlType.AOIRGB))
{
methodInfo = new AoiMethodRgb();
}
else if (type.Equals(ControlType.Match))
{
methodInfo = new AoiTemplateMethod();
}
return methodInfo;
}
public static ABaseControl GetControl(AoiMethod method)
{
ABaseControl aoiControl = null;
if (method is AoiBlobMethod)
{
aoiControl = new control.AoiBlobControl();
}
else if (method is AoiMarkMethod)
{
aoiControl = new control.AioMarkControl();
}
else if (method is AoiMethodRgb)
{
aoiControl = new control.AoiRgbControl();
}
else if (method is AoiTemplateMethod)
{
aoiControl = new control.AioTempMatchControl();
}
return aoiControl;
}
}
public class ControlType
{
/// <summary>
/// Mark点设置
/// </summary>
public static string Mark = "Mark点设置";
/// <summary>
/// 斑点分析
/// </summary>
public static string AOIBlob = "斑点分析";
/// <summary>
/// 颜色抽取
/// </summary>
public static string AOIRGB = "颜色抽取";
/// <summary>
/// 模板匹配
/// </summary>
public static string Match = "模板匹配";
}
}
......@@ -8,18 +8,6 @@ namespace AccAOI
{
public class FormUtil
{
public static int GetIntValue(Asa.Theme.FlatText text)
{
int value = 0;
try
{
value = int.Parse(text.Text);
}
catch (Exception ex)
{
value = 0;
}
return value;
}
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading.Tasks;
namespace AccAOI.camera
{
public class CameraManager
{
public static List<string> hikNameList = new List<string>();
private static char spiltChar = '#';
public static string ErrorMsg = "";
public static void LoadCamera(bool isReLoad = false)
{
if (isReLoad||hikNameList.Count<=0)
{
hikNameList = new List<string>();
HIKCamera.Instance.Load();
}
string[] names = HIKCamera.Instance.CameraName;
hikNameList.AddRange(names);
}
public static void CloseCamera()
{
HIKCamera.Instance.Close();
}
[HandleProcessCorruptedStateExceptions]
public static Bitmap GetCamerImage(string cameraName)
{
Bitmap bitm = null;
try
{
if (hikNameList.Contains(cameraName))
{
bool result = HIKCamera.Instance.IsOpen;
if (!result)
{
result = HIKCamera.Instance.Open(cameraName);
}
if (result)
{
HIKCamera.Instance.GrabOne();
if (HIKCamera.Instance.Image != null)
{
bitm = (Bitmap)HIKCamera.Instance.Image;
}
HIKCamera.Instance.Close();
}
else
{
ErrorMsg = ("相机【" + cameraName + "】打开失败:" + HIKCamera.Instance.ErrInfo);
}
}
else
{
ErrorMsg = ("未找到相机【" + cameraName + "】无法获取图片");
}
}
catch (Exception ex)
{
ErrorMsg = ("从相机【" + cameraName + "】获取图片出错:" + ex.ToString());
}
return bitm;
}
}
}
......@@ -27,7 +27,7 @@ namespace AccAOI.control
protected object UpdateLock = "";
public Image GetImg()
{
return FrmAoiSetting.Img;
return FrmAoiSetting.BaseImg;
}
internal bool IsShowOk = false;
/// <summary>
......@@ -115,4 +115,5 @@ namespace AccAOI.control
UpdateImage();
}
}
}
......@@ -36,12 +36,19 @@
this.btnOpenImage = new Asa.Theme.FlatButton();
this.txtImage = new Asa.Theme.FlatText();
this.lblTime = new System.Windows.Forms.Label();
this.trackBarSamePercent = new System.Windows.Forms.TrackBar();
this.flatLabel3 = new Asa.Theme.FlatLabel();
this.txtSamePercent = new Asa.Theme.FlatText();
this.panParam.SuspendLayout();
this.panResult.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarSamePercent)).BeginInit();
this.SuspendLayout();
//
// panParam
//
this.panParam.Controls.Add(this.txtSamePercent);
this.panParam.Controls.Add(this.trackBarSamePercent);
this.panParam.Controls.Add(this.flatLabel3);
this.panParam.Controls.Add(this.flatLabel2);
this.panParam.Controls.Add(this.flatTextSearchZoom);
this.panParam.Controls.Add(this.flatLabel1);
......@@ -53,22 +60,22 @@
this.panResult.Controls.Add(this.btnOpenImage);
this.panResult.Controls.Add(this.btnTest);
this.panResult.Controls.Add(this.lblResult);
this.panResult.Size = new System.Drawing.Size(298, 197);
//
// flatLabel1
//
this.flatLabel1.Inside = false;
this.flatLabel1.Location = new System.Drawing.Point(14, 50);
this.flatLabel1.Location = new System.Drawing.Point(14, 90);
this.flatLabel1.Name = "flatLabel1";
this.flatLabel1.Size = new System.Drawing.Size(80, 30);
this.flatLabel1.Size = new System.Drawing.Size(68, 30);
this.flatLabel1.TabIndex = 0;
this.flatLabel1.Text = "搜索区域:";
this.flatLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// flatTextSearchZoom
//
this.flatTextSearchZoom.Font = new System.Drawing.Font("宋体", 9F);
this.flatTextSearchZoom.Inside = false;
this.flatTextSearchZoom.Location = new System.Drawing.Point(175, 50);
this.flatTextSearchZoom.Location = new System.Drawing.Point(175, 90);
this.flatTextSearchZoom.Name = "flatTextSearchZoom";
this.flatTextSearchZoom.Size = new System.Drawing.Size(95, 30);
this.flatTextSearchZoom.TabIndex = 1;
......@@ -77,7 +84,7 @@
// flatLabel2
//
this.flatLabel2.Inside = false;
this.flatLabel2.Location = new System.Drawing.Point(109, 50);
this.flatLabel2.Location = new System.Drawing.Point(109, 90);
this.flatLabel2.Name = "flatLabel2";
this.flatLabel2.Size = new System.Drawing.Size(65, 30);
this.flatLabel2.TabIndex = 2;
......@@ -138,15 +145,51 @@
this.lblTime.TabIndex = 8;
this.lblTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// trackBarSamePercent
//
this.trackBarSamePercent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.trackBarSamePercent.Location = new System.Drawing.Point(125, 40);
this.trackBarSamePercent.Maximum = 100;
this.trackBarSamePercent.Name = "trackBarSamePercent";
this.trackBarSamePercent.Size = new System.Drawing.Size(165, 45);
this.trackBarSamePercent.TabIndex = 12;
this.trackBarSamePercent.TickStyle = System.Windows.Forms.TickStyle.None;
this.trackBarSamePercent.Value = 50;
this.trackBarSamePercent.ValueChanged += new System.EventHandler(this.trackBarSamePercent_ValueChanged);
//
// flatLabel3
//
this.flatLabel3.Inside = false;
this.flatLabel3.Location = new System.Drawing.Point(14, 37);
this.flatLabel3.Name = "flatLabel3";
this.flatLabel3.Size = new System.Drawing.Size(55, 30);
this.flatLabel3.TabIndex = 11;
this.flatLabel3.Text = "相似度:";
this.flatLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// txtSamePercent
//
this.txtSamePercent.Font = new System.Drawing.Font("宋体", 9F);
this.txtSamePercent.Inside = false;
this.txtSamePercent.Location = new System.Drawing.Point(75, 37);
this.txtSamePercent.Name = "txtSamePercent";
this.txtSamePercent.Padding = new System.Windows.Forms.Padding(3);
this.txtSamePercent.Size = new System.Drawing.Size(41, 30);
this.txtSamePercent.TabIndex = 26;
this.txtSamePercent.Text = "50";
this.txtSamePercent.TextChanged += new System.EventHandler(this.txtSamePercent_TextChanged);
//
// AioMarkControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(312, 700);
this.ClientSize = new System.Drawing.Size(312, 833);
this.Name = "AioMarkControl";
this.TitleName = "Mark设置";
this.panParam.ResumeLayout(false);
this.panParam.PerformLayout();
this.panResult.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.trackBarSamePercent)).EndInit();
this.ResumeLayout(false);
}
......@@ -161,5 +204,8 @@
private Asa.Theme.FlatText txtImage;
private Asa.Theme.FlatButton btnOpenImage;
private System.Windows.Forms.Label lblTime;
private System.Windows.Forms.TrackBar trackBarSamePercent;
private Asa.Theme.FlatLabel flatLabel3;
private Asa.Theme.FlatText txtSamePercent;
}
}
......@@ -11,6 +11,7 @@ using AOI;
using System.Threading;
using System.Drawing.Drawing2D;
using System.IO;
using Asa.Theme;
namespace AccAOI.control
{
......@@ -32,11 +33,26 @@ namespace AccAOI.control
{
method.RoiPath = currPath;
}
int value =trackBarSamePercent.Value;
SetText(txtSamePercent, trackBarSamePercent.Value);
// int value = trackBarSamePercent.Value;
method.SamePercent = value;
AoiInfo = method;
}
return AoiInfo;
}
public override void ShowAoiInfo()
{
if (this.AoiInfo is AoiMarkMethod)
{
AoiMarkMethod method = (AoiMarkMethod)AoiInfo;
trackBarSamePercent.Value = (int)method.SamePercent;
IsShowOk = true;
UpdateImage();
}
}
private void btnTest_Click(object sender, EventArgs e)
{
if (this.AoiInfo is AoiMarkMethod)
......@@ -47,15 +63,18 @@ namespace AccAOI.control
if (File.Exists(fileName))
{
//读取图片内容
checkImg = (Image)Image.FromFile(fileName).Clone();
// checkImg = (Image)Image.FromFile(fileName).Clone();
Image file = (Image)Image.FromFile(fileName);
checkImg = new Bitmap(file);
file.Dispose();
}
if (checkImg == null)
{
checkImg = FrmAoiSetting.Img;
checkImg = FrmAoiSetting.BaseImg;
}
DateTime time = DateTime.Now;
AoiMarkMethod mark = (AoiMarkMethod)AoiInfo;
Image result= mark.FixImage(FrmAoiSetting.Img, checkImg);
Image result= mark.FixImage(FrmAoiSetting.BaseImg, checkImg);
TimeSpan span = DateTime.Now - time;
if (result == null)
{
......@@ -84,6 +103,8 @@ namespace AccAOI.control
{
try
{
int value = trackBarSamePercent.Value;
SetText(txtSamePercent, trackBarSamePercent.Value);
Image BaseImage = GetImg();
if (BaseImage == null || currPath == null)
{
......@@ -131,5 +152,44 @@ namespace AccAOI.control
txtImage.Text = fileName;
}
private void trackBarSamePercent_ValueChanged(object sender, EventArgs e)
{
UpdateImage();
}
private void SetTbValue(TrackBar tb, int value)
{
if (tb.Value.Equals(value.ToString()))
{
return;
}
if (value < tb.Minimum)
{
tb.Value = tb.Minimum;
}
else if (value > tb.Maximum)
{
tb.Value = tb.Maximum;
}
else
{
tb.Value = value;
}
UpdateImage();
}
private void SetText(FlatText text, int value)
{
if (text.Text.ToString().Equals(value.ToString()))
{
return;
}
text.Text = value.ToString();
}
private void txtSamePercent_TextChanged(object sender, EventArgs e)
{
int value = AOIFormUtil.GetIntValue(txtSamePercent);
SetTbValue(trackBarSamePercent, value);
UpdateImage();
}
}
}
namespace AccAOI.control
{
partial class AioTempMatchControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.lblResult = new System.Windows.Forms.Label();
this.btnTest = new Asa.Theme.FlatButton();
this.btnOpenImage = new Asa.Theme.FlatButton();
this.txtImage = new Asa.Theme.FlatText();
this.lblTime = new System.Windows.Forms.Label();
this.trackBarSamePercent = new System.Windows.Forms.TrackBar();
this.flatLabel3 = new Asa.Theme.FlatLabel();
this.txtSamePercent = new Asa.Theme.FlatText();
this.panParam.SuspendLayout();
this.panResult.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarSamePercent)).BeginInit();
this.SuspendLayout();
//
// panParam
//
this.panParam.Controls.Add(this.txtSamePercent);
this.panParam.Controls.Add(this.trackBarSamePercent);
this.panParam.Controls.Add(this.flatLabel3);
//
// panResult
//
this.panResult.Controls.Add(this.lblTime);
this.panResult.Controls.Add(this.txtImage);
this.panResult.Controls.Add(this.btnOpenImage);
this.panResult.Controls.Add(this.btnTest);
this.panResult.Controls.Add(this.lblResult);
//
// lblResult
//
this.lblResult.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.lblResult.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblResult.ForeColor = System.Drawing.Color.Red;
this.lblResult.Location = new System.Drawing.Point(29, 123);
this.lblResult.Name = "lblResult";
this.lblResult.Size = new System.Drawing.Size(231, 24);
this.lblResult.TabIndex = 4;
this.lblResult.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnTest
//
this.btnTest.ImageSize = new System.Drawing.Size(0, 0);
this.btnTest.Inside = false;
this.btnTest.Location = new System.Drawing.Point(141, 79);
this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(90, 30);
this.btnTest.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnTest.TabIndex = 5;
this.btnTest.Text = "测试结果";
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
//
// btnOpenImage
//
this.btnOpenImage.ImageSize = new System.Drawing.Size(0, 0);
this.btnOpenImage.Inside = false;
this.btnOpenImage.Location = new System.Drawing.Point(45, 79);
this.btnOpenImage.Name = "btnOpenImage";
this.btnOpenImage.Size = new System.Drawing.Size(90, 30);
this.btnOpenImage.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnOpenImage.TabIndex = 6;
this.btnOpenImage.Text = "打开本地图片";
this.btnOpenImage.Click += new System.EventHandler(this.btnOpenImage_Click);
//
// txtImage
//
this.txtImage.Font = new System.Drawing.Font("宋体", 9F);
this.txtImage.Inside = false;
this.txtImage.Location = new System.Drawing.Point(8, 33);
this.txtImage.Name = "txtImage";
this.txtImage.Size = new System.Drawing.Size(281, 30);
this.txtImage.TabIndex = 7;
//
// lblTime
//
this.lblTime.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.lblTime.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblTime.ForeColor = System.Drawing.Color.Green;
this.lblTime.Location = new System.Drawing.Point(29, 158);
this.lblTime.Name = "lblTime";
this.lblTime.Size = new System.Drawing.Size(231, 24);
this.lblTime.TabIndex = 8;
this.lblTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// trackBarSamePercent
//
this.trackBarSamePercent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.trackBarSamePercent.Location = new System.Drawing.Point(125, 40);
this.trackBarSamePercent.Maximum = 100;
this.trackBarSamePercent.Name = "trackBarSamePercent";
this.trackBarSamePercent.Size = new System.Drawing.Size(165, 45);
this.trackBarSamePercent.TabIndex = 12;
this.trackBarSamePercent.TickStyle = System.Windows.Forms.TickStyle.None;
this.trackBarSamePercent.Value = 50;
this.trackBarSamePercent.ValueChanged += new System.EventHandler(this.trackBarSamePercent_ValueChanged);
//
// flatLabel3
//
this.flatLabel3.Inside = false;
this.flatLabel3.Location = new System.Drawing.Point(14, 37);
this.flatLabel3.Name = "flatLabel3";
this.flatLabel3.Size = new System.Drawing.Size(55, 30);
this.flatLabel3.TabIndex = 11;
this.flatLabel3.Text = "相似度:";
this.flatLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// txtSamePercent
//
this.txtSamePercent.Font = new System.Drawing.Font("宋体", 9F);
this.txtSamePercent.Inside = false;
this.txtSamePercent.Location = new System.Drawing.Point(75, 37);
this.txtSamePercent.Name = "txtSamePercent";
this.txtSamePercent.Padding = new System.Windows.Forms.Padding(3);
this.txtSamePercent.Size = new System.Drawing.Size(41, 30);
this.txtSamePercent.TabIndex = 26;
this.txtSamePercent.Text = "50";
this.txtSamePercent.TextChanged += new System.EventHandler(this.txtSamePercent_TextChanged);
//
// AioTempMatchControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(312, 833);
this.Name = "AioTempMatchControl";
this.TitleName = "模板匹配";
this.panParam.ResumeLayout(false);
this.panParam.PerformLayout();
this.panResult.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.trackBarSamePercent)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label lblResult;
private Asa.Theme.FlatButton btnTest;
private Asa.Theme.FlatText txtImage;
private Asa.Theme.FlatButton btnOpenImage;
private System.Windows.Forms.Label lblTime;
private System.Windows.Forms.TrackBar trackBarSamePercent;
private Asa.Theme.FlatLabel flatLabel3;
private Asa.Theme.FlatText txtSamePercent;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AOI;
using System.Threading;
using System.Drawing.Drawing2D;
using System.IO;
using Asa.Theme;
namespace AccAOI.control
{
public partial class AioTempMatchControl : ABaseControl
{
public AioTempMatchControl()
{
InitializeComponent();
}
public override AoiMethod GetAoiInfo()
{
if (this.AoiInfo is AoiTemplateMethod)
{
AoiTemplateMethod method = (AoiTemplateMethod)AoiInfo;
if (currPath != null)
{
method.RoiPath = currPath;
}
int value =trackBarSamePercent.Value;
SetText(txtSamePercent, trackBarSamePercent.Value);
// int value = trackBarSamePercent.Value;
method.SamePercent = value;
AoiInfo = method;
}
return AoiInfo;
}
public override void ShowAoiInfo()
{
if (this.AoiInfo is AoiTemplateMethod)
{
AoiTemplateMethod method = (AoiTemplateMethod)AoiInfo;
trackBarSamePercent.Value = (int)method.SamePercent;
IsShowOk = true;
UpdateImage();
}
}
private void btnTest_Click(object sender, EventArgs e)
{
if (this.AoiInfo is AoiTemplateMethod)
{
string fileName = txtImage.Text.ToString();
Image checkImg = null;
if (File.Exists(fileName))
{
//读取图片内容
//checkImg = (Image)Image.FromFile(fileName).Clone();
Image file = (Image)Image.FromFile(fileName);
checkImg = new Bitmap(file);
file.Dispose();
}
if (checkImg == null)
{
checkImg = FrmAoiSetting.BaseImg;
}
DateTime time = DateTime.Now;
AoiTemplateMethod Match = (AoiTemplateMethod)AoiInfo;
ResultBean result= Match.Check(FrmAoiSetting.BaseImg, checkImg);
TimeSpan span = DateTime.Now - time;
if (result == null)
{
this.aoiImage.Image = null;
lblResult.ForeColor = Color.Red ;
lblResult.Text = "匹配失败";
}
else
{
lblResult.ForeColor = Color.Green;
lblResult.Text =result.result? "OK":"NG" ;
if (result.currentRoiImage != null)
{
this.aoiImage.Image = result.currentRoiImage;
}
}
lblTime.Text= "耗时:" + Math.Round(span.TotalSeconds, 1)+ "秒";
}
}
public override void UpdateImage()
{
if (!IsShowOk)
{
return;
}
if (Monitor.TryEnter(UpdateLock))
{
try
{
int value = trackBarSamePercent.Value;
SetText(txtSamePercent, trackBarSamePercent.Value);
Image BaseImage = GetImg();
if (BaseImage == null || currPath == null)
{
return;
}
GetAoiInfo();
AoiTemplateMethod MatchMethod = (AoiTemplateMethod)AoiInfo;
MatchMethod.RoiPath = currPath;
GC.Collect();
}
catch (Exception ex)
{
Console.WriteLine("UpdateImage出错:" + ex.ToString());
}
finally
{
Monitor.Exit(UpdateLock);
}
}
else
{
Console.WriteLine("UpdateImage执行失败,未得到锁");
}
}
private void btnOpenImage_Click(object sender, EventArgs e)
{
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
openDialog.Title = "打开本地图片";
openDialog.Filter = "All Supported Images (*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png)|*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png|Bitmaps (*.bmp;*.dib;*.rle)|*.bmp;*.dib;*.rle|Graphics Interchange Format (*.gif)|*.gif|Joint Photographic Experts (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|All Files (*.*)|*.*";
openDialog.DefaultExt = "png";
//openDialog.DefaultExt = "png";
System.Windows.Forms.DialogResult result = openDialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.Cancel)
{
return;
}
string fileName = openDialog.FileName;
txtImage.Text = fileName;
}
private void trackBarSamePercent_ValueChanged(object sender, EventArgs e)
{
UpdateImage();
}
private void SetTbValue(TrackBar tb, int value)
{
if (tb.Value.Equals(value.ToString()))
{
return;
}
if (value < tb.Minimum)
{
tb.Value = tb.Minimum;
}
else if (value > tb.Maximum)
{
tb.Value = tb.Maximum;
}
else
{
tb.Value = value;
}
UpdateImage();
}
private void SetText(FlatText text, int value)
{
if (text.Text.ToString().Equals(value.ToString()))
{
return;
}
text.Text = value.ToString();
}
private void txtSamePercent_TextChanged(object sender, EventArgs e)
{
int value = AOIFormUtil.GetIntValue(txtSamePercent);
SetTbValue(trackBarSamePercent, value);
UpdateImage();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -44,23 +44,26 @@
this.btnUpdate = new Asa.Theme.FlatButton();
this.flatLabel7 = new Asa.Theme.FlatLabel();
this.txtNumResult = new Asa.Theme.FlatText();
this.lblList = new System.Windows.Forms.Label();
this.panResult.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarThresh)).BeginInit();
this.SuspendLayout();
//
// panParam
//
this.panParam.Location = new System.Drawing.Point(2, 319);
this.panParam.Size = new System.Drawing.Size(302, 146);
this.panParam.Size = new System.Drawing.Size(302, 128);
//
// panResult
//
this.panResult.Location = new System.Drawing.Point(2, 471);
this.panResult.Size = new System.Drawing.Size(302, 216);
this.panResult.Controls.Add(this.lblList);
this.panResult.Location = new System.Drawing.Point(2, 450);
this.panResult.Size = new System.Drawing.Size(302, 370);
//
// flatLabel1
//
this.flatLabel1.Inside = false;
this.flatLabel1.Location = new System.Drawing.Point(14, 358);
this.flatLabel1.Location = new System.Drawing.Point(14, 350);
this.flatLabel1.Name = "flatLabel1";
this.flatLabel1.Size = new System.Drawing.Size(42, 30);
this.flatLabel1.TabIndex = 8;
......@@ -70,7 +73,7 @@
// trackBarThresh
//
this.trackBarThresh.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.trackBarThresh.Location = new System.Drawing.Point(63, 364);
this.trackBarThresh.Location = new System.Drawing.Point(63, 356);
this.trackBarThresh.Maximum = 255;
this.trackBarThresh.Minimum = -1;
this.trackBarThresh.Name = "trackBarThresh";
......@@ -83,7 +86,7 @@
// lblthresh
//
this.lblthresh.Inside = false;
this.lblthresh.Location = new System.Drawing.Point(265, 358);
this.lblthresh.Location = new System.Drawing.Point(265, 350);
this.lblthresh.Name = "lblthresh";
this.lblthresh.Size = new System.Drawing.Size(30, 30);
this.lblthresh.TabIndex = 10;
......@@ -92,7 +95,7 @@
// flatLabel3
//
this.flatLabel3.Inside = false;
this.flatLabel3.Location = new System.Drawing.Point(14, 508);
this.flatLabel3.Location = new System.Drawing.Point(14, 484);
this.flatLabel3.Name = "flatLabel3";
this.flatLabel3.Size = new System.Drawing.Size(75, 30);
this.flatLabel3.TabIndex = 13;
......@@ -101,7 +104,7 @@
// chkwhiteOnBlack
//
this.chkwhiteOnBlack.Inside = false;
this.chkwhiteOnBlack.Location = new System.Drawing.Point(125, 419);
this.chkwhiteOnBlack.Location = new System.Drawing.Point(125, 405);
this.chkwhiteOnBlack.Name = "chkwhiteOnBlack";
this.chkwhiteOnBlack.Size = new System.Drawing.Size(62, 30);
this.chkwhiteOnBlack.TabIndex = 15;
......@@ -110,7 +113,7 @@
// flatLabel2
//
this.flatLabel2.Inside = false;
this.flatLabel2.Location = new System.Drawing.Point(12, 419);
this.flatLabel2.Location = new System.Drawing.Point(12, 405);
this.flatLabel2.Name = "flatLabel2";
this.flatLabel2.Size = new System.Drawing.Size(75, 30);
this.flatLabel2.TabIndex = 16;
......@@ -121,7 +124,7 @@
//
this.txtminArea.Font = new System.Drawing.Font("宋体", 9F);
this.txtminArea.Inside = false;
this.txtminArea.Location = new System.Drawing.Point(98, 508);
this.txtminArea.Location = new System.Drawing.Point(98, 484);
this.txtminArea.Name = "txtminArea";
this.txtminArea.Padding = new System.Windows.Forms.Padding(3);
this.txtminArea.Size = new System.Drawing.Size(74, 30);
......@@ -132,7 +135,7 @@
//
this.txtmaxArea.Font = new System.Drawing.Font("宋体", 9F);
this.txtmaxArea.Inside = false;
this.txtmaxArea.Location = new System.Drawing.Point(205, 508);
this.txtmaxArea.Location = new System.Drawing.Point(205, 484);
this.txtmaxArea.Name = "txtmaxArea";
this.txtmaxArea.Padding = new System.Windows.Forms.Padding(3);
this.txtmaxArea.Size = new System.Drawing.Size(74, 30);
......@@ -142,7 +145,7 @@
// flatLabel5
//
this.flatLabel5.Inside = false;
this.flatLabel5.Location = new System.Drawing.Point(176, 514);
this.flatLabel5.Location = new System.Drawing.Point(176, 490);
this.flatLabel5.Name = "flatLabel5";
this.flatLabel5.Size = new System.Drawing.Size(24, 25);
this.flatLabel5.TabIndex = 19;
......@@ -151,7 +154,7 @@
// flatLabel4
//
this.flatLabel4.Inside = false;
this.flatLabel4.Location = new System.Drawing.Point(176, 557);
this.flatLabel4.Location = new System.Drawing.Point(176, 526);
this.flatLabel4.Name = "flatLabel4";
this.flatLabel4.Size = new System.Drawing.Size(24, 39);
this.flatLabel4.TabIndex = 23;
......@@ -161,7 +164,7 @@
//
this.txtmaxNum.Font = new System.Drawing.Font("宋体", 9F);
this.txtmaxNum.Inside = false;
this.txtmaxNum.Location = new System.Drawing.Point(205, 557);
this.txtmaxNum.Location = new System.Drawing.Point(205, 526);
this.txtmaxNum.Name = "txtmaxNum";
this.txtmaxNum.Padding = new System.Windows.Forms.Padding(3);
this.txtmaxNum.Size = new System.Drawing.Size(74, 30);
......@@ -172,7 +175,7 @@
//
this.txtminNum.Font = new System.Drawing.Font("宋体", 9F);
this.txtminNum.Inside = false;
this.txtminNum.Location = new System.Drawing.Point(98, 557);
this.txtminNum.Location = new System.Drawing.Point(98, 526);
this.txtminNum.Name = "txtminNum";
this.txtminNum.Padding = new System.Windows.Forms.Padding(3);
this.txtminNum.Size = new System.Drawing.Size(74, 30);
......@@ -182,7 +185,7 @@
// flatLabel6
//
this.flatLabel6.Inside = false;
this.flatLabel6.Location = new System.Drawing.Point(14, 557);
this.flatLabel6.Location = new System.Drawing.Point(14, 526);
this.flatLabel6.Name = "flatLabel6";
this.flatLabel6.Size = new System.Drawing.Size(75, 30);
this.flatLabel6.TabIndex = 20;
......@@ -192,7 +195,7 @@
//
this.btnUpdate.ImageSize = new System.Drawing.Size(0, 0);
this.btnUpdate.Inside = false;
this.btnUpdate.Location = new System.Drawing.Point(189, 613);
this.btnUpdate.Location = new System.Drawing.Point(189, 571);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(90, 30);
this.btnUpdate.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
......@@ -203,7 +206,7 @@
// flatLabel7
//
this.flatLabel7.Inside = false;
this.flatLabel7.Location = new System.Drawing.Point(10, 613);
this.flatLabel7.Location = new System.Drawing.Point(10, 571);
this.flatLabel7.Name = "flatLabel7";
this.flatLabel7.Size = new System.Drawing.Size(83, 30);
this.flatLabel7.TabIndex = 43;
......@@ -214,17 +217,30 @@
this.txtNumResult.Enabled = false;
this.txtNumResult.Font = new System.Drawing.Font("宋体", 9F);
this.txtNumResult.Inside = false;
this.txtNumResult.Location = new System.Drawing.Point(98, 613);
this.txtNumResult.Location = new System.Drawing.Point(98, 571);
this.txtNumResult.Name = "txtNumResult";
this.txtNumResult.Padding = new System.Windows.Forms.Padding(3);
this.txtNumResult.Size = new System.Drawing.Size(74, 30);
this.txtNumResult.TabIndex = 42;
//
// lblList
//
this.lblList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblList.BackColor = System.Drawing.Color.Transparent;
this.lblList.ForeColor = System.Drawing.Color.White;
this.lblList.Location = new System.Drawing.Point(14, 168);
this.lblList.Name = "lblList";
this.lblList.Size = new System.Drawing.Size(269, 191);
this.lblList.TabIndex = 0;
this.lblList.Text = "面积列表:";
//
// AoiBlobControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(312, 699);
this.ClientSize = new System.Drawing.Size(312, 833);
this.Controls.Add(this.flatLabel7);
this.Controls.Add(this.txtNumResult);
this.Controls.Add(this.btnUpdate);
......@@ -261,6 +277,7 @@
this.Controls.SetChildIndex(this.btnUpdate, 0);
this.Controls.SetChildIndex(this.txtNumResult, 0);
this.Controls.SetChildIndex(this.flatLabel7, 0);
this.panResult.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.trackBarThresh)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
......@@ -285,5 +302,6 @@
private Asa.Theme.FlatButton btnUpdate;
private Asa.Theme.FlatLabel flatLabel7;
private Asa.Theme.FlatText txtNumResult;
private System.Windows.Forms.Label lblList;
}
}
......@@ -67,10 +67,10 @@ namespace AccAOI.control
}
MethodBlob.whiteOnBlack= chkwhiteOnBlack.Checked ;
MethodBlob.maxArea = FormUtil.GetIntValue(txtmaxArea);
MethodBlob.minArea = FormUtil.GetIntValue(txtminArea);
MethodBlob.maxNum = FormUtil.GetIntValue(txtmaxNum);
MethodBlob.minNum = FormUtil.GetIntValue(txtminNum);
MethodBlob.maxArea = AOIFormUtil.GetIntValue(txtmaxArea);
MethodBlob.minArea = AOIFormUtil.GetIntValue(txtminArea);
MethodBlob.maxNum = AOIFormUtil.GetIntValue(txtmaxNum);
MethodBlob.minNum = AOIFormUtil.GetIntValue(txtminNum);
if (currPath != null)
{
MethodBlob.RoiPath = currPath;
......@@ -89,6 +89,7 @@ namespace AccAOI.control
{
try
{
lblList.Text = "面积列表:";
Image BaseImage = GetImg();
if (BaseImage == null || currPath == null)
{
......@@ -112,6 +113,17 @@ namespace AccAOI.control
this.CutImage = cutImage;
}
}
list = (from m in list orderby m.Area descending select m).ToList< CvBlob > ();
string text= "编号".PadLeft(5,' ') + "面积↓".PadLeft(8, ' ') + "X坐标".PadLeft(10, ' ') + "Y坐标".PadLeft(10, ' ');
int index = 1;
foreach (CvBlob cv in list)
{
text += "\r\n" + index.ToString().PadLeft(5, ' ')+ cv.Area.ToString().PadLeft(12, ' ')+ Math.Round(cv.Centroid.X, 2).ToString().PadLeft(12, ' ') +
Math.Round(cv.Centroid.Y, 2).ToString().PadLeft(12, ' ');
index++;
}
lblList.Text = text;
GC.Collect();
}
catch (Exception ex)
......
namespace AccAOI.control
using System;
namespace AccAOI.control
{
partial class AoiRgbControl
{
......@@ -145,7 +147,7 @@
this.txtMaxR.Size = new System.Drawing.Size(41, 30);
this.txtMaxR.TabIndex = 26;
this.txtMaxR.Text = "255";
this.txtMaxR.TextChanged += new System.EventHandler(this.txtMinR_TextChanged);
this.txtMaxR.TextChanged += new System.EventHandler(this.txtMaxR_TextChanged);
//
// txtMinR
//
......@@ -187,7 +189,7 @@
this.txtMaxG.Size = new System.Drawing.Size(41, 30);
this.txtMaxG.TabIndex = 30;
this.txtMaxG.Text = "255";
this.txtMaxG.TextChanged += new System.EventHandler(this.txtMinR_TextChanged);
this.txtMaxG.TextChanged += new System.EventHandler(this.txtMaxG_TextChanged);
//
// txtMinG
//
......@@ -199,7 +201,7 @@
this.txtMinG.Size = new System.Drawing.Size(41, 30);
this.txtMinG.TabIndex = 29;
this.txtMinG.Text = "0";
this.txtMinG.TextChanged += new System.EventHandler(this.txtMinR_TextChanged);
this.txtMinG.TextChanged += new System.EventHandler(this.txtMinG_TextChanged);
//
// flatLabel6
//
......@@ -230,7 +232,7 @@
this.txtMaxB.Size = new System.Drawing.Size(41, 30);
this.txtMaxB.TabIndex = 34;
this.txtMaxB.Text = "255";
this.txtMaxB.TextChanged += new System.EventHandler(this.txtMinR_TextChanged);
this.txtMaxB.TextChanged += new System.EventHandler(this.txtMaxB_TextChanged);
//
// txtMinB
//
......@@ -242,7 +244,7 @@
this.txtMinB.Size = new System.Drawing.Size(41, 30);
this.txtMinB.TabIndex = 33;
this.txtMinB.Text = "0";
this.txtMinB.TextChanged += new System.EventHandler(this.txtMinR_TextChanged);
this.txtMinB.TextChanged += new System.EventHandler(this.txtMinB_TextChanged);
//
// flatLabel8
//
......@@ -392,6 +394,8 @@
}
#endregion
private Asa.Theme.FlatLabel flatLabel5;
......
......@@ -51,20 +51,21 @@ namespace AccAOI.control
{
methodRgb = (AoiMethodRgb)AoiInfo;
methodRgb.minR = FormUtil.GetIntValue(txtMinR);
methodRgb.maxR = FormUtil.GetIntValue(txtMaxR);
methodRgb.minG = FormUtil.GetIntValue(txtMinG);
methodRgb.maxG = FormUtil.GetIntValue(txtMaxG);
methodRgb.maxB = FormUtil.GetIntValue(txtMaxB);
methodRgb.minB = FormUtil.GetIntValue(txtMinB);
SetTbValue(tbMinR, methodRgb.minR);
SetTbValue(tbMaxR, methodRgb.maxR);
SetTbValue(tbMinG, methodRgb.minG);
SetTbValue(tbMaxG, methodRgb.maxG);
SetTbValue(tbMaxB, methodRgb.maxB);
SetTbValue(tbMinB, methodRgb.minB);
methodRgb.minRate = FormUtil.GetIntValue(txtminRate);
methodRgb.maxRate = FormUtil.GetIntValue(txtmaxRate);
methodRgb.minR = tbMinR.Value;
methodRgb.maxR = tbMaxR.Value;
methodRgb.minG = tbMinG.Value;
methodRgb.maxG = tbMaxG.Value;
methodRgb.maxB = tbMaxB.Value;
methodRgb.minB = tbMinB.Value;
SetText(txtMinR, methodRgb.minR);
SetText(txtMaxR, methodRgb.maxR);
SetText(txtMinG, methodRgb.minG);
SetText(txtMaxG, methodRgb.maxG);
SetText(txtMaxB, methodRgb.maxB);
SetText(txtMinB, methodRgb.minB);
methodRgb.minRate = AOIFormUtil.GetIntValue(txtminRate);
methodRgb.maxRate = AOIFormUtil.GetIntValue(txtmaxRate);
if (currPath != null)
{
methodRgb.RoiPath = currPath;
......@@ -133,41 +134,81 @@ namespace AccAOI.control
UpdateImage();
}
private void txtMinR_TextChanged(object sender, EventArgs e)
{
UpdateImage();
}
//private void txtMinR_TextChanged(object sender, EventArgs e)
//{
// UpdateImage();
//}
private void tbMinR_ValueChanged(object sender, EventArgs e)
{
SetText(txtMinR, tbMinR.Value);
UpdateImage();
}
private void tbMaxR_ValueChanged(object sender, EventArgs e)
{
SetText(txtMaxR, tbMaxR.Value);
UpdateImage();
}
private void tbMinG_ValueChanged(object sender, EventArgs e)
{
SetText(txtMinG, tbMinG.Value);
UpdateImage();
}
private void tbMaxG_ValueChanged(object sender, EventArgs e)
{
SetText(txtMaxG, tbMaxG.Value);
UpdateImage();
}
private void tbMinB_ValueChanged(object sender, EventArgs e)
{
SetText(txtMinB, tbMinB.Value);
UpdateImage();
}
private void tbMaxB_ValueChanged(object sender, EventArgs e)
{
SetText(txtMaxB, tbMaxB.Value);
UpdateImage();
}
private void txtMaxG_TextChanged(object sender, EventArgs e)
{
int value = AOIFormUtil.GetIntValue(txtMaxG);
SetTbValue(tbMaxG, value);
}
private void txtMaxR_TextChanged(object sender, EventArgs e)
{
int value = AOIFormUtil.GetIntValue(txtMaxR);
SetTbValue(tbMaxR, value);
}
private void txtMinG_TextChanged(object sender, EventArgs e)
{
int value = AOIFormUtil.GetIntValue(txtMinG);
SetTbValue(tbMinG, value);
}
private void txtMaxB_TextChanged(object sender, EventArgs e)
{
int value = AOIFormUtil.GetIntValue(txtMaxB);
SetTbValue(tbMaxB, value);
}
private void txtMinR_TextChanged(object sender, EventArgs e)
{
int value = AOIFormUtil.GetIntValue(txtMinR);
SetTbValue(tbMinR, value);
}
private void txtMinB_TextChanged(object sender, EventArgs e)
{
int value = AOIFormUtil.GetIntValue(txtMinB);
SetTbValue(tbMinB, value);
}
private void SetText(FlatText text, int value)
{
if (text.Text.ToString().Equals(value.ToString()))
......
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!