yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Raspberry Pi 4B📖
1.Preparation before use
  • 1.1 Download image
  • 1.2 Write image into SD card
  • 1.3 Start up Raspberry Pi
  • 1.4 Linux common commands
  • 1.5 Precautions
2.Basic course
  • 2.1 Log into Raspberry Pi system
  • 2.2 Change password and root account
  • 2.3 Remote transfer file
  • 2.4 Backup image file
  • 2.5 Fixing Raspberry Pi IP
  • 2.6 Set screen keep on
  • 2.7 Get Pi temperature
  • 2.8 Connect WIFI
  • 2.9 Modify Pi time
  • 2.10 Set the boot self-starting program
3.Expand course
  • 3.1 Serial port communicates with external devices
  • 3.2 2.Serial port login Pi
  • 3.3 Configured as a router
  • 3.4 Install Jupyter Lab
  • 3.5 Install Jupyter Widgets
  • 3.6 More Detail for Widgets
  • 3.7 Install OpenCV
  • 3.8 Install Tensorflow
4.Programming course
C language
  • 1.Development environment
  • 2.Print Hello World
  • 3.Pin output level
  • 4.Read pin level
  • 5.PWM output
Python language
  • 1.Development environment
  • 2.Print basic usage
  • 3.Pin output level
  • 4.Read pin level
  • 5.PWM output
5.AI vision course
A.Getting started with OpenCV
  • 6.Picture Rotation
  • 1.Introduction of OpenCV
  • 2.OpenCV image read and display
  • 3.OpenCV image write
  • 4.OpenCV image quality
  • 5.OpenCV pixel operation
B.OpenCV Geometric transformat
  • 1.Picture Zoom
  • 2.Picture Cut
  • 3.Picture Shift
  • 4.Picture Mirroring
  • 5.Affine Map
  • 7.Perspective Transformation
C.OpenCV picture processing
  • 1.Grayscale processing
  • 2.Image Binarization
  • 3.Edge detection
  • 4.Drawing line segment
  • 5.Drawing rectangle circle
  • 6.Drawing text picture
D.OpenCV image beautification
  • 1.Histogram of color pictures
  • 2.Histogram equalization
  • 3.Image restoration
  • 4.Brightness enhancement
  • 5.Skin whitening
  • 6.Gaussian mean filtering
  • 7.Median filtering
F.AI Advanced Course (Ubuntu system)
  • 1. QR code
  • 2. Human posture estimation
  • 3. Target detection
  • 4. Mediapipe development
  • 5. yolov4-tiny
E.Install TensorFlow
  • Install TensorFlow
6.ROS1 coursenew
Basic Course
  • 1.ROS introduction
  • 2.Project file structure
  • 3.Common commands and tools
  • 4.Publisher
  • 5.Subscribers
  • 6.Customize topic messages and use
  • 7.Client
  • 8.Server
  • 9.Custom service messages and usage
  • 10.TF release and monitoring
Visual Image Processing
  • 1. AR vision
  • 2. AR QR code
  • 3. ROS+Opencv foundation
  • 4. ROS+Opencv application
  • 5. MediaPipe development
7.ROS2 coursenew
Docker Course
  • 1.Overview and installation
  • 2.Common commands
  • 3.Understand and publish images
  • 4.Hardware interaction data processing
  • 5.Enter docker container
  • 6.Update docker images
Basic Course
  • 1.Introduction to ROS2
  • 2.Commands and tools
  • 3.ROS2 Topic communications
  • 4.ROS2 service communications
  • 5.ROS2launch file starts
OpenCV Course
  • 1.OpenCV Basic Course
  • 2.ROS+opencv application
  • 3.QR code recognition
  • 4.AR Vision
  • 5.Mediapipe
8.Accessories installation
  • 1. Installation of heat sink
  • 2. Wiring of cooling fan
  • 3. Double fan armor case Installation
  • 4. Argon NEO aluminum case installation
  • 5. Argon ONE aluminum alloy case installation
  • 6. Metal shell with built-in fan installation
  • 7. Acrylic case with cooling fan installation
  • 8. White-red ABS protective case installation
Download
  • Tools
  • C_code
  • Python code
  • ROS System
Download ZIP

Welcome to Raspberry Pi 4B repository

4. ROS+Opencv application

4. ROS+Opencv application

4. ROS+Opencv application 4.1. Overview 4.2. Use 4.2.1. Start 4.2.2. Display method 4.2.3. Effect display 4.3. Node 4.3.1. edge detection algorithm 4.3.2. Contour moment 4.3.3. Face Recognition

4.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

Feature pack: ~/software/library_ws/src/opencv_apps

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

The path to the node that enables the camera and publishes the [/image] topic:

~/yahboomcar_ws/src/yahboomcar_visual/scripts/pub_image.py 

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

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

image-20210903181852659

4.2. Use

4.2.1. Start

Step 1: Activate the camera

xxxxxxxxxx
roslaunch yahboomcar_visual opencv_apps.launch img_flip:=false 
  • img_flip parameter: Whether the image needs to be flipped horizontally, the default is false.

