Difference between revisions of "Template:Linux-RK3399MIPICamera"
(→Work with MIPI Camera OV13850 Under Linux) |
(updated by API) |
||
Line 1: | Line 1: | ||
− | ===Work with MIPI Camera OV13850 Under Linux=== | + | ===Work with MIPI Camera OV13850 and MIPI WDR Camera OV4689 Under Linux=== |
Hardware Setting: | Hardware Setting: | ||
− | The | + | The Camera module can be connected to a MIPI port:<br /> |
{{#switch: {{{1}}} | {{#switch: {{{1}}} | ||
| NanoPC-T4 = | | NanoPC-T4 = | ||
Line 17: | Line 17: | ||
--> | --> | ||
− | FriendlyELEC provides a test script "gst-camera.sh" to test a camera's functions. You can run it in a commandline to test picture taking and video recording. | + | FriendlyELEC provides a test script "gst-camera.sh" to test a camera's functions. You can run it in a commandline to test picture taking and video recording. |
− | + | ||
− | + | ||
− | + | ||
====Options in "gst-camera.sh"==== | ====Options in "gst-camera.sh"==== | ||
::{| class="wikitable" | ::{| class="wikitable" | ||
Line 35: | Line 32: | ||
|- | |- | ||
| --verbose or -v || If it is specified as "yes" it will output the complete command when "gst-launch-1.0" is called | | --verbose or -v || If it is specified as "yes" it will output the complete command when "gst-launch-1.0" is called | ||
+ | |- | ||
+ | | -x || Using the rkximagesink plugin, the preview image will be output to the X11 window for the FriendlyDesktop and Lubuntu systems | ||
+ | |- | ||
+ | | -k || Using the kmssink plugin, the preview image will be output directly to the screen for the FriendlyCore system | ||
|} | |} | ||
+ | |||
+ | The script gst-camera.sh will automatically recognize OV13850 and OV4689 and pass the appropriate parameters to gst-launch-1.0. | ||
====Usage of gst-camera.sh==== | ====Usage of gst-camera.sh==== | ||
Line 60: | Line 63: | ||
Here is the complete gsteamer command you will see: | Here is the complete gsteamer command you will see: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | gst-launch-1.0 rkisp num-buffers=512 io-mode=4 path-iqf=/etc/cam_iq/ | + | gst-launch-1.0 rkisp num-buffers=512 io-mode=4 path-iqf=/etc/cam_iq/${XMLFILE} \ |
! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 \ | ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 \ | ||
! tee name=t t. ! queue ! kmssink t. ! queue ! mpph264enc \ | ! tee name=t t. ! queue ! kmssink t. ! queue ! mpph264enc \ | ||
! queue ! h264parse ! mpegtsmux ! filesink location=1.ts | ! queue ! h264parse ! mpegtsmux ! filesink location=1.ts | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | The ${XMLFILE} variable may be rk-ov13850.xml or rk-ov4689.xml, depending on the camera model you are connected to. | ||
+ | |||
+ | ====gst-launch-1.0 parameter description==== | ||
+ | Preview ov13850 camera on FriendlyDesktop: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | gst-launch-1.0 rkisp device=/dev/video0 sensor-id=1 io-mode=4 path-iqf=/etc/cam_iq/rk-rk-ov13850.xml ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! rkximagesink | ||
+ | </syntaxhighlight> | ||
+ | Preview ov4689 camera on FriendlyDesktop: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | gst-launch-1.0 rkisp device=/dev/video0 sensor-id=1 io-mode=4 path-iqf=/etc/cam_iq/rk-ov4689.xml ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! rkximagesink | ||
+ | </syntaxhighlight> | ||
+ | Important parameters | ||
+ | ::{| class="wikitable" | ||
+ | |- | ||
+ | |parameter || description | ||
+ | |- | ||
+ | | device || If only one camera is connected, no matter which CSI interface is connected, the device (selfpath) used for preview is /dev/video0, and the device (mainpath) used for photographing is /dev/video2, if 2 cameras are connected at the same time. The camera nodes corresponding to the CSI1 interface are /dev/video0 and /dev/video2, and CSI2 corresponds to /dev/video4 and /dev/video6. | ||
+ | |- | ||
+ | | sensor-id || If only one camera is connected, the sensor-id is 1 regardless of which CSI interface is connected. If two cameras are connected at the same time, the camera of the CSI1 interface is 1, and the camera of the CSI2 interface is 5. | ||
+ | |- | ||
+ | | path-iqf || Specify the camera's tuning xml file. When the camera is OV4689, you need to specify /etc/cam_iq/rk-ov4689.xml. When the camera is OV13850, you need to specify /etc/cam_iq/rk-rk-ov13850.xml. | ||
+ | |- | ||
+ | | rkximagesink or kmssink || rkximagesink for FriendlyDesktop, will display on X11 window, kmssink for FriendlyCore, directly display on the screen | ||
+ | |} | ||
+ | |||
+ | ====Camera application tutorial: Push video stream==== | ||
+ | Please refre this guide: [[RTMP-For-RK3399]]<br /> | ||
+ | |||
+ | ====Reference resource==== | ||
+ | http://blog.iotwrt.com/media/2017/10/01/camera/ | ||
+ | http://www.360doc.com/content/16/1019/17/496343_599664458.shtml |
Revision as of 04:29, 20 December 2018
Contents
1 Work with MIPI Camera OV13850 and MIPI WDR Camera OV4689 Under Linux
Hardware Setting:
The Camera module can be connected to a MIPI port:
FriendlyELEC provides a test script "gst-camera.sh" to test a camera's functions. You can run it in a commandline to test picture taking and video recording.
1.1 Options in "gst-camera.sh"
Options Comment --index or -i Camera's index, it can be either 0 or 1. When two cameras are connected to a board you need to specify 1 to access the second camera. --mode or -m Camera's resolution. For example if a camera's resolution is 720P 30FPS you can set width=1280, height=720 and framerate=30/1 --action or -a Specify an action, it can be "preview" to preview, "photo" to take a picture or "video" to record video --output or -o Specify an output file to save a picture when taking a picture or video file when recording video --verbose or -v If it is specified as "yes" it will output the complete command when "gst-launch-1.0" is called -x Using the rkximagesink plugin, the preview image will be output to the X11 window for the FriendlyDesktop and Lubuntu systems -k Using the kmssink plugin, the preview image will be output directly to the screen for the FriendlyCore system
The script gst-camera.sh will automatically recognize OV13850 and OV4689 and pass the appropriate parameters to gst-launch-1.0.
1.2 Usage of gst-camera.sh
- Preview
gst-camera.sh --action preview
- Picture Taking
You can run the following command to take a picture and save it as a "1.jpg" file,
gst-camera.sh --action photo -output 1.jpg
- Preview and Record
You can run the following command to preview and record video and save your video to a "1.ts" file. Hardware encoding is activated when it is recording video.
gst-camera.sh --action video -output 1.ts
- Show Complete Command
If you add the "--verbose yes" option it will show a complete gsteamer command.
gst-camera.sh --action video --output 1.ts --verbose yes
Here is the complete gsteamer command you will see:
gst-launch-1.0 rkisp num-buffers=512 io-mode=4 path-iqf=/etc/cam_iq/${XMLFILE} \ ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 \ ! tee name=t t. ! queue ! kmssink t. ! queue ! mpph264enc \ ! queue ! h264parse ! mpegtsmux ! filesink location=1.ts
The ${XMLFILE} variable may be rk-ov13850.xml or rk-ov4689.xml, depending on the camera model you are connected to.
1.3 gst-launch-1.0 parameter description
Preview ov13850 camera on FriendlyDesktop:
gst-launch-1.0 rkisp device=/dev/video0 sensor-id=1 io-mode=4 path-iqf=/etc/cam_iq/rk-rk-ov13850.xml ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! rkximagesink
Preview ov4689 camera on FriendlyDesktop:
gst-launch-1.0 rkisp device=/dev/video0 sensor-id=1 io-mode=4 path-iqf=/etc/cam_iq/rk-ov4689.xml ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! rkximagesink
Important parameters
parameter description device If only one camera is connected, no matter which CSI interface is connected, the device (selfpath) used for preview is /dev/video0, and the device (mainpath) used for photographing is /dev/video2, if 2 cameras are connected at the same time. The camera nodes corresponding to the CSI1 interface are /dev/video0 and /dev/video2, and CSI2 corresponds to /dev/video4 and /dev/video6. sensor-id If only one camera is connected, the sensor-id is 1 regardless of which CSI interface is connected. If two cameras are connected at the same time, the camera of the CSI1 interface is 1, and the camera of the CSI2 interface is 5. path-iqf Specify the camera's tuning xml file. When the camera is OV4689, you need to specify /etc/cam_iq/rk-ov4689.xml. When the camera is OV13850, you need to specify /etc/cam_iq/rk-rk-ov13850.xml. rkximagesink or kmssink rkximagesink for FriendlyDesktop, will display on X11 window, kmssink for FriendlyCore, directly display on the screen
1.4 Camera application tutorial: Push video stream
Please refre this guide: RTMP-For-RK3399
1.5 Reference resource
http://blog.iotwrt.com/media/2017/10/01/camera/ http://www.360doc.com/content/16/1019/17/496343_599664458.shtml