Pointgrey相机代码和资料

xiaoxiao2021-02-28  111

打开单目Pointgrey相机

Error error; Camera camera; // Get the image error=camera.Connect(NULL);//灰点的库函数调用,检测相机 error=camera.StartCapture();//开启相机 char key = 0; int i=0; while(1) { Image rawImage; error = camera.RetrieveBuffer( &rawImage );//捕获帧 if (error!=PGRERROR_OK) { AfxMessageBox("Capture error!");捕获失败弹出错误 continue; } // convert to rgb Kevin的例子,图像格式转换 Image rgbImage; rawImage.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage ); // convert to OpenCV Mat unsigned int rowBytes = (double)rgbImage.GetReceivedDataSize()/(double)rgbImage.GetRows(); cv::Mat image = cv::Mat(rgbImage.GetRows(), rgbImage.GetCols(), CV_8UC3, rgbImage.GetData(),rowBytes); //cv::imshow("image", image); IplImage *pImg=cvLoadImage("Lre.bmp");//在MFC中定义了一个显示控件,m_picture为控件的成员变量 *pImg=IplImage(image); CDC* pDC = m_picture.GetWindowDC(); CvvImage limg; CRect rect; m_picture.GetClientRect(&rect); limg.CopyOf(pImg); limg.DrawToHDC(pDC -> m_hDC,&rect); key = cv::waitKey(30); } if (error!=PGRERROR_OK) { } camera.Disconnect();

打开双目PointGrey相机

Error error; BusManager busMgr; unsigned int numCameras=0; error=busMgr.GetNumOfCameras(&numCameras);//检测相机个数 if (error!=PGRERROR_OK) { AfxMessageBox("Insufficient number of cameras"); } Camera** ppCameras = new Camera*[numCameras]; // Connect to all detected cameras and attempt to set them to // a common video mode and frame rate for (unsigned int i = 0; i < numCameras; i++) { ppCameras[i] = new Camera(); PGRGuid guid; error = busMgr.GetCameraFromIndex( i, &guid );//获取每个相机的唯一ID // Connect to a camera error = ppCameras[i]->Connect( &guid );//连接相机 if (error != PGRERROR_OK) { AfxMessageBox("GUID=NO!"); } // Set all cameras to a specific mode and frame rate so they // can be synchronized CameraInfo camInfo; error = ppCameras[i]->GetCameraInfo( &camInfo );//获取相机的基本信息,可以忽略 if (error != PGRERROR_OK) { AfxMessageBox("INFORMATION ERROR"); } // error = ppCameras[i]->SetVideoModeAndFrameRate( VIDEOMODE_1600x1200Y8,FRAMERATE_15 ); //if (error!=PGRERROR_OK) // { // AfxMessageBox("MODEL error!"); // } } //Camera cameras; //error = cameras.StartSyncCapture( numCameras, (const Camera**)ppCameras,NULL,NULL );//works for FireWire cameras,not work for USB cameras error=ppCameras[0]->StartCapture();//开始拍照 error=ppCameras[1]->StartCapture(); if (error!=PGRERROR_OK) { AfxMessageBox("Startcapture error!"); } char key = 0; int i=0; while(1) { //Image rawImage; Image image0,image1; error=ppCameras[0]->RetrieveBuffer( &image0 );//获取下一帧图像 error=ppCameras[1]->RetrieveBuffer( &image1 ); if (error!=PGRERROR_OK) { AfxMessageBox("RetrieveBuffer error!"); } // convert to rgb Image rgbImage0,rgbImage1; //BMPOption option;//指定存储的图像 image0.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage0 ); image1.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage1 ); // convert to OpenCV Mat对图像进行压缩,转换成CV矩阵 unsigned int rowBytes0 = (double)rgbImage0.GetReceivedDataSize()/(double)rgbImage0.GetRows(); cv::Mat imageR = cv::Mat(rgbImage0.GetRows(), rgbImage0.GetCols(), CV_8UC3, rgbImage0.GetData(),rowBytes0); unsigned int rowBytes1 = (double)rgbImage1.GetReceivedDataSize()/(double)rgbImage1.GetRows(); cv::Mat imageL = cv::Mat(rgbImage1.GetRows(), rgbImage1.GetCols(), CV_8UC3, rgbImage1.GetData(),rowBytes1); //cv::imshow("image", imageR); //将cv::Mat转换成IplImage格式 IplImage *pImgR=cvCreateImage(cvSize(1600,1200),8,3);//简单的初始化Lre.bmp,工程中任意的一张图像。 *pImgR=IplImage(imageR); //MFC图像显示控件 CDC* pDC = m_picture2.GetWindowDC(); CvvImage limg; CRect rect; m_picture2.GetClientRect(&rect); limg.CopyOf(pImgR); limg.DrawToHDC(pDC -> m_hDC,&rect); cvSaveImage("RIGHT.BMP",pImgR); IplImage *pImgL=cvCreateImage(cvSize(1600,1200),8,3); *pImgL=IplImage(imageL); CDC* pDC1 = m_picture.GetWindowDC(); CvvImage limg1; CRect rect1; m_picture.GetClientRect(&rect1); limg1.CopyOf(pImgL); limg1.DrawToHDC(pDC1 -> m_hDC,&rect1); cvSaveImage("LEFT.BMP",pImgL); key = cv::waitKey(50);

