请问qt5截完图怎么直接输出字节集数据

img


我完截图,不想让他保存在本地。
我想直接用 print()输出截完图得字节集内容过后可以直接给cv调用

麻烦各位帮帮忙

试试这个

import cv2
import numpy as np

# 图片转为字节流
img_src = cv2.imread("E:/result_data/1.jpg")
img_byte = img_src.tobytes()

# 字节流转为图片
nparr = np.frombuffer(img_byte, dtype=np.uint8)
img_shape = int(math.sqrt(nparr.shape[0]/3))
img_dst= nparr.reshape(img_shape,img_shape,3)
cv2.imshow("dst", img_dst)
cv2.waitKey(0)


imgptr = self.face_show_register.pixmap().toImage()
ptr = imgptr.constBits()
ptr.setsize(imgptr.byteCount())
mat = np.array(ptr).reshape(imgptr.height(), imgptr.width(),4)
mat_img = cv2.cvtColor(mat, cv2.COLOR_BGR2RGB)
网上搜到的,希望能解决楼主问题