7 #include <rgbd/Image.h>
10 #include <ros/node_handle.h>
11 #include <ros/advertise_service_options.h>
15 #include <opencv2/highgui/highgui.hpp>
35 float old_depth =
z_buffer_.at<
float>(y, x);
36 if (old_depth == 0 || depth < old_depth)
61 int nvert = points_list.
size();
64 float testx = point.x;
65 float testy = point.y;
68 for(; ii < points_list.
size(); ++ii){
69 vertx[ii] = points_list[ii].x;
70 verty[ii] = points_list[ii].y;
74 for (i = 0, j = nvert-1; i < nvert; j = i++) {
75 if ( ((verty[i]>testy) != (verty[j]>testy)) &&
76 (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
84 int REDS[] = { 255, 0 , 255, 0, 255, 0 , 255};
85 int GREENS[] = { 255, 255, 0 , 0, 255, 255, 0 };
86 int BLUES[] = { 255, 255, 255, 255, 0, 0, 0 };
90 int hash(
const char *str,
int max_val)
92 unsigned long hash = 5381;
98 return hash % max_val;
105 int i =
hash(
id.c_str(), 7);
125 rgb_params[0] = CV_IMWRITE_JPEG_QUALITY;
129 if (!cv::imencode(
".jpg",
image, data, rgb_params)) {
139 params[0] = CV_IMWRITE_PNG_COMPRESSION;
142 if (!cv::imencode(
".png",
image, data, params)) {
170 std::string srv_get_measurements, srv_set_label, srv_raise_event, srv_get_command, map_image_topic;
172 config.
value(
"srv_get_measurements", srv_get_measurements);
181 int image_width, image_height;
185 double world_width, world_height;
189 double cam_x, cam_y, cam_z;
201 ros::AdvertiseServiceOptions opt_get_measurements =
202 ros::AdvertiseServiceOptions::create<ed_msgs::GetMeasurements>(
209 ros::AdvertiseServiceOptions opt_set_label =
210 ros::AdvertiseServiceOptions::create<ed_msgs::SetLabel>(
217 ros::AdvertiseServiceOptions opt_raise_event =
218 ros::AdvertiseServiceOptions::create<ed_msgs::RaiseEvent>(
225 ros::AdvertiseServiceOptions opt_get_command =
226 ros::AdvertiseServiceOptions::create<ed_msgs::GetGUICommand>(
232 pub_image_map_ = nh.advertise<tue_serialization::Binary>(
"/ed/gui/map_image", 1);
234 map_image_ = cv::Mat(image_width, image_height, CV_8UC3, cv::Scalar(50, 50, 50));
240 image_width / (world_width / cam_z), image_height / (world_height / cam_z),
241 image_width / 2, image_height / 2,
278 const pcl::PointCloud<pcl::PointXYZ>& chull_points = e->convexHull().chull;
280 if (!chull_points.empty())
283 for(
unsigned int i = 0; i < chull_points.size(); ++i)
310 if (e->visual() && e->id() !=
"floor")
313 cv::Vec3b color_vec(0.5 * color[0], 0.5 * color[1], 0.5 * color[2]);
317 opt.
setMesh(e->visual()->getMesh(), pose);
330 const pcl::PointCloud<pcl::PointXYZ>& chull_points = e->convexHull().chull;
338 if (!chull_points.empty())
341 for(
unsigned int i = 0; i < chull_points.size(); ++i)
343 int j = (i + 1) % chull_points.size();
345 const pcl::PointXYZ& p1 = chull_points[i];
346 const pcl::PointXYZ& p2 = chull_points[j];
351 0.3 * color, thickness);
355 for(
unsigned int i = 0; i < chull_points.size(); ++i)
357 const pcl::PointXYZ p = chull_points[i];
361 0.5 * color, thickness);
366 for(
unsigned int i = 0; i < chull_points.size(); ++i)
368 int j = (i + 1) % chull_points.size();
370 const pcl::PointXYZ& p1 = chull_points[i];
371 const pcl::PointXYZ& p2 = chull_points[j];
379 if (e->type() ==
"person")
392 if (e->lastMeasurement() && (!last_measurement || e->lastMeasurement()->timestamp() > e->lastMeasurement()->timestamp()))
393 last_measurement = e->lastMeasurement();
396 if (last_measurement)
398 const geo::Pose3D& sensor_pose = last_measurement->sensorPose();
404 cv::circle(
map_image_, p_2d, 10, cv::Scalar(255, 255, 255));
406 rgbd::View view(*last_measurement->image(), 100);
417 cv::Scalar fustrum_color(100, 100, 100);
419 cv::line(
map_image_, p_2d, p1_2d, fustrum_color);
420 cv::line(
map_image_, p_2d, p2_2d, fustrum_color);
421 cv::line(
map_image_, p_2d, p3_2d, fustrum_color);
422 cv::line(
map_image_, p_2d, p4_2d, fustrum_color);
424 cv::line(
map_image_, p1_2d, p2_2d, fustrum_color);
425 cv::line(
map_image_, p1_2d, p3_2d, fustrum_color);
426 cv::line(
map_image_, p2_2d, p4_2d, fustrum_color);
427 cv::line(
map_image_, p3_2d, p4_2d, fustrum_color);
436 tue_serialization::Binary msg;
468 const cv::Mat&
rgb_image = m->image()->getRGBImage();
471 cv::Mat rgb_image_masked(
rgb_image.rows,
rgb_image.cols, CV_8UC3, cv::Scalar(0, 0, 0));
475 cv::Point2i pt = it();
476 rgb_image_masked.at<cv::Vec3b>(pt) =
rgb_image.at<cv::Vec3b>(pt);
479 res.images.push_back(tue_serialization::Binary());
482 res.ids.push_back(e->id());
483 res.images.back().info = e->type();
486 res.images.pop_back();
509 res.msg =
"GUIServer: srvSetLabel: Id does not exist: " + id;
518 e_updated->setType(req.label);
523 res.msg =
"[ED] GUI Plugin: srv SetLabel not yet implemented.";
538 if (it == params.
end())
540 value = atof(it->second.c_str());
549 if (it == params.
end())
551 value = it->second.c_str();
560 for(
unsigned int i = 0; i < req.param_names.size(); ++i)
561 params[req.param_names[i]] = req.param_values[i];
563 if (req.name ==
"click")
576 if (type ==
"delete")
581 res.msg =
"Deletion not yet implemented";
589 else if (type ==
"navigate")
595 else if (type ==
"select")
601 res.msg =
"Unknown click type: " + type;
612 res.msg =
"Could not parse click event";
615 else if (req.name ==
"zoom")
624 else if (req.name ==
"pan")
633 else if (req.name ==
"explore")
639 else if (req.name ==
"wait")
647 res.msg =
"Unknown event received: " + req.name;
668 res.param_values.push_back(it->second);