How to use multiband blender in opencv c++

asked 2020-04-27 04:59:15 -0600

Abdelrahman gravatar image

updated 2020-04-27 08:58:17 -0600

I am working in a stitching task from 2 input cameras My pipeline is the following : 1. synchronize the cameras 2. find keyPoints and descriptors from each image using sift 3. match the keyPoints using BFMathcer and KNN 4. warp the right image 5. stack the left image to it

My issue is that the colors from each camera has a large different from the other one I tried to use cv::detail::MultiBandBlender but there is no explained document of how to use it even the very limited examples online didn't help at all

what I tried until now

    cv::Mat final_res;
    cv::detail::MultiBandBlender blender;
    cv::Rect bounding_box(0,0, left_frame.cols+right_frame.cols,
                                                  left_frame.rows);
    blender.prepare(bounding_box);

    cv::warpPerspective(right_frame, result_stitching,  homography_right,
                                                       cv::Size( bounding_box.size()));
    cv::Mat mask = cv::Mat::ones( bounding_box.size(), CV_8U);

    cv::Mat insetImage( result_stitching, cv::Rect(0, 0, 
                                                             left_frame.cols,    
                                                             left_frame.rows));
    left_frame.copyTo(insetImage);

    blender.feed(result_stitching.clone(),mask , cv::Point(0, 0));
    blender.blend(final_res, mask);
    final_res.convertTo(final_res, (final_res.type() / 8) * 8);

with this I have 2 images:

  • result_stitching( stitching results without blending) https://drive.google.com/open?id=11QQ...

  • final_res( stitching results with blending) https://drive.google.com/open?id=1Qy8...

    the blending results is turned to black image I need to know how to use MultiBandBlender in a correct way even if anyone knows how to blend the results using any way in c++ I am open to any solution, the target is to make the total image colors balanced

edit retag flag offensive close merge delete