I am trying to get a C++ program for capturing images using a Basler camera to work. I got the code from the manufacturer and it was supposed to be "very easy to use", however, linking it has become a nightmare. My C++ times are in the past (only using Matlab lately), so I might be making some stupid mistake, but please enlighten me:
The code looks like this:
// Include files to use the PYLON API.
#include <pylon/PylonIncludes.h>
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
// Namespace for using pylon objects.
using namespace Pylon;
using namespace GenApi;
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/video/video.hpp>
//#include <opencv2/videoio.hpp>
using namespace cv;
// Namespace for using cout.
using namespace std;
#include <stdio.h>
#include "kbhit.h"
#include <sys/stat.h> // for checking the file size
#include <sstream>
// Number of images to be grabbed.
//static const uint32_t c_countOfImagesToGrab = 100;
int main(int argc, char* argv[])
{
// The exit code of the sample application.
int exitCode = 0;
// Automagically call PylonInitialize and PylonTerminate to ensure the pylon runtime system
// is initialized during the lifetime of this object.
Pylon::PylonAutoInitTerm autoInitTerm;
VideoWriter cvVideoCreator;
struct stat statbuf;
string filenameBase = "/opt/PylonTestAVI";
uint filecounter = 1;
string filename = "";
... (and so on)
I am trying to compile it using the following:
g++ GrabV3.cpp -I/opt/pylon5 -I/opt/pylon5/include -I/usr/local/include -I/usr/include/ -L/opt/pylon5/lib64
Here /opt/pylon5 is Basler's own library and /usr/local/include links to the opencv4 folder.
I get a page-long error message list - the start looks like this
GrabV3.cpp:(.text+0x2a5): undefined reference to cv::VideoWriter::VideoWriter()'
GrabV3.cpp:(.text+0x32a): undefined reference to
Pylon::CTlFactory::GetInstance()'
GrabV3.cpp:(.text+0x346): undefined reference to Pylon::CDeviceInfo::CDeviceInfo()'
GrabV3.cpp:(.text+0x370): undefined reference to
Pylon::CInstantCamera::CInstantCamera(Pylon::IPylonDevice, Pylon::ECleanup)'
GrabV3.cpp:(.text+0x38e): undefined reference to Pylon::CInstantCamera::Open()'
GrabV3.cpp:(.text+0x39d): undefined reference to
Pylon::CInstantCamera::GetNodeMap()'
GrabV3.cpp:(.text+0x3cb): undefined reference to GenICam_3_1_Basler_pylon::gcstring::gcstring(char const*)'
GrabV3.cpp:(.text+0x41b): undefined reference to
GenICam_3_1_Basler_pylon::gcstring::~gcstring()'
GrabV3.cpp:(.text+0x465): undefined reference to GenICam_3_1_Basler_pylon::gcstring::gcstring(char const*)'
GrabV3.cpp:(.text+0x488): undefined reference to
GenICam_3_1_Basler_pylon::gcstring::~gcstring()'
GrabV3.cpp:(.text+0x4af): undefined reference to GenICam_3_1_Basler_pylon::gcstring::gcstring(char const*)'
GrabV3.cpp:(.text+0x4ff): undefined reference to
GenICam_3_1_Basler_pylon::gcstring::~gcstring()'
GrabV3.cpp:(.text+0x526): undefined reference to GenICam_3_1_Basler_pylon::gcstring::gcstring(char const*)'
GrabV3.cpp:(.text+0x576): undefined reference to
GenICam_3_1_Basler_pylon::gcstring::~gcstring()'
GrabV3.cpp:(.text+0x745): undefined reference to `cv::VideoWriter::open(cv::String const&, int, double, cv::Size_, bool)'*
so apparently nothing works, starting with the cv:VideoWriter() function which is a part of standard OpenCV (which I installed using this tutorial: https://cv-tricks.com/installation/opencv-4-1-ubuntu18-04/).
So I am lost here - already spent about a day trying to make it work. Can somebody help?