1

我根据实时视频在 GUI 中制作了一个框架。

当我打开电脑并运行程序时,整个视频出现在屏幕上。但是过了一会儿,当我运行程序时,屏幕上只出现了一部分视频。

错误代码不会发生..所以我不知道问题是什么。

像这样。 在此处输入图像描述

我正在使用 FLIR 相机(Spinnaker SDK)、Python 3.8 和 Visual Studio Code(通过将看起来像有线 Internet 线的电缆插入计算机主体来使用 FLIR 相机。)

我写的代码:

    def __init__(self, video_source=0):
        # open the video source 
         self.cap=EasyPySpin.VideoCapture(video_source)  
         if not self.cap.isOpened():
             raise ValueError("ERROR", video_source)
                    

    def getFrame(self):
        if self.cap.isOpened ():
            isTrue, frame_original = self.cap.read()  
            global frame
            
            if isTrue: 
                frame = cv2.resize(frame_original, dsize=(0,0), fx=0.26, fy=0.26, interpolation=cv2.INTER_AREA)
                # if isTure is true then current frame converted to RGB
                return (isTrue, cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
            else:     
                return(isTrue, None) 
           
        else: 
            return (None)              
    
    def __del__(self):  
        if self.cap.isOpened():
            self.cap.release()

有什么可以参考的吗?如果您知道解决方案,请帮助我。

4

0 回答 0