本文整理汇总了C++中boost::format::parse方法的典型用法代码示例。如果您正苦于以下问题:C++ format::parse方法的具体用法?C++ format::parse怎么用?C++ format::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::format
的用法示例。
在下文中一共展示了format::parse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
ros::init(argc, argv, "image_saver", ros::init_options::AnonymousName);
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
//std::string topic = nh.resolveName("image");
// std::string topic = "/ardrone/image_raw";
std::string topic = "/ardrone/kinect/image_raw";
std::string topic_depth = "/ardrone/kinect/depth/image_raw";
Callbacks callbacks;
//callbacks.control ="10000000";
//callbacks.path = "/home/jay/data/";
//obtain saving location
std::string saving_location = nh.resolveName("generated_set");
//if(saving_location.compare("generated_set")) saving_location = "remote_images/set_online";
callbacks.path = "/home/jay/data/"+saving_location;
boost::filesystem::path dir(callbacks.path);
boost::filesystem::remove_all(dir);
if(boost::filesystem::create_directory(dir)) {
callbacks.path_depth = callbacks.path+"/depth";
boost::filesystem::path dir_depth(callbacks.path_depth);
if(boost::filesystem::create_directory(dir_depth)) {
std::cout << "Success in creating: "<<callbacks.path_depth << "\n";
}
callbacks.path = callbacks.path+"/RGB";
boost::filesystem::path dir_rgb(callbacks.path);
if(boost::filesystem::create_directory(dir_rgb)) {
std::cout << "Success in creating: "<<callbacks.path << "\n";
}
}else{
std::cout <<"Failed to make saving direction "<<callbacks.path <<"\n";
}
// Useful when CameraInfo is being published
/*image_transport::CameraSubscriber sub_image_and_camera = it.subscribeCamera(topic, 1,
&Callbacks::callbackWithCameraInfo,
&callbacks);*/
// Useful when CameraInfo is not being published
image_transport::Subscriber sub_image = it.subscribe(
topic, 1, boost::bind(&Callbacks::callbackWithoutCameraInfo, &callbacks, _1));
//depth
image_transport::Subscriber sub_image_depth = it.subscribe(
topic_depth, 1, boost::bind(&Callbacks::callbackWithoutCameraInfoWithDepth, &callbacks, _1));
// Make subscriber to cmd_vel in order to set the name.
ros::Subscriber takeOff = nh.subscribe("/ardrone/takeoff",1,&Callbacks::callbackTakeoff, &callbacks);
ros::Subscriber subControl = nh.subscribe("/dagger_vel",1,&Callbacks::callbackCmd, &callbacks);
// [hover, back, forward, turn right, turn left, down, up, clockwise, ccw]
// Adapt name instead of left0000.jpg it should be 00000-gt1.jpg when receiving control 1 ~ straight
ros::NodeHandle local_nh("~");
std::string format_string;
local_nh.param("filename_format", format_string, std::string("%s/%010i-gt%s.%s"));
local_nh.param("encoding", encoding, std::string("bgr8"));
local_nh.param("save_all_image", save_all_image, true);
g_format.parse(format_string);
ros::ServiceServer save = local_nh.advertiseService ("save", service);
ros::spin();
}
示例2: main
int main(int argc, char** argv)
{
ros::init(argc, argv, "image_saver", ros::init_options::AnonymousName);
ros::NodeHandle nh;
g_format.parse("left%04i.%s");
image_transport::ImageTransport it(nh);
std::string topic = nh.resolveName("image");
image_transport::CameraSubscriber sub = it.subscribeCamera(topic, 1, &callback);
ros::spin();
}
示例3: onInit
void ImageNodelet::onInit()
{
ros::NodeHandle nh = getNodeHandle();
ros::NodeHandle local_nh = getPrivateNodeHandle();
// Command line argument parsing
const std::vector<std::string>& argv = getMyArgv();
// First positional argument is the transport type
std::string transport;
local_nh.param("image_transport", transport, std::string("raw"));
for (int i = 0; i < (int)argv.size(); ++i)
{
if (argv[i][0] != '-')
{
transport = argv[i];
break;
}
}
NODELET_INFO_STREAM("Using transport \"" << transport << "\"");
// Internal option, should be used only by the image_view node
bool shutdown_on_close = std::find(argv.begin(), argv.end(),
"--shutdown-on-close") != argv.end();
// Default window name is the resolved topic name
std::string topic = nh.resolveName("image");
local_nh.param("window_name", window_name_, topic);
bool autosize;
local_nh.param("autosize", autosize, false);
std::string format_string;
local_nh.param("filename_format", format_string, std::string("frame%04i.jpg"));
filename_format_.parse(format_string);
cv::namedWindow(window_name_, autosize ? cv::WND_PROP_AUTOSIZE : 0);
cv::setMouseCallback(window_name_, &ImageNodelet::mouseCb, this);
#ifdef HAVE_GTK
// Register appropriate handler for when user closes the display window
GtkWidget *widget = GTK_WIDGET( cvGetWindowHandle(window_name_.c_str()) );
if (shutdown_on_close)
g_signal_connect(widget, "destroy", G_CALLBACK(destroyNode), NULL);
else
g_signal_connect(widget, "destroy", G_CALLBACK(destroyNodelet), &sub_);
#endif
// Start the OpenCV window thread so we don't have to waitKey() somewhere
startWindowThread();
image_transport::ImageTransport it(nh);
image_transport::TransportHints hints(transport, ros::TransportHints(), getPrivateNodeHandle());
sub_ = it.subscribe(topic, 1, &ImageNodelet::imageCb, this, hints);
}
示例4: main
int main(int argc, char **argv)
{
ros::init(argc, argv, "image_view", ros::init_options::AnonymousName);
if (ros::names::remap("image") == "image") {
ROS_WARN("Topic 'image' has not been remapped! Typical command-line usage:\n"
"\t$ rosrun image_view image_view image:=<image topic> [transport]");
}
ros::NodeHandle nh;
ros::NodeHandle local_nh("~");
// Default window name is the resolved topic name
std::string topic = nh.resolveName("image");
local_nh.param("window_name", g_window_name, topic);
std::string format_string;
local_nh.param("filename_format", format_string, std::string("frame%04i.jpg"));
g_filename_format.parse(format_string);
// Handle window size
bool autosize;
local_nh.param("autosize", autosize, false);
cv::namedWindow(g_window_name, autosize ? (CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED) : 0);
cv::setMouseCallback(g_window_name, &mouseCb);
// Start the OpenCV window thread so we don't have to waitKey() somewhere
cv::startWindowThread();
// Handle transport
// priority:
// 1. command line argument
// 2. rosparam '~image_transport'
std::string transport;
local_nh.param("image_transport", transport, std::string("raw"));
ros::V_string myargv;
ros::removeROSArgs(argc, argv, myargv);
for (size_t i = 1; i < myargv.size(); ++i) {
if (myargv[i][0] != '-') {
transport = myargv[i];
break;
}
}
ROS_INFO_STREAM("Using transport \"" << transport << "\"");
image_transport::ImageTransport it(nh);
image_transport::TransportHints hints(transport, ros::TransportHints(), local_nh);
image_transport::Subscriber sub = it.subscribe(topic, 1, imageCb, hints);
ros::spin();
cv::destroyWindow(g_window_name);
return 0;
}
示例5: local_nh
ExtractImages(const ros::NodeHandle& nh, const std::string& transport)
: filename_format_(""), count_(0), _time(ros::Time::now().toSec())
{
std::string topic = nh.resolveName("image");
ros::NodeHandle local_nh("~");
std::string format_string;
local_nh.param("filename_format", format_string, std::string("frame%05i.png"));
filename_format_.parse(format_string);
local_nh.param("sec_per_frame", sec_per_frame_, 0.1);
image_transport::ImageTransport it(nh);
sub_ = it.subscribe(topic, 1, &ExtractImages::image_cb, this, transport);
#if defined(_VIDEO)
video_writer = 0;
#endif
ROS_INFO("Initialized sec per frame to %f", sec_per_frame_);
}
示例6: main
int main(int argc, char** argv)
{
ros::init(argc, argv, "image_saver", ros::init_options::AnonymousName);
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
std::string topic = nh.resolveName("image");
Callbacks callbacks;
// Useful when CameraInfo is being published
image_transport::CameraSubscriber sub_image_and_camera = it.subscribeCamera(topic, 1,
&Callbacks::callbackWithCameraInfo,
&callbacks);
// Useful when CameraInfo is not being published
image_transport::Subscriber sub_image = it.subscribe(
topic, 1, boost::bind(&Callbacks::callbackWithoutCameraInfo, &callbacks, _1));
ros::NodeHandle local_nh("~");
std::string format_string;
local_nh.param("filename_format", format_string, std::string("left%04i.%s"));
local_nh.param("encoding", encoding, std::string("bgr8"));
local_nh.param("save_all_image", save_all_image, true);
local_nh.param("request_start_end", request_start_end, false);
g_format.parse(format_string);
ros::ServiceServer save = local_nh.advertiseService ("save", service);
if (request_start_end && !save_all_image)
ROS_WARN("'request_start_end' is true, so overwriting 'save_all_image' as true");
// FIXME(unkown): This does not make services appear
// if (request_start_end) {
ros::ServiceServer srv_start = local_nh.advertiseService(
"start", &Callbacks::callbackStartSave, &callbacks);
ros::ServiceServer srv_end = local_nh.advertiseService(
"end", &Callbacks::callbackEndSave, &callbacks);
// }
ros::spin();
}
示例7: main
int main(int argc, char** argv)
{
ros::init(argc, argv, "file_publisher");
ros::NodeHandle nh;
// Declare variables that can be modified by launch file or command line.
std::string file;
int frequency;
// Setting parameters with default values
nh.setParam("file", std::string("/home/young/文档/test_pics/ball/level4/blurry/frame"));//
nh.setParam("frequency", int(1));
// Getting the values of parameters if set from launch file or command line
nh.getParam("file", file);
nh.getParam("frequency", frequency);
image_transport::ImageTransport it(nh);
image_transport::Publisher pub = it.advertise("image", 1);
ros::Rate loop_rate(frequency);
ROS_INFO("Ready to publish loaded image from directory:[%s] of frequency:[%d]", file.c_str(), frequency);
int i;
i = START_NUM; // 根据读入的文件名进行修改/home/young/文档/test_pics/ball/level1/clear/frame
g_format.parse("%s%04d.%s");
while (nh.ok()) {
if (i == END_NUM) i = START_NUM;// 根据读入的文件名进行修改/home/young/文档/test_pics/ball/level1/clear/frame
std::string filename = (g_format %file % i % "jpg").str();
/*std::stringstream ss;
ss << file << i << ".bmp";
ss >> filename;*/
//sprintf(filename, "/home/chy/pictures/%d.bmp", i);
ROS_INFO("Ready to publish loaded image from file:[%s]", filename.c_str());
// Loading the image, converting it to cv_bridge::CvImage type and to sensor_msgs::ImagePtr using .toImageMsg()
// cv::WImageBuffer3_b image( cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_COLOR) );
// cv::Mat imageMat(image.Ipl());
cv::Mat imageMat = cv::imread(filename.c_str(), 1);
if(!imageMat.data)
{
continue;
}
cv_bridge::CvImage out_msg;
out_msg.encoding = "bgr8";
out_msg.encoding = sensor_msgs::image_encodings::BGR8;
out_msg.image = imageMat;
// out_msg.header.seq = i;
// out_msg.header.frame_id = i;
out_msg.header.stamp = ros::Time::now();
// ci->header.seq = i;
// ci->header.frame_id = i;
// ci->header.stamp = out_msg.header.stamp;
sensor_msgs::ImagePtr msg = out_msg.toImageMsg();
pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
//image.ReleaseImage();
//imageMat.release();
i++;
}
}