What does type cv :: Scalar mean?

I need to find the sum of the elements in Mat, the OpenCV sum function returns cv :: Scalar, but how to interpret it?

+5
source share
1 answer

cv::Scalar used because the image can be multi-channel. For this reason, white is represented as:

 cv::Scalar(255,255,255); 

To access a specific item, you can simply use the [] operator :

 cv::Scalar myWhite(255,255,255); cout << myWhite[0] << endl; 

For the sum, each channel will represent the sum of that particular channel.

+10
source

Source: https://habr.com/ru/post/1206481/


All Articles