【问题标题】:Check if Mat is a black image检查 Mat 是否为黑色图像
【发布时间】:2016-12-31 22:45:44
【问题描述】:

也许是一个简单的问题,但由于我是菜鸟,所以我不知道如何以优雅的方式做到这一点。 我正在分析视频。为此,我正在考虑框架之间的差异。如果没有任何改变,如果我用 imshow(...) 显示结果帧将是空的或黑色的。 如何确定我是否正在寻找这些黑色(空)框架之一?

我试过了:

Mat threshold_output;
...
threshold_output.empty() --> does not work
or
threshold_output == 0 --> compiler error

也许有人可以告诉我:)。

谢谢

【问题讨论】:

标签: image opencv mat


【解决方案1】:

您可以使用 minMaxLoc 并检查 maxVal == 0 :

// Localizing the best match with minMaxLoc
double minVal; double maxVal; 

minMaxLoc( threshold_output, &minVal, &maxVal);

【讨论】:

    【解决方案2】:

    我解决了这个问题:

    if (countNonZero(NewData) < 1) 
    {
        cout << "Eye contact occurs in this frame" << endl;
    }
    

    谢谢!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-09
      • 2021-05-05
      • 1970-01-01
      相关资源
      最近更新 更多