如下图将包含目录和库目录设置好
#include "stdafx.h"
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<pylon/PylonIncludes.h>
using namespace cv;
using namespace std;
using namespace Pylon;
int _tmain(int argc, _TCHAR* argv[])
{
//basler相机初始化
PylonInitialize();
VideoCapture capture(1);
//设置图片的大小
capture.set(CV_CAP_PROP_FRAME_WIDTH, 2592);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, 1944);
while (1)
{
Mat frame;
capture >> frame;
imshow("摄像头", frame);
char c = cvWaitKey(33);
if (c == 't')
{
PylonTerminate();//退出程序前要释放相机资源,不然下次运行时会出错
break;
}
}
return 0;
}