From a0d7e841422938aefc673148bd387ff677164e2d Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 19 Mar 2017 18:24:58 +0900 Subject: [PATCH 1/2] Check input encoding consistency --- src/nodelet/adding_images_nodelet.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/nodelet/adding_images_nodelet.cpp b/src/nodelet/adding_images_nodelet.cpp index 309d37b1..d59d70d8 100644 --- a/src/nodelet/adding_images_nodelet.cpp +++ b/src/nodelet/adding_images_nodelet.cpp @@ -174,6 +174,11 @@ namespace adding_images { cv_bridge::toCvShare(image_msg1, image_msg1->encoding)->image; cv::Mat image2 = cv_bridge::toCvShare(image_msg2, image_msg2->encoding)->image; + if (image_msg1->encoding != image_msg2->encoding) { + NODELET_ERROR("Encoding of input images must be same: %s, %s", + image_msg1->encoding.c_str(), image_msg2->encoding.c_str()); + return; + } cv::Mat result_image; cv::addWeighted(image1, alpha_, image2, beta_, gamma_, result_image); From 655f10be66a875860e5ff0e5b970f6451f1deb85 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 19 Mar 2017 20:50:48 +0900 Subject: [PATCH 2/2] Clarify with auto_beta for auto beta settings --- cfg/AddingImages.cfg | 2 +- src/nodelet/adding_images_nodelet.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cfg/AddingImages.cfg b/cfg/AddingImages.cfg index 5b378e5a..27f58c01 100755 --- a/cfg/AddingImages.cfg +++ b/cfg/AddingImages.cfg @@ -9,7 +9,7 @@ gen = ParameterGenerator() gen.add("use_camera_info", bool_t, 0, "Indicates that the camera_info topic should be subscribed to to get the default input_frame_id. Otherwise the frame from the image message will be used.", True) gen.add("alpha", double_t, 0, "weight of the first array elements.", 0.5, 0.0, 1.0) -gen.add("use_beta", bool_t, 0, "True: Automatically set beta weight as 1 - alpha, False: Use user defined beta weight", False) +gen.add("auto_beta", bool_t, 0, "True: Automatically set beta weight as 1 - alpha, False: Use user defined beta weight", True) gen.add("beta", double_t, 0, "weight of the second array elements.", 0.5, 0.0, 1.0) gen.add("gamma", double_t, 0, "scalar added to each sum.", 0, 0, 255) diff --git a/src/nodelet/adding_images_nodelet.cpp b/src/nodelet/adding_images_nodelet.cpp index d59d70d8..7dae86f2 100644 --- a/src/nodelet/adding_images_nodelet.cpp +++ b/src/nodelet/adding_images_nodelet.cpp @@ -155,11 +155,11 @@ namespace adding_images { boost::mutex::scoped_lock lock(mutex_); config_ = config; alpha_ = config.alpha; - if ( config.use_beta ) { - beta_ = config.beta; - } else { + if ( config.auto_beta ) { beta_ = 1.0 - alpha_; config.beta = beta_; + } else { + beta_ = config.beta; } gamma_ = config.gamma; }