5 #include <opencv2/highgui/highgui.hpp> 10 int main(
int argc,
char** argv)
13 init(argc, argv,
"opencv_demo");
15 Publisher publisher = nodeHandle.
advertise<grid_map_msgs::GridMap>(
"grid_map", 1,
true);
16 const bool useTransparency =
false;
19 GridMap map({
"original",
"elevation"});
21 map.setGeometry(
Length(1.2, 2.0), 0.01);
22 ROS_INFO(
"Created map with size %f x %f m (%i x %i cells).",
23 map.getLength().x(), map.getLength().y(),
24 map.getSize()(0), map.getSize()(1));
27 if (!useTransparency) map[
"original"].setZero();
43 map.at(
"original", *iterator) = 0.3;
47 cv::Mat originalImage;
48 if (useTransparency) {
51 GridMapCvConverter::toImage<unsigned short, 4>(map,
"original", CV_16UC4, 0.0, 0.3, originalImage);
53 GridMapCvConverter::toImage<unsigned short, 1>(map,
"original", CV_16UC1, 0.0, 0.3, originalImage);
57 cv::namedWindow(
"OpenCV Demo");
60 while (nodeHandle.
ok()) {
64 map.setTimestamp(time.
toNSec());
65 cv::Mat modifiedImage;
66 int blurRadius = 200 -
abs((
int)(200.0 *
sin(time.
toSec())));
67 blurRadius = blurRadius - (blurRadius % 2) + 1;
70 cv::GaussianBlur(originalImage, modifiedImage, cv::Size(blurRadius, blurRadius), 0.0, 0.0);
73 cv::imshow(
"OpenCV Demo", modifiedImage);
77 if (useTransparency) {
78 GridMapCvConverter::addLayerFromImage<unsigned short, 4>(modifiedImage,
"elevation", map, 0.0, 0.3, 0.3);
80 GridMapCvConverter::addLayerFromImage<unsigned short, 1>(modifiedImage,
"elevation", map, 0.0, 0.3);
84 grid_map_msgs::GridMap message;
87 ROS_INFO_STREAM(
"Published image and grid map with blur radius " << blurRadius <<
".");
int main(int argc, char **argv)
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
static void toMessage(const grid_map::GridMap &gridMap, grid_map_msgs::GridMap &message)
Node for comparing different normal filters performances.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void addVertex(const Position &vertex)
#define ROS_INFO_STREAM(args)
INLINE Rall1d< T, V, S > abs(const Rall1d< T, V, S > &x)
void setFrameId(const std::string &frameId)
void setFrameId(const std::string &frameId)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)