微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 硬件工程师文库 > 基于Dragonboard 410c的kinect应用系列之五——脸部识别实现代码

基于Dragonboard 410c的kinect应用系列之五——脸部识别实现代码

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

之前的教程里,给大家讲过基于Dragonboard 410c开发板搭建kinect应用实现自动跟随机器人,今天我们来讲讲实现人脸识别。

一、核心代码:

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

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

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

// </copyright>

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

 

// Defines the entry point for the applicaTIon.

//

 

#include "stdafx.h"

#include "SingleFace.h"

#include "EggAvatar.h"

#include <FaceTrackLib.h>

#include "FTHelper.h"

 

 

 

class SingleFace

{

public:

SingleFace()

: m_hInst(NULL)

, m_hWnd(NULL)

, m_hAccelTable(NULL)

, m_pImageBuffer(NULL)

, m_pVideoBuffer(NULL)

, m_depthType(NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX)

, m_colorType(NUI_IMAGE_TYPE_COLOR)

, m_depthRes(NUI_IMAGE_RESOLUTION_320x240)

, m_colorRes(NUI_IMAGE_RESOLUTION_640x480)

, m_bNearMode(TRUE)

, m_bSeatedSkeletonMode(FALSE)

{}

 

int Run(HINSTANCE hInst, PWSTR lpCmdLine, int nCmdShow);

protected:

BOOL InitInstance(HINSTANCE hInst, PWSTR lpCmdLine, int nCmdShow);

void ParseCmdString(PWSTR lpCmdLine);

void UninitInstance();

ATOM RegisterClass(PCWSTR szWindowClass);

static LRESULT CALLBACK WndProcStatic(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

static INT_PTR CALLBACK About(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

BOOL PaintWindow(HDC hdc, HWND hWnd);

BOOL ShowVideo(HDC hdc, int width, int height, int originX, int originY);

BOOL ShowEggAvatar(HDC hdc, int width, int height, int originX, int originY);

static void FTHelperCallingBack(LPVOID lpParam);

static int const MaxLoadStringChars = 100;

 

HINSTANCE m_hInst;

HWND m_hWnd;

HACCEL m_hAccelTable;

EggAvatar m_eggavatar;

FTHelper m_FTHelper;

IFTImage* m_pImageBuffer;

IFTImage* m_pVideoBuffer;

 

NUI_IMAGE_TYPE m_depthType;

NUI_IMAGE_TYPE m_colorType;

NUI_IMAGE_RESOLUTION m_depthRes;

NUI_IMAGE_RESOLUTION m_colorRes;

BOOL m_bNearMode;

BOOL m_bSeatedSkeletonMode;

};

 

// Run the SingleFace application.

int SingleFace::Run(HINSTANCE hInst, PWSTR lpCmdLine, int nCmdShow)

{

MSG msg = {static_cast<HWND>(0), static_cast<UINT>(0), static_cast<WPARAM>(-1)};

if (InitInstance(hInst, lpCmdLine, nCmdShow))

{

// Main message loop:

while (GetMessage(&msg, NULL, 0, 0))

{

if (!TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

}

}

UninitInstance();

 

return (int)msg.wParam;

}

 

// In this function, we save the instance handle, then create and display the main program window.

BOOL SingleFace::InitInstance(HINSTANCE hInstance, PWSTR lpCmdLine, int nCmdShow)

{

m_hInst = hInstance; // Store instance handle in our global variable

 

ParseCmdString(lpCmdLine);

 

WCHAR szTitle[MaxLoadStringChars]; // The title bar text

LoadString(m_hInst, IDS_APP_TITLE, szTitle, ARRAYSIZE(szTitle));

 

static const PCWSTR RES_MAP[] = { L"80x60", L"320x240", L"640x480", L"1280x960" };

static const PCWSTR IMG_MAP[] = { L"PLAYERID", L"RGB", L"YUV", L"YUV_RAW", L"DEPTH" };

 

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

网站地图

Top