{"id":15551276,"url":"https://github.com/leidenglai/opencv-js-qrcode","last_synced_at":"2025-04-08T03:16:24.531Z","repository":{"id":127775218,"uuid":"495319526","full_name":"leidenglai/opencv-js-qrcode","owner":"leidenglai","description":"基于opencv与wechat_qrcode实现的JS版二维码图像识别库","archived":false,"fork":false,"pushed_at":"2024-06-12T09:21:25.000Z","size":7658,"stargazers_count":160,"open_issues_count":0,"forks_count":21,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T09:46:13.249Z","etag":null,"topics":["opencvjs","qrcode-scanner","wechat-qrcode"],"latest_commit_sha":null,"homepage":"https://leidenglai.github.io/opencv-js-qrcode/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leidenglai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-23T08:22:43.000Z","updated_at":"2024-11-16T08:33:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"5784a819-fe79-40f8-afb8-d96bac4f1514","html_url":"https://github.com/leidenglai/opencv-js-qrcode","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":"0.41666666666666663","last_synced_commit":"eebf54e0631b41cd33f47c86c3edd53ad5630c1a"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leidenglai%2Fopencv-js-qrcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leidenglai%2Fopencv-js-qrcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leidenglai%2Fopencv-js-qrcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leidenglai%2Fopencv-js-qrcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leidenglai","download_url":"https://codeload.github.com/leidenglai/opencv-js-qrcode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767236,"owners_count":20992548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["opencvjs","qrcode-scanner","wechat-qrcode"],"created_at":"2024-10-02T14:03:52.292Z","updated_at":"2025-04-08T03:16:24.511Z","avatar_url":"https://github.com/leidenglai.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# OpencvQr\n## 纯JS识别照片或图片中的二维码\n本库的主要特点是：\n* 纯前端处理，无须调用后端OCR API等接口；\n* 可处理标准正方形的二维码，最重要的是可以处理照片上的二维码；二维码变形、旋转都可以识别；\n* 基于opencv 编译后的webassembly版本，编译添加了微信开源的wechat_qrcode，有极高的识别率。\n\n\n在线测试：https://leidenglai.github.io/opencv-js-qrcode/\n\n**demo code:  [leidenglai/opencv-js-qrcode Example · GitHub](https://github.com/leidenglai/opencv-js-qrcode/tree/gh-pages?tab=readme-ov-file)**\n\n## 加载二维码识别引擎\n本库中采用的是自定义编译的opencv库作为继承，添加了三方组件wechat_qrcode微信二维码引擎，并且去掉不需要的库。封装一些基本方法方便使用。\n\n### NPM\n\n``` sh\nnpm install opencv-qr --save\n```\n\n\n``` javascript\n// ES6 import\nimport OpencvQr from \"opencv-qr\";\n\n// CommonJS require\nconst OpencvQr = require(\"opencv-qr\");\n\n// 加载模型文件，模型文件请自行保存在静态目录\nconst cvQr = new OpencvQr({\n  dw: \"http://xxx.com/models/detect.caffemodel\",\n  sw: \"http://xxx.com/models/sr.caffemodel\",\n});\n\n```\n\n### Browser\n\n也可直接在浏览器中使用\n\n``` html\n\u003cscript src=\"dist/OpencvQr.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const cvQr = new OpencvQr({\n    dw: \"http://xxx.com/models/detect.caffemodel\",\n    sw: \"http://xxx.com/models/sr.caffemodel\",\n  });\n\u003c/script\u003e\n\n```\n\n\n### 使用\n\nOpencvQr暴露一个加载方法和三个使用方法, 支持typescript类型 OpencvQr.d.ts\n\n``` javascript\n  // 初始化时需自行加载模型文件，模型文件请自行保存为静态文件，不可编译转换\n  const cvQr = new OpencvQr({\n    dw: \"http://xxx.com/models/detect.caffemodel\",\n    sw: \"http://xxx.com/models/sr.caffemodel\",\n  });\n\n  // 加载canvas中的图像\n  const result = cvQr.load(\"canvasInput\");\n\n  // 返回解析结果字符\n  const infos = result?.getInfos();\n  // 返回解析的二维码截取图像 ImageData\n  const images = result?.getImages();\n  // 返回已识别的二维码图像相对于原图的位置信息 坐标和宽高\n  const sizes = result?.getSizes();\n\n  // 清除加载图片，释放内存\n  result?.clear(); \n  // or\n  cvQr.clear();\n\n```\n\n\n## 浏览器兼容性：\n暨WebAssembly兼容性，基本上现代浏览器都是支持的：\n\u003cimg width=\"789\" alt=\"CleanShot 2022-05-23 at 17 16 35@2x\" src=\"https://user-images.githubusercontent.com/11383747/169796444-07af908a-48a6-448f-b458-56175ad2576d.png\"\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleidenglai%2Fopencv-js-qrcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleidenglai%2Fopencv-js-qrcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleidenglai%2Fopencv-js-qrcode/lists"}