Reputation: 696
I have a camera which I'm connecting to it thought its own APIs. To get a working code the camera manual has suggested to add these environment variables into the system.
I've set the following in the /etc/bash.bashrc
export PYLON_ROOT=/opt/pylon3
export GENICAM_ROOT_V2_3=${PYLON_ROOT}/genicam
mkdir -p $HOME/genicam_xml_cache
export GENICAM_CACHE_V2_3=$HOME/genicam_xml_cache
export LD_LIBRARY_PATH=${PYLON_ROOT}/lib64:${GENICAM_ROOT_V2_3}/bin/Linux64_x64:${GENICAM_ROOT_V2_3}/bin/Linux64_x64/GenApi/Generic:$LD_LIBRARY_PATH
when I run my qt code from terminal the code runs without any error. but When I run it from the Qtcreator it gives me the following error and terminate the program !
Environment Variable 'GENICAM_ROOT_V2_3' not found
I've added the environment variables code to /etc/profile too but the result were the same. why Qtcreator doesn't find my variables ?
.pro
QT += core
QT += gui
INCLUDEPATH += /opt/pylon3/include \
/opt/pylon3/genicam/library/CPP/include
LIBS += -L/opt/pylon3/lib64 \
-L/opt/GenICam_v2_3/bin/Linux64_x64 \
-L/opt/GenICam_v2_3/bin/Linux64_x64/GenApi/Generic \
-lgxapi \
-lpylonbase \
-lpylonbase-3.2.0 \
-lpylongigesupp \
-lpylonutility \
-lGCBase_gcc40_v2_3 \
-lGenApi_gcc40_v2_3 \
-llog4cpp_gcc40_v2_3 \
-lLog_gcc40_v2_3 \
-lMathParser_gcc40_v2_3 \
-lXerces-C_gcc40_v2_7 \
-lXMLLoader_gcc40_v2_3
TARGET = VLPR
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
CONFIG += link_pkgconfig
PKGCONFIG += opencv
Mainwindow.cpp
MainWindow::MainWindow(QObject *parent) :QObject(parent)
{
Initialize_Cam();
}
void MainWindow::Initialize_Cam()
{
MonoCamThr = new MonoCamThread(this);
MonoCamThr->Stop_Disp = true;
MonoCamThr->start();
MonoCamThr->Stop_Disp = false;
}
Monocam.cpp
MonoCamThread::MonoCamThread(QObject *parent) :
QThread(parent)
{
try
{
// List of cameras
DeviceInfoList_t m_Devices; // Still empty
// Create the unique transport layer factory object
// ... create the transport layer object
// ... create and initialise Cameras
CTlFactory& TlFactory = CTlFactory::GetInstance();
ITransportLayer *pTl = TlFactory.CreateTl( Camera_t::DeviceClass() );
if ( ! pTl )
{
throw GenericException(
"Failed to create transport layer!", __FILE__, __LINE__);
}
// Get all attached cameras and exit if no camera is found
m_Devices.clear();
if ( 0 == pTl->EnumerateDevices( m_Devices ) )
{
throw GenericException(
"No camera present!", __FILE__, __LINE__);
}
if(m_Devices.size()<2)
{
while(1)
{
qDebug() << "Number of Cameras are less than 2 .... \n" ;
}
}
qDebug() << "Number of Cameras are: "<<m_Devices.size()<<" \n" ;
// Restrict number of used camera
size_t nCameras = 2;
// Create all camera devices and set up the grab threads
if(pTl->CreateDevice( m_Devices[0])->GetDeviceInfo().GetModelName())
MonoCamera = new Camera_t( pTl->CreateDevice( m_Devices[1]) );
MonoCamera->Open();
MonoCamera->PixelFormat.SetValue( PixelFormat_Mono8 );
MonoCamera->OffsetX.SetValue( 0 );
MonoCamera->OffsetY.SetValue( 0 );
MonoCamera->Width.SetValue( MonoCamera->Width.GetMax() );
MonoCamera->Height.SetValue( MonoCamera->Height.GetMax() );
}
catch( GenericException &e )
{
qDebug() << "**** An exception occurred! Desription is: " << "\n"<< " " << e.GetDescription() << "\n";
}
}
void MonoCamThread::run()
{
while(!Stop_Disp)
{
//since this part of code never runs I didn' put the code for it ....
}
}
there are other cpp files but they run after camera initialization. I fixed this error once six month ago by adding GENICAM_ROOT_V2_3 PATH location to a system file in ubuntu like .bashrc or .profile but I don't remeber the file name right now !! :((
P.S Don't forget that this code runs in terminal and works fine ... the only problem is that Qt doesn't find the specified variable location !!!
Thanks
Upvotes: 1
Views: 2192
Reputation: 8061
I'm using Qt with a similar cam. I've set "Run settings" like you can see in this image.
Upvotes: 1