User Manual
Table Of Contents
- 1. Premise
- 2. Raspberry Pi System Installation and Developmen
- 3 Log In to The Raspberry Pi and Install The App
- 4 Raspberry Pi Structure Assembly and Precautions
- 5 Controlling A Robot via WEB App
- 6 Common Problems and Solutions(Q&A)
- 7 Set The Program to Start Automatically
- 8 Remote Operation of Raspberry Pi Via MobaXterm
- 9 How to Control WS2812 RGB LED
- 10 How to Control The Servo
- 11 Calling the API to Control the Robot
- 12 Automatic Stabilization Function
- 13 Gait Generation Method of A Hexapod Robot
- 14 Make A Police Light or Breathing Light
- 15 Real-Time Video Transmission
- 16 Why OpenCV Uses Multi-threading to Process Vide
- 17 OpenCV Learn to Use OpenCV
- 18 Using OpenCV to Realize Color Recognition and T
- 19 Machine Line Tracking Based on OpenCV
- 20 Create A WiFi Hotspot on The Raspberry Pi
- 21 Install GUI Dependent Item under Window
- 22 How to Use GUI
- 23 Enable UART
- 24 Control Your Adeept_RaspClaws with An Android D
- Conclusion
114
Convert the picture to black and white, and then binarize (the value of each pixel in the picture is 255
except 0)
'''
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
retval, img = cv2.threshold(img, 0, 255, cv2.THRESH_OTSU)
img = cv2.erode(img, None, iterations=6) #Use Corrosion Denoising
colorPos = img[linePos] #Get an array of pixel values for linePos
try:
lineColorCount_Pos = np.sum(colorPos == lineColorSet) #Get the number of pixels of line color
(line width)
lineIndex_Pos = np.where(colorPos == lineColorSet) #Get the horizontal position of the end
point of the line in the linePos line
'''
Use the endpoint position and line width to calculate the position of the center point of the line
'''
left_Pos = lineIndex_Pos[0][lineColorCount_Pos-1]
right_Pos = lineIndex_Pos[0][0]
center_Pos = int((left_Pos+right_Pos)/2)
print('The position of the center point of the line is:%d'%center_Pos)
except:
'''
If no line is detected, the line width above 0 will cause an error, so that you know that no line has
been detected
'''
center_Pos = 0
print('No line detected')
'''
Draw a horizontal reference line
'''
cv2.line(img,(0,linePos),(640,linePos),(255,255,64),1)
if center_Pos:
'''
If a line is detected, draw the center point of the line
'''
cv2.line(img,(center_Pos,linePos+300),(center_Pos,linePos-300),(255,255,64),1)
# encode as a jpeg image and return it
yield cv2.imencode('.jpg', img)[1].tobytes()