VideoCapture
is a class to interface with video streams, and a single image is returned via call to its read()
method. When you call cap = cv2.imread()
, you are replacing the newly created VideoCapture
instance with np.ndarray
instance which is returned by cv2.imread
.
I believe that replacing
success, img = cap.read()
with
img = cv2.imread(testImg.PNG)
would solve your problem.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…