PointCloud SDK compiling errors

Post Reply
jonwieser
Posts: 1
Joined: Tue Dec 30, 2008 11:14 am

PointCloud SDK compiling errors

Post by jonwieser »

I took the PointCloud SDK WIN32 Sample application and incorporated the Opitrack GreyScale sample application.
I'm getting the following errors when compiling my c++ program

Error 1 error LNK2019: unresolved external symbol "int __cdecl ptc_update(void *)" (?ptc_update@@YAHPAX@Z) referenced in function _main Main.obj
Error 2 error LNK2019: unresolved external symbol "int __cdecl ptc_open(char *,int,int)" (?ptc_open@@YAHPADHH@Z) referenced in function _main Main.obj

I am compiling with Microsoft visual studio. How can I fix these errors?
Jon


Here is my program


//========================================================================-----
//== Point Cloud SDK WIN32 Sample Application
//== Copyright NaturalPoint
//==
//== This sample is intended to show how to properly access and control
//== the Point Cloud SDK. The application does the following:
//==
//== 1. Initializes the Point Cloud COM Component.
//== 2. Loads a camera calibration profile.
//== 3. Starts the cameras.
//== 4. Displays marker count. If there is 1 marker it will display
//== the 3D position of that marker.
//== 5. When a key is pressed the cameras are stopped and the application
//== shuts down.
//==
//== INCLUDES ============================================================-----

#include "stdafx.h"
#include //== For sample simplicity: kbhit()
#include //== SysAllocString (to pass filename)
#include
//== NECESSARY POINT CLOUD INCLUDES AND DEFINITIONS ======================-----


#include
#include


//== INCLUDES ============================================================-----

#include "tinyptc.h"
void ptc_close(void);
int ptc_update(void *);
int ptc_open(char *, int,int);

//== NECESSARY OPTITRACK INCLUDES AND DEFINITIONS ========================-----

#include
#include
#include "./optitrack.h"
#import "./optitrack.tlb"
#include "PointCloud.h"
#import "PointCloud.tlb"

static int noise;
static int carry;
static int index;
static int seed = 0x12345;
static int pixel[640*480];
static unsigned char frameBuffer[640*480];
bool TimeToClose = false;


//== SAMPLE APPLICATION ENTRY POINT ======================================-----

//int _tmain(int argc, _TCHAR* argv[])
int main()
{
//code for Camera Display
//== Initialize Microsoft COM Interop ================----
CoInitialize(NULL);

//== Initialize OptiTrack COM Component ==============----
CComPtr cameraCollection;
CComPtr camera;
CComPtr frame1;

// cameraCollection.CoCreateInstance(CLSID_NPCameraCollection);
cameraCollection.CoCreateInstance(__uuidof(NPCameraCollection));


//== Enumerate (Identify) Available Cameras ==========----
cameraCollection->Enum();

long cameraCount = 0;
int frameCounter = 0;

//== Determine Available Cameras =====================----
cameraCollection->get_Count(&cameraCount);
printf("camera count= %d\n", cameraCount);
int windowWidth = 0;
int windowHeight = 0;
int index = 0;

//== Display Camera Information for All Cameras ======----
for(index=0; indexFree();
frame1.Release();
}
else
{
printf("0\n");
}
printf("got here!\n");
cameraCollection->Item(index, &camera);

long serial,width,height,model,revision,rate;

camera->get_SerialNumber(&serial);
camera->get_Width (&width);
camera->get_Height (&height);
camera->get_Model (&model);
camera->get_Revision (&revision);
camera->get_FrameRate (&rate);

if(index==0)
{
windowWidth = width;
windowHeight = height;
}

//== Set Some Camera Options ====================----

//== Set Grayscale Mode =========================----
camera->SetOption(NP_OPTION_VIDEO_TYPE , (CComVariant) 1 );

//== Don't drop frames ==--
camera->SetOption(NP_OPTION_FRAME_DECIMATION , (CComVariant) 0 );

//== Display 99 on the Camera ===================----
//== Note: This only works for cameras with a display
camera->SetOption(NP_OPTION_NUMERIC_DISPLAY_ON, (CComVariant) 99);

//== Add frame information to the top left of the frame ==--
camera->SetOption(NP_OPTION_TEXT_OVERLAY_OPTION,(CComVariant) 255);

//== Send corrupt frames ==
camera->SetOption(NP_OPTION_SEND_FRAME_MASK,(CComVariant) 255);

//== Slow camera frame frame to 25% ==--
camera->SetOption(NP_OPTION_FRAME_RATE,(CComVariant) 25);

//== Always Clean-up COM Objects ================----
camera.Release();
}

//== Open the first camera ==========================----

