USB Camera Support

Hello Team Toradex,
I have one USB 3.0 camera connect with my device imx8mp than I have start testing for the image with following command.
v4l2-ctl --device=/dev/video4 --stream-mmap=3 --stream-to=rv.jpg --stream-count=1 but it will show my image size only 600k output indicates that the file capture.jpg now has a size of 600 KB, meaning it contains data and is not empty. so can you support me how to test successfully this process?

Regards,
Ravi Vanand

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello Ravi,

Thank you for reaching out to us. It seems you are using the v4l2-ctl command to capture an image from your USB 3.0 camera connected to the iMX8MP device. The image size being only 600 KB could be due to several factors, such as the resolution or format settings of the camera.

Here are some steps to help you troubleshoot and potentially resolve this issue:

  1. Check Supported Formats and Resolutions:
    Use the following command to list the supported formats and resolutions of your camera:

    v4l2-ctl --device=/dev/video4 --list-formats-ext
    

    This will show you the available pixel formats and frame sizes. Ensure you are capturing at the desired resolution.

  2. Adjust Capture Settings:
    If the resolution is lower than expected, you can specify a higher resolution using the --set-fmt-video option. For example:

    v4l2-ctl --device=/dev/video4 --set-fmt-video=width=1920,height=1080,pixelformat=YUYV
    

    Replace 1920x1080 and YUYV with your desired resolution and format.

  3. Capture Image Again:
    After setting the desired format and resolution, try capturing the image again with:

    v4l2-ctl --device=/dev/video4 --stream-mmap=3 --stream-to=rv.jpg --stream-count=1
    
  4. Consider Using GStreamer:
    If you need more control over the capture process, consider using GStreamer, which provides a flexible framework for handling video streams. A simple GStreamer pipeline to capture an image might look like this:

    gst-launch-1.0 v4l2src device=/dev/video4 ! videoconvert ! jpegenc ! filesink location=rv.jpg
    

By following these steps, you should be able to adjust the capture settings to achieve the desired image size and quality. If you continue to experience issues, ensure that your camera is functioning correctly and that the necessary drivers are installed.

Best regards,

Toradex AI Assistant

Please, also check if these links can help you solve your problem:

NXP i.MX 8M Plus - Verdin System on Module.

file capture_mjpg.jpg
i get the below result after applying above command
capture_mjpg.jpg: JPEG image data, baseline, precision 8, 640x480, components 3
now how to show the image on toradex display

hello team toradex ,
can you provide a support for the above issue or not?

Video Processing - GStreamer | Toradex Developer Center the above given document i have followed but the given command in that document did not work proper so can please tell me the right way

regards,
Ravi Vanand

Hello Ravi!

Sorry for the late reply.

Regarding your first question:

you might consider following steps 1 to 3 provided by the Toradex AI assistant. You will obtain a raw image, and then you should use ffmpeg (you will need to install this on your computer) to convert it to a real image. As an example:

ffmpeg -f rawvideo -pix_fmt yuyv422 -s 1920x1080 -i rv.jpg -frames:v 1 output.jpg

Finally, the real camera image is on the output.jpg file. This will allow you to check if the camera is working properly.

Regarding your question on how to show the images on Toradex displays, can you provide additional information on which display you are using exactly?

Best regards,

Marcio

hello @marcioalbano.tx ,
I am able to capture the image by following the steps 1 to 3, but after that i am not be able to use ffmeg commands i will try to install ffmeg but it should not work.

Display That i am using is the Toradex Display Capacitive Touch Display 10.1" LVDS | Toradex Developer Center

Regards,
Ravi Vanand

Hi Ravi,

Have you tried to install the ffmpeg package? On Ubuntu/Debian you can use sudo apt install ffmpeg , for example.

Regarding the display, I would assume that you followed all the steps described in this article. Could you please confirm this?

Best regards,

Marcio

Hello @marcioalbano.tx,
I have Tried to install ffmpeg package on ubuntu using sudo apt install ffmpeg but the command is not working in my scene because i am using ubuntu by connecting my card using ssh putty console.

and for the display i have followed the steps that you have mention in that article

Regards,
Ravi Vanand

Hello @marcioalbano.tx,

whenever i apply the command sudo apt install ffmpeg I Get the below Result

login as: torizon
torizon@192.168.0.137's password:

** WARNING **
THIS DEVICE IS IN ENGINEERING MODE

Check for more info:
https://developer.toradex.com/torizon/application-development/ide-extension

