34 #include <image_view/ImageViewConfig.h> 39 #include <dynamic_reconfigure/server.h> 42 #include <opencv2/highgui/highgui.hpp> 45 #include <boost/bind.hpp> 46 #include <boost/thread.hpp> 47 #include <boost/format.hpp> 59 void set(
const cv::Mat& image);
68 boost::unique_lock<boost::mutex> lock(
mutex_);
75 boost::unique_lock<boost::mutex> lock(
mutex_);
83 boost::unique_lock<boost::mutex> lock(
mutex_);
109 dynamic_reconfigure::Server<image_view::ImageViewConfig>
srv_;
115 virtual void onInit();
117 void reconfigureCb(image_view::ImageViewConfig &config, uint32_t level);
119 void imageCb(
const sensor_msgs::ImageConstPtr& msg);
121 static void mouseCb(
int event,
int x,
int y,
int flags,
void* param);
132 : filename_format_(
""), count_(0)
151 const std::vector<std::string>& argv =
getMyArgv();
153 std::string transport;
154 local_nh.
param(
"image_transport", transport, std::string(
"raw"));
155 for (
int i = 0; i < (int)argv.size(); ++i)
157 if (argv[i][0] !=
'-')
165 bool shutdown_on_close = std::find(argv.begin(), argv.end(),
166 "--shutdown-on-close") != argv.end();
174 std::string format_string;
175 local_nh.
param(
"filename_format", format_string, std::string(
"frame%04i.jpg"));
185 dynamic_reconfigure::Server<image_view::ImageViewConfig>::CallbackType
f =
201 bool do_dynamic_scaling;
202 if (msg->encoding.find(
"F") != std::string::npos) {
203 do_dynamic_scaling =
true;
220 if (msg->encoding ==
"32FC1") {
222 }
else if (msg->encoding ==
"16UC1") {
234 msg->encoding.c_str(), e.what());
245 boost::function<const std::string&()>
getName =
248 if (event == cv::EVENT_LBUTTONDOWN)
253 if (event != cv::EVENT_RBUTTONDOWN)
268 catch (
const boost::io::too_many_args&)
273 if (cv::imwrite(filename, image))
305 catch (
const boost::thread_interrupted&)
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())
#define NODELET_INFO_STREAM(...)
static void mouseCb(int event, int x, int y, int flags, void *param)
#define NODELET_ERROR(...)
#define NODELET_WARN(...)
void reconfigureCb(image_view::ImageViewConfig &config, uint32_t level)
ros::NodeHandle & getNodeHandle() const
#define NODELET_ERROR_THROTTLE(rate,...)
boost::format filename_format_
ros::NodeHandle & getPrivateNodeHandle() const
const std::string & getName() const
boost::thread window_thread_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void publish(const boost::shared_ptr< M > &message) const
image_transport::Subscriber sub_
std::string resolveName(const std::string &name, bool remap=true) const
ThreadSafeImage shown_image_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define NODELET_WARN_ONCE(...)
void set(const cv::Mat &image)
const V_string & getMyArgv() const
#define NODELET_INFO(...)
ThreadSafeImage queued_image_
CvImageConstPtr cvtColorForDisplay(const CvImageConstPtr &source, const std::string &encoding=std::string(), const CvtColorForDisplayOptions options=CvtColorForDisplayOptions())
ROSCPP_DECL void shutdown()
boost::condition_variable condition_
uint32_t getNumSubscribers() const
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
void imageCb(const sensor_msgs::ImageConstPtr &msg)
dynamic_reconfigure::Server< image_view::ImageViewConfig > srv_