Difference between revisions of "APITestPage"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
Line 1: Line 1:
'''(Note: The following content is translated by Google translate)'''
+
===Linux下使用摄像头(支持MIPI接口摄像头: OV13850与OV4689,USB摄像头:罗技C920)===
===2019-05-11===
+
摄像头连接方法:
* '''Android 8.1: '''
+
摄像头可以连接在MIPI接口,如下图所示:<br />
1) Added support for PWM fan, support fan speed control<br />
+
{{#switch: {{{1}}}
2) Add SSD support (Note: SSD partition needs to be ext4 format)<br />
+
| NanoPC-T4 =
* '''FriendlyCore, FriendlyDesktop: '''
+
[[File:T4-mipi-single-camera.jpg|frameless|600px]]<br>
1) Kernel version updated to v4.4.167<br />
+
| NanoPi-M4 =
2) the isp driver of the camera is upgraded from cif_isp10 to rk_isp1, supporting dual mipi cameras to work at the same time<br />
+
[[File:M4-mipi-single-camera.jpg|frameless|600px]]<br>
3) OpenCV is upgraded to the latest version 4.1, supporting dual mipi camera and USB camera (logitech C920)<br />
+
| NanoPi-NEO4 =
4) 4G network support is added to the Linux system (module: Quectel EC20)<br />
+
[[File:Neo4-mipi-single-camera.jpg|frameless|600px]]<br>
5) Add Aanopc-t4 PWM fan support<br />
+
| #default =
* '''EFlasher system: '''
+
}}
1) Reduced file system size<br />
+
2) The network configuration is changed from DHCP to static IP address (192.168.1.231)<br />
+
  
===2019-03-08===
+
<!--
* '''Add Buildroot project:'''
+
M4-mipi-dual-camera.jpg
Add Buildroot Linux system, based on Rockchip original RK3399 Linux SDK, project open source, please refer to the details:[[Buildroot for RK3399|Buildroot for RK3399]]
+
T4-mipi-dual-camera.jpg
* '''Android 8.1 update is as follows: '''
+
-->
1) Optimized LCD and HDMI screen rotation settings, support for command line operations (command: wm rotation 90)<br />
+
 
