|
|
|
|
using HalconDotNet;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Rs.Framework
|
|
|
|
|
{
|
|
|
|
|
public static class ImageProcess
|
|
|
|
|
{
|
|
|
|
|
//static UInt64 imageNum = 0;
|
|
|
|
|
public static ManualResetEvent manualTriggerEvent = new ManualResetEvent(false);
|
|
|
|
|
public static ManualResetEvent autoTriggerEvent = new ManualResetEvent(false);
|
|
|
|
|
|
|
|
|
|
static List<HObject> manualTriggerList=new List<HObject>();
|
|
|
|
|
static List<HObject> autoTriggerList = new List<HObject>();
|
|
|
|
|
|
|
|
|
|
public static void AddManualTrigger(HObject obj)
|
|
|
|
|
{
|
|
|
|
|
//imageNum++;
|
|
|
|
|
//if (imageNum>20)
|
|
|
|
|
//{
|
|
|
|
|
// GC.Collect();
|
|
|
|
|
// imageNum = 0;
|
|
|
|
|
//}
|
|
|
|
|
manualTriggerList.Add(obj);
|
|
|
|
|
manualTriggerEvent.Set();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ClearManualTrigger()
|
|
|
|
|
{
|
|
|
|
|
manualTriggerList.Clear();
|
|
|
|
|
manualTriggerEvent.Reset();
|
|
|
|
|
GC.Collect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static HObject GetManualImage()
|
|
|
|
|
{
|
|
|
|
|
if(manualTriggerList.Count>0)
|
|
|
|
|
{
|
|
|
|
|
return manualTriggerList[0];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static HObject[] GetAutoImage()
|
|
|
|
|
{
|
|
|
|
|
return autoTriggerList.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void AddAutoTrigger(HObject obj)
|
|
|
|
|
{
|
|
|
|
|
//imageNum++;
|
|
|
|
|
//if (imageNum > 20)
|
|
|
|
|
//{
|
|
|
|
|
// LogHelper.Debug($"imagenum={imageNum},释放内存");
|
|
|
|
|
// GC.Collect();
|
|
|
|
|
// imageNum = 0;
|
|
|
|
|
//}
|
|
|
|
|
autoTriggerList.Add(obj);
|
|
|
|
|
autoTriggerEvent.Set();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ClearAutoTrigger()
|
|
|
|
|
{
|
|
|
|
|
autoTriggerList.Clear();
|
|
|
|
|
autoTriggerEvent.Reset();
|
|
|
|
|
GC.Collect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|