我试图从单独的项目中调用pylon5 C++库,但没有成功。如何在Raspberry Pi中使用Basler GigE相机pylon5 C++库
我一直在寻找一个答案,但只是无法弄清楚我做错了什么。
我想我的问题可能是设置环境变量和/或库路径? (我是基于Linux的初学者,当在网上阅读教程时,我容易对某些显而易见的东西感到困惑,但我不知道)
我测试过相机本身正在使用我的树莓和我可以通过使用示例代码抓取图像。
我甚至可以修改相机设置(曝光时间等)并拍照并保存到我的SD卡。所以相机模块不是问题。我的问题更可能是以正确的方式使用共享库。
此外我做了一些简单的共享库,希望能够使用我的Pylon相机代码。当我在库中不包含任何Pylon代码时,它工作正常并返回我想要的值。我甚至可以在那里添加Pylon头文件,它仍然可以很好地编译。然后再次我可以从另一个(在这种情况下是C#)代码中调用我的lib,并按照预期得到返回值,但当尝试调用任何Pylon代码时(在我的库中),将导致'dllNotFoundException'。
我已经把我的pylon5代码在/ opt/pylon5为劝,我从baslerweb.com
http://s.baslerweb.com/media/documents/How%20to%20build%20pylon%20applications%20on%20Raspberry%20Pi.pdf
这里得到了手册中我的项目文件(我用QtCreator)
#-------------------------------------------------
QT -= gui
QT += core
TARGET = baslercamera
TEMPLATE = lib
DEFINES += BASLERCAMERA_LIBRARY
SOURCES += baslercamera.cpp \
Grab.cpp \
Image.cpp \
main.cpp \
BaslerDLL.cpp
HEADERS += baslercamera.h\
baslercamera_global.h \
Image.h \
Grab.h
unix {
target.path = /usr/lib
INSTALLS += target
}
#INCLUDEPATH += $$PWD/../pylon5/include
#DEPENDPATH += $$PWD/../pylon5/include
INCLUDEPATH += /opt/pylon5/include
DEPENDPATH += /opt/pylon5/include
INCLUDEPATH += /home/pi/baslercamera/
DEPENDPATH += /home/pi/baslercamera/
LIBS += "/opt/pylon5/lib" \
-lpylonc
正如你所看到的INCLUDEPATH和LIBS变量是我的弱点。我无法弄清楚我应该包含哪些库以及如何正确包含它们。除了将它们包含在我的项目文件之外,我应该设置一些环境变量吗?
我也尝试设置一些库路径,但我不知道我应该在那里做什么。用户手册说
Set the pylon environment variables:
# source ./pylon4/bin/pylon-setup-env.sh pylon4
我跟着这个,用pylon5取代pylon4。我认为这可能会设置环境变量来使用pylon库。但我不确定那里会发生什么。该塔5指南说:
Environment Variables
=====================
From pylon 5.0 upwards, no additional environment variables are required to
run pylon-based applications.
For development, though, the compiler must know where pylon is installed.
The pylon samples use the environment variable PYLON_ROOT to find the relevant information.
For your convenience, we created the pylon-setup-env.sh script located in the
pylon5/bin directory which can carry out the complete setup.
To setup the environment for a pylon installation in <path> execute:
source <path>/bin/pylon-setup-env.sh <path>
If you want the environment for the standard installation to be persistent, you
can add
source /path/to/your/pylon5/bin/pylon-setup-env.sh /path/to/your/pylon5
to ~/.bashrc
For special use cases, you can do a manual environment setup as follows:
export PYLON_ROOT=/path/to/your/pylon5
Even though there is currently only one variable needed, using pylon-setup-env.sh
is still the preferred way to set up your environment, as we might add more variables
in the future.
我已经在很多方面,我会很高兴的任何帮助或建议继续在自己的图书馆使用这些共享库尝试过。