我是 Python 的新手(但不是 openCV 的新手),我很确定一切都安装正确,我测试了一些程序并且似乎工作正常,但是当我想在图像上绘制时,例如这个代码来自 Python openCV 教程:
import numpy as np
import cv2
# Create a black image
img = np.zeros((512,512,3), np.uint8)
# Draw a diagonal blue line with thickness of 5 px
img = cv2.line(img,(0,0),(511,511),(255,0,0),5)
cv2.imshow('img',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /build/buildd/opencv-2.3.1/modules/core/src/array.cpp, line 2482
Traceback (most recent call last):
File "/home/dccv/rec 2.py", line 17, in <module>
cv2.imshow('img',img)
cv2.error: /build/buildd/opencv-2.3.1/modules/core/src/array.cpp:2482: error: (-206)
Unrecognized or unsupported …Run Code Online (Sandbox Code Playgroud)