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

1. AR vision

1. AR vision

1. AR vision 1.1. Overview 1.2. How to use 1.3. Source code analysis 1.3.1. Algorithm principle 1.3.2. core code

Feature pack: ~/yahboomcar_ws/src/yahboomcar_visual

The effects of this section can be demonstrated on the main control board with our corresponding image system installed.

1.1. Overview

Augmented Reality, referred to as "AR", is a technology that ingeniously integrates virtual information with the real world. It widely uses multimedia, 3D modeling, real-time tracking and registration, intelligent interaction, sensing and other technologies. The method is to simulate and simulate virtual information such as text, images, three-dimensional models, music, and videos generated by the computer, and then apply it to the real world. The two kinds of information complement each other, thereby realizing the "enhancement" of the real world.

The AR system has three prominent features: (1) the information integration of the real world and the virtual world; (2) real-time interactivity; (3) the addition of positioning virtual objects in the three-dimensional scale space.

Augmented reality technology includes multimedia, three-dimensional modeling, real-time video display and control, multi-sensor fusion, real-time tracking and registration, scene fusion and other new technologies and new means.

1.2. How to use

When using the AR case, you must have the internal parameters of the camera, otherwise it will not work. The internal parameter file is in the same directory as the code (under the AR folder of the function package); different cameras correspond to different internal parameters.

The internal parameter calibration can be quickly calibrated with a checkerboard. (We have stored the calibrated camera internal reference files in the main control board image system, so there is no need for secondary calibration)

Start the monocular camera/ Raspberry CSI camera

xxxxxxxxxx
roslaunch usb_cam usb_cam-test.launch 

Start the calibration node

xxxxxxxxxx
rosrun camera_calibration cameracalibrator.py image:=/usb_cam/image_raw camera:=/usb_cam --size 9x6 --square 0.02 

Start the Jetson CSI camera

xxxxxxxxxx
roslaunch yahboomcar_visual yahboom_csi.launch

Start the calibration node

xxxxxxxxxx
rosrun camera_calibration cameracalibrator.py image:=/csi_cam_0/image_raw camera:=/usb_cam --size 9x6 --square 0.02 

After calibration, move the [calibrationdata.tar.gz] file to the [home] directory.

xxxxxxxxxx
sudo mv /tmp/calibrationdata.tar.gz ~ 

After decompression, open [ost.yaml] in the folder, find the camera internal parameter matrix and distortion coefficient and modify it to the corresponding location of the [USB_camera.yaml] file or [csi_camera.yaml], just modify the contents of two [data]. For example: the following.

xxxxxxxxxx
camera_matrix :  !! opencv - matrix 
  rows :  3 
  cols :  3 
  dt :  d 
  data : [ 615.50506 ,    0.      ,  365.84388 , 
           0. , 623.69024 , 238.778 , 
           0. , 0. , 1. ] 
distortion_model :  plumb_bob 
distortion_coefficients :  !! opencv - matrix 
  rows :  1 
  cols :  5 
  dt :  d 
  data : [ 0.166417 ,  - 0.160106 ,  - 0.008776 ,  0.025459 ,  0.000000 ] 

A total of 12 effects.

xxxxxxxxxx
[ "Triangle" ,  "Rectangle" ,  "Parallelogram" , "WindMill" , "TableTennisTable" ,  "Ball" ,  "Arrow" ,  "Knife" ,  "Desk" , 
"Bench" ,  "Stickman" ,  "ParallelBars" ] 

start command

xxxxxxxxxx
roslaunch yahboomcar_visual simple_AR.launch display:=true flip:=false
  • display parameter: True; the image window is displayed locally; Fasle, it is not displayed.

  • flip parameter: whether to switch the screen horizontally, the default is OK.

  • For a monocular camera, change simple_AR_usb.py to simple_AR.py. As for CSI camera, change simple_AR_csi.py to simple_AR.py

    image-20210902122726648

Set parameters according to your needs, you can also directly modify the launch file, and you don't need to attach parameters when starting. When the screen is not turned on, you can use the network monitoring method to view

