• 大小: 10.93MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-07
  • 语言: 其他
  • 标签: Kinect  v2.0  

资源简介

本人,在结合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“ << endl;
        return -1;
        }

    hResult = pSensor->Open();
    if ( FAILED( hResult ) )
        {
        cerr << “Error:IKinectSensor::Open()“ << endl;
        return -1;
        }

    IColorframeSource* pColorSource;
    hResult = pSensor->get_ColorframeSource( &pColorSource );
    if ( FAILED( hResult ) )
        {
        cerr << “Error:IKinectSensor::get_ColorframeSource()“ << endl;
        return -1;
        }

    IColorframeReader* pColorReader;
    hResult = pColorSource->OpenReader( &pColorReader );     
    if ( FAILED( hResult ) )
        {
        cerr << “Error:IColorframeSource::OpenReader()“ << endl;
        return -1; 
        }

    iframeDescription* pColorDescription;
    hResult = pColorSource->get_frameDescription( &pColorDescription );
    if ( FAILED( hResult ) )
        {
        cerr << “Error:IColorframeSource::get_frameDescription()“ << endl;
        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()“ << endl;
        return -1;
        }

    IDepthframeReader* pDepthReader;
    hResult = pDepthSource->OpenReader( &pDepthReader );           
    if ( FAILED( hResult ) )
        {
        cerr << “Error:IDepthframeSource::OpenReader()“ << endl;
        return -1;
        }

    iframeDescription* pDepthDescription;
    hResult = pDepthSource->get_frameDescription( &pDepthDescription );
    if ( FAILED( hResult ) )
        {
        cerr << “Error:IDepthframeSource::get_frameDescription()“ << endl;
        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\link-cvtres.read.1.tlog

     文件          2  2015-01-21 10:41  color-mapping-depth\color-mapping-depth\Debug\link-cvtres.write.1.tlog

     文件          2  2015-01-21 10:41  color-mapping-depth\color-mapping-depth\Debug\link-rc.read.1.tlog

     文件          2  2015-01-21 10:41  color-mapping-depth\color-mapping-depth\Debug\link-rc.write.1.tlog

     文件       2100  2015-01-21 10:41  color-mapping-depth\color-mapping-depth\Debug\link.command.1.tlog

     文件       4520  2015-01-21 10:41  color-mapping-depth\color-mapping-depth\Debug\link.read.1.tlog

     文件        826  2015-01-21 10:41  color-mapping-depth\color-mapping-depth\Debug\link.write.1.tlog

     文件      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个文件信息

评论

共有 条评论