1
votes

I tried to make console application that is using my DLL that is taking care of Kinect. When I am building my project I get:

2>e:\projects\c++\vs\kinect dll\consoleapplication1\consoleapplication1.cpp(4): warning C4627: '#include "KinectDLL.h"': skipped when looking for precompiled header use 2> Add directive to 'stdafx.h' or rebuild precompiled header 2> e:\michał\projects\c++\vs\kinect dll\kinect dll\depthreader.h(4): fatal error C1083: Cannot open include file: 'NuiApi.h': No such file or directory

Note: ConsolApplication1 and Kinect DLL are 2 projects in the same solution, first one have one dependency – Kinect DLL project as DLL. I have “use precompile headers” turned off in both projects!

Kinect DLL projects:

KinectDLL.h:

#ifdef KINECTDLL_EXPORTS
#define KINECTDLL_API __declspec(dllexport) 
#else
#define KINECTDLL_API __declspec(dllimport) 
#endif

DepthReader.h:

#pragma once
#include <ole2.h>
#include <Windows.h>
#include "NuiApi.h"
#include "KinectDLL.h"

namespace KinectDLL{

    class DepthReader{

        static KINECTDLL_API const int        depthWidth  = 640;
        static KINECTDLL_API const int        depthHeight = 480;
        static KINECTDLL_API const int        bytesPerPixel = 4;
    public:
        KINECTDLL_API DepthReader(void);
        KINECTDLL_API ~DepthReader(void);

        KINECTDLL_API int Run(HINSTANCE hInstance, int nCmdShow);
    private:
        HANDLE depthStreamHandle;
        HANDLE nextDepthFrameEvent;
        HANDLE depthStream;
        BYTE* depthRGBX;
        bool nearMode;
        INuiSensor* sensor;
        //HWND m_hWnd;
        HRESULT CreateFirstConnected();
        void Update();
        void ProcessDepth();
    };
}

DepthReader.cpp

#include "stdafx.h"
#include "DepthReader.h"
namespace KinectDLL{
    DepthReader::DepthReader(void) :
        nextDepthFrameEvent(INVALID_HANDLE_VALUE),
        depthStreamHandle(INVALID_HANDLE_VALUE),
        nearMode(false),
        sensor(NULL)
    {
        // create heap storage for depth pixel data in RGBX format
        depthRGBX = new BYTE[depthWidth*depthHeight*bytesPerPixel];
    }

… and so on, mostly copy and pase from MS Kinect examples...

Consoleapplication1 project:

Consolapplication1.cpp:

#include "KinectDLL.h"
#include "stdafx.h"
#include "Rotations.h"
#include "Camera.h"
#include "FileLoader.h"
#include "DepthReader.h"

using namespace std;

Camera camera;
Rotations rotations;
FileLoader fileLoader;
KinectDLL::DepthReader depthReader;

… then there is OpenGL, points from file. I am using Kinect to contole the scene, not to display data from it. No depthReader for now.

Clearly I am doing something stupid but I can't see what. I am reading Microsoft examples about DLL in VC++ but I can't see what is wrong.

1

1 Answers

0
votes

I have just finished created a dll with some functions that depend on the skeleton stream from the kinect. What I did was something like this:

#ifdef KINECTFUNCTIONSDLL_EXPORTS
#define KINECTFUNCTIONSDLL_API __declspec(dllexport) 
#else
#define KINECTFUNCTIONSDLL_API __declspec(dllimport)  
#endif


#include <Windows.h>
#include <NuiApi.h>
using namespace std;
#include <string>
namespace KinectFunctions{

    class GestureRecognizer
{

 public:
  Vector4 KINECTFUNCTIONSDLL_API resta(Vector4 vector1,Vector4 vector2);
 }
}

and now for the .cpp:

#include "KinectFunctionsDLL.h"
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <fstream>
using namespace std;

namespace KinectFunctions{

Vector4 GestureRecognizer::resta(Vector4 vector1,Vector4 vector2){
 Vector4 salida;
 salida.x=vector1.x-vector2.x;
 salida.y=vector1.y-vector2.y;
 salida.z=vector1.z-vector2.z;
 return salida;
 }

}

Keep in mind that the project you use to create the dll must be created checking the DLL option (it's a checkbox that appears when you choose to create a new project. Like it is shown here: https://www.youtube.com/watch?v=yEqRyQhhto8

And of course you need to add the dependencies for the kinect dll, the kinect10.lib and the headers, like in any project where you want to use the device.