我有 NVIDIA Jetson Nano 和 FullHD Ip 摄像头。摄像机流 RTSP/h264。
我想从这个相机解码python脚本中的帧以进行分析。
所以,我尝试使用类似的东西:
# import the necessary packages
from imutils.video import VideoStream
import imutils
import time
import cv2
# grab a reference to the webcam
print("[INFO] starting video stream...")
#vs = VideoStream(src=0).start()
vs = VideoStream(src="rtsp://login:password@192.168.1.180").start()
time.sleep(2.0)
# loop over frames
while True:
# grab the next frame
frame = vs.read()
# resize the frame to have a maximum width of 500 pixels
frame = imutils.resize(frame, width=500)
# show the output frame
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
# if the `q` key was pressed, break from the loop
if key == ord("q"):
break
# release the video stream and close open windows
vs.stop()
cv2.destroyAllWindows()
这是可行的,但以这种方式在 CPU 上解码帧。如何使用 GPU 解码器?