微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 硬件工程师文库 > 基于Dragonboard 410c的kinect应用系列之四——获取人体骨骼图

基于Dragonboard 410c的kinect应用系列之四——获取人体骨骼图

时间:02-21 来源:互联网 点击:

在继《基于Dragonboard 410c的kinect应用系列之三——获取深度图》之后,今天我们来获取下人体的骨骼图。

一、核心代码:

//------------------------------------------------------------------------------

// <copyright file="SkeletonBasics.cpp" company="Microsoft">

// Copyright (c) Microsoft CorporaTIon. All rights reserved.

// </copyright>

//------------------------------------------------------------------------------

 

#include "stdafx.h"

#include <strsafe.h>

#include "SkeletonBasics.h"

#include "resource.h"

 

staTIc const float g_JointThickness = 3.0f;

staTIc const float g_TrackedBoneThickness = 6.0f;

staTIc const float g_InferredBoneThickness = 1.0f;

 

/// <summary>

/// Entry point for the application

/// </summary>

/// <param name="hInstance">handle to the application instance</param>

/// <param name="hPrevInstance">always 0</param>

/// <param name="lpCmdLine">command line arguments</param>

/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>

/// <returns>status</returns>

int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)

{

CSkeletonBasics application;

application.Run(hInstance, nCmdShow);

}

 

/// <summary>

/// Constructor

/// </summary>

CSkeletonBasics::CSkeletonBasics() :

m_pD2DFactory(NULL),

m_hNextSkeletonEvent(INVALID_HANDLE_VALUE),

m_pSkeletonStreamHandle(INVALID_HANDLE_VALUE),

m_bSeatedMode(false),

m_pRenderTarget(NULL),

m_pBrushJointTracked(NULL),

m_pBrushJointInferred(NULL),

m_pBrushBoneTracked(NULL),

m_pBrushBoneInferred(NULL),

m_pNuiSensor(NULL)

{

ZeroMemory(m_Points,sizeof(m_Points));

}

 

/// <summary>

/// Destructor

/// </summary>

CSkeletonBasics::~CSkeletonBasics()

{

if (m_pNuiSensor)

{

m_pNuiSensor->NuiShutdown();

}

 

if (m_hNextSkeletonEvent && (m_hNextSkeletonEvent != INVALID_HANDLE_VALUE))

{

CloseHandle(m_hNextSkeletonEvent);

}

 

// clean up Direct2D objects

DiscardDirect2DResources();

 

// clean up Direct2D

SafeRelease(m_pD2DFactory);

 

SafeRelease(m_pNuiSensor);

}

 

/// <summary>

/// Creates the main window and begins processing

/// </summary>

/// <param name="hInstance">handle to the application instance</param>

/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>

int CSkeletonBasics::Run(HINSTANCE hInstance, int nCmdShow)

{

MSG msg = {0};

WNDCLASS wc = {0};

 

// Dialog custom window class

wc.style = CS_HREDRAW | CS_VREDRAW;

wc.cbWndExtra = DLGWINDOWEXTRA;

wc.hInstance = hInstance;

wc.hCursor = LoadCursorW(NULL, IDC_ARROW);

wc.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP));

wc.lpfnWndProc = DefDlgProcW;

wc.lpszClassName = L"SkeletonBasicsAppDlgWndClass";

 

if (!RegisterClassW(&wc))

{

return 0;

}

 

// Create main application window

HWND hWndApp = CreateDialogParamW(

hInstance,

MAKEINTRESOURCE(IDD_APP),

NULL,

(DLGPROC)CSkeletonBasics::

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top