您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > 彩色图像转HALCON
C++intCGCapDlg::Start(){intw,h;JV__PixelFormatEnumsPixelFormat;JV_GetWidth(m_hCam,&w);JV_GetHeight(m_hCam,&h);JV_GetPixelFormat(m_hCam,&PixelFormat);//根据相机的宽、高、像素格式创建图像,用于接收和绘制采集到的图像m_image.CreateByPixelFormat(w,h,PixelFormat);//开始连续采集JV_StartGrab(m_hCam,StreamCB,(long)this);}intCGCapDlg::OnStreamCB(JV__IMAGE_INFO*pInfo){//将新采集到的一帧图像信息pInfo转换为图像JV_Info2Image(m_hCam,pInfo,&m_image);转换后的彩色图像可以通过m_image.GetBits()取得。}或者使用HALCON进行转换intCGCapDlg::OnStreamCB(JV__IMAGE_INFO*pInfo){GenImage1(ho_Image,byte,pInfo-nSizeX,pInfo-nSizeY,(long)pInfo-pImageBuffer);再使用HalconCfaToRgb函数进行转换}C#privatevoidImageCreat(){intw=0,h=0;JV_STATUSr=JV_GigE.JV_GetWidth(m_hCam,outw);if(r!=JV_STATUS.JV_ST_SUCCESS){MessageBox.Show(取得图像宽度失败);return;}r=JV_GigE.JV_GetHeight(m_hCam,outh);if(r!=JV_STATUS.JV_ST_SUCCESS){MessageBox.Show(取得图像高度失败);return;}r=JV_GigE.JV_GetPixelFormat(m_hCam,outm_PixelFormat);if(r!=JV_STATUS.JV_ST_SUCCESS){MessageBox.Show(取得图像颜色模式失败);return;}if(m_nWidth!=w||m_nHeight!=h){m_nWidth=w;m_nHeight=h;if(m_hImage!=IntPtr.Zero){JV_API.JV_Image.JV_ImageRelease(m_hImage);m_hImage=IntPtr.Zero;}if(m_PixelFormat==JV_API.JV__PixelFormatEnums.PixelFormat_Mono8){m_hImage=JV_API.JV_Image.JV_ImageCreate(w,h,8);}else{m_hImage=JV_API.JV_Image.JV_ImageCreate(w,h,24);}Refresh();}}intStreamCB(refJV_API.IMAGE_INFOpInfo,IntPtrUserVal){JV_GigE.JV_Info2Image(m_hCam,refpInfo,m_hImage);//转换为RGB图像JV_Image.JV_ImageGetBits(m_hImage);//获取彩色图像的指针return0;}
本文标题:彩色图像转HALCON
链接地址:https://www.777doc.com/doc-2433241 .html