关于红外相机热成像相机的一些sdk使用方法

将红外热成像相机转化成c格式,从而用opencv进行显示。

先看一些开发手册的函数

定义一个函数指针  typedef long (*CBF_IR)(long lData, long lParam);                 CBF_IR pCBFframe;

相机接口api函数

IR_SDK_API long IRSDK_Create(long handle, int port, char* ip, CBF_IR cbf_stm, CBF_IR cbf_cmd, CBF_IR cbf_comm, long param = 0);

定义个结构体


定义一个结构体

typedef struct tagFrame

{
    unsigned short width;
    unsigned short height;
    unsigned short u16FpaTemp; //焦面温度随图像数据一起上传
    unsigned char  u8SensorType; //探测器类型随图像数据一起上传
    unsigned short u16EnvTemp; //环境温度随图像数据一起上传
    unsigned char u8TempPrecison; //温度转换
    unsigned short buffer[327680];

} Frame;


IplImage *m_pImgsrc = NULL;
long FrameProc(long hFrame, long lParam)                                                               //1
{
Frame* pFrame = (Frame*)hFrame;
//pFrame为接收到的温度数据。此处根据自己的需求添加代码


//CIRdemovsDlg* dlg = ((CIRdemovsDlg *)lParam);
//CString temp;
//dlg->msgText.GetWindowTextW(temp);
//temp += CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")) + _T(" 接受到数据\r\n");
//dlg->msgText.SetWindowTextW(temp);

unsigned char y8[327680]; // y8 空间大小为图像像素数
    IRSDK_FrameConvert(pFrame, y8, 50, 50, 1, 0);


/*CString strTest;
strTest.Format(L"%d-%d",pFrame->height,pFrame->width);
AfxMessageBox(strTest);*/       
//bool bStop = true;
CvSize sz;
sz.height = pFrame->height;
sz.width = pFrame->width;
if(m_pImgsrc==NULL)
m_pImgsrc = cvCreateImage(sz,8,1);


uchar* pd = (uchar*)m_pImgsrc->imageData; 
for(int i=0;i<sz.height;i++)
{
for(int j=0;j<sz.width;j++)
{
int nIndex = i*m_pImgsrc->widthStep+j;
pd[nIndex] = y8[nIndex];
}
}


cvNamedWindow("ShowIR");
cvShowImage("ShowIR",m_pImgsrc);
cvWaitKey(1);

}

猜你喜欢

转载自blog.csdn.net/suntingsheng123/article/details/80590134