应该添加什么.dll或.lib文件到程序,kinect for windows v1.8 sdk的交互 [英] what .dll or .lib file should I add to program ,the interaction of the kinect for windows v1.8 sdk

查看:74
本文介绍了应该添加什么.dll或.lib文件到程序,kinect for windows v1.8 sdk的交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我开发了一个带有kinect for windows sdk 1.8的程序,交互技术。
开发vs2013

I develop a program with kinect for windows sdk 1.8,the interaction technology。 develop the the vs2013

但是当我编译时,错误来了:

But when I complie,error come:

1.unresolved external symbol" __ imp__NuiGetSensorCount @ 4"在函数int中引用__cdecl ConnectKinect(void)" (?ConnectKinect @@ YAHXZ)"

1.unresolved external symbol "__imp__NuiGetSensorCount@4" referenced in function int __cdecl ConnectKinect(void)" (?ConnectKinect@@YAHXZ)"

2.unresolved external symbol" __ imp__NuiCreateSensorByIndex @ 8"  在函数"int __cdecl ConnectKinect(void)"中引用(?ConnectKinect @@ YAHXZ)"

2.unresolved external symbol "__imp__NuiCreateSensorByIndex@8"  referenced in function "int __cdecl ConnectKinect(void)" (?ConnectKinect@@YAHXZ)"

找不到NuiGetSensorCount和NuiCreateSensorByIndex函数,以及  KinectInteraction180_32.lib,KinectInteraction180_32.dll和我已添加到程序中。

cannot find the NuiGetSensorCount and NuiCreateSensorByIndex function,and the KinectInteraction180_32.lib , KinectInteraction180_32.dll and  I have add to the program.

为什么?是否还需要其他.dll或.lib文件添加到程序中?

why? Is there other .dll or .lib file needed to add to the program?

想要帮助我,谢谢。

推荐答案

//this is my code

#include<Windows.h>
#include<iostream>
#include <NuiApi.h>
#include <KinectInteraction.h>

using namespace std;
class InteractionClient :public INuiInteractionClient
{
public:
	InteractionClient(){}
	~InteractionClient(){}

	STDMETHOD(GetInteractionInfoAtLocation)(THIS_ DWORD skeletonTrackingId, NUI_HAND_TYPE handType, FLOAT x, FLOAT y, _Out_ NUI_INTERACTION_INFO *pInteractionInfo)
	{
		if (pInteractionInfo)
		{
			pInteractionInfo->IsPressTarget = false;
			pInteractionInfo->PressTargetControlId = 0;
			pInteractionInfo->PressAttractionPointX = 0.f;
			pInteractionInfo->PressAttractionPointY = 0.f;
			pInteractionInfo->IsGripTarget = true;
			return S_OK;
		}
		return E_POINTER;
	}

	STDMETHODIMP_(ULONG)    AddRef()                                    { return 2; }
	STDMETHODIMP_(ULONG)    Release()                                   { return 1; }
	STDMETHODIMP            QueryInterface(REFIID riid, void **ppv)     { return S_OK; }
};

INuiSensor * m_pNuiSensor = NULL;

//depth data and skeleton data handle
HANDLE skeletonEvent;
HANDLE depthEvent;
HANDLE depthStreamHandle;
//interaction hand
HANDLE m_hNextInteractionEvent;
HANDLE m_hEvNuiProcessStop;
//InteractionClient
InteractionClient m_nuiIClient;

INuiInteractionStream *m_nuiIStream; 

void interaction();
int ConnectKinect();
void KinectData();

