| | |
| | | using HalconDotNet; |
| | | using MvCameraControl; |
| | | using LB_SmartVisionCommon; |
| | | using LB_VisionProcesses; |
| | | using LB_VisionProcesses.Cameras; |
| | | using MvCameraControl; |
| | | using System; |
| | | using System.Collections.Concurrent; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics; |
| | | using System.Drawing; |
| | |
| | | protected Bitmap CallBackImg { get; set; } |
| | | public Bitmap Bitmap; |
| | | |
| | | private Dictionary<string, List<Bitmap>> _collectedImages; |
| | | public Dictionary<string, List<Bitmap>> CollectedImages |
| | | { |
| | | get => _collectedImages; |
| | | set |
| | | { |
| | | _collectedImages = value; |
| | | } |
| | | } |
| | | //private ConcurrentDictionary<string, ConcurrentQueue<Bitmap>> _collectedImages; |
| | | public ConcurrentDictionary<string, ConcurrentQueue<Bitmap>> CollectedImages = new ConcurrentDictionary<string, ConcurrentQueue<Bitmap>>(); |
| | | //{ |
| | | // get => _collectedImages; |
| | | // set |
| | | // { |
| | | // _collectedImages = value; |
| | | // } |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 队列上限,防止内存爆炸 |
| | | /// </summary> |
| | | public int MAX_QUEUE_CAPACITY = 30; |
| | | |
| | | #endregion |
| | | |
| | | #region operate |
| | | |
| | | /// <summary> |
| | | /// 相机销毁时:清空所有缓存,释放全部内存 |
| | | /// </summary> |
| | | public virtual void ClearAllImages() |
| | | { |
| | | if (CollectedImages.TryRemove(SN, out var queue)) |
| | | { |
| | | while (queue.TryDequeue(out Bitmap bmp)) |
| | | { |
| | | bmp.Dispose(); |
| | | } |
| | | } |
| | | AsyncLogHelper.Info($"LBCamera[{SN}]: 已清空所有图像缓存"); |
| | | } |
| | | public virtual void Dispose() |
| | | { |
| | | try |
| | | { |
| | | ClearAllImages(); |
| | | CloseDevice(); |
| | | } |
| | | catch { } |