QT 위젯에 이미지를 띄웠는데 정상적으로 나오지 않고 이미지가 반복되거나 왜곡되어 표시되는 경우가 있다
위젯에 이미지를 띄우려는 경우 QImage 를 생성할텐데, 이 단계에서 이미지의 한 줄당 바이트 수를 지정해주면 깔끔하게 해결된다
height, width, channels = img.shape
# 이렇게 작성된 부분을
qimg = QImage(img.data, width, height, QImage.Format_RGB888)
# 이렇게 수정해준다 (4번 째 파라미터가 추가됐다)
qimg = QImage(img.data, width, height, width * channels, QImage.Format_RGB888)
C++ 과 python 두 언어에서 모두 해당되는 해결방법이다
참조
https://stackoverflow.com/questions/39057168/qwidget-draws-distorted-angled-qimage
QWidget draws distorted angled QImage
I'm working on a homework for my Digital Image Processing class, and I'm using OpenCV with QT Framework. I've created a class ImageDisplay, which is as sub class of the QWidget class. I've using ...
stackoverflow.com
'Programming > Python' 카테고리의 다른 글
[Python] USB Serial 통신하기 (0) | 2023.07.13 |
---|---|
Pycharm import 빨간 줄 없애기 (0) | 2023.06.20 |
[Python] Scikit-image TypeError: rescale() got an unexpected keyword argument 'multichannel' (0) | 2023.03.15 |
[Python] Could not load the Qt platform plugin "xcb" 해결방법 (0) | 2023.02.26 |
[Python] list를 부분 분리 할 때 사용하는 '*' (0) | 2022.10.06 |