也许一个简单的问题,但因为我是一个菜鸟我不知道如何以优雅的方式做到这一点.我正在分析视频.为此,我在帧之间采取差异.如果没有任何改变,如果我用imshow(...)显示它,结果帧将为空或黑色.我怎么知道我是否正在寻找其中一个黑色(空)帧?
我试过了:
Mat threshold_output;
...
threshold_output.empty() --> does not work
or
threshold_output == 0 --> compiler error
Run Code Online (Sandbox Code Playgroud)
也许有人可以告诉我:).
谢谢
我用这个解决了这个问题:
if (countNonZero(NewData) < 1)
{
cout << "Eye contact occurs in this frame" << endl;
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
你可以使用minMaxLoc并检查maxVal == 0:
// Localizing the best match with minMaxLoc
double minVal; double maxVal;
minMaxLoc( threshold_output, &minVal, &maxVal);
Run Code Online (Sandbox Code Playgroud)