本文整理汇总了C++中boost::format::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ format::clear方法的具体用法?C++ format::clear怎么用?C++ format::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::format
的用法示例。
在下文中一共展示了format::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveImage
bool saveImage(cv::Mat image, std::string &filename, bool depth = false) {
if (!image.empty()) {
try {
filename = (g_format).str();
} catch (...) { g_format.clear(); }
try {
filename = (g_format % path).str();
} catch (...) { g_format.clear(); }
try {
filename = (g_format % path % count_).str();
} catch (...) { g_format.clear(); }
try {
filename = (g_format % path % count_ % "jpg").str();
} catch (...) { g_format.clear(); }
try {
if(!depth){
filename = (g_format % path % count_ % control % "jpg").str();
}else{
filename = (g_format % path_depth % count_ % control % "jpg").str();
}
} catch (...) { g_format.clear(); }
if ( save_all_image || save_image_service ) {
try{
cv::imwrite(filename, image);
ROS_INFO("Saved image %s", filename.c_str());
save_image_service = false;
}catch(runtime_error& ex){
fprintf(stderr, "Exception converting image to PNG format: %s\n", ex.what());
return false;
}
} else {
return false;
}
} else {
ROS_WARN("Couldn't save image, no data!");
return false;
}
return true;
}
示例2: saveImage
bool saveImage(const sensor_msgs::ImageConstPtr& image_msg, std::string &filename) {
cv::Mat image;
try
{
image = cv_bridge::toCvShare(image_msg, encoding)->image;
} catch(cv_bridge::Exception)
{
ROS_ERROR("Unable to convert %s image to bgr8", image_msg->encoding.c_str());
return false;
}
if (!image.empty()) {
try {
filename = (g_format).str();
} catch (...) { g_format.clear(); }
try {
filename = (g_format % count_).str();
} catch (...) { g_format.clear(); }
try {
filename = (g_format % count_ % "jpg").str();
} catch (...) { g_format.clear(); }
if ( save_all_image || save_image_service ) {
cv::imwrite(filename, image);
ROS_INFO("Saved image %s", filename.c_str());
save_image_service = false;
} else {
return false;
}
} else {
ROS_WARN("Couldn't save image, no data!");
return false;
}
return true;
}