'pyqt5 outer class function make the program breakdown

def show_camera(self):
    flag,images = self.cap.read()  #从视频流中读取
    self.gesture_frame_implement = mediapipe_gesture.ReadGesture()
    frame, gesture_str = self.gesture_frame_implement.detect(images)
    show = cv2.resize(frame,(640,480))     #把读到的帧的大小重新设置为 640x480
    show = cv2.cvtColor(show,cv2.COLOR_BGR2RGB) #视频色彩转换回RGB,这样才是现实的颜色
    showImage = QtGui.QImage(show.data,show.shape[1],show.shape[0],QtGui.QImage.Format_RGB888) #把读取到的视频数据变成QImage形式
    self.label_show_camera.setPixmap(QtGui.QPixmap.fromImage(showImage))  #往显示视频的Label里 显示QImage
    del images, show, showImage, flag, frame

In the display window function in pyqt5, an external class function is called(frame, gesture_str = self.gesture_frame_implement.detect(images)). When this external class function is enabled, the memory occupied by the entire program will become larger and larger until the program crashes. (I have deleted the unneeded variables with the DEL method in this outer class function). How to solve it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source