英文:
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("C:/test_image.jpg")
try:
cv2.imshow('result', image)
cv2.waitKey(0)
except:
print("Here")
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论