Baumer工业相机
Baumer工业相机堡盟相机是一种高性能、高质量的工业相机,可用于各种应用场景,如物体检测、计数和识别、运动分析和图像处理。
Baumer的万兆网相机拥有出色的图像处理性能,可以实时传输高分辨率图像。此外,该相机还具有快速数据传输、低功耗、易于集成以及高度可扩展性等特点。
Baumer工业相机的具有彩色工业相机和黑白工业相机两种类型,适用于多种场合,专门用于各种工业应用的成像设备,如质量控制、自动化、检查和机器视觉。它们通常被设计成在极端条件下工作,如高温、潮湿、灰尘和振动。
Baumer工业相机的彩色和黑白成像的技术背景
堡盟工业相机有彩色和黑白两种类型。这两类相机的主要区别在于它们捕捉和处理图像的方式。
彩色相机配备有拜耳滤光片,这是一种放置在相机图像传感器前的类似棋盘的彩色滤光片。这种滤镜将光线分离成红、绿、蓝三色成分,然后由相机的图像处理器进行处理,形成全彩图像。
黑白相机通常使用没有拜耳滤镜的单色图像传感器。这些传感器捕获的图像是灰度的,没有色彩信息。
就应用而言,彩色相机通常用于色彩准确性和差异性很重要的场合,如产品检验或质量控制。黑白相机通常用于需要高对比度和清晰度的情况,如机器视觉应用或低光环境中。
最终,是选择彩色还是黑白堡盟工业相机将取决于相关应用的具体需求。
Baumer工业相机通过BGAPI SDK在回调函数里显示图像
Baumer彩色工业相机和黑白工业相机的像素格式有所不同,因此在SDK回调函数里进行格式转换显示图像时也会有所不同,下面介绍在C#里Baumer彩色工业相机和黑白工业相机的不同的显示图像的方式
彩色工业相机在BufferEvent显示图像
在回调函数里显示图像,C#调用代码如下所示:
void mDataStream_NewBufferEvent(object sender, BGAPI2.Events.NewBufferEventArgs mDSEvent) { try { BGAPI2.Buffer mBufferFilled = null; mBufferFilled = mDSEvent.BufferObj; if (mBufferFilled == null) { MessageBox.Show("Error: Buffer Timeout after 1000 ms!"); } else if (mBufferFilled.IsIncomplete == true) { //MessageBox.Show("Error: Image is incomplete!"); //queue buffer again mBufferFilled.QueueBuffer(); } else { #region//获取当前FrameID FrameIDInt = (int)mBufferFilled.FrameID; OnNotifySetFrameID(FrameIDInt.ToString()); #endregion IntPtr imagebuffer = new IntPtr(); BGAPI2.Image pImage = pImgProcessor.CreateImage((uint)mBufferFilled.Width, (uint)mBufferFilled.Height, mBufferFilled.PixelFormat, mBufferFilled.MemPtr, mBufferFilled.MemSize); BGAPI2.Image pTranImage = null; pTranImage = pImgProcessor.CreateTransformedImage(pImage, "BGR8"); int w = 0; int h = 0; w = (int)pTranImage.Width; h = (int)pTranImage.Height; imagebuffer = pTranImage.Buffer; if (bFirstFrame) { pImgBits = new Byte[w * h * 3]; pBitmap = new System.Drawing.Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format24bppRgb); prcSource.X = 0; prcSource.Y = 0; prcSource.Width = w; prcSource.Height = h; bFirstFrame = false; } System.Drawing.Imaging.BitmapData bmpdata; bmpdata = pBitmap.LockBits(prcSource, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb); System.Runtime.InteropServices.Marshal.Copy(imagebuffer, pImgBits, 0, w * h * 3); System.Runtime.InteropServices.Marshal.Copy(pImgBits, 0, bmpdata.Scan0, w * h * 3); pBitmap.UnlockBits(bmpdata); //清除多余内存 GC.Collect(); #region//将pBitmap图像数据显示在UI界面PictureBox控件上 prcSource.X = 0;prcSource.Y = 0; prcSource.Width = (int)mBufferFilled.Width;prcSource.Height = (int)mBufferFilled.Height; System.Drawing.Graphics graph = System.Drawing.Graphics.FromHwnd(pictureBoxA.Handle); graph.DrawImage(pBitmap, prcPBox, prcSource, GraphicsUnit.Pixel); #endregion //clonebitmap.Dispose(); //清除临时变量clonebitmap所占内存空间 mBufferFilled.QueueBuffer(); } } catch (BGAPI2.Exceptions.IException ex) { { string str2; str2 = string.Format("ExceptionType:{0}! ErrorDescription:{1} in function:{2}", ex.GetType(), ex.GetErrorDescription(), ex.GetFunctionName()); MessageBox.Show(str2); } } return; }
黑白工业相机在BufferEvent显示图像
在回调函数里显示图像,C#调用代码如下所示:
void mDataStream_NewBufferEvent(object sender, BGAPI2.Events.NewBufferEventArgs mDSEvent) { try { BGAPI2.Buffer mBufferFilled = null; mBufferFilled = mDSEvent.BufferObj; if (mBufferFilled == null) { MessageBox.Show("Error: Buffer Timeout after 1000 ms!"); } else if (mBufferFilled.IsIncomplete == true) { //MessageBox.Show("Error: Image is incomplete!"); //queue buffer again mBufferFilled.QueueBuffer(); } else { #region//获取当前FrameID FrameIDInt = (int)mBufferFilled.FrameID; OnNotifySetFrameID(FrameIDInt.ToString()); #endregion //将相机内部图像内存数据转为bitmap数据 System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap((int)mBufferFilled.Width, (int)mBufferFilled.Height, (int)mBufferFilled.Width, System.Drawing.Imaging.PixelFormat.Format8bppIndexed, (IntPtr)((ulong)mBufferFilled.MemPtr + mBufferFilled.ImageOffset)); #region//Mono图像数据转换。彩色图像数据转换于此不同 System.Drawing.Imaging.ColorPalette palette = bitmap.Palette; int nColors = 256; for (int ix = 0; ix < nColors; ix++) { uint Alpha = 0xFF; uint Intensity = (uint)(ix * 0xFF / (nColors - 1)); palette.Entries[ix] = System.Drawing.Color.FromArgb((int)Alpha, (int)Intensity, (int)Intensity, (int)Intensity); } bitmap.Palette = palette; #endregion //回调函数保存图像功能 if (bSaveImg) { //使用bitmap自带函数保存 string strtime = DateTime.Now.ToString("yyyyMMddhhmmssfff"); string saveimagepath = pImgFileDir + "\\" + strtime + ".jpg"; bitmap.Save(saveimagepath, System.Drawing.Imaging.ImageFormat.Bmp); bSaveImg = false;//变量控制单次保存图像 } #region//bitmap的图像数据复制pBitmap Bitmap clonebitmap = (Bitmap)bitmap.Clone(); BitmapData data = clonebitmap.LockBits(new Rectangle(0, 0, clonebitmap.Width, clonebitmap.Height), ImageLockMode.ReadOnly, clonebitmap.PixelFormat); clonebitmap.UnlockBits(data); pBitmap = clonebitmap; #endregion #region//将pBitmap图像数据显示在UI界面PictureBox控件上 prcSource.X = 0;prcSource.Y = 0; prcSource.Width = (int)mBufferFilled.Width;prcSource.Height = (int)mBufferFilled.Height; System.Drawing.Graphics graph = System.Drawing.Graphics.FromHwnd(pictureBoxA.Handle); graph.DrawImage(pBitmap, prcPBox, prcSource, GraphicsUnit.Pixel); #endregion clonebitmap.Dispose(); //清除临时变量clonebitmap所占内存空间 mBufferFilled.QueueBuffer(); } } catch (BGAPI2.Exceptions.IException ex) { { string str2; str2 = string.Format("ExceptionType:{0}! ErrorDescription:{1} in function:{2}", ex.GetType(), ex.GetErrorDescription(), ex.GetFunctionName()); MessageBox.Show(str2); } } return; }
Baumer工业相机的的彩色相机和黑白相机分别的优势
堡盟彩色工业相机的优势:
由于使用了先进的彩色滤光片,色彩再现的精度更高。
能够提供更多的图像细节,更好地区分复杂场景中的物体。
更具视觉吸引力的图像,对检查和质量控制等任务很有用。
可用于机器视觉和交通监控等应用。
堡盟的黑白工业相机的优势:
由于没有彩色滤光片,提供更高的分辨率和更清晰的图像。
对光有更高的敏感性,使其成为低光照条件下的理想应用。
可以捕获更快的帧率,使其成为高速应用的理想选择,如生产线监控。
与彩色摄像机相比,成本降低,使它们成为某些应用中更经济的选择。
Baumer彩色工业相机和黑白工业相机在图像处理上的不同点
彩色工业相机和黑白(单色)工业相机在其图像处理能力上有所不同。
彩色工业相机被设计用来捕捉全彩图像,这意味着它们必须处理和分析来自多个颜色通道(通常是红色、绿色和蓝色)的数据。这需要更多的计算能力和专门的算法来从原始图像数据中提取准确的颜色信息。
黑白工业相机只捕获灰度图像,这意味着它们不需要处理多个颜色通道。这简化了图像处理任务,从而使帧率更快,分辨率更高,噪音更低。
这两种的区别也在导致上面再回调函数里进行显示图像时也有所不同的原因。
就应用而言,彩色工业相机是需要准确识别颜色的任务的理想选择,如质量控制、颜色分类和印刷材料的检查。黑白工业相机更适合于需要高灵敏度的任务,如低光成像或运动检测。