update 更新界面显示
This commit is contained in:
11
Util/util_pic.py
Normal file
11
Util/util_pic.py
Normal file
@ -0,0 +1,11 @@
|
||||
import cv2
|
||||
from PIL.ImageQt import QImage, QPixmap
|
||||
|
||||
|
||||
def cv2_to_qpixmap(cv_img):
|
||||
"""将OpenCV图像转换为QPixmap"""
|
||||
cv_img = cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB)
|
||||
height, width, channel = cv_img.shape
|
||||
bytes_per_line = 3 * width
|
||||
q_img = QImage(cv_img.data, width, height, bytes_per_line, QImage.Format_RGB888)
|
||||
return QPixmap.fromImage(q_img)
|
||||
Reference in New Issue
Block a user