basler gige相机 怎么使用opencv显示图像

2018-12-11 22:52

basler gige相机 怎么使用opencv显示图像

这个是官方的例子,我把头文件,库都配好后,可以运行。

但是它直接调用的是pylon的窗口,现在我想用opencv的窗口来显示他

#include #include

// Namespace for using pylon objects. using namespace Pylon;

// Namespace for using cout. using namespace std;

// 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;

try {

// Create an instant camera object with the camera device found first.

CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice());

// Print the model name of the camera.

cout << \ << 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;

// Start the grabbing of c_countOfImagesToGrab images.

// The camera device is parameterized with a default configur

ation which

// sets up free-running continuous acquisition. camera.StartGrabbing( c_countOfImagesToGrab);

// This smart pointer will receive the grab result data. CGrabResultPtr ptrGrabResult;

// Camera.StopGrabbing() is called automatically by the RetrieveResult() method

// when c_countOfImagesToGrab images have been retrieved. while ( camera.IsGrabbing()) {

// Wait for an image and then retrieve it. A timeout of 5000 ms is used.

camera.RetrieveResult( 5000, ptrGrabResult, TimeoutHandling_ThrowException

);

// Image grabbed successfully? if (ptrGrabResult->GrabSucceeded()) {

// Access the image data.

cout << \ << ptrGrabResult->GetWidth() << endl; cout << \ << ptrGrabResult->GetHeight() << endl;

const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult->GetBuffer(); cout << \ << (uint32_t) pImageBuf

fer[0] << endl << endl;

// Display the grabbed image. Pylon::DisplayImage(1, ptrGrabResult); } else {

cout << \ << ptrGrabResult->GetErrorCode() << \ << ptrGr

abResult->GetErrorDescription();

} } }

catch (GenICam::GenericException &e) {

// Error handling.

cerr << \ << endl << e.GetDescription() << endl; exitCode = 1; }

// Comment the following two lines to disable waiting on exit. cerr << endl << \ << endl; while( cin.get() != '\\n');

return exitCode;

}

opencv显示的代码很简洁如下

#include \ #include \ using namespace cv; using namespace std; int main( )

{

//声明IplImage指针 IplImage* pFrame = NULL;

//获取摄像头

CvCapture* pCapture = cvCreateCameraCapture(0); //CvCapture* pCapture2 = cvCreateCameraCapture(0);

//创建窗口

cvNamedWindow(\摄像头\, 1);

//显示视屏 while(1) {

pFrame=cvQueryFrame( pCapture ); if(!pFrame) break;

cvShowImage(\摄像头\,pFrame);

char c=cvWaitKey(33); if(c==27) break; }

cvReleaseCapture(&pCapture); cvDestroyWindow(\摄像头\); return 0;

}


basler gige相机 怎么使用opencv显示图像.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:心理健康毕业论文大学生人际交往障碍原因及解决方法

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: