SunFounder PiCrawler Kit
Entering s will print the information of the face detection (and color detection) target in the terminal.
Including the center coordinates (X, Y) and size (Weight, height) of the measured object.
Code
from pydoc import text
from vilib import Vilib
from time import sleep, time, strftime, localtime
import threading
import readchar
flag_face = False
flag_color = False
qr_code_flag = False
manual = '''
Input key to call the function!
q: Take photo
1: Color detect : red
2: Color detect : orange
3: Color detect : yellow
4: Color detect : green
5: Color detect : blue
6: Color detect : purple
0: Switch off Color detect
rScan the QR code
f: Switch ON/OFF face detect
s: Display detected object information
'''
color_list = ['close', 'red', 'orange', 'yellow',
'green', 'blue', 'purple',
]
def face_detect(flag):
print("Face Detect:" + str(flag))
Vilib.face_detect_switch(flag)
def qrcode_detect():
global qr_code_flag
if qr_code_flag == True:
Vilib.qrcode_detect_switch(True)
print("Waitting for QR code")
text = None
while True:
temp = Vilib.detect_obj_parameter['qr_data']
if temp != "None" and temp != text:
text = temp
print('QR code:%s'%text)
if qr_code_flag == False:
break
sleep(0.5)
Vilib.qrcode_detect_switch(False)
(continues on next page)
3.7. Computer Vision 59