Ask Your Question
0

How to include and link Pylon library with OpenCV project [closed]

asked 2017-10-03 14:01:23 -0600

skr_robo gravatar image

updated 2017-10-03 14:20:01 -0600

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[])
{
         ...................................
         ..................................
}
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by skr_robo
close date 2018-03-26 11:17:41.730239

Comments

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.

LBerger gravatar imageLBerger ( 2017-10-03 14:13:29 -0600 )edit

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 in CMakeLists.txt.

skr_robo gravatar imageskr_robo ( 2017-10-03 14:21:37 -0600 )edit

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)

LBerger gravatar imageLBerger ( 2017-10-03 14:26:53 -0600 )edit

That did not fix the issue. This time cmake . gave a warning that it was dropping the third argument of target_link_libraries and make reports a lot of undefined references.

skr_robo gravatar imageskr_robo ( 2017-10-03 14:39:21 -0600 )edit

"a lot of undefined references." in compilation or linking ?

and have you try to copy this file

LBerger gravatar imageLBerger ( 2017-10-03 15:30:18 -0600 )edit

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.

skr_robo gravatar imageskr_robo ( 2017-10-03 15:33:09 -0600 )edit

I did see that file and I thought it was only necessary if I was trying to add the library using find_package().

skr_robo gravatar imageskr_robo ( 2017-10-03 15:34:15 -0600 )edit
1

I have to wait a day to add the answer, according to OpenCV forum rules. Anyways, thank you for the help.

skr_robo gravatar imageskr_robo ( 2017-10-03 15:37:27 -0600 )edit
1

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)

LBerger gravatar imageLBerger ( 2017-10-03 15:42:38 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-03-26 04:00:27 -0600

Igor gravatar image

In CMakeLists.txt uncomment the 9th line:

cmake_minimum_required(VERSION 2.8.3)
project(basler_camera)

find_package(catkin REQUIRED COMPONENTS roscpp image_transport camera_info_manager cv_bridge)
find_package(OpenCV REQUIRED)

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES basler_camera
#  CATKIN_DEPENDS roscpp
#  DEPENDS system_lib
)
edit flag offensive delete link more

Comments

@Igor I had already solved it earlier and now I don't have a way of checking the solution. Sorry.

skr_robo gravatar imageskr_robo ( 2018-03-26 11:18:23 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-10-03 14:01:23 -0600

Seen: 3,239 times

Last updated: Oct 03 '17