import numpy
import cv2
img = cv2.imread(r'vedio.capture/R-C.jpg')
Gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # 灰度图
_, img_black = cv2.threshold(Gray, 127, 255, cv2.THRESH_BINARY)#黑白二值
conturs,hierarchy = cv2.findContours(img_black, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)#轮廓查找
print(type(img))
print(img.dtype)
img1 = img.copy #复制,问题就在这
print(type(img))
print(img.dtype)
ret = cv2.drawContours(img1,conturs,-1,(0,255,0),1)#绘制图像
cv2.imshow('culContours',ret)
cv2.waitKey(0)
cv2.imshow('culContours',img)
cv2.waitKey(0)
# cv2.destroyAllWindows()
好像绘制轮廓的时候发现会在原有的图像上绘制,故尝试用np的复制,但是无效,理论上img的被复制,type也是一样的,且被证实成立cv却不能识别,错误代码奉上