Using a dll input

Dear programmers,

I have a question which i don't know how to answer myself.

A part of my code:


#include <vector>
#include <pcl/io/openni_grabber.h>
#include <pcl/visualization/cloud_viewer.h>
using namespace std;

class KinectKernel {
public:
pcl::Grabber* interface;
vector<float> X, Y, Z;
vector<unsigned long> RGB;
bool bRun;
bool bCopying;
int width, height;
int beginU, endU;
int beginV, endV;
public:
KinectKernel ()
{
bCopying = bRun = false;
interface = NULL;
width = height = 0;
}

// point cloud callback
void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud)
{
if (bRun) {
while(bCopying)
Sleep(0);
bCopying=true;

width=endU-beginU;
height=endV-beginV;
X.resize(width*height);
Y.resize(width*height);
Z.resize(width*height);
RGB.resize(width*height);

float *pX = &X[0];
float *pY = &Y[0];
float *pZ = &Z[0];
unsigned long *pRGB = &RGB[0];

for (int j = beginV;j<endV;j++){
for (int i = beginU;i<endU;i++,pX++,pY++,pZ++,pRGB++){
pcl::PointXYZRGB P = cloud->at(i,j);
(*pX) = P.x;
(*pY) = P.y;
(*pZ) = P.z;
(*pRGB) = P.rgba;
}
}
bCopying = false;
}
}

};

extern "C" {
_declspec (dllexport) int GetSizeOfPointCloud(int* Ustart, int* Uend, int* Vstart, int* Vend);
_declspec (dllexport) int GetPointCloud(float *X, float *Y, float *Z, unsigned long *RGB, int cols, int rows);

} //extern "C"

KinectKernel kinect;

//DLL main
BOOL WINAPI DllMain (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved)
{
return TRUE;
}

}
_declspec (dllexport) int GetSizeOfPointCloud(int* Ustart,
int* Uend,
int* Vstart,
int* Vend)
{
kinect.beginU=(*Ustart);
kinect.endU=(*Uend);
kinect.beginV=(*Vstart);
kinect.endV=(*Vend);
return 0;
}

_declspec (dllexport) int GetPointCloud(float *X,
float *Y,
float *Z,
unsigned long *RGB,
int cols,
int rows)
{
if(cols!=kinect.width)
return -1;
if(rows!=kinect.height)
return -2;
while(kinect.bCopying)
Sleep(0);
kinect.bCopying = true;

memcpy(Z,&kinect.Z[0],cols*rows*sizeof(float));
memcpy(X,&kinect.X[0],cols*rows*sizeof(float));
memcpy(Y,&kinect.Y[0],cols*rows*sizeof(float));
memcpy(RGB,&kinect.RGB[0],cols*rows*sizeof(unsigned long));

kinect.bCopying=false;
return 0;
}


I would like to use the function "GetSizeOfPointCloud" as an input of four int32 values "beginU, endU, beginV and endV" in the // point cloud callback part of my code. This four inputs should control the two for loop statements.

The code builds successfully but does not work.
I have no idea how to do this. Thank you in advance for your time and effort.

Best regards,
K
Last edited on
Topic archived. No new replies allowed.