I need help regarding crop and pip using two cameras at the USB ports

I’m going to install the nano and two cameras at a multicopter, a vis-camera like the Gopro and a thermal camera, see photo. I will report in jetson projects.
The streaming via two HDMI-USB3 adapters from /dev/video0 and 1 works fine and very fast. However there is a black frame around the thermal image, see the screenshot. I would like remove the boarder and tried to crop the video.
This command line for instance works fine to get the images:

$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=1280,height=720 ! xvimagesink

This crop test works too:

gst-launch-1.0 -v videotestsrc ! videocrop top=10 left=10 right=10 bottom=10 ! ximagesink

However my video crop does not work.

$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/xraw,framerate=30/1,width=1280,height=720 ! videocrop top=10 left=10 right=10 bottom=10 ! xvimagesink

What is the mistake?
Are there other/better solutions to remove the boarder?
Is nvvidconv a better choise?

The best solution would be a PIP presentation (picture in picture). Does someone have a gstreamer command line for me, which displays two USB cams simultaneously?

Thank you in advance,
Best regards,
Wilhelm


Maybe this typo?

gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/<b>x-raw</b>,framerate=30/1,width=1280,height=720 ! videocrop top=10 left=10 right=10 bottom=10 ! xvimagesink

Honey_Patouceul, thank you.
The typo is only in my post. Sorry!
I made 2 new screenshots (without internet connection and the time is wrong).
The crop basically works, but there is no (thermal)image, only a green screen.
Best regards,
Wilhelm


Regarding crop I found a solution with nv-plugins.

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=1280,hight=720 ! videocrop top=4 bottom=400 left=4 right=800 ! nvvidconv ! nvegltransform ! nveglglessink -e

Best regards,
Wilhelm

Glad to see you’ve got further. It’s hard to give the right command because I don’t know your camera and you give no format in caps, so it may be a bad format output from videocrop, so you may try to add videoconvert after it. It might be slow for high resolutions/framerates, however.

Since you’re already using nvvidconv, you can do the cropping with ISP. The thing is that the parameters are not the margins, but the X or Y coordinates. For top and left it is the same as videocrop, but you would set: right = width - rightMargin and bottom = height - bottomMargin, so for your case:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=1280,height=720 ! nvvidconv top=4 bottom=320 left=4 right=480 ! nvegltransform ! nveglglessink -e

#Or use a second nvvidconv for copying to CPU memory if needed:
gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=1280,height=720 ! nvvidconv top=4 bottom=320 left=4 right=480 ! nvvidconv ! xvimagesink

Honey_Patouceul, thank you very much.
I’m new to gstreamer. What do mean with “you give no format in caps”
The camera was in this case a Gopro with 1920x1080 pixel. I think “width=1280,height=720” are the output pixel.
Your first line works fine, the second with the “xvimagesink” does not.
I will take your first line for further experiments. Now I try to combine two lines with two cameras for PIP.
Best regard
Wilhelm

I mean that you may have caps like: ‘video/x-raw,framerate=30/1,width=1280,height=720,format=YUY2

You may get your camera supported modes with:

#v4l2-ctl command is provided by apt package v4l-utils, you may install it with:
sudo apt-get update
sudo apt-get install v4l-utils

#Now, get your camera formats/resolutions/framerates with:
v4l2-ctl -d /dev/video0 --list-formats-ext

Pick a supported format/resolution/framerate, or post the output of this command for further advice.

You may also try to specify I420 format as output of nvvidconv, it is supported by xvimagesink:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=1280,height=720 ! nvvidconv top=4 bottom=320 left=4 right=480 ! nvvidconv ! <b>video/x-raw,format=I420</b> ! xvimagesink

Hello Honey_Patouceul, your line with video/x-raw,format=I420 did not work. I have tested YUY2 too but without success.

Will nveglglessink make problems for PIP / mix?

Best regards,
Wilhelm

willi@willis:~$  v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'YUYV'
        Name        : YUYV 4:2:2
                Size: Discrete 1920x1080
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 800x600
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1024x768
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x960
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x1024
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1360x768
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1400x900
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1440x900
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)

willi@willis:~$

I’d suggest to crop to 640x480 for now:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,framerate=30/1,width=1280,height=720 ! nvvidconv top=4 bottom=484 left=4 right=644 ! 'video/x-raw(memory:NVMM),format=I420, width=640,height=480' ! nvvidconv ! video/x-raw,format=I420 ! xvimagesink

Does it work ? (you may also try NV12 instead of I420 on recent L4T releases).

Honey_Patouceul, thank you again,
but that is not what I’m looking for. The margins above are only for test purpose. I want to cut to any size, not to a fixed video format, see picture.
So I’m using this line…

gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,framerate=30/1,width=800,hight=600 ! videocrop top=40 bottom=40 left=110 right=110 ! nvvidconv ! nvegltransform ! nveglglessink –e

and will try to combine two lines with two cameras for PIP (with transparency) later.
Best regards,
Wilhelm

Since a few hours the overlay of two videofeeds with transparency works.
Thank you all together for your help.
The full screen image is from a Sony RX0, the thermal camera is a Flir Vue. The alignment is not perfect at the moment.
The picture in the left bottom corner is from the r-pi V2 camera started as an extra task. This camera is very light sensitive (compared with the Sony).
Best regards,
Wilhelm