36 #ifndef IMAGE_VIEW2_H_ 37 #define IMAGE_VIEW2_H_ 39 #include <opencv/cv.h> 40 #include <opencv2/highgui/highgui.hpp> 43 #include <sensor_msgs/Image.h> 49 #include <dynamic_reconfigure/server.h> 51 #include <image_view2/ImageMarker2.h> 52 #include <geometry_msgs/PointStamped.h> 53 #include <geometry_msgs/PolygonStamped.h> 54 #include <std_msgs/Empty.h> 55 #include <std_srvs/Empty.h> 56 #include <image_view2/ChangeMode.h> 57 #include <boost/thread.hpp> 58 #include <boost/format.hpp> 59 #include <boost/foreach.hpp> 60 #include <boost/circular_buffer.hpp> 61 #include <boost/lambda/lambda.hpp> 62 #include <pcl/point_types.h> 64 #include <image_view2/ImageView2Config.h> 66 #include <image_view2/MouseEvent.h> 68 #define DEFAULT_COLOR CV_RGB(255,0,0) 69 #define USER_ROI_COLOR CV_RGB(255,0,0) 70 #define DEFAULT_CIRCLE_SCALE 20 71 #define DEFAULT_LINE_WIDTH 3 76 inline CvScalar
MsgToRGB(
const std_msgs::ColorRGBA &color){
77 if(color.a == 0.0 && color.r == 0.0 && color.g == 0.0 && color.b == 0.0)
80 return CV_RGB(color.r*255, color.g*255, color.b*255);
101 void markerCb(
const image_view2::ImageMarker2ConstPtr& marker);
102 void infoCb(
const sensor_msgs::CameraInfoConstPtr& msg);
104 void imageCb(
const sensor_msgs::ImageConstPtr& msg);
115 static void mouseCb(
int event,
int x,
int y,
int flags,
void* param);
117 const cv::Point2f& end_point);
125 const image_view2::MouseEvent::ConstPtr& event_msg);
130 const std_msgs::Header& header);
133 const std_msgs::Header& header);
137 void drawLineStrip(
const image_view2::ImageMarker2::ConstPtr& marker,
138 std::vector<CvScalar>& colors,
139 std::vector<CvScalar>::iterator& col_it);
140 void drawLineList(
const image_view2::ImageMarker2::ConstPtr& marker,
141 std::vector<CvScalar>& colors,
142 std::vector<CvScalar>::iterator& col_it);
143 void drawPolygon(
const image_view2::ImageMarker2::ConstPtr& marker,
144 std::vector<CvScalar>& colors,
145 std::vector<CvScalar>::iterator& col_it);
146 void drawPoints(
const image_view2::ImageMarker2::ConstPtr& marker,
147 std::vector<CvScalar>& colors,
148 std::vector<CvScalar>::iterator& col_it);
149 void drawFrames(
const image_view2::ImageMarker2::ConstPtr& marker,
150 std::vector<CvScalar>& colors,
151 std::vector<CvScalar>::iterator& col_it);
152 void drawText(
const image_view2::ImageMarker2::ConstPtr& marker,
153 std::vector<CvScalar>& colors,
154 std::vector<CvScalar>::iterator& col_it);
155 void drawLineStrip3D(
const image_view2::ImageMarker2::ConstPtr& marker,
156 std::vector<CvScalar>& colors,
157 std::vector<CvScalar>::iterator& col_it);
158 void drawLineList3D(
const image_view2::ImageMarker2::ConstPtr& marker,
159 std::vector<CvScalar>& colors,
160 std::vector<CvScalar>::iterator& col_it);
161 void drawPolygon3D(
const image_view2::ImageMarker2::ConstPtr& marker,
162 std::vector<CvScalar>& colors,
163 std::vector<CvScalar>::iterator& col_it);
164 void drawPoints3D(
const image_view2::ImageMarker2::ConstPtr& marker,
165 std::vector<CvScalar>& colors,
166 std::vector<CvScalar>::iterator& col_it);
167 void drawText3D(
const image_view2::ImageMarker2::ConstPtr& marker,
168 std::vector<CvScalar>& colors,
169 std::vector<CvScalar>::iterator& col_it);
170 void drawCircle3D(
const image_view2::ImageMarker2::ConstPtr& marker,
171 std::vector<CvScalar>& colors,
172 std::vector<CvScalar>::iterator& col_it);
173 void drawCircle(
const image_view2::ImageMarker2::ConstPtr& marker);
181 std::string frame_id,
ros::Time& acquisition_time,
182 std::map<std::string, int>& tf_fail,
294 image_view2::ChangeModeRequest& req,
295 image_view2::ChangeModeResponse& res);
297 std_srvs::EmptyRequest& req,
298 std_srvs::EmptyResponse& res);
300 std_srvs::EmptyRequest& req,
301 std_srvs::EmptyResponse& res);
303 std_srvs::EmptyRequest& req,
304 std_srvs::EmptyResponse& res);
306 std_srvs::EmptyRequest& req,
307 std_srvs::EmptyResponse& res);
309 std_srvs::EmptyRequest& req,
310 std_srvs::EmptyResponse& res);
312 std_srvs::EmptyRequest& req,
313 std_srvs::EmptyResponse& res);
315 std_srvs::EmptyRequest& req,
316 std_srvs::EmptyResponse& res);
void config_callback(Config &config, uint32_t level)
ros::Publisher point_pub_
image_transport::Subscriber image_sub_
std::vector< std::string > frame_ids_
boost::mutex image_mutex_
cv::Point line_end_point_
void setMode(KEY_MODE mode)
ros::Subscriber info_sub_
cv::Point2f button_up_pos_
void updateLineEndPoint(cv::Point p)
void publishMonoImage(ros::Publisher &pub, cv::Mat &image, const std_msgs::Header &header)
ros::ServiceServer grabcut_mode_srv_
void updatePolyPoint(cv::Point p)
ros::ServiceServer rectangle_mode_srv_
void updateLinePoint(cv::Point p)
ros::Publisher rectangle_img_pub_
void addPoint(int x, int y)
bool noneModeServiceCallback(std_srvs::EmptyRequest &req, std_srvs::EmptyResponse &res)
cv::Point poly_selecting_point_
std::vector< cv::Point2d > point_fg_array_
bool left_button_clicked_
void drawPolygon(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
cv_bridge::CvImage img_bridge_
ros::Publisher background_rect_pub_
sensor_msgs::CameraInfoConstPtr info_msg_
boost::circular_buffer< double > times_
ros::ServiceServer line_mode_srv_
void drawText3D(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
void resolveLocalMarkerQueue()
std::string marker_topic_
ros::ServiceServer none_mode_srv_
bool seriesModeServiceCallback(std_srvs::EmptyRequest &req, std_srvs::EmptyResponse &res)
void drawFrames(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
void setRegionWindowPoint(int x, int y)
void drawLineStrip(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
cv::Point line_start_point_
cv::Point getLineStartPoint()
bool isPolySelectingFirstTime()
ros::ServiceServer series_mode_srv_
void drawLineList(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
ros::ServiceServer change_mode_srv_
void drawCircle(const image_view2::ImageMarker2::ConstPtr &marker)
void updateRegionWindowSize(int x, int y)
void publishRectFromMaskImage(ros::Publisher &pub, cv::Mat &image, const std_msgs::Header &header)
bool rectangleModeServiceCallback(std_srvs::EmptyRequest &req, std_srvs::EmptyResponse &res)
KEY_MODE stringToMode(const std::string &str)
bool polyModeServiceCallback(std_srvs::EmptyRequest &req, std_srvs::EmptyResponse &res)
void infoCb(const sensor_msgs::CameraInfoConstPtr &msg)
cv::Point getLineEndPoint()
void drawPoints(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
V_ImageMarkerMessage marker_queue_
void addRegionPoint(int x, int y)
boost::mutex point_array_mutex_
static void mouseCb(int event, int x, int y, int flags, void *param)
bool isSelectingLineStartPoint()
std::vector< cv::Point2d > poly_points_
boost::mutex line_point_mutex_
ros::Publisher rectangle_pub_
cv::Mat distort_grid_mask_
void drawPoints3D(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
std::vector< image_view2::ImageMarker2::ConstPtr > V_ImageMarkerMessage
void drawText(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
void markerCb(const image_view2::ImageMarker2ConstPtr &marker)
void finishSelectingPoly()
void drawLineList3D(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
bool lineModeServiceCallback(std_srvs::EmptyRequest &req, std_srvs::EmptyResponse &res)
boost::mutex queue_mutex_
void processLeftButtonDown(int x, int y)
ros::Publisher background_mask_pub_
ros::Publisher foreground_mask_pub_
std::vector< cv::Point2d > point_array_
sensor_msgs::ImageConstPtr last_msg_
void drawLineStrip3D(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
void createDistortGridImage()
void drawInfo(ros::Time &before_rendering)
image_transport::Publisher local_image_pub_
void processLeftButtonUp(int x, int y)
void imageCb(const sensor_msgs::ImageConstPtr &msg)
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
boost::mutex poly_point_mutex_
bool changeModeServiceCallback(image_view2::ChangeModeRequest &req, image_view2::ChangeModeResponse &res)
void eventCb(const image_view2::MouseEvent::ConstPtr &event_msg)
void updatePolySelectingPoint(cv::Point p)
image_transport::Publisher image_pub_
boost::format filename_format_
ros::ServiceServer poly_mode_srv_
image_geometry::PinholeCameraModel cam_model_
void publishMouseInteractionResult()
void drawPolygon3D(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
bool isValidMovement(const cv::Point2f &start_point, const cv::Point2f &end_point)
bool poly_selecting_done_
V_ImageMarkerMessage local_queue_
ros::Publisher move_point_pub_
bool grabcutRectModeServiceCallback(std_srvs::EmptyRequest &req, std_srvs::EmptyResponse &res)
bool region_continuous_publish_
bool lookupTransformation(std::string frame_id, ros::Time &acquisition_time, std::map< std::string, int > &tf_fail, tf::StampedTransform &transform)
tf::TransformListener tf_listener_
void pointArrayToMask(std::vector< cv::Point2d > &points, cv::Mat &mask)
void checkMousePos(int &x, int &y)
bool grabcutModeServiceCallback(std_srvs::EmptyRequest &req, std_srvs::EmptyResponse &res)
void updateLineStartPoint(cv::Point p)
void processMouseEvent(int event, int x, int y, int flags, void *param)
ros::ServiceServer grabcut_rect_mode_srv_
void processMove(int x, int y)
CvScalar MsgToRGB(const std_msgs::ColorRGBA &color)
std::vector< cv::Point2d > point_bg_array_
bool line_select_start_point_
ros::Subscriber event_sub_
ros::Publisher foreground_rect_pub_
ros::Subscriber marker_sub_
void publishForegroundBackgroundMask()
cv::Point ratioPoint(double x, double y)
void drawCircle3D(const image_view2::ImageMarker2::ConstPtr &marker, std::vector< CvScalar > &colors, std::vector< CvScalar >::iterator &col_it)
ros::Publisher point_array_pub_