将C#的bitmap格式转换为Halcon的图像格式

       /// <summary>
        /// Bitmap转HObject灰度图
        /// </summary>
        /// <param name="bmp">Bitmap图像</param>
        /// <param name="image">HObject图像</param>
        public static void Bitmap2HObjectBpp8(Bitmap bmp, out HObject image)
        {
            try
            {
                Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
 
                BitmapData srcBmpData = bmp.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
 
                HOperatorSet.GenImage1(out image, "byte", bmp.Width, bmp.Height, srcBmpData.Scan0);
                bmp.UnlockBits(srcBmpData);
            }
            catch (Exception)
            {
                image = null;
            }
        }

 

上一篇:超越halcon速度的二值图像的腐蚀和膨胀,实现目前最快的半径相关类算法(附核心源码)


下一篇:Halcon与QT的联合编程