Based on Tencent Cloud's industry-leading deep learning technology, Tencent Cloud OCR is capable of intelligently recognizing words on images and converting them into editable text. It can recognize printed text and handwriting, meeting the text recognition needs in different scenarios.
By using Serverless Framework Component and OCR SDK, you can quickly deploy a general OCR application based on COS + API + SCF, which contains the following key components:
Use npm to install Serverless Framework globally:
$ npm install -g serverless
If you have already installed Serverless Framework, you can run the following command to upgrade it to the latest version:
$ npm update -g serverless
After the installation is completed, run the serverless -v
command to view the version information of Serverless Framework and make sure that the version information is as follows or displays higher versions:
$ serverless –v
Framework Core: 1.74.1 (standalone)
Plugin: 3.6.14
SDK: 2.3.1
Components: 2.31.6
serverless init
command to download the relevant template.$ serverless init ocr-app
.env.example
file in the template, rename it to .env
, and enter your account, key information, and specified bucket (used to store uploaded images) in it.# .env
TENCENT_APP_ID=xxx
TENCENT_SECRET_ID=xxx
TENCENT_SECRET_KEY=xxx
# region of bucket
REGION=ap-guangzhou
$ npm run bootstrap
$ cd server && npm run start
$ cd frontend && npm run start
$ sls deploy --all
serverless ⚡ framework
backend:
region: ap-guangzhou
apigw:
serviceId: service-4i62q1pg
subDomain: service-4i62q1pg-1258834142.gz.apigw.tencentcs.com
environment: release
url: https://service-4i62q1pg-1258834142.gz.apigw.tencentcs.com/release/
scf:
functionName: serverless-ocr
runtime: Nodejs10.15
namespace: default
frontend:
region: ap-guangzhou
website: https://serverless-ocr-1258834142.cos-website.ap-guangzhou.myqcloud.com
38s › serverless-ocr › Success
After the deployment succeeds, you can use a browser to access the website link generated by the project to view the generated website. Click Upload Image, and the project can implement OCR with the OCR SDK.
sls remove --all
to remove the project.$ sls remove --all
serverless ⚡ framework
38s › tencent-fullstack › Success
Was this page helpful?