SunFounder PiCar-X Kit
Note: Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook!
Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.
Why Join?
• Expert Support: Solve post-sale issues and technical challenges with help from our community and team.
• Learn & Share: Exchange tips and tutorials to enhance your skills.
• Exclusive Previews: Get early access to new product announcements and sneak peeks.
• Special Discounts: Enjoy exclusive discounts on our newest products.
• Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.
Ready to explore and create with us? Click [] and join today!
4.10 8. Stare at You
This project is also based on the 7. Computer Vision project, with the addition of face detection algorithms.
When you appear in front of the camera, it will recognize your face and adjust its gimbal to keep your face in the center
of the frame.
You can view the screen at http://<your IP>:9000/mjpg.
Run the Code
cd ~/picar-x/example
sudo python3 8.stare_at_you.py
When the code is run, the car’s camera will always be staring at your face.
Code
from picarx import Picarx
from time import sleep
from vilib import Vilib
px = Picarx()
def clamp_number(num,a,b):
return max(min(num, max(a, b)), min(a, b))
def main():
Vilib.camera_start()
Vilib.display()
Vilib.face_detect_switch(True)
x_angle =0
y_angle =0
while True:
if Vilib.detect_obj_parameter['human_n']!=0:
coordinate_x = Vilib.detect_obj_parameter['human_x']
coordinate_y = Vilib.detect_obj_parameter['human_y']
(continues on next page)
4.10. 8. Stare at You 73