映美精黑白相机IFrameQueueBuffer转halcon的HObject

07-16 1561阅读

映美精黑白相机,用wpf+halcon开发取图

1.到官网下载,开发包

映美精黑白相机IFrameQueueBuffer转halcon的HObject

1sdk 2c++开发例子 3c#开发例子

  1. 引入TIS.Imaging.ICImagingControl35.dll

3.ICImagingControl使用这个类控制相机

/// 
/// 相机控制
/// 
public ICImagingControl _ic_imaging_control = new ICImagingControl();
 //设置不把图片显示在控件
_ic_imaging_control.LiveDisplay = false;
//禁止覆盖位图
_ic_imaging_control.OverlayBitmapPosition = PathPositions.None;
if (_ic_imaging_control.Devices.Length > 0)
   {
        int device_count_ = _ic_imaging_control.Devices.Length;
        for (int i = 0; i  

4.采用回调方式取图

CamerTakeImage.CamerTakeImage._camer_take_image_static.Init();
if (CamerTakeImage.CamerTakeImage._camer_take_image_static._camer_name != "")
{
    _currently_displayed_buffer = null;
    //创建相机的回调函数
    _sink = new TIS.Imaging.FrameQueueSink((arg) => CamerCallback(arg), TIS.Imaging.MediaSubtypes.Y800, 5);
    CamerTakeImage.CamerTakeImage._camer_take_image_static._ic_imaging_control.Sink = _sink;                             
}

5.把图片转成HObject

    /// 
    /// 相机的回调函数
    /// 
    /// 
    /// 
    FrameQueuedResult CamerCallback(IFrameQueueBuffer buffer)
    {
        DealWithImage.DealWithImage._deal_with_image_static._exit_image = false;
        DealWithImage.DealWithImage._deal_with_image_static._image.Dispose();
        HOperatorSet.GenImage1(out DealWithImage.DealWithImage._deal_with_image_static._image,
            "byte",
            buffer.FrameType.Width,
            buffer.FrameType.Height,
            buffer.GetIntPtr());
        DealWithImage.DealWithImage._deal_with_image_static._exit_image = true;
        hswin_image.RefreshWindow();
       
       //这句话一定要有,不然取图只有五张
        if (_currently_displayed_buffer != null)
        {
            _sink.QueueBuffer(_currently_displayed_buffer);
        }
        _currently_displayed_buffer = buffer;
        return FrameQueuedResult.SkipReQueue;
    }
VPS购买请点击我

文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

目录[+]