The [usb_cam-test.launch] file opens the [web_video_server] node by default, and you can directly use the [IP:8080] webpage to view the image in real time.

  • If use a monocular camera or Raspberry PI CSI camera, change 【pub_image_usb.py】 to 【pub_image.py】

    If use a Jetson camera, you'll need to change 【pub_image_csi.py】 to【 pub_image.py】

image-20210903215736978

Step 2: Start the function of Opencv_apps

xxxxxxxxxx
roslaunch  opencv_apps  face_recognition.launch              # face recognition 
roslaunch  opencv_apps  corner_harris.launch                 # harris corner detection 
roslaunch  opencv_apps  camshift.launch                      # target tracking algorithm 
roslaunch  opencv_apps  convex_hull.launch                   # polygon outline 
roslaunch  opencv_apps  discrete_fourier_transform.launch    # discrete Fourier transform algorithm 
roslaunch  opencv_apps  edge_detection.launch                # edge detection algorithm 
roslaunch  opencv_apps  face_detection.launch                # face detection algorithm 
roslaunch  opencv_apps  fback_flow.launch                    # Optical flow detection algorithm 
roslaunch  opencv_apps  find_contours.launch                 # contour detection 
roslaunch  opencv_apps  general_contours.launch              # general contour detection 
roslaunch  opencv_apps  goodfeature_track.launch             # feature point tracking 
roslaunch  opencv_apps  hls_color_filter.launch              # HLS color filter 
roslaunch opencv_apps  hough_circles .launch #                 Hough circle detection 
roslaunch  opencv_apps  hough_lines.launch                   # Hough line detection 
roslaunch  opencv_apps  hsv_color_filter.launch              # HSV color filter 
roslaunch  opencv_apps  lk_flow.launch                       # LK optical flow algorithm 
roslaunch  opencv_apps  people_detect.launch                 # human detection algorithm 
roslaunch  opencv_apps  phase_corr.launch                    # Phase correlation displacement detection 
roslaunch  opencv_apps  pyramids.launch                      # Image pyramid sampling algorithm 
roslaunch  opencv_apps  rgb_color_filter.launch              # RGB color filter 
roslaunch  opencv_apps  segment_objects.launch               # clear background detection algorithm 
roslaunch  opencv_apps  smoothing.launch                     # simple filter 
roslaunch  opencv_apps  threshold.launch                     # threshold image processing 
roslaunch  opencv_apps  watershed_segmentation.launch        # watershed segmentation algorithm 

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

Set to [False] if no display is required, for example

xxxxxxxxxx
roslaunch opencv_apps contour_moments.launch  debug_view:=False 

However, after this is started, 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.

4.2.2. Display method

  • rqt_image_view

Enter the following command to select the corresponding topic

xxxxxxxxxx
rqt_image_view 
  • opencv

The system defaults to display, no need to do anything.

  • web viewing

(same as the local area network) Enter IP+port in the browser, for example:

xxxxxxxxxx
192.168.2.79:8080 

4.2.3. Effect display

  • Optical flow detection algorithm

Move the screen and observe the phenomenon.

image-20210903215736978

  • Feature point tracking

image-20210903215933659

  • Hough circle detection

image-20210903220054380

  • Hough Line Detection

The lower the threshold, the more lines, and the easier the picture gets stuck.

image-20210903220336691

  • Phase-dependent displacement detection

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

image-20210903220246064

  • watershed segmentation algorithm

Use the mouse to select different objects, and the system will automatically distinguish them.

image-20210903220528108

4.3. Node

Each case in this section will have a topic of subscribing to images and publishing images.

4.3.1. edge detection algorithm

parametertypedefaultParse
~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.2Enter the image aperture size
~apply_blur_postboolFalsewhether to apply GaussianBlur() to the input image
~L2gradientboolFalseParameters of canny
~queue_sizeint3queue size

image-20220219122359784

image-20210903212947694

4.3.2. Contour moment

parametertypedefaultParse
~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-20220219122556604

4.3.3. Face Recognition

This case is self-training and real-time recognition through real-time collection of human images, and the steps are slightly complicated.

parametertypedefaultParse
~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 to topics
~model_methodstring"eigen"Methods of face recognition: "eigen", "fisher" or "LBPH"
~use_saved_databooltrueLoad training data from ~data_dir path
~save_train_databooltrueSave the training data to the ~data_dir path for retraining
~data_dirstring"~/opencv_apps/face_data"Save training data path
~face_model_widthint190width of training face images
~face_model_heightint90height of training face images
~face_paddingdouble0.1Fill ratio for 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 for LBPH method)
~lbph_neighborsint8Neighborhood parameter (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

Steps:

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

If you need to enter the recognized recognition, cycle 1 to 5 in turn, until all recognition personnel are completed, and then perform the sixth step.

image-20210903213928003

Step 3: To ensure that the face can be recognized

image-20210906103107655

The final recognition effect

image-20210906103143423

ROS+Opencv foundation
MediaPipe development

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文