【发布时间】:2021-06-22 15:26:09
【问题描述】:
我正在尝试学习 opencv,当我尝试执行代码时,它给了我错误 AttributeError:模块 'cv2' 没有属性 'samples' 有问题的行是 img = cv.imread(cv.samples.findFile("road.png")) 我在 ubuntu 18.04 上可以做什么? 整个代码:
import cv2 as cv
import sys
img = cv.imread(cv.samples.findFile("starry_night.jpg"))
if img is None:
sys.exit("Could not read the image.")
cv.imshow("Display window", img)
k = cv.waitKey(0)
if k == ord("s"):
cv.imwrite("starry_night.png", img)
【问题讨论】:
-
你能把整个代码贴出来吗?只有一行很难知道你在做什么
-
为什么不只是 download 来自 github 存储库的所需图像?