list_cameras.cpp
Go to the documentation of this file.
00001 /*
00002 This code was developed by the National Robotics Engineering Center (NREC), part
00003 of the Robotics Institute at Carnegie Mellon University.
00004 Its development was funded by DARPA under the LS3 program and submitted for
00005 public release on June 7th, 2012.
00006 Release was granted on August, 21st 2012 with Distribution Statement "A"
00007 (Approved for Public Release, Distribution Unlimited).
00008 
00009 This software is released under a BSD license:
00010 
00011 Copyright (c) 2012, Carnegie Mellon University. All rights reserved.
00012 
00013 Redistribution and use in source and binary forms, with or without modification,
00014 are permitted provided that the following conditions are met:
00015 
00016 Redistributions of source code must retain the above copyright notice, this list
00017 of conditions and the following disclaimer.
00018 Redistributions in binary form must reproduce the above copyright notice, this
00019 list of conditions and the following disclaimer in the documentation and/or
00020 other materials provided with the distribution.
00021 Neither the name of the Carnegie Mellon University nor the names of its
00022 contributors may be used to endorse or promote products derived from this
00023 software without specific prior written permission.
00024 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00025 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00026 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00028 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00031 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00033 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 */
00035 
00047 #include <flycapture/FlyCapture2.h>
00048 #include <iostream>
00049 #include <string>
00050 #include "pointgrey_camera_driver/PointGreyCamera.h"
00051 
00052 using namespace FlyCapture2;
00053 
00054 #define PGERROR(error, msg) PointGreyCamera::handleError(msg, error)
00055 
00056 void printCameraInfo(const CameraInfo& cinfo) {
00057   std::cout << "Serial: " << cinfo.serialNumber
00058             << ", Model: " << cinfo.modelName
00059             << ", Vendor: " << cinfo.vendorName
00060             << ", Sensor: " << cinfo.sensorInfo
00061             << ", Resolution: " << cinfo.sensorResolution
00062             << ", Color: " << std::boolalpha << cinfo.isColorCamera
00063             << ", Firmware Version: " << cinfo.firmwareVersion << std::endl;
00064 }
00065 
00066 int main(int argc, char** argv) {
00067   BusManager bus_manager;
00068 
00069   try {
00070     unsigned num_devices = 0;
00071     PGERROR(bus_manager.GetNumOfCameras(&num_devices),
00072             "Failed get number of cameras");
00073     if (num_devices) {
00074       std::cout << "Number of cameras found: " << num_devices << std::endl;
00075       for (unsigned i = 0; i < num_devices; ++i) {
00076         PGRGuid guid;
00077         std::ostringstream s;
00078         s << i;
00079         PGERROR(bus_manager.GetCameraFromIndex(i, &guid),
00080                 "Failed to get camera from index " + s.str());
00081 
00082         Camera camera;
00083         PGERROR(camera.Connect(&guid), "Failed to connect to camera");
00084 
00085         CameraInfo cinfo;
00086         PGERROR(camera.GetCameraInfo(&cinfo), "Failed to get camera info");
00087 
00088         std::cout << "[" << i << "]";
00089         printCameraInfo(cinfo);
00090       }
00091     } else {
00092       // No cameras found
00093       std::cout << "No PointGrey cameras detected on this computer."
00094                 << std::endl << std::endl;
00095 
00096       std::cout << "Note that you may need to restart udev and "
00097                    "replug your camera, eg:" << std::endl
00098                 << "  sudo service udev restart" << std::endl;
00099     }
00100   } catch (const std::runtime_error& e) {
00101     std::cout << "There was an error checking the active cameras: " << e.what()
00102               << std::endl;
00103   }
00104 }


pointgrey_camera_driver
Author(s): Chad Rockey
autogenerated on Wed Aug 26 2015 15:32:44