Question

I'm currently trying to compute use Kinect For Windows SDK with C++ to remove the background extracting only the player from a scene. For this I'm using the provided sample from the developer toolkit and I'm currently stucked with a problem.

While analyzing the sample, I found this line of code: NuiCreateBackgroundRemovedColorStream(_sensor, &m_pBackgroundRemovalStream);

This line of code starts the background removal and belongs to the KinectBackgroundRemoval.h. When trying to use this line of code, Visual Studio does not underline it with the error but as soon as I press run, it says that I have a problem with my code:

Error   25  error LNK2019: unresolved external symbol __imp__NuiCreateBackgroundRemovedColorStream@8 referenced in function "public: __thiscall Kinect::Kinect(void)" (??0Kinect@@QAE@XZ)   C:\Users\Ricardo\documents\visual studio 2013\Projects\OpenCVSample\OpenCVSample\Kinect.obj OpenCVSample

my code is as follow:

NuiCreateSensorByIndex(0, &_sensor);
    _sensor->NuiInitializationFlags();
    _sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX | NUI_INITIALIZE_FLAG_USES_COLOR);
    _sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX, DEPTH_RESOLUTION, 0, 2, _depthEvent, &_depthStreamHandle);
    _sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR, RGB_RESOLUTION, 0, 2, _rgbEvent, &_rgbStreamHandle);
    _sensor->NuiSkeletonTrackingEnable(_skeletonEvent, NUI_SKELETON_TRACKING_FLAG_ENABLE_IN_NEAR_RANGE);

    NuiCreateBackgroundRemovedColorStream(_sensor, &m_pBackgroundRemovalStream);
    m_pBackgroundRemovalStream->Enable(RGB_RESOLUTION, DEPTH_RESOLUTION, _backgroundRemoveEvent);

note that I have already configured the include file and it does not underlined it with any error. I'm not realy used to C++ so it might be a really simple error.

Many thanks!

Was it helpful?

Solution

You just forgot to add the kinect sdk library to the linker. As MSDN states here, you either needs to link against KinectBackgroundRemoval180_32.lib or KinectBackgroundRemoval180_64.lib. You may add these lines to your code (anywhere), if using Visual Studio:

#if _WIN64
#pragma comment(lib, "KinectBackgroundRemoval180_64.lib")
#elif _WIN32
#pragma comment(lib, "KinectBackgroundRemoval180_32.lib")
#endif

OTHER TIPS

I'm not used to c++ but I'm noticing that you initialize your backgroundremoval stream BEFORE you initiliaze all your other streams. Your BGRemovalStream uses both the image, depth & skeleton stream, in both those streams you need to pass data to the BG removalstream.

So the image/depth or skeleton stream might be trying to send data to the BGRemovalstream before it's even created/initialized.

Might not be the problem but it's something i'm seeing and would explain why the editor isn't giving any errors but it does when it's running.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top