构造函数:
- public CameraFLIRRGB(string CameraSerial_str, string PC_IP1, string Camera_IP1)
- {
- CameraSerial = CameraSerial_str; //序列号
- PC_IP = PC_IP1; //电脑IP
- Camera_IP = Camera_IP1; //相机IP
- BindEvent(); //注册事件
- }
复制代码
注册事件:
- public delegate void GrabImageDelegate(IntPtr pData, uint ImageWidth, uint ImageHeight);
- event GrabImageDelegate GrabImageEvent;
- public void BindEvent()
- {
- RemoveEvent();
- try
- {
- GrabImageEvent += new GrabImageDelegate(get_Image);
- }
- catch (Exception ex)
- {
- LogName.ErrorLog.Fatal(ex);
- }
- }
- //拿图放进队列
- private void get_Image(IntPtr pData, uint ImageWidth, uint ImageHeight)
- {
- try
- {
- image.Dispose();
- HOperatorSet.GenImageInterleaved(out image, pData, "rgb", ImageWidth, ImageHeight, -1, "byte", ImageWidth, ImageHeight, 0, 0, -1, 0);
- //释放指针很重要!!!!!
- Marshal.FreeHGlobal(pData);
- HTuple w, h;
- HOperatorSet.GetImageSize(image, out w, out h);
- if (w != 0 && h != 0)
- {
- QueueGrabImage.Enqueue(new HObject(image));
- if (FrameCount >= ulong.MaxValue)
- FrameCount = 0;
- FrameCount++;
- bo_jisuan = true; //当图像确定采集到了,标志位置为true
- Grab_Image = true;
- LogName.CameraLog.Fatal(CameraSerial + " 采集到图像,图像进队,当前队列个数:" + QueueGrabImage.Count.ToString()); //新增记录
- }
- }
- catch (Exception ex)
- {
- LogName.ErrorLog.Fatal(ex);
- }
- }
复制代码 |