Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.image.processing > #4401

Re: Pt Grey Flycapture

Newsgroups sci.image.processing
Date 2018-10-25 19:21 -0700
References <37daed72-4920-44fa-a5c2-3c4b4324e49f@googlegroups.com>
Message-ID <563780b7-afc2-40be-8149-edb050daa5bd@googlegroups.com> (permalink)
Subject Re: Pt Grey Flycapture
From yanru wang <wangyanruimp@gmail.com>

Show all headers | View raw


在 2018年4月14日星期六 UTC+8下午12:17:32,lentfer.p...@gmail.com写道:
> Hi all,
> 
> New to the whole google groups thing so if I'm posting in the wrong group let me know!
> 
> I'm currently developing a Stereo V-SLAM application and run into some problem with grabbing images from a pair of pt grey FMVU-13S2c cameras.
> 
> I am running Codeblocks on Ubuntu using c++ and the Flycapture api.
> 
> As i have to capture from two cameras my problem lies in the fact that when i have 2 cameras connected the image from the second camera gets corrupted.
> 
> code as follows:
> 
> #include "FlyCapture2.h"
> #include <iostream>
> #include <sstream>
> #include <opencv2/opencv.hpp>
> #include <opencv2/highgui.hpp>
> #include <opencv2/imgproc/imgproc.hpp>
> 
> using namespace FlyCapture2;
> using namespace std;
> using namespace cv;
> 
> int main(int /*argc*/, char ** /*argv*/)
> {
>     //defines
>     FlyCapture2::Image leftRaw;
>     FlyCapture2::Image leftRgb;
>     cv::Mat imgLeft;
>     FlyCapture2::Image rightRaw;
>     FlyCapture2::Image rightRgb;
>     cv::Mat imgRight;
>     unsigned int rowBytesL;
>     unsigned int rowBytesR;
>     const int k_numImages = 100;
>     FlyCapture2::Error error;
>     FlyCapture2::BusManager busMgr;
>     FlyCapture2::Camera LeftCam;
>     FlyCapture2::Camera RightCam;
>     FlyCapture2::PGRGuid guidL;
>     FlyCapture2::PGRGuid guidR;
> 
> 
>     //Connect left camera and start capture.
> 
>     busMgr.GetCameraFromIndex(0, &guidL);
>     LeftCam.Connect(&guidL);
>     LeftCam.StartCapture();
> 
>     //connect right camera and start capture
>     busMgr.GetCameraFromIndex(1, &guidR);
>     RightCam.Connect(&guidR);
>     RightCam.StartCapture();
> 
>     //create windows to display images.
>     namedWindow("LeftImage",WINDOW_AUTOSIZE);
>     namedWindow("RightImage",WINDOW_AUTOSIZE);
> 
> 
>     //capture images
>     for (int i = 0; i <  k_numImages ;i++)
>     {
>         //capture images from cameras
>         LeftCam.RetrieveBuffer(&leftRaw);
>         RightCam.RetrieveBuffer(&rightRaw);
> 
> 
> 
> 
> 
>         //convert captured images to BRG format then to openCV Mat format for display
> 
>         //convert left
>         leftRaw.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &leftRgb);
>         rowBytesL = (double)leftRgb.GetDataSize()/(double)leftRgb.GetRows();
>         imgLeft = cv::Mat(leftRgb.GetRows(), leftRgb.GetCols(), CV_8UC3, leftRgb.GetData(),rowBytesL);
> 
>         //convert right
>         rightRaw.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rightRgb);
>         rowBytesR = (double)rightRgb.GetDataSize()/(double)rightRgb.GetRows();
>         imgRight = cv::Mat(rightRgb.GetRows(), rightRgb.GetCols(), CV_8UC3,  rightRgb.GetData(),rowBytesR);
> 
>         //SaveImages
> 
>         ostringstream leftFileName;
>         leftFileName << "LeftImage-" << "-" << i << ".jpg";
>         leftRgb.Save(leftFileName.str().c_str());
> 
>         ostringstream rightfilename;
>         rightfilename << "RightImage-" << "-" << i << ".jpg";
>         rightRgb.Save(rightfilename.str().c_str());
> 
>         //display images
>         imshow("LeftImage",imgLeft);
>         imshow("RightImage",imgRight);
>         waitKey(1);
> 
>     }
> 
> 
>     //
>     // Stop streaming for each camera
>     //
> 
>         LeftCam.StopCapture();
>         LeftCam.Disconnect();
>         RightCam.StopCapture();
>         RightCam.Disconnect();
> 
> 
>     cout << "Press Enter to exit..." << endl;
>     cin.ignore();
> 
>     return 0;
> }
> 
> 
> If i connect each camera individually or stop capturing and disconnect the camera object before capturing the image from the other camera both images are fine.
> 
> 
> 
> 
> Sound familiar to anyone??
> 
> 
> Thanks,
> 
> Patrick

Hi Patrick,

I had more 2 Pt Grey cameras connected successfully. The code to capture the images is wrote with matlab script by another guy from my previous group. I couldn't help you with your code, but I do know the conflicts between cameras coming from the trigger timing sequence. I need to reset the timing everytime when I reconnect the cameras. So maybe notice the trigger timing.

Thanks,

Yanru

Back to sci.image.processing | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Pt Grey Flycapture lentfer.patrick.86@gmail.com - 2018-04-13 21:17 -0700
  Re: Pt Grey Flycapture yanru wang <wangyanruimp@gmail.com> - 2018-10-25 19:21 -0700

csiph-web