如何使用opencv

时间:2018-05-08 23:29:32

标签: python linux opencv ssh nvidia-jetson

我目前正在使用带有gitbash的Windows计算机,使用板载相机ssh到nvidia jetson tx2:

ssh nvidia@'my ip address"

然后我用命令激活jetson tx2上的摄像头:

gst-launch-1.0 -ev nvcamerasrc ! nvoverlaysink

我准备好了一个python脚本来查看相机流:

import numpy as np
import cv2
cap=cv2.VideoCapture('/dev/video0')
while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Our operations on the frame come here
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    # Display the resulting frame
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

当我直接在我的jetson tx2 python发行版上运行这个脚本时,我已安装此脚本显示相机源。

我的问题是,如何让这个脚本在我用来进入jetson tx2的机器上运行?

我认为这与该行有关:

cap=cv2.VideoCapture('/dev/video0')

当我进入jetson时,相机如何被调用?

1 个答案:

答案 0 :(得分:0)

您需要X11转发显示屏。现在它不知道如何处理输出,因为没有连接显示器。如果您在Windows上运行,则需要下载xming。运行它(只需双击桌面快捷方式),然后:

ssh -X nvidia@ip_address

请记住,X转发带宽有限,因此可能会降低您的流程速度,无论结果如何。