I’ve been trying to run the ssd-mobilenet-v2 demo using my-detection.py (available in Hello AI World). However, since I’m using Arducam’s stereoscopic camera (IMX219), it would give me this error:
File “/home/evannandi/Desktop/pyPro/openCV/openCV1.py”, line 5, in
camera = jetson.utils.gstCamera(2560, 720, 0) # using V4L2
Exception: jetson.utils – gstCamera.init() failed to parse args tuple
PyTensorNet_Dealloc()
So I’ve been trying to modify the code to be able to run my camera, as follows:
import jetson.inference
import jetson.utils
import cv2
import numpy as np
net = jetson.inference.detectNet(“ssd-mobilenet-v2”, threshold=0.5)
cam = cv2.VideoCapture("/dev/video0", cv2.CAP_V4L2)
cam.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(‘Y’, ‘1’, ‘6’, ’ '))
cam.set(cv2.CAP_PROP_CONVERT_RGB, False)
display = jetson.utils.glDisplay()
while True:
ret, frame = cam.read()
frame_rgba = cv2.convertScaleAbs(frame, None, 0.5) #makes brighter
frame_rgba = frame_rgba.astype(np.uint8) #funky
frame_rgba = cv2.cvtColor(frame_rgba, cv2.COLOR_BAYER_RG2RGBA)
width = frame.shape[1]
height = frame.shape[0]
img = jetson.utils.cudaFromNumpy(frame_rgba)
detections = net.Detect(img, width, height, 'opt.overlay')
cv2.imshow("Overtaking Assistance", frame_rgba)
ret = cv2.waitKey(1)
# press 'q' to exit.
if ret == ord('q'):
break
However, now I would get this error:
Traceback (most recent call last):
File “/home/evannandi/Desktop/pyPro/Object Detection Trial/my-detection.py”, line 10, in
display = jetson.utils.glDisplay()
Exception: jetson.utils – failed to create glDisplay device
PyTensorNet_Dealloc()
Please help :)