void printCameras() { FlyCapture2::BusManager busMgr; unsigned int cameraNum; if(!check_success(busMgr.GetNumOfCameras(&cameraNum))) return; ROS_INFO ("Found %d cameras", cameraNum); for (unsigned int i = 0; i < cameraNum; i++) { unsigned int serNo; if(check_success(busMgr.GetCameraSerialNumberFromIndex(i, &serNo))) { ROS_INFO ("Camera %u: S/N %u", i, serNo); } } }
/*! Return the serial id of a camera with \e index. \param index : Camera index. The following code shows how to retrieve the serial id of all the cameras that are connected on the bus. \code #include <visp3/flycapture/vpFlyCaptureGrabber.h> int main() { #if defined(VISP_HAVE_FLYCAPTURE) vpFlyCaptureGrabber g; unsigned int num_cameras = vpFlyCaptureGrabber::getNumCameras(); for (unsigned int i=0; i<num_cameras; i++) { unsigned int serial_id = vpFlyCaptureGrabber::getCameraSerial(i); std::cout << "Camera with index " << i << " has serial id: " << serial_id << std::endl; } #endif } \endcode When two cameras are connected (PGR Flea3 in our case), we get the following: \code Camera with index 0 has serial id: 15372913 Camera with index 1 has serial id: 15290004 \endcode \sa setCameraSerial() */ unsigned int vpFlyCaptureGrabber::getCameraSerial(unsigned int index) { unsigned int num_cameras = vpFlyCaptureGrabber::getNumCameras(); if(index >= num_cameras) { throw (vpException(vpException::badValue, "The camera with index %u is not present. Only %d cameras connected.", index, num_cameras) ); } unsigned int serial_id; FlyCapture2::BusManager busMgr; FlyCapture2::Error error; error = busMgr.GetCameraSerialNumberFromIndex(index, &serial_id); if (error != FlyCapture2::PGRERROR_OK) { error.PrintErrorTrace(); throw (vpException(vpException::fatalError, "Cannot get camera with index %d serial id.", index) ); } return serial_id; }
void init() { FlyCapture2::Error error; FlyCapture2::BusManager busMgr; for (int tries = 0; tries < 5; ++tries) { if ((error = busMgr.GetNumOfCameras(&cameraNum)) != PGRERROR_OK) ROS_ERROR (error.GetDescription ()); if (cameraNum) { ROS_INFO ("Found %d cameras", cameraNum); unsigned int serNo; for (unsigned int i = 0; i < cameraNum; i++) { if ((error = busMgr.GetCameraSerialNumberFromIndex(i, &serNo)) != PGRERROR_OK) ROS_ERROR (error.GetDescription ()); else ROS_INFO ("Camera %u: S/N %u", i, serNo); } } return; usleep(200000); } }