OpenHarmony开源社区
直播中

小伍

8年用户 4725经验值
擅长:电源/新能源 嵌入式技术
私信 关注
[经验]

【OpenHarmony样例】基于Hi3518开发板开发的智能猫眼

一 概述

本Demo是基于Hi3518开发板,使用开源OpenHarmony开发的RTSP协议流媒体应用。达到将Hi3518开发板中摄像头获取的数据通过RTSP协议传输到手机并显示 。

rtsp实现可参考文档:RTSPServer
1.1应用运行效果图
15.png
1.2 设备与手机间交互示意图
16.png
如上图所示,手机播放3518摄像头采集的视频数据。

二 快速上手
2.1硬件开发环境准备
  • 预装windows系统的PC机
  • Hi3518EV300 IoT Camera开发板
  • USB转串口线、网线(Windows工作台通过USB转串口线、网线与开发板连接)
  • 开发板介绍参照文档:Hi3518开发板介绍
  • 淘宝店Hi3518EV300开发板购买地址:HarmonyOS HiSpark Aries IPC 摄像头(Hi3518E)开发板套件
2.2下载源码准备
  • 注册码云gitee账号。
  • 注册码云SSH公钥,请参考码云帮助中心的公钥管理:https://gitee.com/help/articles/4181
  • 安装下载工具
    1. sudo apt-get install git-lfs
    2. sudo apt-get install curl
    3. sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1

  • 安装git客户端并配置用户信息。
    1. git config --global user.name "yourname"
    2. git config --global user.email "your-email-address"
    3. git config --global credential.helper store

  • 安装码云repo工具,可以执行如下命令。
    1. curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo
    2. chmod a+x /usr/local/bin/repo
    3. pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests

下载OpenHarmony源码
  1. #特别注意:请下载OpenHarmony 1.0.1 版本,后续会更新支持OpenHarmony其他版本
  2. repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony_1.0.1_release --no-repo-verify
  3. repo sync -c
  4. repo forall -c 'git lfs pull'
下载smart_door_viewer_3518代码

具体仓库地址: knowledge_demo_smart_home
通过git命令下载(方便后期代码上传管理,建议先将仓库fork到自己账号目录,然后再下载):
  1. git clone git@gitee.com:xxxxxxx/knowledge_demo_smart_home.git
  2. 其中xxxxxxx为fork后相关账号名字。
代码拷贝
1.在OpenHarmony的vendor目录下新建一个team_x的目录:
  1. mkdir vendor/team_x
2.将下载的智能油烟机代码的代码拷贝到新建的team_x下面:
  1. cp -rf ../knowledge_demo_smart_home/dev/team_x/smart_door_viewer_3518/ vendor/team_x/
3.将下面文件替换到openHarmony1.0.1源码下的文件
17.png
代码目录结构
  1. ├── smart_door_viewer_3518
  2. │   ├── BUILD.gn                                                                                // 编译脚本
  3. │   ├── include
  4. │   │   ├── camera_sample.h                                                                // 摄像头定义头文件
  5. │   │   ├── rtp.h                                       // rtp协议传输头文件
  6. │   │   ├── rtsp_log.h                                  // 打印调试头文件
  7. │   │   └── rtsp_server.h                               // rtsp_server头文件
  8. │   └── src
  9. │       ├── camera_sample.cpp                           // 摄像头实现
  10. │       ├── main.cpp                                    // 主函数
  11. │       ├── rtp.cpp                                     // rtp协议实现
  12. │       └── rtsp_server.cpp                             // rtsp协议实现
  13. ├── foundation              
  14. │   └── multimedia
  15. │       └── media_lite
  16. │           ├── frameworks
  17. │           │   └── recorder_lite
  18. │           │       ├── recorder.cpp                    //增加获取h.265数据存放至环形缓冲区接口实现
  19. │           │       ├── recorder_impl.cpp               //增加向应用层提供环形缓冲区接口实现
  20. │           │       └── recorder_impl.h                 //增加向应用层提供环形缓冲区接口定义
  21. │           └── interfaces
  22. │               └── kits
  23. │                   └── recorder_lite
  24. │                       └── recorder.h                  //增加获取h.265数据存放至环形缓冲区接口定义
2.3Linux编译服务器开发环境准备
开发基础环境由windows 工作台和Linux 编译服务器组成。windows 工作台通过samba 服务或ssh 方式访问Linux编译服务器。其中windows 工作台用来烧录和代码编辑,Linux编译服务器用来编译OpenHarmony代码,为了简化步骤,Linux编译服务器推荐安装Ubuntu20.04。
参考官方文档搭建开发Linux编译环境。
  • 系统基础环境搭建。
  • Hi3518搭建环境

编译​        

源码和环境准备完后,接下来就是编译,编译涉及的指令有2条,hb set和hb build -f 。
  1. hb set         --         设置工程目录和选择对应的目标,通过键盘的上下键来选择。
