34 #include <opencv2/highgui/highgui.hpp> 40 #include <boost/format.hpp> 42 #include <std_srvs/Empty.h> 43 #include <std_srvs/Trigger.h> 51 bool service(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res) {
64 std_srvs::Trigger::Response &res)
66 ROS_INFO(
"Received start saving request");
75 std_srvs::Trigger::Response &res)
77 ROS_INFO(
"Received end saving request");
137 filename = filename.replace(filename.rfind(
"."), filename.length(),
".ini");
151 ROS_ERROR(
"Unable to convert %s image to %s", image_msg->encoding.c_str(),
encoding.c_str());
155 if (!image.empty()) {
167 cv::imwrite(filename, image);
168 ROS_INFO(
"Saved image %s", filename.c_str());
175 ROS_WARN(
"Couldn't save image, no data!");
189 int main(
int argc,
char** argv)
206 std::string format_string;
207 local_nh.
param(
"filename_format", format_string, std::string(
"left%04i.%s"));
215 ROS_WARN(
"'request_start_end' is true, so overwriting 'save_all_image' as true");
CvImageConstPtr toCvShare(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
Subscriber subscribe(const std::string &base_topic, uint32_t queue_size, const boost::function< void(const sensor_msgs::ImageConstPtr &)> &callback, const ros::VoidPtr &tracked_object=ros::VoidPtr(), const TransportHints &transport_hints=TransportHints())
bool service(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
CameraSubscriber subscribeCamera(const std::string &base_topic, uint32_t queue_size, const CameraSubscriber::Callback &callback, const ros::VoidPtr &tracked_object=ros::VoidPtr(), const TransportHints &transport_hints=TransportHints())
std::string resolveName(const std::string &name, bool remap=true) const
void callbackWithCameraInfo(const sensor_msgs::ImageConstPtr &image_msg, const sensor_msgs::CameraInfoConstPtr &info)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool saveImage(const sensor_msgs::ImageConstPtr &image_msg, std::string &filename)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool callbackStartSave(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
ROSCPP_DECL void spin(Spinner &spinner)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
bool writeCalibration(const std::string &file_name, const std::string &camera_name, const sensor_msgs::CameraInfo &cam_info)
int main(int argc, char **argv)
bool callbackEndSave(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
void callbackWithoutCameraInfo(const sensor_msgs::ImageConstPtr &image_msg)