基于Dragonboard 410c的kinect应用系列之五——脸部识别实现代码
// Add mode params in title
WCHAR szTitleComplete[MAX_PATH];
swprintf_s(szTitleComplete, L"%s -- Depth:%s:%s Color:%s:%s NearMode:%s, SeatedSkeleton:%s", szTitle,
IMG_MAP[m_depthType], (m_depthRes < 0)? L"ERROR": RES_MAP[m_depthRes], IMG_MAP[m_colorType], (m_colorRes < 0)? L"ERROR": RES_MAP[m_colorRes], m_bNearMode? L"ON": L"OFF",
m_bSeatedSkeletonMode?L"ON": L"OFF");
WCHAR szWindowClass[MaxLoadStringChars]; // the main window class name
LoadString(m_hInst, IDC_SINGLEFACE, szWindowClass, ARRAYSIZE(szWindowClass));
RegisterClass(szWindowClass);
m_hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SINGLEFACE));
m_pImageBuffer = FTCreateImage();
m_pVideoBuffer = FTCreateImage();
m_hWnd = CreateWindow(szWindowClass, szTitleComplete, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, m_hInst, this);
if (!m_hWnd)
{
return FALSE;
}
ShowWindow(m_hWnd, nCmdShow);
UpdateWindow(m_hWnd);
return SUCCEEDED(m_FTHelper.Init(m_hWnd,
FTHelperCallingBack,
this,
m_depthType,
m_depthRes,
m_bNearMode,
TRUE, // if near mode doesn't work, fall back to default mode
m_colorType,
m_colorRes,
m_bSeatedSkeletonMode));
}
void SingleFace::UninitInstance()
{
// Clean up the memory allocated for Face Tracking and rendering.
m_FTHelper.Stop();
if (m_hAccelTable)
{
DestroyAcceleratorTable(m_hAccelTable);
m_hAccelTable = NULL;
}
DestroyWindow(m_hWnd);
m_hWnd = NULL;
if (m_pImageBuffer)
{
m_pImageBuffer->Release();
m_pImageBuffer = NULL;
}
if (m_pVideoBuffer)
{
m_pVideoBuffer->Release();
m_pVideoBuffer = NULL;
}
}
// Register the window class.
ATOM SingleFace::RegisterClass(PCWSTR szWindowClass)
{
WNDCLASSEX wcex = {0};
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = &SingleFace::WndProcStatic;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = m_hInst;
wcex.hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_SINGLEFACE));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_SINGLEFACE);
wcex.lpszClassName = szWindowClass;
return RegisterClassEx(&wcex);
}
LRESULT CALLBACK SingleFace::WndProcStatic(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static SingleFace* pThis = NULL; // cheating, but since there is just one window now, it will suffice.
if (WM_CREATE == message)
{
pThis = reinterpret_cast<SingleFace*>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams);
}
return pThis ? pThis->WndProc(hWnd, message, wParam, lParam) : DefWindowProc(hWnd, message, wParam, lParam);
}
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_KEYUP - Exit in response to ESC key
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
LRESULT CALLBACK SingleFace::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
UINT wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(m_hInst, MAK
DragonBoard 410c 脸部识别 Kinect 相关文章: