强制退出窗口时 ssh 连接丢失

强制退出窗口时 ssh 连接丢失

我正在使用ssh连接到服务器(Ubuntu 19.04)并使用jupyter-notebook。我使用 打开一个窗口OpenCV,然后当我想关闭窗口时,我应该强制退出它,因为关闭按钮不起作用。这样做会导致 ssh 连接丢失。这是我的代码:

from pypylon import pylon
import cv2

# conecting to the first available camera
camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())

# Grabing Continusely (video) with minimal delay
camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly) 
converter = pylon.ImageFormatConverter()
# print(converter)
# exit()
# converting to opencv bgr format
converter.OutputPixelFormat = pylon.PixelType_BGR8packed
converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned

while camera.IsGrabbing():
    grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)

    if grabResult.GrabSucceeded():
        # Access the image data
        image = converter.Convert(grabResult)
        img = image.GetArray()
        cv2.namedWindow('title', cv2.WINDOW_NORMAL)
        cv2.imshow('title', img)
        cv2.waitKey()
    grabResult.Release()

# Releasing the resource    
camera.StopGrabbing()

cv2.destroyAllWindows()

有什么问题?

相关内容