Open Shooshpanchik opened 5 years ago
Hello, Shooshpanchik.
I tested your suggestion on 'demo.py' of function 'open' and it works! But i don't understand the difference between 'cv2.imread' and 'cv2.imdecode'.
Could you explain it? why it prevent the crush? And I think your comment seems to be more appropriate for 'Pull requests'.
Thanks! I learn one thing. I will update the 'open' function.
This code don't crush program if fileName contains Cyrillic symbols
stream = open(fileName, "rb") bytes = bytearray(stream.read()) numpyarray = np.asarray(bytes, dtype=np.uint8) stream.close() image = QPixmap(fileName)
mat_img = cv2.imread(fileName)
mat_img = cv2.imdecode(numpyarray, cv2.IMREAD_UNCHANGED) if image.isNull(): QMessageBox.information(self, "Image Viewer", "Cannot load %s." % fileName) return