PDA

Visualizza la versione completa : [C++] Errore compilazione: LNK1120 Unresolved external


iljakie
16-07-2017, 14:17
Salve ragazzi, nel codice postato qui sotto ho il seguente errore di compilazione. Uso visual studio 2010.

6>FirstSample.obj : error LNK2019: unresolved external symbol "public: bool __thiscall SavePointCloud::onImageGrabbed(struct GenTLConsumerImplHelper::GrabResult,class std::vector<struct GenTLConsumerImplHelper::PartInfo,class std::allocator<struct GenTLConsumerImplHelper::PartInfo> >)" (?onImageGrabbed@SavePointCloud@@QAE_NUGrabResult@ GenTLConsumerImplHelper@@V?$vector@UPartInfo@GenTL ConsumerImplHelper@@V?$allocator@UPartInfo@GenTLCo nsumerImplHelper@@@std@@@std@@@Z) referenced in function "public: int __thiscall SavePointCloud::run(void)" (?run@SavePointCloud@@QAEHXZ)
6>C:\Users\sony\Desktop\Basler\ToF\Samples\Cpp\Debug \FirstSample.exe : fatal error LNK1120: 1 unresolved externals

Qualcuno ha un idea di cosa voglia dire?


#include "stdafx.h"
#include <ConsumerImplHelper/ToFCamera.h>
#include <iostream>
#include <iomanip>


#if defined (_MSC_VER) && defined (_WIN32)
// You have to delay load the GenApi libraries used for configuring the camera device.
// Refer to the project settings to see how to instruct the linker to delay load DLLs.
// ("Properties->Linker->Input->Delay Loaded Dlls" resp. /DELAYLOAD linker option).
# pragma message( "Remember to delayload these libraries (/DELAYLOAD linker option):")
# pragma message( " /DELAYLOAD:\"" DLL_NAME("GCBase") "\"")
# pragma message( " /DELAYLOAD:\"" DLL_NAME("GenApi") "\"")
#endif










#include <GenTL/PFNC.h>
#include <string>


#include <fstream>


#include <stdio.h>
#include <cstdio>
#include <sstream>




using namespace GenTLConsumerImplHelper;
using namespace GenApi;
using namespace std;


void WritePcdHeader( ostream& o, size_t width, size_t height, bool saveIntensity )
{
o << "# .PCD v0.7 - Point Cloud Data file format" << endl;
o << "VERSION 0.7" << endl;
o << "FIELDS x y z rgb" << endl;
o << "SIZE 4 4 4";
if ( saveIntensity )
o << " 4";
o << endl;


o << "TYPE F F F";
if ( saveIntensity )
o << " F";
o << endl;


o << "COUNT 1 1 1";
if ( saveIntensity )
o << " 1";
o << endl;


o << "WIDTH " << width << endl;
o << "HEIGHT " << height << endl;
o << "VIEWPOINT 0 0 0 1 0 0 0" << endl;
o << "POINTS " << width * height << endl;
o << "DATA ASCII" << endl;
}












using namespace GenTLConsumerImplHelper;
using namespace std;


class SavePointCloud
{
public:
int run();


bool onImageGrabbed( GrabResult grabResult , BufferParts );


private:
CToFCamera m_Camera;
int m_nBuffersGrabbed;
};








int SavePointCloud::run()
{
m_nBuffersGrabbed = 0;


try
{
// Open the first camera found, i.e., establish a connection to the camera device.
m_Camera.OpenFirstCamera();


/* CToFCamera::OpenFirstCamera() is a shortcut for the following sequence:
CameraList cameras = CToFCamera::EnumerateCameras();
CameraInfo camInfo = *cameras.begin();
m_Camera.Open(camInfo);


If there are multiple cameras connected and you want to open a specific one, use
the CToFCamera::Open( CameraInfoKey, string ) method.

Example: Open a camera using its IP address
CToFCamera::Open( IpAddress, "192.168.0.2" );


Instead of the IP address, any other property of the CameraInfo struct can be used,
e.g., the serial number or the user-defined name:


CToFCamera::Open( SerialNumber, "23167572" );
CToFCamera::Open( UserDefinedName, "Left" );
*/


cout << "Connected to camera " << m_Camera.GetCameraInfo().strDisplayName << endl;


// Enable 3D (point cloud) data, intensity data, and confidence data.
GenApi::CEnumerationPtr ptrComponentSelector = m_Camera.GetParameter("ComponentSelector");
GenApi::CBooleanPtr ptrComponentEnable = m_Camera.GetParameter("ComponentEnable");
GenApi::CEnumerationPtr ptrPixelFormat = m_Camera.GetParameter("PixelFormat");


// Enable range data.
ptrComponentSelector->FromString("Range");
ptrComponentEnable->SetValue(true);
// Range information can be sent either as a 16-bit grey value image or as 3D coordinates (point cloud). For this sample, we want to acquire 3D coordinates.
// Note: To change the format of an image component, the Component Selector must first be set to the component
// you want to configure (see above).
// To use 16-bit integer depth information, choose "Mono16" instead of "Coord3D_ABC32f".
ptrPixelFormat->FromString("Coord3D_ABC32f" );


ptrComponentSelector->FromString("Intensity");
ptrComponentEnable->SetValue(true);


ptrComponentSelector->FromString("Confidence");
ptrComponentEnable->SetValue(true);


// Acquire images until the call-back onImageGrabbed indicates to stop acquisition.
// 5 buffers are used (round-robin).
m_Camera.GrabContinuous( 50, 500, this, &SavePointCloud::onImageGrabbed );


// Clean-up
m_Camera.Close();
}
catch ( const GenICam::GenericException& e )
{
cerr << "Exception occurred: " << e.GetDescription() << endl;
// After successfully opening the camera, the IsConnected method can be used
// to check if the device is still connected.
if ( m_Camera.IsOpen() && ! m_Camera.IsConnected() )
{
cerr << "Camera has been removed." << endl;
}


return EXIT_FAILURE;
}


return EXIT_SUCCESS;
}






