DART-MX8M CSI: Difference between revisions

From Variscite Wiki
(Created page with "{{PageHeader|DART-MX8M - Camera}} {{DocImage|category1=DART-MX8M|category2=Yocto}} __toc__ = Testing our MIPI cameras = Before you start any of below pipeline make sure you h...")
 
No edit summary
(42 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{PageHeader|DART-MX8M - Camera}} {{DocImage|category1=DART-MX8M|category2=Yocto}} __toc__
<!-- Set release according to "release" parameter in URL and use RELEASE_SUMO_V1.0_DART-MX8M as default
= Testing our MIPI cameras =
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release|RELEASE_SUMO_V1.0_DART-MX8M}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
!-- Set local variables
--> {{#vardefine:VIDEO_DEV | <!--
-->    {{#switch:{{#var:HARDWARE_NAME}} | <!--
-->      DART-MX8M = videoX | <!--
-->      DART-MX8M-PLUS = videoX | <!--
-->      VAR-SOM-MX8 = videoX | <!--
-->      video0 <!--
-->    }} <!--
--> }} <!--
--> {{#vardefine:VIDEO_DEV_STR | <!--
-->    {{#switch:{{#var:HARDWARE_NAME}} | <!--
-->      DART-MX8M = In the examples below /dev/videoX is either /dev/video0 or /dev/video1 | <!--
-->      DART-MX8M-PLUS = In the examples below /dev/videoX is either /dev/video1 or /dev/video2 | <!--
-->      VAR-SOM-MX8 = In the examples below /dev/videoX is either /dev/video0 or /dev/video1 | <!--
-->        <!--
-->    }} <!--
--> }} <!--
--> {{PageHeader|{{#var:HARDWARE_NAME}} Camera}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
= Testing MIPI-CSI2 cameras =


Before you start any of below pipeline make sure you have camera connected. IMX family of processor uses gstreamer as multimedia framework.
Before running any of the pipelines below make sure you have camera(s) connected. i.MX family of processors uses gstreamer as multimedia framework.
Please refer to https://gstreamer.freedesktop.org/
Please refer to https://gstreamer.freedesktop.org/


== Camera Probe ==
== Camera Probe ==


Run below command to see if you have got the camera detected
Run the following command to see if you have the camera(s) detected
  root@imx8m-var-dart:~# v4l2-ctl --list-devices
  # v4l2-ctl --list-devices


This should output below
This should produce the following output
{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M |
<pre>
<pre>
root@imx8m-var-dart:~# v4l2-ctl --list-devices
# v4l2-ctl --list-devices
i.MX6S_CSI (platform:30a90000.csi1_bridge):
i.MX6S_CSI (platform:30a90000.csi1_bridge):
        /dev/video0
      /dev/video0


i.MX6S_CSI (platform:30b80000.csi2_bridge):
i.MX6S_CSI (platform:30b80000.csi2_bridge):
      /dev/video1
</pre>
As you can see above there are 2 cameras accessible as /dev/video0 and /dev/video1
| {{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M-PLUS |
<pre>
ev ():
        /dev/v4l-subdev0
mxc-isi-cap (platform:32e00000.isi:cap_devic):
         /dev/video1
         /dev/video1
mxc-isi-m2m (platform:32e00000.isi:m2m_devic):
        /dev/video0
mxc-isi-cap (platform:32e02000.isi:cap_devic):
        /dev/video2
</pre>
As you can see above there are 2 cameras accessible as /dev/video1 and /dev/video2
|
<pre>
# v4l2-ctl --list-devices
i.MX6S_CSI (platform:32e20000.csi1_bridge):
      /dev/video0
</pre>
</pre>
As you can see above there are 2 cameras accessible as /dev/video0 and /dev/video1
As you can see above there is 1 camera accessible as /dev/video0
}}}}
 
== Testing Camera Preview on Display ==
{{#var:VIDEO_DEV_STR}}
 
{{#varexists:USE_KMSSINK |
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX8M-NANO |
* HD 720p 1280x720@30fps:
# gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! video/x-raw,width=1280,height=720 ! kmssink sync=false can-scale=false


== Testing Camera Loopback / Camera Preview on Display ==
* Full HD 1080p 1920x1080@30fps:
# gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! video/x-raw,width=1920,height=1080 ! kmssink sync=false can-scale=false
|
* NTSC 480p 720x480@30fps:
# gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! imxvideoconvert_g2d ! video/x-raw,width=720,height=480 ! kmssink sync=false can-scale=false


In the examples below /dev/videoX is either /dev/video0 or /dev/video1
* HD 720p 1280x720@30fps:
# gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! imxvideoconvert_g2d ! video/x-raw,width=1280,height=720 ! kmssink sync=false can-scale=false


* For 640x480@30fps:
* Full HD 1080p 1920x1080@30fps:
  root@imx8m-var-dart:~# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=640,height=480 ! kmssink
  # gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! imxvideoconvert_g2d ! video/x-raw,width=1920,height=1080 ! kmssink sync=false can-scale=false
}}
|
* VGA 480p 640x480@30fps:
# gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! video/x-raw,width=640,height=480 ! autovideosink sync=false


* NTSC 720x480@30fps:
* NTSC 480p 720x480@30fps:
  root@imx8m-var-dart:~# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=720,height=480 ! kmssink
  # gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! video/x-raw,width=720,height=480 ! autovideosink sync=false


* 720P 1280x720@30fps :
* HD 720p 1280x720@30fps:
  root@imx8m-var-dart:~# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=1280,height=720 ! kmssink
  # gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! video/x-raw,width=1280,height=720 ! autovideosink sync=false


* For 1080P@30fps:
* Full HD 1080p 1920x1080@30fps:
  root@imx8m-var-dart:~# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=1920,height=1080 ! kmssink
  # gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! video/x-raw,width=1920,height=1080 ! autovideosink sync=false
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX8M-NANO ||
* QSXGA 1944p 2592x1944@15fps:
# gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} ! video/x-raw,width=2592,height=1944 ! autovideosink sync=false
}}}}


* For QSXGA 2592x1944@15fps:
== Testing Camera JPEG Snapshot ==
root@imx8m-var-dart:~# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=2592,height=1944 ! kmssink


== Testing Camera JPEG Snapshot / Taking Single Picture ==
To capture JPEG snapshot run one of the pipelines below depending upon the required picture resolution.
To Capture JPEG snapshot run any of below pipeline depending upon the resolution you want to take picture.  


*For 640x480:
{{#var:VIDEO_DEV_STR}}
root@imx:~# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=0 num-buffers=1 ! jpegenc ! filesink location=/tmp/test.jpg


*NTSC 720x480:
* VGA 480p 640x480:
  root@imx:~# 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 v4l2src device=/dev/{{#var:VIDEO_DEV}} num-buffers=1 ! video/x-raw,width=640,height=480 ! jpegenc ! filesink location=/tmp/test_640x480.jpg


* 720P 1280x720:
* NTSC 480p 720x480:
  root@imx:~# 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 v4l2src device=/dev/{{#var:VIDEO_DEV}} num-buffers=1 ! video/x-raw,width=720,height=480 ! jpegenc ! filesink location=/tmp/test_720x480.jpg


* For 1080P:
* HD 720p 1280x720:
  root@imx:~# 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 v4l2src device=/dev/{{#var:VIDEO_DEV}} num-buffers=1 ! video/x-raw,width=1280,height=720 ! jpegenc ! filesink location=/tmp/test_1280x720.jpg


* For QSXGA 2592x1944:
* Full HD 1080p 1920x1080:
  root@imx:~# 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 v4l2src device=/dev/{{#var:VIDEO_DEV}} num-buffers=1 ! video/x-raw,width=1920,height=1080 ! jpegenc ! filesink location=/tmp/test_1920x1080.jpg
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX8M-NANO ||
* QSXGA 1944p 2592x1944:
  # gst-launch-1.0 v4l2src device=/dev/{{#var:VIDEO_DEV}} num-buffers=1 ! video/x-raw,width=2592,height=1944 ! jpegenc ! filesink location=/tmp/test_2592x1944.jpg
}}


{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M |
== Using both cameras simultaneously ==


'''Please note : jpegenc is opensource software based jpeg encoder. This gets executed on CPU not using JPEG hardware acceleration.
The following pipeline is an example of using both cameras simultaneously.<br>
To see your recently taken picture, transfer /tmp/test.jpg to your PC via scp or winscp and see whether you got correct snapshot or not.  
In this example a short video stream from each camera is saved as an MJPEG-encoded AVI file.


== References ==
# gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=100 ! video/x-raw,width=1920,height=1080 ! jpegenc ! avimux ! filesink location=./test0.avi \
You can find more examples in the [[VAR-SOM-MX6 GSTREAM FSLC#Camera Loopback|GStreamer section]].
                  v4l2src device=/dev/video1 num-buffers=100 ! video/x-raw,width=1920,height=1080 ! jpegenc ! avimux ! filesink location=./test1.avi
|{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M-PLUS |
== Using both cameras simultaneously ==


'''Please note: IMX7 has different multimedia capabilities than IMX6. All the references mentioned above for [[VAR-SOM-MX6 GSTREAM FSLC#Camera Loopback|GStreamer section]] should only be considered as examples. The pipelines may not work on IMX7 software stack.  
The following pipeline is an example of using both cameras simultaneously.<br>
In this example a short video stream from each camera is saved as an H.264-encoded AVI file.


For detailed camera training for IMX family refer to : http://cache.freescale.com/files/training/doc/ftf/2014/FTF-CON-F0119.pdf
# gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=100 ! video/x-raw,width=1920,height=1080 ! vpuenc_h264 ! avimux ! filesink location=./test0.avi \
                  v4l2src device=/dev/video2 num-buffers=100 ! video/x-raw,width=1920,height=1080 ! vpuenc_h264 ! avimux ! filesink location=./test1.avi
|
}}}}

