我使用此功能使用 OpenCV 放置叠加图像。
void OverlayImage(IplImage* src, IplImage* overlay, CvPoint location, CvScalar S, CvScalar D) {
for (int i = location.y; i < (location.y + overlay->height); i++) {
for (int j = location.x; j < (location.x + overlay->width); j++) {
CvScalar source = cvGet2D(src, i, j);
CvScalar over = cvGet2D(overlay, i-location.y, j-location.x);
CvScalar merged;
for(int i = 0; i < 4; i++)
merged.val[i] = (S.val[i] * source.val[i] + D.val[i] * over.val[i]);
cvSet2D(src, i + location.y, j + location.x, merged);
}
}
}
然后使用这样的功能-
OverlayImage(temp, tempad, cvPoint(10, 10), cvScalar(0,0,0,0), cvScalar(1,1,1,1));
用于隐藏叠加图像,例如
OverlayImage(temp, tempad, cvPoint(10, 10), cvScalar(1,1,1,1), cvScalar(0,0,0,0));
用于显示
我使用这些功能的方式是:
if (frame_number < 400)
OverlayImage(temp, tempad, cvPoint(10, 10), cvScalar(1,1,1,1), cvScalar(0,0,0,0));
else
OverlayImage(temp, tempad, cvPoint(10, 10), cvScalar(0,0,0,0), cvScalar(1,1,1,1));
但是第一张图像有一些失真区域,我希望在视频 400 帧后使该图像消失。我怎样才能使那个区域清晰?
请帮忙!