Is there an equivalent OpenCV function for `all()` function from MATLAB?

```
if all(bwImg(:)) || all(~bwImg(:))
....
end

```

This is the code I'm trying to implement. Of course I can iterate over all of the values and check if they are 1 or zero.