OpenKinect / libfreenect2

Open source drivers for the Kinect for Windows v2 device
2.08k stars 752 forks source link

Issue initializing a Pipeline with Gstreamer using Kinect webcam ASUS #1178

Open Adrien3B1BGang opened 1 year ago

Adrien3B1BGang commented 1 year ago

I'm trying to use a webcam plunged into a Jetson Xavier NX so as to use it for obstacle detection for blind people but I don't know which pipeline to use with Gstreamer so as to capture image on this webcam. Here's my code using OpenCV and Python below thanks in advance

`

coding=utf-8

import cv2 print(cv2.version)

width = 800 height = 600 flip = 2

camSet = 'udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! appsink'

camSet = 'videotestsrc ! video/x-raw,framerate=20/1 ! videoscale ! videoconvert ! appsink'

camSet = 'appsrc ! videoconvert ! x264enc tune=zerolatency bitrate=500 speed-preset=superfast ! rtph264pay ! udpsink host=127.0.0.1 port=5000'

camSet='nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=3264, height=2464, framerate=21/1,format=NV12 ! nvvidconv flip-method='+str(flip)+' ! video/x-raw, width='+str(width)+', height='+str(height)+', format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink'

cam = cv2.VideoCapture(camSet,cv2.CAP_GSTREAMER)

window_width = 1920 window_height = 1020 print("Nombre de frames par secondes : ") print(cam.get(cv2.CAP_PROP_FPS))

cam.set(cv2.CAP_PROP_FRAME_WIDTH,window_width) cam.set(cv2.CAP_PROP_FRAME_HEIGHT,window_height)

if not cam.isOpened(): quit(1)

else :

print("Success")

while True: #boucle infinie ret, frame = cam.read() #on met l'image capturée par la camera dans la variable frame

if not ret:
    break

cv2.imshow('myCam', frame) #on affiche la frame, grâce à la boucle infinie ça devient une video (succesion d'images)
cv2.moveWindow('myCam',0,0) #On bouge la fenêtre
if cv2.waitKey(1) == ord('q'): #Si on appuie sur q on quitte la boucle (plus propre que ctrl + c)
    break

cam.release() cv2.destroyAllWindows()

`