SunFounder PiCar-X Kit
(continued from previous page)
sleep(0.5)
Vilib.qrcode_detect_switch(False)
def take_photo():
_time = strftime('%Y-%m-%d-%H-%M-%S',localtime(time()))
name = 'photo_%s'%_time
username = os.getlogin()
path = f"/home/{username}/Pictures/"
Vilib.take_photo(name, path)
print('photo save as %s%s.jpg'%(path,name))
def object_show():
global flag_color, flag_face
if flag_color is True:
if Vilib.detect_obj_parameter['color_n'] == 0:
print('Color Detect: None')
else:
color_coodinate = (Vilib.detect_obj_parameter['color_x'],Vilib.detect_obj_
˓→parameter['color_y'])
color_size = (Vilib.detect_obj_parameter['color_w'],Vilib.detect_obj_
˓→parameter['color_h'])
print("[Color Detect] ","Coordinate:",color_coodinate,"Size",color_size)
if flag_face is True:
if Vilib.detect_obj_parameter['human_n'] == 0:
print('Face Detect: None')
else:
human_coodinate = (Vilib.detect_obj_parameter['human_x'],Vilib.detect_obj_
˓→parameter['human_y'])
human_size = (Vilib.detect_obj_parameter['human_w'],Vilib.detect_obj_
˓→parameter['human_h'])
print("[Face Detect] ","Coordinate:",human_coodinate,"Size",human_size)
def main():
global flag_face, flag_color, qr_code_flag
qrcode_thread = None
Vilib.camera_start(vflip=False,hflip=False)
Vilib.display(local=True,web=True)
print(manual)
while True:
# readkey
key = readchar.readkey()
key = key.lower()
# take photo
if key == 'q':
(continues on next page)
70 Chapter 4. Play with Python