I can’t get the gstream pipeline to work directly from the terminal… this might be the issue
gst-launch-1.0 v4l2src device=/dev/video7 ! video/x-raw,framerate=30/1 ! xvimagesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
I have tried Jetson Nano, and I met the same problem as yours. The JetPack version which I used is 4.6 but it was 4.4 posted herer. I am trying to recover the system to 4.4 and see what is going on.
this is how I am controlling the resolution from the command line. The nano can’t effectively process the 4K streams for object recognition in my tests. You may get better results.
if (argc > 1 && strcmp("--format", argv[1]) == 0) {
if (argc > 2 && strcmp("4K", argv[2]) == 0) {
printf("THETA live video is 4K");
res = thetauvc_get_stream_ctrl_format_size(devh,
THETAUVC_MODE_UHD_2997, &ctrl);
} else if (argc > 2 && strcmp("2K", argv[2]) == 0) {
printf("THETA live video is 2K");
res = thetauvc_get_stream_ctrl_format_size(devh,
THETAUVC_MODE_FHD_2997, &ctrl);
}
else {
printf("specify video device. --format 4K or --format 2K\n");
goto exit;
}
}
Based on Ubuntu 18.04.5 LTS
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic
confirmed with nvv4l2decoder
tested on Jetson Nano. You may need to specify nvv4l2decoder for Xavier as I’ve heard that decodebin may not work.
if (strcmp(cmd_name, "gst_loopback") == 0)
// for Jetson Nano
pipe_proc = "nvv4l2decoder ! autovideoconvert !"
// pipe_proc = "decodebin ! autovideoconvert ! "
"video/x-raw,format=I420 ! identity drop-allocation=true !"
"v4l2sink device=/dev/video1 qos=false sync=false";
else
// pipe_proc = " decodebin ! autovideosink sync=false qos=false";
// tested on Jetson Nano. Should work on Xavier
pipe_proc = "nvv4l2decoder ! nv3dsink sync=false qos=false";
starting gst_loopback
Ignoring errors about pixformat. See below. The OP got it to work with the error.
To make testing easier, I installed VS Code ARM64 on the Nano. The Jetson is such a cool little device. IMO, it’s much easier to work on than a Raspberry Pi. However, I guess it does cost more than an RPi and likley has more power requirements. The entire Jetson line is great.
You may be able to get additional help on the NVIDIA developer forum. I’m not sure why it wouldn’t be installed with JetPack. The file should be there.
I tried using your Canny program in the Jetson Xavier, and I’m still getting the "Internal data stream error".
$ python canny.py --video_device 7
Called with args:
Namespace(video_device=7)
OpenCV version: 4.5.3
Device Number: 7
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (2057) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Internal data stream error.
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (1034) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (597) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video7): can't open camera by index
camera open failed
I found this extremely weird. Because even though the pipeline is working with gst_loopback, it is not working on its own in the terminal nor in OpenCV.
I tried different pipelines configurations, but yet nothing seems to be working. Do you have any idea on what could be wrong?
import sys
import cv2
print (cv2.__version__)
print(cv2.__file__)
#print(cv2.getBuildInformation())
cap = cv2.VideoCapture('decodebin ! autovideoconvert ! video/x-raw,format=I420 ! identity drop-allocation=true ! v4l2sink device=/dev/video7 qos=false sync=false', cv2.CAP_GSTREAMER)
if not cap.isOpened() :
print("capture failed")
exit()
ret,frame = cap.read()
while ret :
cv2.imshow('frame',frame)
ret,frame = cap.read()
if(cv2.waitKey(1) & 0xFF == ord('q')):
break;
cap.release()
cv2.destroyAllWindows()
I am getting this error:
/usr/local/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (944) open OpenCV | GStreamer warning: cannot find appsink in manual pipeline
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (597) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
capture failed
/usr/local/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (854) open OpenCV | GStreamer warning: Error opening bin: no property "n-thread" in element "videoconvert0"
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (597) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
capture failed
/usr/local/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (2057) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Internal data stream error.
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (1034) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/spacer/Downloads/opencv-4.5.3/modules/videoio/src/cap_gstreamer.cpp (597) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
capture failed