@arcships/light-ocr 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/index.cjs +10 -2
- package/js/index.d.ts +35 -2
- package/package.json +6 -6
package/js/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ const { loadNative } = require('./load-native.cjs');
|
|
|
7
7
|
|
|
8
8
|
const DEFAULT_MODEL = 'ppocrv6-small';
|
|
9
9
|
const MODEL_PACKAGE = '@arcships/light-ocr-model-ppocrv6-small';
|
|
10
|
-
const EXPECTED_BUNDLE_ID = 'ppocrv6-small-onnx-20260714.
|
|
10
|
+
const EXPECTED_BUNDLE_ID = 'ppocrv6-small-onnx-20260714.2';
|
|
11
11
|
|
|
12
12
|
class OcrError extends Error {
|
|
13
13
|
constructor(code, message, detail) {
|
|
@@ -117,6 +117,14 @@ class OcrEngineImpl {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
recognize(image, options = {}) {
|
|
120
|
+
return this.#recognize('recognize', image, options);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
recognizeEncoded(data, options = {}) {
|
|
124
|
+
return this.#recognize('recognizeEncoded', data, options);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#recognize(nativeMethod, image, options) {
|
|
120
128
|
let signal;
|
|
121
129
|
let nativeOptions;
|
|
122
130
|
try {
|
|
@@ -136,7 +144,7 @@ class OcrEngineImpl {
|
|
|
136
144
|
|
|
137
145
|
let operation;
|
|
138
146
|
try {
|
|
139
|
-
operation = this.#native
|
|
147
|
+
operation = this.#native[nativeMethod](image, nativeOptions);
|
|
140
148
|
} catch (error) {
|
|
141
149
|
return Promise.reject(normalizeNativeError(error));
|
|
142
150
|
}
|
package/js/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
3
|
export type PixelFormat = 'gray8' | 'rgb8' | 'bgr8' | 'rgba8';
|
|
4
|
-
export type DetectionStrategy = 'bounded' | 'upstreamExact';
|
|
4
|
+
export type DetectionStrategy = 'bounded' | 'tiled' | 'upstreamExact';
|
|
5
5
|
export type BuiltInModel = 'ppocrv6-small';
|
|
6
6
|
|
|
7
7
|
export interface DetectionOptions {
|
|
@@ -23,6 +23,7 @@ export interface ResourceLimits {
|
|
|
23
23
|
readonly maxPixels: number;
|
|
24
24
|
readonly maxDetectionSide: number;
|
|
25
25
|
readonly maxDetectionCandidates: number;
|
|
26
|
+
readonly maxDetectionTiles: number;
|
|
26
27
|
readonly maxRecognitionBatchSize: number;
|
|
27
28
|
readonly maxRecognitionWidth: number;
|
|
28
29
|
readonly maxTemporaryBytes: number;
|
|
@@ -35,7 +36,10 @@ export interface CreateEngineOptions {
|
|
|
35
36
|
readonly interOpThreads?: number;
|
|
36
37
|
readonly recognitionScoreThreshold?: number;
|
|
37
38
|
readonly recognitionBatchSize?: number;
|
|
38
|
-
readonly reducedLimits?: ResourceLimits
|
|
39
|
+
readonly reducedLimits?: Omit<ResourceLimits, 'maxDetectionTiles'> & {
|
|
40
|
+
/** Omission preserves the 0.1 reducedLimits source shape. */
|
|
41
|
+
readonly maxDetectionTiles?: number;
|
|
42
|
+
};
|
|
39
43
|
readonly queueCapacity?: number;
|
|
40
44
|
readonly maxPendingInputBytes?: number;
|
|
41
45
|
readonly detection?: DetectionOptions;
|
|
@@ -64,6 +68,17 @@ export interface RecognitionBatchShape {
|
|
|
64
68
|
readonly height: number;
|
|
65
69
|
readonly width: number;
|
|
66
70
|
}
|
|
71
|
+
export interface DetectionPassShape {
|
|
72
|
+
readonly tileOrdinal: number;
|
|
73
|
+
readonly x: number;
|
|
74
|
+
readonly y: number;
|
|
75
|
+
readonly width: number;
|
|
76
|
+
readonly height: number;
|
|
77
|
+
readonly tensorWidth: number;
|
|
78
|
+
readonly tensorHeight: number;
|
|
79
|
+
readonly contourCandidates: number;
|
|
80
|
+
readonly rawCandidates: number;
|
|
81
|
+
}
|
|
67
82
|
export interface Diagnostics {
|
|
68
83
|
readonly rejectedLines: readonly RejectedLine[];
|
|
69
84
|
readonly warnings: readonly DiagnosticWarning[];
|
|
@@ -71,14 +86,20 @@ export interface Diagnostics {
|
|
|
71
86
|
readonly acceptedBoxes: number;
|
|
72
87
|
readonly detectionInputWidth: number;
|
|
73
88
|
readonly detectionInputHeight: number;
|
|
89
|
+
readonly rawDetectionBoxes: number;
|
|
90
|
+
readonly suppressedDuplicateBoxes: number;
|
|
91
|
+
readonly maxLiveDetectionPassBuffers: number;
|
|
92
|
+
readonly detectionPasses: readonly DetectionPassShape[];
|
|
74
93
|
readonly recognitionBatchShapes: readonly RecognitionBatchShape[];
|
|
75
94
|
}
|
|
76
95
|
export interface TimingUs {
|
|
77
96
|
readonly total: number;
|
|
97
|
+
readonly decode: number;
|
|
78
98
|
readonly inputValidation: number;
|
|
79
99
|
readonly detectionPreprocess: number;
|
|
80
100
|
readonly detectionInference: number;
|
|
81
101
|
readonly detectionPostprocess: number;
|
|
102
|
+
readonly detectionMerge: number;
|
|
82
103
|
readonly cropAndSort: number;
|
|
83
104
|
readonly recognitionPreprocess: number;
|
|
84
105
|
readonly recognitionInference: number;
|
|
@@ -92,16 +113,26 @@ export interface OcrResult {
|
|
|
92
113
|
readonly timingUs: TimingUs;
|
|
93
114
|
readonly diagnostics?: Diagnostics;
|
|
94
115
|
}
|
|
116
|
+
export interface TiledDetectionInfo {
|
|
117
|
+
readonly contractVersion: 'tiled-v1';
|
|
118
|
+
readonly tileSide: 1280;
|
|
119
|
+
readonly minimumOverlap: 128;
|
|
120
|
+
readonly artificialBoundaryMargin: 32;
|
|
121
|
+
readonly mergeIouThreshold: 0.5;
|
|
122
|
+
readonly mergeIosThreshold: 0.8;
|
|
123
|
+
}
|
|
95
124
|
export interface EngineInfo {
|
|
96
125
|
readonly coreVersion: string;
|
|
97
126
|
readonly modelBundleId: string;
|
|
98
127
|
readonly modelBundleSchemaVersion: string;
|
|
128
|
+
readonly normalizedConfigSchemaVersion: string;
|
|
99
129
|
readonly backend: string;
|
|
100
130
|
readonly executionProvider: string;
|
|
101
131
|
readonly capabilities: {
|
|
102
132
|
readonly detection: boolean;
|
|
103
133
|
readonly recognition: boolean;
|
|
104
134
|
readonly textlineOrientation: boolean;
|
|
135
|
+
readonly tiledDetection: boolean;
|
|
105
136
|
};
|
|
106
137
|
readonly concurrencyMode: 'serialized_reject_when_busy';
|
|
107
138
|
readonly limits: ResourceLimits & { readonly maxConcurrentCalls: 1 };
|
|
@@ -109,6 +140,7 @@ export interface EngineInfo {
|
|
|
109
140
|
readonly interOpThreads: number;
|
|
110
141
|
readonly detectionStrategy: DetectionStrategy;
|
|
111
142
|
readonly detectionMaxSide: number;
|
|
143
|
+
readonly tiledDetection?: TiledDetectionInfo;
|
|
112
144
|
readonly defaultRecognitionScoreThreshold: number;
|
|
113
145
|
readonly defaultRecognitionBatchSize: number;
|
|
114
146
|
readonly adapter: {
|
|
@@ -139,6 +171,7 @@ export class OcrError extends Error {
|
|
|
139
171
|
export interface OcrEngine {
|
|
140
172
|
readonly info: EngineInfo;
|
|
141
173
|
recognize(image: RawImage, options?: RecognizeOptions): Promise<OcrResult>;
|
|
174
|
+
recognizeEncoded(data: Uint8Array, options?: RecognizeOptions): Promise<OcrResult>;
|
|
142
175
|
close(): Promise<void>;
|
|
143
176
|
}
|
|
144
177
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/arcships/light-ocr/issues"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@arcships/light-ocr-model-ppocrv6-small": "0.
|
|
6
|
+
"@arcships/light-ocr-model-ppocrv6-small": "0.2.0"
|
|
7
7
|
},
|
|
8
8
|
"description": "Offline PP-OCRv6 OCR for Node.js, powered by an embeddable C++ core",
|
|
9
9
|
"engines": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"module": "./js/index.mjs",
|
|
37
37
|
"name": "@arcships/light-ocr",
|
|
38
38
|
"optionalDependencies": {
|
|
39
|
-
"@arcships/light-ocr-darwin-arm64": "0.
|
|
40
|
-
"@arcships/light-ocr-darwin-x64": "0.
|
|
41
|
-
"@arcships/light-ocr-linux-x64-gnu": "0.
|
|
42
|
-
"@arcships/light-ocr-win32-x64": "0.
|
|
39
|
+
"@arcships/light-ocr-darwin-arm64": "0.2.0",
|
|
40
|
+
"@arcships/light-ocr-darwin-x64": "0.2.0",
|
|
41
|
+
"@arcships/light-ocr-linux-x64-gnu": "0.2.0",
|
|
42
|
+
"@arcships/light-ocr-win32-x64": "0.2.0"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
},
|
|
52
52
|
"type": "commonjs",
|
|
53
53
|
"types": "./js/index.d.ts",
|
|
54
|
-
"version": "0.
|
|
54
|
+
"version": "0.2.0"
|
|
55
55
|
}
|