14 #include <opencv2/highgui/highgui.hpp>
35 cv::Vec3b fill_colour(0, 0, 255);
36 cv::Scalar outline_colour_1(255, 255, 255);
37 cv::Scalar outline_colour_2(0, 0, 0);
39 int depth_width = snapshot.
image->getDepthImage().cols;
40 double f = (double)canvas.cols / depth_width;
49 cv::Point bb_min(i_pxl % depth_width, i_pxl / depth_width);
50 cv::Point bb_max(i_pxl % depth_width, i_pxl / depth_width);
54 int x = *it % depth_width;
55 int y = *it / depth_width;
62 for(
double x2 = f * x; x2 < (f * (x + 1)); ++x2)
63 for(
double y2 = f * y; y2 < (f * (y + 1)); ++y2)
64 canvas.at<cv::Vec3b>(y2, x2) = fill_colour;
68 cv::rectangle(canvas, f * bb_min, f * bb_max, cv::Scalar(255, 255, 255), 2);
69 cv::rectangle(canvas, f * bb_min - d, f * bb_max + d, cv::Scalar(0, 0, 0), 2);
70 cv::rectangle(canvas, f * bb_min + d, f * bb_max - d, cv::Scalar(0, 0, 0), 2);
79 std::cout <<
"Usage: ed_segmenter IMAGE-FILE-OR-DIRECTORY [WORLDMODEL-NAME] [ENTITY-ID]" <<
std::endl;
83 int main(
int argc,
char **argv)
89 std::cout <<
"No worldmodel provided! Using empty worldmodel and no segmentation area" <<
std::endl;
113 model_name = argv[2];
127 area_description =
"on_top_of " + entity_id;
128 e = world_model->getEntity(entity_id);
131 std::cerr <<
"Entity '" << entity_id <<
"' could not be found in world model '" << model_name <<
"'." <<
std::endl;
155 cv::Mat canvas = snapshot.
image->getRGBImage().clone();
158 if (error_msg.
empty())
165 cv::putText(canvas,
"Segmentation failed", cv::Point(10, 20), cv::FONT_HERSHEY_COMPLEX_SMALL, 1, cv::Scalar(255, 255, 255), 1);
168 cv::imshow(
"RGB", canvas);
169 char key = cv::waitKey();