I am trying to use ExposureCompensator class. I am trying to paste a small image to a bigger image but before pasting it i want to balance brightness of two images. When i run the code smallImage will return as a black image.
int num_images = 2;
int img_idx = 1;
//left and top corner position of small image
int left = 300;
int top = 400;
vector<Point> corners(num_images);
vector<Mat> images_warped(num_images);
vector<Mat> masks_warped(num_images);
images_warped.push_back(bigImage);
images_warped.push_back(smallImage);
corners.push_back(Point(0, 0));
corners.push_back(Point(left, top));
//created two white Mats as masks
Mat bigMask(bigImage.rows, bigImage.cols, 0);
bigMask(Range::all(),Range(0,bigMask.cols)) = 255;
Mat smallMask(smallImage.rows, smallImage.cols, 0);
smallMask(Range::all(),Range(0,smallMask.cols)) = 255;
masks_warped.push_back(bigMask);
masks_warped.push_back(smallMask);
int expos_comp_type = detail::ExposureCompensator::GAIN;
Ptr<detail::ExposureCompensator> compensator = detail::ExposureCompensator::createDefault(expos_comp_type);
compensator->feed(corners, images_warped, masks_warped);
compensator->apply(img_idx, corners[img_idx], smallImage, smallMask);