xxxxxxxxxx
Open the IP of the device: 8080 
  1. When the screen is displayed (that is, display is true), press the [q] key to exit, and the [f] key to switch between different effects. You can also use the command line to switch.

image-20210902122726648

Use the [f] or [F] key to switch between different effects.

image-20210906141251637

  1. When the screen is not displayed (ie display is false), the effect can only be switched through the command line

image-20220219095427447

image-20210906141829879

1.3. Source code analysis

1.3.1. Algorithm principle

Find object poses from 3D-2D point correspondences using the RANSAC scheme.

The RanSaC algorithm (Random Sampling Consistency) was originally a classic algorithm for data processing. Its function is to extract specific components in objects in the presence of a large amount of noise. The following figure is an illustration of the effect of the RanSaC algorithm. There are some points in the figure that obviously satisfy a straight line, and another group of points is pure noise. The goal is to find the equation of the line in the presence of a lot of noise, where the amount of noisy data is 3 times that of the line.

img

If this effect cannot be obtained by the least squares method, the straight line will be a little higher than the straight line in the figure.

The basic assumptions of RANSAC are: (1) The data consists of "inside points", for example: the distribution of the data can be explained by some model parameters; (2) "outlier points" are data that cannot fit the model; (3) Except Data other than this is noise. The causes of outliers are: extreme values of noise; wrong measurement methods; wrong assumptions about the data. RANSAC also makes the following assumptions: given a set of (usually small) intra-office points, there is a process by which the model parameters can be estimated; and the model can explain or apply to intra-office points.

1.3.2. core code

Design Flow:

Yes
No
input image
Is the corner of each picture
Find corner subpixels
output image
Computed object attitude
Output image points and Jacobian matrix
Draw and output the image

launch file

xxxxxxxxxx
< launch > 
    < arg  name = "flip"  default = "False" /> 
    < arg  name = "display"  default = "False" /> 
    < node  name = "simple_AR"  pkg = "yahboomcar_visual"  type = "simple_AR.py"  output = "screen"  args = "$(arg display)" > 
        < param  name = "flip"  type = "bool"  value = "$(arg flip)" /> 
        < remap  from = "/simpleAR/camera"  to = "/simpleAR/camera" /> 
    </ node > 
    <!-- web_video_server --> 
    < node  pkg = "web_video_server"  type = "web_video_server"  name = "web_video_server"  output = "screen" /> 
</ launch > 

python main function

xxxxxxxxxx
    def  process ( self ,  img ): 
        if  self . flip  ==  'True' :  img  =  cv . flip ( img ,  1 ) 
        gray  =  cv . cvtColor ( img ,  cv . COLOR_BGR2GRAY ) 
        # Find the corners of each image 
        retval ,  corners  =  cv . findChessboardCorners ( 
            gray ,  self . patternSize ,  None , 
            flags = cv . CALIB_CB_ADAPTIVE_THRESH  +  cv . CALIB_CB_NORMALIZE_IMAGE  +  cv . CALIB_CB_FAST_CHECK ) 
        # Find corner subpixels 
        if  retval : 
            corners  =  cv . cornerSubPix ( 
                gray ,  corners , ( 11 ,  11 ), ( - 1 ,  - 1 ), 
                ( cv . TERM_CRITERIA_EPS  +  cv . TERM_CRITERIA_MAX_ITER ,  30 ,  0.001 )) 
            # Calculate object pose solvePnPRansac 
            retval ,  rvec ,  tvec ,  inliers  =  cv . solvePnPRansac ( 
                self . objectPoints ,  corners ,  self . cameraMatrix ,  self . distCoeffs ) 
            # output image points and jacobian matrix 
            image_Points ,  jacobian  =  cv . projectPoints ( 
                self . __axis ,  rvec ,  tvec ,  self . cameraMatrix ,  self . distCoeffs , ) 
            # draw the image 
            img  =  self . draw ( img ,  corners ,  image_Points ) 
        return  img 

key function

