文章目录
- 前言
- 一、外观和机芯参数
- 二、SDK的使用
- 1、打开相机
- 2、回调函数中获取全局温度和图像
- 3、关闭相机
前言
最近工作中接触了一款基于武汉高芯科技有限公司开发的红外模组,即coin417g2(测温型)+9.1mm镜头.使用此模组,开发了一套红外热成像检测桌面应用程序.下面简单记录下该模组的使用.
一、外观和机芯参数
如下是该机芯的外观和机芯参数:
二、SDK的使用
这里使用的是linux_sdk_usb2.0_v.1.1.5_aarch64-linux-gnu-gcc-8.4.0版本.
1、打开相机
int ret = guide_usb_initial();
if(ret < 0){g_pLog->log_E(QString::fromLocal8Bit("初始化相机失败,ret=%1").arg(ret));return -1;
}
else{g_pLog->log_I(QString::fromLocal8Bit("初始化相机成功,ret=%1").arg(ret));ret = guide_usb_opencommandcontrol((OnSerialDataReceivedCB)serailCallBack);if(ret < 0){g_pLog->log_E(QString::fromLocal8Bit("开启机芯控制命令通信失败,ret=%1").arg(ret));return -1;}else{g_pLog->log_I(QString::fromLocal8Bit("开启机芯控制命令通信成功"));}
}
m_deviceInfo = (guide_usb_device_info_t*)malloc(sizeof (guide_usb_device_info_t));
m_deviceInfo->width = IMAGEWIDTH;
m_deviceInfo->height = IMAGEHEIGHT;
m_deviceInfo->video_mode = Y16_PARAM_YUV; //观瞄mode:YUV_PARAM //测温mode:Y16_PARAM_YUV
ret = guide_usb_openstream(m_deviceInfo,(OnFrameDataReceivedCB)frameCallBack,(OnDeviceConnectStatusCB)connectStatusCallBack);
if(ret < 0)
{g_pLog->log_E(QString::fromLocal8Bit("打开视频流失败,ret=%1").arg(ret));return -1;
}
else{g_pLog->log_I(QString::fromLocal8Bit("打开视频流成功"));
}
2、回调函数中获取全局温度和图像
int serailCallBack(guide_usb_serial_data_t *pSerialData)
{int i = 0;for (i = 0;i< pSerialData->serial_recv_data_length;i++){if(i== (pSerialData->serial_recv_data_length-1)){printf("%x\n",pSerialData->serial_recv_data[i]);fflush(stdout);}else{printf("%x ",pSerialData->serial_recv_data[i]);fflush(stdout);}}return 1;
}int connectStatusCallBack(guide_usb_device_status_e deviceStatus)
{if(deviceStatus == DEVICE_CONNECT_OK){printf("VideoStream Capture start...\n");fflush(stdout);g_pLog->log_I(QString::fromLocal8Bit("连接正常"));}else{printf("VideoStream Capture end...\n");fflush(stdout);g_pLog->log_I(QString::fromLocal8Bit("断开连接"));}return 1;
}int frameCallBack(guide_usb_frame_data_t *pVideoData)
{//回调函数中建议只对数据入队,其他操作建议另起线程处理//YUV数据 [pVideoData->frame_yuv_data:机芯送出来的YUV数据] yuv422 uyvy//Y16数据 [pVideoData->frame_src_data:机芯送出来的Y16数据] for measure//参数行数据[pVideoData->paramLine:机芯送出来的参数行数据]if(m_mutex.try_lock()){if(m_dataQueue.size() <1){guide_usb_measure_external_param_t param;param.distance = 50;param.emiss = 98;param.relHum = 60;param.reflectedTemper = 230;param.atmosphericTemper = 230;param.modifyK = 100;param.modifyB = 0;//int ret = guide_usb_measure_convertgray2temper(1,1,pVideoData->frame_src_data,(uchar*)pVideoData->paramLine,IMAGEWIDTH*IMAGEHEIGHT,¶m,pTemper);if(ret >= 0){cv::Mat yuvimg = cv::Mat(IMAGEHEIGHT,IMAGEWIDTH,CV_8UC2,pVideoData->frame_yuv_data);cv::Mat bgrImg;cv::cvtColor(yuvimg, bgrImg, cv::COLOR_YUV2BGR_Y422);m_dataQueue.enqueue(bgrImg);}}m_mutex.unlock();}else{QThread::usleep(10);}return 1;
}
3、关闭相机
int ret = guide_usb_closestream();
if(ret < 0){g_pLog->log_E(QString::fromLocal8Bit("关闭视频流失败,ret=%1").arg(ret));
}
else{g_pLog->log_I(QString::fromLocal8Bit("关闭视频流成功"));
}ret = guide_usb_closecommandcontrol();
if(ret < 0){g_pLog->log_E(QString::fromLocal8Bit("关闭机芯控制命令通信失败,ret=%1").arg(ret));
}
else{g_pLog->log_I(QString::fromLocal8Bit("关闭机芯控制命令通信成功"));
}ret = guide_usb_exit();
if(ret < 0){g_pLog->log_E(QString::fromLocal8Bit("清除数据释放内存失败,ret=%1").arg(ret));
}
else{g_pLog->log_I(QString::fromLocal8Bit("清除数据释放内存成功"));
}
if(m_deviceInfo != NULL)
{free(m_deviceInfo);m_deviceInfo = NULL;
}
if(paraData != NULL)
{free(paraData);paraData = NULL;
}