list_cameras.cpp
Go to the documentation of this file.
1 /*
2 This code was developed by the National Robotics Engineering Center (NREC), part
3 of the Robotics Institute at Carnegie Mellon University.
4 Its development was funded by DARPA under the LS3 program and submitted for
5 public release on June 7th, 2012.
6 Release was granted on August, 21st 2012 with Distribution Statement "A"
7 (Approved for Public Release, Distribution Unlimited).
8 
9 This software is released under a BSD license:
10 
11 Copyright (c) 2012, Carnegie Mellon University. All rights reserved.
12 
13 Redistribution and use in source and binary forms, with or without modification,
14 are permitted provided that the following conditions are met:
15 
16 Redistributions of source code must retain the above copyright notice, this list
17 of conditions and the following disclaimer.
18 Redistributions in binary form must reproduce the above copyright notice, this
19 list of conditions and the following disclaimer in the documentation and/or
20 other materials provided with the distribution.
21 Neither the name of the Carnegie Mellon University nor the names of its
22 contributors may be used to endorse or promote products derived from this
23 software without specific prior written permission.
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 
47 #include <flycapture/FlyCapture2.h>
48 #include <iostream>
49 #include <string>
51 
52 using namespace FlyCapture2;
53 
54 #define PGERROR(error, msg) PointGreyCamera::handleError(msg, error)
55 
56 void printCameraInfo(const CameraInfo& cinfo) {
57  std::cout << "Serial: " << cinfo.serialNumber
58  << ", Model: " << cinfo.modelName
59  << ", Vendor: " << cinfo.vendorName
60  << ", Sensor: " << cinfo.sensorInfo
61  << ", Resolution: " << cinfo.sensorResolution
62  << ", Color: " << std::boolalpha << cinfo.isColorCamera
63  << ", Firmware Version: " << cinfo.firmwareVersion << std::endl;
64 }
65 
66 int main(int argc, char** argv) {
67  BusManager bus_manager;
68 
69  try {
70  unsigned num_devices = 0;
71  PGERROR(bus_manager.GetNumOfCameras(&num_devices),
72  "Failed get number of cameras");
73  if (num_devices) {
74  std::cout << "Number of cameras found: " << num_devices << std::endl;
75  for (unsigned i = 0; i < num_devices; ++i) {
76  PGRGuid guid;
77  std::ostringstream s;
78  s << i;
79  PGERROR(bus_manager.GetCameraFromIndex(i, &guid),
80  "Failed to get camera from index " + s.str());
81 
82  Camera camera;
83  PGERROR(camera.Connect(&guid), "Failed to connect to camera");
84 
85  CameraInfo cinfo;
86  PGERROR(camera.GetCameraInfo(&cinfo), "Failed to get camera info");
87 
88  std::cout << "[" << i << "]";
89  printCameraInfo(cinfo);
90  }
91  } else {
92  // No cameras found
93  std::cout << "No PointGrey cameras detected on this computer."
94  << std::endl << std::endl;
95 
96  std::cout << "Note that you may need to restart udev and "
97  "replug your camera, eg:" << std::endl
98  << " sudo service udev restart" << std::endl;
99  }
100  } catch (const std::runtime_error& e) {
101  std::cout << "There was an error checking the active cameras: " << e.what()
102  << std::endl;
103  }
104 }
Interface to Point Grey cameras.
XmlRpcServer s
#define PGERROR(error, msg)
void printCameraInfo(const CameraInfo &cinfo)
int main(int argc, char **argv)


pointgrey_camera_driver
Author(s): Chad Rockey
autogenerated on Fri May 8 2020 03:10:28