資源簡介
本人,在結合Kinect v2.0+ VS2012+openCV2.4.9,將彩色幀映射到深度空間,本想利用一些國內外的現有資料,怎奈只找到MapDepthrFrameToColorSpace,空間的轉換,未找到現成的程序能夠使用openCV2.4.9將Kinect v2.0里的彩色幀映射到深度空間里,故自己嘗試著將MapColorFrameToDepthSpace在程序中實現,程序寫出來,也能跑出來,映射也實現了,但還有點瑕疵。鑒于當前無相關標準結果參考,故上傳于此,待同仁參考,期待改進。讓我們一起來將Kinect v2.0+ VS2012+openCV2.4.9完美結合,將Kinect v2.0的所有功能完美呈現。

代碼片段和文件信息
//?CoodinateMapper.cpp?:?定義控制臺應用程序的入口點。
//
#include?“stdafx.h“
#include
#include
#include?
#include?
using?namespace?cv;
using?namespace?std;
template
inline?void?SafeRelease(?Interface?*&?pInterfaceToRelease?)
????{
????if?(?pInterfaceToRelease?!=?NULL?)
????????{
????????pInterfaceToRelease->Release();
????????pInterfaceToRelease?=?NULL;
????????}
????}
int?_tmain(int?argc?_TCHAR*?argv[])
????{
????IKinectSensor*?pSensor?;
????HRESULT?hResult?=?S_OK?;
????hResult?=?GetDefaultKinectSensor(?&pSensor?);
????if?(?FAILED(?hResult?)?)
????????{
????????cerr?<“Error:GetDefaultKinectSensor“?<????????return?-1;
????????}
????hResult?=?pSensor->Open();
????if?(?FAILED(?hResult?)?)
????????{
????????cerr?<“Error:IKinectSensor::Open()“?<????????return?-1;
????????}
????IColorframeSource*?pColorSource;
????hResult?=?pSensor->get_ColorframeSource(?&pColorSource?);
????if?(?FAILED(?hResult?)?)
????????{
????????cerr?<“Error:IKinectSensor::get_ColorframeSource()“?<????????return?-1;
????????}
????IColorframeReader*?pColorReader;
????hResult?=?pColorSource->OpenReader(?&pColorReader?);?????
????if?(?FAILED(?hResult?)?)
????????{
????????cerr?<“Error:IColorframeSource::OpenReader()“?<????????return?-1;?
????????}
????iframeDescription*?pColorDescription;
????hResult?=?pColorSource->get_frameDescription(?&pColorDescription?);
????if?(?FAILED(?hResult?)?)
????????{
????????cerr?<“Error:IColorframeSource::get_frameDescription()“?<????????return?-1;
????????}
????int?colorHeight?=?NULL;
????int?colorWidth?=?NULL;
????pColorDescription->get_Height(?&colorHeight?);
????pColorDescription->get_Width(?&colorWidth?);
????unsigned?int?colorBufferSize?=?colorWidth?*?colorHeight?*?4?*?sizeof(?unsigned?char?);
????Mat?colorBufferMat(?colorHeight?colorWidth?CV_8UC4?);
????Mat?colorMat(?colorHeight/2?colorWidth/2?CV_8UC4?);
????namedWindow(?“color“?CV_WINDOW_NORMAL?);
????IDepthframeSource*?pDepthSource;
????hResult?=?pSensor->get_DepthframeSource(?&pDepthSource?);??????
????if?(?FAILED(?hResult?)?)
????????{
????????cerr?<“Error:IKinectSensor::get_DepthframeSource()“?<????????return?-1;
????????}
????IDepthframeReader*?pDepthReader;
????hResult?=?pDepthSource->OpenReader(?&pDepthReader?);???????????
????if?(?FAILED(?hResult?)?)
????????{
????????cerr?<“Error:IDepthframeSource::OpenReader()“?<????????return?-1;
????????}
????iframeDescription*?pDepthDescription;
????hResult?=?pDepthSource->get_frameDescription(?&pDepthDescription?);
????if?(?FAILED(?hResult?)?)
????????{
????????cerr?<“Error:IDepthframeSource::get_frameDescription()“?<????????return?-1;
????????}
????int?depthWidth?=?NULL;
????int?depthHeight?=?NULL;
????pDepthDescription->get_Width(?&depthWidth?);
????pDepthDescription-
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7499??2015-01-21?09:34??color-mapping-depth\color-mapping-depth\color-mapping-depth.cpp
?????文件???????4658??2015-01-20?18:10??color-mapping-depth\color-mapping-depth\color-mapping-depth.vcxproj
?????文件???????1323??2015-01-20?18:10??color-mapping-depth\color-mapping-depth\color-mapping-depth.vcxproj.filters
?????文件???????1702??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\cl.command.1.tlog
?????文件??????33370??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\CL.read.1.tlog
?????文件???????1232??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\CL.write.1.tlog
?????文件?????????87??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\color-mapping-depth.lastbuildstate
?????文件????????162??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\color-mapping-depth.log
?????文件?????381545??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\color-mapping-depth.obj
?????文件????1245184??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\color-mapping-depth.pch
?????文件??????????2??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\li
?????文件??????????2??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\li
?????文件??????????2??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\li
?????文件??????????2??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\li
?????文件???????2100??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\li
?????文件???????4520??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\li
?????文件????????826??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\li
?????文件??????12092??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\stdafx.obj
?????文件?????855040??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\vc110.idb
?????文件????1019904??2015-01-21?10:41??color-mapping-depth\color-mapping-depth\Debug\vc110.pdb
?????文件???????5918??2015-01-20?08:31??color-mapping-depth\color-mapping-depth\mhi.cpp
?????文件???????1594??2015-01-13?15:22??color-mapping-depth\color-mapping-depth\ReadMe.txt
?????文件????????224??2015-01-13?15:22??color-mapping-depth\color-mapping-depth\stdafx.cpp
?????文件????????233??2015-01-13?15:22??color-mapping-depth\color-mapping-depth\stdafx.h
?????文件????????236??2015-01-13?15:22??color-mapping-depth\color-mapping-depth\targetver.h
?????文件???47644672??2015-03-11?10:38??color-mapping-depth\color-mapping-depth.sdf
?????文件????????924??2015-01-13?15:22??color-mapping-depth\color-mapping-depth.sln
????..A..H.?????32768??2015-03-11?10:38??color-mapping-depth\color-mapping-depth.v11.suo
?????文件??????99840??2015-01-21?10:41??color-mapping-depth\Debug\color-mapping-depth.exe
?????文件?????483240??2015-01-21?10:41??color-mapping-depth\Debug\color-mapping-depth.ilk
............此處省略11個文件信息
評論
共有 條評論