npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

esearch-ocr

v5.1.5

Published

paddleocr models run on onnx

Downloads

52

Readme

eSearch-OCR

本仓库是 eSearch的 OCR 服务依赖

支持本地 OCR(基于 PaddleOCR

PaddleOCR License

paddle 预测库

基于onnxruntime的 web runtime,使用 wasm 运行,未来可能使用 webgl 甚至是 webgpu。

模型需要转换为 onnx 才能使用:Paddle2ONNX在线转换

部分模型已打包:Releases

在 js 文件下可以使用 electron 进行调试

使用

npm i esearch-ocr onnxruntime-web

web

import * as ocr from "esearch-ocr";
import * as ort from "onnxruntime-web";
const ocr = require("esearch-ocr");
const ort = require("onnxruntime-node");

[!IMPORTANT] 需要手动安装 onnxruntime(onnxruntime-node 或 onnxruntime-web,视平台而定),并在init参数中传入ort 这样设计是因为 web 和 electron 可以使用不同的 ort,很难协调,不如让开发者自己决定

浏览器或 Electron 示例

await ocr.init({
    detPath: "ocr/det.onnx",
    recPath: "ocr/rec.onnx",
    dic: "abcdefg...",
    ort,
});

const url = "data:image/png;base64,...";
ocr.ocr(url)
    .then((l) => {})
    .catch((e) => {});

或者

const localOCR = await ocr.init({
    detPath: "ocr/det.onnx",
    recPath: "ocr/rec.onnx",
    dic: "abcdefg...",
    ort,
});

localOCR.ocr(/*像上面ocr.ocr一样调用*/);

这在需要多次运行 ocr 时非常有用

node.js 示例,需要安装canvas

演示项目

init type

{
    ort: typeof import("onnxruntime-web");
    detPath: string;
    recPath: string;
    dic: string; // 文件内容,不是路径
    dev?: boolean;
    maxSide?: number;
    imgh?: number;
    imgw?: number;
    detShape?: [number, number]; // ppocr v3 需要指定为[960, 960], v4 为[640, 640]
    canvas?: (w: number, h: number) => any; // 用于node
    imageData?: any; // 用于node
    cv?: any;
}

ocr type

type PointType = [number, number]
ocr(img: ImageData): Promise<{
    text: string;
    mean: number;
    box: [PointType, PointType, PointType, PointType]; // ↖ ↗ ↘ ↙
}[]>

除了 ocr 函数,还有det函数,可单独运行,检测文字坐标;rec函数,可单独运行,检测文字内容。具体定义可看编辑器提示