Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
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
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 }