O'Reilly logo

Learn OpenCV 4 by Building Projects - Second Edition by Prateek Joshi, Vinicius G. Mendonca, David Millan Escriva

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scalar object type

The Scalar object type is a template class derived from Vec with four elements. The Scalar type is widely used in OpenCV to pass and read pixel values.

To access Vec and Scalar values, we use the [] operator, which can be initialized from another scalar, vector, or value by value, as in the following sample:

Scalar s0(0);Scalar s1(0.0, 1.0, 2.0, 3.0);Scalar s2(s1);

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required