我有一个相机,我连接到它,认为它自己的API。为了获得工作代码,相机手册建议将这些环境变量添加到系统中。
我在/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当我从终端运行我的qt代码时,代码运行时没有任何错误。但是,当我从it创建者运行它时,它会给出以下错误并终止程序!
Environment Variable 'GENICAM_ROOT_V2_3' not found
我也将环境变量代码添加到/etc/profile中,但结果是相同的。为什么‘t创建者找不到我的变量?
.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 += opencvMainwindow.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 ....
}
}还有其他cpp文件,但它们在摄像机初始化后运行。六个月前,我修正了一次错误,将GENICAM_ROOT_V2_3路径位置添加到.bashrc或.profile之类的ubuntu系统文件中,但我现在不记得文件名了!!:(
别忘了这段代码在终端机上运行很好..。唯一的问题是Qt找不到指定的变量位置!
谢谢
发布于 2014-04-14 08:48:28
我用Qt和一个类似的摄像头。我设置了“运行设置”,就像您在这张图片中看到的那样。

https://stackoverflow.com/questions/23052991
复制相似问题