我正在研究 jetson nano 并使用 hello ai world 提供的 jetson 库。我已经测试了库附带的基本算法,它们都运行良好,但我做了一些更改以使其在视频上运行
出现错误这是我的代码
import jetson.inference
import jetson.utils
import cv2
#import argparse
import sys
import numpy as np
width=720
height=480
vs=cv2.VideoCapture('b.m4v') #video input file
net = jetson.inference.detectNet("ssd-mobilenet-v2", threshold=0.5) #loading the model
#camera = jetson.utils.gstCamera(1280, 720, "/dev/video0") #using V4L2
display = jetson.utils.glDisplay() #initialting a display window
while display.IsOpen():
_,frame = vs.read() #reading a frmae
img = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA) #converting it to a bgra format for jetson util
img = jetson.utils.cudaFromNumpy(img) #converting image to cuda format from numpy array
#img, width, height = camera.CaptureRGBA()
detections = net.Detect(img, width, height) #running detections on each image and saving the results in detections
display.RenderOnce(img, width, height) #display the output frame with detection
display.SetTitle("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS())) #display title for the output feed
这是错误:
[OpenGL] glDisplay -- X screen 0 resolution: 1280x1024
[OpenGL] failed to create X11 Window.
jetson.utils -- PyDisplay_Dealloc()
Traceback (most recent call last):
File "pool1.py", line 16, in <module>
display = jetson.utils.glDisplay() #initialting a display window
Exception: jetson.utils -- failed to create glDisplay device
PyTensorNet_Dealloc()