IMX CSI: Difference between revisions

From Variscite Wiki
(Add install utils)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{PageHeader|VAR-SOM-MX7 - Camera}} {{DocImage|category1=VAR-SOM-MX7|category2=Yocto}} __toc__
<!-- Set release according to "release" parameter in URL and use RELEASE_DUNFELL_V1.0_VAR-SOM-MX7 as default
--> {{INIT_RELEASE_PARAM|RELEASE_DUNFELL_V1.0_VAR-SOM-MX7}}<!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{PageHeader|VAR-SOM-MX7 - Camera}} {{DocImage|category1=Debian|category2=Yocto}} [[category:VAR-SOM-MX7]] __toc__
<!-- Set local variables
-->{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:VIDEOSRC|imxv4l2src}}<!--
-->{{#vardefine:VIDEOSINK|imxv4l2sink}}<!--
-->|<!--
-->{{#vardefine:VIDEOSRC|imxv4l2videosrc}}<!--
-->{{#vardefine:VIDEOSINK|imxpxpvideosink}}<!--
-->}}
= Testing our MIPI cameras =
= Testing our MIPI cameras =


Before you start any of below pipeline make sure you have camera connected. IMX family of processor uses gstreamer as multimedia framework.
{{#varexists:DEBIAN_NAME|
Please refer to https://gstreamer.freedesktop.org/
== Install Utils ==
Run the following command to install v4l-utils:
# apt-get clean; apt-get update; apt-get install -y v4l-utils
}}


== Camera Probe ==
== Camera probe ==
 
Make sure the camera is connected, and boot the board.<br>
Run below command to see if you have got the camera detected
Then, run the below command to verify the camera was detected successfully:
  # v4l2-ctl --list-devices
  # v4l2-ctl --list-devices


Line 17: Line 33:
pxp (pxp_v4l2_out):
pxp (pxp_v4l2_out):
         /dev/video0
         /dev/video0
</pre>
</pre>
As you can see above i.MX6S_CSI (platform:30710000.csi): is camera and pxp (pxp_v4l2_out): pixel procesing engine for overlay on display
In the output seen above, "i.MX6S_CSI" is the camera, and "pxp" is the i.MX Pixel Processing Pipeline.


== i.MX platform specific gstreamer plugins ==
== i.MX platform specific gstreamer plugins ==
Run below command to verify you have the i.MX7 platform specific gstreamer plugins installed on your system:
Run below command to verify you have the i.MX7 platform specific gstreamer plugins installed on your system:


<pre>
# gst-inspect-1.0 | grep "imx"
# gst-inspect-1.0 | grep "imx"
{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |
imxpxp:  imxpxpvideotransform: Freescale PxP video transform
imxcompositor:  imxcompositor_pxp: IMX pxp Video Compositor
imxpxp:  imxpxpvideosink: Freescale PxP video sink
imxmp3enc:  imxmp3enc: imx mp3 audio encoder
imxv4l2videosrc:  imxv4l2videosrc: V4L2 CSI Video Source
imxv4l2:  imxv4l2sink: IMX Video (video4linux2) Sink
imxaudio:  imxmp3audioenc: Freescale i.MX MP3 encoder
imxv4l2:  imxv4l2src: IMX Video (video4linux2) Source
imxaudio:  imxuniaudiodec: Freescale i.MX uniaudio decoder
imxvideoconvert:  imxvideoconvert_pxp: IMX pxp Video Converter
</pre>
|
imxpxp:  imxpxpvideotransform: Freescale PxP video transform
imxpxp:  imxpxpvideosink: Freescale PxP video sink
imxv4l2videosrc:  imxv4l2videosrc: V4L2 CSI Video Source
imxaudio:  imxmp3audioenc: Freescale i.MX MP3 encoder
imxaudio:  imxuniaudiodec: Freescale i.MX uniaudio decoder
}}


== Gstreamer example 1: Testing Camera Loopback / Camera preview on the display ==
== Gstreamer example 1: Testing Camera Loopback / Camera preview on the display ==
Line 37: Line 58:
The below pipelines are suitable for the fslc based Yocto releases for the VAR-SOM-MX7 (Yocto Morty and newer).  
The below pipelines are suitable for the fslc based Yocto releases for the VAR-SOM-MX7 (Yocto Morty and newer).  


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=640,height=480}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=0}}<!--
-->}}
* For 640x480@30fps:
* For 640x480@30fps:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=0 ! imxpxpvideosink
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 {{#var:CAPS}} ! {{#var:VIDEOSINK}}


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=720,height=480}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=1}}<!--
-->}}
* For 720x480@30fps:
* For 720x480@30fps:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=1 ! imxpxpvideosink
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 {{#var:CAPS}} ! {{#var:VIDEOSINK}}


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=1280,height=720}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=2}}<!--
-->}}
* For 1280x720@30fps :
* For 1280x720@30fps :
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=2 ! imxpxpvideosink
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 {{#var:CAPS}} ! {{#var:VIDEOSINK}}


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=1920,height=1080}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=3}}<!--
-->}}
* For 1920x1080@30fps:
* For 1920x1080@30fps:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=3 ! imxpxpvideosink
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 {{#var:CAPS}} ! {{#var:VIDEOSINK}}


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=2592,height=1944}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=4}}<!--
-->}}
* For 2592x1944@15fps:
* For 2592x1944@15fps:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=4 ! imxpxpvideosink
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 {{#var:CAPS}} ! {{#var:VIDEOSINK}}


== Gstreamer example 2: Taking a JPEG snapshot from the camera ==
== Gstreamer example 2: Taking a JPEG snapshot from the camera ==
To capture and encode a JPEG snapshot from the camera, run one of the below pipelines depending on the wanted resolution:
To capture and encode a JPEG snapshot from the camera, run one of the below pipelines depending on the wanted resolution:


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=640,height=480}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=0 ! 'video/x-raw,format=UYVY'}}<!--
-->}}
* For 640x480:
* For 640x480:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=0 num-buffers=1 ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 num-buffers=1 {{#var:CAPS}} ! jpegenc ! filesink location=/tmp/test.jpg


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=720,height=480}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=1 ! 'video/x-raw,format=UYVY'}}<!--
-->}}
* For 720x480:
* For 720x480:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=1 num-buffers=1 ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 num-buffers=1 {{#var:CAPS}} ! jpegenc ! filesink location=/tmp/test.jpg


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=1280,height=720}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=2 ! 'video/x-raw,format=UYVY'}}<!--
-->}}
* For 1280x720:
* For 1280x720:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=2 num-buffers=1 ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 num-buffers=1 {{#var:CAPS}} ! jpegenc ! filesink location=/tmp/test.jpg


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=1920,height=1080}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=3 ! 'video/x-raw,format=UYVY'}}<!--
-->}}
* For 1920x1080:
* For 1920x1080:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=3 num-buffers=1 ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 num-buffers=1 {{#var:CAPS}} ! jpegenc ! filesink location=/tmp/test.jpg


{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin |<!--
-->{{#vardefine:CAPS|! video/x-raw,width=2592,height=1944}}<!--
-->|<!--
-->{{#vardefine:CAPS|imx-capture-mode=4 ! 'video/x-raw,format=UYVY'}}<!--
-->}}
* For 2592x1944:
* For 2592x1944:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=4 num-buffers=1 ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 {{#var:VIDEOSRC}} device=/dev/video1 num-buffers=1 {{#var:CAPS}} ! jpegenc ! filesink location=/tmp/test.jpg
 
= References =
* The GStreamer [https://gstreamer.freedesktop.org/ website]
{{#ifeq: {{#var:GSTREAMER_PLUGIN}} | imx-gst1.0-plugin | |
* The gstreamer-imx [https://github.com/Freescale/gstreamer-imx/blob/master/README.md README]
* The gstreamer-imx [https://github.com/Freescale/gstreamer-imx/blob/master/docs/faq.md FAQ]
}}

Latest revision as of 18:50, 6 June 2023

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release RELEASE_DUNFELL_V1.0_VAR-SOM-MX7.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
VAR-SOM-MX7 - Camera

Testing our MIPI cameras

Camera probe

Make sure the camera is connected, and boot the board.
Then, run the below command to verify the camera was detected successfully:

# v4l2-ctl --list-devices

This should output below

i.MX6S_CSI (platform:30710000.csi):
        /dev/video1

pxp (pxp_v4l2_out):
        /dev/video0

In the output seen above, "i.MX6S_CSI" is the camera, and "pxp" is the i.MX Pixel Processing Pipeline.

i.MX platform specific gstreamer plugins

Run below command to verify you have the i.MX7 platform specific gstreamer plugins installed on your system:

# gst-inspect-1.0 | grep "imx"
imxpxp:  imxpxpvideotransform: Freescale PxP video transform
imxpxp:  imxpxpvideosink: Freescale PxP video sink
imxv4l2videosrc:  imxv4l2videosrc: V4L2 CSI Video Source
imxaudio:  imxmp3audioenc: Freescale i.MX MP3 encoder
imxaudio:  imxuniaudiodec: Freescale i.MX uniaudio decoder

Gstreamer example 1: Testing Camera Loopback / Camera preview on the display

The below pipelines are suitable for the fslc based Yocto releases for the VAR-SOM-MX7 (Yocto Morty and newer).


  • For 640x480@30fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=0 ! imxpxpvideosink


  • For 720x480@30fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=1 ! imxpxpvideosink


  • For 1280x720@30fps :
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=2 ! imxpxpvideosink


  • For 1920x1080@30fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=3 ! imxpxpvideosink


  • For 2592x1944@15fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 imx-capture-mode=4 ! imxpxpvideosink

Gstreamer example 2: Taking a JPEG snapshot from the camera

To capture and encode a JPEG snapshot from the camera, run one of the below pipelines depending on the wanted resolution:


  • For 640x480:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 num-buffers=1 imx-capture-mode=0 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg


  • For 720x480:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 num-buffers=1 imx-capture-mode=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg


  • For 1280x720:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 num-buffers=1 imx-capture-mode=2 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg


  • For 1920x1080:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 num-buffers=1 imx-capture-mode=3 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg


  • For 2592x1944:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 num-buffers=1 imx-capture-mode=4 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg

References