当前位置:网站首页>30 lines of code to realize serverless real-time health code recognition -- operation manual
30 lines of code to realize serverless real-time health code recognition -- operation manual
2022-08-02 12:19:00 【HUAWEI CLOUD】
1 实验介绍
• 实验描述:In this experiment, the text recognition service will be usedSDK开发包,Try the text recognition service,and based on thisBuild yousmart applications and systems.无需配置和管理服务器等基础设施,函数以弹性、免运维、高可靠的方式运行.
• 内容介绍:On HUAWEI CLOUD Function Workflow Service,按照指导创建函数,通过OBS桶上Pass the health code截图,The trigger function passes华为云OCR SDK调用通用文字识别服务,识别Health code content.
2 前提条件
This experiment needs to be performed on HUAWEI CLOUD,Therefore, users need to log in with a HUAWEI CLOUD account;
If you don't have a HUAWEI CLOUD account, please do so firstRegister a HUAWEI CLOUD account and complete real-name authentication,Please use it during the experimentChrome浏览器完成相关操作.
Please refer to HUAWEI CLOUD account registration steps:
https://support.huaweicloud.com/intl/zh-cn/usermanual-account/account_id_001.html
Please refer to the real-name authentication operation steps:
https://support.huaweicloud.com/intl/zh-cn/usermanual-account/zh-cn_topic_0119621533.html
3 操作指导
3.1 登录华为云
Users who already have an account or have completed registration log in to Huawei云官网:【https://www.huaweicloud.com/】
Please refer to HUAWEI CLOUD login:
https://support.huaweicloud.com/usermanual-iam/iam_01_0033.html
3.2 获取ak/sk
AK/SK(Access Key ID/Secret Access Key)即访问密钥,Contains the access keyID(AK)和秘密访问密钥(SK)两部分,华为云通过AK识别用户的身份,通过SK对请求数据进行签名验证,用于确保请求的机密性、完整性和请求者身份的正确性.
操作步骤
a) 登录HUAWEI CLOUD management console,Point your mouse to the username in the upper right corner of the page,在下拉列表中单击“我的凭证”.
b) 在“我的凭证”页面中选择“访问密钥”页签.单击“Added access secret钥”,Follow the instructions to obtain an authentication accountAK/SK,请妥善保管AK/SK信息.
3.3 开通OCR文字识别服务
The mouse points to the upper left corner of the page“服务列表”,Find it after expansion“人工智能”下的“文字识别”点击打开.
In the upper left corner of the page will beThe area switches to“北京四”,找到“通用文字识别”点击“开通服务”.
3.4 Get the health code identification code
浏览器打开:https://health-qr-recognition-code.obs.cn-north-4.myhuaweicloud.com/Health-QR-Recognition.txt,下载文件,保存本地,以备后续步骤使用.
3.5 Configure health code recognition函数
3.5.1 创建函数
The mouse points to the upper left corner of the page“服务列表”,Find it after expansion“算”下的“函数工作流(functionGraph)”点击打开.
Navigate on the left栏展开“函数”菜单,点击选择“函数列表”,Then click the upper right corner of the function list page“创建函数”按钮.
在“Create a function page”Custom input function name(我这里用的是Health-QR-Recognition),其他配置默认,点击“Create a function button”.
3.5.2 修改代码
页面跳转到 函数详情页面,将index.jsThe code inside the file is removed,用3.4Steps get code replacement,点击“部署”按钮进行保存.
3.5.3 添加依赖包
向下滚动页面,点击“添加依赖包”按钮.
按“ocr”搜索依赖包,选择“cloud-ocr-sdk-nodejs-1.0.3”Click after the dependency package“确认”按钮.
3.5.4 Add environment scalars
切换至“设置”页签,选择“环境变量”,点击“Add environment scalars”按钮.
添加键:ocrEndpoint,值:ocr.cn-north-4.myhuaweicloud.com,后点击“保存”按钮.
3.5.5 开通日志服务
切换到“监控”页签,选择“日志”,点击“立即开通”按钮.
3.5.6 创建触发器
还是在“设置”页签,选择点击“触发器”页签,点击“创建触发器”按钮.
on the Create Trigger page,触发器类型选择“对象存储服务(OBS)” 后点击“创建桶”.
跳转到OBSService Create Bucket page,Configure and create as shown belowOBS桶后,点击“立即创建”按钮(If there is a prompt pop-up box,点击“确定”即可),完成OBSbucket creation.
区域:华北-北京四
数据冗余存储策略:单AZ存储
桶名称:自定义(我这里用的是“health-qr-healthsource-img-obs”)
Other content defaults
点击“立即创建”按钮.
待OBS创建完毕,Return to the Function Create Trigger page,点击按钮刷新,
桶:Select the bucket you just created(That is, the bucket with the custom name in the previous step)
事件:选择Put,Post事件
后缀:jpg(上传图片的后缀,Consistent with the suffix of the subsequently recognized picture)
后点击“确定”按钮,完成OBS触发器创建.
3.6 上传图片触发函数执行
回到OBS列表页,Select Open previously createdOBS.
Navigate on the left栏选择“对象”,点击 “上传对象”按钮,Drag and drop the local health code to the red box.
点击“上传”按钮.
3.7 View the function execution log
Enter on the function page“监控”页签,选择“日志”,You can see that the image upload has triggered the function execution(Without logging,You can wait for a while,Log synchronization is slightly delayed),Click to invoke the result as“执行成功”对应的“请求ID”.
Read the log content,可以看到,The uploaded health code content has passedjson格式返回.
4 后续
This experiment was passedOBSBy uploading the health code,The trigger function identifies the content of the health code,Of course, this is the core part of image content recognition,If you want to batch process and store the results,Also need to develop a small program,As the entrance for users to upload health code pictures,The results of image analysis need to be further extracted and stored,And abnormal code timely alarm,Here they are introduced one by one,Let the developers play freely.
边栏推荐
- pig4cloud服务架构使用
- Distributed current limiting, hand & redisson implementation
- Process finished with exit code 1
- Crack detection technology based on deep learning
- 免费的中英文翻译软件-自动批量中英文翻译软件推荐大全
- [kali-information collection] (1.8) ARP reconnaissance tool _Netdiscover
- 使用mosquitto过程中的问题解决
- numpy&pands 中的unique
- 7种最常用数据分析思维,解决95%的分析难题
- MyCat2的介绍与安装以及基本使用
猜你喜欢
随机推荐
JVM简介
干测试这些年,去过阿里也去过小公司,给年轻测试员们一个忠告...
【kali-信息收集】(1.8)ARP侦查工具_Netdiscover
Create your own app applet ecosystem with applet containers
Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单。
Thymeleaf
SQL函数 $TRANSLATE
故障分析 | 一条 SELECT 语句跑崩了 MySQL ,怎么回事?
[kali-information collection] (1.8) ARP reconnaissance tool _Netdiscover
Likou 209 - String with the Minimum Length - Sliding Window Method
手撸架构,Redis面试41问
linux basic command explanation
手撸架构,Mysql 面试126问
ABAP-OOAVL template program
DTG-SSOD: The latest semi-supervised detection framework, Dense Teacher (with paper download)
如何更好评估信用贷风险?看这场评分卡模型直播就可以了
Crack detection technology based on deep learning
太厉害了,终于有人能把TCP/IP 协议讲的明明白白了
力扣35-搜索插入位置——二分查找
7种最常用数据分析思维,解决95%的分析难题