• 大小: 1.48MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-01
  • 语言: 其他
  • 标签: Kinect2  源码  例子  

资源简介

Kinect2的入门例子源码,包含人体追踪、彩色图像读取、深度图像读取、脸部识别、脸部重建、坐标映射、Fusion等20个源码例程

资源截图

代码片段和文件信息

#include “app.h“
#include “util.h“

#include 
#include 
#include 
#include 

#include 

// Constructor
Kinect::Kinect()
{
    // Initialize
    initialize();
}

// Destructor
Kinect::~Kinect()
{
    // Finalize
    finalize();
}

// Processing
void Kinect::run()
{
    // Main Loop
    while( true ){
        // Update Data
        update();

        // Draw Data
        draw();

        // Show Data
        show();

        // Key Check
        if( GetKeyState( VK_ESCAPE ) < 0 ){
            break;
        }
    }
}

// Initialize
void Kinect::initialize()
{
    // Initialize Sensor
    initializeSensor();

    // Initialize Audio
    initializeAudio();

    // Wait a Few Seconds until begins to Retrieve Data from Sensor ( about 2000-[ms] )
    std::this_thread::sleep_for( std::chrono::seconds( 2 ) );
}

// Initialize Sensor
inline void Kinect::initializeSensor()
{
    // Open Sensor
    ERROR_CHECK( GetDefaultKinectSensor( &kinect ) );

    ERROR_CHECK( kinect->Open() );

    // Check Open
    BOOLEAN isOpen = FALSE;
    ERROR_CHECK( kinect->get_IsOpen( &isOpen ) );
    if( !isOpen ){
        throw std::runtime_error( “failed IKinectSensor::get_IsOpen( &isOpen )“ );
    }
}

// Initialize Audio
inline void Kinect::initializeAudio()
{
    // Retrieve Audio Source
    ComPtr audioSource;
    ERROR_CHECK( kinect->get_AudioSource( &audioSource ) );

    // Open Audio Beam Reader
    ERROR_CHECK( audioSource->OpenReader( &audioBeamframeReader ) );
}

// Finalize
void Kinect::finalize()
{
    // Close Sensor
    if( kinect != nullptr ){
        kinect->Close();
    }
}

// Update Data
void Kinect::update()
{
    // Update Audio
    updateAudio();
}

// Update Audio
inline void Kinect::updateAudio()
{
    // Retrieve Audio Beam frame List
    ComPtrameList> audioBeamframeList;
    const HRESULT ret = audioBeamframeReader->AcquireLatestBeamframes( &audioBeamframeList );
    if( FAILED( ret ) ){
        return;
    }

    //  Retrieve Audio Beam frame Count
    UINT beamCount = 0;
    ERROR_CHECK( audioBeamframeList->get_BeamCount( &beamCount ) );

    Concurrency::parallel_for( 0 static_cast( beamCount ) [&]( int i ){
        // Retrieve Audio Beam frame
        ComPtrame> audioBeamframe;
        ERROR_CHECK( audioBeamframeList->OpenAudioBeamframe( i &audioBeamframe ) );

        // Retrieve Audio Beam Subframe Count
        UINT subframeCount = 0;
        ERROR_CHECK( audioBeamframe->get_SubframeCount( &subframeCount ) );

        Concurrency::parallel_for( 0 static_cast( subframeCount ) [&]( int j ){
            // Retrieve Audio Beam Subframe
            ComPtrame> audioBeamSubframe;
            ERROR_CHECK( audioBeamframe->GetSubframe( j &audioBeamSubframe ) );

            // Retrieve Beam Angle ( Radian +/- 1.0 )
            ERROR_CHECK( audioBeamSubframe->get_BeamAngle( &beamAngle ) );

            // Retrieve Beam Angle Confidence ( 0.0

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-12-06 04:13  Kinect2Sample-master\
     文件        3941  2017-12-06 04:13  Kinect2Sample-master\HOWTOBUILD.md
     文件        1082  2017-12-06 04:13  Kinect2Sample-master\LICENSE
     文件        1655  2017-12-06 04:13  Kinect2Sample-master\README.md
     目录           0  2017-12-06 04:13  Kinect2Sample-master\sample\
     目录           0  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBeam\
     文件         642  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBeam\CMakeLists.txt
     文件        7138  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBeam\FindKinectSDK2.cmake
     文件        3958  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBeam\app.cpp
     文件        1082  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBeam\app.h
     文件         251  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBeam\main.cpp
     文件         783  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBeam\util.h
     目录           0  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBody\
     文件        1403  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBody\CMakeLists.txt
     文件        7138  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBody\FindKinectSDK2.cmake
     文件        7788  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBody\app.cpp
     文件        1682  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBody\app.h
     文件         251  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBody\main.cpp
     文件         783  2017-12-06 04:13  Kinect2Sample-master\sample\AudioBody\util.h
     目录           0  2017-12-06 04:13  Kinect2Sample-master\sample\Body\
     文件        1383  2017-12-06 04:13  Kinect2Sample-master\sample\Body\CMakeLists.txt
     文件        7138  2017-12-06 04:13  Kinect2Sample-master\sample\Body\FindKinectSDK2.cmake
     文件        8981  2017-12-06 04:13  Kinect2Sample-master\sample\Body\app.cpp
     文件        1788  2017-12-06 04:13  Kinect2Sample-master\sample\Body\app.h
     文件         251  2017-12-06 04:13  Kinect2Sample-master\sample\Body\main.cpp
     文件         783  2017-12-06 04:13  Kinect2Sample-master\sample\Body\util.h
     目录           0  2017-12-06 04:13  Kinect2Sample-master\sample\BodyIndex\
     文件        1403  2017-12-06 04:13  Kinect2Sample-master\sample\BodyIndex\CMakeLists.txt
     文件        7138  2017-12-06 04:13  Kinect2Sample-master\sample\BodyIndex\FindKinectSDK2.cmake
     文件        3843  2017-12-06 04:13  Kinect2Sample-master\sample\BodyIndex\app.cpp
     文件        1200  2017-12-06 04:13  Kinect2Sample-master\sample\BodyIndex\app.h
............此处省略125个文件信息

评论

共有 条评论