解决方法 将传入cv2.rectangle()的第一个参数先使用cv2.UMat().get()方法转化一下类型,像这样: img = cv2.UMat(img).get() cv2.rectangle(img, (x1, y1), (x2, y2), (B, G