In addition to using the keyboard to control the status of the car, we also wrote a ball tracking code.
sudo apt-get install libatlas-base-dev libjasper-dev libqt4-test libwebp6 libtiff5 libopenexr23 libgstreamer1.0-0 libavcodec-dev libavformat-dev libswscale-dev libqtgui4 -y sudo pip3 install opencv-python==220.127.116.11 cd ~/SunFounder_PiCar-V/ball_track python3 ball_tracker.py
After the code runs, find a red ball (at least larger than the diameter of the camera) and put it within 10-50cm range in front of the camera to get the car to follow your ball.
If you want to know whether the car has catched your ball, you can do as follows:
Step 1: Enable the VNC on the Raspberry Pi.
Choose 5 Interfacing Options.
Finally select OK->Finish to exit the config.
Step 2: Download the VNC Viewer for your computer and install it.
Note: During your installation on your Windows, if you encounter the following prompt, please click Comtinue to continue your installation.
Step 3: Open VNC Viewer you have installed, type in your Raspberry Pi IP address, and press the Enter button.
Step 4: Enter the username and password of your Raspberry Pi on this page, by default, they are pi and raspberry; then click OK.
Step 5: Now, we enter the Raspberry Pi desktop, click Terminal and type the following commands to open the code ball_tracker.py.
cd ~/SunFounder_PiCar-V/ball_track sudo nano ball_tracker.p
Then modify the code as follows:
Show_image_enable = True
Draw_circle_enble = True
Press Ctrl+X and Y to save the change.
Note: After you finish doing this step, you must log in the Raspberry Pi via VNC, or you can use a monitor; if not, the warning is as follows:
Step 6: Run the ball_tracker.py.
Step 7: After running the code ball_tracker.py, these four images will appear. If you place a red ball in front of the camera, you can see a green circle which represents that the car has catched your red ball.