阅读量:0
1.之前写了黑白IFrameQueueBuffer转halcon的HObject,下载这边文件写,彩色IFrameQueueBuffer转halcon的HObject
2.相机的部署跟黑白的一样,不同的是取图的格式改变
if (CamerTakeImageOne._camer_take_image_static._camer_is_exit) { textbox_message_of_machine.AppendText("查找到相机一" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine); //绑定相机回调函数 _currently_displayed_buffer_one = null; //创建相机的回调函数,图片格式设置为RGB24 _sink_one = new TIS.Imaging.FrameQueueSink((arg) => CamerCallbackOne(arg), TIS.Imaging.MediaSubtypes.RGB24, 5); CamerTakeImageOne._camer_take_image_static._ic_imaging_control.Sink = _sink_one; } else { textbox_message_of_machine.AppendText("没有查找到相机一" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine); }
3.把图片转成HObject
/// <summary> /// 第一个相机的回调函数 /// </summary> /// <param name="buffer"></param> /// <returns></returns> FrameQueuedResult CamerCallbackOne(IFrameQueueBuffer buffer) { DealWithImageOne._deal_with_image_one_static._exit_image = false; DealWithImageOne._deal_with_image_one_static._image.Dispose(); HOperatorSet.GenImageInterleaved(out DealWithImageOne._deal_with_image_one_static._image, (HTuple)buffer.GetIntPtr(), (HTuple)"rgb", (HTuple)buffer.FrameType.Width, (HTuple)buffer.FrameType.Height, -1, "byte", 0, 0, 0, 0, -1, 0); DealWithImageOne._deal_with_image_one_static._exit_image = true; hswinone.RefleshWindow(); _image_count_one++; return FrameQueuedResult.SkipReQueue; }