Other basic object types

We have learned about the Mat and Vec3b classes, but we need to learn about other classes as well.

In this section, we will learn about the most basic object types required in most of the projects:

  • Vec
  • Scalar
  • Point
  • Size
  • Rect
  • RotatedRect

The vec object type

vec is a template class that is used mainly for numerical vectors. We can define any type of vectors and a number of components:

Vec<double,19> myVector;

Or we can use any of the predefined types:

typedef Vec<uchar, 2> Vec2b; typedef Vec<uchar, 3> Vec3b; typedef Vec<uchar, 4> Vec4b; typedef Vec<short, 2> Vec2s; typedef Vec<short, 3> Vec3s; typedef Vec<short, 4> Vec4s; typedef Vec<int, 2> Vec2i; typedef Vec<int, 3> Vec3i; typedef Vec<int, 4> Vec4i; typedef Vec<float, 2> Vec2f; typedef ...

Get OpenCV By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.