5、ROS+OpenCV application

5.1、Overview

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

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

Function package path:~/software/transbot_library/src/opencv_apps

Code reference: https://github.com/Itseez/opencv/tree/master/samples/cpp

opencv_apps provides various nodes that run internally OpenCV's functionalities and publish the result as ROS topics. With opencv_apps, you can skip writing OpenCV application codes for a lot of its functionalities by simply running a launch file that corresponds to OpenCV's functionality you want.

 

image-20210903181852659

5.2、Usage

5.2.1、Start up

Step 1: Start the camera

【camDevice】:ORBBEC camera is【Astra】,High frame rate camera【USBCam】;The default is【USBCam】

If the webpage cannot be viewed, check if there is no [web_video_server] node, if not, you need to run the following command.

Step 2: Start the function of Opencv_apps

Almost every function case will have a parameter [debug_view], boolean type, whether to use Opencv to display the picture, it is displayed by default.

If you don’t need to display it, set it to [False], for example

5.2.2、显示方法

Enter the following command to select the corresponding topic

The system displays it by default.

(At the same LAN) Enter IP+port in the browser, for example:

5.2.3、Effect show

Move the screen and observe the phenomenon.

image-20210903215736978

image-20210903215933659

image-20210903220054380

The lower the threshold, the more lines there are, and the more easily the picture gets stuck.

image-20210903220336691

The faster the camera moves, the larger the radius of the circle.

image-20210903220246064

Use the mouse to select different objects, the system automatically distinguishes them.

image-20210903220528108

5.3、Node

5.3.1、Edge detection algorithm

ParameterTypeDefaultAnalyze
~use_camera_infobooltrueSubscribe to the topic [camera_info] to get the default coordinate system ID, otherwise use the image information directly.
~debug_viewboolfalseWhether to create a window to display the node image
~edge_typeint0Specify the edge detection method: 0: Sobel operator, 1: Laplacian operator, 2: Canny edge detection
~canny_threshold1int100Specify the second canny threshold
~canny_threshold2int200Specify the first canny threshold
~apertureSizeint3The aperture size of the Sobel operator.
~apply_blur_preboolTrueWhether to apply blur() to the input image
~postBlurSizedouble3.2Input image aperture size
~apply_blur_postboolFalseWhether to apply GaussianBlur() to the input image
~L2gradientboolFalseParameters of canny
~queue_sizeint3Queue size

image-20210903212838217

image-20210903212947694

5.3.2、Contour moment

ParameterTypeDefaultAnalyze
~use_camera_infobooltrueSubscribe to the topic [camera_info] to get the default coordinate system ID, otherwise use the image information directly.
~debug_viewboolfalseWhether to create a window to display the node image
~canny_low_thresholdint0Canny edge detection low threshold
~queue_sizeint3Queue size

image-20210903212751344

5.3.3、Face recognition

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 subscribed topics
~model_methodstring"eigen"Face recognition method: "eigen", "fisher" or "LBPH"
~use_saved_databooltrueLoad training data from the ~data_dir path
~save_train_databooltrueSave the training data to the ~data_dir path for retraining
~data_dirstring"~/opencv_apps/face_data"保存训练数据路径
~face_model_widthint190Train the width of the face image
~face_model_heightint90Training the height of the face image
~face_paddingdouble0.1Fill 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 (only applicable to LBPH method)
~lbph_neighborsint8Neighborhood parameters (only applicable to LBPH method)
~lbph_grid_xint8Grid x parameters (only applicable to LBPH method)
~lbph_grid_yint8Grid y parameter (only applicable to LBPH method)
~queue_sizeint100Image subscriber queue size

Steps:

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

If you need to enter the recognition, cycle 1~5 in turn until all the recognition personnel are entered, and then perform step 6.

image-20210903213928003

Step 3: Ensure that the face can be recognized

image-20210906103107655

Recognition effect

image-20210906103143423