资料汇总

ExampleLanguageDescriptionAsyncTriggerExC++Demonstrates some of the basic asynchronous trigger capabilities of compatible PGR Imaging Products.AsyncTriggerExCSharpC#Equivalent to AsnycTriggerEx, except written in C#.BusEvents_CSharpC#Demonstrates how to handle bus events such as bus arrivals, removals and resets through the Managed interface.CustomImageExC++Demonstrates how to configure a PGR Imaging Product to output custom sized images.CustomImageExCSharpC#Equivalent to CustomImageEx, except written in C#.ExtendedShutterExC++Demonstrates how to enable and calculate extended integration times for applicable Point Grey Imaging Products.FlyCap2C++The main Point Grey Research application used to work with single lens cameras.FlyCap2MFCC++Equivalent to FlyCap2, except uses features of the Microsoft Foundation Class Library.FlyCapture2GUIC++This example contains the same source code that is used for the Camera Selection and Camera Control dialogs in FlyCapture.FlyCapture2TestC++Tests basic functionality of a single camera and reports information related to all compatible cameras attached to the host system.FlyCapture2Test_CCEquivalent to FlyCapture2Test, except written in C.FlyCapture2Test_CSharpC#Equivalent to FlyCapture2Test, except written in C#.GigEGrabExC++Demonstrates how to grab images with GigE Vision cameras.GigEGrabEx_CCEquivalent to GigEGrabEx, except written in C.GigEGrabEx_CSharpC#Equivalent to GigEGrabEx, except written in C#.GrabCallbackExC++Demonstrates how to use the image callback functionality to receive images instead of using RetrieveBuffer().GrabCallbackEx_CSharpC#Equivalent to GrabCallbackEx, except written in C#.HighDynamicRangeExC++Demonstrates the use of High Dynamic Range (HDR) functionality.ImageEventExC++Demonstrates how to implement partial image event notification. Partial image event notification is a mechanism that provides the user with access to image data as it arrives in the PC’s memory, before the entire image is available.MultipleCameraExC++Synchronizes image grabbing across multiple cameras.SaveImageToAviExC++Demonstrates saving a series of images to an AVI file.SaveImageToFlashExC++Demonstrates saving images to the data flash on the camera.SerialPortExC++Demonstrates how to transmit and receive characters by using the camera’s serial buffer system.
转载请注明原文地址: https://www.6miu.com/read-42192.html

最新回复(0)