As the title says. I was addicted to OpenCV because it didn't read the path, so I looked into what happened and found that if I put Japanese in the path, it wouldn't work properly.
C: ↓ user ↓ test01.jpg TestOpenCV.py
TestOpenCV.py
import cv2
filename = "C:/user/test01.jpg " # ファイルパスの「user」がアウトで読み込んでくれない
img = cv2.imread(filename,0) # img =Become None
Do not include Japanese in the path or use a relative path.
TestOpenCV.py
import cv2
filename = "C:/User/test01.jpg " #Change "User" to "User"
filename = "./test01.jpg " #TestOpenCV if you can't change the name.Make it a relative path as seen from py
img = cv2.imread(filename,0) #It loads the image properly
Recommended Posts