RGB-D相机SDK是一套适用于RGB-D系列相机的统一SDK接口,为上层软件的二次开发提供简单易用的API。此RGB-D系列相机主要包括MV-DB500S-S、MV-DB500S-R、MV-DB500S-C、MV-DB1300A、MV-EB435i,采用主动双目立体成像技术,结合彩色摄像头输出深度图像和RGB图像。相机内置高精度深度融合算法、宽动态图像处理算法,广泛应用于仓储物流、大件体积测量等应用场景。
图2-1 RGB-D相机SDK接口调用流程图
该示例程序说明了如何通过调用SDK接口获取图像数据
#include "../common/common.hpp"
#include "../common/RenderImage.hpp"
int main(int argc,char** argv)
{
MV3D_RGBD_VERSION_INFO stVersion;
ASSERT_OK( MV3D_RGBD_GetSDKVersion(&stVersion) );
ASSERT_OK(MV3D_RGBD_Initialize());
unsigned int nDevNum = 0;
ASSERT_OK(MV3D_RGBD_GetDeviceNumber(DeviceType_Ethernet | DeviceType_USB, &nDevNum));
LOGD("MV3D_RGBD_GetDeviceNumber success! nDevNum:%d.", nDevNum);
ASSERT(nDevNum);
// 查找设备
std::vector<MV3D_RGBD_DEVICE_INFO> devs(nDevNum);
ASSERT_OK(MV3D_RGBD_GetDeviceList(DeviceType_Ethernet | DeviceType_USB, &devs[0], nDevNum, &nDevNum));
for (unsigned int i = 0; i < nDevNum; i++)
{
LOG("Index[%d]. SerialNum[%s] IP[%s] name[%s].\r\n", i, devs[i].chSerialNumber, devs[i].SpecialInfo.stNetInfo.chCurrentIp, devs[i].chModelName);
}
//打开设备
void* handle = NULL;
unsigned int nIndex = 0;
ASSERT_OK(MV3D_RGBD_OpenDevice(&handle, &devs[nIndex]));
LOGD("OpenDevice success.");
// 开始工作流程
ASSERT_OK(MV3D_RGBD_Start(handle));
LOGD("Start work success.");
BOOL bExit_Main = FALSE;
RenderImgWnd depthViewer(768, 512, "depth");
MV3D_RGBD_FRAME_DATA stFrameData = {0};
while (!bExit_Main && depthViewer)
{
// 获取图像数据
int nRet = MV3D_RGBD_FetchFrame(handle, &stFrameData, 5000);
if (MV3D_RGBD_OK == nRet)
{
LOGD("MV3D_RGBD_FetchFrame success.");
RIFrameInfo depth = { 0 };
RIFrameInfo rgb = { 0 };
parseFrame(&stFrameData, &depth, &rgb);
depthViewer.RenderImage(depth);
}
//按任意键退出
if (_kbhit())
{
bExit_Main = TRUE;
}
}
ASSERT_OK(MV3D_RGBD_Stop(handle));
ASSERT_OK(MV3D_RGBD_CloseDevice(&handle));
ASSERT_OK(MV3D_RGBD_Release());
LOGD("Main done!");
return 0;
}
序号 |
接口名称 |
接口功能说明 |
1 |
MV3D_RGBD_GetSDKVersion(MV3D_RGBD_VERSION_INFO* pstVersion) |
获取SDK版本号 |
2 |
MV3D_RGBD_Initialize() |
SDK运行环境初始化 |
3 |
MV3D_RGBD_Release() |
SDK运行环境释放 |
4 |
MV3D_RGBD_GetDeviceNumber(uint32_t nDeviceType, uint32_t* pDeviceNumber) |
获取当前环境中设备数量 |
5 |
MV3D_RGBD_GetDeviceList(uint32_t nDeviceType, MV3D_RGBD_DEVICE_INFO* pstDeviceInfos, uint32_t nMaxDeviceCount, uint32_t* pDeviceCount); |
获取设备列表 |
6 |
MV3D_RGBD_OpenDevice(HANDLE *handle, MV3D_RGBD_DEVICE_INFO* pstDeviceInfo = NULL) |
打开设备 |
7 |
MV3D_RGBD_OpenDeviceByName(HANDLE *handle, const char* chDeviceName) |
通过设备名称打开设备 |
8 |
MV3D_RGBD_OpenDeviceBySerialNumber(HANDLE *handle, const char* chSerialNumber) |
通过序列号打开设备 |
9 |
MV3D_RGBD_OpenDeviceByIp(HANDLE *handle, const char* chIP) |
通过IP打开设备,仅网口设备有效 |
10 |
MV3D_RGBD_CloseDevice(HANDLE *handle) |
关闭设备 |
11 |
MV3D_RGBD_GetDeviceInfo(HANDLE handle, MV3D_RGBD_DEVICE_INFO* pstDevInfo) |
获取当前设备的详细信息 |
12 |
MV3D_RGBD_SetIpConfig(const char* chSerialNumber, MV3D_RGBD_IP_CONFIG* pstIPConfig) |
配置IP,仅网口设备有效 |
13 |
MV3D_RGBD_RegisterFrameCallBack(HANDLE handle, MV3D_RGBD_FrameDataCallBack cbOutput, void* pUser) |
注册图像数据回调 |
14 |
MV3D_RGBD_RegisterExceptionCallBack(HANDLE handle, MV3D_RGBD_ExceptionCallBack cbException, void* pUser) |
注册异常消息回调 |
15 |
MV3D_RGBD_Start(HANDLE handle) |
开始工作 |
16 |
MV3D_RGBD_Stop(HANDLE handle) |
停止工作 |
17 |
MV3D_RGBD_FetchFrame(HANDLE handle, MV3D_RGBD_FRAME_DATA* pstFrameData, uint32_t nTimeOut) |
轮询方式获取帧数据 |
18 |
MV3D_RGBD_SoftTrigger(HANDLE handle) |
执行设备软触发 |
19 |
MV3D_RGBD_Execute(HANDLE handle, const char* strKey) |
执行设备Command命令 |
20 |
MV3D_RGBD_GetCalibInfo(HANDLE handle, uint32_t nCoordinateType, MV3D_RGBD_CALIB_INFO *pstCalibInfo) |
获取相机当前标定信息 |
21 |
MV3D_RGBD_LocalUpgrade(HANDLE handle, const char* pFilePathName) |
设备升级 |
22 |
MV3D_RGBD_GetUpgradeProcess(HANDLE handle, uint32_t* pProcess) |
获取升级进度 |
23 |
MV3D_RGBD_GetParam(HANDLE handle, const char* strKey, MV3D_RGBD_PARAM* pstParam) |
获取相机参数值 |
24 |
MV3D_RGBD_SetParam(HANDLE handle, const char* strKey, MV3D_RGBD_PARAM* pstParam) |
设置相机参数值 |
25 |
MV3D_RGBD_ExportAllParam(HANDLE handle, const char* pOutFileName) |
导出相机参数 |
26 |
MV3D_RGBD_ImportAllParam(HANDLE handle, const char* pInFileName) |
导入相机参数 |
27 |
MV3D_RGBD_MapDepthToPointCloud(void* handle, MV3D_RGBD_IMAGE_DATA* pstDepthImage, MV3D_RGBD_IMAGE_DATA* pstPointCloudImage) |
RGBD相机深度图像转换点云图像 |