Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IPython笔记本中的Python OpenCV错误_Python_Opencv_Ipython Notebook - Fatal编程技术网

IPython笔记本中的Python OpenCV错误

IPython笔记本中的Python OpenCV错误,python,opencv,ipython-notebook,Python,Opencv,Ipython Notebook,我在IPython笔记本中运行此代码时出错。 我的代码: 错误: error Traceback (most recent call last) <ipython-input-12-dc7e5a608b64> in <module>() 6 # Draw a diagonal blue line with thickness of 5 px 7 img = cv2.line(i

我在IPython笔记本中运行此代码时出错。 我的代码:

错误:

error                                     Traceback (most recent call last)
<ipython-input-12-dc7e5a608b64> in <module>()
      6 # Draw a diagonal blue line with thickness of 5 px
      7 img = cv2.line(img,(0,0),(511,511),(255,0,0),5)
----> 8 cv2.imshow('image',img)
      9 cv2.waitKey(0)

error: ..\..\..\modules\highgui\src\window.cpp:261: error: (-215) size.width>0 && size.height>0 in function cv::imshow
您使用cv2.line函数的输出重新分配img数组,但是 根据统计,它的产量是零

此版本将为您提供所需的结果:

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
cv2.line(img,(0,0),(511,511),(255,0,0),5)
cv2.imshow('image',img)
cv2.waitKey(0)
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
cv2.line(img,(0,0),(511,511),(255,0,0),5)
cv2.imshow('image',img)
cv2.waitKey(0)