BASLER GIGE相机 怎么使用OPENCV显示图像

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" 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);
value
of
first
pixel:
//
}
Display
the
grabbed
image.
Pylon::DisplayImage(1, ptrGrabResult);
else
{ Code() << " cout << "Error: " << ptrGrabResult->GetErrorDescription(); } }
{
// The exit int exitCode = 0;
code
of
the
sample
application.
to
// Automagically call PylonInitialize and PylonTerminate ensure the pylon runtime system // is initialized during the lifetime of this object.
//
me() << endl;
Print the model name of the camera. cout << "Using device " << camera.GetDeviceInfo().GetModelNa
control f this
// The parameter the count of buffers // allocated for parameter is 10.
basler gige 相机 怎么使用 opencv 显示图像
这个是官方的例子,我把头文件,库都配好后,可以运行。 但是它直接调用的是 pylon 的窗口,现在我想用 opencv 的窗口来显示他
#include #include
<pylon/PylonIncludes.h> <pylon/PylonGUI.h> pylon objects.
on
// Comment exit.
the
following to
two
lines
to
disable
waiting
cerr << endl << "Press Enter while( cin.get() != '\n');
exit." << eΒιβλιοθήκη Baidudl;
return exitCode;
}
opencv 显示的代码很简洁如下
char c=cvWaitKey(33);
if(c==27) break;
} cvReleaseCapture(&pCapture); cvDestroyWindow("摄像头"); return 0; }
Pylon::PylonAutoInitTerm autoInitTerm;
try
{
amera
device
// Create an found first.
instant
camera
object
with
the
c
CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice());
// Namespace for using using namespace Pylon; // Namespace for using namespace std; using
cout.
// Number of images to be grabbed. static const uint32_t c_countOfImagesToGrab = 100; int main(int argc, char* argv[])
// Image grabbed successfully? if (ptrGrabResult->GrabSucceeded())
{
//
() << endl;
Access the image data. cout << "SizeX: " << ptrGrabResult->GetWidth
cout << "SizeY:
" << ptrGrabResult->GetError
}
catch (GenICam::GenericException &e)
{
//
Error handling. cerr << "An exception occurred." << endl
<< e.GetDescription() << endl; exitCode = 1; }
" << ptrGrabResult->GetHeigh
t() << endl;
const uint8_t *pImageBuffer = (uint8_t *) ptrGrab
Result->GetBuffer(); cout << "Gray " << (uint32_t) pImageBuffer[0] << endl << endl;
{
retrieved.
it.
A
timeout
of
// Wait for an image 5000 ms is used.
and
then
retrieve
camera.RetrieveResult( 5000, ptrGrabResult, TimeoutHandling _ThrowException);
camera.MaxNumBuffer = 5;
MaxNumBuffer grabbing. The
can
be
used
to o
default
value
//
Start
the
grabbing
of
c_countOfImagesToGrab
images. default // The camera device is parameterized with a configuration which // sets up free-running continuous acquisition.
camera.StartGrabbing( c_countOfImagesToGrab);
// esult data.
This
smart
pointer
will
receive
the
grab
r
CGrabResultPtr ptrGrabResult;
by
the
// Camera.StopGrabbing() is called automatically RetrieveResult() method // when c_countOfImagesToGrab images have been while ( camera.IsGrabbing())
相关文档
最新文档