我收到错误:ValueError异常:无效字面对于int()与基体10:'20 r xfa20'
ValueError:invalid literal for int() with base 10 : '20\r\xfa20'
在这部分代码:
while True:
ret, im = cam.read()
gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(gray, 1.2, 5)
for(x, y, w, h) in faces:
a = ser.readline()
b = int((a).strip())
print(int(a))
cv2.rectangle(im, (x, y), (x+w, y+h), (225, 0, 0), 2)
Id, conf = recognizer.predict(gray[y:y+h, x:x+w])
print conf
if(conf < 50):
if(Id == 1):
Id = "disheet"
if(count1 == 0):
GPIO.output(13, GPIO.HIGH)
ser.write('d')
我我正在连续发送来自Arduino的20
,以便Pi和Arduino之间的通信将开始。
你能告诉我们你是从阅读本'ser'文件的内容?它看起来像不包含完整的字符串表示形式 – KGS
问题是2“20”值之间的'\ r \ xfa',它似乎是某种控制序列('\ r'是_CR_字符)。阅读时,你可以对该序列进行拆分,但这是纯粹的猜测。 – CristiFati
@service的KGS值是0,1,2 .... 12 –