bool SavePointCloud( const BufferParts parts, const char* fileName )
{
if ( parts.empty() )
{
cerr << "No valid image data." << endl;
return false;
}


// If the point cloud is enabled, the first part always contains the point cloud data.
if ( parts[0].dataFormat != PFNC_Coord3D_ABC32f )
{
cerr << "Unexpected data format for the first image part. Coord3D_ABC32f is expected." << endl;
return false;
}


const bool saveIntensity = parts.size() > 1;
if ( saveIntensity && parts[1].dataFormat != PFNC_Mono16 )
{
cerr << "Unexpected data format for the second image part. Mono 16 is expected." << endl;
return false;
}


ofstream o( fileName );
if ( ! o )
{
cerr << "Error:\tFailed to create file "<< fileName << endl;
return false;
}


CToFCamera::Coord3D *pPoint = (CToFCamera::Coord3D*) parts[0].pData;
uint16_t *pIntensity = saveIntensity ? (uint16_t*) parts[1].pData : NULL;
const size_t nPixel = parts[0].width * parts[0].height;


WritePcdHeader( o, parts[0].width, parts[0].height, saveIntensity );


for ( size_t i = 0; i < nPixel; ++i )
{
// Check if there are valid 3D coordinates for that pixel.
if ( pPoint->IsValid() )
{
o.precision( 0 ); // Coordinates will be written as whole numbers.

// Write the coordinates of the next point. Note: Since the coordinate system
// used by the CloudCompare tool is different from the one used by the ToF camera,
// we apply a 180-degree rotation around the x-axis by writing the negative
// values of the y and z coordinates.
o << std::fixed << pPoint->x << ' ' << -pPoint->y << ' ' << -pPoint->z;

if ( saveIntensity )
{
// Save the intensity as an RGB value.
uint8_t gray = *pIntensity >> 8;
uint32_t rgb = (uint32_t) gray << 16 | (uint32_t) gray << 8 | (uint32_t) gray;
// The point cloud library data format represents RGB values as floats.
float fRgb = * (float*) &rgb;
o.unsetf(ios_base::floatfield); // Switch to default float formatting
o.precision(9); // Intensity information will be written with highest precision.
o << ' ' << fRgb << endl;
}
}
else
{
o << "nan nan nan 0" << endl;
}
pPoint++;
pIntensity++;
}
o.close();
cout << "done." << endl;
return true;
}










//bool Sample::onImageGrabbed( GrabResult grabResult, BufferParts parts )
//{
// if ( grabResult.status == GrabResult::Timeout )
// {
// cerr << "Timeout occurred. Acquisition stopped." << endl;
// // The timeout might be caused by a removal of the camera. Check if the camera
// // is still connected.
// if ( ! m_Camera.IsConnected() )
// {
// cerr << "Camera has been removed." << endl;
// }
//
// return false; // Indicate to stop acquisition
// }
// m_nBuffersGrabbed++;
// if ( grabResult.status != GrabResult::Ok )
// {
// cerr << "Image " << m_nBuffersGrabbed << "was not grabbed." << endl;
// }
// else
// {
// // Retrieve the values for the center pixel
// const int width = (int) parts[0].width;
// const int height = (int) parts[0].height;
// const int x = (int) (0.5 * width);
// const int y = (int) (0.5 * height);
// CToFCamera::Coord3D *p3DCoordinate = (CToFCamera::Coord3D*) parts[0].pData + y * width + x;
// uint16_t *pIntensity = (uint16_t*) parts[1].pData + y * width + x;
// uint16_t *pConfidence = (uint16_t*) parts[2].pData + y * width + x;
//
// cout << "Center pixel of image " << setw(2) << m_nBuffersGrabbed << ": ";
// cout.setf( ios_base::fixed);
// cout.precision(1);
// if ( p3DCoordinate->IsValid() )
// cout << "x=" << setw(6) << p3DCoordinate->x << " y=" << setw(6) << p3DCoordinate->y << " z=" << setw(6) << p3DCoordinate->z;
// else
// cout << "x= n/a y= n/a z= n/a";
// cout << " intensity="<< setw(5) << *pIntensity << " confidence=" << setw(5) << *pConfidence << endl;
// }
// return m_nBuffersGrabbed < 10; // Indicate to stop acquisition when 10 buffers are grabbed
//}


int main(int argc, char* argv[])
{
int exitCode = EXIT_SUCCESS;

try
{
CToFCamera::InitProducer();


SavePointCloud ;




exitCode = EXIT_SUCCESS;
}
catch ( GenICam::GenericException& e )
{
cerr << "Exception occurred: " << endl << e.GetDescription() << endl;
exitCode = EXIT_FAILURE;
}


// Release the GenTL producer and all of its resources.
// Note: Don't call TerminateProducer() until the destructor of the CToFCamera
// class has been called. The destructor may require resources which may not
// be available anymore after TerminateProducer() has been called.
if ( CToFCamera::IsProducerInitialized() )
CToFCamera::TerminateProducer(); // Won't throw any exceptions


cout << endl << "Press Enter to exit." << endl;
while (cin.get() != '\n');


return exitCode;
}

oregon
16-07-2017, 17:24
Significa che il compilatore non trova il codice di


SavePointCloud::onImageGrabbed

Loading