华为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?
- 通用参考
本文导读
展开导读
链接复制成功!
示例-EIServices模块
EIServices模块输出示例代码如下:
import hilens import cv2 import numpy as np import base64 import json def run(): # 使用图片作为输入 f=open('/tmp/dengchao.jpg','rb') base_f=base64.b64encode(f.read()) f_string=base_f.decode('utf-8') response0 = hilens.EIServices.HumanDetect(f_string) print(response0.requestState) print(response0.responseBody) # 使用Mat格式或者直接从摄像头输入 #img = cv2.imread("/tmp/dengchao.jpg") cap = hilens.VideoCapture() frame = cap.read() img = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_NV21) img_str = cv2.imencode('.jpg', img)[1].tostring() # 将图片编码成流数据,放到内存缓存中,然后转化成string格式 b64_code = base64.b64encode(img_str) # 编码成base64 f_string1=b64_code.decode('utf-8') response1 = hilens.EIServices.HumanDetect(f_string1) print(response1.requestState) print(response1.responseBody) headers = hilens.EIHeaders() body = {"image_base64": f_string} json_str = json.dumps(body) response5 = hilens.EIServices.Request(hilens.POST, "hilens-api.cn-north-4.myhuaweicloud.com", "/v1/human-detect", "", json_str, headers) print(response5.requestState) print(response5.responseBody) body1 = {"face_set_name": "ei_test"} json_str1 = json.dumps(body1) response6 = hilens.EIServices.Request(hilens.POST, "face.cn-north-4.myhuaweicloud.com", "/v1/fc3bc995e9c441369d71159c67404e88/face-sets", "", json_str1, headers) print(response6.requestState) print(response6.responseBody) response7 = hilens.EIServices.AddFace("ei_test", f_string, "") print(response7.requestState) print(response7.responseBody) response8 = hilens.EIServices.SearchFace("ei_test", f_string, 1, 0.93, "") print(response8.requestState) print(response8.responseBody) response9 = hilens.EIServices.Request(hilens.POST, "face.cn-north-4.myhuaweicloud.com","/v1/fc3bc995e9c441369d71159c67404e88/face-sets/ei_test/search", "", json_str, headers) print(response9.requestState) print(response9.responseBody) response10 = hilens.EIServices.Request(hilens.DELETE, "face.cn-north-4.myhuaweicloud.com", "/v1/fc3bc995e9c441369d71159c67404e88/face-sets/ei_test", "", "", headers) print(response10.requestState) print(response10.responseBody) response11 = hilens.EIServices.Request(hilens.GET, "face.cn-north-4.myhuaweicloud.com", "/v1/fc3bc995e9c441369d71159c67404e88/face-sets/ei_test", "", "", headers) print(response11.requestState) print(response11.responseBody) if __name__ == '__main__': hilens.init("hello") run() hilens.terminate()
父主题: EIServices模块