示例#1
0
void CCflycap_close(CCflycap *ccntxt) {
  if (!ccntxt) {CAM_IFACE_THROW_ERROR("no CCflycap specified (NULL argument)");}
  FlyCapture2::Camera *cam = (FlyCapture2::Camera *)ccntxt->inherited.cam;
  CIPGRCHK(cam->StopCapture());
  CIPGRCHK(cam->Disconnect());

  cam_iface_backend_extras* backend_extras = (cam_iface_backend_extras*)(ccntxt->inherited.backend_extras);


  if (backend_extras!=NULL) {
    delete backend_extras;
    ccntxt->inherited.backend_extras = (void*)NULL;
  }

  delete cam;
  ccntxt->inherited.cam = (void*)NULL;
}
示例#2
0
int main(int argc, char *argv[])
{

    get_param();

    std::string t_stamp = get_timestamp();

    sprintf (data_filename, "%s/data_%s.out", save_dir, t_stamp.c_str());
    std::cout << "data_filename: " << data_filename << std::endl;


    FlyCapture2::BusManager busMgr;

    PGRGuid guid;
    err = busMgr.GetCameraFromSerialNumber(cam_serial, &guid);
    if (err != PGRERROR_OK) {
      std::cout << "Index error" << std::endl;
      return false;
    }


    // Point Grey cam init
    init_cam_capture(pt_grey, guid);

    if (use_calib)
      load_calib_param();


    imageCallback(&pt_grey);


    printf("Stopping...\n");

    err = pt_grey.StopCapture();
    
    if ( err != PGRERROR_OK )
    {
        // This may fail when the camera was removed, so don't show 
        // an error message
    }  

    pt_grey.Disconnect();


}
示例#3
0
void BACKEND_METHOD(cam_iface_get_camera_info)(int device_number, Camwire_id *out_camid) {
  CAM_IFACE_CHECK_DEVICE_NUMBER(device_number);
  if (out_camid==NULL) { CAM_IFACE_THROW_ERROR("return structure NULL"); }

  FlyCapture2::PGRGuid guid;
  CIPGRCHK( BACKEND_GLOBAL(busMgr_ptr)->GetCameraFromIndex(device_number, &guid));

  FlyCapture2::CameraInfo camInfo;
  FlyCapture2::Camera *cam = new FlyCapture2::Camera;
  CIPGRCHK(cam->Connect(&guid));
  CIPGRCHK(cam->GetCameraInfo(&camInfo));
  CIPGRCHK(cam->Disconnect());

  cam_iface_snprintf(out_camid->vendor, CAMWIRE_ID_MAX_CHARS, camInfo.vendorName);
  cam_iface_snprintf(out_camid->model, CAMWIRE_ID_MAX_CHARS, camInfo.modelName);
  cam_iface_snprintf(out_camid->chip, CAMWIRE_ID_MAX_CHARS, "GUID %x %x %x %x",
		     guid.value[0],
		     guid.value[1],
		     guid.value[2],
		     guid.value[3]);
}
示例#4
0
int get_mode_list(int device_number, std::vector<CamMode> &result ) {

  FlyCapture2::Camera *cam = new FlyCapture2::Camera;
  FlyCapture2::PGRGuid guid;
  FlyCapture2::Error err;
  CamMode mode;
  FlyCapture2::Format7Info fmt7Info;
  bool supported;

  //FlyCapture2::Mode k_fmt7Mode;
  //FlyCapture2::PixelFormat k_fmt7PixFmt;
  std::ostringstream oss;
  std::vector<FlyCapture2::Mode> fmt7modes;
  fmt7modes.push_back(FlyCapture2::MODE_0);
  fmt7modes.push_back(FlyCapture2::MODE_1);
  fmt7modes.push_back(FlyCapture2::MODE_2);
  fmt7modes.push_back(FlyCapture2::MODE_3);
  fmt7modes.push_back(FlyCapture2::MODE_4);
  fmt7modes.push_back(FlyCapture2::MODE_5);
  fmt7modes.push_back(FlyCapture2::MODE_6);
  fmt7modes.push_back(FlyCapture2::MODE_7);
  fmt7modes.push_back(FlyCapture2::MODE_8);
  fmt7modes.push_back(FlyCapture2::MODE_9);
  fmt7modes.push_back(FlyCapture2::MODE_10);
  fmt7modes.push_back(FlyCapture2::MODE_11);
  fmt7modes.push_back(FlyCapture2::MODE_12);
  fmt7modes.push_back(FlyCapture2::MODE_13);
  fmt7modes.push_back(FlyCapture2::MODE_14);
  fmt7modes.push_back(FlyCapture2::MODE_15);
  fmt7modes.push_back(FlyCapture2::MODE_16);
  fmt7modes.push_back(FlyCapture2::MODE_17);
  fmt7modes.push_back(FlyCapture2::MODE_18);
  fmt7modes.push_back(FlyCapture2::MODE_19);
  fmt7modes.push_back(FlyCapture2::MODE_20);
  fmt7modes.push_back(FlyCapture2::MODE_21);
  fmt7modes.push_back(FlyCapture2::MODE_22);
  fmt7modes.push_back(FlyCapture2::MODE_23);
  fmt7modes.push_back(FlyCapture2::MODE_24);
  fmt7modes.push_back(FlyCapture2::MODE_25);
  fmt7modes.push_back(FlyCapture2::MODE_26);
  fmt7modes.push_back(FlyCapture2::MODE_27);
  fmt7modes.push_back(FlyCapture2::MODE_28);
  fmt7modes.push_back(FlyCapture2::MODE_29);
  fmt7modes.push_back(FlyCapture2::MODE_30);
  fmt7modes.push_back(FlyCapture2::MODE_31);

  std::vector<FlyCapture2::PixelFormat> pixfmts;
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_MONO8);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_411YUV8);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_422YUV8);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_444YUV8);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_RGB8);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_MONO16);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_RGB16);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_S_MONO16);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_S_RGB16);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_RAW8);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_RAW16);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_MONO12);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_RAW12);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_BGR);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_BGRU);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_RGB);
  pixfmts.push_back(FlyCapture2::PIXEL_FORMAT_RGBU);

  err = BACKEND_GLOBAL(busMgr_ptr)->GetCameraFromIndex(device_number, &guid);
  // if (err!=FlyCapture2::PGRERROR_OK) {
  //   goto errlabel2;
  // }
  err = cam->Connect(&guid);
  // if (err!=FlyCapture2::PGRERROR_OK) {
  //   goto errlabel2;
  // }

  // FORMAT 7 -- test all modes
  std::vector<FlyCapture2::Mode>::const_iterator fmt7mode;
  for(fmt7mode=fmt7modes.begin(); fmt7mode!=fmt7modes.end(); fmt7mode++) {
    fmt7Info.mode = *fmt7mode;
    err = cam->GetFormat7Info( &fmt7Info, &supported );
    // if (err != FlyCapture2::PGRERROR_OK) goto errlabel1;

    // Do work
    if (supported) {

      std::vector<FlyCapture2::PixelFormat>::const_iterator pixfmt;
      for(pixfmt=pixfmts.begin(); pixfmt!=pixfmts.end(); pixfmt++) {
	if (*pixfmt & fmt7Info.pixelFormatBitField) {

	  std::ostringstream oss = std::ostringstream();
	  oss << "format 7, mode " << *fmt7mode << " (" << pixfmt2string(*pixfmt) << ", " << fmt7Info.maxWidth << "x" << fmt7Info.maxHeight <<")";

	  mode.descr = oss.str();
	  mode.videomode = FlyCapture2::VIDEOMODE_FORMAT7;
	  mode.fmt7ImageSettings.mode = *fmt7mode;
	  mode.fmt7ImageSettings.offsetX = 0;
	  mode.fmt7ImageSettings.offsetY = 0;
	  mode.fmt7ImageSettings.width = fmt7Info.maxWidth;
	  mode.fmt7ImageSettings.height = fmt7Info.maxHeight;
	  mode.fmt7ImageSettings.pixelFormat = *pixfmt;

	  bool valid;
	  err = cam->ValidateFormat7Settings( &mode.fmt7ImageSettings,
					      &valid,
					      &mode.fmt7PacketInfo );
	  if (err == FlyCapture2::PGRERROR_OK) {
	    result.push_back(mode);
	  }
	}
      }
    }
  }

  // not format 7 -- test each videomode and framerate combination

  std::vector<FlyCapture2::VideoMode> videomodes;
  videomodes.push_back(FlyCapture2::VIDEOMODE_160x120YUV444);
  videomodes.push_back(FlyCapture2::VIDEOMODE_320x240YUV422);
  videomodes.push_back(FlyCapture2::VIDEOMODE_640x480YUV411);
  videomodes.push_back(FlyCapture2::VIDEOMODE_640x480YUV422);
  videomodes.push_back(FlyCapture2::VIDEOMODE_640x480RGB);
  videomodes.push_back(FlyCapture2::VIDEOMODE_640x480Y8);
  videomodes.push_back(FlyCapture2::VIDEOMODE_640x480Y16);
  videomodes.push_back(FlyCapture2::VIDEOMODE_800x600YUV422);
  videomodes.push_back(FlyCapture2::VIDEOMODE_800x600RGB);
  videomodes.push_back(FlyCapture2::VIDEOMODE_800x600Y8);
  videomodes.push_back(FlyCapture2::VIDEOMODE_800x600Y16);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1024x768YUV422);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1024x768RGB);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1024x768Y8);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1024x768Y16);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1280x960YUV422);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1280x960RGB);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1280x960Y8);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1280x960Y16);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1600x1200YUV422);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1600x1200RGB);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1600x1200Y8);
  videomodes.push_back(FlyCapture2::VIDEOMODE_1600x1200Y16);

  std::vector<FlyCapture2::FrameRate> framerates;
  framerates.push_back(FlyCapture2::FRAMERATE_1_875);
  framerates.push_back(FlyCapture2::FRAMERATE_3_75);
  framerates.push_back(FlyCapture2::FRAMERATE_7_5);
  framerates.push_back(FlyCapture2::FRAMERATE_15);
  framerates.push_back(FlyCapture2::FRAMERATE_30);
  framerates.push_back(FlyCapture2::FRAMERATE_60);
  framerates.push_back(FlyCapture2::FRAMERATE_120);
  framerates.push_back(FlyCapture2::FRAMERATE_240);

  std::vector<FlyCapture2::VideoMode>::const_iterator videomode;
  for(videomode=videomodes.begin(); videomode!=videomodes.end(); videomode++) {
    std::vector<FlyCapture2::FrameRate>::const_iterator framerate;
    for(framerate=framerates.begin(); framerate!=framerates.end(); framerate++) {
      err = cam->GetVideoModeAndFrameRateInfo(*videomode, *framerate, &supported);
      if (err == FlyCapture2::PGRERROR_OK) {
	if (supported) {
	  std::ostringstream oss = std::ostringstream();
	  oss << "videomode " << *videomode << " framerate " << *framerate;
	  mode.descr = oss.str();
	  mode.videomode = *videomode;
	  mode.framerate = *framerate;
	}
      }
    }
  }

  // err = cam->Disconnect();
  cam->Disconnect();
  return 0;


 // errlabel1:
  // err = cam->Disconnect();
 // errlabel2:
 //  return 1;
}