我一直在编写这个动作检测程序,并遇到了'如果句子'的问题,这里是代码:
for (int i = 0; i < frameSize; i++, backFrame++, currFrame++)
{
// difference
diff = ((int)*currFrame) - ((int)*backFrame);
// threshold
if ((diff >= differenceThreshold) || (diff <= differenceThresholdNeg))
{
*currFrame = (byte)255;
if (i < 640)
{
x[i] = i;
y[i] = 0;
}
else
{
x[i] = i % 640;
y[i] = i / 640;
}
if (xMax < x[i]) xMax = x[i];
if (xMin > x[i]) xMin = x[i];
if (yMax < y[i]) yMax = y[i];
if (yMin > y[i]) yMin = y[i];
xC = ((xMax - xMin) / 2) + xMin;
yC = ((yMax - yMin) / 2) + yMin;
}
else
{
*currFrame = (byte)0;
}
}
问题是它在'if'之后跳过代码并且即使在条件
时也执行'else'(((diff >= differenceThreshold) || (diff <= differenceThresholdNeg))) is true.
我是C#的新手,所以有人可以帮助我吗?