我正在尝试使用该ExposureCompensator
课程。我正在尝试将小图像粘贴到更大的图像上,但在粘贴之前我想平衡两个图像的亮度。但是,当我运行代码时,smallImage
将返回黑色图像。
PS:另外,如果我使用ExposureCompensator::GAIN_BLOCK
它会给出错误,整数除以零。
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, smallMask;
bigMask.create(bigImage.size(), CV_8U);
bigMask.setTo(Scalar::all(255));
smallMask.create(smallImage.size(), CV_8U);
smallMask.setTo(Scalar::all(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);