Commit 856532b0 刘韬

添加多盘算法点料接口

1 个父辈 8fc867c8
using Asa.HaoboSDK; using Asa.HaoboSDK;
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
...@@ -27,6 +29,24 @@ namespace Asa ...@@ -27,6 +29,24 @@ namespace Asa
Directory.CreateDirectory("CountTemplate"); Directory.CreateDirectory("CountTemplate");
var flag = eyemInitModel("CountTemplate", out hModelIDs); var flag = eyemInitModel("CountTemplate", out hModelIDs);
AlgoIndex.Add("NONE", -1);
for (int i = 0; i < sOptions.Length; i++)
{
AlgoIndex.Add(sOptions[i], i);
}
}
/// <summary>
/// 算法名称对索引应序号
/// </summary>
public static Dictionary<string, int> AlgoIndex = new Dictionary<string, int>();
static string[] sOptions = { "IP_DEFAULT_PARTS", "IP_SMALL_PARTS", "IP_LARGE_PARTS", "IP_LONG_PARTS", "IP_SQUARE_PARTS", "", "IP_DYNAMIC_SP1", "IP_DYNAMIC_SP2" };
/// <summary>
/// 返回算法索引序列
/// </summary>
public static int[] GetAlgoIndex(string[] types) {
var xx = from type in types select AlgoIndex[type];
return xx.ToArray();
} }
/// <summary> /// <summary>
/// 16位窗位 /// 16位窗位
...@@ -237,6 +257,52 @@ namespace Asa ...@@ -237,6 +257,52 @@ namespace Asa
eyemImageFree(ref tpDstImg); eyemImageFree(ref tpDstImg);
return n; return n;
} }
/// <summary>
/// 4盘算法点料
/// </summary>
[HandleProcessCorruptedStateExceptions]
public static int GetCountObjectIrregularPartsMultiopt(string path, int ShrinkOffset, string[] type, out int[] count, out Bitmap BmpDstImg)
{
count = null;
BmpDstImg = null;
//string fileName = Path.GetFileNameWithoutExtension(path);
int flag = eyemImageRead(path, -1, out EyemImage eyem);
if (flag != 0) return -1;
int n = GetCountObjectIrregularPartsMultiopt(eyem, ShrinkOffset, type, out count, out BmpDstImg);
eyemImageFree(ref eyem);
return n;
}
/// <summary>
/// 4盘算法点料
/// </summary>
[HandleProcessCorruptedStateExceptions]
public static int GetCountObjectIrregularPartsMultiopt(EyemImage eyem, int ShrinkOffset, string[] type, out int[] count, out Bitmap BmpDstImg)
{
BmpDstImg = null;
EyemRect tpRoi = new EyemRect
{
iXs = 0 + ShrinkOffset,
iYs = 0 + ShrinkOffset,
iWidth = eyem.iWidth - ShrinkOffset * 2,
iHeight = eyem.iHeight - ShrinkOffset * 2
};
setSkipProcessID(-1);
int[] ipReelNum = new int[4];
int n = eyemCountObjectIrregularPartsMultiopt(eyem, tpRoi, GetAlgoIndex(type), ipReelNum, out EyemImage tpDstImg);
count = ipReelNum;
if (n == 0)
BmpDstImg = eyemCvtToBitmap(tpDstImg);
eyemImageFree(ref tpDstImg);
return n;
}
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
public static int GetLocalCountTemplate(string path, int ShrinkOffset, string template, out int[] count, out Bitmap BmpDstImg) public static int GetLocalCountTemplate(string path, int ShrinkOffset, string template, out int[] count, out Bitmap BmpDstImg)
......
...@@ -42,6 +42,9 @@ namespace Asa ...@@ -42,6 +42,9 @@ namespace Asa
public static extern int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, string fileName, string ccTplName, IntPtr hModelID, [MarshalAs(UnmanagedType.LPArray)] int[] ipReelNum, out EyemImage tpDstImg); public static extern int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, string fileName, string ccTplName, IntPtr hModelID, [MarshalAs(UnmanagedType.LPArray)] int[] ipReelNum, out EyemImage tpDstImg);
//多选项异形件
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
public static extern int eyemCountObjectIrregularPartsMultiopt(EyemImage tpImage, EyemRect tpRoi, int[] iOptions, [MarshalAs(UnmanagedType.LPArray)] int[] ipReelNum, out EyemImage tpDstImg);
//[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)] //[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
//internal static extern int eyemCountObject(EyemImage tpSrcImg, EyemRect tpRoi, string fileName, double dOffset, int iMinArea, int iMaxArea, int iWinSize, ref string pNumObj, out EyemImage tpDstImg); //internal static extern int eyemCountObject(EyemImage tpSrcImg, EyemRect tpRoi, string fileName, double dOffset, int iMinArea, int iMaxArea, int iWinSize, ref string pNumObj, out EyemImage tpDstImg);
...@@ -84,7 +87,11 @@ namespace Asa ...@@ -84,7 +87,11 @@ namespace Asa
//通过名称移除模板 //通过名称移除模板
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)] [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
internal static extern int eyemRemoveModelByName( IntPtr hModelID, string ccTplName); internal static extern int eyemRemoveModelByName( IntPtr hModelID, string ccTplName);
//跳过程序执行 /// <summary>
/// 结束之前的算法计算
/// </summary>
/// <param name="pid">-1复位, 0结束</param>
/// <returns></returns>
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)] [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
internal static extern int setSkipProcessID(int pid); internal static extern int setSkipProcessID(int pid);
// 设定日志回调 // 设定日志回调
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!