Hello everyone,
I have problem when i try to build the object detection stack it not working i saw some errors but i don’t know why ?
warning: importing jetson.utils is deprecated. please 'import jetson_utils' instead.
warning: importing jetson.inference is deprecated. please 'import jetson_inference' instead.
jetson.inference -- detectNet loading build-in network 'ssd-mobilenet-v2'
[TRT] Could not register plugin creator - ::FlattenConcat_TRT version 1
[TRT] didn't load expected number of class colors (0 of 91)
[TRT] filling in remaining 91 class colors with default colors
my hardware configuration:
-PI camera V2.1
- jetson nano
- Power
my software configuration:
CV2 4.6.0 V
GStreamer Core Library version 1.14.5
this is the code,
import jetson.inference
import jetson.utils
import cv2
# set interference
net = jetson.inference.detectNet("ssd-mobilenet-v2", threshold=0.5)
def gstreamer_pipeline(
capture_width=1920,
capture_height=1080,
display_width=960,
display_height=540,
framerate=30,
flip_method=0,
):
return (
"nvarguscamerasrc ! "
"video/x-raw(memory:NVMM), "
"width=(int)%d, height=(int)%d, framerate=(fraction)%d/1 ! "
"nvvidconv flip-method=%d ! "
"video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! "
"videoconvert ! "
"video/x-raw, format=(string)BGR ! appsink drop=True"
% (
capture_width,
capture_height,
framerate,
flip_method,
display_width,
display_height,
)
)
# process csi camera
video_file = cv2.VideoCapture(gstreamer_pipeline(), cv2.CAP_GSTREAMER)
if video_file.isOpened():
cv2.namedWindow("Detection result", cv2.WINDOW_AUTOSIZE)
print('CSI stream opened. Press ESC or Ctrl + c to stop application')
while cv2.getWindowProperty("Detection result", 0) >= 0:
ret, frame = video_file.read()
# convert and detect
imgCuda = jetson.utils.cudaFromNumpy(frame)
detections = net.Detect(imgCuda)
# draw rectangle and description
for d in detections:
x1, y1, x2, y2 = int(d.Left), int(d.Top), int(d.Right), int(d.Bottom)
className = net.GetClassDesc(d.ClassID)
cv2.rectangle(frame, (x1,y1), (x2, y2), (0, 0, 0), 2)
cv2.putText(frame, className, (x1+5, y1+15), cv2.FONT_HERSHEY_DUPLEX, 0.75, (0, 0, 0), 2)
# show frame
cv2.imshow("Detection result", frame)
# stop via ESC key
keyCode = cv2.waitKey(30) & 0xFF
if keyCode == 27 or not ret:
break
# close
video_file.release()
cv2.destroyAllWindows()
else:
print('unable to open csi stream')```