当前位置: 首页 > news >正文

幼儿园网站建设结论分析12月30日疫情最新消息

幼儿园网站建设结论分析,12月30日疫情最新消息,学做网站需要,商品关键词优化的方法Baumer工业相机堡盟工业相机如何通过BGAPI SDK直接实现Mono16位深度的图像保存(C#) Baumer工业相机Baumer工业相机保存位深度12/16位图像的技术背景代码案例分享1:引用合适的类文件2:通过BGAPI SDK直接保存Mono12/16图像3&#xf…

Baumer工业相机堡盟工业相机如何通过BGAPI SDK直接实现Mono16位深度的图像保存(C#)

  • Baumer工业相机
  • Baumer工业相机保存位深度12/16位图像的技术背景
  • 代码案例分享
    • 1:引用合适的类文件
    • 2:通过BGAPI SDK直接保存Mono12/16图像
    • 3:使用BGAPI SDK的图像直接转换Mono12/16图像并保存的功能
  • 工业相机使用位深度12/16位图像的优点
  • 工业相机使用位深度12/16位图像的行业应用

Baumer工业相机

Baumer工业相机堡盟相机是一种高性能、高质量的工业相机,可用于各种应用场景,如物体检测、计数和识别、运动分析和图像处理。

Baumer的万兆网相机拥有出色的图像处理性能,可以实时传输高分辨率图像。此外,该相机还具有快速数据传输、低功耗、易于集成以及高度可扩展性等特点。

Baumer工业相机通过使用BGAPI SDK进行开发时,在C++环境可以直接实现位深度为16的图像保存。

Baumer工业相机保存位深度12/16位图像的技术背景

工业相机通常用于需要高质量图像的分析和检查的专业环境中。这些相机被设计用来捕捉16比特的高比特深度的图像,与低比特深度的图像相比,可以捕捉到更大范围的色彩和细节。

保存位深16位图像的工业相机的技术背景涉及几个关键部分。首先,相机的图像传感器必须能够捕捉到高比特深度的图像。这是通过使用高质量的图像传感器来实现的,该传感器能够以每像素16比特的分辨率捕获数据。

其次,相机的电子设备必须能够处理和存储高比特深度的图像数据。这意味着相机需要有一个高速处理器和足够的内存来处理所产生的大量图像数据。

第三,相机的软件必须能够支持16位图像的保存。这意味着相机的固件和软件接口必须被设计成能够处理16位图像所产生的更大的文件尺寸,并且还能与工业标准文件格式如TIFF和RAW兼容。

总的来说,保存16位深度图像的工业相机的技术背景涉及高质量的图像传感器、强大的电子器件和专门的软件的组合,这些都是为了处理捕捉和存储高位深度图像的独特需求。

这里主要描述如何在C#的平台下通过BGAPI SDK直接实现Mono16图像格式的保存功能的核心代码

代码案例分享

本文介绍使用BGAPI SDK对Baumer的工业相机进行开发时,直接实现Mono12或者Mono16图像格式的保存功能

如下为核心代码实现步骤:

1:引用合适的类文件

C#环境下核心代码如下所示:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
using CSCameraDemo.Properties;
using System.Globalization;
using WindowsFormsApplication1;
using System.Threading.Tasks;
using System.Threading;
using System.Drawing.Imaging;using BGAPI2;

2:通过BGAPI SDK直接保存Mono12/16图像

下面为在在C#环境开启相机连接相机后通过转换图像格式实现Mono12或者Mono16图像格式保存的核心代码。

如下所示:

SystemList 
Open a System 
Get the InterfaceList and fill it Open an Interface 
Get the DeviceList and fill it 
Open a Devicevoid 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 againmBufferFilled.QueueBuffer();}else{#region//获取当前FrameIDFrameIDInt = (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;#endregionlong currenttime = (long)mBufferFilled.Timestamp;                   DateTime sdasd = GetTime(currenttime, true);#region//回调函数保存图像功能if (bSaveImg){//使用bitmap自带函数保存string strtime = DateTime.Now.ToString("yyyyMMddhhmmssfff");string saveimagepath = pImgFileDir  +"\\"+ strtime + ".jpg";// bitmap.Save(saveimagepath, System.Drawing.Imaging.ImageFormat.Bmp);//使用opencv进行保存图像if (mBufferFilled.PixelFormat == "Mono8"){OpenCvSharp.Mat matgray = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);//用bitmap转换为mat                           matgray.SaveImage("opencv_image.png");Cv2.ImWrite("opencvcv_image_Clone.png", matgray);Cv2.ImWrite(saveimagepath, matgray);}                      //将相机中原始图像数据通过BGAPI SDK直接保存为16位深度的图像if (mBufferFilled.PixelFormat.Contains("Mono12")){short[] mImageBuffer16Copy = new short[(uint)((uint)mBufferFilled.Width * (uint)mBufferFilled.Height * 1)];Marshal.Copy((IntPtr)mBufferFilled.MemPtr, mImageBuffer16Copy, 0, (int)((int)mBufferFilled.Width * (int)mBufferFilled.Height * 1));//convert Mono12 to Mono16uint length = (uint)((uint)mBufferFilled.Width * (uint)mBufferFilled.Height) * 1;for (uint l = 0; l < length; l++){mImageBuffer16Copy[l] = (short)(mImageBuffer16Copy[l] << 4);}saveimagepath = pImgFileDir + "\\" + strtime + "-Mono16.png";saveMono16Tiff(saveimagepath , mImageBuffer16Copy, (int)mBufferFilled.Width, (int)mBufferFilled.Height * 1);}bSaveImg = false;//变量控制单次保存图像}#endregion#region//bitmap的图像数据复制pBitmapBitmap 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);#endregionclonebitmap.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;
}

3:使用BGAPI SDK的图像直接转换Mono12/16图像并保存的功能

下面为在在C#环境开启相机连接相机后通过BGAPI SDK直接实现Mono12或者Mono16图像格式保存的核心代码。

如下所示:

public static void saveMono16Tiff(string fileName, short[] shortarray, int imagewidth, int imageheight)
{FileStream FileST = new FileStream(fileName, FileMode.Create);// Create the writer for data.BinaryWriter binWriter = new BinaryWriter(FileST);// Write data to Test.data.ushort data16 = 0;uint data32 = 0;uint sizeX = (uint)imagewidth;uint sizeY = (uint)imageheight;int imagelength2 = imagewidth * imageheight;// TIFF identifier and count of directory entries//================================================data16 = 0x4949;	// identifier "II" for little-endian byte orderbinWriter.Write(data16);data16 = 42;		// tiff identifier 42binWriter.Write(data16);data32 = 8;			// offset for the first IFDbinWriter.Write(data32);data16 = 12;		// number of directory entriesbinWriter.Write(data16);// 1. entry: ImageWidth (number of columns)//==========================================data16 = 0x100;		// tag:   100.HbinWriter.Write(data16);data16 = 4;			// type:  LONGbinWriter.Write(data16);data32 = 1;			// count: 1binWriter.Write(data32);data32 = sizeX;		// value: horizontal image sizebinWriter.Write(data32);// 2. entry: ImageLength (number of rows)//=======================================data16 = 0x101;		// tag:   101.H binWriter.Write(data16);data16 = 4;			// type:  LONGbinWriter.Write(data16);data32 = 1;			// count: 1binWriter.Write(data32);data32 = sizeY;		// value: horizontal image sizebinWriter.Write(data32);// 3. entry: BitsPerSample//=========================data16 = 0x102;		// tag:   102.H binWriter.Write(data16);data16 = 3;			// type:  SHORTbinWriter.Write(data16);data32 = 1;			// count: 1 == SamplesPerPixel Mono16binWriter.Write(data32);data32 = 16;		 // SamplesPerPixel == 1 => value: 16    (16 bps => NOT BASELINE!)binWriter.Write(data32);// 4. entry: Compression//=======================data16 = 0x103;		// tag:   103.H binWriter.Write(data16);data16 = 3;			// type:  SHORTbinWriter.Write(data16);data32 = 1;			// count: 1 binWriter.Write(data32);data32 = 1;			// value: 1 (no compression)binWriter.Write(data32);// 5. entry: PhotometricInterpretation//======================================data16 = 0x106;		// tag:   106.H binWriter.Write(data16);data16 = 3;			// type:  SHORTbinWriter.Write(data16);data32 = 1;			// count: 1 binWriter.Write(data32);data32 = 1;			// SamplesPerPixel == 1 => value: 1 (BlackIsZero)binWriter.Write(data32);// 6. entry: StripOffsets//========================data16 = 0x111;		// tag:   111.H binWriter.Write(data16);data16 = 4;			// type:  LONGbinWriter.Write(data16);data32 = 1;			// count: 1 == StripsPerImagebinWriter.Write(data32);data32 = 174;		// value = 8 + 2 + 12*12 + 4 + 8 + 8 = 174binWriter.Write(data32);// 7. entry: SamplesPerPixel//===========================data16 = 0x115;		// tag:   115.H binWriter.Write(data16);data16 = 3;			// type:  SHORTbinWriter.Write(data16);data32 = 1;			// count: 1 binWriter.Write(data32); ;data32 = 1;			// SamplesPerPixel == 1 Mono16binWriter.Write(data32);// 8. entry: RowsPerStrip//========================data16 = 0x116;		// tag:   116.H binWriter.Write(data16);data16 = 4;			// type:  LONGbinWriter.Write(data16);data32 = 1;			// count: 1binWriter.Write(data32);data32 = sizeY;		// value: vertical image size (one strip only)binWriter.Write(data32);// 9. entry: StripByteCounts (For each strip, the number of bytes in the strip after compression.)//================================================================================================data16 = 0x117;		// tag:   117.H binWriter.Write(data16);data16 = 4;			// type:  LONGbinWriter.Write(data16);data32 = 1;			// count: 1 == StripsPerImagebinWriter.Write(data32);data32 = 2 * 1 * sizeX * sizeY;		// value = 2* 1 * SizeX * SizeYbinWriter.Write(data32);// 10. entry: XResolution (The number of pixels per ResolutionUnit in the ImageWidth direction.)//================================================================================================data16 = 0x11A;		// tag:   11A.H binWriter.Write(data16);data16 = 5;			// type:  RATIONALbinWriter.Write(data16);data32 = 1;			// count: 1 binWriter.Write(data32);data32 = 158;		// offset to value = 8 + (2 + 12*12 + 4) = 158binWriter.Write(data32);// 11. entry: YResolution (The number of pixels per ResolutionUnit in the ImageLength direction.)//================================================================================================data16 = 0x11B;		// tag:   11B.H binWriter.Write(data16);data16 = 5;			// type:  RATIONALbinWriter.Write(data16);data32 = 1;			// count: 1 binWriter.Write(data32);data32 = 166;		// offset to value = 8 + (2 + 12*12 + 4) + 8 = 166binWriter.Write(data32);// 12. entry: ResolutionUnit (The unit of measurement for XResolution and YResolution.)//=====================================================================================data16 = 0x128;		// tag:   128.H binWriter.Write(data16);data16 = 3;			// type:  SHORTbinWriter.Write(data16);data32 = 1;			// count: 1 binWriter.Write(data32);data32 = 2;			// value: 2 (Inch) => dpibinWriter.Write(data32);data32 = 0;			// offset of next IFD: nonebinWriter.Write(data32);//  write IFD values longer than 4 byte//======================================data32 = 72;		// XResolution numerator: 72 => 72 dpi (a common value..)binWriter.Write(data32);data32 = 1;			// XResolution denominator: 1binWriter.Write(data32);data32 = 72;		// YResolution numerator: 72 => 72 dpi (a common value..)binWriter.Write(data32);data32 = 1;			// YResolution denominator: 1binWriter.Write(data32);// end of header save to file// save image data (converted from Mono12 to Mono16) to filefor (int i = 0; i < imagelength2; i++){data16 = (ushort)shortarray[i];binWriter.Write(data16);}// close filebinWriter.Close();FileST.Close();return;}   // end of saveMono16Tiff()

工业相机使用位深度12/16位图像的优点

更好的图像细节:12/16位图像可以捕捉到更多的细节和颜色深度,提供更高的图像质量。

更广泛的动态范围:12/16位图像允许在明暗变化很大的场景中捕捉到更多的细节和颜色,以及更好的光线控制。

更低的噪声:采用12/16位图像可以减少噪声,使得图像更加清晰。

更好的后期处理:12/16位图像可以在后期处理中更灵活地进行平滑、增加对比度和其他调整。

因此,工业相机使用12/16位图像可以提供更高质量的图像,更好的细节和颜色控制,并为后期处理提供更多的灵活性。

工业相机使用位深度12/16位图像的行业应用

  1. 医疗成像:工业相机可用于各种医疗成像应用,例如X射线成像,MRI和CT扫描。这些应用需要16位图像位深度来提供高质量的成像结果。

  2. 汽车制造:工业相机可以用于汽车制造中的各种应用,例如质量控制和检查。这些应用需要高分辨率和16位图像位深度,以检测并处理微小的缺陷或问题。

  3. 机器人视觉:工业相机的高速度和高精度对于机器人视觉应用非常重要。机器人需要能够识别和定位目标,同时能够处理16位图像位深度的高质量图像。

  4. 智能交通系统:工业相机也可以用于智能交通系统中。例如,交通监控摄像机需要高质量的图像以便能够识别和跟踪车辆,行人和其他交通标志。

总之,工业相机使用16位图像位深度的行业应用范围非常广泛,它们可以用于各种不同的应用,以提供高质量的成像结果和精确的图像处理功能。


文章转载自:
http://contribution.mzpd.cn
http://moldau.mzpd.cn
http://ulceration.mzpd.cn
http://planetology.mzpd.cn
http://empathically.mzpd.cn
http://hepatocele.mzpd.cn
http://cistus.mzpd.cn
http://synod.mzpd.cn
http://percussive.mzpd.cn
http://pentoxid.mzpd.cn
http://consequence.mzpd.cn
http://jeannette.mzpd.cn
http://synoptic.mzpd.cn
http://monogamic.mzpd.cn
http://autotrophic.mzpd.cn
http://needlebook.mzpd.cn
http://syntax.mzpd.cn
http://natural.mzpd.cn
http://awash.mzpd.cn
http://lash.mzpd.cn
http://consternate.mzpd.cn
http://whiteout.mzpd.cn
http://fender.mzpd.cn
http://lampers.mzpd.cn
http://overexert.mzpd.cn
http://ensue.mzpd.cn
http://tincture.mzpd.cn
http://oarsman.mzpd.cn
http://clochard.mzpd.cn
http://isoelectronic.mzpd.cn
http://cymiferous.mzpd.cn
http://screen.mzpd.cn
http://behavioristic.mzpd.cn
http://cordillera.mzpd.cn
http://ayh.mzpd.cn
http://smithiantha.mzpd.cn
http://praam.mzpd.cn
http://polygalaceous.mzpd.cn
http://wednesday.mzpd.cn
http://lichenification.mzpd.cn
http://maffei.mzpd.cn
http://glooming.mzpd.cn
http://hankerchief.mzpd.cn
http://aposiopesis.mzpd.cn
http://noninductivity.mzpd.cn
http://westphalia.mzpd.cn
http://kogai.mzpd.cn
http://shamos.mzpd.cn
http://tetrode.mzpd.cn
http://palau.mzpd.cn
http://jeanne.mzpd.cn
http://estuarial.mzpd.cn
http://start.mzpd.cn
http://offshore.mzpd.cn
http://ruth.mzpd.cn
http://doglegged.mzpd.cn
http://decemvir.mzpd.cn
http://glabrous.mzpd.cn
http://event.mzpd.cn
http://curtsey.mzpd.cn
http://hlf.mzpd.cn
http://fruited.mzpd.cn
http://retia.mzpd.cn
http://crowdie.mzpd.cn
http://squiz.mzpd.cn
http://overcooked.mzpd.cn
http://broadsheet.mzpd.cn
http://recumbent.mzpd.cn
http://tokology.mzpd.cn
http://mongol.mzpd.cn
http://pipet.mzpd.cn
http://percale.mzpd.cn
http://binomial.mzpd.cn
http://broma.mzpd.cn
http://desired.mzpd.cn
http://crystallizability.mzpd.cn
http://clef.mzpd.cn
http://insured.mzpd.cn
http://couchy.mzpd.cn
http://choochoo.mzpd.cn
http://haemacytometer.mzpd.cn
http://humanics.mzpd.cn
http://isa.mzpd.cn
http://eurystomatous.mzpd.cn
http://madia.mzpd.cn
http://buildable.mzpd.cn
http://sidecar.mzpd.cn
http://canvasser.mzpd.cn
http://bureaucratese.mzpd.cn
http://ortanique.mzpd.cn
http://girsh.mzpd.cn
http://subdeaconry.mzpd.cn
http://vibracula.mzpd.cn
http://imaginable.mzpd.cn
http://copiously.mzpd.cn
http://seafolk.mzpd.cn
http://expel.mzpd.cn
http://holophrasis.mzpd.cn
http://gms.mzpd.cn
http://antepartum.mzpd.cn
http://www.15wanjia.com/news/93944.html

相关文章:

  • 做美瞳网站需要什么资质营销型网站制作建设
  • 做网站策划师的图片百度账号注册
  • wordpress 添加微博话题墙郑州seo排名优化公司
  • 做暧暖网站站长工具综合查询官网
  • 官方网站开发公司做一个网站要花多少钱
  • 电子商务概论亿唐网不做网站做品牌品牌设计
  • 网站seo关键字优化搜索百度
  • 联盟营销是一种什么的网络营销方式湖南seo排名
  • 在网站制作完成后网站建设谷歌seo服务
  • 中山网站制seo搜索引擎优化是
  • 建网赚网站企点客服
  • 网站怎么做盈利活动推广方案
  • 网站设计个人搜索引擎的两个基本方法
  • app开发网站建设怎么做电商生意
  • 关于排版的网站网站快速优化排名官网
  • 做请帖网站电商具体是做什么的
  • asp网站导航怎么做今日的新闻头条10条
  • 西安网站空间品牌宣传文案范文
  • 小程序怎么上架网站优化技术
  • 建设银行租房平台网站在广州做seo找哪家公司
  • 四川网站建设公司手机百度如何发布广告
  • 仿淘宝php c2c电子商务网站模板seow是什么意思
  • 专业营销的网站建设公司郑州抖音seo
  • 网站建设开标书网站秒收录工具
  • 北京网站建设公司华网长沙网站优化效果
  • 哪个网站做兼职可靠精准营销推广
  • 武汉网站建设开发公司seo网站
  • 专业网站建设现状及对策研究培训心得体会
  • 方特网站是谁做的怎么免费搭建自己的网站
  • 腾讯网站的品牌建设计划西安疫情最新数据