Revision as of 19:14, 29 May 2022

DART-MX8M Camera

Testing MIPI-CSI2 cameras

Before running any of the pipelines below make sure you have camera(s) connected. i.MX family of processors uses gstreamer as multimedia framework. Please refer to https://gstreamer.freedesktop.org/

Camera Probe

Run the following command to see if you have the camera(s) detected

# v4l2-ctl --list-devices

This should produce the following output

# v4l2-ctl --list-devices
i.MX6S_CSI (platform:30a90000.csi1_bridge):
      /dev/video0

i.MX6S_CSI (platform:30b80000.csi2_bridge):
      /dev/video1

As you can see above there are 2 cameras accessible as /dev/video0 and /dev/video1

Testing Camera Preview on Display

In the examples below /dev/videoX is either /dev/video0 or /dev/video1

  • VGA 480p 640x480@30fps:
# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=640,height=480 ! autovideosink sync=false
  • NTSC 480p 720x480@30fps:
# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=720,height=480 ! autovideosink sync=false
  • HD 720p 1280x720@30fps:
# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=1280,height=720 ! autovideosink sync=false
  • Full HD 1080p 1920x1080@30fps:
# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=1920,height=1080 ! autovideosink sync=false
  • QSXGA 1944p 2592x1944@15fps:
