Objective:
In this lesson, we will show you how to use Raspberry Pi camera to “see” the line and make auto driving. We will use a famou computer-vision software library called OpenCV.

Hardware Installation:
Everything same as lesson 6 , but the camera must facing down to the tracking line.

Software Installation:

Step 1) Install OpenCV library for Python3 by following command:

sudo apt update
sudo apt install python3-opencv

Step 2)Download Lesson 7 sample code :

wget http://osoyoo.com/driver/picar/oc-tracking.py

Step 3)run the code:

Python3 oc-tracking.py

Note: If you want to debug the opencv code, you can uncomment all the cv2.imshow statements in line 22,120,125. Then connect the pi to a display device(we highly command you use OSOYOO 5″ DSI screen). Then you will see how the OpenCV transform the camera video into line data and then control the car movement.

Running result: