1
0

More than 1 year has passed since last update.

python画像読み込みエラー

Last updated at Posted at 2021-12-06

import cv2
print(cv2.version)

image = cv2.imread("./test.jpg")

image2 = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

cv2.namedWindow('image')

while True:
cv2.imshow('image', image)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()

実行後
error: OpenCV(4.5.1) /private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/pip-req-build-yvyj7qlp/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

ここを参考に
https://qiita.com/Nw3965/items/5ef4bc82dd9c28e36a19

3行目を絶対パスに変更
image = cv2.imread("./test.jpg")

image = cv2.imread("/Users/○○○/Desktop/test.jpg")

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0