SunFounder picar-x
(continued from previous page)
face_num = len(faces)
max_area = 0
if face_num > 0:
for (x,y,w,h) in faces: # Because the picture is reduced during operation,
˓→the increase now go back.
x = x
*
2
y = y
*
2
w = w
*
2
h = h
*
2
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) # Draw a frame for the
˓→recognized object on the image.
return img
• detectMultiScale - OpenCV
4.10 Video Car
This program will provide a First Person View from the PiCar-X! Use the keyboards WSAD keys to control the
direction of movement, and the O and P to adjust the speed.
Run the Code
Note:
• This project requires access to the Raspberry Pi desktop to view the footage taken by the camera module.
• You can connect a screen to the PiCar-X or refer to the tutorial remote_desktop to access it with VNC or XRDP.
• Once inside the Raspberry Pi desktop, open Terminal and type the following command to run it, or just open
and run it with a Python editor.
cd /home/pi/picar-x/example
sudo python3 video_car.py
Once the code is running, you can see what PiCar-X is shooting and control it by pressing the following keys.
• O: speed up
• P: speed down
• W: forward
• S: backward
• A: turn left
• Dturn right
• F: stop
• T: take photo
• ESC / Ctrl+C: quit
code
4.10. Video Car 71