Skip to content

Commit 28f50e1

Browse files
authored
Merge pull request ros-perception#1 from wkentaro/add_image_beta
Fix AddingImages
2 parents 755bfae + 655f10b commit 28f50e1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

cfg/AddingImages.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ gen = ParameterGenerator()
99
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)
1010

1111
gen.add("alpha", double_t, 0, "weight of the first array elements.", 0.5, 0.0, 1.0)
12-
gen.add("use_beta", bool_t, 0, "True: Automatically set beta weight as 1 - alpha, False: Use user defined beta weight", False)
12+
gen.add("auto_beta", bool_t, 0, "True: Automatically set beta weight as 1 - alpha, False: Use user defined beta weight", True)
1313
gen.add("beta", double_t, 0, "weight of the second array elements.", 0.5, 0.0, 1.0)
1414
gen.add("gamma", double_t, 0, "scalar added to each sum.", 0, 0, 255)
1515

src/nodelet/adding_images_nodelet.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ namespace adding_images {
155155
boost::mutex::scoped_lock lock(mutex_);
156156
config_ = config;
157157
alpha_ = config.alpha;
158-
if ( config.use_beta ) {
159-
beta_ = config.beta;
160-
} else {
158+
if ( config.auto_beta ) {
161159
beta_ = 1.0 - alpha_;
162160
config.beta = beta_;
161+
} else {
162+
beta_ = config.beta;
163163
}
164164
gamma_ = config.gamma;
165165
}
@@ -174,6 +174,11 @@ namespace adding_images {
174174
cv_bridge::toCvShare(image_msg1, image_msg1->encoding)->image;
175175
cv::Mat image2 =
176176
cv_bridge::toCvShare(image_msg2, image_msg2->encoding)->image;
177+
if (image_msg1->encoding != image_msg2->encoding) {
178+
NODELET_ERROR("Encoding of input images must be same: %s, %s",
179+
image_msg1->encoding.c_str(), image_msg2->encoding.c_str());
180+
return;
181+
}
177182

178183
cv::Mat result_image;
179184
cv::addWeighted(image1, alpha_, image2, beta_, gamma_, result_image);

0 commit comments

Comments
 (0)