在此问题被驳回之前,请注意:
目标:尝试在PyQt5 GUI窗口中传输OpenCV网络摄像头视频帧
import os
import os
def diff_dir_with_filelist(directory, filepath):
new_files = os.listdir(directory)
with open(filepath, 'r') as text_file:
old_list = text_file.readlines()
old_files = set(item.rstrip() for item in old_list)
return [x for x in new_files if x not in old_files]
results = diff_dir_with_filelist("C:\\Users\\INstokes\\Desktop\\CityPts\\", "C:\\Users\\INstokes\\Desktop\\CityPts\\file.txt")
print(results)
我不知道如何调试它。没有错误回溯打印到控制台。任何帮助表示赞赏。提前谢谢。
答案 0 :(得分:1)
首先需要将openCv图像转换为QImage,然后使用pixmap显示图像,因为pixmap支持QImage格式。
height, width, bytesPerComponent = Img.shape
bytesPerLine = 3 * width
cv2.cvtColor(Img, cv2.COLOR_BGR2RGB, Img)
QImg = QImage(Img.data, width, height, bytesPerLine,QImage.Format_RGB888)
现在使用此QImg来pixmap
pixmap = QPixmap.fromImage(QImg)