zh8637688 / Wx Cardscanner
名片扫描-微信小程序,包括腾讯 ai 开放平台的使用,以及在小程序中实现图片转 Base64 的方法。
Stars: ✭ 156
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Wx Cardscanner
Weapp Qrcode Base64
微信小程序生成二维码的插件,基于base64编码输出二维码,不依赖canvas
Stars: ✭ 100 (-35.9%)
Mutual labels: base64, weapp
Weapp Native
weapp-native (wn) 像React组件开发一样来开发微信小程序,开发微信小程序框架 [此项目短时间内已不再维护,有兴趣继续的可以加群联系我]
Stars: ✭ 144 (-7.69%)
Mutual labels: weapp
Deep License Plate Recognition
Automatic License Plate Recognition (ALPR) or Automatic Number Plate Recognition (ANPR) software that works with any camera.
Stars: ✭ 148 (-5.13%)
Mutual labels: ocr
Neuralnet Handwriting Ios
A handwriting recognition example for iOS using NeuralNet
Stars: ✭ 148 (-5.13%)
Mutual labels: ocr
Tedeval
TedEval: A Fair Evaluation Metric for Scene Text Detectors
Stars: ✭ 143 (-8.33%)
Mutual labels: ocr
Easypr4android
Andorid端实时车牌识别Realtime chinese plate recoginition on android
Stars: ✭ 155 (-0.64%)
Mutual labels: ocr
Crnn
Convolutional Recurrent Neural Network (CRNN) for image-based sequence recognition.
Stars: ✭ 1,901 (+1118.59%)
Mutual labels: ocr
Tesseract4android
Fork of tess-two rewritten from scratch to support latest version of Tesseract OCR.
Stars: ✭ 148 (-5.13%)
Mutual labels: ocr
Cax
HTML5 Canvas 2D Rendering Engine - 小程序、小游戏以及 Web 通用 Canvas 渲染引擎
Stars: ✭ 1,864 (+1094.87%)
Mutual labels: weapp
Crnn.pytorch
crnn实现水平和垂直方向中文文字识别, 提供在3w多个中文字符训练的水平识别和垂直识别的预训练模型; 欢迎关注,试用和反馈问题... ...
Stars: ✭ 145 (-7.05%)
Mutual labels: ocr
East icpr
Forked from argman/EAST for the ICPR MTWI 2018 CHALLENGE
Stars: ✭ 154 (-1.28%)
Mutual labels: ocr
Yundocs
云档3.0版本,taro开发。可打包多平台小程序,h5,IOS和Android客户端。欢迎star跟进
Stars: ✭ 143 (-8.33%)
Mutual labels: weapp
Scene Text Recognition
Scene text detection and recognition based on Extremal Region(ER)
Stars: ✭ 146 (-6.41%)
Mutual labels: ocr
Wxa
🖖 渐进式小程序开发框架。轻量级的渐进式小程序开发框架,专注于小程序原生开发,提供更好的工程化、代码复用能力,提高开发效率并改善开发体验。
Stars: ✭ 149 (-4.49%)
Mutual labels: weapp
Ocrtable
Recognize tables and text from scanned images that contain tables. 从包含表格的扫描图片中识别表格和文字
Stars: ✭ 155 (-0.64%)
Mutual labels: ocr
Tesseract Macos
Objective C wrapper for the open source OCR Engine Tesseract (macOS)
Stars: ✭ 154 (-1.28%)
Mutual labels: ocr
wx-cardscanner
名片扫描-微信小程序
基础库版本 >= 1.9.0
OCR
接口调用的是腾讯ai开放平台的ocr名片扫描,请将ocr.js中的app_id、app_key替换成自己的。
经测试,腾讯ai开放平台的名片识别率较高,且能识别字段非常丰富,中英文识别率都不错。
其中签名部分计算方式如下:
let _genRequestSign = (params) => {
// 1. 对请求参数按字典升序排序
params = _sortObject(params)
// 2. 拼接键值对,value部分进行URL编码
let paramStr = ''
let keys = Object.keys(params)
for (let idx in keys) {
let key = keys[idx]
paramStr += key + '=' + encodeURIComponent(params[key]) + '&'
}
// 3. 拼接key
paramStr += 'app_key=' + app_key
// 4. md5
return md5.hexMD5(paramStr).toUpperCase()
}
let _sortObject = (obj) => {
var keys = Object.keys(obj).sort()
var newObj = {}
for (var i = 0; i < keys.length; i++) {
newObj[keys[i]] = obj[keys[i]]
}
return newObj
}
图片转Base64
接口要求将图片进行base64编码后上传,最简单的方法就是读取图片文件原始数据,然后进行base64编码,但是微信小程序没有提供文件操作接口,只能寻求其他方法
FileSystemManager.readFile({filePath: filePath, encoding: 'base64', success: (res) => {})
即可获取)。
更新,小程序Api中已提供文件读取的接口,通过在基础库1.9.0中,微信提供了一个接口wx.canvasGetImageData
可以获取canvas上指定区域的图像数据,所以可以将图片绘制到canvas上,再通过canvas获取图像数据,那么在小程序中将图片进行base64编码的流程如下:
- 绘制图片至canvas
- 获取canvas上图像数据
- 使用开源库UPNG对原始图像数据进行png编码
- png编码后数据进行base64编码
canvas = wx.createCanvasContext(canvasID)
// 1. 绘制图片至canvas
canvas.drawImage(imgPath, 0, 0, imgWidth, imgHeight)
// 绘制完成后执行回调,API 1.7.0
canvas.draw(false, () => {
// 2. 获取图像数据, API 1.9.0
wx.canvasGetImageData({
canvasId: canvasID,
x: 0,
y: 0,
width: imgWidth,
height: imgHeight,
success(res) {
// 3. png编码
let pngData = upng.encode([res.data.buffer], res.width, res.height)
// 4. base64编码
let base64 = wx.arrayBufferToBase64(pngData)
// ...
}
})
})
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].