Why is image/jpeg poor quality compared to video/x-raw?


I’m using a USB camera to check the video in both image/jpeg and video/x-raw.
※ Information about the USB camera can be found under the case.

Comparing the photos attached below, video/x-raw looks clearer.
What is the reason for this?
Also, when I move my hand in front of the camera, the video/x-raw reacts in real time and the image/jpeg has a delay.
Please tell me the reason for this.

Here is my Jetpack information.

  $ cat /etc/nv_tegra_release
  # R35 (release), REVISION: 1.0, GCID: 31346300, BOARD: t186ref, EABI: aarch64, DATE: Thu Aug 25 18:41:45 UTC 2022

The image is the code obtained with image/jpeg.

cap = cv2.VideoCapture ('v4l2src device=/dev/video0 io-mode=2 ! image/jpeg, width= 640, height= 480, framerate=61612/513 ! nvv4l2decoder mjpeg=1 ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink', cv2.CAP_GSTREAMER)


The image is the code obtained with video/x-raw.

cap = cv2.VideoCapture('v4l2src device=/dev/video0 io-mode=2 ! video/x-raw, width=640, height=480, framerate=30/1 ! videoconvert ! video/x-raw,format=BGR ! appsink', cv2.CAP_GSTREAMER)


Device found:

        name  : HD USB Camera: HD USB Camera
        class : Video/Source
        caps  : video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)6/1;
                video/x-raw, format=(string)YUY2, width=(int)1280, height=(int)1024, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)6/1;
                video/x-raw, format=(string)YUY2, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)9/1;
                video/x-raw, format=(string)YUY2, width=(int)1024, height=(int)768, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)6/1;
                video/x-raw, format=(string)YUY2, width=(int)800, height=(int)600, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)20/1;
                video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1;
                video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1;
                image/jpeg, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1;
                image/jpeg, width=(int)1280, height=(int)1024, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1;
                image/jpeg, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1;
                image/jpeg, width=(int)1024, height=(int)768, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1;
                image/jpeg, width=(int)800, height=(int)600, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1;
                image/jpeg, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)61612/513;
                image/jpeg, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)61612/513;
                udev-probed = true
                device.bus_path = platform-3610000.xhci-usb-0:4.1:1.0
                sysfs.path = /sys/devices/platform/3610000.xhci/usb1/1-4/1-4.1/1-4.1:1.0/video4linux/video0
                device.bus = usb
                device.subsystem = video4linux
                device.vendor.id = 32e4
                device.vendor.name = "HD\\x20USB\\x20Camera"
                device.product.id = 9230
                device.product.name = "HD\ USB\ Camera:\ HD\ USB\ Camera"
                device.serial = HD_USB_Camera_HD_USB_Camera
                device.capabilities = :capture:
                device.api = v4l2
                device.path = /dev/video0
                v4l2.device.driver = uvcvideo
                v4l2.device.card = "HD\ USB\ Camera:\ HD\ USB\ Camera"
                v4l2.device.bus_info = usb-3610000.xhci-4.1
                v4l2.device.version = 330344 (0x00050a68)
                v4l2.device.capabilities = 2225078273 (0x84a00001)
                v4l2.device.device_caps = 69206017 (0x04200001)
        gst-launch-1.0 v4l2src ! ...

It looks like the source has different video quality for JPEG and YUYV formats. You may dump the JPEGs for check:

$ gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 num-buffers=50 ! image/jpeg, width= 640, height= 480, framerate=61612/513 ! multifilesink location=dump_%03d.jpg


Thank you.
I got the images dump_000.jpd~dump_049.jpg by entering the command you advised me.
Attach dump_000.jpg as a representative.

The image quality I get with this command is also bad.
Is there any way to improve the image quality?


Please check with camera vendor and see if there is properties you can set up and get better quality. Or can use YUYV format.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.