torizon@verdin-imx8mp-15132884:~$ ls
Dockerfile  digital_io_test.sh  imx8mp-verdin-wifi-atdm.dtb  test
Downloads   docker-compose.yml  index.html                   test.wav
adv7180.ko  gstreamer-docker    media-ctl-setup
dev2        home                setup
torizon@verdin-imx8mp-15132884:~$  sudo apt install ffmpeg
Password:
sudo: apt: command not found

Regards,
Ravi Vanand

Hello Ravi,

Checking the output from your console, you seem to be using Torizon. In this case, I suggest you take a look at this article that contains instructions on how to use cameras in Torizon. You can also find more information on how to use Gstreamer on Torizon in here. You will also information on how to use Displays with Torizon in here.

Best Regards,

Marcio

Hello @marcioalbano.tx,
I have followed all above article that you have mentioned but i get the below result

torizon@verdin-imx8mp-15132884:~$ docker stop $(docker ps -a -q)
8fe019f0b8d7
ad3a5c427d16
db0a5031da25
d0e35fe15e70
112f0232939e
250cdba17d06
c9737d4a8513
4de0e68a02a1
7aa3248743b7
32f1384315af
5a28341e8970
69e37caf3823
b38ca9bdcd74
64a75ce42d44
8c9a39c9b52f
3052b71c7900
e733dee378a9
c4562d49710e
fbea50aba622
torizon@verdin-imx8mp-15132884:~$ ls /dev/video*
/dev/video0  /dev/video1  /dev/video2  /dev/video3  /dev/video4
torizon@verdin-imx8mp-15132884:~$ ocker run --rm -it -v /tmp:/tmp -v /var/run/db                                                                  us:/var/run/dbus -v /dev:/dev -v /sys:/sys \
> ^C
torizon@verdin-imx8mp-15132884:~$ ocker run --rm -it -v /tmp:/tmp -v /var/run/db                                                                  us:/var/run/dbus -v /dev:/dev -v /sys:/sys
-sh: ocker: command not found
torizon@verdin-imx8mp-15132884:~$ docker run --rm -it -v /tmp:/tmp -v /var/run/d                                                                  bus:/var/run/dbus -v /dev:/dev -v /sys:/sys \
>     --device /dev/video0 --device /dev/video1 --device /dev/video2 --device /d                                                                  ev/video3 --device /dev/video12 --device /dev/video13 \
docker: invalid reference format.
See 'docker run --help'.
torizon@verdin-imx8mp-15132884:~$     --device-cgroup-rule='c 226:* rmw' --devic                                                                  e-cgroup-rule='c 199:* rmw' \
>     <your-dockerhub-username>/<Dockerfile-name>
-sh: syntax error near unexpected token `newline'
torizon@verdin-imx8mp-15132884:~$ v4l2-ctl --list-devices
mxc-isi-m2m (platform:32e00000.isi:m2m_devic):
        /dev/video2

UVC Camera (046d:0823) (usb-xhci-hcd.2.auto-1):
        /dev/video3
        /dev/video4
        /dev/media0

Failed to open /dev/video0: Device or resource busy
torizon@verdin-imx8mp-15132884:~$ v4l2-ctl --device /dev/video3 -D
Driver Info:
        Driver name      : uvcvideo
        Card type        : UVC Camera (046d:0823)
        Bus info         : usb-xhci-hcd.2.auto-1
        Driver version   : 5.15.148
        Capabilities     : 0x84a00001
                Video Capture
                Metadata Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04200001
                Video Capture
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : uvcvideo
        Model            : UVC Camera (046d:0823)
        Serial           : B01E64C0
        Bus info         : usb-xhci-hcd.2.auto-1
        Media version    : 5.15.148
        Hardware revision: 0x00000010 (16)
        Driver version   : 5.15.148
Interface Info:
        ID               : 0x03000002
        Type             : V4L Video
Entity Info:
        ID               : 0x00000001 (1)
        Name             : UVC Camera (046d:0823)
        Function         : V4L2 I/O
        Flags            : default
        Pad 0x01000007   : 0: Sink
          Link 0x0200001c: from remote pad 0x100000a of entity 'Extension 4' (Vi                                                                  deo Pixel Formatter): Data, Enabled, Immutable
torizon@verdin-imx8mp-15132884:~$ gst-launch-1.0 <videosrc> ! <capsfilter> ! <vi                                                                  deosink>
-sh: syntax error near unexpected token `newline'
torizon@verdin-imx8mp-15132884:~$
torizon@verdin-imx8mp-15132884:~$ gst-launch-1.0 <videosrc> ! <capsfilter> ! <vi                                                                  deosink>
-sh: syntax error near unexpected token `newline'
torizon@verdin-imx8mp-15132884:~$ gst-launch-1.0 v4l2src device=</dev/video*> !                                                                   <capsfilter> ! fpsdisplaysink video-sink=waylandsink
-sh: /dev/video*: ambiguous redirect
torizon@verdin-imx8mp-15132884:~$
torizon@verdin-imx8mp-15132884:~$
torizon@verdin-imx8mp-15132884:~$ gst-launch-1.0 v4l2src device=</dev/video*> !                                                                   <capsfilter> ! fpsdisplaysink video-sink=waylandsink
-sh: /dev/video*: ambiguous redirect
torizon@verdin-imx8mp-15132884:~$

Regards,
Ravi Vanand

Hello Ravi,

Please notice that device=</dev/video*> is a generic example. Please replace /dev/video* with the device file of the camera that you want to use. In your case, I believe it should be /dev/video3 or /dev/video4 , which is shown by the output of the v4l2-ctl --list-devices command you used before.

Based on your last console output, you might want to test the following:

gst-launch-1.0 v4l2src device=/dev/video3 ! fpsdisplaysink video-sink=waylandsink

Best Regards,

Marcio

Hello @marcioalbano.tx,

/dev/video* instead of above command I am using /dev/video4 and based on the v4l2-ctl --list-devices command i have apply the gst-launch-1.0 v4l2src device=/dev/video3 ! fpsdisplaysink video-sink=waylandsink command but i don’t get the result

Regards,
Ravi Vanand

Hello @marcioalbano.tx,

i am getting the below result when i apply those commands
gst-launch-1.0 v4l2src device=/dev/video4 ! fp sdisplaysink video-sink=waylandsink
WARNING: erroneous pipeline: could not set property “video-sink” in element “fps displaysink0” to “waylandsink”

Regards,
Ravi Vanand

Hello @marcioalbano.tx,

Give the solution i am still waiting for your replay

Regards,
Ravi Vanand

Hello Ravi,

Can you confirm which TorizonOS version you are using? You can check this using sudo tdx-info. (Check the Distro version field).

I tested the following procedure using a TorizonOS 6.8.0 version on imx8mp module and it worked without any issues. On your Torizon OS image:

  1. start weston container
docker run -e ACCEPT_FSL_EULA=1 -d --rm --name=weston --net=host --cap-add CAP_SYS_TTY_CONFIG \
             -v /dev:/dev -v /tmp:/tmp -v /run/udev/:/run/udev/ \
             --device-cgroup-rule='c 4:* rmw' --device-cgroup-rule='c 13:* rmw' \
             --device-cgroup-rule='c 199:* rmw' --device-cgroup-rule='c 226:* rmw' \
             torizon/weston-vivante:$CT_TAG_WESTON_VIVANTE --developer --tty=/dev/tty7
  1. Create a Dockerfile for gstreamer inside the board. You can get the Dockerfile in here

  2. Build and run the container from the dockerfile you just created.

docker build -t camera-test .
docker run --privileged -v /var/rootdirs/media:/media:z -v /tmp:/tmp -it  camera-test
  1. check the /dev/video device files that appear for your camera.
v4l2-ctl --list-devices
  1. Run gstreamer pipeline, using the correct device file (For this example notice that /dev/video2 is being used, but you should check if it applies for your case).
gst-launch-1.0 v4l2src device=/dev/video2 ! fpsdisplaysink video-sink=waylandsink

Best Regards,

Marcio

Hello @marcioalbano.tx,
i am using ID=torizon
NAME=“TorizonCore”
VERSION=“6.7.0-devel-20240821064044+build.0 (kirkstone)”
VERSION_ID=6.7.0-devel-20240821064044-build.0
PRETTY_NAME=“TorizonCore 6.7.0-devel-20240821064044+build.0 (kirkstone)”
DISTRO_CODENAME=“kirkstone”
BUILD_ID=“0”
ANSI_COLOR=“1;34”
VARIANT=“Docker”
regards,
Ravi Vanand

Hello @marcioalbano.tx,
I have followed your docker file link and same docker file i have created but it shouldn’t work and i have also followed process that you are showing in above chat but it will not work so that is why i am sharing the my OS details so give me solution according that

Best Regards,
Ravi Vanand