1

我正在尝试使用该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);
4

1 回答 1

0

如果您在代码中创建矢量对象:

vector<Point> corners(num_images);
vector<Mat> images_warped(num_images);
vector<Mat> masks_warped(num_images);

对象的大小将为 2。在 push_back() 方法之后,大小将为 4。

尝试将上面的代码替换为:

vector<Point> corners(0);
vector<Mat> images_warped(0);
vector<Mat> masks_warped(0);
于 2016-08-17T02:46:29.527 回答