XUELK-AN-007: USB Camera input on i.MX6UL-based platforms

From DAVE Developer's Wiki
Revision as of 15:23, 5 July 2017 by U0007 (talk | contribs) (Created page with "{{InfoBoxTop}} {{AppliesToAXELULite}} {{AppliesToSBCLynx}} {{InfoBoxBottom}} == History == {| class="wikitable" border="1" !Version !Date !Notes |- |1.0.0 |Jul 2017 |First rel...")

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Info Box
AXEL ULite-top.png Applies to AXEL ULite
SBC Lynx-top.png Applies to SBC Lynx

History[edit | edit source]

Version Date Notes
1.0.0 Jul 2017 First release

Introduction[edit | edit source]

As known, i.MX6UL SoC has not an IPU cell allowing strong performances on video acquisition. However, using an USB camera it is possible to capture a raw data video playing it on LCD controller.

This application note describes some tests that were performed on an AXELULite-based platform to evaluate the capabilities and the performances of the i.MXUL when it captures and displays a camera source on LCD panel. The test bed was based on Yocto distribution using smart package manager for adding required software component.

USB camera driver[edit | edit source]

Common USB cameras can be used with a standard USB Video Class driver. Linux kernel must be compiled with this driver built-in or the kernel module can be dynamically loaded (in this case it has to be available on /lib/modules root file system directory).

Once plugged on USB host connector, the kernel driver recognizes the device and create the device node /dev/video1

[    6.989549] uvcvideo: Found UVC 1.00 device USB2.0 Camera (1871:0141)
[    7.041576] input: USB2.0 Camera as /devices/soc0/soc.0/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb2/2-1/2-1:1.0/input/input5
[    7.138819] usbcore: registered new interface driver uvcvideo
[    7.191864] USB Video Class driver (1.1.1)
[    7.439394] usb_audio: Warning! Unlikely big volume range (=6144), cval->res is probably wrong.
[    7.489486] usb_audio: [3] FU [Mic Capture Volume] ch = 1, val = 5120/11264/1[    7.546073] usbcore: registered new interface driver snd-usb-audio

gstreamer[edit | edit source]

Starting from original Yocto based root file system provided here, more packages need to be added for using the well known multimedia framework gstreamer

More info about gstreamer can be found here and on Github gstreamer server


We assume that network interface has been already configured for Internet access. In any case, simple configuration can be done directly on serial console with the following commands:

root@sbc-lynx:~# ifconfig eth0 192.168.0.94
root@sbc-lynx:~# route add default gw 192.168.0.254
root@sbc-lynx:~# echo "nameserver 8.8.8.8" > /etc/resolv.conf

where 192.168.0.254 is the gateway address and 8.8.8.8 is the DNS server (in this case Google's one).

smart packages[edit | edit source]

Firts of all, SMART channels must be added for accessing DAVE's server for Yocto pre-built packages, using the following commands:

root@sbc-lynx:~# smart channel --add cortexa7hf_vfp_neon type=rpm-md baseurl=http://yocto.dave.eu/xuelk-latest/cortexa7hf_vfp_neon
root@sbc-lynx:~# smart channel --add cortexa7hf_vfp_neon_mx6ul type=rpm-md baseurl=http://yocto.dave.eu/xuelk-latest/cortexa7hf_vfp_neon_mx6ul
root@sbc-lynx:~# smart channel --add sbc_lynx type=rpm-md baseurl=http://yocto.dave.eu/xuelk-latest/sbc_lynx

and finally updating the smart cache checking for the new available packages:

root@sbc-lynx:~# smart update


Adding gstreamer packages[edit | edit source]

It is possibile to install the gstreamer 1.0 tool using the following command:

root@sbc-lynx:~# smart install gstreamer1.0-1.4.5-r0
...
...

as it's shown on installation log, smart asks for installing xxx MB of additional packages.

Then, it is enough to install the other gstreamer plugins, for example:

gstreamer1.0-plugins-good-1.4.5-r0
gstreamer1.0-plugins-base-1.4.5-r0
gstreamer1.0-plugins-bad-1.4.5-r0

gstreamer pipeline[edit | edit source]

The pipeline used is the easiest one for capturing a raw data stream from a standard USB camera

gst-launch-1.0 -v v4l2src device=/dev/video1 ! imxv4l2sink

Test bed[edit | edit source]

  • iMX6UL cpu is running at 528MHz
root@arm:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
528000
  • system DRAM is 256MB
  • lcd panel is 800x480

Results[edit | edit source]

Use case #1: Video capture 640x480@30fps[edit | edit source]

  • pipeline:
gst-launch-1.0 -v v4l2src device=/dev/video1 ! 'video/x-raw, format=YUY2, width=640, height=480, framerate=30/1' ! imxv4l2sink force-aspect-ratio=true
  • top process shows that cpu is running at 20%
Mem: 81752K used, 165412K free, 356K shrd, 9084K buff, 18600K cached
CPU:   2% usr  13% sys   0% nic  64% idle   0% io   0% irq  19% sirq
Load average: 0.13 0.09 0.05 1/64 452
  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
  432   386 root     S    35364  14%  22% gst-launch-1.0 -v v4l2src device=/dev/
  447   386 root     R     2828   1%   2% top -d 1
   71     2 root     SW       0   0%   1% [pxp_dispatch]
    3     2 root     SW       0   0%   1% [ksoftirqd/0]
  382     1 root     S     5028   2%   0% /usr/sbin/tcf-agent -d -L- -l0
...

Use case #2: Video capture 640x480@30fps scaled to 320x240[edit | edit source]

This use case is similar to the previous one, but the video data has been scaled to 1/4 using the imxv4l2sink plugin overlay capabilities

gst-launch-1.0 -v v4l2src device=/dev/video1 ! 'video/x-raw, format=YUY2, width=320, height=240, framerate=30/1' ! imxv4l2sink overlay-top=120 overlay-left=240 overlay-width=320 overlay-height=240 force-aspect-ratio=true

Use case #3: Video capture 640x480@30fps with rotation[edit | edit source]

In this use case the PXP iMX6UL hardware cell is performing an image rotation on the screen using the imxvideoconvert_pxp NXP gstreamer plugin

gst-launch-1.0 -v v4l2src device=/dev/video1 ! capsfilter caps="video/x-raw, width=640, height=480, framerate=30/1" ! imxvideoconvert_pxp rotation=1 ! imxv4l2sink force-aspect-ratio=true