Skip to content

Commit

Permalink
Merge pull request ros-perception#1 from wkentaro/add_image_beta
Browse files Browse the repository at this point in the history
Fix AddingImages
  • Loading branch information
k-okada authored Mar 21, 2017
2 parents 755bfae + 655f10b commit 28f50e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cfg/AddingImages.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 8 additions & 3 deletions src/nodelet/adding_images_nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down

0 comments on commit 28f50e1

Please sign in to comment.