I have the following code and it does not work because it cannot read the file from disk. The image is always None.
None
# -*- coding: utf-8 -*- import cv2 import numpy bgrImage = cv2.imread(u'D:\\ö\\handschuh.jpg')
Note: my file is already saved as UTF-8 with specification. I have been tested with Notepad ++.
In Process Monitor, I see that Python is accessing the file in the wrong way:
I read about:
open()
This can be done using
# -*- coding: utf-8 -*- import cv2 import numpy stream = open(u'D:\\ö\\handschuh.jpg', "rb") bytes = bytearray(stream.read()) numpyarray = numpy.asarray(bytes, dtype=numpy.uint8) bgrImage = cv2.imdecode(numpyarray, cv2.IMREAD_UNCHANGED)
, np.fromfile(), ndarray, cv2.imdecode() ndarray (, -):
np.fromfile()
cv2.imdecode()
import numpy as np # img is in BGR format if the underlying image is a color image img = cv2.imdecode(np.fromfile('测试目录/test.jpg', dtype=np.uint8), cv2.IMREAD_UNCHANGED)
np.fromfile() 1- . cv2.imdecode . cv2.IMREAD_UNCHANGED . .
cv2.imdecode
cv2.IMREAD_UNCHANGED
PS. , . .
bgrImage = cv2.imread(filename.encode('utf-8'))
utf-8
Source: https://habr.com/ru/post/1673893/More articles:df.unique () on entire column-based DataFrame - pythonЧто делают двойные фигурные скобки ({{) в файлах YAML (как используется Ansible)? - ansibleLoosely coupled custom frameworks in Swift - iosIntegration controller decorated with [Login] attribute - c #October loginCMS with multiple websites in one browser - octobercmsFind consecutive dates spanning a weekend - sqlFind users who worked for 5 consecutive days with a range of output dates - sqlHow to fill entire FloatingActionButton with icon - androidhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1673897/assigning-tasks-to-specific-machines-with-airflow&usg=ALkJrhgpTFLsu421ttZx7DHpMIGN5aUCEwSpring HATEROAS resourcesupport → domain object - javaAll Articles