https://docs.opencv.org/3.0-alpha/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html

  • findChessboardCorners()
xxxxxxxxxx
def  findChessboardCorners ( image ,  patternSize ,  corners = None ,  flags = None ):  
    ''' 
Find image corners 
:param image: Input the original checkerboard image. The image must be an 8-bit grayscale or colormap. 
:param patternSize: (w,h), the number of interior corners of each row and column on the board.  w = the number of black and white blocks on a row of the board - 1, h = the number of black and white blocks on a column of the board - 1. 
For example: 10x6 chessboard, then (w,h)=(9,5) 
:param corners: array, output array of detected corners. 
:param flags: int, different operation flags, can be 0 or a combination of the following values: 
CALIB_CB_ADAPTIVE_THRESH Converts the image to black and white using adaptive thresholding instead of using a fixed threshold. 
    CALIB_CB_NORMALIZE_IMAGE Use histogram equalization to equalize the image before binarizing it with fixed threshold or adaptive thresholding. 
    CALIB_CB_FILTER_QUADS uses additional criteria (such as contour area, perimeter, square shape) to filter out false quads extracted during the contour retrieval stage. 
    CALIB_CB_FAST_CHECK Runs a quick check mechanism on the image to find the corners of the board, and returns a quick reminder if no corners are found. 
    Calls in degenerate conditions can be greatly accelerated when the checkerboard is not observed. 
    :return: retval, corners 
''' 
    pass 
  • cornerSubPix()

We need to use cornerSubPix() to further optimize the detected corners, so that the accuracy of the corners can reach sub-pixel level.

xxxxxxxxxx
def  cornerSubPix ( image ,  corners ,  winSize ,  zeroZone ,  criteria ): 
    ''' 
Subpixel corner detection function 
:param image: input image 
:param corners: pixel corners (both as input and output) 
:param winSize: area size is NXN; N=(winSize*2+1) 
:param zeroZone: Similar to winSize, but always has a smaller range, Size(-1,-1) means ignore 
:param criteria: criteria to stop optimization 
:return: subpixel corner 
''' 
    pass 
  • solvePnPRansac()
xxxxxxxxxx
def  solvePnPRansac ( objectPoints ,  imagePoints ,  cameraMatrix ,  distCoeffs ,  
                   rvec = None ,  tvec = None ,  useExtrinsicGuess = None ,  iterationsCount = None ,  
                   reprojectionError = None ,  confidence = None ,  inliers = None ,  flags = None ): 
    ''' 
    Calculate object pose 
:param objectPoints: list of object points 
:param imagePoints: list of corner points 
:param cameraMatrix: camera matrix 
:param distCoeffs: Distortion coefficients 
    :param rvec: 
    :param tvec: 
    :param useExtrinsicGuess: 
    :param iterationsCount: 
:param reprojectionError: 
    :param confidence: 
    :param inliers: 
    :param flags: 
    :return: retval, rvec, tvec, inliers 
''' 
    pass 

Find object poses from 3D-2D point correspondences using the RANSAC scheme. This function estimates the object pose given a set of object points, their corresponding image projections, and the camera matrix and distortion coefficients. This function finds a pose that minimizes the re-projection error, the re-observation error, that is, the observed pixel point projection imagePoints and the object projection ( projectPoints()) sum of squared distances between objectPoints. The use of RANSAC can avoid the effect of outliers on the results.

  • projectPoints()
def  projectPoints ( objectPoints ,  rvec ,  tvec ,  cameraMatrix ,  distCoeffs ,  imagePoints = None ,  jacobian = None ,  aspectRatio = None ):  
    ''' 
Output image points and Jacobian matrix 
    :param objectPoints:  
:param rvec: rotation vector 
:param tvec: translation vector 
:param cameraMatrix: camera matrix 
:param distCoeffs: Distortion coefficients 
    :param imagePoints:  
    :param jacobian:  
param aspectRatio: 
    :return: imagePoints, jacobian 
''' 
    pass 
TF release and monitoring
AR QR code

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/中文