本文整理汇总了C++中flycapture2::Error::PrintErrorTrace方法的典型用法代码示例。如果您正苦于以下问题:C++ Error::PrintErrorTrace方法的具体用法?C++ Error::PrintErrorTrace怎么用?C++ Error::PrintErrorTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flycapture2::Error
的用法示例。
在下文中一共展示了Error::PrintErrorTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: acquire
/*!
Acquire a color image from the active camera.
\param I : Image data structure (RGBa image).
\param timestamp : The acquisition timestamp.
*/
void vpFlyCaptureGrabber::acquire(vpImage<vpRGBa> &I, FlyCapture2::TimeStamp ×tamp)
{
this->open();
FlyCapture2::Error error;
// Retrieve an image
error = m_camera.RetrieveBuffer( &m_rawImage );
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError,
"Cannot retrieve image for camera with guid 0x%lx",
m_guid) );
}
timestamp = m_rawImage.GetTimeStamp();
// Create a converted image
FlyCapture2::Image convertedImage;
// Convert the raw image
error = m_rawImage.Convert( FlyCapture2::PIXEL_FORMAT_RGBU, &convertedImage );
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError,
"Cannot convert image for camera with guid 0x%lx",
m_guid) );
}
height = convertedImage.GetRows();
width = convertedImage.GetCols();
unsigned char *data = convertedImage.GetData();
I.resize(height, width);
unsigned int bps = convertedImage.GetBitsPerPixel();
memcpy(I.bitmap, data, width*height*bps/8);
}
示例2: connect
/*!
Connect the active camera.
\sa disconnect()
*/
void vpFlyCaptureGrabber::connect()
{
if (m_connected == false) {
FlyCapture2::Error error;
m_numCameras = this->getNumCameras();
if (m_numCameras == 0) {
throw (vpException(vpException::fatalError, "No camera found on the bus"));
}
FlyCapture2::BusManager busMgr;
error = busMgr.GetCameraFromIndex(m_index, &m_guid);
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError,
"Cannot retrieve guid of camera with index %u.",
m_index) );
}
// Connect to a camera
error = m_camera.Connect(&m_guid);
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError,
"Cannot connect to camera with guid 0x%lx", m_guid));
}
m_connected = true;
}
if (m_connected && m_capture)
init = true;
else
init = false;
}
示例3: main
/*!
Power on/off the camera.
\param on : true to power on the camera, false to power off the camera.
The following example shows how to turn off a camera.
\code
#include <visp3/flycapture/vpFlyCaptureGrabber.h>
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
vpFlyCaptureGrabber g;
g.setCameraIndex(0);
g.connect();
bool power = g.getCameraPower();
std::cout << "Camera is powered: " << ((power == true) ? "on" : "off") << std::endl;
if (power)
g.setCameraPower(false); // Power off the camera
#endif
}
\endcode
\sa getCameraPower()
*/
void vpFlyCaptureGrabber::setCameraPower(bool on)
{
this->connect();
if ( ! isCameraPowerAvailable() ) {
throw (vpException(vpException::badValue,
"Cannot power on camera. Feature not available") );
}
// Power on the camera
const unsigned int powerReg = 0x610;
unsigned int powerRegVal = 0;
powerRegVal = (on == true) ? 0x80000000 : 0x0;
FlyCapture2::Error error;
error = m_camera.WriteRegister( powerReg, powerRegVal );
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError, "Cannot power on the camera.") );
}
const unsigned int millisecondsToSleep = 100;
unsigned int regVal = 0;
unsigned int retries = 10;
// Wait for camera to complete power-up
do
{
vpTime::wait(millisecondsToSleep);
error = m_camera.ReadRegister(powerReg, ®Val);
if (error == FlyCapture2::PGRERROR_TIMEOUT) {
// ignore timeout errors, camera may not be responding to
// register reads during power-up
}
else if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError, "Cannot power on the camera.") );
}
retries--;
} while ((regVal & powerRegVal) == 0 && retries > 0);
// Check for timeout errors after retrying
if (error == FlyCapture2::PGRERROR_TIMEOUT) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError, "Cannot power on the camera. Timeout occur") );
}
}
示例4: frameToImage
static bool frameToImage (FlyCapture2::Image * frame, sensor_msgs::Image & image)
{
// Get the raw image dimensions
FlyCapture2::PixelFormat pixFormat;
uint32_t rows, cols, stride;
FlyCapture2::Image convertedImage;
FlyCapture2::Error error;
error = frame->Convert(FlyCapture2::PIXEL_FORMAT_RGB, &convertedImage );
if (error != FlyCapture2::PGRERROR_OK)
{
error.PrintErrorTrace();
return false;
}
// Get the raw image dimensions
convertedImage.GetDimensions( &rows, &cols, &stride, &pixFormat );
return sensor_msgs::fillImage (image, sensor_msgs::image_encodings::RGB8,
rows, cols, stride,
convertedImage.GetData ());
}
示例5: ptgr_err
// Print point grey errors.
void TrackerDataSource::ptgr_err( FlyCapture2::Error error ){
if(error != FlyCapture2::PGRERROR_OK){
error.PrintErrorTrace();
std::cout << "Press Enter to continue" << std::endl;
getchar();
}
}
示例6: _pgrSafeCall
void _pgrSafeCall(FlyCapture2::Error err, std::string fileName, int lineNum)
{
if(err != FlyCapture2::PGRERROR_OK)
{
std::cout << "File: " << fileName << " Line: " << lineNum << std::endl;
err.PrintErrorTrace();
std::cout << std::endl;
}
}
示例7: start
int VideoHandler::start() {
if (m_stopped) {
if ( m_camera) {
FlyCapture2::BusManager busMgr;
FlyCapture2::Error error;
FlyCapture2::PGRGuid guid;
cout << m_camIdx << endl;
error = busMgr.GetCameraFromIndex( m_camIdx, &guid );
if (error != PGRERROR_OK)
{
error.PrintErrorTrace();
return -1;
}
cout << "got camera from index" << endl;
pVideoSaver = new VideoSaver();
cout << "created VideoSaver" << endl;
if (pVideoSaver->init(guid)!=0){
cout << "Warning: Error in initializing the camera\n" ;
return -1;
}
if (fname.empty()) {
cout << "start capture thread" << endl;
if (pVideoSaver->startCapture()!=0) {
cout << "Warning: Error in starting the capture thread the camera \n";
return -1;
}
}
else {
cout << "start capture and write threads" << endl;
if (pVideoSaver->startCaptureAndWrite(fname,string("X264"))!=0) {
cout << "Warning: Error in starting the writing thread the camera \n";
return -1;
}
}
}
else {
pVideoCapture = new VideoCapture(fname);
//pVideoCapture->set(cv::CAP_PROP_CONVERT_RGB,true); // output RGB
}
if (knnMethod)
pBackgroundSubtractor = cv::createBackgroundSubtractorKNN(250,400,false);
else
pBackgroundThresholder = new BackgroundThresholder();
m_stopped=false;
startThreads();
}
return 0;
}
示例8: isVideoModeAndFrameRateSupported
/*!
Return true if video mode and framerate is supported.
*/
bool vpFlyCaptureGrabber::isVideoModeAndFrameRateSupported(FlyCapture2::VideoMode video_mode,
FlyCapture2::FrameRate frame_rate)
{
this->connect();
FlyCapture2::Error error;
bool supported = false;
error = m_camera.GetVideoModeAndFrameRateInfo(video_mode, frame_rate, &supported);
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError, "Cannot get video mode and framerate.") );
}
return supported;
}
示例9: stopCamera
int VideoSaverFlyCapture::stopCamera() {
if (isFlyCapture()) {
if (m_Camera.IsConnected()) {
FlyCapture2::Error error = m_Camera.Disconnect();
if ( error != FlyCapture2::PGRERROR_OK ) {
error.PrintErrorTrace();
return -1;
}
}
return 0;
} else {
return VideoSaver::stopCamera();
}
}
示例10: getProperty
/*!
Return property values.
\param prop_type : Property type.
*/
FlyCapture2::Property vpFlyCaptureGrabber::getProperty(FlyCapture2::PropertyType prop_type)
{
this->connect();
FlyCapture2::Property prop;
prop.type = prop_type;
FlyCapture2::Error error;
error = m_camera.GetProperty( &prop );
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError,
"Cannot get property %d value.", (int)prop_type));
}
return prop;
}
示例11: throw
/*!
Return true if format7 mode is supported.
*/
bool vpFlyCaptureGrabber::isFormat7Supported(FlyCapture2::Mode format7_mode)
{
this->connect();
FlyCapture2::Format7Info fmt7_info;
bool supported = false;
FlyCapture2::Error error;
fmt7_info.mode = format7_mode;
error = m_camera.GetFormat7Info(&fmt7_info, &supported);
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError, "Cannot get format7 info.") );
}
return supported;
}
示例12: disconnect
/*!
Disconnect the active camera.
\sa connect()
*/
void vpFlyCaptureGrabber::disconnect()
{
if (m_connected == true) {
FlyCapture2::Error error;
error = m_camera.Disconnect();
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError, "Cannot stop capture.") );
}
m_connected = false;
}
if (m_connected && m_capture)
init = true;
else
init = false;
}
示例13: startCapture
/*!
Start active camera capturing images.
\sa stopCapture()
*/
void vpFlyCaptureGrabber::startCapture()
{
this->connect();
if (m_capture == false) {
FlyCapture2::Error error;
error = m_camera.StartCapture();
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError,
"Cannot start capture for camera with guid 0x%lx", m_guid));
}
m_capture = true;
}
if (m_connected && m_capture)
init = true;
else
init = false;
}
示例14: information
/*!
Print to the output stream active camera information (serial number, camera model,
camera vendor, sensor, resolution, firmaware version, ...).
*/
std::ostream &vpFlyCaptureGrabber::getCameraInfo(std::ostream & os)
{
this->connect();
FlyCapture2::CameraInfo camInfo;
FlyCapture2::Error error = m_camera.GetCameraInfo(&camInfo);
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
}
os << "Camera information: " << std::endl;
os << " Serial number : " << camInfo.serialNumber << std::endl;
os << " Camera model : " << camInfo.modelName << std::endl;
os << " Camera vendor : " << camInfo.vendorName << std::endl;
os << " Sensor : " << camInfo.sensorInfo << std::endl;
os << " Resolution : " << camInfo.sensorResolution << std::endl;
os << " Firmware version : " << camInfo.firmwareVersion << std::endl;
os << " Firmware build time: " << camInfo.firmwareBuildTime << std::endl;
return os;
}
示例15: setProperty
/*!
Set camera property.
\param prop_type : Property type.
\param on : true to turn property on.
\param auto_on : true to turn auto mode on, false to turn manual mode.
\param value : value to set.
\param prop_value : Switch to affect value to the corresponding variable.
*/
void vpFlyCaptureGrabber::setProperty(const FlyCapture2::PropertyType &prop_type,
bool on, bool auto_on,
float value, PropertyValue prop_value)
{
this->connect();
FlyCapture2::PropertyInfo propInfo;
propInfo = this->getPropertyInfo(prop_type);
if (propInfo.present) {
FlyCapture2::Property prop;
prop.type = prop_type;
prop.onOff = on && propInfo.onOffSupported;
prop.autoManualMode = auto_on && propInfo.autoSupported;
prop.absControl = propInfo.absValSupported;
switch(prop_value) {
case ABS_VALUE: {
float value_ = std::max<float>(std::min<float>(value, propInfo.absMax), propInfo.absMin);
prop.absValue = value_;
break;
}
case VALUE_A: {
unsigned int value_ = std::max<unsigned int>(std::min<unsigned int>((unsigned int)value, propInfo.max), propInfo.min);
prop.valueA = value_;
break;
}
}
FlyCapture2::Error error;
error = m_camera.SetProperty(&prop);
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
throw (vpException(vpException::fatalError,
"Cannot set property %d.",
(int)prop_type) );
}
}
}