Using Opencv To Realize Color Recognition And Tracking; Color Recognition And Color Space; Process Of Color Identifying And Tracking - ADEEPT AWR Wheeled Robot Manual

4wd smart robot kit compatible with raspberry pi 4 3 model b+ b, opencv target tracking
Table of Contents

Advertisement

97
19 Using OpenCV to Realize Color Recognition
and Tracking

19.1 Color Recognition and Color Space

●For the development preparation and operation of OpenCV function, please refer to 18.
●Create camera_opencv.py in the folder where app.py and base_camera.py in 18. The code related to
the OpenCV color tracking function to be introduced in this chapter is written in camera_opencv.py
●For safety reasons, this routine does not control the motor or servo motion, and only outputs OpenCV
calculation results.
●We use OpenCV for color recognition using the HSV color space. Before introducing the code, we first
need to understand the color space and why we use the HSV color space instead of the more common RGB
color space for color recognition.
●Color space:
· Color space is how colors are organized. With the help of color space and tests for physical devices, fixed
analog and digital representations of colors can be obtained. The color space can be defined by just picking
some colors at random, for example, the Pantone system just takes a specific set of colors as samples, and
then defines the name and code for each color; it can also be based on a strict mathematical definition, such as
Adobe RGB , SRGB.
●RGB color space:
·RGB uses an additive color mixing method because it describes the ratio of various "lights" to produce
colors. The light is continuously superimposed from dark to produce color. RGB describes the values of red,
green and blue light. RGBA is to add alpha channel to RGB to achieve transparency effect.
Common color spaces based on RGB mode are sRGB, Adobe RGB, and Adobe Wide Gamut RGB.
●HSV color space:
· HSV (Hue: Hue, Saturation: Saturation, Brightness; Value), also known as HSB (B refers to Brightness) is
commonly used by artists, because compared with the term of addition and subtraction, the use of hue,
saturation and other concepts to describe color is more natural and intuitive. HSV is a variant of the RGB color
space, its content and color scale are closely related to its source-RGB color space
·Using the HSV color space in OpenCV's color recognition function can make the recognition result more
accurate, less affected by ambient light, and it is very convenient to define the color range, because what you
are looking for during color recognition is not a certain color, but a certain one Range of colors, so use the HSV
color space that is more in line with human eye habits for color recognition.

19.2 Process of Color Identifying and Tracking

● We can use this function to control the servo to make the camera aim at a certain color object, the

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?

This manual is also suitable for:

Picar-b

Table of Contents

Save PDF