How to view CSI sensor stream. Source: https://elinux.org/Jetson_TX1/TX2_OV5693

gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=120/1, format=NV12' ! nvvidconv flip-method=0 ! nvegltransform ! nveglglessink -e

How to extend Xavier's display and mouse/keyboard over the network to another linux device

Terminal N1

ssh -X name@hostip 
export DISPLAY=:0
chromium-browser

Terminal N2

ssh -X name@hostip 'x2x -east -to :0'

Cloning a filesystem of a Jetson and making a deployment image of it to distribute it to other devices

Stop the filesystem and force it to read only access:

 echo u > /proc/sysrq-trigger

CASE I: Transferring the image over ssh to host PC:

dd if=/dev/mmcblk0p1 | ssh user@hostpc dd of=/data/image.raw 

Transferring the image over ssh from host PC to Jetson:

ssh user@server dd if=/data/image.raw | dd of=/dev/mmcblk0p1 status=progress

CASE II: Transferring the image over netcat to host PC: Host PC

netcat -l -p <port> > your_image_file

Jetson:

 sudo dd if=/dev/mmcblk0p1 | netcat <ip_address> <port>

CASE III: preparation of distribution image

cd /home/nvidia/Downloads/Xavier/Linux_for_Tegra/bootloader/ && sudo ./mksparse -v --fillpattern=0 /data/image.raw system.img

and deployment of an image to another device via usb cable

cd /home/nvidia/Downloads/Xavier/Linux_for_Tegra/  && sudo ./flash.sh -r jetson-xavier mmcblk0p1

Adding web chat feature for onboard camera

sudo su
cd /usr/src/linux-headers-4.9.140-tegra-ubuntu18.04_aarch64/kernel-4.9
## dropped in latter release##make modules_prepare
mkdir v4l2loopback
git clone https://github.com/umlaeute/v4l2loopback.git v4l2loopback
cd v4l2loopback && git checkout -b v0.10.0
make
## if the sequence above fails - adopt the line: make -C /lib/modules/4.9.140-tegra/build M=`$pwd` modules
## make -C /lib/modules/`uname -r`-tegra/build M=/usr/src/v4l2loopback modules_install

make install
apt-get install -y v4l2loopback-dkms v4l2loopback-utils
modprobe v4l2loopback devices=1 video_nr=2 exclusive_caps=1
echo options v4l2loopback devices=1 video_nr=2 exclusive_caps=1 > /etc/modprobe.d/v4l2loopback.conf
echo v4l2loopback > /etc/modules
update-initramfs -u

TERMINAL 1:

gst-launch-1.0 -v nvarguscamerasrc ! 'video/x-raw(memory:NVMM), format=NV12, width=1920, height=1080, framerate=30/1' ! nvvidconv ! 'video/x-raw, width=640, height=480, format=I420, framerate=30/1' ! videoconvert ! identity drop-allocation=1 ! 'video/x-raw, width=640, height=480, format=RGB, framerate=30/1' ! v4l2sink device=/dev/video2

TERMINAL 2:

export DISPLAY=:0
chromium-browser

Otherwise, you may check that the output is played either with A:

 vlc v4l2:///dev/video2

or B:

gst-launch-1.0 v4l2src device=/dev/video2 ! 'video/x-raw, format=RGB, width=640, height=480, framerate=30/1' ! queue ! videoconvert ! xvimagesink

Network streaming for onboard CSI and ZED cameras

CSI camera streaming:

sudo apt-get install libgstrtspserver-1.0 libgstreamer1.0-dev
wget https://gstreamer.freedesktop.org/src/gst-rtsp/gst-rtsp-server-1.14.1.tar.xz
tar -xvf gst-rtsp-server-1.14.1.tar.xz
cd  gst-rtsp-server-1.14.1
cd examples
gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
#./test-launch "nvarguscamerasrc ! video/x-raw(memory:NVMM), format=NV12, width=1920, height=1080, framerate=30/1 ! nvvidconv #! video/x-raw, width=640, height=480, format=NV12, framerate=30/1 ! omxh265enc ! rtph265pay name=pay0 pt=96 config-#interval=1"
./test-launch "nvarguscamerasrc ! video/x-raw(memory:NVMM), format=NV12, width=1280, height=720, framerate=120/1 ! omxh265enc ! rtph265pay name=pay0 pt=96 config-interval=1"

NB! In Jetpack 4.3 pipelines changed to

./test-launch "nvarguscamerasrc ! video/x-raw(memory:NVMM), format=NV12, width=1920, height=1080, framerate=30/1 ! nvvidconv ! video/x-raw(memory:NVMM), width=640, height=480, format=NV12, framerate=30/1 ! omxh265enc ! rtph265pay name=pay0 pt=96 config-interval=1"

And to play it:

  • NB! Adding display-id=2 as in nvoverlaysink display-id=2 will redirect output to USB-C display
gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test ! queue ! decodebin ! nvoverlaysink
gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test ! queue ! rtph265depay ! h265parse ! nvv4l2decoder ! nvoverlaysink

Another computer in the network:

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test ! queue ! decodebin ! videoconvert ! xvimagesink

For VLC

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test ! queue ! decodebin ! videoconvert ! v4l2sink device=/dev/video1

ZED camera streaming:

./test-launch "v4l2src device=/dev/video1 ! video/x-raw,format=YUY2 ! nvvidconv ! video/x-raw(memory:NVMM),width=2560,height=720,format=I420 ! omxh265enc ! rtph265pay name=pay0 pt=96"

Vlc reading

vlc rtsp://server_ip_address:8554/test

Recording an event with onboard CSI camera

Video only:

gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=2592, height=1944, format=NV12, framerate=30/1' ! omxh264enc ! 'video/x-h264,stream-format=byte-stream' ! filesink location="test2.h264" -e

With audio:

gst-launch-1.0 -e nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080,format=NV12,framerate=30/1' ! omxh264enc ! 'video/x-h264,stream-format=byte-stream' ! h264parse ! queue ! muxer.video_0 alsasrc device="hw:2,0" ! voaacenc ! queue ! muxer.audio_0 qtmux name=muxer ! filesink location=test.mov

Make a single shoot

gst-launch-1.0 nvarguscamerasrc num-buffers=1 ! 'video/x-raw(memory:NVMM), width=(int)2592, height=(int)1944' ! nvvidconv ! jpegenc ! filesink location=camerashot.jpg

Restart USB-A port on Xavier

root@nvidia-desktop:/sys/class/regulator/regulator.13# echo disabled > state 
root@nvidia-desktop:/sys/class/regulator/regulator.13# echo enabled > state

Building a module natively and adding it without reflashing

wget https://developer.download.nvidia.com/embedded/L4T/r32_Release_v4.3/sources/T186/public_sources.tbz2
 tar -xjf public_sources.tbz2 
cd Linux_for_Tegra/ 
cd source/ 
cd public/ 
tar -xjf kernel_src.tbz2 
mkdir ~/out 
TEGRA_KERNEL_OUT=~/out 
cd kernel/ 
cd kernel-4.9/
 make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig 
nano Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig
 #here i sth eplace for adding a line like modulename=m ## 
make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j 6 KERNEL_MODULES_OUT=~/out/modules
 sudo make modules_install ARCH=arm64 O=$TEGRA_KERNEL_OUT INSTALL_MOD_PATH=$KERNEL_MODULES_OUT