資源簡介
需安裝kinectSDK_v2.0,配置opencv和pcl庫。可設置采集幀數,開始采集后會在本地保存相互對齊的彩色數據、深度數據和對應的點云文件

代碼片段和文件信息
#include?“prepare.h“
#define?frameCount?5
int?main(int?argc?char**argv)
{
clock_t?time?=?clock();
//preparatory?work
Kinect?kinect;
if?(kinect.kinectStart()?!=?0)
{
cout?<“failed?to?start“;
return?-1;
}
//prepare?buffer
Mat?DepthBuffer(Image::iDepthHeight?Image::iDepthWidth?CV_16UC1);
Mat?DepthBufferT(Image::iDepthHeight?Image::iDepthWidth?CV_8UC1);
Mat?ColorBuffer(Image::iColorHeight?Image::iColorWidth?CV_8UC4);
Mat?MappedColor(Image::iDepthHeight?Image::iDepthWidth?CV_8UC3);
Mat?MappedDepth(Image::iColorHeight?Image::iColorWidth?CV_8UC1);
ColorSpacePoint*?pColorSpacePoint?=?new?ColorSpacePoint[Image::iDepthframeSize];
DepthSpacePoint*?pDepthSpacePoint?=?new?DepthSpacePoint[Image::iColorframeSize];
CameraSpacePoint*?pCameraSpacePoint?=?new?CameraSpacePoint[Image::iColorframeSize];
//prepare?image?file
string?str[frameCount];
for?(int?i?=?0;?i?ameCount;?i++)
{
char?c[3];
_itoa(i?c?10);
str[i]?=?c;
}
//get?frame?info
for?(int?i?=?0;?i?ameCount;?i++)
{
//get?depth?data
while?(kinect.pDepthframeReader->AcquireLatestframe(&kinect.pDepthframe)?!=?S_OK);
while?(kinect.pDepthframe->CopyframeDataToArray(Image::iDepthframeSize?(UINT16*)DepthBuffer.data)?!=?S_OK);
kinect.releaseDepthframe();
DepthBuffer.convertTo(DepthBufferT?CV_8U?255.0f?/?Image::iDepthMax);
//get?color?data
while?(kinect.pColorframeReader->AcquireLatestframe(&kinect.pColorframe)?!=?S_OK);
while?(kinect.pColorframe->CopyConvertedframeDataToArray(Image::iColorframeSize?*?4?ColorBuffer.data?ColorImageFormat_Bgra)?!=?S_OK);
kinect.releaseColorframe();
//prepare?point?cloud?data?buffer
PointCloud::Ptr?cloud_depth(new?PointCloud);
cloud_depth->width?=?Image::iDepthWidth;
cloud_depth->height?=?Image::iDepthHeight;
cloud_depth->is_dense?=?false;
cloud_depth->resize(Image::iDepthframeSize);
/*PointCloud::Ptr?cloud_color(new?PointCloud);
cloud_color->width?=?Image::iColorWidth;
cloud_color->height?=?Image::iColorHeight;
cloud_color->is_dense?=?false;
cloud_color->resize(Image::iColorframeSize);*/
//map?coordinate
kinect.coordinateMap((UINT16*)DepthBuffer.data?pColorSpacePoint?pCameraSpacePoint?&MappedColor?&ColorBuffer?cloud_depth);
//kinect.coordinateMap((UINT16*)DepthBuffer.data?pDepthSpacePoint?pCameraSpacePoint?&MappedDepth?DepthBufferT.data?&ColorBuffer?cloud_color);
//save?mapped?depth-color?image
imwrite(“g://“?+?str[i]?+?“1depth.png“?DepthBufferT);
imwrite(“g://“?+?str[i]?+?“1color.png“?MappedColor);
io::savePCDFile(“g://“?+?str[i]?+?“1depth.pcd“?*cloud_depth);
//imwrite(“g://“?+?str[i]?+?“0color.png“?ColorBuffer);
//imwrite(“g://“?+?str[i]?+?“0depth.png“?MappedDepth);
//io::savePLYFile(“g://“?+?str[i]?+?“0color.ply“?*cloud_color);
}
//release?dynamic?array
delete[]?pColorSpacePoint;
delete[]?pDepthSpacePoint;
delete[]?pCamer
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7728??2017-04-03?21:56??3D_Reconstruction1\3D_Reconstruction\3D_Reconstruction.vcxproj
?????文件???????1177??2017-04-03?21:56??3D_Reconstruction1\3D_Reconstruction\3D_Reconstruction.vcxproj.filters
?????文件????????634??2017-04-03?20:19??3D_Reconstruction1\3D_Reconstruction\3D_Reconstruction.vcxproj.user
?????文件???????3119??2017-05-09?02:04??3D_Reconstruction1\3D_Reconstruction\main.cpp
?????文件???????9456??2017-05-08?18:40??3D_Reconstruction1\3D_Reconstruction\prepare.cpp
?????文件???????1346??2017-05-08?01:26??3D_Reconstruction1\3D_Reconstruction\prepare.h
?????文件????????168??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\3D_Recon.923DBE24.tlog\3D_Reconstruction.lastbuildstate
?????文件??????12504??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\3D_Recon.923DBE24.tlog\cl.command.1.tlog
?????文件????1447542??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\3D_Recon.923DBE24.tlog\CL.read.1.tlog
?????文件???????4234??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\3D_Recon.923DBE24.tlog\CL.write.1.tlog
?????文件??????15536??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\3D_Recon.923DBE24.tlog\li
?????文件??????31766??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\3D_Recon.923DBE24.tlog\li
?????文件????????728??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\3D_Recon.923DBE24.tlog\li
?????文件???????7899??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\3D_Reconstruction.log
?????文件????2155213??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\main.obj
?????文件????1778604??2017-04-03?21:40??3D_Reconstruction1\3D_Reconstruction\x64\Debug\mainMapToDepth.obj
?????文件????1783053??2017-04-03?20:37??3D_Reconstruction1\3D_Reconstruction\x64\Debug\main_MapToDepth.obj
?????文件?????311844??2017-03-28?17:03??3D_Reconstruction1\3D_Reconstruction\x64\Debug\main_test.obj
?????文件?????338833??2017-03-29?20:41??3D_Reconstruction1\3D_Reconstruction\x64\Debug\main_test3.obj
?????文件?????274642??2017-03-28?17:00??3D_Reconstruction1\3D_Reconstruction\x64\Debug\main_test_1.obj
?????文件?????301148??2017-03-29?15:10??3D_Reconstruction1\3D_Reconstruction\x64\Debug\mian_test2.obj
?????文件????1146081??2017-05-08?18:46??3D_Reconstruction1\3D_Reconstruction\x64\Debug\prepare.obj
?????文件???12160000??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\vc120.idb
?????文件???15437824??2017-05-09?02:02??3D_Reconstruction1\3D_Reconstruction\x64\Debug\vc120.pdb
?????文件????7274496??2018-06-20?14:58??3D_Reconstruction1\3D_Reconstruction.sdf
?????文件???????1351??2017-03-28?10:24??3D_Reconstruction1\3D_Reconstruction.sln
????..A..H.?????58368??2018-06-20?14:58??3D_Reconstruction1\3D_Reconstruction.v12.suo
?????文件?????329216??2017-05-09?02:02??3D_Reconstruction1\x64\Debug\3D_Reconstruction.exe
?????文件????2671204??2017-05-09?02:02??3D_Reconstruction1\x64\Debug\3D_Reconstruction.ilk
?????文件???17272832??2017-05-09?02:02??3D_Reconstruction1\x64\Debug\3D_Reconstruction.pdb
............此處省略10個文件信息
- 上一篇:grabcut的c++源代碼
- 下一篇:opencv之數字識別
評論
共有 條評論