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 309d37b1..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; } @@ -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);