华为HiLens
华为HiLens
- 最新动态
- 功能总览
- 产品介绍
- 快速入门
- 用户指南
- 最佳实践
- 开发指南
- SDK参考
-
常见问题
- 其他问题
- 算法类问题
- 管理数据
- 管理产品
- 购买技能
- 安装/启动技能
- 技能开发
- 管理设备
- 注册设备
-
端侧设备HiLens Kit
- 设备介绍
- HiLens Kit硬件操作
-
HiLens Kit系统操作
- 如何使用SSH登录设备?
- 为什么更改设备系统密码后,使用新密码可以使用浏览器登录华为HiLens智能边缘管理系统,但是无法使用PuTTY登录设备?
- 如何对HiLens Kit系统进行底层操作?
- HiLens Kit可以导入自定义的Python模块吗?
- 如何在HiLens Kit安装yum?
- 如何管理设备文件?
- 如何在HiLens Kit安装软件包?
- 如何使用root登录设备,并关闭连接超时?
- 基于Python的openmv 的设备,是否支持通过调用API去调用HiLens Kit的技能?
- HiLens Kit不能显示中文怎么办?
- HiLens Kit如何清除已保存的wifi信息?
- HiLens Kit 如何使用命令行连接无线网络
- HiLens Kit如何配置永久性DNS?
- 通用参考
本文导读
展开导读
链接复制成功!
示例-难例上传
难例上传示例如下所示:
import hilens import cv2 import numpy as np def run(): # 构造摄像头 cap = hilens.VideoCapture() disp = hilens.Display(hilens.HDMI) hard_sample = hilens.HardSample(0.5,0.5,1) # 1,2为检测模型使用的算法 #hard_sample = hilens.HardSample(0.5,0.5,0) # 0为分类模型使用的算法 hard_sample_flag = False # 是否存在难例上传配置 hard_sample_config = hilens.get_hard_sample_config() # 获取难例配置 if not hard_sample_config: hilens.warning("hardSampleConfig is empty") else: hard_sample_flag = True data_count = hard_sample_config["hard_sample_setting"][0]["data_count"] data_current_count = hard_sample_config["hard_sample_setting"][0]["datacur_count"] upload_jpeg_url = hard_sample_config["hard_sample_setting"][0]["dataset_path"] model_name = hard_sample_config["hard_sample_setting"][0]["model_name"] camera_name = "default" if data_count > data_current_count: upload_flag = True # upload_flag是否继续上传 else: upload_flag = False while True: # 获取一帧画面 frame = cap.read() if hard_sample_flag: if upload_flag: if hard_sample.hard_sample_detection_filter([[0.,0.,1280.,720.,0.4,1]]): # 检测算法的输入为后处理之后的检测框,每个检测框包括[xmin, ymin, xmax, ymax, conf, label](包括置信度和类别标签) #if hard_sample.hard_sample_classification_filter([0.2, 0.2, 0.2, 0.2, 0.2],5): # 分类算法的输入为各类别的概率,即模型的输出 hard_sample.upload_jpeg(upload_jpeg_url, data_current_count, model_name, camera_name, frame) data_current_count += 1 hard_sample_config["hard_sample_setting"][0]["datacur_count"] = data_current_count if data_current_count == 1 or data_current_count == data_count: if data_current_count == data_count: upload_flag = False hilens.set_hard_sample_config(hard_sample_config) # 更新端侧难例配置文件 #输出到HDMI disp.show(frame) if __name__ == '__main__': #参数【hello】要与基本信息的【检验值】一致。详情请查看开发指南 hilens.init("hello") run() hilens.terminate()
父主题: 难例上传模块