打开单目Pointgrey相机
Error
error;
Camera
camera;
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;
}
Image rgbImage;
rawImage.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage );
unsigned
int rowBytes = (double)rgbImage.GetReceivedDataSize()/(double)rgbImage.GetRows();
cv::Mat
image = cv::Mat(rgbImage.GetRows(), rgbImage.GetCols(), CV_8UC3, rgbImage.GetData(),rowBytes);
IplImage
*pImg=cvLoadImage(
"Lre.bmp");
*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];
for (unsigned
int i =
0; i < numCameras; i++)
{
ppCameras[i] = new Camera();
PGRGuid guid;
error = busMgr.GetCameraFromIndex( i, &guid );
error = ppCameras[i]->Connect( &guid );
if (
error != PGRERROR_OK)
{
AfxMessageBox(
"GUID=NO!");
}
CameraInfo camInfo;
error = ppCameras[i]->GetCameraInfo( &camInfo );
if (
error != PGRERROR_OK)
{
AfxMessageBox(
"INFORMATION ERROR");
}
}
error=ppCameras[
0]->StartCapture();
error=ppCameras[
1]->StartCapture();
if (
error!=PGRERROR_OK)
{
AfxMessageBox(
"Startcapture error!");
}
char key =
0;
int i=
0;
while(
1)
{
Image image0,image1;
error=ppCameras[
0]->RetrieveBuffer( &image0 );
error=ppCameras[
1]->RetrieveBuffer( &image1 );
if (
error!=PGRERROR_OK)
{
AfxMessageBox(
"RetrieveBuffer error!");
}
Image rgbImage0,rgbImage1;
image0.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage0 );
image1.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage1 );
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);
IplImage
*pImgR=cvCreateImage(cvSize(
1600,
1200),
8,
3);
*pImgR=IplImage(imageR);
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);
资料汇总
ExampleLanguageDescription
AsyncTriggerExC++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.