Message : error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

huangapple go评论82阅读模式
英文:

Message : error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

问题

我正在运行下面的代码,并尝试修改路径,但问题仍未解决。在这里,异常部分被执行,而try块未被执行。

代码:

import cv2
import numpy as np 
image = cv2.imread("C:\\test_image.jpg")

try:
    cv2.imshow('result', image)
    cv2.waitKey(0)

except:
    print("这里")
英文:

I am running the below code and have tried to modify the path, but still the issue is not getting resolved. Here, the exception part is getting executed and the try block is not getting executed.

Code :

import cv2
import numpy as np 
image = cv2.imread("C:\\test_image.jpg")

try:
    cv2.imshow('result', image)
    cv2.waitKey(0)

except:
    print("Here")

答案1

得分: 1

我猜测路径不正确。尝试将反斜杠变成双反斜杠,像这样:C:\test_image.jpg

英文:

I guess the path is incorrect. Try making your backslash double like C:\test_image.jpg

答案2

得分: 0

你的路径不正确

import numpy as np 
image = cv2.imread("C:/test_image.jpg")

try:
    cv2.imshow('result', image)
    cv2.waitKey(0)

except:
    print("Here")

<details>
<summary>英文:</summary>

Your path is incorrect

```import cv2
import numpy as np 
image = cv2.imread(&quot;C:/test_image.jpg&quot;)

try:
    cv2.imshow(&#39;result&#39;, image)
    cv2.waitKey(0)

except:
    print(&quot;Here&quot;)

</details>



huangapple
  • 本文由 发表于 2020年1月6日 02:56:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/59603176.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定