好的,马克的建议解决了链接问题。然而,由于该软件仍未编译,并且我们仍在“编译使用 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/包括/塔
现在出现以下错误:
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')是一个 INLINE 函数,定义在
/usr/include/opencv2/videoio/videoio_c.h,现在超出了某些范围
原因。
我试图通过包含来暴力链接它
#include "/usr/include/opencv2/videoio/videoio_c.h"
但这导致链接完全搞砸了。
感谢@Mark 让我走到这一步;从这里怎么走?