编译使用Basler相机的程序
Compiling a program for using a Basler Camera
我正在尝试使用Basler相机拍摄图像的C++程序。我得到了 来自制造商的代码,它应该是"非常易于使用的",但是,链接它有 成为一场噩梦。我的C++时间已经过去了(最近才使用 Matlab(,所以我可能会犯一些愚蠢的错误,但请启发我:
代码如下所示:
// 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)
我正在尝试使用以下方法编译它:
g++ GrabV3.cpp -I/opt/pylon5 -I/opt/pylon5/include -I/usr/local/include -I/usr/include/ -L/opt/pylon5/lib64
此处/opt/pylon5 是 Basler 自己的库和 opencv4 文件夹的链接。
我收到一个长达一页的错误消息列表 - 开始看起来像这样GrabV3.cpp:(.text+0x2a5(: 对cv::VideoWriter::VideoWriter()'
GrabV3.cpp:(.text+0x32a): undefined reference to
Pylon::CTlFactory::GetInstance((' 的未定义引用 GrabV3.cpp:(.text+0x346(: 对Pylon::CDeviceInfo::CDeviceInfo()'
GrabV3.cpp:(.text+0x370): undefined reference to
Pylon::CInstantCamera::CInstantCamera(Pylon::IPylonDevice, Pylon::ECleanup(的未定义引用 GrabV3.cpp:(.text+0x38e(: 对Pylon::CInstantCamera::Open()'
GrabV3.cpp:(.text+0x39d): undefined reference to
Pylon::CInstantCamera::GetNodeMap((' 的未定义引用 GrabV3.cpp:(.text+0x3cb(: 对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(: 对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(: 对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(: 对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(: 未定义引用 'cv::VideoWriter::open(cv::String const&, int, double, cv::Size_, bool('*
所以显然没有任何效果,从 cv:VideoWriter(( 函数开始,它是标准 OpenCV 的一部分(我使用本教程安装:https://cv-tricks.com/installation/opencv-4-1-ubuntu18-04/(。
所以我在这里迷路了——已经花了大约一天的时间试图让它工作。有人可以帮忙吗?
好的,所以马克的建议解决了链接问题。但是,由于软件仍未编译,并且我们仍处于"编译使用Basler相机的程序"主题中,因此我将继续解决范围问题:
g++ $(pkg-config --cflags --libs opencv4( GrabV3.cpp
-I/opt/pylon5/include -I/opt/pylon5/include/pylon -L/opt/pylon5/lib64 -L/opt/pylon5/include/pylon5/include/pylon(包括/pylon(现在给出以下错误:
GrabV3.cpp: In function ‘int main(int, char**)’:
GrabV3.cpp:84:32: error: ‘CV_FOURCC’ was not declared in this scope
cvVideoCreator.open(filename,CV_FOURCC('D','I','V','X'),20,FrameSize,true);
在"等等"之后(请参阅我的第一篇文章(,代码继续如下:
try
{
// Create an instant camera object with the camera device found first.
CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice());
camera.Open();
INodeMap& nodeMap = camera.GetNodeMap();
CEnumerationPtr TestImageSelector = nodeMap.GetNode("TestImageSelector");
TestImageSelector->FromString("Testimage4");
CIntegerPtr Width = nodeMap.GetNode("Width");
CIntegerPtr Height = nodeMap.GetNode("Height");
Size FrameSize = Size(Width->GetValue(),Height->GetValue());
stringstream s ;
s<<"_" ;
s<< filecounter;
filename = filenameBase;
filename += s.str() + ".avi";
//cvVideoCreator.open("``/opt/PylonTest_DIVX.avi",CV_FOURCC('M','P','4','2'),20,FrameSize,true);
cvVideoCreator.open(filename,CV_FOURCC('D','I','V','X'),20,FrameSize,true);
//cvVideoCreator.open("/opt/PylonTest.avi",CV_FOURCC('M','J','P','G'),20,FrameSize,true);
// Print the model name of the camera.
cout << "Using device " << camera.GetDeviceInfo().GetModelName() << endl;
// The parameter MaxNumBuffer can be used to control the count of buffers
// allocated for grabbing. The default value of this parameter is 10.
camera.MaxNumBuffer = 5;
CImageFormatConverter fc;
fc.OutputPixelFormat = PixelType_BGR8packed;
CPylonImage image;
// Start the grabbing of c_countOfImagesToGrab images.
// The camera device is parameterized with a default configuration which
// sets up free-running continuous acquisition.
camera.StartGrabbing();
// This smart pointer will receive the grab result data.
CGrabResultPtr ptrGrabResult;
CV_FOURCC('D','I','V','X'(是一个内联函数,定义在/usr/include/opencv2/videoio/videoio_c.h,现在已经超出了某些人的范围 原因。
我试图通过包含
#include "/usr/include/opencv2/videoio/videoio_c.h"
但这导致链接完全搞砸了。 感谢@Mark让我走到这一步;如何从这里开始?
- 操纵安卓相机的深度图导致应用程序崩溃
- OpenGL 相机移动程序顶点着色器问题
- 编译使用Basler相机的程序
- 使用OpenCV为使用GENICAM API和C++的各种相机创建程序
- C .exe在C#实时相机流应用程序中
- 相机枚举的选项和UWP应用程序的HAL(WPF/C CLI DLL)
- 如何在 Unity Android 应用程序中的 OpenCV 中使用 ARCore 相机图像
- 在程序中获取 USB 相机图片
- 无法从C++应用程序中正确生成Raspberry Pi相机应用程序作为子进程
- 使用C++程序中的拉斯皮斯蒂尔读取相机图像
- 带有GUI的C++程序,可使用远程放置的相机进行拍摄并读取未压缩的TIFF图像
- 在C++中使用 OpenCV 从相机流式传输视频时程序无法启动
- 当相机离我的260k多边形网格很近时,DirectX 9应用程序会减慢速度
- 如何创建用于从(WiFi)相机接收视频流的应用程序
- XIMEA:openCV 2.4.9找不到XIMEA相机,尽管它可以与其他程序配合使用
- OpenGL程序/w着色器,相机移动不正确
- 如何在用户模式应用程序C++中访问AVStream扩展相机控制属性
- "相机正在使用中。关闭使用它的所有应用程序,然后重试。在黑莓 Z10 中调用黑莓 10 级联中的相机时
- 如何在c++中处理两个进程(一个OpenGL应用程序通过相机运行手势)
- 如何在光线追踪面向对象的程序中声明变量,当它们中的大多数是矢量和相机声明时