# gst-launch-1.0 v4l2src device=/dev/videoX ! video/x-raw,width=2592,height=1944 ! autovideosink sync=false

Testing Camera JPEG Snapshot

To capture JPEG snapshot run one of the pipelines below depending upon the required picture resolution.

In the examples below /dev/videoX is either /dev/video0 or /dev/video1

  • VGA 480p 640x480:
# gst-launch-1.0 v4l2src device=/dev/videoX num-buffers=1 ! video/x-raw,width=640,height=480 ! jpegenc ! filesink location=/tmp/test_640x480.jpg
  • NTSC 480p 720x480:
# gst-launch-1.0 v4l2src device=/dev/videoX num-buffers=1 ! video/x-raw,width=720,height=480 ! jpegenc ! filesink location=/tmp/test_720x480.jpg
  • HD 720p 1280x720:
# gst-launch-1.0 v4l2src device=/dev/videoX num-buffers=1 ! video/x-raw,width=1280,height=720 ! jpegenc ! filesink location=/tmp/test_1280x720.jpg
  • Full HD 1080p 1920x1080:
# gst-launch-1.0 v4l2src device=/dev/videoX num-buffers=1 ! video/x-raw,width=1920,height=1080 ! jpegenc ! filesink location=/tmp/test_1920x1080.jpg
  • QSXGA 1944p 2592x1944:
# gst-launch-1.0 v4l2src device=/dev/videoX num-buffers=1 ! video/x-raw,width=2592,height=1944 ! jpegenc ! filesink location=/tmp/test_2592x1944.jpg

Using both cameras simultaneously

The following pipeline is an example of using both cameras simultaneously.
In this example a short video stream from each camera is saved as an MJPEG-encoded AVI file.

# gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=100 ! video/x-raw,width=1920,height=1080 ! jpegenc ! avimux ! filesink location=./test0.avi \
                 v4l2src device=/dev/video1 num-buffers=100 ! video/x-raw,width=1920,height=1080 ! jpegenc ! avimux ! filesink location=./test1.avi