我正在做对象分类机器人手臂项目.Python openCV做对象检测部件,而Arduino控制机器人手臂。在这里我附加了一些对象检测代码。我不知道如何将检测到的对象从python发送到arduino。我该怎么办?
Python代码对象检测部分
x,y,w,h = cv2.boundingRect(contours[i])
if(vtc==3):
cv2.putText(frame,'TRIANGLE',(x,y),cv2.FONT_HERSHEY_PLAIN,(255,255,255),2,cv2.LINE_AA)
elif (vtc == 4):
cv2.putText(frame, 'RECTANGLE', (x, y), cv2.FONT_HERSHEY_PLAIN, scale, (255, 255, 255), 2,cv2.LINE_AA)
elif(vtc==5):
cv2.putText(frame,'PENTAGEN',(x,y),cv2.FONT_HERSHEY_PLAIN,scale,(255,255,255),2,cv2.LINE_AA)
elif(vtc==6):
cv2.putText(frame,'HEXAGEN',(x,y),cv2.FONT_HERSHEY_PLAIN,scale,(255,255,255),2,cv2.LINE_AA)
else:
#detect and label circle
area = cv2.contourArea(contours[i])
x,y,w,h = cv2.boundingRect(contours[i])
radius = w/2
if(abs(1 - (float(w)/h))<=2 and abs(1-(area/(math.pi*radius*radius)))<=0.2):
cv2.putText(frame,'CIRCLE',(x,y),cv2.FONT_HERSHEY_PLAIN,scale,(255,255,255),2,cv2.LINE_AA)