/// <summary> /// 显示图像 /// </summary> private void DisplayImage(HWindowControl hCtrl, IHalImage image) { if (hCtrl.InvokeRequired) { DisplayImageCallBack a = new DisplayImageCallBack(DisplayImage); hCtrl.Invoke(a, hCtrl, image); return; } else { if (System.Environment.TickCount - ticketNum > 33) { ticketNum = System.Environment.TickCount; try { HSystem.SetSystem("flush_graphic", "false"); //hCtrl.HalconWindow.ClearWindow(); //if (image.Width != hCtrl.ImagePart.Width) // SetImagePart(hCtrl,0, 0, image.Height, image.Width); hCtrl.HalconWindow.DispObj(image.SourceImage); HSystem.SetSystem("flush_graphic", "true"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } }
/// <summary> /// 运行取像 /// </summary> public void Run() { if (isRealDisplay) { return; } int ticketCount = System.Environment.TickCount; HObject ho_OutputImage; HOperatorSet.GenEmptyObj(out ho_OutputImage); if (asyncGrab) { ho_OutputImage = SafeAsyncGrabImage(); } else { ho_OutputImage = SafeSyncGrabImage(); } int triggerNumber = System.Environment.TickCount; m_outputImage = new HalImage8Grey(ref ho_OutputImage); HalCompleteEventArgs eventArgs = new HalCompleteEventArgs(ticketCount, triggerNumber, m_outputImage); if (Complete != null) { Complete(this, eventArgs); } }
/// <summary> /// 反序列化构造 /// </summary> /// <param name="info"></param> /// <param name="context"></param> private HalAcqFifoTool(SerializationInfo info, StreamingContext context) { //反序列化对象 _operator = (IHalAcqOperator)info.GetValue("operator", typeof(IHalAcqOperator)); cameraOpenInfo = (IHalAcqOpenInfo)info.GetValue("cameraOpenInfo", typeof(IHalAcqOpenInfo)); asyncGrab = info.GetBoolean("asyncGrabImage"); m_outputImage = (IHalImage)info.GetValue("outputImage", typeof(IHalImage)); acqState = new HalAcqState(); //判断被序列化的相机是否在相机列表中,如果在尝试打开相机 if (SystemExistCamera(cameraOpenInfo.Device.S)) { //打开相机 if (OpenCamera(ref cameraOpenInfo)) { //对Operator传入新的相机句柄 _operator.CameraHandle = __halAcqHandle; halGigEAccess = new CHalGigEAccess(ref __halAcqHandle); } } }
public HalCompleteEventArgs(int ticket, int triggerNumber, IHalImage image) { _image = image; _ticket = ticket; _triggerNumber = triggerNumber; }