2) Fix the problem that the microphone cannot sound after forcing the audio output to the headphones<br />
+
为了方便测试摄像头,我们提供了脚本可以在命令行测试摄像头的拍照和录像功能。<br />
* '''FriendlyCore, FriendlyDesktop, Lubuntu is updated as follows: '''
+
你可以用以下命令更新这个脚本到最新版本:
1) Kernel version updated to v4.4.154<br />
+
<syntaxhighlight lang="bash">
2) Docker support<br />
+
cd /tmp/
3) Kernel configuration items are optimized to enable more features and device drivers<br />
+
git clone https://github.com/friendlyarm/gst-camera-sh.git
4) Fixed an issue where USB WiFi could not be used<br />
+
sudo cp gst-camera-sh/*.sh /usr/bin/
5) Fix the stability problem of ISP camera<br />
+
</syntaxhighlight>
===2018-12-19===
+
 
* '''Android 8.1 update is as follows: '''
+
共有以下三个脚本:<br />
1) Update the AOSP source version to Android8.1-SDK v5.00-20181109<br />
+
gst-camera.sh: 单个摄像头的预览、拍照与录像 <br />
2) Add HDMI resolution and HDMI overscan setting UI<br />
+
dual-camera.sh: 预览两个摄像头 <br />
3) Add audio output settings, you can set the default output to headphones or HDMI<br />
+
stop-gst-camera.sh: 停止预览<br />
4) Add OV13850 and wide dynamic OV4689 camera support<br />
+
<br />
* '''FriendlyCore is updated as follows: '''
+
====gst-camera.sh 参数说明====
1) Added OV13850 and wide dynamic OV4689 camera support<br />
+
::{| class="wikitable"
2) Added ffmpeg support, provides static libraries and header files, supports 4K hardware decoding (does not support hardware encoding)<br />
+
|-
3) Added mpv player, supports 4K hardware decoding<br />
+
|参数 || 功能
* '''FriendlyDesktop is updated as follows: '''
+
|-
1) Added OV13850 and wide dynamic OV4689 camera support<br />
+
|  --index或-i || 选择要使用的摄像头的序号,可选值为0和1,当同时连接两个摄像头时,指定为1表示要操作第二个摄像头
2) Add Chrome-browser browser, support web page 1080P hardware decoding, support WebGL<br />
+
|-
3) Added ffmpeg support, provides static libraries and header files, supports 4K hardware decoding (does not support hardware encoding)<br />
+
|  --action或-a || 指定命令要执行的动作,可选参数为: preview、photo和video,分别对应预览、拍照和录像
4) Fix the volume adjustment Issue<br />
+
|-
5) Set the audio output channel to HDMI by default (can be modified by /etc/pulse/default.pa)<br />
+
|  --output或-o || 指定输出的文件名,用于拍照和录像时指定输出文件名
6) Optimize the local player, associated with the mp4 file<br />
+
|-
7) Automatically enable swap partitioning for NEO4<br />
+
|  --verbose或-v || 指定为yes时,会输出调用gst-launch-1.0命令的完整命令行
8) Fix the issue of hostapd related issues<br />
+
|-
9) Adjust DPMS settings, turn off automatic sleep by default<br />
+
-x || 使用rkximagesink插件,预览图像会输出到X11窗口,适用于FriendlyDesktop与Lubuntu系统
* '''Lubuntu updated as follows: '''
+
|-
1) Added OV13850 and wide dynamic OV4689 camera support<br />
+
|  -g || 使用glimagesink插件,预览图像会输出到X11窗口,适用于FriendlyDesktop与Lubuntu系统
2) Add Chrome-browser browser, support web page 1080P hardware decoding, support WebGL<br />
+
|-
3) Set the audio output channel to HDMI by default (can be modified by /etc/asound.conf)<br />
+
|  -k || 使用kmssink插件,预览图像会直接输出到屏幕,适用于FriendlyCore系统
4) Optimize the local hard disk player, associated with the local mp4 file, double-click the local video to start the local hard disk player playback (only mp4 files are supported)<br />
+
|}
5) Fixed some issues regarding the package error reported in the previous version<br />
+
 
6) Adjust DPMS settings, turn off automatic sleep by default<br />
+
脚本gst-camera.sh会自动识别OV13850/OV4689/罗技C920摄像头,并传递合适的参数给gst-launch-1.0。
===2018-11-12===
+
 
* Android 8.1 update is as follows:
+
====gst-camera.sh 使用方法====
1) Add support for USB-C display<br />
+
* '''预览图像'''
2) Add support for 4G network, the model number of the support module is: Quectel EC20<br />
+
<syntaxhighlight lang="bash">
3) Add Android hardware access library FriendlyThing for programming various hardware resources under Android, such as Uart, SPI, I2C, GPIO, etc.<br />
+
gst-camera.sh --action preview
4) Optimize kernel configuration to improve PCIe performance, and connect NVME SSD will have a large performance improvement<br />
+
</syntaxhighlight>
5) Integrate the Google Play app store<br />
+
* '''拍照'''
6) Improve the underlying support of the camera so that it can automatically adapt to vertical screen (HD702E) and landscape (HDMI)<br />
+
用命令拍照一张照片,存储为文件 1.jpg:
7) Fix the problem that the partition table is abnormal when Android8 is connected to NVME SSD and Android8 cannot be started.<br />
+
<syntaxhighlight lang="bash">
* Android 7.1 update is as follows:
+
gst-camera.sh -a photo -o 1.jpg
1) Add support for 4G network, the model number of the support module is: Quectel EC20<br />
+
</syntaxhighlight>
2) Add Android hardware access library FriendlyThing for programming various hardware resources under Android, such as Uart, SPI, I2C, GPIO, etc.<br />
+
 
3) Optimize kernel configuration to improve PCIe performance, and connect NVME SSD will have a large performance improvement<br />
+
* '''录像并预览'''
4) Improve the underlying support of the camera so that it can automatically adapt to vertical screen (HD702E) and landscape (HDMI)<br />
+
用以下命令启动录像,存储为视频文件 1.ts,录像时使用了硬件编码:
5) Fix the problem that the partition table is abnormal when Android8 is connected to NVME SSD and Android8 cannot be started.<br />
+
<syntaxhighlight lang="bash">
* FriendlyCore and FriendlyDesktop are updated as follows:
+
gst-camera.sh --action video -output 1.ts
1) Added support for OV13850 camera, provides gsteamer plugin to support ISP<br />
+
</syntaxhighlight>
2) Add WiringPi support for C language programming to access hardware resources such as GPIO<br />
+
<br />
3) Added WiringPi-Python support for Python programming access to hardware resources such as GPIO<br />
+
* '''显示完整的命令'''
4) Optimize kernel configuration to improve PCIe performance, and connect NVME SSD will have a large performance improvement<br />
+
加入 --verbose yes 的参数,会显示最终的 gsteamer 命令,例如:
===2018-09-21===
+
<syntaxhighlight lang="bash">
* Added support for an eDP screen
+
gst-camera.sh --action video --output 1.ts --verbose yes
* Linux has enabled PCI-E to Sata function (AHCI SATA support)
+
</syntaxhighlight>
* SquashFS under Linux enables LZO/XZ/ZSTD compression support
+
你会得到以下完整的 gsteamer 命令,这对你开发会有帮助:
===2018-09-05===
+
<syntaxhighlight lang="bash">
* Add new OS: Android 8.1, the main features are as follows:
+
gst-launch-1.0 rkisp num-buffers=512 device=/dev/video0 io-mode=1 ! \
1) Support 2 CAM1320 (OV13850) at the same time, you can choose to switch between before and after camera use<br />
+
    video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! \
2) Support USB camera (1 way, can not be used simultaneously with CAM1320)<br />
+
        mpph264enc ! queue ! h264parse ! mpegtsmux ! \
3) Support AndroidNN GPU acceleration solution, which provides general acceleration support for AI related applications developed with AndroidNN API<br />
+
        filesink location=/tmp/camera-record.ts
4) Integrate the Tensorflow Lite item identification demo provided by Rockchip: TfLiteCameraDemo (connect CAM1320 or USB camera before starting)<br />
+
</syntaxhighlight>
5) Integrated Lightning is the default browser application (Note: Android official does not provide Browser application by default)<br />
+
 
6) Support RC-100 infrared remote control, support pull-down notification bar, screen capture<br />
+
====gst-launch-1.0命令行解析====
7) Support Android full disk encryption function, system partition has Verity enabled, when using adb, adb root; adb disable-verity command disable Verity<br />
+
在FriendlyDesktop下预览摄像头命令如下:
8) Support MTP function, after connecting Type-C, you can enter Settings -> Connected devices -> USB to select the corresponding function<br />
+
<syntaxhighlight lang="bash">
9) Upgrade the kernel version to 4.4.126<br />
+
gst-launch-1.0 rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! rkximagesink
10) Update the AOSP source to the version android-8.1.0_r41 and update the August security patch<br />
+
</syntaxhighlight>
* FriendlyCore adds Qt dual camera sample program: the example is located in /opt/dual-camera directory, run by run.sh (two USB cameras must be connected before starting, it is recommended to use Logitech C270 or Logitech C922 camera)<br />
+
重要参数说明:
* FriendlyDesktop defaults to HDMI resolution of 1080P<br />
+
::{| class="wikitable"
 +
|-
 +
|参数 || 说明
 +
|-
 +
| device || 用于预览的device (selfpath) 是 /dev/video1, 用于拍照的device (mainpath) /dev/video0, 如果是多路摄像头,则另一路预览(selfpath)/dev/video5, 另一路拍照 (mainpath)是 /dev/video4, USB摄像头一般都是 /dev/video8
 +
|-
 +
| io-mode || 值为1表示是memory map模式,值为4表示是dmabuf模式,一般预览用io-mode=4,拍照用io-mode=1, 在OpenCV里访问用io-mode=4
 +
|-
 +
| rkximagesink/glimagesink/kmssink || 在X-Windows窗口中输出mipi摄像头图像时指定为rkximagesink (适用于FriendlyDesktop),如果是USB摄像头则指定为glimagesink,FriendlyCore下只能使用kmssink
 +
|}
 +
 
 +
====在OpenCV中访问摄像头====
 +
访问MIPI摄像头:
 +
<syntaxhighlight lang="python">
 +
cv.VideoCapture('rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=640,height=480,framerate=30/1 ! videoconvert ! appsink', cv.CAP_GSTREAMER)
 +
</syntaxhighlight>
 +
访问USB摄像头:
 +
<syntaxhighlight lang="python">
 +
cv.VideoCapture('rkisp device=/dev/video8 io-mode=4 ! videoconvert ! video/x-raw,format=NV12,width=640,height=480,framerate=30/1 ! videoconvert ! appsink', cv.CAP_GSTREAMER)
 +
</syntaxhighlight>
 +
<br />
 +
详情请参考这里的示例代码:https://github.com/friendlyarm/install-opencv-on-friendlycore/tree/rk3399/examples<br />
 +
<br />
 +
====摄像头应用教程: 推流至直播平台====
 +
请查看这篇文档: [[RTMP-For-RK3399/zh]]<br />
 +
 
 +
====参考资源====
 +
http://blog.iotwrt.com/media/2017/10/01/camera/
 +
http://www.360doc.com/content/16/1019/17/496343_599664458.shtml

Revision as of 08:36, 14 May 2019

1 Linux下使用摄像头(支持MIPI接口摄像头: OV13850与OV4689,USB摄像头:罗技C920)

摄像头连接方法: 摄像头可以连接在MIPI接口,如下图所示:


为了方便测试摄像头,我们提供了脚本可以在命令行测试摄像头的拍照和录像功能。
你可以用以下命令更新这个脚本到最新版本:

cd /tmp/
git clone https://github.com/friendlyarm/gst-camera-sh.git
sudo cp gst-camera-sh/*.sh /usr/bin/

共有以下三个脚本:
gst-camera.sh: 单个摄像头的预览、拍照与录像
dual-camera.sh: 预览两个摄像头
stop-gst-camera.sh: 停止预览

1.1 gst-camera.sh 参数说明

参数 功能
--index或-i 选择要使用的摄像头的序号,可选值为0和1,当同时连接两个摄像头时,指定为1表示要操作第二个摄像头
--action或-a 指定命令要执行的动作,可选参数为: preview、photo和video,分别对应预览、拍照和录像
--output或-o 指定输出的文件名,用于拍照和录像时指定输出文件名
--verbose或-v 指定为yes时,会输出调用gst-launch-1.0命令的完整命令行
-x 使用rkximagesink插件,预览图像会输出到X11窗口,适用于FriendlyDesktop与Lubuntu系统
-g 使用glimagesink插件,预览图像会输出到X11窗口,适用于FriendlyDesktop与Lubuntu系统
-k 使用kmssink插件,预览图像会直接输出到屏幕,适用于FriendlyCore系统

脚本gst-camera.sh会自动识别OV13850/OV4689/罗技C920摄像头,并传递合适的参数给gst-launch-1.0。

1.2 gst-camera.sh 使用方法

  • 预览图像
gst-camera.sh --action preview
  • 拍照

用命令拍照一张照片,存储为文件 1.jpg:

gst-camera.sh -a photo -o 1.jpg
  • 录像并预览

用以下命令启动录像,存储为视频文件 1.ts,录像时使用了硬件编码:

gst-camera.sh --action video -output 1.ts


  • 显示完整的命令

加入 --verbose yes 的参数,会显示最终的 gsteamer 命令,例如:

gst-camera.sh --action video --output 1.ts --verbose yes

你会得到以下完整的 gsteamer 命令,这对你开发会有帮助:

gst-launch-1.0 rkisp num-buffers=512 device=/dev/video0 io-mode=1 ! \
    video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! \
        mpph264enc ! queue ! h264parse ! mpegtsmux ! \
        filesink location=/tmp/camera-record.ts

1.3 gst-launch-1.0命令行解析

在FriendlyDesktop下预览摄像头命令如下:

gst-launch-1.0 rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! rkximagesink

重要参数说明:

参数 说明
device 用于预览的device (selfpath) 是 /dev/video1, 用于拍照的device (mainpath) 是 /dev/video0, 如果是多路摄像头,则另一路预览(selfpath)是 /dev/video5, 另一路拍照 (mainpath)是 /dev/video4, USB摄像头一般都是 /dev/video8
io-mode 值为1表示是memory map模式,值为4表示是dmabuf模式,一般预览用io-mode=4,拍照用io-mode=1, 在OpenCV里访问用io-mode=4
rkximagesink/glimagesink/kmssink 在X-Windows窗口中输出mipi摄像头图像时指定为rkximagesink (适用于FriendlyDesktop),如果是USB摄像头则指定为glimagesink,FriendlyCore下只能使用kmssink

1.4 在OpenCV中访问摄像头

访问MIPI摄像头:

cv.VideoCapture('rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=640,height=480,framerate=30/1 ! videoconvert ! appsink', cv.CAP_GSTREAMER)

访问USB摄像头:

cv.VideoCapture('rkisp device=/dev/video8 io-mode=4 ! videoconvert ! video/x-raw,format=NV12,width=640,height=480,framerate=30/1 ! videoconvert ! appsink', cv.CAP_GSTREAMER)


详情请参考这里的示例代码:https://github.com/friendlyarm/install-opencv-on-friendlycore/tree/rk3399/examples

1.5 摄像头应用教程: 推流至直播平台

请查看这篇文档: RTMP-For-RK3399/zh

1.6 参考资源

http://blog.iotwrt.com/media/2017/10/01/camera/ http://www.360doc.com/content/16/1019/17/496343_599664458.shtml