EasyManua.ls Logo

SunFounder PiCar-X Kit - Page 75

Default Icon
181 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder PiCar-X Kit
(continued from previous page)
take_photo()
# color detect
elif key != '' and key in ('0123456'): # '' in ('0123') -> True
index = int(key)
if index == 0:
flag_color = False
Vilib.color_detect('close')
else:
flag_color = True
Vilib.color_detect(color_list[index]) # color_detect(color:str -> color_
˓name/close)
print('Color detect : %s'%color_list[index])
# face detection
elif key =="f":
flag_face = not flag_face
face_detect(flag_face)
# qrcode detection
elif key =="r":
qr_code_flag = not qr_code_flag
if qr_code_flag == True:
if qrcode_thread == None or not qrcode_thread.is_alive():
qrcode_thread = threading.Thread(target=qrcode_detect)
qrcode_thread.setDaemon(True)
qrcode_thread.start()
else:
if qrcode_thread != None and qrcode_thread.is_alive():
# wait for thread to end
qrcode_thread.join()
print('QRcode Detect: close')
# show detected object information
elif key == "s":
object_show()
sleep(0.5)
if __name__ == "__main__":
main()
How it works?
The first thing you need to pay attention to here is the following function. These two functions allow you to start the
camera.
Vilib.camera_start()
Vilib.display()
Functions related to “object detection”:
Vilib.face_detect_switch(True) : Switch ON/OFF face detection
Vilib.color_detect(color) : For color detection, only one color detection can be performed at the same
time. The parameters that can be input are: "red", "orange", "yellow", "green", "blue", "purple"
Vilib.color_detect_switch(False) : Switch OFF color detection
4.9. 7. Computer Vision 71

Table of Contents

Related product manuals