我試圖從單獨的項目中調用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.
我已經在很多方面,我會很高興的任何幫助或建議繼續在自己的圖書館使用這些共享庫嘗試過。