18.png
  1. hb build -f  -- 开始全量编译。(hb build 为增量编译)
编译完后会生成对应整个系统固件(u-boot-hi3518ev300.bin,OHOS_Image.bin, rootfs_vfat.img, userfs_vfat.img)

以下表格为所有生成的固件及对应的位置:
生产固件及应用文件的名称对应文件路径文件说明
u-boot-hi3518ev300.bindevice/hisilicon/hispark_aries/sdk_liteos/uboot/out/boot系统启动引导程序
OHOS_Image.binout/hispark_aries/smart_door_viewer_3518/系统内核固件
rootfs_vfat.imgout/hispark_aries/smart_door_viewer_3518/文件系统
userfs_vfat.imgout/hispark_aries/smart_door_viewer_3518/用户数据
2.4固件烧录烧录工具选择​        固件编译完后,是需要烧录到单板的。这里我们用的是HiTool工具烧录的。(HiTool工具下载地址:HiHope官网)
烧录步骤​        打开HiTool工具,如下图:
烧写步骤按照图中标注即可。点击擦除后再拔出USB口再接入。
19.png
擦除成功如下所示。
20.png
然后按如下图选择,再点击烧写。
21.png
烧录成功后,会弹出如下提示,单板也会自行启动。
22.png
单板在启动的时候需要设置bootargs,否则不能正常启动。单板第一次启动会停在hisilicon界面:
23.png
输入以下启动参数:
  1. setenv bootcmd "sf probe 0;sf read 0x40000000 0x100000 0x600000;go 0x40000000";
  2. setenv bootargs "console=ttyAMA0,115200n8 root=flash fstype=jffs2 rw rootaddr=7M rootsize=8M";
  3. save;
  4. reset
三启动rtsp_server应用开启热点
准备一部手机开启热点设置
ssid为"SMedia",password为”12345678“。

设备连接热点

1、准备一张SD卡插入到插槽内。
2、进入3518的shell输入如下命令连接热点:
  1. ./bin/wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf
24.png
3、在3518中输入ifconfig查看连接状态:
25.png
运行应用1、在串口下输入
  1. ./bin/rtsp_server



26.png
打印如下表示设备应用已准备完毕
27.png
4、在手机应用市场中搜索”完美播放器“并下载安装。
28.png 5、打开菜单选择网址播放。
29.png
6、输入rtsp播放地址,其中ip地址192.168.43.118为3518板子中的地址。
30.png

效果动图
31.gif

回帖(1)

巴拉巴拉啦啦啦

2022-5-8 21:27:48
[ERROR]RTSP SERVER(RtspServerSelect:421):      TcpRead ret <= 0
[ERROR]RTSP SERVER(RtspServerScheduleConnection:443):   RtspServerSelect ret < 0
[INFO](RtspServerSelect:419):  the buffer->
[ERROR]RTSP SERVER(RtspServerSelect:421):      TcpRead ret <= 0
[ERROR]RTSP SERVER(RtspServerScheduleConnection:443):   RtspServerSelect ret < 0
[INFO](RtspServerSelect:419):  the buffer->
[ERROR]RTSP SERVER(RtspServerSelect:421):      TcpRead ret <= 0
[ERROR]RTSP SERVER(RtspServerScheduleConnection:443):   RtspServerSelect ret < 0
[INFO](RtspServerSelect:419):  the buffer->
[ERROR]RTSP SERVER(RtspServerSelect:421):      TcpRead ret <= 0
[ERROR]RTSP SERVER(RtspServerScheduleConnection:443):   RtspServerSelect ret < 0
[INFO](RtspServerSelect:419):  the buffer->
[ERROR]RTSP SERVER(RtspServerSelect:421):      TcpRead ret <= 0
[ERROR]RTSP SERVER(RtspServerScheduleConnection:443):   RtspServerSelect ret < 0
[INFO](RtspServerSelect:419):  the buffer->
[ERROR]RTSP SERVER(RtspServerSelect:421):      TcpRead ret <= 0
[ERROR]RTSP SERVER(RtspServerScheduleConnection:443):   RtspServerSelect ret < 0
[INFO](RtspServerSelect:419):  the buffer->
[ERROR]RTSP SERVER(RtspServerSelect:421):      TcpRead ret <= 0
[ERROR]RTSP SERVER(RtspServerScheduleConnection:443):   RtspServerSelect ret < 0
[INFO](RtspServerSelect:419):  the buffer->
[ERROR]RTSP SERVER(RtspServerSelect:421):      TcpRead ret <= 0
[ERROR]RTSP SERVER(RtspServerScheduleConnection:443):   RtspServerSelect ret < 0

想请问一下大佬,这种情况是什么原因呐
举报

更多回帖

发帖
×
20
完善资料,
赚取积分