├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── HiLens_framework ├── Atlas500使用说明.MD ├── CMakeLists.txt ├── HiLens Framework SDK.MD ├── HiLens_Framework.png ├── License │ ├── LICENSE.txt │ └── Open Source Software Notice.md ├── README.MD ├── README_ch.md ├── VERSION ├── build.sh ├── common │ ├── include │ │ ├── apigateway │ │ │ ├── RequestParams.h │ │ │ ├── constants.h │ │ │ ├── hasher.h │ │ │ ├── header.h │ │ │ ├── signer.h │ │ │ └── utils.h │ │ ├── hilens_errorcode.h │ │ ├── hstring.h │ │ ├── message_mgr.h │ │ ├── sf_common.h │ │ ├── sfw_log.h │ │ └── utils.h │ └── lib │ │ └── libhilens_common.so ├── deploy │ ├── decode.graph │ ├── encode.graph │ ├── infer.graph │ ├── install.sh │ ├── logger.conf │ ├── scc.conf │ └── sfw.conf ├── engine │ └── lib │ │ ├── infer_engine.so │ │ └── relay_engine.so ├── hda │ └── hdacli │ │ ├── python2 │ │ ├── hdacli_internal.py │ │ ├── hdacli_wrap.cxx │ │ └── hdacli_wrap.h │ │ └── python3 │ │ ├── hdacli_internal.py │ │ └── hdacli_wrap.cxx ├── hilens_media │ ├── include │ │ ├── HiLensAudioRpc.h │ │ ├── HiLensMedia.h │ │ ├── MediaComm.h │ │ ├── MediaLog.h │ │ └── MediaUtils.h │ └── lib │ │ └── libhilens_media.so ├── hilens_security │ ├── include │ │ ├── auth.h │ │ ├── check_license.h │ │ ├── conf.h │ │ ├── device_utils.h │ │ ├── hilens_security.h │ │ ├── vdecoder.h │ │ ├── vencoder.h │ │ └── wsclient.h │ └── lib │ │ ├── libhilens_security.so │ │ ├── libsc-common.so │ │ ├── libsc-kmc.so │ │ ├── libsc-pwdpolicy.so │ │ ├── libsc-sdp.so │ │ ├── libsc-secrypto.so │ │ ├── libsc-securec.so │ │ ├── libsc-zlog.so │ │ └── libsc-zlog.so.1.2 ├── include │ ├── audio_capture.h │ ├── audio_output.h │ ├── ei_services.h │ ├── errors.h │ ├── hilens.h │ ├── log.h │ ├── media_process.h │ ├── model.h │ ├── output.h │ ├── resource.h │ └── video_capture.h ├── libhilens │ ├── BlockingQueue.h │ ├── CMakeLists.txt │ ├── VideoCaptureEx.cpp │ ├── VideoCaptureEx.h │ ├── audio_capture.cpp │ ├── audio_output.cpp │ ├── audio_play.cpp │ ├── audio_play.h │ ├── display_hdmi.cpp │ ├── display_hdmi.h │ ├── dvpp_decoder.cpp │ ├── dvpp_decoder.h │ ├── dvpp_encoder.cpp │ ├── dvpp_encoder.h │ ├── ei_services.cpp │ ├── ei_utils.cpp │ ├── ei_utils.h │ ├── encode_src_engine.cpp │ ├── encode_src_engine.h │ ├── file_audio.cpp │ ├── file_audio.h │ ├── h264_writer.cpp │ ├── h264_writer.h │ ├── hiai_common.cpp │ ├── hiai_common.h │ ├── hilens.cpp │ ├── ipc_capture.cpp │ ├── ipc_capture.h │ ├── license_video_capture.cpp │ ├── license_video_capture.h │ ├── local_audio.cpp │ ├── local_audio.h │ ├── local_camera.cpp │ ├── local_camera.h │ ├── log.cpp │ ├── media_process.cpp │ ├── model.cpp │ ├── model_impl.cpp │ ├── model_impl.h │ ├── mp4_reader.cpp │ ├── mp4_reader.h │ ├── obszilla │ │ ├── obsutils.cpp │ │ ├── obsutils.h │ │ ├── obszilla.cpp │ │ ├── obszilla.h │ │ ├── request.cpp │ │ └── request.h │ ├── output.cpp │ ├── relay_dvpp_engine.cpp │ ├── relay_dvpp_engine.h │ ├── resource.cpp │ ├── route.cpp │ ├── route.h │ ├── rtmp_publisher.cpp │ ├── rtmp_publisher.h │ ├── rtsp_puller.cpp │ ├── rtsp_puller.h │ ├── src_engine.h │ ├── src_engines.cpp │ ├── uvc_capture.cpp │ ├── uvc_capture.h │ ├── vdecfactory.cpp │ ├── vdecfactory.h │ └── video_capture.cpp ├── python │ ├── CMakeLists.txt │ ├── hilens.i │ ├── hilens.py │ ├── hilens_internal.py │ ├── hilens_wrap.cxx │ ├── numpy.i │ ├── wrapper.cpp │ └── wrapper.h └── third_party │ ├── README.md │ ├── README_ch.md │ └── third_install.sh ├── LICENSE ├── README.md ├── contrib └── README.MD ├── docs ├── HiLens 模型支持列表 - ddk893.MD ├── HiLens 部署 模型转换 算子网络支持清单.xlsx ├── HiLens常见问题-第1期.MD ├── README.md └── pics │ ├── FAQ_1.png │ ├── FAQ_2.png │ ├── FAQ_3.png │ ├── FAQ_4.png │ ├── FAQ_5.png │ ├── FAQ_6.PNG │ ├── Thumbs.db │ ├── hilens.png │ ├── hilens_platform.jpg │ ├── hilens_size.png │ ├── hilens_str.png │ └── qr_code.png ├── official_examples ├── ModelArts + HiLens 端云协同,开发手势识别AI应用 │ ├── README.md │ ├── gesture_main.py │ └── img │ │ ├── HiLens_authorize.PNG │ │ ├── Hilens_Kit_connectwifi.png │ │ ├── Hilens_Kit_connectwifi2.png │ │ ├── connect_to_computer.png │ │ ├── connect_to_computer2.PNG │ │ ├── connect_to_computer3.png │ │ ├── console.png │ │ ├── convert_model.png │ │ ├── create_obs.png │ │ ├── create_skill.png │ │ ├── create_skill2.png │ │ ├── default_gateway.png │ │ ├── default_gateway2.png │ │ ├── delete_skill.PNG │ │ ├── delete_skill2.PNG │ │ ├── deploy.PNG │ │ ├── flow.jpg │ │ ├── hdactl.png │ │ ├── ies.jpg │ │ ├── import_model.png │ │ ├── ma_pipeline.png │ │ ├── maincode.png │ │ ├── mobaxterm.PNG │ │ ├── ping.png │ │ ├── ping_hilens_kit_ip.png │ │ ├── set_IP_adress.png │ │ ├── set_IP_adress2.png │ │ ├── sign_up_HiLens.PNG │ │ ├── skillmanager.PNG │ │ ├── skillmanager2.PNG │ │ ├── stop_skill.PNG │ │ ├── trainjob-parameter.png │ │ ├── trainjob-source.png │ │ ├── trainjob-test.png │ │ └── update_HiLens.PNG ├── 一键部署AI模型到端侧设备Hilens Kit │ ├── README.md │ └── img │ │ ├── HiLens_authorize.PNG │ │ ├── Hilens_Kit_connectwifi.png │ │ ├── Hilens_Kit_connectwifi2.png │ │ ├── connect_to_computer.png │ │ ├── connect_to_computer2.PNG │ │ ├── connect_to_computer3.png │ │ ├── console.png │ │ ├── convert_model.png │ │ ├── create_obs.png │ │ ├── create_skill.png │ │ ├── create_skill2.png │ │ ├── default_gateway.png │ │ ├── default_gateway2.png │ │ ├── delete_skill.PNG │ │ ├── delete_skill2.PNG │ │ ├── deploy.PNG │ │ ├── deploy2.PNG │ │ ├── flow.jpg │ │ ├── flow.png │ │ ├── hdactl.png │ │ ├── ies.jpg │ │ ├── import_model.png │ │ ├── ma_pipeline.png │ │ ├── maincode.png │ │ ├── mobaxterm.PNG │ │ ├── ping.png │ │ ├── ping_hilens_kit_ip.png │ │ ├── purchase_1.PNG │ │ ├── purchase_2.PNG │ │ ├── set_IP_adress.png │ │ ├── set_IP_adress2.png │ │ ├── sign_up_HiLens.PNG │ │ ├── skillmanager.PNG │ │ ├── skillmanager2.PNG │ │ ├── start.PNG │ │ ├── stop_skill.PNG │ │ ├── trainjob-parameter.png │ │ ├── trainjob-source.png │ │ ├── trainjob-test.png │ │ ├── update_HiLens.PNG │ │ ├── 人脸检测.PNG │ │ └── 参数.PNG └── 技能模板 │ ├── Face_Detection_Template │ ├── main.py │ ├── models │ │ └── face_detection_demo.om │ └── postprocess.py │ ├── Face_Landmarks_Detection_Template │ ├── index.py │ ├── models │ │ ├── centerface_template_model.om │ │ └── landmark68_template_model.om │ └── utils.py │ ├── Helmet_Detection_Template │ ├── index.py │ ├── models │ │ └── helmet_template_model.om │ └── utils.py │ ├── Single_Human_Pose_Template │ ├── index.py │ ├── models │ │ └── pose_template_model.om │ └── utils.py │ └── Static_Gesture_Recognition_Template │ ├── index.py │ ├── models │ └── gesture_template_model.om │ └── utils.py └── tools ├── HiLens Kit + ROS ├── README.MD ├── ROS程序编译指导文档.MD ├── install_rpm.sh └── pics │ ├── pic_1.png │ ├── pic_10.png │ ├── pic_11.png │ ├── pic_12.png │ ├── pic_13.png │ ├── pic_14.png │ ├── pic_15.png │ ├── pic_16.png │ ├── pic_17.png │ ├── pic_18.png │ ├── pic_19.png │ ├── pic_2.png │ ├── pic_3.png │ ├── pic_4.png │ ├── pic_5.png │ ├── pic_6.png │ ├── pic_7.png │ ├── pic_8.png │ ├── pic_9.png │ ├── ros_1.png │ ├── ros_2.png │ ├── ros_3.png │ └── ros_4.png ├── HiLens Kit - yum ├── README.MD └── rpm.zip ├── HiLens Kit-gdb ├── README.MD └── gdb.rar └── README.MD /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /HiLens_framework/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(SkillFramework) 4 | 5 | # 使用C++11标准 6 | set(CMAKE_CXX_STANDARD 11) 7 | 8 | #ADD_DEFINITIONS(-g) 9 | 10 | # 当CLOUD为ON时,编译Studio版本 11 | if(CLOUD) 12 | message("\nBuilding Framework for studio...\n") 13 | add_definitions(-DCLOUD) 14 | endif() 15 | 16 | if(CLOUD) 17 | set(DDK_Version "893") 18 | set(JsonLib "jsoncpp-cloud") 19 | set(log4cpluslib "log4cplus-cloud") 20 | else() 21 | # 使用B887版本DDK的HOST侧库需要加上此编译选项 22 | add_compile_options(-D_GLIBCXX_USE_CXX11_ABI=0) 23 | set(DDK_Version "887") 24 | set(JsonLib "jsoncpp") 25 | set(log4cpluslib "log4cplus") 26 | endif() 27 | 28 | if(CMAKE_BUILD_TYPE MATCHES DEBUG) 29 | set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb") 30 | endif() 31 | 32 | # 添加安全编译选项 33 | add_compile_options(-fstack-protector-strong) 34 | set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") 35 | set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,relro,-z,now,-z,noexecstack -pie") 36 | 37 | # 不自动添加rpath 38 | set(CMAKE_SKIP_RPATH TRUE) 39 | set(CMAKE_SKIP_BUILD_RPATH TRUE) 40 | set(CMAKE_SKIP_INSTALL_RPATH TRUE) 41 | 42 | # 当SFW_OFFLINE为ON时,编译离线版本 43 | if(SF_OFFLINE) 44 | message("\nBuilding offline package...\n") 45 | add_definitions(-DSF_OFFLINE) 46 | endif() 47 | 48 | 49 | include_directories(${CMAKE_SOURCE_DIR}/third_party/openssl/include) 50 | include_directories(${CMAKE_SOURCE_DIR}/third_party/curl/include) 51 | include_directories(${CMAKE_SOURCE_DIR}/third_party/ddk_${DDK_Version}/include/third_party/opencv/include) 52 | 53 | link_directories(${CMAKE_SOURCE_DIR}/third_party/ApiGateway/lib/${LIB_DIR}) 54 | link_directories(${CMAKE_SOURCE_DIR}/third_party/srslibrtmp/lib/${LIB_DIR}) 55 | link_directories(${CMAKE_SOURCE_DIR}/third_party/python/lib/${LIB_DIR}) 56 | link_directories(${CMAKE_SOURCE_DIR}/third_party/curl/lib/${LIB_DIR}) 57 | link_directories(${CMAKE_SOURCE_DIR}/third_party/ffmpeg/lib/${LIB_DIR}) 58 | link_directories(${CMAKE_SOURCE_DIR}/third_party/${JsonLib}/lib/${LIB_DIR}) 59 | link_directories(${CMAKE_SOURCE_DIR}/third_party/openssl/lib/${LIB_DIR}) 60 | link_directories(${CMAKE_SOURCE_DIR}/third_party/${log4cpluslib}/lib/${LIB_DIR}) 61 | link_directories(${CMAKE_SOURCE_DIR}/third_party/nanomsg/lib/${LIB_DIR}) 62 | link_directories(${CMAKE_SOURCE_DIR}/third_party/json-c/lib/${LIB_DIR}) 63 | link_directories(${CMAKE_SOURCE_DIR}/third_party/zlog/lib/${LIB_DIR}) 64 | link_directories(${CMAKE_SOURCE_DIR}/third_party/ddk_${DDK_Version}/lib/host/${LIB_DIR}) 65 | link_directories(${CMAKE_SOURCE_DIR}/third_party/boost/lib/${LIB_DIR}) 66 | link_directories(${CMAKE_SOURCE_DIR}/hilens_media/lib/${LIB_DIR}) 67 | link_directories(${CMAKE_SOURCE_DIR}/common/lib/${LIB_DIR}) 68 | link_directories(${CMAKE_SOURCE_DIR}/hilens_security/lib/${LIB_DIR}) 69 | 70 | add_subdirectory(libhilens) 71 | add_subdirectory(python) 72 | -------------------------------------------------------------------------------- /HiLens_framework/HiLens Framework SDK.MD: -------------------------------------------------------------------------------- 1 | # Huawei HiLens Framework 2 | Huawei HiLens Framework开发工具包(Huawei HiLens Framework SDK,Huawei HiLens Framework Software Development Kit)是HiLens Kit上运行的HiLens Framework的c++开发包,使用户可以开发c++版本的技能并在HiLens Kit上运行。 3 | 4 | ## Huawei HiLens Framework 简介 5 | 6 | Huawei HiLens Framework通过封装底层接口、实现常用的管理功能,让开发者可以在Huawei HiLens管理控制台上方便地开发技能,培育AI生态。 7 | Huawei HiLens Framework的分层结构如图: 8 |
9 | 10 |
11 | Huawei HiLens Framework封装了底层的多媒体处理库(摄像头/麦克风驱动模块Media_mini),以及D芯片相关的图像处理库(DVPP)和模型管理库(ModelManager),另外开发者也可以使用熟悉的视觉处理库OpenCV。在此之上,Huawei HiLens Framework提供了以下6个模块供开发者使用,方便开发诸如人形检测、人脸识别、疲劳驾驶检测等技能,模块说明如表所示: 12 | 13 | 14 | | 序号 | 模块 | 功能 | 15 | | --- | --- | --- | 16 | | 1 | Input Manager | 负责视频、音频等输入数据的接入管理| 17 | | 2 | Media Processor | 负责视频、音频等媒体数据的处理 | 18 | | 3 | Model Manager | 负责模型的初始化与推断任务 | 19 | | 4 | Output Manager | 负责流、文件、消息通知等输出任务的管理 | 20 | | 5 | Resource Manager | 负责文件、图片、模型等资源的路径管理 | 21 | | 6 | Logging System | 负责日志系统管理 | 22 | 23 | ## 环境准备 24 | 25 | ### 环境搭建 26 | 27 | 1. 查看您的编译机Linux系统环境。 28 | 执行uname -a可查看Linux系统信息,例如查看x86_64的ubuntu系统信息: 29 | Linux ubuntu 4.4.0-144-generic #170-Ubuntu SMP Thu Mar 14 11:56:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux 30 | 2. 查看端侧设备HiLens Kit的系统环境。 31 | 登录端侧设备的系统环境请参见使用SSH连接到HiLens Kit。 32 | 例执uname -a,可得如下HiLens Kit系统环境: 33 | Linux Euler 4.19.36-vhulk1907.1.0.h448.eulerosv2r8.aarch #1 SMP Mon Jul 22 00.00.00 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux 34 | 3. 下载交叉编译工具,并解压下载的压缩包。 35 | 如果您的编译机是x86_64的Linux系统,可以直接下载我们提供的交叉编译工具,里面已经包含了HiLens Kit上需要的库。 36 | 4. 进入交叉编译工具目录后,执行指令pwd获取路径位置,编译时设置编译器路径。 37 | 如果您的编译机是x86_64的Linux系统,路径位置是“.../aarch64-linux-gnu-gcc-7.3.0”,则编译时设置路径为: 38 | export CC=".../aarch64-linux-gnu-gcc-7.3.0/bin/aarch64-linux-gnu-gcc" 39 | export CXX=".../aarch64-linux-gnu-gcc-7.3.0/bin/aarch64-linux-gnu-g++" 40 | 详细的编译指导请参考步骤6中的示例代码。 41 | 5. 下载Huawei HiLens Framework SDK开发包:“cloud-c-sdk-HiLensFramework-1.0.4.tar.gz”,并解压,重命名文件名。 42 | Huawei HiLens Framework SDK软件包下载地址为:https://hilens-framework-sdk-demo.obs.cn-north-1.myhuaweicloud.com/sdk/cloud-c-sdk-HiLensFramework-1.0.4.tar.gz 43 | 6. 参考示例程序和接口调用说明进行代码开发,编译指导和示例代码说明,详见示例代码中的“README.md”。 44 | Huawei HiLens Framework示例代码下载地址为:https://hilens-framework-sdk-demo.obs.cn-north-1.myhuaweicloud.com/demo/license-plate-recognition-demo.zip 45 | 46 | *Note* : 47 | 48 | 1. 搭建环境时,下载SDK开发包和参考示例程序进行代码开发必须在编译机上进行安装、调试。 49 | 2. 开发过程中,您有任何问题可以在Huawei HiLens服务论坛中发帖求助 50 | 51 | ## 初始化 HiLens Framework 52 | 53 | 该接口用于初始化HiLens Framework。在调用HiLens Framework的其他接口之前,需要先做全局初始化。 54 | 55 | * 接口调用 56 | 57 | ``` 58 | HiLensEC hilens::Init(const std::string & verify) 59 | ``` 60 | 61 | * 参数说明 62 | 63 | | 参数名 | 说明| 64 | | --- | --- | 65 | |verify | 应与Huawei HiLens管理控制台上新建技能时,所填写的“基本信息”中的“检验值”一致。如果不一致,HiLens Framework会强制技能停止。| 66 | 67 | * 返回值 68 | 69 | HiLensEC,错误码。0为成功,其他为失败。 -------------------------------------------------------------------------------- /HiLens_framework/HiLens_Framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/HiLens_Framework.png -------------------------------------------------------------------------------- /HiLens_framework/VERSION: -------------------------------------------------------------------------------- 1 | 1.1.0 2 | -------------------------------------------------------------------------------- /HiLens_framework/common/include/apigateway/RequestParams.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_REQUESTPARAMS_H_ 18 | #define SRC_REQUESTPARAMS_H_ 19 | #include 20 | #include 21 | #include "header.h" 22 | 23 | class RequestParams { 24 | public: 25 | RequestParams(); 26 | RequestParams(std::string method, std::string host, std::string uri, std::string queryParams); 27 | RequestParams(std::string method, std::string host, std::string uri, std::string queryParams, std::string payload); 28 | virtual ~RequestParams(); 29 | 30 | const std::string getMethod(); 31 | const std::string getHost(); 32 | const std::string getUri(); 33 | const std::string getQueryParams(); 34 | const std::string getPayload(); 35 | const std::set
*getHeaders(); 36 | 37 | void addHeader(Header &header); 38 | void addHeader(std::string key, std::string value); 39 | std::string initHeaders(); 40 | 41 | private: 42 | /* HTTP Request Parameters */ 43 | std::string mMethod; 44 | std::string mHost; 45 | std::string mUri; 46 | std::string mQueryParams; 47 | std::string mPayload; 48 | 49 | std::set
mHeaders; 50 | }; 51 | 52 | #endif /* SRC_REQUESTPARAMS_H_ */ 53 | -------------------------------------------------------------------------------- /HiLens_framework/common/include/apigateway/constants.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_CONSTANTS_H_ 18 | #define SRC_CONSTANTS_H_ 19 | 20 | #include 21 | namespace defaults { 22 | static const std::string sdk_signing_algorithm = "SDK-HMAC-SHA256"; 23 | static const std::string dateFormat = "X-Sdk-Date"; 24 | static const std::string host = "Host"; 25 | } 26 | 27 | #endif /* SRC_CONSTANTS_H_ */ 28 | -------------------------------------------------------------------------------- /HiLens_framework/common/include/apigateway/hasher.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_HASHER_H_ 18 | #define SRC_HASHER_H_ 19 | 20 | #include 21 | #include "constants.h" 22 | 23 | class Hasher { 24 | public: 25 | Hasher(); 26 | ~Hasher(); 27 | const std::string hexEncode(unsigned char *md, size_t len); 28 | int hashSHA256(const std::string &str, int len, unsigned char *hash); 29 | unsigned char *hmac(const void *key, unsigned int keyLength, const std::string &data); 30 | }; 31 | 32 | #endif /* SRC_HASHER_H_ */ 33 | -------------------------------------------------------------------------------- /HiLens_framework/common/include/apigateway/header.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_HEADER_H_ 18 | #define SRC_HEADER_H_ 19 | 20 | #include 21 | #include 22 | #include "utils.h" 23 | 24 | class Header { 25 | public: 26 | Header(const std::string key) 27 | { 28 | mKey = key; 29 | } 30 | 31 | Header(const std::string &key, const std::string &value) 32 | { 33 | mKey = key; 34 | mValues = value; 35 | } 36 | 37 | std::string getKey() 38 | { 39 | return mKey; 40 | } 41 | 42 | const std::string &getValue() 43 | { 44 | return mValues; 45 | } 46 | 47 | void setValue(std::string value) 48 | { 49 | mValues = value; 50 | } 51 | 52 | bool operator < (const Header &r) const 53 | { 54 | if (toLowerCaseStr(this->mKey).compare(toLowerCaseStr(r.mKey)) < 0) { 55 | return true; 56 | } else { 57 | return false; 58 | } 59 | } 60 | ~Header() {} 61 | 62 | private: 63 | std::string mKey; 64 | std::string mValues; 65 | }; 66 | 67 | 68 | #endif /* SRC_HEADER_H_ */ 69 | -------------------------------------------------------------------------------- /HiLens_framework/common/include/apigateway/signer.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_SIGNER_H_ 18 | #define SRC_SIGNER_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "header.h" 27 | #include "hasher.h" 28 | #include "RequestParams.h" 29 | 30 | class Signer { 31 | public: 32 | Signer(); 33 | Signer(std::string appKey, std::string appSecret); 34 | ~Signer(); 35 | 36 | /* Task 1: Get Canonicalized Request String */ 37 | const std::string getCanonicalRequest(std::string signedHeaders, std::string method, std::string uri, 38 | std::string query, const std::set
*headers, std::string payload); 39 | 40 | const std::string getCanonicalURI(std::string &uri); 41 | const std::string getCanonicalQueryString(std::map &queryParams); 42 | const std::string getCanonicalQueryString(std::map> &queryParams); 43 | const std::string getCanonicalQueryString(std::string &queryParams); 44 | const std::string getCanonicalHeaders(const std::set
*headers); 45 | const std::string getSignedHeaders(const std::set
*headers); 46 | const std::string getHexHash(std::string &payload); 47 | 48 | /* Task 2: Get String to Sign */ 49 | const std::string getStringToSign(std::string algorithm, std::string date, std::string canonicalRequest); 50 | 51 | /* Task 3: Calculate the Signature */ 52 | const std::string getSignature(const char *signingKey, const std::string &stringToSign); 53 | 54 | 55 | // One stroke create signature 56 | const std::string createSignature(RequestParams *request); 57 | 58 | private: 59 | /* Credentials */ 60 | std::string mAppKey; 61 | std::string mAppSecret; 62 | Hasher *hasher; 63 | }; 64 | 65 | #endif /* SRC_SIGNER_H_ */ 66 | -------------------------------------------------------------------------------- /HiLens_framework/common/include/apigateway/utils.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_UTILS_H_ 18 | #define SRC_UTILS_H_ 19 | 20 | #include 21 | #include 22 | 23 | std::string trim(const std::string &str); 24 | std::string toLowerCaseStr(std::string str); 25 | std::string toISO8601Time(std::time_t &time); 26 | std::string uriDecode(std::string &str); 27 | std::string uriEncode(const std::string &str, bool path = false); 28 | 29 | #endif /* SRC_UTILS_H_ */ 30 | -------------------------------------------------------------------------------- /HiLens_framework/common/include/hilens_errorcode.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_ERROR_CODE_H 18 | #define HILENS_ERROR_CODE_H 19 | 20 | namespace hilens { 21 | const int HILENS_OK = 0; 22 | 23 | // common错误码 24 | const int ERROR_GENERAL = 1; // 通用错误 25 | const int ERROR_READ_FILE_FAILED = 2; 26 | const int ERROR_MEMORY_ALLOC = 3; 27 | const int ERROR_FSEEK_FILE = 4; 28 | 29 | // ffmpeg错误码 30 | const int ERROR_FFMPEG_AVFORMAT_INIT = 101; 31 | const int ERROR_FFMPEG_BITSTREAMFILTER = 102; 32 | 33 | // mp4 reader错误码 34 | const int ERROR_DECODE_FRAME_SIZE = 201; 35 | } // namespace hilens 36 | 37 | #endif -------------------------------------------------------------------------------- /HiLens_framework/common/include/hstring.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_HSTRING_H 18 | #define HILENS_HSTRING_H 19 | 20 | namespace hilens { 21 | class Hstring { 22 | public: 23 | Hstring(); 24 | virtual ~Hstring(); 25 | 26 | // move constructor 27 | Hstring(Hstring &&tempStr); 28 | Hstring(const Hstring &hstr); 29 | Hstring(const char *cstr); 30 | Hstring(const char *cstr, unsigned long len); 31 | 32 | Hstring &append(const Hstring &hstr); 33 | Hstring &operator = (const Hstring &right); 34 | Hstring &operator = (Hstring &&right); 35 | 36 | Hstring operator + (const Hstring &right); 37 | Hstring &operator += (const Hstring &right); 38 | 39 | unsigned long length() const; 40 | const char *c_str() const; 41 | bool empty() const; 42 | 43 | protected: 44 | char *data; 45 | unsigned long len; 46 | }; 47 | } // namespace hilens 48 | #endif 49 | -------------------------------------------------------------------------------- /HiLens_framework/common/include/message_mgr.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_MESSAGE_MGR_H 18 | #define COMMON_MESSAGE_MGR_H 19 | 20 | #ifndef SF_OFFLINE 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "wsclient.h" 28 | #include "../libhilens/BlockingQueue.h" 29 | 30 | namespace common { 31 | class TimeoutMsg { 32 | public: 33 | TimeoutMsg() 34 | { 35 | createTime = Time::now(); 36 | } 37 | virtual ~TimeoutMsg() {} 38 | static const int SECOND_TIME_MS = 1000; 39 | static const int TIME_OUT = 10; 40 | using Time = std::chrono::high_resolution_clock; 41 | using ms = std::chrono::duration>; 42 | using elaspms = std::chrono::duration; 43 | virtual bool IsMessageTimeOut() 44 | { 45 | elaspms fs = Time::now() - createTime; 46 | double timeUsed = std::chrono::duration_cast(fs).count(); 47 | return (int)(timeUsed / SECOND_TIME_MS) >= TIME_OUT; 48 | } 49 | 50 | protected: 51 | std::chrono::system_clock::time_point createTime; 52 | }; 53 | 54 | class MessageInfo : public TimeoutMsg { 55 | public: 56 | MessageInfo(std::function cb) 57 | { 58 | callback = cb; 59 | } 60 | virtual ~MessageInfo() {} 61 | std::function callback; 62 | }; 63 | class MessageMgr { 64 | public: 65 | static MessageMgr &Instance(); 66 | virtual ~MessageMgr(); 67 | 68 | /* * 69 | * @brief 发送消息,需转发到云测 70 | * 71 | * @param msg 消息内容 72 | * @param length 消息长度 73 | * @param callback 回调 74 | * 75 | * @return int 0为成功 76 | */ 77 | int Send(const char *msg, int length, std::function callback = NULL); 78 | 79 | void OnMessage(const char *msg, int length, const std::string &uuid); 80 | 81 | private: 82 | MessageMgr(); 83 | MessageMgr(MessageMgr &); 84 | std::string Getuuid(); 85 | void ClearOldMsg(); 86 | 87 | private: 88 | std::map> msgMap; 89 | std::mutex mapMutex; 90 | }; 91 | } 92 | #endif // SF_OFFLINE 93 | #endif // COMMON_MESSAGE_MGR_H -------------------------------------------------------------------------------- /HiLens_framework/common/include/sf_common.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SF_COMMIN_H 18 | #define SF_COMMIN_H 19 | 20 | // C释放内存 21 | #define SF_FREE(p) do { \ 22 | if (p != NULL) { \ 23 | free(p); \ 24 | } \ 25 | p = NULL; \ 26 | } while (0) 27 | 28 | // C++释放内存 29 | #define SF_DELETE(p) do { \ 30 | if (p != nullptr) { \ 31 | delete p; \ 32 | } \ 33 | p = nullptr; \ 34 | } while (0) 35 | 36 | #define HILENS_OK 0 37 | #define HILENS_ERROR 1 38 | 39 | namespace hilens { 40 | class SFCommon { 41 | public: 42 | static int GetFileSize(const char *fileName); 43 | 44 | static int ReadFile(const char *filePath, unsigned char **fileBuff, int *buffSize); 45 | 46 | static int WriteFile(const char *filePath, const unsigned char *fileBuff, int buffSize); 47 | 48 | private: 49 | SFCommon(); 50 | ~SFCommon(); 51 | }; 52 | } // namespace hilens 53 | 54 | #endif -------------------------------------------------------------------------------- /HiLens_framework/common/include/sfw_log.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_SFW_LOG_H 18 | #define COMMON_SFW_LOG_H 19 | 20 | #include 21 | #include "errors.h" 22 | 23 | namespace hilens { 24 | // 日志pattern,此样式的结果类似于:2019-08-13 14:25:12,996[12345][INFO][SFW] Hello 25 | #define LOG_LAYOUT "%D{%Y-%m-%d %H:%M:%S,%q}[%i][%-5p][SFW] %m%n" 26 | #define SFW_LOGGER_NAME "sfw_logger" 27 | 28 | HiLensEC InitSFWLogger(); 29 | 30 | #define LOG_DEBUG(...) LOG4CPLUS_DEBUG_FMT(SFW_LOGGER_NAME, __VA_ARGS__) 31 | #define INFO(...) LOG4CPLUS_INFO_FMT(SFW_LOGGER_NAME, __VA_ARGS__) 32 | #define WARN(...) LOG4CPLUS_WARN_FMT(SFW_LOGGER_NAME, __VA_ARGS__) 33 | #define ERROR(...) LOG4CPLUS_ERROR_FMT(SFW_LOGGER_NAME, __VA_ARGS__) 34 | } 35 | #endif -------------------------------------------------------------------------------- /HiLens_framework/common/include/utils.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_UTILS_H 18 | #define COMMON_UTILS_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace hilens { 25 | enum HttpCode { 26 | HTTP_CODE_OK = 200, 27 | HTTP_CODE_MULTI = 300, 28 | HTTP_CODE_UNAUTHORIZED = 401 29 | }; 30 | 31 | // 字符串转Json对象 32 | bool String2Json(const std::string &str, Json::Value &obj, std::string &errorMsg); 33 | 34 | // Json对象转字符串 35 | void Json2String(const Json::Value &obj, std::string &str); 36 | 37 | // 读取文件到Json对象 38 | bool File2Json(const std::string &filepath, Json::Value &obj, std::string &errorMsg); 39 | 40 | // Json对象保存到文件 41 | bool Json2File(const Json::Value &obj, const std::string &filepath, std::string &errorMsg); 42 | 43 | // 一个CURL响应回调函数,可将body写入一个std::string中。userp为该string的指针 44 | size_t CurloptWriteFunction(const void *buffer, size_t size, size_t nmemb, void *userp); 45 | 46 | template std::shared_ptr MakeSharedArray(size_t size) 47 | { 48 | // default_delete是STL中的默认删除器 49 | return std::shared_ptr(new T[size](), std::default_delete()); 50 | } 51 | 52 | template std::unique_ptr MakeUniqueArray(size_t size) 53 | { 54 | // default_delete是STL中的默认删除器 55 | return std::unique_ptr(new T[size]()); 56 | } 57 | // 获取技能ID 58 | const char *GetSkillID(); 59 | 60 | /* * 61 | * @brief 执行有返回值的系统命令 62 | * 63 | * @param cmd 命令 64 | * @param result 处理结果 65 | * @param retval 返回值 66 | */ 67 | void ExecutePopen(const char *cmd, std::string &result, std::string &retval); 68 | 69 | /* * 70 | * @brief 执行系统命令 71 | * 72 | * @param cmd 命令 73 | * @param result 处理结果 74 | * 75 | */ 76 | void ExecutePopen(const char *cmd, std::string &result); 77 | 78 | /* * 79 | * @brief 执行系统命令 80 | * 81 | * @param cmd 命令 82 | * @param onResponse 响应 83 | * 84 | */ 85 | void ExecutePopen(const char *cmd, std::function onResponse); 86 | } // namespace hilens 87 | #endif // COMMON_UTILS_H -------------------------------------------------------------------------------- /HiLens_framework/common/lib/libhilens_common.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/common/lib/libhilens_common.so -------------------------------------------------------------------------------- /HiLens_framework/deploy/decode.graph: -------------------------------------------------------------------------------- 1 | graphs { 2 | graph_id: replace_graph_id 3 | priority: 1 4 | engines { 5 | id: 1000 6 | engine_name: "SrcEngine" 7 | side: HOST 8 | thread_num: 1 9 | } 10 | engines { 11 | id: 1003 12 | engine_name: "DvppEngine" 13 | side: DEVICE 14 | thread_num: 1 15 | so_name: "/home/hilens/skillframework/lib/infer_engine.so" 16 | } 17 | engines { 18 | id: 1004 19 | engine_name: "DestDvppEngine" 20 | side: HOST 21 | thread_num: 1 22 | } 23 | connects { 24 | src_engine_id: 1000 25 | src_port_id: 0 26 | target_engine_id: 1003 27 | target_port_id: 0 28 | } 29 | connects { 30 | src_engine_id: 1003 31 | src_port_id: 0 32 | target_engine_id: 1004 33 | target_port_id: 0 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /HiLens_framework/deploy/encode.graph: -------------------------------------------------------------------------------- 1 | graphs { 2 | graph_id: replace_graph_id 3 | priority: 1 4 | 5 | engines { 6 | id: 1000 7 | engine_name: "EncodeSrcEngine" 8 | side: HOST 9 | thread_num: 1 10 | } 11 | engines { 12 | id: 1002 13 | engine_name: "EncodeEngine" 14 | side: DEVICE 15 | thread_num: 1 16 | so_name: "/home/hilens/skillframework/lib/infer_engine.so" 17 | } 18 | engines { 19 | id: 1004 20 | engine_name: "DestDvppEngine" 21 | side: HOST 22 | thread_num: 1 23 | } 24 | 25 | connects { 26 | src_engine_id: 1000 27 | src_port_id: 0 28 | target_engine_id: 1002 29 | target_port_id: 0 30 | } 31 | connects { 32 | src_engine_id: 1002 33 | src_port_id: 0 34 | target_engine_id: 1004 35 | target_port_id: 0 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /HiLens_framework/deploy/infer.graph: -------------------------------------------------------------------------------- 1 | graphs { 2 | graph_id: replace_graph_id 3 | priority: 1 4 | engines { 5 | id: 1001 6 | engine_name: "InferEngine" 7 | side: DEVICE 8 | thread_num: 1 9 | so_name: "/home/hilens/skillframework/lib/infer_engine.so" 10 | ai_config{ 11 | items{ 12 | name: "model_path" 13 | value: "replace_graph_model" 14 | } 15 | } 16 | } 17 | engines { 18 | id: 1002 19 | engine_name: "DestEngine" 20 | side: HOST 21 | thread_num: 1 22 | so_name: "/home/hilens/skillframework/lib/relay_engine.so" 23 | } 24 | connects { 25 | src_engine_id: 1001 26 | src_port_id: 0 27 | target_engine_id: 1002 28 | target_port_id: 0 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /HiLens_framework/deploy/logger.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | file perms = 600 3 | [formats] 4 | # default = "%d[%-5V][%p:%t][%f:%U:%L]%m%n" 5 | default = "%d.%ms[%V](%p-%f:%L)%m%n" 6 | [rules] 7 | SCC.INFO "/home/log/alog/hilens/skillframework/scc.log",5MB * 20 ~ "/home/log/alog/hilens/skillframework/scc.log.#2r"; default 8 | PPC.INFO "/home/log/alog/hilens/skillframework/ppc.log",1MB * 5 ~ "/home/log/alog/hilens/skillframework/ppc.log.#2r"; default 9 | media.INFO "/home/log/alog/hilens/skillframework/hilens_media.log",5MB * 10 ~ "/home/log/alog/hilens/skillframework/hilens_media-%d(%Y%m%d).#2s.log"; default 10 | -------------------------------------------------------------------------------- /HiLens_framework/deploy/scc.conf: -------------------------------------------------------------------------------- 1 | [CRYPTO] 2 | primaryKeyStoreFile =/home/hilens/hda/etc/ks/primary.ks 3 | standbyKeyStoreFile =/home/hilens/hda/etc/ks/standby.ks 4 | backupFolderName=/home/hilens/hda/etc/ks/backup/ 5 | logCfgFile=/home/hilens/skillframework/configs/logger.conf 6 | logCategory=SCC 7 | domainCount=8 8 | [PWDPOLICY] 9 | logCfgFile=/home/hilens/skillframework/configs/logger.conf 10 | logCategory=PPC 11 | -------------------------------------------------------------------------------- /HiLens_framework/deploy/sfw.conf: -------------------------------------------------------------------------------- 1 | # skillframework配置文件 2 | 3 | # 日志级别,可选TRACE, DEBUG, INFO, WARN, ERROR, FATAL。默认为INFO 4 | log_level=INFO 5 | -------------------------------------------------------------------------------- /HiLens_framework/engine/lib/infer_engine.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/engine/lib/infer_engine.so -------------------------------------------------------------------------------- /HiLens_framework/engine/lib/relay_engine.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/engine/lib/relay_engine.so -------------------------------------------------------------------------------- /HiLens_framework/hda/hdacli/python2/hdacli_wrap.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * This file was automatically generated by SWIG (http://www.swig.org). 3 | * Version 3.0.12 4 | * 5 | * This file is not intended to be easily readable and contains a number of 6 | * coding conventions designed to improve portability and efficiency. Do not make 7 | * changes to this file unless you know what you are doing--modify the SWIG 8 | * interface file instead. 9 | * ----------------------------------------------------------------------------- */ 10 | 11 | #ifndef SWIG_hdacli_internal_WRAP_H_ 12 | #define SWIG_hdacli_internal_WRAP_H_ 13 | 14 | #include 15 | #include 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /HiLens_framework/hilens_media/include/HiLensAudioRpc.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_AUDIO_RPC_H 18 | #define HILENS_AUDIO_RPC_H 19 | 20 | #include "MediaComm.h" 21 | 22 | #ifdef __cplusplus 23 | #if __cplusplus 24 | extern "C" { 25 | #endif 26 | #endif /* __cplusplus */ 27 | 28 | // 服务端启动RPC,接收处理音频操作 29 | int StartAudioRPCServer(); 30 | 31 | int AudioRpcInit(); 32 | int AudioRpcDeInit(); 33 | int AudioRpcRead(unsigned char *buffer, int len, int n); 34 | 35 | #ifdef __cplusplus 36 | #if __cplusplus 37 | } 38 | #endif 39 | #endif /* __cplusplus */ 40 | 41 | #endif /* HILENS_RPC_H */ 42 | -------------------------------------------------------------------------------- /HiLens_framework/hilens_media/lib/libhilens_media.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/hilens_media/lib/libhilens_media.so -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/include/auth.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_SECURITY_AUTH_H 18 | #define HILENS_SECURITY_AUTH_H 19 | 20 | #ifndef SF_OFFLINE 21 | 22 | #include 23 | #include 24 | #include "hstring.h" 25 | #include 26 | #include 27 | #include "json/json.h" 28 | #include "check_license.h" 29 | 30 | namespace hilens { 31 | /* * 32 | * 已冻结 33 | */ 34 | #define FREEZE 1 35 | class Auth { 36 | public: 37 | static Auth &Instance(); 38 | 39 | virtual ~Auth(); 40 | 41 | void OnTokenQuery(const Json::Value &doc); 42 | 43 | /* * 44 | * @brief 从agent获取临时ak sk token 45 | * 46 | * @param ak 出参,access 47 | * @param sk 出参,secret 48 | * @param token 出参,securityTokens 49 | * @return int 0为成功 50 | */ 51 | int Get(Hstring &ak, Hstring &sk, Hstring &token); 52 | 53 | /* * 54 | * @brief 运行认证License的线程 55 | */ 56 | void RunCheckLicenseThread(const std::string &verify); 57 | 58 | int GetChannelLimit(); 59 | 60 | /* * 61 | * @brief 获取model key 62 | * 63 | * @param outModelKey 出参,model key 64 | * @return int 0为成功 65 | */ 66 | int GetModelKey(Hstring &outModelKey); 67 | 68 | private: 69 | Auth(); 70 | Auth(const Auth &); 71 | 72 | void RequestAuth(); 73 | 74 | /* * 75 | * @brief 向Console发请求认证技能 76 | */ 77 | void CheckLicenseThread(const std::string &verify); 78 | bool RequestLicense(const std::string &verify); 79 | 80 | private: 81 | std::thread checkThread; 82 | std::atomic_bool keepCheck; 83 | 84 | std::atomic_int licenseValidTime; 85 | std::atomic_int channelLimit; 86 | std::atomic_bool checkFlag; 87 | 88 | std::mutex authmtx; 89 | bool requestTokening; 90 | Hstring ak; 91 | Hstring sk; 92 | Hstring token; 93 | time_t expiryTime; 94 | std::string measureType; 95 | 96 | /* * 97 | * 对应的LG证书 98 | */ 99 | common::LicenseSignatureStatus licSignStatus; 100 | Hstring modelKey; 101 | int freeze; 102 | }; 103 | } 104 | 105 | #endif // SF_OFFLINE 106 | #endif // HILENS_SECURITY_AUTH_H -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/include/check_license.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_SECURITY_CHECK_LICENSE_H 18 | #define HILENS_SECURITY_CHECK_LICENSE_H 19 | 20 | #ifndef SF_OFFLINE 21 | #include 22 | #include "json/json.h" 23 | namespace common { 24 | typedef enum LICENSE_SIGNATURE_STATUS { 25 | /* * 26 | * 验证成功 27 | */ 28 | LSS_SUCCESS = 0, 29 | /* * 30 | * 验证失败 31 | */ 32 | LSS_FAIL, 33 | } LicenseSignatureStatus; 34 | class CheckLicense { 35 | public: 36 | CheckLicense(); 37 | ~CheckLicense(); 38 | 39 | bool RequestLicense(const std::string &verify, const Json::Value &config, int &licenseValidTime, int &channelLimit, 40 | int &freeze, LicenseSignatureStatus &licSignStatus, std::string &modelKey); 41 | 42 | private: 43 | bool RequestFromHost(const std::string &verify, const Json::Value &config, int &licenseValidTime, int &channelLimit, 44 | int &freeze, LicenseSignatureStatus &licSignStatus, std::string &modelKey); 45 | bool CheckLicenseResult(const std::string &license, int &licenseValidTime, int &channelLimit, int &freeze, 46 | LicenseSignatureStatus &licSignStatus, std::string &modelKey); 47 | bool LicenseSignatureVerify(const std::string &licenseSignature); 48 | }; 49 | } // namespace common 50 | 51 | #endif // SF_OFFLINE 52 | #endif // HILENS_SECURITY_CHECK_LICENSE_H -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/include/conf.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_SECURITY_CONF_H 18 | #define HILENS_SECURITY_CONF_H 19 | 20 | #include 21 | #include 22 | #include "errors.h" 23 | #include "hstring.h" 24 | #include "utils.h" 25 | 26 | #define SFW_CONF_PATH "/home/hilens/skillframework/configs/sfw.conf" 27 | #define DEVICE_INFO "/home/hilens/hda/etc/device_info.conf" 28 | #define HDA_CONF_PATH "/home/hilens/hda/etc/hda.conf" 29 | #define OBS_STORAGE_CONF_PATH "/home/hilens/hda/etc/obs_storage_path" 30 | 31 | namespace hilens { 32 | class Configuration { 33 | public: 34 | // hda的配置文件 35 | static Configuration hdaConfig; 36 | // 设备信息文件 37 | static Configuration deviceInfo; 38 | // SFW的配置文件 39 | static Configuration sfwConfig; 40 | // 云侧接口地址 41 | static Configuration api; 42 | // 加载hdaConfig和deviceInfo 43 | static bool Init(); 44 | 45 | // 根据key获取value,如果没有会自动插入空字符串到map然后返回 46 | std::string &operator[](const std::string &key); 47 | // 检查是否有某配置项 48 | bool Has(const std::string &key); 49 | 50 | protected: 51 | int Load(const char *filepath); 52 | std::map data; 53 | int Parse(const std::string &line); 54 | }; 55 | 56 | // 设备配置 57 | class DeviceConfig { 58 | public: 59 | // 加载设备配置 60 | static HiLensEC Init(); 61 | static bool HasCamera(const std::string &name); 62 | static Hstring GetCameraURL(const std::string &name); 63 | 64 | private: 65 | struct IPCMeta { 66 | Hstring username; 67 | Hstring password; 68 | Hstring protocol; 69 | Hstring urn; 70 | }; 71 | static std::map cameraList; 72 | }; 73 | 74 | // 上传到obs桶的配置 75 | class OBSConfig { 76 | public: 77 | static OBSConfig &Instance(); 78 | HiLensEC Init(); 79 | std::string Bucket(); 80 | std::string Domain(); 81 | std::string Prefix(); 82 | 83 | private: 84 | OBSConfig() {} 85 | OBSConfig(const OBSConfig &); 86 | std::string bucket; 87 | std::string domain; 88 | std::string prefix; 89 | }; 90 | } // namespace hilens 91 | #endif // HILENS_SECURITY_CONF_H 92 | -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/include/device_utils.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_SECURITY_DEVICE_UTILS_H 18 | #define HILENS_SECURITY_DEVICE_UTILS_H 19 | 20 | #include 21 | #include 22 | 23 | namespace hilens { 24 | // 字符串hash 25 | std::string HashString(const unsigned char *key, int keyLength, const char *data); 26 | 27 | // 获取设备ID 28 | std::string GetDeviceID(); 29 | } // namespace hilens 30 | #endif // HILENS_SECURITY_DEVICE_UTILS_H -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/include/hilens_security.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_SECURITY_H 18 | #define HILENS_SECURITY_H 19 | 20 | #include "errors.h" 21 | 22 | namespace hilens { 23 | class HilensSecurity { 24 | public: 25 | static HilensSecurity &Instance(); 26 | HiLensEC Init(); 27 | 28 | private: 29 | HilensSecurity(); 30 | HilensSecurity(const HilensSecurity &); 31 | virtual ~HilensSecurity(); 32 | }; 33 | } // namespace hilens 34 | #endif // HILENS_SECURITY_H -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/include/vdecoder.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_SECURITY_VDECODER_H 18 | #define HILENS_SECURITY_VDECODER_H 19 | 20 | #include 21 | #include "vdecfactory.h" 22 | #include 23 | #include "BlockingQueue.h" 24 | #include 25 | #include 26 | namespace hilens { 27 | class VDecoder : public VDecFactoryInterface { 28 | public: 29 | // MPP VPSS组件支持的最小宽高为128像素(高可能可以支持更小,但是意义不大,这里保持和宽的统一) 30 | static const int MIN_WIDTH = 128; 31 | static const int MIN_HEIGHT = 128; 32 | 33 | // MPP VPSS组件的约束:视频宽必须是16的倍数,高必须是2的倍数 34 | // MPP 35 | // VPSS组件图片缓存的宽是32字节对齐的。也就是说视频宽是16的倍数,但是不是32的倍数情况下,图片会padding16像素的黑边 36 | static const int MIN_ALIGN_WIDTH = 16; 37 | static const int MIN_ALGIN_HEIGHT = 2; 38 | static const int ALIGN_MEMORY_WIDTH = 32; 39 | 40 | public: 41 | VDecoder(unsigned int width, unsigned int height, ENCODE_TYPE_E codec); 42 | VDecoder(unsigned int width, unsigned int height, unsigned int destWidth, unsigned int destHeight, 43 | ENCODE_TYPE_E codec); 44 | 45 | int Init(bool bfast); 46 | virtual ~VDecoder(); 47 | 48 | // 输入数据,获得输出数据 49 | virtual void RegisterCallback(std::function cb); 50 | virtual int DecodeFrameBuf(unsigned char *inData, unsigned int inSize); 51 | 52 | private: 53 | MediaHandle handle; 54 | ENCODE_TYPE_E codec; 55 | 56 | unsigned int width; 57 | unsigned int height; 58 | 59 | unsigned int destWidth; 60 | unsigned int destHeight; 61 | unsigned int alignWidth; 62 | std::function decCb; 63 | std::mutex initmtx; 64 | std::atomic_bool running; 65 | std::thread decthread; 66 | void decthreadFunc(); 67 | BlockingQueue decqueue; 68 | bool bIsFast; 69 | 70 | static std::atomic_int g_usedCount; 71 | }; 72 | } // namespace hilens 73 | #endif // HILENS_SECURITY_VDECODER_H 74 | -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/include/vencoder.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_SECURITY_VENCODER_H 18 | #define HILENS_SECURITY_VENCODER_H 19 | 20 | #include 21 | 22 | namespace hilens { 23 | class VEncoder { 24 | public: 25 | VEncoder(); 26 | /* * 27 | * @brief 初始化视频编码器 28 | * 29 | * @param w 视频宽度(像素) 30 | * @param h 视频高度(像素) 31 | * @return int 初始化结果 32 | */ 33 | int Init(int w, int h); 34 | virtual ~VEncoder(); 35 | /* * 36 | * @brief 编码一帧视频 37 | * 38 | * @param indata 输入视频数据 39 | * @param insize 输入视频数据大小(字节) 40 | * @param outdata 输出视频数据 41 | * @param outsize 输出视频数据大小(字节) 42 | * @return int 编码结果 43 | */ 44 | int EncodeFrame(const unsigned char *indata, unsigned int insize, unsigned char **outdata, unsigned int *outsize); 45 | 46 | private: 47 | MediaHandle handle; 48 | }; 49 | } // namespace hilens 50 | #endif // HILENS_SECURITY_VENCODER_H -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/lib/libhilens_security.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/hilens_security/lib/libhilens_security.so -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/lib/libsc-common.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/hilens_security/lib/libsc-common.so -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/lib/libsc-kmc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/hilens_security/lib/libsc-kmc.so -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/lib/libsc-pwdpolicy.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/hilens_security/lib/libsc-pwdpolicy.so -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/lib/libsc-sdp.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/hilens_security/lib/libsc-sdp.so -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/lib/libsc-secrypto.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/hilens_security/lib/libsc-secrypto.so -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/lib/libsc-securec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/hilens_security/lib/libsc-securec.so -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/lib/libsc-zlog.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/hilens_security/lib/libsc-zlog.so -------------------------------------------------------------------------------- /HiLens_framework/hilens_security/lib/libsc-zlog.so.1.2: -------------------------------------------------------------------------------- 1 | libsc-zlog.so -------------------------------------------------------------------------------- /HiLens_framework/include/audio_capture.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_INCLUDE_AUDIO_CAPTURE_H 18 | #define HILENS_INCLUDE_AUDIO_CAPTURE_H 19 | 20 | #include 21 | #include 22 | #include "media_process.h" 23 | 24 | /* 一次读取最大音频帧数,供python接口 */ 25 | #define MAX_FRAME_NUM_ONCE (512) 26 | 27 | typedef struct AudioFrame_s { 28 | std::shared_ptr data; 29 | unsigned int size; 30 | } AudioFrame; 31 | 32 | struct AudioProperties { 33 | unsigned int enSamplerate; /* sample rate */ 34 | unsigned int enBitwidth; /* bitwidth */ 35 | unsigned int u32PtNumPerFrm; /* point num per frame (80/160/240/320/480/1024/2048) 36 | (ADPCM IMA should add 1 point, AMR only support 160) */ 37 | }; 38 | 39 | typedef enum audio_input_TYPE_E { 40 | AUDIO_FROM_MIC = 0, 41 | AUDIO_FROM_FILE = 1, 42 | AUDIO_FROM_BUTT 43 | } AUDIO_INPUT_TYPE_E; 44 | 45 | namespace hilens { 46 | /* * 47 | * @brief 音频采集器 48 | * 使用音频采集器来读取MIC 的数据 49 | */ 50 | class AudioCapture { 51 | public: 52 | /* * 53 | * @brief 构造音频采集器(MIC作为输入,必须指定参数) 54 | * @return 音频采集器实例 55 | */ 56 | static std::shared_ptr Create(); 57 | 58 | /* * 59 | * @brief 析构音频采集器(音频文件为输入,参数通过ffmpeg提取头文件获取) 60 | */ 61 | static std::shared_ptr Create(const std::string filePath); 62 | 63 | /* * 64 | * @brief 析构音频采集器 65 | */ 66 | virtual ~AudioCapture() {} 67 | 68 | /* * 69 | * @brief 读取音频帧 70 | * 如果读取发生错误,此接口将会抛出一个std::runtime_error 71 | * @return PCM格式的音频数据 72 | */ 73 | virtual int Read(AudioFrame &frames, int = 1) = 0; 74 | 75 | /* * 76 | * @brief设置音频MIC采样参数,主要是采样率、位宽和单帧采样点数 77 | * 78 | * @return 79 | */ 80 | virtual int SetProperty(const struct AudioProperties &properties) = 0; 81 | virtual int GetProperty(struct AudioProperties &properties) = 0; 82 | 83 | /* * 84 | * @brief设置音频音量 85 | * 86 | * @return 87 | */ 88 | virtual int SetVolume(int volume) = 0; 89 | virtual int GetVolume() = 0; 90 | 91 | protected: 92 | AudioCapture() {} 93 | AudioCapture(const AudioCapture &); 94 | }; 95 | } // namespace hilens 96 | #endif // HILENS_INCLUDE_AUDIO_CAPTURE_H 97 | -------------------------------------------------------------------------------- /HiLens_framework/include/audio_output.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_INCLUDE_AUDIO_OUTPUT_H 18 | #define HILENS_INCLUDE_AUDIO_OUTPUT_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include "media_process.h" 24 | #include "audio_capture.h" 25 | 26 | namespace hilens { 27 | /* * 28 | * @brief 使用音频输出口播放音频文件 29 | * @param filePath 播放音频文件路径 30 | * @param vol 播放音量,范围[-121, 6] 31 | * @return HiLensEC 0为成功,其他为失败 32 | */ 33 | HiLensEC PlayAacFile(const std::string filePath, int vol); 34 | /* 35 | * @brief 播音异常处理 36 | */ 37 | void PlayHandleSigno(int signo); 38 | 39 | /* * 40 | * @brief 音频播放 41 | * 使用AuioOutput类来将声音输出到AO接口 */ 42 | class AudioOutput { 43 | public: 44 | /* * 45 | * @brief 构造输出,输入来源是MIC 46 | */ 47 | static std::shared_ptr Create(const struct AudioProperties &property); 48 | 49 | /* * 50 | * @brief 构造输出,输入来源是音频文件 51 | */ 52 | static std::shared_ptr Create(const std::string filePath); 53 | 54 | /* * 55 | * @brief 析构音频播放器 56 | */ 57 | virtual ~AudioOutput() {} 58 | 59 | /* * 60 | * @brief 播放音频来源MIC 61 | */ 62 | virtual int Play() = 0; 63 | 64 | /* * 65 | * @brief设置音频播放采样率、位宽和单帧采样点数 66 | * 67 | * @return 68 | */ 69 | virtual int SetProperty(const struct AudioProperties &properties) = 0; 70 | virtual int GetProperty(struct AudioProperties &properties) = 0; 71 | 72 | /* * 73 | * @brief设置音频音量 74 | * 75 | * @return 76 | */ 77 | virtual int SetVolume(int volume) = 0; 78 | virtual int GetVolume() = 0; 79 | 80 | 81 | protected: 82 | AudioOutput() {} 83 | AudioOutput(const AudioOutput &); 84 | }; 85 | } // namespace hilens 86 | #endif // HILENS_INCLUDE_AUDIO_OUTPUT_H -------------------------------------------------------------------------------- /HiLens_framework/include/errors.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_INCLUDE_ERRORS_H 18 | #define HILENS_INCLUDE_ERRORS_H 19 | 20 | namespace hilens { 21 | enum HiLensEC { 22 | // / 没有错误 23 | OK = 0, 24 | // / 未知错误 25 | UNKNOWN_ERROR, 26 | // / 初始化CURL错误 27 | INIT_CURL_ERROR, 28 | // / 创建文件夹失败 29 | CREATE_DIR_FAILED, 30 | // / 打开文件失败 31 | OPENFILE_FAILED, 32 | // / 重命名失败 33 | RENAME_FAILED, 34 | // / 文件不存在或无文件访问权限 35 | ACCESS_FILE_FAILED, 36 | // / 无效的BUF 37 | INVALID_BUF, 38 | // / 无法解析,查看网络是否通畅 39 | COULDNT_RESOLVE_HOST, 40 | // / 写错误,检查下载目录是否有写权限,空间是否足够 41 | WRITE_ERROR, 42 | // / 请求超时 43 | TIMEOUT, 44 | // / 认证信息错误,检查ak,sk,token是否有效 45 | AUTH_FAILED, 46 | // / 没有这个对象 47 | NOT_FOUND, 48 | // / 服务端内部错误 49 | SERVER_ERROR, 50 | // / 对象冲突 51 | OBJECT_CONFLICT, 52 | // / 追加失败(比如追加到不可追加的对象上) 53 | APPEND_FAILED, 54 | // / hiai engine发送数据失败,请根据日志来分析具体情况 55 | HIAI_SEND_DATA_FAILED, 56 | // / hiai engine推理错误,请根据日志来分析具体情况(可能是实际输入大小与模型的输入大小不匹配) 57 | HIAI_INFER_ERROR, 58 | // / 图片处理,src尺寸不符合约束条件 59 | INVALID_SRC_SIZE, 60 | // / 图片处理,dst尺寸不符合约束条件 61 | INVALID_DST_SIZE, 62 | // / mpp处理图片失败 63 | MPP_PROCESS_FAILED, 64 | // / WebSocket错误 65 | WEBSOCKET_ERROR, 66 | // / 配置文件错误 67 | CONFIG_FILE_ERROR, 68 | // / 参数有误 69 | INVALID_PARAM, 70 | // / 内部错误,请检查初始化是否失败,结合日志分析 71 | INTERNAL_ERROR, 72 | // / 日志初始化失败 73 | INIT_LOG_ERROR, 74 | // /MIC初始化失败 75 | INIT_MIC_ERROR, 76 | // / AENC初始化失败 77 | INIT_AENC_ERROR, 78 | // / ADEC初始化失败 79 | INIT_ADEC_ERROR, 80 | // / AO初始化失败 81 | INIT_AO_ERROR, 82 | // / 音频文件不支持 83 | AUDIO_CHECK_ERROR, 84 | // / 音频系统初始化失败 85 | AUDIO_SYSTEM_INIT_FAILED, 86 | // / 地址非法 87 | ADDRESS_INVALID, 88 | // / 连接失败 89 | CONNECT_FAIL, 90 | // / SKILL_ID不存在或者非法 91 | SKILL_ID_INVALID, 92 | // / 还没连接 93 | NO_CONNECT, 94 | // / 发送失败 95 | SEND_FAIL, 96 | // / 连接超时 97 | CONNECT_TIMEOUT, 98 | // / 消息过长 99 | MSG_TOO_LONG, 100 | // / 消息非法 101 | MSG_INVALID, 102 | // / 消息队列已满 103 | MSG_QUEUE_FULL, 104 | }; 105 | } 106 | #endif // HILENS_INCLUDE_ERRORS_H -------------------------------------------------------------------------------- /HiLens_framework/include/hilens.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_INCLUDE_HILENS_H 18 | #define HILENS_INCLUDE_HILENS_H 19 | 20 | // 为方便包含,在此头文件中将hilens其他几个头文件包含了 21 | #include "errors.h" 22 | #include "ei_services.h" 23 | #include "log.h" 24 | #include "media_process.h" 25 | #include "model.h" 26 | #include "output.h" 27 | #include "resource.h" 28 | #include "video_capture.h" 29 | #include "audio_capture.h" 30 | #include "audio_output.h" 31 | 32 | namespace hilens { 33 | /* * 34 | * @brief 初始化hilens 35 | * 在调用hilens的接口之前,须先调用hilens::Init()以全局初始化 36 | * @param verify 对应console上创建技能的检验值。 37 | * @return HiLensEC 0为成功,其他为失败 38 | */ 39 | HiLensEC Init(const std::string &verify); 40 | 41 | /* * 42 | * @brief 终止hilens 43 | * 在程序结束时,须调用hilens::Terminate()以释放相关资源 44 | * 45 | * @return HiLensEC 0为成功,其他为失败 46 | */ 47 | HiLensEC Terminate(); 48 | } // namespace hilens 49 | #endif // HILENS_INCLUDE_HILENS_H 50 | -------------------------------------------------------------------------------- /HiLens_framework/include/log.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_INCLUDE_LOG_H 18 | #define HILENS_INCLUDE_LOG_H 19 | 20 | #include 21 | 22 | namespace hilens { 23 | /* * 24 | * @brief 日志级别 25 | */ 26 | enum LogLevel { 27 | TRACE, 28 | DEBUG, 29 | INFO, 30 | WARNING, 31 | ERROR, 32 | FATAL 33 | }; 34 | 35 | /* * 36 | * @brief 打印一条TRACE级别的日志 37 | * @details 可按照printf的风格打印日志 38 | * @param fmt 日志格式 39 | * @param ... 日志的参数 40 | */ 41 | void Trace(const char *fmt, ...); 42 | 43 | /* * 44 | * @brief 打印一条DEBUG级别的日志 45 | * @details 可按照printf的风格打印日志 46 | * @param fmt 日志格式 47 | * @param ... 日志的参数 48 | */ 49 | void Debug(const char *fmt, ...); 50 | 51 | /* * 52 | * @brief 打印一条INFO级别的日志 53 | * @details 可按照printf的风格打印日志 54 | * @param fmt 日志格式 55 | * @param ... 日志的参数 56 | */ 57 | void Info(const char *fmt, ...); 58 | 59 | /* * 60 | * @brief 打印一条WARNING级别的日志 61 | * @details 可按照printf的风格打印日志 62 | * @param fmt 日志格式 63 | * @param ... 日志的参数 64 | */ 65 | void Warning(const char *fmt, ...); 66 | 67 | /* * 68 | * @brief 打印一条ERROR级别的日志 69 | * @details 可按照printf的风格打印日志 70 | * @param fmt 日志格式 71 | * @param ... 日志的参数 72 | */ 73 | void Error(const char *fmt, ...); 74 | 75 | /* * 76 | * @brief 打印一条FATAL级别的日志 77 | * @details 可按照printf的风格打印日志 78 | * @param fmt 日志格式 79 | * @param ... 日志的参数 80 | */ 81 | void Fatal(const char *fmt, ...); 82 | 83 | /* * 84 | * @brief 设置日志级别 85 | * @param level 日志级别 86 | */ 87 | void SetLogLevel(LogLevel level); 88 | } // namespace hilens 89 | #endif // HILENS_INCLUDE_LOG_H -------------------------------------------------------------------------------- /HiLens_framework/include/media_process.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_INCLUDE_MEDIA_PROCESS_H 18 | #define HILENS_INCLUDE_MEDIA_PROCESS_H 19 | 20 | #include 21 | #include 22 | #include "errors.h" 23 | 24 | namespace hilens { 25 | /* * 26 | * @brief 颜色转换码 27 | */ 28 | enum CvtCode { 29 | BGR2YUV_NV12, 30 | RGB2YUV_NV12, 31 | BGR2YUV_NV21, 32 | RGB2YUV_NV21 33 | }; 34 | 35 | /* * 36 | * @brief 转换图片的颜色格式。opencv原生未提供RGB/BGR到NV12/NV21的转换选项,故在这里做补充 37 | * 38 | * @param src 源图 39 | * @param dst 目的图片 40 | * @param code 指定何种转换类型 41 | * @return HiLensEC 0为成功,其他为失败 42 | */ 43 | HiLensEC CvtColor(const cv::Mat &src, cv::Mat &dst, CvtCode code); 44 | 45 | /* * 46 | * @brief 硬件加速的预处理器 47 | */ 48 | class Preprocessor { 49 | public: 50 | /* * 51 | * @brief 构造并初始化一个3559加速的预处理器 52 | * 53 | * @return 成功则返回预处理器的指针,初始化失败则返回nullptr 54 | */ 55 | static std::shared_ptr Create(); 56 | 57 | /* * 58 | * @brief 缩放图片(硬件加速) 59 | * @param src 源图,必须为NV21的格式。宽度范围[64, 1920], 2的倍数;高度范围[64, 1080], 2的倍数。 60 | * @param dst 目的图片 61 | * @param w 缩放宽度,范围[64, 1920], 2的倍数 62 | * @param h 缩放高度,范围[64, 1080], 2的倍数 63 | * @param type 目的图片的格式,0为NV21,1为NV12 64 | * @return HiLensEC 0为成功,其他为失败 65 | */ 66 | HiLensEC Resize(const cv::Mat &src, cv::Mat &dst, unsigned int w, unsigned int h, int type = 0); 67 | 68 | /* * 69 | * @brief 裁剪图片(硬件加速) 70 | * @param src 源图,必须为NV21的格式。宽度范围[64, 1920], 2的倍数;高度范围[64, 1080], 2的倍数。 71 | * @param dst 目的图片 72 | * @param x 裁剪区域左上角x坐标,范围[0, 1920], 2的倍数 73 | * @param y 裁剪区域左上角y坐标,范围[0, 1080], 2的倍数 74 | * @param w 裁剪宽度,范围[64, 1920], 2的倍数 75 | * @param h 裁剪高度,范围[64, 1080], 2的倍数 76 | * @param type 目的图片的格式,0为NV21,1为NV12 77 | * @return HiLensEC 0为成功,其他为失败 78 | */ 79 | HiLensEC Crop(const cv::Mat &src, cv::Mat &dst, unsigned int x, unsigned int y, unsigned int w, unsigned int h, 80 | int type = 0); 81 | 82 | virtual ~Preprocessor(); 83 | 84 | protected: 85 | Preprocessor() {} 86 | Preprocessor(const Preprocessor &); 87 | bool Init(); 88 | void *handle = NULL; 89 | }; 90 | } // namespace hilens 91 | #endif // HILENS_INCLUDE_MEDIA_PROCESS_H 92 | -------------------------------------------------------------------------------- /HiLens_framework/include/model.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_INCLUDE_MODEL_H 18 | #define HILENS_INCLUDE_MODEL_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include "media_process.h" 24 | #include "errors.h" 25 | 26 | namespace hilens { 27 | /* * 28 | * @brief 一组模型模型推理数据 29 | */ 30 | struct InferData { 31 | unsigned int size; // 输出大小 32 | std::shared_ptr data; // 数据指针 33 | /* * 34 | * @brief 构造一个空的模型推理数据 35 | */ 36 | InferData() : size(0), data(nullptr) {} 37 | 38 | /* * 39 | * @brief 从一个cv::Mat构造一个InferData 40 | * @param img 输入图片 41 | */ 42 | InferData(const cv::Mat &img); 43 | 44 | /* * 45 | * @brief 从一组指针数据构造一个InferData 46 | * @param data 数据指针,此构造函数会拷贝这部分数据 47 | * @param size 数据大小(字节) 48 | */ 49 | InferData(const unsigned char *data, unsigned int size); 50 | }; 51 | 52 | /* * 53 | * @brief 模型推理输入输出 54 | */ 55 | typedef std::vector InferDataVec; 56 | 57 | /* * 58 | * @brief 模型管理器 59 | * 使用模型管理器加载模型并进行推理 60 | */ 61 | class Model { 62 | public: 63 | /* * 64 | * @brief 构造模型管理器 65 | * @param filename 模型文件路径。假设模型放在./mymodels/test.om,则filename为 "./mymodels/test.om" 66 | * @return 成功则模型管理器实例的指针,失败则返回nullptr 67 | */ 68 | static std::shared_ptr Create(const std::string &filename); 69 | 70 | /* * 71 | * @brief 进行推理 72 | * 将数据输入模型进行推理,推理结束后将推理结果返回。 73 | * @param inputs 输入数据 74 | * @param outputs 输入数据 75 | * @return int 0推理成功,其他为失败。 76 | */ 77 | virtual HiLensEC Infer(const InferDataVec &inputs, InferDataVec &outputs) = 0; 78 | 79 | /* * 80 | * @brief 销毁模型 81 | * Model析构时会销毁掉hiai::Graph等资源 82 | */ 83 | virtual ~Model() {} 84 | 85 | protected: 86 | Model() {} 87 | Model(const Model &); 88 | }; 89 | } // namespace hilens 90 | #endif // HILENS_INCLUDE_MODEL_H 91 | -------------------------------------------------------------------------------- /HiLens_framework/include/resource.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_INCLUDE_RESOURCE_H 18 | #define HILENS_INCLUDE_RESOURCE_H 19 | 20 | #include 21 | #include "errors.h" 22 | 23 | namespace hilens { 24 | /* * 25 | * @brief 返回技能工作区目录的路径 26 | * @details 由于证书校验等问题,不允许在技能安装目录下写操作,故需要指定各技能可写的工作区位置 27 | * @return 技能工作区路径(末尾带“/”),如果获取失败则返回空字符串 28 | */ 29 | std::string GetWorkspacePath(); 30 | 31 | /* * 32 | * @brief 返回技能模型目录的路径 33 | * @details 对于技能代码包和模型分离的情况,模型会下载到特定目录,使用此函数来获取该路径 34 | * @return 技能模型目录的路径(末尾带“/”),如果获取失败则返回空字符串 35 | */ 36 | std::string GetModelDirPath(); 37 | 38 | /* * 39 | * @brief 获取技能配置 40 | * @details 获取技能配置,即技能配置文件中的内容解析成的Json对象(jsoncpp)。 41 | * 注意此函数每次都会读取配置文件并解析成Json对象,所以如果需要读多个配置项,请将返回值存为一个变量,不要过于频繁的调用GetSkillConfig() 42 | * @return 技能配置Json对象。如果解析失败,则返回一个空的Json::Value(可用.empty()判断) 43 | */ 44 | Json::Value GetSkillConfig(); 45 | 46 | /* * 47 | * @brief 计算一个文件的MD5值 48 | * @param 文件路径 49 | * @return 字符串,MD5值。如果读取文件失败,则返回空字符串 50 | */ 51 | std::string MD5ofFile(const std::string &filepath); 52 | 53 | /* * 54 | * @brief 从OBS下载一个文件 55 | * @param url OBS对象的下载链接 56 | * @return 0成功,其他为失败 57 | */ 58 | HiLensEC DownloadFileFromOBS(const std::string &url, const std::string &downloadTo); 59 | } // namespace hilens 60 | #endif // HILENS_INCLUDE_RESOURCE_H 61 | -------------------------------------------------------------------------------- /HiLens_framework/include/video_capture.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HILENS_INCLUDE_VIDEO_CAPTURE_H 18 | #define HILENS_INCLUDE_VIDEO_CAPTURE_H 19 | 20 | #include 21 | #include 22 | #include "media_process.h" 23 | 24 | namespace hilens { 25 | /* * 26 | * @brief 视频采集器 27 | * 使用视频采集器来读取本地摄像头或IP摄像头的数据 28 | */ 29 | class VideoCapture { 30 | public: 31 | /* * 32 | * @brief 构造视频采集器(本地摄像头) 33 | * @return 视频采集器实例 34 | */ 35 | static std::shared_ptr Create(); 36 | 37 | /* * 38 | * @brief 构造视频采集器 39 | * @param name 40 | * 设备配置中的摄像头名(设备配置中的IPC)。优先从设备配置中的摄像头名称,也可以直接传入形如rtsp://xxx的取流地址 41 | * 视频帧宽度必须为16的倍数,高为2的倍数,且宽高的最小值为128 42 | * @return 视频采集器实例 43 | */ 44 | static std::shared_ptr Create(const std::string &name); 45 | 46 | /* * 47 | * @brief 构造视频采集器 48 | * @param name 设备配置中的摄像头名(设备配置中的IPC)。 49 | * 优先从设备配置中的摄像头名称,也可以直接传入形如rtsp://xxx的取流地址,还支持读取本地mp4文件 50 | * @param width 设置读取到的视频帧图片宽度(要求为16的倍数,推荐为32的倍数,且最小为128) 51 | * @param height 设置读取到的视频帧图片高度(要求为2的倍数,且最小为128) 52 | * @return 视频采集器实例 53 | */ 54 | static std::shared_ptr Create(const std::string &name, const unsigned int width, 55 | const unsigned int height); 56 | /* * 57 | * @brief 构造视频采集器 58 | * @param dev /dev中的UVC摄像头ID 59 | * @return 视频采集器实例 60 | */ 61 | static std::shared_ptr Create(int dev); 62 | 63 | /* * 64 | * @brief 析构视频采集器 65 | */ 66 | virtual ~VideoCapture() {} 67 | 68 | /* * 69 | * @brief 读取一帧视频 70 | * 如果摄像头(IPC)读取发生错误,此接口将会抛出一个std::runtime_error 71 | * @return YUV_NV21的视频数据,如果是IPC或本地摄像头,则返回的是YUV_NV21的数据,如果是UVC摄像头,则返回JPEG数据 72 | */ 73 | virtual cv::Mat Read() = 0; 74 | 75 | /* * 76 | * @brief 返回视频原始帧宽度 77 | * @return 视频宽度 78 | */ 79 | virtual int Width() = 0; 80 | 81 | /* * 82 | * @brief 返回视频原始帧高度 83 | * @return 视频高度 84 | */ 85 | virtual int Height() = 0; 86 | 87 | protected: 88 | VideoCapture() {} 89 | VideoCapture(const VideoCapture &); 90 | }; 91 | } // namespace hilens 92 | #endif // HILENS_INCLUDE_VIDEO_CAPTURE_H 93 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/HiLens_framework/libhilens/CMakeLists.txt -------------------------------------------------------------------------------- /HiLens_framework/libhilens/audio_capture.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "utils.h" 22 | #include "sf_common.h" 23 | #include "audio_capture.h" 24 | #include "local_audio.h" 25 | #include "file_audio.h" 26 | 27 | using namespace std; 28 | 29 | namespace hilens { 30 | /* 构造AudioCapture 对象MIC */ 31 | shared_ptr AudioCapture::Create() 32 | { 33 | #ifdef CLOUD 34 | return nullptr; 35 | #else 36 | LocalAudio *audio = new (std::nothrow) LocalAudio(); 37 | if (audio) { 38 | if (!audio->Init()) { 39 | delete audio; 40 | return nullptr; 41 | } 42 | } 43 | return shared_ptr(audio); 44 | #endif 45 | } 46 | 47 | /* 构造AudioCapture 对象音频文件 */ 48 | shared_ptr AudioCapture::Create(const std::string filePath) 49 | { 50 | #ifdef CLOUD 51 | FileAudio *audio = new (std::nothrow) FileAudio(); 52 | #else 53 | LocalAudio *audio = new (std::nothrow) LocalAudio(); 54 | #endif 55 | if (audio) { 56 | if (!audio->Init(filePath)) { 57 | delete audio; 58 | return nullptr; 59 | } 60 | } 61 | return shared_ptr(audio); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/audio_output.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "utils.h" 22 | #include "sf_common.h" 23 | #include "audio_output.h" 24 | #include "audio_play.h" 25 | #include "errors.h" 26 | 27 | typedef enum hiAIO_SOUND_MODE_E { 28 | AUDIO_SOUND_MODE_MONO = 0, /* mono */ 29 | AUDIO_SOUND_MODE_STEREO = 1, /* stereo */ 30 | AUDIO_SOUND_MODE_BUTT 31 | } AUDIO_SOUND_MODE_E; 32 | 33 | static AUDIO_SOUND_MODE_E gSoundMode = AUDIO_SOUND_MODE_STEREO; 34 | /* 申明内部处理函数 */ 35 | extern bool gAudioSystemInit; 36 | extern bool AudioFileCheck(const std::string filePath, struct AudioProperties &property, int &chnCnt); 37 | extern bool AudioSystemInit(void); 38 | extern bool AudioSystemUnInit(void); 39 | 40 | 41 | using namespace std; 42 | 43 | namespace hilens { 44 | /* 构造AudioOutput对象 */ 45 | shared_ptr AudioOutput::Create(const struct AudioProperties &property) 46 | { 47 | AudioPlay *audioPlay = new (std::nothrow) AudioPlay(); 48 | if (audioPlay) { 49 | audioPlay->SetProperty(property); 50 | if (!audioPlay->Init()) { 51 | delete audioPlay; 52 | return nullptr; 53 | } 54 | } 55 | return shared_ptr(audioPlay); 56 | } 57 | 58 | /* 构造AudioCapture 对象音频文件 */ 59 | shared_ptr AudioOutput::Create(const std::string filePath) 60 | { 61 | AudioPlay *audioPlay = new (std::nothrow) AudioPlay(); 62 | if (audioPlay) { 63 | if (!audioPlay->Init(filePath)) { 64 | delete audioPlay; 65 | return nullptr; 66 | } 67 | } 68 | return shared_ptr(audioPlay); 69 | } 70 | 71 | /* 解码播放aac格式音频文件 */ 72 | HiLensEC PlayAacFile(const std::string filePath, int vol) 73 | { 74 | return OK; 75 | } 76 | 77 | void PlayHandleSigno(int signo) {} 78 | } 79 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/audio_play.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include "utils.h" 20 | #include "sf_common.h" 21 | #include "audio_play.h" 22 | 23 | using namespace hilens; 24 | using namespace std; 25 | 26 | bool AudioPlay::Init() 27 | { 28 | return true; 29 | } 30 | 31 | bool AudioPlay::Init(const std::string filePath) 32 | { 33 | return true; 34 | } 35 | 36 | AudioPlay::~AudioPlay() {} 37 | 38 | /* 播放MIC录入声音 */ 39 | int AudioPlay::Play() 40 | { 41 | return 0; 42 | } 43 | 44 | /* 当前无用函数,防止python编译问题,后续统一删除 */ 45 | int AudioPlay::SetProperty(const struct AudioProperties &properties) 46 | { 47 | return 0; 48 | } 49 | 50 | int AudioPlay::GetProperty(struct AudioProperties &properties) 51 | { 52 | return 0; 53 | } 54 | 55 | int AudioPlay::SetVolume(int vol) 56 | { 57 | return 0; 58 | } 59 | 60 | int AudioPlay::GetVolume() 61 | { 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/audio_play.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILESN_AUDIO_PLAY_H 18 | #define LIBHILESN_AUDIO_PLAY_H 19 | 20 | #include 21 | #include "audio_output.h" 22 | 23 | namespace hilens { 24 | /* * 25 | * @brief 音频播放 26 | * 使用AuioOutput类来将声音输出到AO接口 */ 27 | class AudioPlay : public AudioOutput { 28 | public: 29 | AudioPlay() {} 30 | virtual ~AudioPlay(); 31 | 32 | /* * 33 | * @brief设置音频音量 34 | * 35 | * @return 36 | */ 37 | virtual int SetVolume(int vol); 38 | virtual int GetVolume(); 39 | 40 | 41 | /* * 42 | * @brief设置音频播放采样率、位宽和单帧采样点数 43 | * 44 | * @return 45 | */ 46 | virtual int SetProperty(const struct AudioProperties &properties); 47 | virtual int GetProperty(struct AudioProperties &properties); 48 | 49 | /* * 50 | * @brief 显示一张图片 51 | */ 52 | virtual int Play(); 53 | 54 | /* * 55 | * @brief 音频播放初始化 56 | */ 57 | bool Init(); 58 | bool Init(const std::string filePath); 59 | 60 | private: 61 | AUDIO_INPUT_TYPE_E audioType; 62 | }; 63 | } // namespace hilens 64 | #endif // LIBHILESN_AUDIO_PLAY_H 65 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/display_hdmi.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "display_hdmi.h" 18 | #include 19 | #include "HiLensMedia.h" 20 | #include "sfw_log.h" 21 | #include "utils.h" 22 | #include 23 | 24 | #define ALIGN_MEMORY_WIDTH 32 /* mpp 宽度必须32位对齐 */ 25 | 26 | namespace hilens { 27 | bool DisplayHDMI::envCreated = false; 28 | 29 | HiLensEC DisplayHDMI::Show(const cv::Mat &frame) 30 | { 31 | if (!envCreated) { 32 | SHOW_HDMI_PARAM params; 33 | alignWidth = (frame.cols + ALIGN_MEMORY_WIDTH - 1) / ALIGN_MEMORY_WIDTH * ALIGN_MEMORY_WIDTH; 34 | params.imageWidth = alignWidth; 35 | params.imageHeight = frame.rows * 2 / 3; 36 | params.outputSize = HILENS_VO_OUTPUT_1080P60; 37 | params.skillid = (char *)GetSkillID(); 38 | int ret = CreateShowEnv(params); 39 | if (ret == HILENS_SUCCESS) { 40 | envCreated = true; 41 | } else if (ret == HILENS_RESOURCE_NOT_ENOUGH) { 42 | ERROR("HDMI resource is already occupied, failed to show HDMI!"); 43 | } else { 44 | ERROR("HDMI resource init failed!"); 45 | return UNKNOWN_ERROR; 46 | } 47 | if (alignWidth != frame.cols && ret == HILENS_SUCCESS) { 48 | showMat = cv::Mat(frame.rows, alignWidth, CV_8UC1); 49 | memset_s(showMat.data, (size_t)(params.imageWidth * params.imageHeight), 0, 50 | (size_t)(params.imageWidth * params.imageHeight)); 51 | memset_s(showMat.data + params.imageWidth * params.imageHeight, 52 | (size_t)(params.imageWidth * params.imageHeight / 2), 128, 53 | (size_t)(params.imageWidth * params.imageHeight / 2)); 54 | int left = ((alignWidth - frame.cols) / 2) / 2 * 2; 55 | showRect = cv::Rect(left, 0, frame.cols, frame.rows); 56 | } 57 | } 58 | int ret; 59 | if (alignWidth != frame.cols) { 60 | frame.copyTo(showMat(showRect)); 61 | ret = ShowToLocalHDMI(showMat.data, showMat.total() * showMat.elemSize()); 62 | } else { 63 | ret = ShowToLocalHDMI(frame.data, frame.total() * frame.elemSize()); 64 | } 65 | 66 | return ret == 0 ? OK : UNKNOWN_ERROR; 67 | } 68 | } // namespace hilens -------------------------------------------------------------------------------- /HiLens_framework/libhilens/display_hdmi.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_DISPLAY_HDMI_H 18 | #define LIBHILENS_DISPLAY_HDMI_H 19 | 20 | #include "output.h" 21 | 22 | namespace hilens { 23 | class DisplayHDMI : public Display { 24 | public: 25 | DisplayHDMI() {} 26 | ~DisplayHDMI() {} 27 | virtual HiLensEC Show(const cv::Mat &frame); 28 | 29 | private: 30 | static bool envCreated; 31 | int alignWidth; 32 | cv::Mat showMat; 33 | cv::Rect showRect; 34 | }; 35 | } 36 | #endif // LIBHILENS_DISPLAY_HDMI_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/dvpp_decoder.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_DVPP_DECODER_H 18 | #define LIBHILENS_DVPP_DECODER_H 19 | 20 | #ifdef CLOUD 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "model.h" 27 | #include "hiai_common.h" 28 | #include "vdecfactory.h" 29 | #include "BlockingQueue.h" 30 | 31 | namespace hilens { 32 | class DvppDecoder; 33 | 34 | // ???? 35 | class DvppInferRecvInterface : public hiai::DataRecvInterface { 36 | public: 37 | DvppInferRecvInterface(); 38 | ~DvppInferRecvInterface() {} 39 | HIAI_StatusT RecvData(const std::shared_ptr &message); 40 | void SetDepend(DvppDecoder *dependDvppImpl); 41 | 42 | std::shared_ptr output; 43 | DvppDecoder *dependDvppImpl; 44 | }; 45 | 46 | class DvppDecoder : public VDecFactoryInterface { 47 | public: 48 | DvppDecoder(const std::string &filepath); 49 | virtual ~DvppDecoder(); 50 | 51 | bool Init(bool bfast); 52 | HiLensEC Decode(const unsigned char *data, unsigned int size); 53 | void AddData(const DvppEngineTensorT &data); 54 | virtual void RegisterCallback(std::function cb); 55 | virtual int DecodeFrameBuf(unsigned char *inData, unsigned int inSize); 56 | 57 | private: 58 | int SetCallback(); 59 | 60 | private: 61 | uint32_t graph_id; 62 | uint32_t src_engine_id; 63 | uint32_t src_port_id; 64 | uint32_t dst_engine_id; 65 | uint32_t dst_port_id; 66 | 67 | std::shared_ptr callback; 68 | std::shared_ptr graph; 69 | CodeTypeE codeType; 70 | 71 | std::shared_ptr framedata; 72 | std::function decCb; 73 | BlockingQueue imgqueue; 74 | std::mutex sendmtx; 75 | bool bIsFast; 76 | }; 77 | } // namespace hilens 78 | #endif // CLOUD 79 | #endif // LIBHILENS_DVPP_DECODER_H 80 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/dvpp_encoder.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_DVPP_ENCODER_H 18 | #define LIBHILENS_DVPP_ENCODER_H 19 | 20 | #ifdef CLOUD 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "model.h" 27 | #include "hiai_common.h" 28 | 29 | namespace hilens { 30 | class DvppEncoder; 31 | 32 | // 回调函数 33 | class DvppEncodeRecvInterface : public hiai::DataRecvInterface { 34 | public: 35 | DvppEncodeRecvInterface(); 36 | ~DvppEncodeRecvInterface(); 37 | HIAI_StatusT RecvData(const std::shared_ptr &message); 38 | void SetDepend(DvppEncoder *dependDvppImpl); 39 | 40 | bool flag; // 是否接收完成 41 | std::shared_ptr output; 42 | DvppEncoder *dependDvppImpl; 43 | }; 44 | 45 | class DvppEncoder { 46 | public: 47 | DvppEncoder(const std::string &filepath) : framedata(new DvppEngineTensorT) 48 | { 49 | if (filepath == "h264") { 50 | codeType = CODE_TYPE_H264; 51 | } else { 52 | codeType = CODE_TYPE_H265; 53 | } 54 | } 55 | virtual ~DvppEncoder(); 56 | 57 | bool Init(int width, int height); 58 | virtual HiLensEC Encode(const InferData &inputs); 59 | virtual HiLensEC Encode(const unsigned char *data, const int size); 60 | void AddData(const DvppEngineTensorT &data); 61 | void ReadData(InferData &data); 62 | int GetBuffSize(); 63 | 64 | private: 65 | int SetCallback(); 66 | 67 | private: 68 | const int QUEUE_NUM = 10; 69 | const int FRAME_BUFF_SIZE = 4 * 1024 * 1024; // 4MB,支持存储1080P及以下图片 70 | 71 | uint32_t graph_id; 72 | uint32_t src_engine_id; 73 | uint32_t src_port_id; 74 | uint32_t dst_engine_id; 75 | uint32_t dst_port_id; 76 | 77 | int width; 78 | int height; 79 | 80 | CodeTypeE codeType; 81 | 82 | std::shared_ptr callback; 83 | std::shared_ptr graph; 84 | 85 | std::queue dataQueue; 86 | std::mutex dataMtx; 87 | std::condition_variable consume; 88 | 89 | int framecount; 90 | std::shared_ptr framedata; 91 | }; 92 | } // namespace hilens 93 | #endif // CLOUD 94 | #endif // LIBHILENS_DVPP_ENCODER_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/encode_src_engine.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "encode_src_engine.h" 25 | 26 | // Source Engine 27 | HIAI_IMPL_ENGINE_PROCESS("EncodeSrcEngine", EncodeSrcEngine, SOURCE_ENGINE_INPUT_SIZE) 28 | { 29 | HIAI_StatusT hiai_ret = HIAI_OK; 30 | 31 | // receive data 32 | if (nullptr == arg0) { 33 | return HIAI_ERROR; 34 | } 35 | 36 | // send tata to port 0 37 | hiai_ret = hiai::Engine::SendData(0, "EncodeEngineTensorT", arg0); 38 | if (HIAI_OK != hiai_ret) { 39 | return HIAI_ERROR; 40 | } 41 | return HIAI_OK; 42 | } -------------------------------------------------------------------------------- /HiLens_framework/libhilens/encode_src_engine.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_ENGINE_H_ 18 | #define SRC_ENGINE_H_ 19 | 20 | #include "hiaiengine/api.h" 21 | 22 | #define SOURCE_ENGINE_INPUT_SIZE 1 23 | #define SOURCE_ENGINE_OUTPUT_SIZE 1 24 | using hiai::Engine; 25 | 26 | // Source Engine 27 | class EncodeSrcEngine : public Engine { 28 | /* * 29 | * @ingroup hiaiengine 30 | * @brief HIAI_DEFINE_PROCESS : 重载Engine Process处理逻辑 31 | * @[in]: 定义一个输入端口,一个输出端口 32 | */ 33 | HIAI_DEFINE_PROCESS(SOURCE_ENGINE_INPUT_SIZE, SOURCE_ENGINE_OUTPUT_SIZE) 34 | }; 35 | 36 | #endif // SRC_ENGINE_H_ -------------------------------------------------------------------------------- /HiLens_framework/libhilens/file_audio.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_FILE_AUDIO_H 18 | #define LIBHILENS_FILE_AUDIO_H 19 | 20 | #include 21 | #include "audio_capture.h" 22 | extern "C" { 23 | #include 24 | #include 25 | #include 26 | #include 27 | } 28 | 29 | namespace hilens { 30 | class FileAudio : public AudioCapture { 31 | public: 32 | FileAudio() {} 33 | virtual ~FileAudio(); 34 | 35 | /* 读取一帧音频 */ 36 | virtual int Read(AudioFrame &frames, int n = 1); 37 | /* 音频参数 */ 38 | virtual int SetProperty(const struct AudioProperties &properties) {} 39 | virtual int GetProperty(struct AudioProperties &properties); 40 | /* 音频音量 */ 41 | virtual int SetVolume(int volume) {} 42 | virtual int GetVolume(); 43 | 44 | /* * 45 | * @brief 音频初始化 46 | */ 47 | bool Init() 48 | { 49 | return false; 50 | } 51 | bool Init(const std::string filePath); 52 | 53 | private: 54 | /* 环境初始化标志 */ 55 | static bool envCreated; 56 | /* 音频参数 */ 57 | struct AudioProperties audioProperties; 58 | /* 音频来源0:MIC 1:音频文件 */ 59 | AUDIO_INPUT_TYPE_E audioType; 60 | /* 音频帧临时缓存 */ 61 | std::shared_ptr defaultData; 62 | /* MIC录入音量大小,范围[-87, +86] */ 63 | int volume; 64 | /* 通道数目 */ 65 | int chnCnt; 66 | 67 | int audioIndex; 68 | 69 | AVFormatContext *pFormatCtx; 70 | AVCodecContext *codecCtx; 71 | AVCodec *cod; 72 | AVPacket *packet; 73 | AVFrame *avframe; 74 | struct SwrContext *convert_ctx; 75 | int buffer_size; 76 | uint8_t *buffer; 77 | }; 78 | } // namespace hilens 79 | #endif // LIBHILENS_FILE_AUDIO_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/h264_writer.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "h264_writer.h" 18 | #include "sfw_log.h" 19 | 20 | using namespace hilens; 21 | 22 | H264Writer::~H264Writer() 23 | { 24 | delete encoder; 25 | if (fp) { 26 | fclose(fp); 27 | } 28 | } 29 | 30 | bool H264Writer::Init(const std::string &filepath) 31 | { 32 | encoder = new (std::nothrow) VEncoder(); 33 | if (encoder == nullptr) { 34 | ERROR("Failed to construct VEncoder"); 35 | return false; 36 | } 37 | 38 | fp = fopen(filepath.c_str(), "wb"); 39 | if (!fp) { 40 | ERROR("Failed to open file %s.", filepath.c_str()); 41 | return false; 42 | } 43 | 44 | return true; 45 | } 46 | 47 | HiLensEC H264Writer::Show(const cv::Mat &frame) 48 | { 49 | if (!encoderInited) { 50 | if (encoder->Init(frame.cols, frame.rows * 2 / 3) != 0) { 51 | ERROR("Failed to init encoder"); 52 | return UNKNOWN_ERROR; 53 | } 54 | encoderInited = true; 55 | } 56 | 57 | // 编码,如果编码失败则忽略该帧 58 | unsigned char *framedata = nullptr; // h264帧数据块 59 | unsigned int framesize = 0; // h264帧数据块大小 60 | if (encoder->EncodeFrame(frame.data, frame.total() * frame.elemSize(), &framedata, &framesize) != 0) { 61 | WARN("Failed to encode frame."); 62 | return INTERNAL_ERROR; 63 | } 64 | 65 | fwrite(framedata, 1, framesize, fp); 66 | free(framedata); 67 | framedata = nullptr; 68 | 69 | return OK; 70 | } -------------------------------------------------------------------------------- /HiLens_framework/libhilens/h264_writer.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_H264_WRITER_H 18 | #define LIBHILENS_H264_WRITER_H 19 | 20 | #include 21 | #include "output.h" 22 | #include "vencoder.h" 23 | 24 | namespace hilens { 25 | class H264Writer : public Display { 26 | public: 27 | H264Writer() {} 28 | virtual ~H264Writer(); 29 | bool Init(const std::string &filepath); 30 | virtual HiLensEC Show(const cv::Mat &frame); 31 | VEncoder *encoder = nullptr; 32 | FILE *fp = nullptr; 33 | bool encoderInited = false; 34 | }; 35 | } 36 | #endif // LIBHILENS_H264_WRITER_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/hiai_common.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "hiai_common.h" 18 | 19 | using namespace std; 20 | 21 | void GetTransSearPtr(void *inputPtr, std::string &ctrlStr, uint8_t *&dataPtr, uint32_t &dataLen) 22 | { 23 | DvppEngineTensorT *engine_trans = (DvppEngineTensorT *)inputPtr; 24 | ctrlStr = std::string((char *)inputPtr, sizeof(DvppEngineTensorT)); 25 | dataPtr = (uint8_t *)engine_trans->data.get(); 26 | dataLen = engine_trans->size; 27 | } 28 | 29 | /* * 30 | * @ingroup hiaiengine 31 | * @brief GetTransSearPtr, Deserialization of Trans data 32 | * @param [in] : ctrl_ptr Struct Pointer 33 | * @param [in] : data_ptr Struct data Pointer 34 | * @param [out]:std::shared_ptr Pointer to the pointer that is transmitted to the Engine 35 | * @author w00437212 36 | */ 37 | std::shared_ptr GetTransDearPtr(const char *ctrlPtr, const uint32_t &ctrlLen, const uint8_t *dataPtr, 38 | const uint32_t &dataLen) 39 | { 40 | DvppEngineTensorT *engine_trans = (DvppEngineTensorT *)ctrlPtr; 41 | std::shared_ptr engineTranPtr(new DvppEngineTensorT); 42 | 43 | engineTranPtr->size = engine_trans->size; 44 | engineTranPtr->codeType = engine_trans->codeType; 45 | engineTranPtr->data.reset(const_cast(dataPtr), hiai::Graph::ReleaseDataBuffer); 46 | return std::static_pointer_cast(engineTranPtr); 47 | } 48 | 49 | // 注册DvppEngineTensorT 50 | HIAI_REGISTER_SERIALIZE_FUNC("DvppEngineTensorT", DvppEngineTensorT, GetTransSearPtr, GetTransDearPtr); 51 | 52 | // 注册在engine间传输的几种数据类型 53 | HIAI_REGISTER_DATA_TYPE("InferEngineTensorT", InferEngineTensorT); 54 | HIAI_REGISTER_DATA_TYPE("InferEngineInputT", InferEngineInputT); 55 | HIAI_REGISTER_DATA_TYPE("InferEngineOutputT", InferEngineOutputT); 56 | HIAI_REGISTER_DATA_TYPE("EncodeEngineTensorT", EncodeEngineTensorT); 57 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/hilens.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "hilens.h" 18 | #include 19 | #include "sfw_log.h" 20 | #include "obszilla/obszilla.h" 21 | #include "hiai_common.h" 22 | #include "hilens_security.h" 23 | #include "wsclient.h" 24 | #include 25 | #include "conf.h" 26 | #include "auth.h" 27 | 28 | namespace hilens { 29 | #define ASSERT_OK(ec) if ((ec) != OK) { \ 30 | return (ec); \ 31 | } 32 | 33 | extern HiLensEC InitSkillLogger(); 34 | 35 | HiLensEC Init(const std::string &verify) 36 | { 37 | // 加载配置 38 | Configuration::Init(); 39 | 40 | // 初始化日志 41 | log4cplus::initialize(); 42 | HiLensEC ec = OK; 43 | ec = InitSkillLogger(); 44 | ASSERT_OK(ec) 45 | 46 | ec = InitSFWLogger(); 47 | ASSERT_OK(ec) 48 | 49 | // 检查字符串的合法性 50 | const std::regex re("^[a-z0-9A-Z]+$"); 51 | if (!std::regex_match(verify, re)) { 52 | ERROR("Invalid skill code, please check the verify string!"); 53 | return INVALID_PARAM; 54 | } 55 | 56 | // 初始化HiAiEngine 57 | HIAI_Init(0); 58 | 59 | #ifndef SF_OFFLINE 60 | // 初始化HilensSecurity实例,必须提前初始化,否则在hilens_media起来之后初始化HilensSecurity会导致1004错误 61 | HilensSecurity::Instance().Init(); 62 | 63 | // 初始化OBSZilla 64 | ec = OBSZilla::GlobalInit(); 65 | ASSERT_OK(ec); 66 | // 加载摄像头配置 67 | DeviceConfig::Init(); 68 | // 加载OBS设置 69 | OBSConfig::Instance().Init(); 70 | // 初始化并连接到hdad 71 | const string LOCAL_HOST = "127.0.0.1"; 72 | if ((ec = (HiLensEC)common::WSClient::Instance().Init(LOCAL_HOST.c_str(), GetSkillID())) != OK) { 73 | Error("WSClient init fail"); 74 | return ec; 75 | } 76 | if ((ec = (HiLensEC)common::WSClient::Instance().ConnectAsync()) != OK) { 77 | Error("WSClient connect fail"); 78 | return ec; 79 | } 80 | // 检查License 81 | Auth::Instance().RunCheckLicenseThread(verify); 82 | #endif 83 | 84 | return OK; 85 | } 86 | 87 | HiLensEC Terminate() 88 | { 89 | log4cplus::Logger::shutdown(); 90 | 91 | return OK; 92 | } 93 | } // namespace hilens 94 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/ipc_capture.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_IPC_CAPTURE_H 18 | #define LIBHILENS_IPC_CAPTURE_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "license_video_capture.h" 26 | #include "rtsp_puller.h" 27 | #include "vdecfactory.h" 28 | #include "BlockingQueue.h" 29 | 30 | namespace hilens { 31 | class IPCCapture : public LicenseVideoCapture { 32 | public: 33 | IPCCapture(); 34 | IPCCapture(const unsigned int destWidth, const unsigned int destHeight); 35 | virtual ~IPCCapture(); 36 | 37 | virtual bool Init(const std::string &name); 38 | 39 | // 返回的是YVU_NV12的数据 40 | virtual cv::Mat Read(); 41 | virtual int Width(); 42 | virtual int Height(); 43 | 44 | private: 45 | bool InitDecoder(); 46 | void DecCallback(cv::Mat &outimg); 47 | 48 | private: 49 | std::unique_ptr puller; 50 | IVDec vDecoder; 51 | std::unique_ptr frameData; 52 | 53 | size_t frameSize; 54 | bool updated; 55 | 56 | int width; 57 | int height; 58 | int destWidth; 59 | int destHeight; 60 | 61 | std::mutex mtx; 62 | std::thread pullStreamThread; 63 | BlockingQueue imgqueue; 64 | }; 65 | } // namespace hilens 66 | #endif // LIBHILENS_IPC_CAPTURE_H 67 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/license_video_capture.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "license_video_capture.h" 18 | #include "local_camera.h" 19 | #include "ipc_capture.h" 20 | #include "uvc_capture.h" 21 | #include "auth.h" 22 | #include "sfw_log.h" 23 | #include "hilens_errorcode.h" 24 | #include "mp4_reader.h" 25 | 26 | using namespace std; 27 | using namespace hilens; 28 | 29 | mutex LicenseVideoCapture::usedMtx; 30 | 31 | // 构造本地摄像头 32 | shared_ptr LicenseVideoCapture::Create() 33 | { 34 | lock_guard autolock(usedMtx); 35 | 36 | LocalCamera *cam = new (std::nothrow) LocalCamera(); 37 | if (cam != nullptr) { 38 | if (!cam->Init()) { 39 | delete cam; 40 | return nullptr; 41 | } 42 | } 43 | 44 | return std::shared_ptr(cam); 45 | } 46 | 47 | // 构造IPC 48 | shared_ptr LicenseVideoCapture::Create(const string &name) 49 | { 50 | // 使用宽高默认值(0,0)表示使用视频帧原始宽和高 51 | return Create(name, 0, 0); 52 | } 53 | 54 | shared_ptr LicenseVideoCapture::Create(const std::string &name, const unsigned int width, 55 | const unsigned int height) 56 | { 57 | lock_guard autolock(usedMtx); 58 | 59 | // 支持读取MP4文件 60 | if (name.size() > 4 && name.substr(name.size() - 4, 4) == ".mp4") { 61 | MP4Reader *cam = new (std::nothrow) MP4Reader(width, height); 62 | return Init(cam, name); 63 | } else { 64 | IPCCapture *cam = new (std::nothrow) IPCCapture(width, height); 65 | return Init(cam, name); 66 | } 67 | } 68 | 69 | shared_ptr LicenseVideoCapture::Create(int dev) 70 | { 71 | lock_guard autolock(usedMtx); 72 | 73 | UVCCapture *cam = new (std::nothrow) UVCCapture(); 74 | if (cam != nullptr) { 75 | if (!cam->Init(dev)) { 76 | delete cam; 77 | return nullptr; 78 | } 79 | } 80 | 81 | return std::shared_ptr(cam); 82 | } 83 | 84 | LicenseVideoCapture::LicenseVideoCapture() {} 85 | 86 | LicenseVideoCapture::~LicenseVideoCapture() {} 87 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/license_video_capture.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_LICENSE_VIDEO_CAPTURE_H 18 | #define LIBHILENS_LICENSE_VIDEO_CAPTURE_H 19 | 20 | #include "video_capture.h" 21 | #include 22 | #include 23 | 24 | namespace hilens { 25 | class LicenseVideoCapture : public VideoCapture { 26 | public: 27 | /* * 28 | * @brief 构造视频采集器(本地摄像头) 29 | * @return 视频采集器实例 30 | */ 31 | static std::shared_ptr Create(); 32 | /* * 33 | * @brief 构造视频采集器 34 | * @param name 35 | * 设备配置中的摄像头名(设备配置中的IPC)。优先从设备配置中的摄像头名称,也可以直接传入形如rtsp://xxx的取流地址 36 | * @return 视频采集器实例 37 | */ 38 | static std::shared_ptr Create(const std::string &name); 39 | 40 | /* * 41 | * @brief 构造视频采集器 42 | * @param name 设备配置中的摄像头名(设备配置中的IPC)。 43 | * 优先从设备配置中的摄像头名称,也可以直接传入形如rtsp://xxx的取流地址,还支持读取本地mp4文件 44 | * @param width 设置读取到的视频帧图片宽度(要求为16的倍数,推荐为32的倍数,且最小为128) 45 | * @param height 设置读取到的视频帧图片高度(要求为2的倍数,且最小为128) 46 | * @return 视频采集器实例 47 | */ 48 | static std::shared_ptr Create(const std::string &name, const unsigned int width, 49 | const unsigned int height); 50 | /* * 51 | * @brief 构造视频采集器 52 | * @param dev /dev中的UVC摄像头ID 53 | * @return 视频采集器实例 54 | */ 55 | static std::shared_ptr Create(int dev); 56 | 57 | protected: 58 | LicenseVideoCapture(); 59 | virtual ~LicenseVideoCapture(); 60 | 61 | private: 62 | template static std::shared_ptr Init(T1 instance, T2 name) 63 | { 64 | if (instance != nullptr) { 65 | if (!instance->Init(name)) { 66 | delete instance; 67 | return nullptr; 68 | } 69 | } 70 | 71 | return std::shared_ptr(instance); 72 | } 73 | 74 | private: 75 | static std::mutex usedMtx; 76 | }; 77 | } // namespace hilens 78 | #endif // LIBHILENS_LICENSE_VIDEO_CAPTURE_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/local_audio.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_LOCAL_AUDIO_H 18 | #define LIBHILENS_LOCAL_AUDIO_H 19 | 20 | #include 21 | #include "audio_capture.h" 22 | extern "C" { 23 | #include 24 | #include 25 | #include 26 | #include 27 | } 28 | 29 | namespace hilens { 30 | class LocalAudio : public AudioCapture { 31 | public: 32 | LocalAudio() {} 33 | virtual ~LocalAudio(); 34 | 35 | /* 读取一帧音频 */ 36 | virtual int Read(AudioFrame &frames, int n = 1); 37 | /* 音频参数设置 */ 38 | virtual int SetProperty(const struct AudioProperties &properties); 39 | virtual int GetProperty(struct AudioProperties &properties); 40 | /* 音频录入音量设置 */ 41 | virtual int SetVolume(int vol); 42 | virtual int GetVolume(); 43 | 44 | /* * 45 | * @brief 音频初始化 46 | */ 47 | bool Init(); 48 | bool Init(const std::string filePath); 49 | 50 | private: 51 | bool Init_Split(const std::string &filePath); 52 | int ReadFromFile(int n); 53 | int GetWavdata(int frameIndex); 54 | /* public */ 55 | /* 音频来源0:MIC 1:音频文件 */ 56 | AUDIO_INPUT_TYPE_E audioType; 57 | /* 音频帧临时缓存 */ 58 | std::shared_ptr defaultData; 59 | /* 一次读取最大音频帧数目 */ 60 | int maxFrmNum; 61 | /* 一帧音频大小 */ 62 | int frameSize; 63 | 64 | /* ffmpeg for file */ 65 | int audioIndex; 66 | int bytesPersample; 67 | bool dftDataInit; 68 | AVFormatContext *pFormatCtx; 69 | AVCodecContext *codecCtx; 70 | AVCodec *cod; 71 | AVPacket *packet; 72 | AVFrame *avframe; 73 | struct SwrContext *convert_ctx; 74 | int buffer_size; 75 | unsigned char *buffer; 76 | }; 77 | } // namespace hilens 78 | #endif // LIBHILENS_LOCAL_AUDIO_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/local_camera.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "local_camera.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "utils.h" 25 | #include "sfw_log.h" 26 | #include "sf_common.h" 27 | 28 | using namespace hilens; 29 | using namespace cv; 30 | 31 | bool LocalCamera::Init() 32 | { 33 | if (!envCreated) { 34 | // 全局初始化 35 | CAMERA_PARAM params; 36 | // 先暂时固定为720p的分辨率 37 | params.imageHeight = CAM_HEIGHT; 38 | params.imageWidth = CAM_WIDTH; 39 | params.skillid = (char *)GetSkillID(); 40 | params.fixelFormat = YVU_SEMIPLANAR_420; 41 | 42 | int ret = CreateCameraEnv(params); 43 | if (ret == HILENS_SUCCESS) { 44 | envCreated = true; 45 | } else if (ret == HILENS_RESOURCE_NOT_ENOUGH) { 46 | ERROR("local camera is already occupied!"); 47 | } else { 48 | ERROR("local camera init failed!"); 49 | } 50 | } 51 | 52 | return envCreated; 53 | } 54 | 55 | LocalCamera::~LocalCamera() 56 | { 57 | if (envCreated) { 58 | DestroyCameraEnv(); 59 | envCreated = false; 60 | } 61 | } 62 | 63 | int LocalCamera::Width() 64 | { 65 | return CAM_WIDTH; 66 | } 67 | 68 | int LocalCamera::Height() 69 | { 70 | return CAM_HEIGHT; 71 | } 72 | 73 | Mat LocalCamera::Read() 74 | { 75 | // 没有调用init()的对象,不允许read 76 | if (!envCreated) { 77 | throw std::runtime_error("LocalCamera init failed!"); 78 | } 79 | 80 | Mat frame(CAM_HEIGHT * 3 / 2, CAM_WIDTH, CV_8UC1); 81 | 82 | OUTPUT_PARAM outFrame = { 0 }; 83 | while (ReadFrameFromCamera(&outFrame) != HILENS_SUCCESS) { 84 | } 85 | 86 | int ret = memcpy_s(frame.data, frame.total() * frame.elemSize(), outFrame.outData, outFrame.size); 87 | if (ret != 0) { 88 | ERROR("memcpy_s failed!"); 89 | } 90 | 91 | SF_FREE(outFrame.outData); 92 | return frame; 93 | } 94 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/local_camera.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_LOCAL_CAMERA_H 18 | #define LIBHILENS_LOCAL_CAMERA_H 19 | 20 | #include "license_video_capture.h" 21 | #include 22 | 23 | #define CAM_WIDTH 1280 24 | #define CAM_HEIGHT 720 25 | 26 | namespace hilens { 27 | class LocalCamera : public LicenseVideoCapture { 28 | public: 29 | LocalCamera() {} 30 | virtual ~LocalCamera(); 31 | 32 | virtual cv::Mat Read(); 33 | virtual int Width(); 34 | virtual int Height(); 35 | 36 | // 非线程安全函数,由LicenseVideoCapture的create()调用时加锁保证线程安全 37 | bool Init(); 38 | 39 | private: 40 | bool envCreated = false; 41 | }; 42 | } // namespace hilens 43 | #endif // LIBHILENS_LOCAL_CAMERA_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/model.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "model.h" 18 | #include 19 | #include "model_impl.h" 20 | #include "auth.h" 21 | #include "sfw_log.h" 22 | #include "hiaiengine/ai_memory.h" 23 | 24 | using namespace std; 25 | using namespace hilens; 26 | using namespace cv; 27 | 28 | InferData::InferData(const Mat &img) 29 | { 30 | size = img.total() * img.elemSize(); 31 | unsigned char *buff = new unsigned char[size]; 32 | if (!buff) { 33 | ERROR("InferData new memory fail!"); 34 | } 35 | memcpy_s(buff, size, img.data, size); 36 | data.reset(buff); 37 | } 38 | 39 | InferData::InferData(const unsigned char *data, unsigned int size) 40 | { 41 | unsigned char *buff = nullptr; 42 | this->size = size; 43 | 44 | buff = new unsigned char[size]; 45 | if (!buff) { 46 | ERROR("InferData new memory fail!"); 47 | } 48 | this->data.reset(buff); 49 | 50 | if (data) { 51 | memcpy_s(buff, size, data, size); 52 | } 53 | } 54 | 55 | shared_ptr Model::Create(const string &filename) 56 | { 57 | ModelImpl *model = new (std::nothrow) ModelImpl(filename); 58 | if (model) { 59 | if (!model->Init()) { 60 | delete model; 61 | return nullptr; 62 | } 63 | } 64 | return shared_ptr(model); 65 | } 66 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/model_impl.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_MODEL_IMPL_H 18 | #define LIBHILENS_MODEL_IMPL_H 19 | 20 | #include 21 | #include "model.h" 22 | #include "hiai_common.h" 23 | #include "BlockingQueue.h" 24 | 25 | namespace hilens { 26 | // 回调函数 27 | class InferRecvInterface : public hiai::DataRecvInterface { 28 | public: 29 | InferRecvInterface(BlockingQueue *pqinfer, BlockingQueue *pqsend) 30 | { 31 | flag = false; 32 | pinferque = pqinfer; 33 | psendque = pqsend; 34 | } 35 | ~InferRecvInterface(){} 36 | HIAI_StatusT RecvData(const std::shared_ptr &message); 37 | bool flag; // 是否接收完成 38 | std::shared_ptr output; 39 | BlockingQueue *pinferque; 40 | BlockingQueue *psendque; 41 | }; 42 | 43 | class ModelImpl : public Model { 44 | public: 45 | ModelImpl(const std::string &filepath) : filepath(filepath) {} 46 | virtual ~ModelImpl(); 47 | bool Init(); 48 | virtual HiLensEC Infer(const InferDataVec &inputs, InferDataVec &outputs); 49 | 50 | private: 51 | uint32_t graph_id; 52 | uint32_t src_engine_id; 53 | uint32_t src_port_id; 54 | uint32_t dst_engine_id; 55 | uint32_t dst_port_id; 56 | std::shared_ptr callback; 57 | std::shared_ptr graph; 58 | std::string filepath; 59 | int SetCallback(); 60 | BlockingQueue inferque; 61 | BlockingQueue sendque; 62 | std::mutex infermtx; 63 | }; 64 | } // namespace hilens 65 | #endif // LIBHILENS_MODEL_IMPL_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/mp4_reader.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_MP4_READER_H 18 | #define LIBHILENS_MP4_READER_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include "license_video_capture.h" 24 | #include "vdecfactory.h" 25 | #include 26 | #include 27 | #include "BlockingQueue.h" 28 | 29 | extern "C" { 30 | #include 31 | } 32 | 33 | namespace hilens { 34 | class MP4Reader : public LicenseVideoCapture { 35 | public: 36 | MP4Reader(); 37 | MP4Reader(const unsigned int destWidth, const unsigned int destHeight); 38 | ~MP4Reader(); 39 | 40 | virtual bool Init(const std::string &name); 41 | virtual cv::Mat Read(); 42 | virtual int Width(); 43 | virtual int Height(); 44 | 45 | private: 46 | int Decode(std::shared_ptr &tmpFrame); 47 | int InitBitstreamFilter(const AVCodecParameters *codecpar); 48 | int InitVideoContext(); 49 | bool InitDecoder(); 50 | int FilterStream(AVPacket *srcPkt, std::shared_ptr &tmpFrame, unsigned int &tmpFrameSize); 51 | void decCallback(cv::Mat &outimg); 52 | 53 | private: 54 | VDecFactory::DecType type; 55 | 56 | IVDec vDecoder; 57 | size_t frameSize; 58 | 59 | int videoIndex; 60 | std::thread readThread; 61 | std::atomic_bool stopFlag; 62 | bool isAnnexb; 63 | 64 | AVFormatContext *pFormatCtx; 65 | AVBSFContext *bsfContext; 66 | 67 | int width; 68 | int height; 69 | int destWidth; 70 | int destHeight; 71 | /* add to potect read when async */ 72 | std::thread decThread; 73 | void decThreadFunc(); 74 | BlockingQueue imgqueue; 75 | }; 76 | } // namespace hilens 77 | #endif // LIBHILENS_MP4_READER_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/obszilla/obsutils.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "obsutils.h" 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | 27 | // 计算哈希时读取文件的batch大小 28 | #define BATCHLEN 65536 29 | 30 | string GetDate_RFC1123() 31 | { 32 | // 获取RFC 1123时间戳 33 | struct tm *timeinfo = nullptr; 34 | size_t bufferSize = 80; 35 | char buffer[bufferSize]; 36 | time_t t = time(nullptr); 37 | timeinfo = gmtime(&t); 38 | if (timeinfo == nullptr) { 39 | return ""; 40 | } 41 | strftime(buffer, bufferSize, "%a, %d %b %Y %H:%M:%S GMT", timeinfo); 42 | return buffer; 43 | } 44 | 45 | long SizeofFile(const std::string &filepath) 46 | { 47 | long filesize = -1; 48 | struct stat statbuff; 49 | if (stat(filepath.c_str(), &statbuff) < 0) { 50 | return filesize; 51 | } else { 52 | filesize = statbuff.st_size; 53 | } 54 | return filesize; 55 | } 56 | 57 | size_t UploadBufferReadFunc(void *buffer, size_t size, size_t nmemb, void *userp) 58 | { 59 | ReadBuf *buf = static_cast(userp); 60 | size_t cpsize = nmemb < buf->size ? nmemb : buf->size; 61 | int ret = memcpy_s(buffer, cpsize, buf->data, cpsize); 62 | if (ret != 0) { 63 | return 0; 64 | } 65 | buf->data += cpsize; 66 | buf->size -= cpsize; 67 | return cpsize; 68 | } 69 | 70 | size_t ResponseHeaderCallback(const void *buffer, size_t size, size_t nmemb, std::map *userp) 71 | { 72 | string head((const char *)buffer, nmemb); 73 | size_t split = head.find_first_of(": "); 74 | if (split == string::npos) { 75 | // 不是键值对的先忽略吧 76 | return nmemb; 77 | } 78 | string key = string(head, 0, split); 79 | string value = string(head, split + 2, head.length() - split - 4); // OBS返回的每项后面还有个\r\n要去掉 80 | (*userp)[key] = value; 81 | return nmemb; 82 | } -------------------------------------------------------------------------------- /HiLens_framework/libhilens/obszilla/obsutils.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef OBSZILLA_OBSUTILS_H 18 | #define OBSZILLA_OBSUTILS_H 19 | 20 | #include 21 | #include 22 | 23 | // 获取当前时间戳(RFC1123格式) 24 | std::string GetDate_RFC1123(); 25 | 26 | // 获取文件大小(字节)。如果获取失败返回-1 27 | long SizeofFile(const std::string &filepath); 28 | 29 | // 上传buf时将此结构体传给CURL作为read_func的userp 30 | struct ReadBuf { 31 | const char *data; 32 | size_t size; 33 | }; 34 | 35 | // 用于上传buf的read_func 36 | size_t UploadBufferReadFunc(void *buffer, size_t size, size_t nmemb, void *userp); 37 | 38 | // 用于获取响应的headers的回调 39 | size_t ResponseHeaderCallback(const void *buffer, size_t size, size_t nmemb, std::map *userp); 40 | 41 | #endif /* OBSZILLA_OBSUTILS_H */ -------------------------------------------------------------------------------- /HiLens_framework/libhilens/obszilla/obszilla.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef OBSZILLA_OBSZILLA_H 18 | #define OBSZILLA_OBSZILLA_H 19 | 20 | #include 21 | #include 22 | #include "errors.h" 23 | #include "request.h" 24 | 25 | namespace hilens { 26 | // 描述一个要下载/上传的OBS对象 27 | struct OBSObject { 28 | std::string bucket; // 对象所在的桶 29 | std::string domain; // 对象所在的域 30 | std::string object; // 对象资源路径 31 | }; 32 | 33 | class OBSZilla { 34 | public: 35 | // 上传模式 36 | enum UploadMode { 37 | WRITE, // 写模式 38 | APPEND // 追加模式 39 | }; 40 | 41 | // 下载到哪个目录下 42 | std::string downloadTo; 43 | 44 | // 传输超时设置,当传输时间超过timeout时放弃治疗(毕竟万一网速太差,下几天也不是个办法) 45 | // 默认为0(永不超时,注意是已经建立连接后传输时的超时设置,内部设置了建立连接的超时限制为30s) 46 | unsigned int timeout; 47 | // 是否打印详情到stdout,1为打印,0为不打印。默认为0 48 | int verbose; 49 | 50 | // 全局初始化,在实例化OBSZilla并调用任何方法之前应先调用此静态方法 51 | static HiLensEC GlobalInit(); 52 | 53 | // 构造函数 54 | OBSZilla(); 55 | 56 | // 析构函数 57 | virtual ~OBSZilla(); 58 | 59 | // 下载一个OBS对象(链接的形式,如https://bucket.obs.cn-north-4.myhuaweicloud.com/test.txt) 60 | // 除了RequestURL类型,url可以为std::string 61 | HiLensEC Download(const RequestURL &url); 62 | 63 | // 下载一个OBS对象(链接的形式) 64 | HiLensEC Download(const char *url); 65 | 66 | // 下载一个OBS对象(根据桶名、域名和对象路径) 67 | HiLensEC Download(const OBSObject &obj); 68 | 69 | // 上传一个文件,将filepath指向的文件存到OBS,OBS信息填在obj里 70 | // filepath: 本地文件路径 71 | // obj: OBS对象信息 72 | // mode: 上传方式 73 | HiLensEC Upload(const std::string &filepath, const OBSObject &obj, const UploadMode mode = WRITE); 74 | 75 | // 上传一个buffer,buffer指针为buf,buffer字节数为bufSize,OBS信息填在obj里 76 | // buf: buffer指针 77 | // bufSize: buffer字节数 78 | // obj: OBS对象信息 79 | // mode: 上传方式 80 | HiLensEC UploadBuffer(const char *buf, size_t bufSize, const OBSObject &obj, const UploadMode mode = WRITE); 81 | 82 | protected: 83 | // 鉴权信息 84 | OBSAuth GetAuth(); 85 | static std::map reqError; 86 | static std::map httpError; 87 | HiLensEC GetErrorCode(int ret, int httpcode); 88 | // 获取云上对象下次追加的位置 89 | // 返回对象追加的位置,如果不存在则返回"0",如果请求错误返回空字符串 90 | std::string GetObjectNextAppendPos(const OBSObject &obj); 91 | int Mkdirs(const std::string &FileDir); 92 | }; 93 | } // namespace hilens 94 | #endif /* OBSZILLA_OBSZILLA_H */ -------------------------------------------------------------------------------- /HiLens_framework/libhilens/relay_dvpp_engine.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "hiai_common.h" 18 | #include "relay_dvpp_engine.h" 19 | 20 | // Dest Engine 接收Infer Engine推理输出tensor 21 | HIAI_IMPL_ENGINE_PROCESS("DestDvppEngine", DestDvppEngine, DEST_ENGINE_INPUT_SIZE) 22 | { 23 | // 接收推理模块输出 24 | std::shared_ptr output_tensor = std::static_pointer_cast(arg0); 25 | 26 | if (nullptr == output_tensor) { 27 | return HIAI_ERROR; 28 | } 29 | // 直接透传,输出到端口0 30 | hiai::Engine::SendData(0, "DvppEngineTensorT", std::static_pointer_cast(output_tensor)); 31 | 32 | return HIAI_OK; 33 | } -------------------------------------------------------------------------------- /HiLens_framework/libhilens/relay_dvpp_engine.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_RELAY_DVPP_ENGINE_H 18 | #define LIBHILENS_RELAY_DVPP_ENGINE_H 19 | 20 | #include "hiaiengine/data_type_reg.h" 21 | #include "hiaiengine/data_type.h" 22 | #include "hiaiengine/api.h" 23 | 24 | #define DEST_ENGINE_INPUT_SIZE 1 25 | #define DEST_ENGINE_OUTPUT_SIZE 1 26 | 27 | using hiai::Engine; 28 | 29 | class DestDvppEngine : public Engine { 30 | HIAI_DEFINE_PROCESS(DEST_ENGINE_INPUT_SIZE, DEST_ENGINE_OUTPUT_SIZE) 31 | }; 32 | #endif // LIBHILENS_RELAY_DVPP_ENGINE_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/route.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SF_OFFLINE 18 | #include "route.h" 19 | #include "sfw_log.h" 20 | #include "utils.h" 21 | #include "auth.h" 22 | 23 | using namespace std; 24 | 25 | namespace hilens { 26 | Router &Router::Instance() 27 | { 28 | static Router route; 29 | return route; 30 | } 31 | 32 | Router::Router() 33 | { 34 | // 指定各个消息对应的处理函数 35 | // token查询 36 | funcs["token_query"] = [](const Json::Value &doc) { Auth::Instance().OnTokenQuery(doc); }; 37 | } 38 | 39 | Router::~Router() {} 40 | 41 | void Router::Route(const string &msg) 42 | { 43 | // 解析并初步检查错误 44 | Json::Value doc; 45 | string errorMsg; 46 | if (!String2Json(msg, doc, errorMsg)) { 47 | WARN("Received invalid message. %s", errorMsg.c_str()); 48 | return; 49 | } 50 | if (!doc.isMember("topic") || !doc["topic"].isString()) { 51 | WARN("Received invalid message. 'topic' string not found."); 52 | return; 53 | } 54 | 55 | // 开始分类 56 | string topic = doc["topic"].asString(); 57 | 58 | if (funcs.find(topic) == funcs.end()) { 59 | WARN("Received invalid message. Unknown 'topic'."); 60 | return; 61 | } 62 | 63 | // 调用相关函数 64 | funcs[topic](doc); 65 | } 66 | } 67 | #endif 68 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/route.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_ROUTE_H 18 | #define LIBHILENS_ROUTE_H 19 | 20 | #ifndef SF_OFFLINE 21 | #include 22 | #include 23 | #include 24 | #include "json/json.h" 25 | 26 | namespace hilens { 27 | /* * 28 | * @brief 与hdad的消息路由器 29 | * 30 | */ 31 | class Router { 32 | public: 33 | static Router &Instance(); 34 | void Route(const std::string &msg); 35 | 36 | private: 37 | Router(); 38 | Router(const Router &); 39 | ~Router(); 40 | std::map> funcs; 41 | }; 42 | } 43 | 44 | #endif // SF_OFFLINE 45 | #endif // LIBHILENS_ROUTE_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/rtmp_publisher.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_RTMP_PUBLISHER_H 18 | #define LIBHILENS_RTMP_PUBLISHER_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "media_process.h" 27 | #include "vencoder.h" 28 | #include "output.h" 29 | #include "dvpp_encoder.h" 30 | 31 | namespace hilens { 32 | class RTMPPublisher : public Display { 33 | public: 34 | RTMPPublisher() {} 35 | bool Init(const std::string &url); 36 | virtual ~RTMPPublisher(); 37 | int Connect(); 38 | int Disconnect(); 39 | virtual HiLensEC Show(const cv::Mat &frame); 40 | 41 | private: 42 | // 推流线程及相关函数 43 | void PubThread(); 44 | // 获取输入的图片,如果没有输入则阻塞线程 45 | cv::Mat GetInputFrame(); 46 | // 获取时间戳 47 | int GetTimestamp(); 48 | const char *GetFrameType(char nut); 49 | // 发送h264数据 50 | int SendH264Data(const char *framedata, int framesize); 51 | int ReadH264Frame(char *data, int size, char **pp, int *pnb_start_code, char **frame, int *frame_size); 52 | // 处理发送错误的情况 53 | void DealError(int ret); 54 | int Reconnect(); 55 | 56 | private: 57 | bool connected; 58 | std::thread tpublish; 59 | srs_rtmp_t rtmp; 60 | bool encoderInited; 61 | VEncoder *encoder = nullptr; 62 | 63 | std::string url; 64 | int startTime; 65 | struct timeval tv; 66 | std::mutex mtx; 67 | std::list frames; 68 | 69 | // 判定需要重连的条件 70 | int reconnectThreshold; 71 | int reconnectIndex; 72 | int idx; // 发送的帧计数 73 | }; 74 | } // namespace hilens 75 | #endif // LIBHILENS_RTMP_PUBLISHER_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/rtsp_puller.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_RTSP_PULLER_H 18 | #define LIBHILENS_RTSP_PULLER_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | extern "C" { 25 | #include 26 | } 27 | #include "hstring.h" 28 | 29 | namespace hilens { 30 | using RTSPCallback = std::function; 31 | 32 | class RTSPPuller { 33 | public: 34 | // 拉流支持编码类型 35 | enum CodecType { 36 | H264, 37 | HEVC 38 | }; 39 | 40 | public: 41 | RTSPPuller(const Hstring &url); 42 | virtual ~RTSPPuller(); 43 | 44 | int Init(); 45 | 46 | // 得到的frame数据会传入callback 47 | int Start(const RTSPCallback &callback); 48 | int GetFrameSize(int &width, int &height); 49 | void Stop(); 50 | bool IsRunning(); 51 | bool IsStart(); 52 | 53 | CodecType GetCodecType(); 54 | 55 | private: 56 | static void InitFFMPEG(); 57 | 58 | private: 59 | std::atomic_bool running; 60 | std::atomic_bool startFlag; 61 | 62 | Hstring url; 63 | AVFormatContext *pFormatCtx; 64 | int videoIndex; 65 | CodecType type; 66 | RTSPCallback captureCallback; 67 | }; 68 | } // namespace hilens 69 | #endif // LIBHILENS_RTSP_PULLER_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/src_engine.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_ENGINE_H_ 18 | #define SRC_ENGINE_H_ 19 | 20 | #include "hiaiengine/api.h" 21 | 22 | #define SOURCE_ENGINE_INPUT_SIZE 1 23 | #define SOURCE_ENGINE_OUTPUT_SIZE 1 24 | using hiai::Engine; 25 | 26 | // Source Engine 27 | class SrcEngine : public Engine { 28 | /* * 29 | * @ingroup hiaiengine 30 | * @brief HIAI_DEFINE_PROCESS : 重载Engine Process处理逻辑 31 | * @[in]: 定义一个输入端口,一个输出端口 32 | */ 33 | HIAI_DEFINE_PROCESS(SOURCE_ENGINE_INPUT_SIZE, SOURCE_ENGINE_OUTPUT_SIZE); 34 | }; 35 | 36 | #endif // SRC_ENGINE_H_ -------------------------------------------------------------------------------- /HiLens_framework/libhilens/src_engines.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "src_engine.h" 25 | 26 | // Source Engine 27 | HIAI_IMPL_ENGINE_PROCESS("SrcEngine", SrcEngine, SOURCE_ENGINE_INPUT_SIZE) 28 | { 29 | HIAI_StatusT hiai_ret = HIAI_OK; 30 | 31 | // receive data 32 | if (nullptr == arg0) { 33 | return HIAI_ERROR; 34 | } 35 | 36 | // send tata to port 0 37 | hiai_ret = hiai::Engine::SendData(0, "DvppEngineTensorT", arg0); 38 | if (HIAI_OK != hiai_ret) { 39 | return HIAI_ERROR; 40 | } 41 | return HIAI_OK; 42 | } -------------------------------------------------------------------------------- /HiLens_framework/libhilens/uvc_capture.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_UVC_CAPTURE_H 18 | #define LIBHILENS_UVC_CAPTURE_H 19 | 20 | #include 21 | #include "license_video_capture.h" 22 | 23 | /* 存放UVC摄像头一帧数据的缓存结构 */ 24 | typedef struct UvcFrameBuffer { 25 | void *start; 26 | size_t length; 27 | } UvcFrameBuf; 28 | 29 | namespace hilens { 30 | class UVCCapture : public LicenseVideoCapture { 31 | public: 32 | UVCCapture() {} 33 | virtual ~UVCCapture(); 34 | bool Init(int dev); 35 | /* 返回的是MJPEG格式的数据 */ 36 | virtual cv::Mat Read(); 37 | virtual int Width(); 38 | virtual int Height(); 39 | 40 | private: 41 | int devId; 42 | int fd; 43 | UvcFrameBuf *frameBuf; 44 | void *uvcBuffer; 45 | int width; 46 | int height; 47 | std::mutex mtx; 48 | /* 双路放权 */ 49 | unsigned int readFrameNum; 50 | bool Check(int dev); 51 | bool SetParam(); 52 | bool MallocBuffer(); 53 | bool SetBuffer(); 54 | }; 55 | } /* namespace hilens */ 56 | #endif // LIBHILENS_UVC_CAPTURE_H -------------------------------------------------------------------------------- /HiLens_framework/libhilens/vdecfactory.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "vdecfactory.h" 18 | #include "vdecoder.h" 19 | #include "dvpp_decoder.h" 20 | #include "sf_common.h" 21 | #include "sfw_log.h" 22 | 23 | using namespace hilens; 24 | 25 | IVDec VDecFactory::Create(unsigned int width, unsigned int height, DecType codec, bool bfast) 26 | { 27 | return Create(width, height, width, height, codec, bfast); 28 | } 29 | 30 | IVDec VDecFactory::Create(unsigned int width, unsigned int height, unsigned int destWidth, unsigned int destHeight, 31 | DecType codec, bool bfast) 32 | { 33 | ENCODE_TYPE_E mppcodec = EN_H264; 34 | if (codec == VDecFactory::DecH265) 35 | mppcodec = EN_H265; 36 | VDecoder *pdec = new (std::nothrow) VDecoder(width, height, destWidth, destHeight, mppcodec); 37 | if (pdec) { 38 | if (pdec->Init(bfast) != HILENS_OK) { 39 | ERROR("MppDecoder init failed!"); 40 | return nullptr; 41 | } else { 42 | return std::shared_ptr(pdec); 43 | } 44 | } 45 | 46 | return nullptr; 47 | } 48 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/vdecfactory.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LIBHILENS_VDECFACTORY_H 18 | #define LIBHILENS_VDECFACTORY_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace hilens { 25 | class VDecFactoryInterface { 26 | public: 27 | template inline std::function BindCallback(F &&f, Args &&... args) 28 | { 29 | return std::bind(std::forward(f), std::forward(args)..., std::placeholders::_1); 30 | } 31 | 32 | virtual void RegisterCallback(std::function cb) = 0; 33 | virtual int DecodeFrameBuf(unsigned char *inData, unsigned int inSize) = 0; 34 | }; 35 | 36 | using IVDec = std::shared_ptr; 37 | 38 | class VDecFactory { 39 | public: 40 | typedef enum _DecType { 41 | DecH265 = 0, 42 | DecH264 = 1 43 | } DecType; 44 | 45 | static IVDec Create(unsigned int width, unsigned int height, DecType codec, bool bfast); 46 | static IVDec Create(unsigned int width, unsigned int height, unsigned int destWidth, unsigned int destHeight, 47 | DecType codec, bool bfast); 48 | 49 | private: 50 | VDecFactory() = default; 51 | ~VDecFactory() = default; 52 | VDecFactory(const VDecFactory &) = delete; 53 | VDecFactory &operator = (const VDecFactory &) = delete; 54 | }; 55 | } // namespace hilens 56 | #endif // LIBHILENS_VDECFACTORY_H 57 | -------------------------------------------------------------------------------- /HiLens_framework/libhilens/video_capture.cpp: -------------------------------------------------------------------------------- 1 | /* * 2 | * Copyright 2020 Huawei Technologies Co., Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "video_capture.h" 18 | #include "license_video_capture.h" 19 | 20 | using namespace std; 21 | using namespace hilens; 22 | 23 | static int g_usedCount = 0; 24 | 25 | // 构造本地摄像头 26 | shared_ptr VideoCapture::Create() 27 | { 28 | return LicenseVideoCapture::Create(); 29 | } 30 | 31 | // 构造IPC 32 | shared_ptr VideoCapture::Create(const string &name) 33 | { 34 | return LicenseVideoCapture::Create(name); 35 | } 36 | 37 | shared_ptr VideoCapture::Create(const std::string &name, const unsigned int width, 38 | const unsigned int height) 39 | { 40 | return LicenseVideoCapture::Create(name, width, height); 41 | } 42 | 43 | // 构造UVC摄像头 44 | shared_ptr VideoCapture::Create(int dev) 45 | { 46 | return LicenseVideoCapture::Create(dev); 47 | } 48 | -------------------------------------------------------------------------------- /HiLens_framework/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(hilens_python) 4 | 5 | include_directories(${CMAKE_SOURCE_DIR}/include) 6 | include_directories(${CMAKE_SOURCE_DIR}/third_party/numpy/include) 7 | include_directories(${CMAKE_SOURCE_DIR}/third_party/python/include) 8 | include_directories(${CMAKE_SOURCE_DIR}/third_party/jsoncpp/include) 9 | include_directories(${CMAKE_SOURCE_DIR}/third_party/log4cplus/include) 10 | include_directories(${CMAKE_SOURCE_DIR}/third_party/ddk_887/include/libc_sec/include) 11 | 12 | include_directories(${CMAKE_SOURCE_DIR}/libhilens) 13 | include_directories(${CMAKE_SOURCE_DIR}/common/include) 14 | 15 | add_library(_hilens_internal SHARED hilens_wrap.cxx wrapper.cpp) 16 | target_link_libraries(_hilens_internal hilens python3.7m) 17 | set_target_properties(_hilens_internal PROPERTIES PREFIX "") # 取消_hilens_internal.so的lib前缀 18 | target_compile_options(_hilens_internal PRIVATE -fPIC) 19 | -------------------------------------------------------------------------------- /HiLens_framework/python/hilens.i: -------------------------------------------------------------------------------- 1 | %module hilens_internal 2 | 3 | %{ 4 | #define SWIG_FILE_WITH_INIT 5 | 6 | #include "../include/errors.h" 7 | #include "../include/ei_services.h" 8 | #include "../include/hilens.h" 9 | #include "../include/log.h" 10 | #include "../include/media_process.h" 11 | #include "../include/model.h" 12 | #include "../include/output.h" 13 | #include "../include/resource.h" 14 | #include "../include/video_capture.h" 15 | #include "../include/audio_capture.h" 16 | #include "../include/audio_output.h" 17 | #include "./wrapper.h" 18 | 19 | using namespace hilens; 20 | %} 21 | 22 | %include "std_string.i" 23 | %include "std_vector.i" 24 | %include "std_shared_ptr.i" 25 | %include "numpy.i" 26 | %init %{ 27 | import_array(); 28 | %} 29 | 30 | // For Upload 31 | %apply (unsigned char* IN_ARRAY1, int DIM1) {(const unsigned char *buffer, size_t bufferSize)} 32 | 33 | // For InferData 34 | %apply (unsigned char* IN_ARRAY1, int DIM1) {(const unsigned char* data, unsigned int size)} 35 | %apply (float* IN_ARRAY1, int DIM1) {(const float *data, unsigned int size)} 36 | 37 | // For PreprocessorWrapper 38 | %apply (unsigned char* IN_ARRAY1, int DIM1) {(const unsigned char *srcData, unsigned int srcSize)} 39 | %apply (unsigned char* INPLACE_ARRAY1, int DIM1) {(unsigned char* dstData, unsigned int dstSize)} 40 | 41 | // For InferDataWrapper 42 | %apply (unsigned char* ARGOUT_ARRAY1, int DIM1){(unsigned char* data, unsigned int size)} 43 | %apply (float* ARGOUT_ARRAY1, int DIM1){(float* data, unsigned int size)} 44 | 45 | %include "../include/errors.h" 46 | %include "../include/ei_services.h" 47 | %include "../include/hilens.h" 48 | %include "../include/log.h" 49 | %include "../include/media_process.h" 50 | %include "../include/model.h" 51 | %include "../include/output.h" 52 | %include "../include/resource.h" 53 | %include "../include/video_capture.h" 54 | %include "../include/audio_capture.h" 55 | %include "../include/audio_output.h" 56 | %include "./wrapper.h" 57 | 58 | %template(InferDataVec) std::vector; 59 | %template(EIHeaders) std::vector; 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 | **`Documentation`** | 6 | ------------------- | 7 | [![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://support.huaweicloud.com/devg-hilens/hilens_05_0002.html) | 8 | 9 | [华为HiLens](https://www.huaweicloud.com/product/hilens.html)为端云协同多模态AI开发应用平台,面向AI应用开发者,软硬件厂商以及普通用户,提供简单易用的开发框架、开箱即用的开发环境、丰富的AI技能市场和云上管理平台,对接多种端侧计算设备,支持视觉及听觉AI应用开发、AI应用在线部署、海量设备管理等丰富功能。 10 | 11 | 华为HiLens由AI推理相机HiLens Kit以及智能小站等端侧设备和云上开发平台组成,可通过ModelArts或离线导入训练好的模型,同时平台也为Tensorflow和Caffe模型提供在线转换。HiLens Framework封装了视频分析算法的基础组件,如:图像处理,推理,日志,视频流推流上云,华为云上API对接。目前为开发者提供稳定的Python和C++ APIs. 12 | 13 | 华为HiLens Kit 多模态AI开发套件,端侧具有超强AI算力。华为自研昇腾AI加速模块(Ascend310),领跑业界的AI芯片,采用达芬奇架构,支持16TOPS算力,16路1080P 30fps视频分析;在视频编解码方面,支持H.265,H.264等多种规格的视频编解码,3559A的NNIE架构CPU与昇腾310融合架构,让开发和移植变得更加快速,支持工业级,行业级复杂AI算法的实时推理。 14 | 15 | 所有华为HiLens文档,请参考HiLens的[华为云文档主页](https://support.huaweicloud.com/hilens/index.html),同时华为HiLens也开放了[开发者论坛](https://bbs.huaweicloud.com/forum/forum-771-1.html)供所有开发者讨论HiLens的开发和方向。你也许很有兴趣了解怎样快速将模型快速部署在端侧设备HiLens Kit上面,我们提供了贴心快速[入门手册](https://support.huaweicloud.com/qs-hilens/hilens_04_0002.html).欢迎大家,反馈问题和特性需求,上报bug在[GitHub Issue主页](https://github.com/huaweicloud/HiLens-Lab/issues). 16 | 17 | **News: 华为HiLens创建了微信群,请添加华为云小助手,欢迎大家入群进行实时交流和分享!** 18 | 19 | qr_code 20 | 21 | ## 华为HiLens平台 22 | 23 |
24 | 25 |
26 | 27 | ## Framework 28 | 29 | 华为HiLens云上开发平台包括一站式技能开发、设备部署与管理、数据管理、技能市场等,并提供统一的算法开发框架HiLens Framework屏蔽硬件细节,封装集成组件和开发调试环境环境HiLens Studio,帮助用户开发AI技能并将其推送到端侧计算设备,另外在技能市场内,预置使用于不同芯片的多种算法包,支持部署算法到HiLens Kit,智能小站以及第三方设备,覆盖商超,家庭,园区等多种商用场景,强大的HiLens 开发者社区,也可帮助企业根据场景定制AI算法。 30 | 31 |
32 | 33 |
34 | 35 | ## HiLens Kit 36 | 37 |
38 | 39 |
40 | 41 | 42 | ## Resources 43 | 44 | * [华为HiLens主页](https://www.huaweicloud.com/product/hilens.html) 45 | * [HiLens Kit 硬件参数](https://support.huawei.com/enterprise/zh/doc/EDOC1100112066?idPath=7919749%7C9856522%7C22892968%7C23710428%7C250700826) 46 | * [昇腾芯片模型转换](https://support.huawei.com/enterprise/zh/doc/EDOC1100107956) 47 | * [ModelArts](https://www.huaweicloud.com/product/modelarts.html) 48 | * [华为HiLens 快速入门](https://support.huaweicloud.com/qs-hilens/hilens_04_0002.html) 49 | * [华为HiLens帮助文档](https://support.huaweicloud.com/productdesc-hilens/hilens_01_0001.html) 50 | * [华为HiLens视频课程](https://education.huaweicloud.com:8443/courses/course-v1:HuaweiX+CBUCNXE034+Self-paced/about?isAuth=0&cfrom=hwc) 51 | * [华为云AI开发者社区](https://developer.huaweicloud.com/resource/ai.html) 52 | * [华为HiLens FAQ](https://support.huaweicloud.com/hilens_faq/HiLens_03_0001.html) 53 | * [OpenEuler](https://openeuler.org/zh/) 54 | * [华为开源镜像](https://mirrors.huaweicloud.com/euler/2.8/os/aarch64/ ) 55 | 56 | 57 | ## License 58 | 59 | [Apache License 2.0](LICENSE) 60 | -------------------------------------------------------------------------------- /contrib/README.MD: -------------------------------------------------------------------------------- 1 | Under construction.... -------------------------------------------------------------------------------- /docs/HiLens 部署 模型转换 算子网络支持清单.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/HiLens 部署 模型转换 算子网络支持清单.xlsx -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | under construction.... -------------------------------------------------------------------------------- /docs/pics/FAQ_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/FAQ_1.png -------------------------------------------------------------------------------- /docs/pics/FAQ_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/FAQ_2.png -------------------------------------------------------------------------------- /docs/pics/FAQ_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/FAQ_3.png -------------------------------------------------------------------------------- /docs/pics/FAQ_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/FAQ_4.png -------------------------------------------------------------------------------- /docs/pics/FAQ_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/FAQ_5.png -------------------------------------------------------------------------------- /docs/pics/FAQ_6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/FAQ_6.PNG -------------------------------------------------------------------------------- /docs/pics/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/Thumbs.db -------------------------------------------------------------------------------- /docs/pics/hilens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/hilens.png -------------------------------------------------------------------------------- /docs/pics/hilens_platform.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/hilens_platform.jpg -------------------------------------------------------------------------------- /docs/pics/hilens_size.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/hilens_size.png -------------------------------------------------------------------------------- /docs/pics/hilens_str.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/hilens_str.png -------------------------------------------------------------------------------- /docs/pics/qr_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/docs/pics/qr_code.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/HiLens_authorize.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/HiLens_authorize.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/Hilens_Kit_connectwifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/Hilens_Kit_connectwifi.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/Hilens_Kit_connectwifi2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/Hilens_Kit_connectwifi2.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/connect_to_computer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/connect_to_computer.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/connect_to_computer2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/connect_to_computer2.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/connect_to_computer3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/connect_to_computer3.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/console.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/convert_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/convert_model.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/create_obs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/create_obs.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/create_skill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/create_skill.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/create_skill2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/create_skill2.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/default_gateway.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/default_gateway.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/default_gateway2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/default_gateway2.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/delete_skill.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/delete_skill.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/delete_skill2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/delete_skill2.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/deploy.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/deploy.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/flow.jpg -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/hdactl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/hdactl.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/ies.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/ies.jpg -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/import_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/import_model.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/ma_pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/ma_pipeline.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/maincode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/maincode.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/mobaxterm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/mobaxterm.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/ping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/ping.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/ping_hilens_kit_ip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/ping_hilens_kit_ip.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/set_IP_adress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/set_IP_adress.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/set_IP_adress2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/set_IP_adress2.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/sign_up_HiLens.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/sign_up_HiLens.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/skillmanager.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/skillmanager.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/skillmanager2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/skillmanager2.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/stop_skill.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/stop_skill.PNG -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/trainjob-parameter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/trainjob-parameter.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/trainjob-source.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/trainjob-source.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/trainjob-test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/trainjob-test.png -------------------------------------------------------------------------------- /official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/update_HiLens.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/ModelArts + HiLens 端云协同,开发手势识别AI应用/img/update_HiLens.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/HiLens_authorize.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/HiLens_authorize.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/Hilens_Kit_connectwifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/Hilens_Kit_connectwifi.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/Hilens_Kit_connectwifi2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/Hilens_Kit_connectwifi2.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/connect_to_computer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/connect_to_computer.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/connect_to_computer2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/connect_to_computer2.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/connect_to_computer3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/connect_to_computer3.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/console.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/convert_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/convert_model.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/create_obs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/create_obs.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/create_skill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/create_skill.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/create_skill2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/create_skill2.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/default_gateway.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/default_gateway.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/default_gateway2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/default_gateway2.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/delete_skill.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/delete_skill.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/delete_skill2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/delete_skill2.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/deploy.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/deploy.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/deploy2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/deploy2.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/flow.jpg -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/flow.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/hdactl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/hdactl.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/ies.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/ies.jpg -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/import_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/import_model.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/ma_pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/ma_pipeline.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/maincode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/maincode.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/mobaxterm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/mobaxterm.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/ping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/ping.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/ping_hilens_kit_ip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/ping_hilens_kit_ip.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/purchase_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/purchase_1.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/purchase_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/purchase_2.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/set_IP_adress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/set_IP_adress.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/set_IP_adress2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/set_IP_adress2.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/sign_up_HiLens.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/sign_up_HiLens.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/skillmanager.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/skillmanager.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/skillmanager2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/skillmanager2.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/start.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/start.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/stop_skill.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/stop_skill.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/trainjob-parameter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/trainjob-parameter.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/trainjob-source.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/trainjob-source.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/trainjob-test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/trainjob-test.png -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/update_HiLens.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/update_HiLens.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/人脸检测.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/人脸检测.PNG -------------------------------------------------------------------------------- /official_examples/一键部署AI模型到端侧设备Hilens Kit/img/参数.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/一键部署AI模型到端侧设备Hilens Kit/img/参数.PNG -------------------------------------------------------------------------------- /official_examples/技能模板/Face_Detection_Template/main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # !/usr/bin/python3 3 | # SkillFramework 1.0.0 face detection demo 4 | 5 | import hilens 6 | import cv2 7 | import numpy as np 8 | from postprocess import im_detect_nms 9 | 10 | # 网络输入尺寸 11 | input_height = 480 12 | input_width = 480 13 | 14 | 15 | def main(): 16 | """ 利用SkillFramework进行人脸检测模型的推理 """ 17 | hilens.init("test") # 参数要与创建技能时填写的检验值保持一致 18 | model_path = hilens.get_model_dir() + "face_detection_demo.om" # 模型路径 19 | model = hilens.Model(model_path) 20 | display_hdmi = hilens.Display(hilens.HDMI) # 图像通过hdmi输出到屏幕 21 | camera = hilens.VideoCapture() 22 | 23 | 24 | while True: 25 | # 1. 读取摄像头输入(yuv nv21) 26 | input_nv21 = camera.read() 27 | 28 | # 2. 转为bgr 29 | input_bgr = cv2.cvtColor(input_nv21, cv2.COLOR_YUV2BGR_NV21) 30 | src_image_height = input_bgr.shape[0] 31 | src_image_width = input_bgr.shape[1] 32 | 33 | # 3. 保留原图比例的resize为网络输入尺寸 34 | im_scale1 = float(input_width) / float(src_image_width) 35 | im_scale2 = float(input_height) / float(src_image_height) 36 | im_scale = min(im_scale1, im_scale2) 37 | input_bgr_rescaled = cv2.resize(input_bgr, None, None, fx=im_scale, fy=im_scale) 38 | input_bgr_resized = np.zeros((input_height, input_width, 3), dtype = np.uint8) 39 | input_bgr_resized[0:input_bgr_rescaled.shape[0],0:input_bgr_rescaled.shape[1],:] = input_bgr_rescaled 40 | 41 | # 3. 推理 42 | outputs = model.infer([input_bgr_resized.flatten()]) 43 | 44 | # 4. 后处理得到人脸bounding box,恢复到原图比例,画人脸框 45 | detect_boxes = im_detect_nms(outputs[0]) 46 | if len(detect_boxes) > 0: 47 | for rect in detect_boxes: 48 | left = max(rect[0] / im_scale, 0) 49 | top = max(rect[1] / im_scale, 0) 50 | right = min(rect[2] / im_scale, src_image_width) 51 | bottom = min(rect[3] / im_scale, src_image_height) 52 | cv2.rectangle(input_bgr, (int(left), int(top)), (int(right), int(bottom)), 255, 2) 53 | 54 | # 5. 输出图像,必须是yuv nv21形式 55 | output_nv21 = hilens.cvt_color(input_bgr, hilens.BGR2YUV_NV21) 56 | display_hdmi.show(output_nv21) 57 | 58 | 59 | if __name__ == "__main__": 60 | 61 | main() 62 | -------------------------------------------------------------------------------- /official_examples/技能模板/Face_Detection_Template/models/face_detection_demo.om: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/技能模板/Face_Detection_Template/models/face_detection_demo.om -------------------------------------------------------------------------------- /official_examples/技能模板/Face_Landmarks_Detection_Template/index.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3.7 2 | # 本模板展示多模型技能 3 | 4 | import cv2 5 | import hilens 6 | from utils import * 7 | 8 | def run(): 9 | 10 | # 系统初始化,参数要与创建技能时填写的检验值保持一致 11 | hilens.init("landmarks") 12 | 13 | # 初始化自带摄像头与HDMI显示器 14 | camera = hilens.VideoCapture() 15 | display = hilens.Display(hilens.HDMI) 16 | 17 | # 初始化模型:人脸检测模型(centerface)、人脸68个关键点检测模型 18 | centerface_model_path = hilens.get_model_dir() + "centerface_template_model.om" 19 | centerface_model = hilens.Model(centerface_model_path) 20 | 21 | landmark_model_path = hilens.get_model_dir() + "landmark68_template_model.om" 22 | landmark_model = hilens.Model(landmark_model_path) 23 | 24 | # 本段代码展示如何录制HiLens Kit摄像头拍摄的视频 25 | fps = 10 26 | size = (1280, 720) 27 | format = cv2.VideoWriter_fourcc('M','J','P','G') # 注意视频格式 28 | writer = cv2.VideoWriter("face.avi", format, fps, size) 29 | 30 | # 待保存视频的起始帧数,可自行调节或加入更多逻辑 31 | frame_count = 0 32 | frame_start = 100 33 | frame_end = 150 34 | uploaded = False 35 | 36 | while True: 37 | # 读取一帧图片(YUV NV21格式) 38 | input_yuv = camera.read() 39 | 40 | # 图片预处理:转为RGB格式、缩放为模型输入尺寸 41 | img_rgb = cv2.cvtColor(input_yuv, cv2.COLOR_YUV2RGB_NV21) 42 | img_pre = preprocess(img_rgb) 43 | 44 | img_h, img_w = img_rgb.shape[:2] 45 | 46 | # 人脸检测模型推理,并进行后处理得到画面中最大的人脸检测框 47 | output = centerface_model.infer([img_pre.flatten()]) 48 | face_box = get_largest_face_box(output, img_h, img_w) 49 | 50 | # 画面中检测到有人脸且满足一定条件 51 | if face_box is not None: 52 | # 截取出人脸区域并做预处理 53 | img_face = preprocess_landmark(img_rgb, face_box) 54 | 55 | # 人脸关键点模型推理,得到68个人脸关键点 56 | output2 = landmark_model.infer([img_face.flatten()]) 57 | landmarks = output2[0].reshape(68, 2) 58 | 59 | # 将人脸框和人脸关键点画在RGB图中 60 | img_rgb = draw_landmarks(img_rgb, face_box, landmarks) 61 | 62 | # 输出处理后的图像到HDMI显示器,必须先转换成YUV NV21格式 63 | output_nv21 = hilens.cvt_color(img_rgb, hilens.RGB2YUV_NV21) 64 | display.show(output_nv21) 65 | 66 | # 录制一段视频并发送到OBS中 67 | if not uploaded: 68 | frame_count += 1 69 | if frame_count > frame_end: # 录制结束点 70 | uploaded = True 71 | writer.release() # 先保存在本地 72 | ret = hilens.upload_file("face.avi", "face.avi", "write") # 发送到OBS中 73 | if ret != 0: 74 | hilens.error("upload file failed!") 75 | return 76 | elif frame_count > frame_start: # 录制开始点 77 | # 注意写入的图片格式必须为BGR 78 | writer.write(cv2.cvtColor(img_rgb, cv2.COLOR_RGB2BGR)) 79 | 80 | hilens.terminate() 81 | 82 | if __name__ == "__main__": 83 | run() -------------------------------------------------------------------------------- /official_examples/技能模板/Face_Landmarks_Detection_Template/models/centerface_template_model.om: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/技能模板/Face_Landmarks_Detection_Template/models/centerface_template_model.om -------------------------------------------------------------------------------- /official_examples/技能模板/Face_Landmarks_Detection_Template/models/landmark68_template_model.om: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/技能模板/Face_Landmarks_Detection_Template/models/landmark68_template_model.om -------------------------------------------------------------------------------- /official_examples/技能模板/Helmet_Detection_Template/index.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3.7 2 | import cv2 3 | import time 4 | import numpy as np 5 | import threading 6 | 7 | import hilens 8 | from utils import * 9 | 10 | # IPC摄像头处理线程 11 | def camera_thread(camera_address, server_url): 12 | # 初始化IPC 13 | camera = hilens.VideoCapture(camera_address) 14 | 15 | # 初始化模型 16 | helmet_model_path = hilens.get_model_dir() + "helmet_template_model.om" 17 | helmet_model = hilens.Model(helmet_model_path) 18 | 19 | while True: 20 | # 读取一帧图片(YUV NV21格式) 21 | input_yuv = camera.read() 22 | 23 | # 图片预处理:转为RGB格式、缩放为模型输入尺寸 24 | img_rgb = cv2.cvtColor(input_yuv, cv2.COLOR_YUV2RGB_NV21) 25 | img_preprocess, img_w, img_h = preprocess(img_rgb) 26 | 27 | # 模型推理,并进行后处理得到检测框 28 | output = helmet_model.infer([img_preprocess.flatten()]) 29 | bboxes = get_result(output, img_w, img_h) 30 | 31 | # 从检测结果中判断是否有未佩戴安全帽的人 32 | if no_helmet(bboxes): 33 | # 后处理得到检测框,并在RGB图中画框 34 | img_rgb = draw_boxes(img_rgb, bboxes) 35 | 36 | # 以POST方式传输数据 37 | try: 38 | post_msg(server_url, img_rgb, bboxes) 39 | except Exception as e: 40 | hilens.error("post data failed!") 41 | print ("Reason : ", e) 42 | 43 | # 等待5秒后再检测,避免发送数据过多 44 | time.sleep(15) 45 | 46 | 47 | def run(): 48 | # 系统初始化,参数要与创建技能时填写的检验值保持一致 49 | hilens.init("helmet") 50 | 51 | # 读取技能配置 52 | skill_cfg = hilens.get_skill_config() 53 | if skill_cfg is None or 'server_url' not in skill_cfg or 'IPC_address' not in skill_cfg: 54 | hilens.error("skill config not correct") 55 | return 56 | 57 | # 获取POST服务器地址和IPC地址,多个IPC地址用分号分隔开 58 | server_url = skill_cfg['server_url'] 59 | camera_list = skill_cfg['IPC_address'].split(';') 60 | 61 | # 每个IPC启动一个独立的线程 62 | threads_list = [] 63 | for camera_address in camera_list: 64 | t = threading.Thread(target=camera_thread, args=(camera_address, server_url)) 65 | t.start() 66 | threads_list.append(t) 67 | 68 | for t in threads_list: 69 | t.join() 70 | 71 | hilens.terminate() 72 | 73 | 74 | if __name__ == "__main__": 75 | run() -------------------------------------------------------------------------------- /official_examples/技能模板/Helmet_Detection_Template/models/helmet_template_model.om: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/技能模板/Helmet_Detection_Template/models/helmet_template_model.om -------------------------------------------------------------------------------- /official_examples/技能模板/Single_Human_Pose_Template/index.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3.7 2 | 3 | import hilens 4 | from utils import * 5 | 6 | def run(): 7 | # 系统初始化,参数要与创建技能时填写的检验值保持一致 8 | hilens.init("pose") 9 | 10 | # 初始化模型 11 | pose_model_path = hilens.get_model_dir() + "pose_template_model.om" 12 | pose_model = hilens.Model(pose_model_path) 13 | 14 | # 初始化USB摄像头与HDMI显示器 15 | camera = hilens.VideoCapture() 16 | display_hdmi = hilens.Display(hilens.HDMI) 17 | 18 | while True: 19 | # 读取一帧图片(BGR格式) 20 | input_yuv = camera.read() 21 | 22 | # 图片预处理:转为BGR格式、裁剪/缩放为模型输入尺寸 23 | input_bgr = cv2.cvtColor(input_yuv, cv2.COLOR_YUV2BGR_NV21) 24 | img_preprocess = preprocess(input_bgr) 25 | 26 | # 模型推理 27 | model_outputs = pose_model.infer([img_preprocess.flatten()]) 28 | 29 | # 从推理结果中解码出人体关键点并画在图像中 30 | points = get_points(input_bgr, model_outputs) 31 | img_data = draw_limbs(input_bgr, points) 32 | 33 | # 输出处理后的图像到HDMI显示器,必须先转换成YUV NV21格式 34 | output_nv21 = hilens.cvt_color(img_data, hilens.BGR2YUV_NV21) 35 | display_hdmi.show(output_nv21) 36 | 37 | hilens.terminate() 38 | 39 | 40 | if __name__ == "__main__": 41 | run() -------------------------------------------------------------------------------- /official_examples/技能模板/Single_Human_Pose_Template/models/pose_template_model.om: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/技能模板/Single_Human_Pose_Template/models/pose_template_model.om -------------------------------------------------------------------------------- /official_examples/技能模板/Static_Gesture_Recognition_Template/index.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3.7 2 | import os 3 | import cv2 4 | import time 5 | import numpy as np 6 | 7 | import hilens 8 | from utils import * 9 | 10 | 11 | def run(): 12 | # 配置系统日志级别 13 | hilens.set_log_level(hilens.ERROR) 14 | 15 | # 系统初始化,参数要与创建技能时填写的检验值保持一致 16 | hilens.init("gesture") 17 | 18 | # 初始化模型 19 | gesture_model_path = hilens.get_model_dir() + "gesture_template_model.om" 20 | gesture_model = hilens.Model(gesture_model_path) 21 | 22 | # 初始化本地摄像头与HDMI显示器 23 | camera = hilens.VideoCapture() 24 | display_hdmi = hilens.Display(hilens.HDMI) 25 | 26 | # 上一次上传OBS图片的时间与上传间隔 27 | last_upload_time = 0 28 | upload_duration = 5 29 | 30 | # 读取技能配置 31 | skill_cfg = hilens.get_skill_config() 32 | if skill_cfg is None or 'server_url' not in skill_cfg: 33 | hilens.error("server_url not configured") 34 | return 35 | 36 | while True: 37 | # 读取一帧图片(YUV NV21格式) 38 | input_yuv = camera.read() 39 | 40 | # 图片预处理:转为RGB格式、缩放为模型输入尺寸 41 | img_rgb = cv2.cvtColor(input_yuv, cv2.COLOR_YUV2RGB_NV21) 42 | img_preprocess, img_w, img_h = preprocess(img_rgb) 43 | 44 | # 模型推理 45 | output = gesture_model.infer([img_preprocess.flatten()]) 46 | 47 | # 后处理得到手势所在区域与类别,并在RGB图中画框 48 | bboxes = get_result(output, img_w, img_h) 49 | img_rgb = draw_boxes(img_rgb, bboxes) 50 | 51 | # 输出处理后的图像到HDMI显示器,必须先转回YUV NV21格式 52 | output_yuv = hilens.cvt_color(img_rgb, hilens.RGB2YUV_NV21) 53 | display_hdmi.show(output_yuv) 54 | 55 | # 上传OK手势图片到OBS,为防止OBS数据存储过多,间隔一定的时间才上传图片 56 | if time.time() - last_upload_time > upload_duration: 57 | # 截取出OK手势图片(如果有的话) 58 | img_OK = get_OK(img_rgb, bboxes) 59 | if img_OK is not None: 60 | # 上传OK手势图片到OBS,图片(用当前时间命名)需要先转为BGR格式并按照jpg格式编码 61 | img_OK = cv2.cvtColor(img_OK, cv2.COLOR_RGB2BGR) 62 | img_OK = cv2.imencode('.jpg', img_OK)[1] 63 | filename = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime()) 64 | ret = hilens.upload_bufer(filename+"_OK.jpg", img_OK, "write") 65 | if ret != 0: 66 | hilens.error("upload pic failed!") 67 | return 68 | 69 | last_upload_time = time.time() 70 | 71 | # 以POST方式传输处理后的整张图片 72 | try: 73 | post_msg(skill_cfg['server_url'], img_rgb) 74 | except Exception as e: 75 | hilens.error("post data failed!") 76 | print ("Reason : ", e) 77 | 78 | hilens.terminate() 79 | 80 | 81 | if __name__ == "__main__": 82 | run() -------------------------------------------------------------------------------- /official_examples/技能模板/Static_Gesture_Recognition_Template/models/gesture_template_model.om: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/official_examples/技能模板/Static_Gesture_Recognition_Template/models/gesture_template_model.om -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/ROS程序编译指导文档.MD: -------------------------------------------------------------------------------- 1 | # ROS程序编译 2 | 3 | 该文档主要用于在ubuntu机子上面编译ros库,当编译成功后,将整个文件夹的库拷贝至HiLens Kit 上面进行运行 4 | 5 | A quick note: 6 | 7 | 1. 不能使用windows10的WSL 进行操作。 8 | 2. 在执行如下指令前,请确保ubuntu上面的docker能够正常运行 9 | 10 | **如果ROS是安装在与它匹配的架构的机子上面,你只需要执行”catkin_init”去初始化ROS catkin workspace 以及”catkin_make”去build workpsace。在每个workspace中都需要一个”src”文件夹存放你所需要编译的ROS packages 。** 11 | 12 | 但是, 现在ROS 没有安装在这个docker 镜像中,但是我们可以用aarch64的库来编译ROS。(ROS以及安装在HiLens上面了),这种方式叫做 isolated building. 13 | 14 | **下面已demo编译为例,讲解如何使用。Demo文件存放在/demo_ws 中,进入到镜像之后可以查看。** 15 | 16 | 17 | ## 步骤一 18 | 19 |
20 | 21 |
22 | 23 | [点击下载镜像文件](https://hilens-guide-cn-north-4.obs.cn-north-4.myhuaweicloud.com/ros_melodic_builder_exported.tar.gz) 24 | 25 | 下载docker 镜像文件,这个tar.gz 文件需要用docker import 来加载,然后进入之后,如图所示: 26 | 27 |
28 | 29 |
30 | 31 | ## 步骤二 32 | 33 | 执行如下命令,能够激活所有需要的ROS和catkin相关东西,这个叫做hybrid build . runtime libraries 是aarch64,因为你需要在hilens kit上面去运行, 而build libraries是amd64,因为你是在这个镜像里面build。 34 | 35 | ``` 36 | $ source /ros_catkin_ws/devel_isolated/setup.bash 37 | ``` 38 | 39 | ## 步骤三 40 | 41 | 编译demo文件 : 文件目录/demo_ws . 42 | 如果你进入到、demo_ws/src中,你可以看到我们已经提供了很多ROS相关的库(HiLens ROS driver, RPLIdar driver, Kineck driver, mBot driver 等等) 43 | 44 | 执行如下命令,编译demo。 45 | 46 | ``` 47 | $ cd /demo_ws 48 | ``` 49 | 50 | Build 这个workspace,你将用到catkin_make, 但是必须告诉它用aarch64 去编译。所以需要执行命令: 51 | 52 | ``` 53 | $ catkin_make -DCMAKE_TOOLCHAIN_FILE=/ros_catkin_ws/rostoolchain.cmake 54 | ``` 55 | 56 | 当demo 开始编译时,你将会遇到如下报错: 57 | 58 |
59 | 60 |
61 | 62 | 出现如图所示的编译错误,是因为aarch64 和amd64 冲突. 所以执行指令: 63 | 64 | ``` 65 | $ sed -i 's/isystem/I/g' ./build/diagnostics/test_diagnostic_aggregator/CMakeFiles/test_diagnostic_aggregator.dir/flags.make 66 | ``` 67 | 68 | 最后 再次执行命令: 69 | 70 | ``` 71 | $ catkin_make -DCMAKE_TOOLCHAIN_FILE=/ros_catkin_ws/rostoolchain.cmake 72 | ``` 73 | 74 | 你将看到如下所示内容,说明ros程序编译成功 75 | 76 |
77 | 78 |
79 | 80 | ## 步骤四 81 | 82 | 建议你将自己的packages 放入到demo_ws中,因为一些基础的ROS packages 已经build好了。 -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/install_rpm.sh: -------------------------------------------------------------------------------- 1 | rpm -i python2-2.7.17-1.fc29.aarch64.rpm 2 | rpm -i --nodeps python2-libs-2.7.17-1.fc29.aarch64.rpm 3 | rpm -i python2-2.7.17-1.fc29.aarch64.rpm 4 | rpm -i python2-setuptools-40.8.0-1.fc29.noarch.rpm 5 | rpm -U python2-pip-18.1-1.fc29.noarch.rpm 6 | rpm -U python2-netifaces-0.10.6-5.fc29.aarch64.rpm 7 | rpm -U python2-nose-1.3.7-21.fc29.noarch.rpm 8 | rpm -U libgfortran-8.2.1-2.fc29.aarch64.rpm 9 | rpm -U openblas-0.3.7-1.fc29.aarch64.rpm 10 | rpm -U openblas-serial-0.3.7-1.fc29.aarch64.rpm 11 | rpm -U openblas-threads-0.3.7-1.fc29.aarch64.rpm 12 | rpm -U python2-numpy-1.15.1-1.fc29.aarch64.rpm 13 | rpm -U tmux-2.9a-2.fc29.aarch64.rpm 14 | rpm -i gpm-libs-1.20.7-16.fc29.aarch64.rpm 15 | rpm -i vim-filesystem-8.1.2198-1.fc29.noarch.rpm 16 | rpm -i vim-common-8.1.2198-1.fc29.aarch64.rpm 17 | rpm -U vim-enhanced-8.1.2198-1.fc29.aarch64.rpm 18 | rpm -U --reinstall python2-numpy-1.15.1-1.fc29.aarch64.rpm -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_1.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_10.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_11.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_12.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_13.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_14.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_15.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_16.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_17.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_18.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_19.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_2.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_3.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_4.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_5.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_6.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_7.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_8.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/pic_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/pic_9.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/ros_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/ros_1.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/ros_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/ros_2.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/ros_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/ros_3.png -------------------------------------------------------------------------------- /tools/HiLens Kit + ROS/pics/ros_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit + ROS/pics/ros_4.png -------------------------------------------------------------------------------- /tools/HiLens Kit - yum/README.MD: -------------------------------------------------------------------------------- 1 | ## HiLens Kit安装yum及配置yum源 2 | 3 | 查看系统版本 4 | ``` 5 | $ uname -a 6 | ``` 7 | "Linux Euler 4.19.36-vhulk1907.1.0.h448.eulerosv2r8.aarch64 #1 SMP Mon Jul 22 00:00:00 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux" 8 | 9 | 下载附件rpm包放到/tmp目录,或者去[华为开源镜像站](https://mirrors.huaweicloud.com/euler/2.8/os/aarch64/Packages/)下载相应rpm包,并用unzip解压,进入目录依次安装以下库: 10 | 11 | ``` 12 | $ rpm -ivh deltarpm-3.6-28.eulerosv2r8.aarch64.rpm dnf-data-4.0.4-1.h2.eulerosv2r8.noarch.rpm python3-iniparse-0.4-32.eulerosv2r8.noarch.rpm python3-libcomps-0.1.8-14.eulerosv2r8.aarch64.rpm libcomps-*.rpm 13 | $ rpm -ivh --force gpgme-1.11.1-3.eulerosv2r8.aarch64.rpm 14 | $ rpm -ivh python3-gpg-1.11.1-3.eulerosv2r8.aarch64.rpm 15 | $ rpm -ivh libyaml-0.2.1-2.h1.eulerosv2r8.aarch64.rpm libmodulemd-1.6.4-1.eulerosv2r8.aarch64.rpm 16 | $ rpm -ivh python3-hawkey-0.22.0-6.eulerosv2r8.aarch64.rpm libdnf-0.22.0-6.eulerosv2r8.aarch64.rpm librepo-1.9.1-1.eulerosv2r8.aarch64.rpm libsolv-0.6.35-3.eulerosv2r8.aarch64.rpm python3-libdnf-0.22.0-6.eulerosv2r8.aarch64.rpm 17 | $ rpm -ivh ima-evm-utils-1.1-4.eulerosv2r8.aarch64.rpm 18 | $ rpm -ivh --force python3-rpm-4.14.2-1.h5.eulerosv2r8.aarch64.rpm rpm-libs-4.14.2-1.h5.eulerosv2r8.aarch64.rpm rpm-sign-*.rpm rpm-build-libs-4.14.2-1.h5.eulerosv2r8.aarch64.rpm rpm-4.14.2-1.h5.eulerosv2r8.aarch64.rpm 19 | $ rpm -ivh python3-dnf-*.rpm 20 | $ rpm -ivh dnf-4.0.4-1.h2.eulerosv2r8.noarch.rpm 21 | $ rpm -ivh yum-4.0.4-1.h2.eulerosv2r8.noarch.rpm 22 | 23 | ``` 24 | 这个时候运行yum还会报缺少以下几个库: 25 | 26 | ``` 27 | ImportError: libgio-2.0.so.0: cannot open shared object file: No such file or directory 28 | ImportError: libnghttp2.so.14: cannot open shared object file: No such file or directory 29 | ImportError: libssh.so.4: cannot open shared object file: No such file or directory 30 | ImportError: libbrotlidec.so.1: cannot open shared object file: No such file or directory 31 | 32 | ``` 33 | 34 | 需要安装: 35 | 36 | ``` 37 | $ rpm -ivh --force glib2-2.58.1-1.h1.eulerosv2r8.aarch64.rpm 38 | $ rpm -ivh --force libnghttp2-1.34.0-1.eulerosv2r8.aarch64.rpm 39 | $ rpm -ivh --force libssh-0.8.3-3.h1.eulerosv2r8.aarch64.rpm 40 | $ rpm -ivh --force brotli-1.0.5-1.eulerosv2r8.aarch64.rpm 41 | ``` 42 | 43 | 安装yum之后还需要配置yum源为华为开源镜像站地址,可以参考 https://support.huaweicloud.com/csg_faq/csg_04_1209.html 44 | 登录Kit进入 /etc/yum.repos.d目录,修改euleros_aarch64.repo文件如下 45 | 46 | ``` 47 | [base] 48 | name=EulerOS-2.0SP8 base 49 | baseurl=http://mirrors.huaweicloud.com/euler/2.8/os/aarch64/ 50 | enabled=1 51 | gpgcheck=1 52 | gpgkey=http://mirrors.huaweicloud.com/euler/2.8/os/RPM-GPG-KEY-EulerOS 53 | ``` 54 | 配置完成可以通过yum repolist查看 55 | 56 | 至此yum的安装就完成了,如果安装过程中缺少其他库可自行下载相应的rpm安装。 57 | 可以安装vim试一下,注意:安装的时候需要连接网络并关闭gpgcheck选项: 58 | 59 | ``` 60 | $ yum install vim --nogpgcheck 61 | ``` -------------------------------------------------------------------------------- /tools/HiLens Kit - yum/rpm.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit - yum/rpm.zip -------------------------------------------------------------------------------- /tools/HiLens Kit-gdb/README.MD: -------------------------------------------------------------------------------- 1 | ## HiLens Kit上面使用gdb 2 | 3 | A quick note: 4 | 5 | 虽然现在HiLens Kit 上面能够安装yum,但是基于yum安装的,并不代表能够使用。如果无法使用,可能是依赖裁剪掉了,造成的。 6 | 7 | 附件为两种不同gdb, 可以下载直接使用,任选一个拷贝到HiLens Kit上面即可使用,不用安装。 8 | -------------------------------------------------------------------------------- /tools/HiLens Kit-gdb/gdb.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/HiLens-Lab/2b0613db2a40ec86c267bc69076e9fb7987fc610/tools/HiLens Kit-gdb/gdb.rar -------------------------------------------------------------------------------- /tools/README.MD: -------------------------------------------------------------------------------- 1 | update: 2 | 3 | 1. 2020-01-12 添加了在HiLens Kit上面安装ROS 4 | --------------------------------------------------------------------------------