当前位置:网站首页>Opencv face recognition of ros2 foxy~galactic~humble

Opencv face recognition of ros2 foxy~galactic~humble

2022-06-13 09:20:00 zhangrelay

OpenCV Tools are widely used . About the ROS2 How to use the blog has not been updated :

Earliest ,2019 year :ROS2 Use OpenCV Basics

Recently updated some :


The exercises used in the simulation are as follows :


So how to achieve the following face recognition effects ?

Mona Lisa's smile , Always so mysterious …… 


Problems encountered, such as :

[INFO] [1655036597.738995500] [face_detection]: Receiving image
Traceback (most recent call last):
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/cv_bridge/core.py", line 194, in imgmsg_to_cv2
    res = cvtColor2(im, img_msg.encoding, desired_encoding)
RuntimeError: [8UC3] is not a color format. but [bgr8] is. The conversion does not make sense

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zhangrelay/ros_ws/opencv_ros2-main/opencv_ros2/face_detection.py", line 95, in <module>
    main()
  File "/home/zhangrelay/ros_ws/opencv_ros2-main/opencv_ros2/face_detection.py", line 84, in main
    rclpy.spin(face_detection)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 222, in spin
    executor.spin_once()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 712, in spin_once
    raise handler.exception()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 239, in __call__
    self._handler.send(None)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 418, in handler
    await call_coroutine(entity, arg)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 343, in _execute_subscription
    await await_or_execute(sub.callback, msg)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 107, in await_or_execute
    return callback(*args)
  File "/home/zhangrelay/ros_ws/opencv_ros2-main/opencv_ros2/face_detection.py", line 53, in listener_callback
    current_frame = self.br.imgmsg_to_cv2(data, "bgr8")
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/cv_bridge/core.py", line 196, in imgmsg_to_cv2
    raise CvBridgeError(e)
cv_bridge.core.CvBridgeError: [8UC3] is not a color format. but [bgr8] is. The conversion does not make sense

How to solve it ? 

Tips :

current_frame = self.br.imgmsg_to_cv2(data, "rgb8")

answer :

[8UC3] is not a color format. but [rgb8] is.


[email protected]:~$ ros2 node list
/face_detection
/image_publisher
/rqt_gui_py_node_1492
[email protected]:~$ ros2 node info /face_detection
/face_detection
  Subscribers:
    /image_raw: sensor_msgs/msg/Image
  Publishers:
    /parameter_events: rcl_interfaces/msg/ParameterEvent
    /rosout: rcl_interfaces/msg/Log
  Service Servers:
    /face_detection/describe_parameters: rcl_interfaces/srv/DescribeParameters
    /face_detection/get_parameter_types: rcl_interfaces/srv/GetParameterTypes
    /face_detection/get_parameters: rcl_interfaces/srv/GetParameters
    /face_detection/list_parameters: rcl_interfaces/srv/ListParameters
    /face_detection/set_parameters: rcl_interfaces/srv/SetParameters
    /face_detection/set_parameters_atomically: rcl_interfaces/srv/SetParametersAtomically
  Service Clients:

  Action Servers:

  Action Clients:

[email protected]:~$

Basic concepts

What is face detection ? In computer vision , One of the basic problems that we try to solve is to automatically detect objects in images without human intervention . Face detection can be considered as the problem of detecting faces in images . There may be subtle differences in human faces , But on the whole , To be sure , Certain features are related to all human faces . There are many face detection algorithms .

Face detection is usually the first step of many face related technologies , For example, face recognition or verification . However , Face detection can have very useful applications . The most successful application of face detection is probably photographing . When you take pictures of your friends , The built-in face detection algorithm of the digital camera will detect the position of the face and adjust the focus accordingly .

What is? OpenCV In the field of artificial intelligence , Computer vision is one of the most interesting and challenging tasks . Computer vision is like a bridge between computer software and the visualization around us . It allows computer software to understand and understand the visualization of the surrounding environment . for example : According to color 、 Shape and size determine the fruit . This task may be easy for the human brain , But in the computer vision pipeline , First we collect data , Then perform data processing activities , Then train and teach the model to know how to distinguish fruits according to their size , The shape and color of the fruit .

at present , There are various software packages to perform machine learning 、 Deep learning and computer vision tasks . up to now , Computer vision is the best module for such complex activities . OpenCV It's an open source library . It is supported by various programming languages , for example R、Python. It can run on most platforms , for example Windows、Linux and MacOS.


原网站

版权声明
本文为[zhangrelay]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130905213561.html