if(cameraCount>0)
{
if (!ptc_open("OptiTrack Grayscale Sample", windowWidth, windowHeight)) return 1;

cameraCollection->Item(0, &camera);
{
camera->Open();
camera->Start();
camera->SetOption(NP_OPTION_EXPOSURE, (CComVariant) 305);
{
while(!TimeToClose)
{
Sleep(10);

MSG msg;
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if(GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

camera->GetFrame(0, &frame1);

if(frame1!=0)
{
//== New Frame Has Arrived ==========================------
frameCounter++;

camera->GetFrameImage(frame1, windowWidth, windowHeight, windowWidth, 8, (byte *) frameBuffer);

for (int index=0; indexFree();
frame1.Release();
}
}
}
camera->Stop();
camera->Close();
}

camera.Release();
}


//== Always Clean-up COM Objects ================----
cameraCollection.Release();

//== Uninitialize Microsoft COM Interop =============----
CoUninitialize();

//ExitProcess(1);


printf("OptiTrack Point Cloud Win32 Sample Application ================================\n");
printf("Copyright NaturalPoint ==================================================------\n\n");
printf("\n");
printf("Note: For this demo to work properly, run the camera calibration tool to create\n");
printf(" a camera calibration profile. Copy the calibration profile into the same\n");
printf(" directory as this demo using the filename \"Calibration Result.cal\".\n\n");
printf("Press any key to exit\n\n");

//== Initialize Microsoft COM Interop =================================----
CoInitialize(NULL);

//== Initialize OptiTrack COM Component ===============================----
CComPtr pointCloud;
CComPtr frame;
CComPtr point;
HRESULT result;

pointCloud.CoCreateInstance(_uuidof(NPPointCloud));

//== Load Calibration File ============================================----

BSTR Filename = ::SysAllocString(L"Calibration Result.cal");

result = pointCloud->LoadProfile(Filename);

switch(result)
{
case NP_POINTCLOUD_FILE_NOT_FOUND:
printf("Calibration file not found\n");
break;
case NP_POINTCLOUD_LOAD_FAILED:
printf("Failed to load calibration file\n");
break;
case NP_POINTCLOUD_FAILED:
printf("Load failed\n");
break;
default:
printf("Camera Calibration Profile loaded\n\n");
break;
}

if(result==S_OK)
{
//== Display Point Cloud Camera Count =============================----

long cameraCount;

pointCloud->get_CameraCount(&cameraCount);

printf("Point Cloud Cameras: %d\n\n", cameraCount);

//== Show Camera Information For Each Camera ======================----

for(int i=0; i camera;

pointCloud->GetCamera(i, &camera);

double x,y,z;
double camMatrix[9];

camera->get_X(&x);
camera->get_Y(&y);
camera->get_Z(&z);

for(int j=0; jGetRotationMatrix(j,&camMatrix[j]);

printf("Camera #%d located @ (%2.3f,2.3%f,2.3%f)\n",i, x,y,z);
printf(" -->> Orientation Matrix: [ %2.3f,2.3%f,2.3%f ]\n",camMatrix[0],camMatrix[1],camMatrix[2]);
printf(" [ %2.3f,2.3%f,2.3%f ]\n",camMatrix[3],camMatrix[4],camMatrix[5]);
printf(" [ %2.3f,2.3%f,2.3%f ]\n",camMatrix[6],camMatrix[7],camMatrix[8]);
printf("\n");

camera.Release();
}

double x=0, y=0, z=0, key=0;
float range=0.0;

// user enters distance range from origin

printf("Please enter the range(meters):\n");
scanf_s("%f",&range);

//range = 0.2;
printf("range = %f\n",range);
printf("Starting Point Cloud Capture...\n\n");
pointCloud->Start(); //== Start capturing 3D marker data ===========---

int frameCounter = 0;

double originx=0, originy=0, originz=0;
int c=0, dur=0;
double freq=0;
int freq1=0;
double dist=0.0;

while(!_kbhit())
{
//== Check for incoming point cloud frames =========================---

pointCloud->GetFrame(&frame);

if(frame!=NULL)
{
//== Process incoming frame ====================================---
long markerCount;
frame->get_Count(&markerCount);
if(((frameCounter++)&4)==0) //== Only display every 5 frames ---
{
printf("Frame #%4d: %d Markers \n", frameCounter, markerCount);
if(c==0)
{
printf("Please press any key to initialize origin:\n");
//scanf_s("%f\n",&key);
getchar();
}
if(markerCount>=1)
{

frame->Item(0, &point); //== Get 3D Marker Details =====---
if(point!=NULL)
{
point->get_X(&x); //== Get marker location =======---
point->get_Y(&y);
point->get_Z(&z);
}

printf("Marker #1 Location: (%2.5f,%2.5f,%2.5f)\n",x,y,z);

if(c==0)
{
// set current position of marker to origin
printf("Initializing origin\n");
originx=x; originy=y; originz=z;
c=1;
printf ("origin (x y z)=(%2.5f,%2.5f,%2.5f)\n",originx,originy,originz);
}

dist = sqrt(pow(x-originx,2)+pow(y-originy,2)+pow(z-originz,2));
printf("Marker Distance from origin: %2.5f\n",dist);

if(dist > range)
{
//printf("warning!!!\n");
dur = 17; //tone duration (ms)
freq = 750+(dist*10000); //tone freq proprotional to distance from origin
freq1 = int(freq);
Beep(freq1,dur);
}
point.Release(); //== Done with point, release it ======---
}
else
printf("\n");
}

frame.Release(); //== Done with frame, release it ======---
}

//== Pump Messages and Hibernate momentarily =======================---

//Sleep(5);

MSG msg;
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if(GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}

printf("\nStopping Point Cloud Capture...\n");

pointCloud->Stop(); //== Stop capturing 3D marker data ========---
}

printf("Shutting down...\n");
//== Always Clean-up COM Objects ================----
pointCloud.Release();

//== Uninitialize Microsoft COM Interop =============----
CoUninitialize();

printf("Application Exit.\n");
getchar();
return 0;
}
JameBUYv
Posts: 1
Joined: Sun Dec 23, 2018 1:25 pm
Location: Colombia
Contact:

PointCloud SDK compiling errors

Post by JameBUYv »

Indeed very strange to see std linker errors - as Irrlicht doesnt use the standard library at all. I dont think we are to blame here.
Post Reply