Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic data types in OpenCV

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What is the basic data type in OpenCV, many novices are not very clear about it. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

Let's focus on the eight basic data types commonly seen in OpenCV and the operations they support.

1. Point class

As the basic type of OpenCV, the Point class is probably the simplest, although relatively simple, but you who are familiar with opencv do not necessarily know much about it, especially some of its operations.

This class is created based on a base template structure, so it can be any type of point, such as integer, floating point, etc. The operations directly supported by the Point class are as follows:

2. Scalar class

Scalar is a four-dimensional dot class, and like other types, it is actually related to a template class, but the alias that accesses it returns an instance of the template. In the template, all members are double-precision floating-point data. In computer vision algorithms, the Scalar class has some special member functions related to quaternion vectors. The following table lists some operations supported by Scalar:

3. Size class

The size class is similar to the Point class in practice and can be converted to the Point class. The main difference between the two is that the data members of the Point class are x and y, while the data members of the size class are width and height. The size class has three aliases, Size,Size2i,Size2f, the first two are equivalent to the integer size, and the last one represents the 32-bit floating point size. The following table lists the operations supported by the size class:

4. Rect class

The Rect class contains members x and y of the Point class (representing the vertices in the upper-left corner of the rectangle) and members of the size class width and heigth (representing the width and length of the rectangle). The following table lists the operations supported by the Rect class: in addition, the Rect class also supports a series of overloaded operators that can be used to calculate various geometric properties such as two rectangles or one rectangle, as follows:

5. RotatedRect class

The RotatedRect class is a container that contains a central point Point2f, a size Size2f, and an extra float angle. Where the angle of float represents the angle at which the drawing rotates around the center point. A very important difference between RotatedRect and Rect is that RotatedRect takes the center as the origin, while Rect takes the upper-left corner as the origin. The following table lists the operations supported by the RotatedRect class:

6. Fixed matrix class

Fixed matrix classes are built for matrices with known dimensions at compile time, which is why they are called "fixed". Because all the data inside it is allocated on the stack, they are allocated and cleared quickly. Operations on fixed classes run quickly, and special optimizations have been made on small matrices. Usually, a fixed matrix class is actually a template called Matx, but independent matrices are usually assigned by aliases, and the basic format of these aliases is Matx {1 ~ 2.} {1 ~ 2.} {f ~ (d)}, where the number can be any number between 1 and 6. The operations supported are:

7. Fixed vector class

The fixed vector class is actually derived from the fixed matrix class. The fixed vector class Vec is actually a fixed matrix class listed as 1. The aliases prepared for a specific instance are in the following format:

Vec {2,3,4,5,6} {b,s,w,I,f,d}

The meaning of the last character is the same as before, where w stands for unsigned short, and the following table represents the operations supported by Vec:

8. Plural class

The plural class in OpenCV is different from the plural class template complex in STL, but can be converted to each other. The biggest difference lies in the way to get the members. The real and imaginary parts in the STL class are obtained through the member functions real () and imag (), and directly through the member variables re and im in OpenCV. The supported operations are as follows:

Like many basic types, complex classes give aliases to important templates, such as Complexf and Complexd for single-precision and double-precision complex numbers, respectively.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report