How to include and link Pylon library with OpenCV project [closed]
I am trying to access images from a Basler camera interfaced with a Jetson TX1. I am using OpenCV-C++
along with Pylon
library to do so. I am trying to link the Pylon
using cmake
. I have the following CMakeLists.txt file:
cmake_minimum_required(VERSION 3.5.1)
project(basler_test)
set(CMAKE_CXX_STANDARD 14)
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl, -E")
find_package(OpenCV REQUIRED)
include_directories(/opt/pylon5/include)
link_directories(/opt/pylon5/lib64)
add_executable(basler_test basler_test.cpp)
target_link_libraries(basler_test ${OpenCV_LIBS} /opt/pylon5/include/pylon/PylonIncludes.h)
The cmake .
command works fine but when I do make
, it gives:
fatal error: pylon/Platform.h: No such file or directory
compilation terminated
I checked for the above file and it does exist in the same directory as PylonIncludes.h
. So, I believe this error is because something has not been set properly in the CMakeLists.txt
. I don't have enough experience creating them to identify what's wrong. Kindly help.
Edit: Here is the relevant part of the source file: basler_test.cpp
//This is a test program to check the functionality of Basler dart daA2500-14uc Camera.
#define saveImages 0
#define recordVideo 1
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/video.hpp>
#include <pylon/PylonIncludes.h>
#ifdef PYLON_WIN_BUILD
#include <pylon/PylonGUI.h>
#endif
static const uint32_t c_countOfImagesToGrab = 10;
int main(int argc, char* argv[])
{
...................................
..................................
}
your question is not relative opencv but cmake. When i have got that's sort of problem I give full path in include directive. It does not really solve your problem but you should be able to compile your source file.
I added it here because I felt someone might have tried accessing Basler camera via OpenCV and may have figured out how to properly include
Pylon
inCMakeLists.txt
.try with
# include </opt/pylon5/include/pylon/PylonIncludes.h>
and replace target_link_libraries(basler_test ${OpenCV_LIBS} /opt/pylon5/include/pylon/PylonIncludes.h) with target_link_libraries(basler_test ${OpenCV_LIBS} pathtopylonlibs)That did not fix the issue. This time
cmake .
gave a warning that it was dropping the third argument oftarget_link_libraries
andmake
reports a lot of undefined references."a lot of undefined references." in compilation or linking ?
and have you try to copy this file
How to check whether it is in compilation or linking?
Anyways, I have figured what is wrong and I am adding it as an answer.
I did see that file and I thought it was only necessary if I was trying to add the library using
find_package()
.I have to wait a day to add the answer, according to OpenCV forum rules. Anyways, thank you for the help.
if my memory is good create a folder cmake where is your cmakelist.txt. write this file and add findpackage(Pylon) in cmakeklist.txt and ${PYLON_LIBRARIES} for libs ${PYLON_INCLUDE_DIRS} for inculde (PS i'm not a cmake expert)