解释在opencv中实现的阴影检测代码的工作原理
Explain the working of shadow detection code implemented in opencv?
我正在尝试理解opencv中实现的用于阴影检测的代码,其链接在这里
代码是
detectShadowGMM(const float* data, int nchannels, int nmodes,
const GMM* gmm, const float* mean,
float Tb, float TB, float tau)
{
float tWeight = 0;
// check all the components marked as background:
for( int mode = 0; mode < nmodes; mode++, mean += nchannels )
{
GMM g = gmm[mode];
float numerator = 0.0f;
float denominator = 0.0f;
for( int c = 0; c < nchannels; c++ )
{
numerator += data[c] * mean[c];
denominator += mean[c] * mean[c];
}
// no division by zero allowed
if( denominator == 0 )
return false;
// if tau < a < 1 then also check the color distortion
if( numerator <= denominator && numerator >= tau*denominator )
{
float a = numerator / denominator;
float dist2a = 0.0f;
for( int c = 0; c < nchannels; c++ )
{
float dD= a*mean[c] - data[c];
dist2a += dD*dD;
}
if (dist2a < Tb*g.variance*a*a)
return true;
};
tWeight += g.weight;
if( tWeight > TB )
return false;
};
return false;
}
我假设的n通道是每个像素的rgb通道。我不确定dist2a,分子和分母是什么。前景和背景可能是,但为什么我们要乘以"数据和平均值"和"平均值和平均值"。这里实现的论文是日夫科维奇。"用于背景减法的改进自适应高斯混合模型",国际会议模式识别,英国,2004 年 8 月,
逻辑是:在RGB色彩空间中,E代表背景,I表示每个像素i的前景。E 和 I 之间的强度差是通过最小化 (a) = (Ii-aEi)^2 给出的"a"来计算的色差由 CDi = |高爱|如果值在阈值范围内,则像素被分类为阴影。这张图片会更好地解释它
请帮我用代码映射逻辑。
本文中解释了实现一种实时鲁棒背景减法和阴影检测的统计方法由塔纳拉特·霍普拉塞特 大卫·哈伍德 拉里·戴维斯这在上述论文的参考文献中存在。
下面的链接显示了用于实现的公式。 点击这里查看图片
相关文章:
- 注释一行使代码工作,而没有它,代码不起作用
- 当我的代码工作正常时,为什么在SPOJ中遇到运行时(Sigabrt)错误
- 回文字符串问题:为什么我必须放+1而不是-1才能让这个代码工作
- 如何使用模板或继承使以下代码工作
- 为什么这个循环运行不可见的代码?工作不正常
- 堆叠C++代码工作正常,但在运行代码结束时"glibc detected"
- 返回引用 - 为什么我的代码工作正常?不应该
- 如何使此代码工作
- 为什么这个单例类代码工作正常
- 对于下面的代码,我将 decltype(s1.size()) 更改为 int,代码工作正常.在这种情况下,decltyp
- 代码工作到一定程度,然后崩溃
- 为什么此代码工作/失败取决于在中创建的范围闭包
- OpenGL代码工作,不管我使用什么输入/窗口处理程序
- c++代码工作正常,但进程以termination结束,而不是返回0
- 为什么代码工作良好,当我编译和运行它,即使我没有提到数组的大小
- 如果元素不能为代码工作
- 为什么这段代码工作正常?(vector.clear(), vector<vector<int> >)
- C++ 昨天分段错误测试的代码工作完美,现在它出错了
- 由于在返回语句中使用了布尔或操作,因此递归如何对以下代码工作
- C /c++ hackerrank,我的代码是工作的,但我得到0.38 /10分(不知道为什么)代码工作