8 #include <opencv2/opencv.hpp>
9 #include <boost/filesystem.hpp>
10 #include <vision_module/Tools/Parameters.hpp>
11 #include <vision_module/Tools/MatPublisher.hpp>
12 #include <vision_module/Projections/CameraProjections.hpp>
13 #include <rqt_vision_module/GuiEvent.h>
14 #include <rqt_vision_module/mouseevent.hpp>
15 #include <vision_module/Tools/LinearBoundaryChecker.hpp>
16 #include <rqt_vision_module/ConsoleMsg.h>
37 return ((length1 >= 0 && length2 >= 0) && GetDistance(realLocation) >= 0
38 && imgLocation.x >= 0 && imgLocation.x < IMGWIDTH
39 && imgLocation.y >= 0 && imgLocation.y < IMGHEIGHT);
43 length1 = length2 = 0;
44 realLocation.x = realLocation.y = 0;
45 imgLocation.x = imgLocation.y = -1;
65 return !hold && isValid();
69 return p1.x >= 0 && p1.x < IMGWIDTH && p1.y >= 0 && p1.y < IMGHEIGHT
70 && p2.x >= 0 && p2.x < IMGWIDTH && p2.y >= 0 && p2.y < IMGHEIGHT
71 && abs(p1.x - p2.x) >= 1 && abs(p1.y && p2.y) >= 1;
75 p1.x = p1.y = p2.x = p2.y = -1;
81 if (p1.y <= p2.y && p1.x <= p2.x)
85 rec.width = abs(p1.x - p2.x);
86 rec.height = abs(p1.y - p2.y);
88 else if (p1.y <= p2.y && p1.x > p2.x)
92 rec.width = abs(p1.x - p2.x);
93 rec.height = abs(p1.y - p2.y);
95 else if (p1.y > p2.y && p1.x <= p2.x)
99 rec.width = abs(p1.x - p2.x);
100 rec.height = abs(p1.y - p2.y);
102 else if (p1.y > p2.y && p1.x > p2.x)
106 rec.width = abs(p1.x - p2.x);
107 rec.height = abs(p1.y - p2.y);
121 Point mouseLastMovePos;
122 vector<Point> histogramContour;
124 ros::Publisher vision_msg_pub;
126 CascadeClassifier object_cascade;
128 ros::NodeHandle nodeHandle;
129 ros::Subscriber gui_events_sub;
130 ros::Subscriber rviz_click_sub;
133 mouseLastMovePos(0, 0), projection(projection)
135 vision_msg_pub = nodeHandle.advertise<rqt_vision_module::ConsoleMsg>(
136 "/rqt_vision_module/console", 10);
137 gui_events_sub = nodeHandle.subscribe<rqt_vision_module::GuiEvent>(
138 "/rqt_vision_module/gui_events", 30, &GuiManager::gui_events_callback,
140 rviz_click_sub = nodeHandle.subscribe<geometry_msgs::PointStamped>(
141 "/clicked_point", 1, &GuiManager::rviz_click_callback,
this);
144 void writeGuiConsole(Scalar color,
const char * format, ...)
148 va_start(args, format);
149 vsnprintf(buffer, 255, format, args);
150 ROS_INFO(
" %s", buffer);
151 rqt_vision_module::ConsoleMsg msg;
152 msg.message = buffer;
153 msg.b = color.val[0];
154 msg.g = color.val[1];
155 msg.r = color.val[2];
157 vision_msg_pub.publish(msg);
161 void writeGuiConsoleFormat(Scalar color,
const char * format, ...)
166 strftime(bufferTime, 12,
"%H:%M:%S | ", localtime(&t));
170 va_start(args, format);
171 vsnprintf(buffer, 255, format, args);
173 string txt=bufferTime;
175 if (color == redColor())
177 ROS_ERROR(
" %s", txt.c_str());
179 if (color == yellowColor())
181 ROS_WARN(
" %s", txt.c_str());
185 ROS_INFO(
" %s", txt.c_str());
187 rqt_vision_module::ConsoleMsg msg;
189 msg.message +=
"\r\n";
190 msg.b = color.val[0];
191 msg.g = color.val[1];
192 msg.r = color.val[2];
194 vision_msg_pub.publish(msg);
200 return LoadCascade();
202 inline bool LoadCascade()
204 return object_cascade.load(params.configPath +
"cascadeBall.xml");
206 void Publish(
const Mat &gray, Mat &guiRawImg,
bool shouldPublish);
207 void Update(
const Mat &rawHSV,
const Mat & img);
208 void rviz_click_callback(
const geometry_msgs::PointStampedConstPtr& msg);
209 void gui_events_callback(
const rqt_vision_module::GuiEvent::ConstPtr & msg);
A container class for gui rectangles.
Definition: GuiManager.hpp:53
For pixel projections.
Definition: CameraProjections.hpp:50
A container class for distance-size calibration.
Definition: GuiManager.hpp:23
A container class for managing gui events.
Definition: GuiManager.hpp:117