5. Voice control color recognition

5.1. Description

Start or stop the color recognition function of ROSMASTER by voice module.

5.2. Steps

5.2.1. Function package path

5.2.2. Start

  1. After the program is run, we put the object to be identified in front of the camera, select the color area of the object with the mouse, keep the mouse and do not release it.

  2. Then, say "Hi Yahboom" to the voice module, wait until the voice module replies saying "Hi, i‘m here".

  3. We can say "What color is this?" and the voice module will announce the color of the area selected by the mouse.

Note: Since the camera is more sensitive to light, the recognition results of the same color will be different in environments with different intensities of light.

5.3. Code analysis

5.3.1. Import the speech recognition library and create speech recognition objects

5.3.2. Get mouse events and specify the area selected by the mouse

This step is mainly to get the value of self.Roi_init, which is used to obtain the HSV value of the area

5.3.3. Get the HSV value of the selected area

5.3.4. Determine the area where the HSV value is located, and broadcast the identification result according to the interval

5.3.5. Program flow chart

image-20220406152934237

Code path:

5.3.6. Voice module communication protocol

function wordSpeech Recognition Module ResultsVoice broadcast content
What color is this?60Reply according to the color identified, as following table
colorThe host sends the result of the recognitionVoice broadcast content
red61This is red
blue62This is blue
green63This is green
yellow64This is yellow