我有透明图像[如下所示],并且尝试使用aishack.in cvOverlayImage()函数将其覆盖在相机源上
cvOverlayImage()
void cvOverlayImage(IplImage* src, IplImage* overlay, CvPoint location, CvScalar S, CvScalar D)
{
int x,y,i;
for(x=0;x < overlay->width -10;x++)
{
if(x+location.x>=src->width) continue;
for(y=0;y < overlay->height -10;y++)
{
if(y+location.y>=src->height) continue;
CvScalar source = cvGet2D(src, y+location.y, x+location.x);
CvScalar over = cvGet2D(overlay, y, x);
CvScalar merged;
for(i=0;i<4;i++)
merged.val[i] = (S.val[i]*source.val[i]+D.val[i]*over.val[i]);
cvSet2D(src, y+location.y, x+location.x, merged);
}
}
}
调用cvOverlayImage()
cvOverlayImage(image_n, neg_img, cvPoint(0, 0), cvScalar(1.0,1.0,1.0,1.0), cvScalar(0.1,0.1,0.1,0.1));
输入到cvOverlayImage()
cvOverlayImage()的输出
如您所见,我没有得到我所需要的。请帮助我。
最佳答案
这未经测试,但是S [i] + D [i] = 1是否不应该保留总强度?
关于opencv - 在opencv中的相机输出上覆盖透明图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8035476/