Hello, I need some help and dont know where to search for, I searched and testet a lots last days, but nothing. I am new in this.
About my project:
Jetson Nano 2 GB Developer Kid, Raspberry Pi Camera V2. I would like to recognize and detect the objects, where they are, as in the demo from (jetson-inference in GitHub).
About my problem : I run the demo for object detection from Jetson-inference without problem, I made all steps from there, but I try to run one code from Toptechboy.com (Ai on the Jetson nano-Lesson 53), but its give errors and cant start any Video. I will send the code here and picture from the error>
I will be very happy for your advices or solution. Thank you very much!!!
import jetson.inference
import jetson.utils
import time
import cv2
import numpy as np
timeStamp=time.time()
fpsFilt=0
net=jetson.inference.detectNet('SSD-Mobilenet-v2',threshold=.5)
dispW=1280
dispH=720
flip=2
font=cv2.FONT_HERSHEY_SIMPLEX
# Gstreamer code for improvded Raspberry Pi Camera Quality
#camSet='nvarguscamerasrc wbmode=3 tnr-mode=2 tnr-strength=1 ee-mode=2 ee-strength=1 ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method='+str(flip)+' ! video/x-raw, width='+str(dispW)+', height='+str(dispH)+', format=BGRx ! videoconvert ! video/x-raw, format=BGR ! videobalance contrast=1.5 brightness=-.2 saturation=1.2 ! appsink'
cam=cv2.VideoCapture("csi://")
#cam=jetson.utils.gstCamera(dispW,dispH,'0')
# cam=cv2.VideoCapture('/dev/video1') # print from USB-Camera
cam.set(cv2.CAP_PROP_FRAME_WIDTH, dispW)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, dispH)
#cam=jetson.utils.gstCamera(dispW,dispH,'/dev/video1')
#display=jetson.utils.glDisplay()
#while display.IsOpen():
while True:
#img, width, height= cam.CaptureRGBA()
_,img = cam.read()
height=img.shape[0]
width=img.shape[1]
frame=cv2.cvtColor(img,cv2.COLOR_BGR2RGBA).astype(np.float32)
frame=jetson.utils.cudaFromNumpy(frame)
detections=net.Detect(frame, width, height)
for detect in detections: # d=detect in murtaza
#print(detect)
ID=detect.ClassID
top=int(detect.Top)
left=int(detect.Left)
bottom=int(detect.Bottom)
right=int(detect.Right)
item=net.GetClassDesc(ID) # item is a object, koito zasicha
# print(item,top,left,bottom,right)
cx,cy=int(detect.Center[0]),int(detect.Center[1]) # ot murtaza kod , koordinati na centyra na obekta
cv2.circle(img, (cx,cy),5 ,(0,255,0),cv2.FILLED) # ot murtaza kod
cv2.rectangle(img, (left, top), (right, bottom), (0, 255, 0), 2)
cv2.putText(img, item, (left, top + 15), font, 0.75, (0, 0, 255), 2)
#display.RenderOnce(img,width,height)
dt=time.time()-timeStamp
timeStamp=time.time()
fps=1/dt
fpsFilt=.9*fpsFilt + .1*fps
#print(str(round(fps,1))+' fps')
cv2.putText(img,str(round(fpsFilt,1))+' fps',(0,30),font,1,(0,0,255),2) # print fps on streaming
cv2.imshow('detCam',img)
cv2.moveWindow('detCam',0,0)
if cv2.waitKey(1)==ord('q'):
break
cam.release()
cv2.destroyAllWindows()