7.Face recognition

7.1 Overview

wiki:http://wiki.ros.org/opencv_apps

Source code:https://github.com/ros-perception/opencv_apps.git

Most of the code was originally taken from:https://github.com/Itseez/opencv/tree/master/samples/cpp

Functional package:~/software/library_ws/src/opencv_apps

The topic subscribed by this function package is [/image]. What we have to do is to open the camera node, write a topic that converts the camera topic into a [/image] node, and publish the [/image] topic.

Turn on the camera and publish the path of the node of the [/image] topic:

The opencv_apps program provides various nodes that internally run the functions of opencv and publish the results to a ROS topic. When using the opencv_apps program, you only need to run a launch file according to your own business needs, so that you no longer have to write program codes for these functions.

ROS Wiki has related node analysis, topic subscription and topic publishing of the corresponding node, introduction of related parameters, etc. See the ROS WiKi for details.

7.2 Use

Step 1: Start the camera

Almost every case of ros+opencv application will have a parameter [debug_view], Boolean type, whether to use Opencv to display pictures, which is displayed by default.

If no display is required, set it to [False], for example

However, after starting in this way, some cases cannot be displayed in other ways, because in the source code, some [debug_view] is set to [False], which will turn off image processing.

7.3 Display method

Enter the following command to select the corresponding topic

The system displays it by default, no need to do anything.

(Same as under LAN) Enter IP+port in the browser, for example:

For the specific ip, use your current virtual machine ip.

7.4 Face recognition display

This case is based on autonomous training and real-time recognition by collecting images of people in real time, and the steps are slightly complicated.

ParameterTypeDefaultAnalyze
~approximate_syncboolfalseSubscribe to the topic [camera_info] to get the default coordinate system ID, otherwise use the image information directly.
~queue_sizeint100Queue size for subscribing topics
~model_methodstring"eigen"Face recognition method: "eigen", "fisher" or "LBPH"
~use_saved_databooltrueLoad training data from ~data_dir path
~save_train_databooltrueSave training data to ~data_dir path for retraining
~data_dirstring"~/opencv_apps/face_data"Save training data path
~face_model_widthint190Width of training face images
~face_model_heightint90Training face image height
~face_paddingdouble0.1Filling ratio of each face
~model_num_componentsint0The number of components of the face recognizer model (0 is considered unlimited)
~model_thresholddouble8000.0Face recognition model threshold
~lbph_radiusint1Radius parameter (for LBPH method only)
~lbph_neighborsint8Neighborhood parameters (only for LBPH method)
~lbph_grid_xint8Grid x parameter (only for LBPH method)
~lbph_grid_yint8Grid y parameter (only for LBPH method)
~queue_sizeint100Image subscriber queue size

Operation steps:

  1. First, enter the character’s name after the colon in the picture below: Yahboom
  2. Confirm name: y
  3. Then place the face in the center of the image and click OK.
  4. Add a photo in a loop: y, click to confirm.
  5. To end image collection, enter: n and click Confirm.
  6. Close the launch file and restart.

If you need to enter the recognized identifications, cycle through steps 1 to 5 until all identified persons have been entered, and then proceed to step six.

image-20210903213928003

Step 3: Ensure that faces can be recognized

image-20210906103107655

Final recognition effect

image-20210906103143423