void KinectData()
{
	HANDLE hEvents[5] = { m_hEvNuiProcessStop, skeletonEvent, depthEvent, m_hNextInteractionEvent };

	while (1)
	{
		int nEventIdx;
		nEventIdx = WaitForMultipleObjects(sizeof(hEvents) / sizeof(hEvents[0]),hEvents, FALSE, 100);
		if (WAIT_OBJECT_0 == WaitForSingleObject(m_hEvNuiProcessStop, 0))
		{
			break;
		}
		// Process signal events
		/*if (WAIT_OBJECT_0 == WaitForSingleObject(depthEvent, 0))
		{

		}
		if (WAIT_OBJECT_0 == WaitForSingleObject(skeletonEvent, 0))
		{

		}*/
		if (WAIT_OBJECT_0 == WaitForSingleObject(m_hNextInteractionEvent, 0))
		{
			interaction();
		}
	}

	/*CloseHandle(m_hEvNuiProcessStop);
	m_hEvNuiProcessStop = NULL;
	CloseHandle(skeletonEvent);
	CloseHandle(depthEvent);
	CloseHandle(m_hNextInteractionEvent);*/
	return;
}
int ConnectKinect()//connect kinect ,then open the skeleton stream and the depth stream 
{
	INuiSensor * pNuiSensor;
	HRESULT hr;
	int SensorCount = 0;
	hr = NuiGetSensorCount(&SensorCount);
	if (FAILED(hr))
		return 0;

	//find the kinect
	for (int index = 0; index < SensorCount; index++)
	{
		hr = NuiCreateSensorByIndex(index, &pNuiSensor);
		if (FAILED(hr))
			continue;

		//is the sensor useable
		hr = pNuiSensor->NuiStatus();
		if (S_OK == hr)
		{
			m_pNuiSensor = pNuiSensor;
			break;
		}
		// This sensor wasn't OK, so release it since we're not using it
		pNuiSensor->Release();
	}
	if (NULL != m_pNuiSensor)
	{
		//if cannot find the kinect,return 0
		if (NULL == m_pNuiSensor || FAILED(hr))
			return 0;
		//if find the kinect ,intialize the stream
		if (SUCCEEDED(hr))
		{
			hr = m_pNuiSensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX | NUI_INITIALIZE_FLAG_USES_SKELETON);
			if (FAILED(hr))
			{
				cout << "cannot initialize the kinect";
				return 0;
			}
			//create event,and stream handle
			skeletonEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
			depthEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
			depthStreamHandle = NULL;
			//open the depth stream
			hr = m_pNuiSensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX, NUI_IMAGE_RESOLUTION_640x480, 0, 2, depthEvent, &depthStreamHandle);
			if (FAILED(hr))
			{
				cout << "Could not open depth stream video" << endl;
				return 0;
			}
			//track the skeleton
			hr = m_pNuiSensor->NuiSkeletonTrackingEnable(skeletonEvent, 0);
			if (FAILED(hr))
			{
				cout << "Could not open skeleton stream video" << endl;
				return 0;
			}

		}
	}
	return 1;
}
void interaction()
{
	//get next frame
	NUI_INTERACTION_FRAME interaction_frame;
	auto ret = m_nuiIStream->GetNextFrame(0, &interaction_frame);
	if (FAILED(ret))
	{
		cout << "failed getnextframe" << endl;
		return;
	}

	int trackingID = 0;
	int event = 0;

	COORD pos = { 0, 0 };
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut, pos);

	cout << "show Interactions!" << endl;
	for (int i = 0; i<NUI_SKELETON_COUNT; i++)
	{
		trackingID = interaction_frame.UserInfos[i].SkeletonTrackingId;

		event = interaction_frame.UserInfos[i].HandPointerInfos->HandEventType;

		if (event == NUI_HAND_EVENT_TYPE_GRIP) {
			cout << "id=" << trackingID << "---------event:" << "Grip" << endl;
		}
		else if (event == NUI_HAND_EVENT_TYPE_GRIPRELEASE) {
			cout << "id=" << trackingID << "---------event:" << "GripRelease" << endl;
		}
		else  {
			cout << "id=" << trackingID << "---------event:" << "None" << endl;
		}

	}

	return;

}


void main()
{
	HRESULT hr;
	m_hNextInteractionEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
	m_hEvNuiProcessStop = CreateEvent(NULL, TRUE, FALSE, NULL);
	//open the interaction stream
	hr = NuiCreateInteractionStream(m_pNuiSensor, (INuiInteractionClient *)(&m_nuiIClient), &m_nuiIStream);
	if (FAILED(hr))
	{
		cout << "cannot open the interaction stream";
		return;
	}
	//main function
	KinectData();
	m_pNuiSensor->NuiShutdown();
	return;
}





这篇关于应该添加什么.dll或.lib文件到程序,kinect for windows v1.8 sdk的交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