capacitor-card-scanner 0.3.2 → 0.3.4

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/README.md CHANGED
@@ -130,8 +130,8 @@ await CardScanner.removeAllListeners();
130
130
  start(options?: StartOptions | undefined) => Promise<void>
131
131
  ```
132
132
 
133
- Opens the camera **behind** the WebView. The WebView background is made
134
- transparent, so the HTML page must also use transparent backgrounds
133
+ Opens the camera **behind** the WebView. The WebView background is made
134
+ transparent, so the HTML page must also use transparent backgrounds
135
135
  where the camera should be visible.
136
136
 
137
137
  | Param | Type |
@@ -216,7 +216,7 @@ Switches between the rear and front camera.
216
216
  startDetection(options?: DetectionOptions | undefined) => Promise<void>
217
217
  ```
218
218
 
219
- Starts looking for cards: draws a red rectangle around the card and reads
219
+ Starts looking for cards: draws a red rectangle around the card and reads
220
220
  its text, emitting `cardDetected`. Requires `start()` first. Android only.
221
221
 
222
222
  | Param | Type |
@@ -328,19 +328,24 @@ requestPermissions() => Promise<PermissionStatus>
328
328
 
329
329
  #### DetectionOptions
330
330
 
331
- | Prop | Type | Description | Default |
332
- | --------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
333
- | **`intervalMs`** | <code>number</code> | Minimum time between two OCR runs, in milliseconds. The red rectangle is updated on every frame regardless. | <code>300</code> |
334
- | **`stableFrames`** | <code>number</code> | How many consecutive OCR runs must read the same card before `cardDetected` fires. | <code>2</code> |
335
- | **`includeImage`** | <code>boolean</code> | Include a JPEG of the detected card in the event. | <code>false</code> |
336
- | **`cardAspectRatio`** | <code>number</code> | Expected width / height of an upright card. Only upright cards are detected; a card lying sideways falls outside the tolerance. | <code>0.716 (63 x 88 mm)</code> |
337
- | **`aspectTolerance`** | <code>number</code> | Allowed relative deviation from `cardAspectRatio` (0.15 = ±15%). Increase it if tilted cards are not detected. | <code>0.15</code> |
338
- | **`minCardArea`** | <code>number</code> | Smallest card size, as a fraction of the camera frame (0-1). | <code>0.08</code> |
339
- | **`maxCardArea`** | <code>number</code> | Largest card size, as a fraction of the camera frame (0-1). | <code>0.9</code> |
340
- | **`requireCard`** | <code>boolean</code> | Only read text when a card-shaped object is visible. When false, the whole frame is read if no card is found. | <code>true</code> |
341
- | **`debug`** | <code>boolean</code> | Every object found is always outlined: red when accepted as a card, grey when rejected. With `debug`, each outline is also labelled with its area (`a`), width/height ratio (`r`) and the filter that rejected it. Use it to tune the filters above. | <code>false</code> |
342
- | **`showRejected`** | <code>boolean</code> | Outline (in grey) the objects that were not accepted as a card. The accepted card is always outlined in red. | <code>true</code> |
343
- | **`repeatAfterMs`** | <code>number</code> | How long (ms) the card must be out of view before the same card can be reported again. While a card stays in view it is reported only once. | <code>1500</code> |
331
+ | Prop | Type | Description | Default |
332
+ | ------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
333
+ | **`intervalMs`** | <code>number</code> | Minimum time between two OCR runs, in milliseconds. The red rectangle is updated on every frame regardless. | <code>300</code> |
334
+ | **`stableFrames`** | <code>number</code> | How many consecutive OCR runs must read the same card before `cardDetected` fires. | <code>2</code> |
335
+ | **`includeImage`** | <code>boolean</code> | Include a JPEG of the detected card in the event. | <code>false</code> |
336
+ | **`cardAspectRatio`** | <code>number</code> | Expected width / height of an upright card. Only upright cards are detected; a card lying sideways falls outside the tolerance. | <code>0.716 (63 x 88 mm)</code> |
337
+ | **`aspectTolerance`** | <code>number</code> | Allowed relative deviation from `cardAspectRatio` (0.15 = ±15%). Increase it if tilted cards are not detected. | <code>0.15</code> |
338
+ | **`minCardArea`** | <code>number</code> | Smallest card size, as a fraction of the camera frame (0-1). | <code>0.08</code> |
339
+ | **`maxCardArea`** | <code>number</code> | Largest card size, as a fraction of the camera frame (0-1). | <code>0.9</code> |
340
+ | **`requireCard`** | <code>boolean</code> | Only read text when a card-shaped object is visible. When false, the whole frame is read if no card is found. | <code>true</code> |
341
+ | **`debug`** | <code>boolean</code> | Every object found is always outlined: red when accepted as a card, grey when rejected. With `debug`, each outline is also labelled with its area (`a`), width/height ratio (`r`) and the filter that rejected it. Use it to tune the filters above. | <code>false</code> |
342
+ | **`showRejected`** | <code>boolean</code> | Outline (in grey) the objects that were not accepted as a card. The accepted card is always outlined in red. | <code>true</code> |
343
+ | **`repeatAfterMs`** | <code>number</code> | How long (ms) the card must be out of view before the same card can be reported again. While a card stays in view it is reported only once. | <code>1500</code> |
344
+ | **`cardGapMs`** | <code>number</code> | While the card outline stays in view, at most one card is reported, even if later readings give a different name. The outline must disappear for longer than this (ms) for the next card to be read, e.g. when swapping cards. | <code>500</code> |
345
+ | **`sameCardMaxDistance`** | <code>number</code> | Two card images whose perceptual hashes differ in at most this many bits (of 64) are treated as the same card. Lower = stricter. Lets a card slid over another one be reported without the outline disappearing. | <code>16</code> |
346
+ | **`nameLines`** | <code>number</code> | The card name is looked for only in the first N lines of text on the card, top to bottom. | <code>3</code> |
347
+ | **`reservedWords`** | <code>string[]</code> | Words/phrases that are never the card name (card types, subtypes...). A line made only of these words is skipped, so "Trainer" or "Stage 1" are ignored but "Energy Retrieval" is still a name. Replaces the defaults. Also matched without spaces, so "STAGE1" counts as "Stage 1". | <code>['Basic', 'Stage', 'Stage 1', 'Stage 2', 'Trainer', 'Item', 'Supporter', 'Stadium', 'Energy', 'Special Energy', 'Basic Energy', 'Pokémon', 'Pokémon Tool', 'Tera']</code> |
348
+ | **`reservedPrefixes`** | <code>string[]</code> | Lines starting with any of these are never the card name. Replaces the defaults. | <code>['Evolves from', 'HP']</code> |
344
349
 
345
350
 
346
351
  #### PluginListenerHandle
@@ -352,14 +357,15 @@ requestPermissions() => Promise<PermissionStatus>
352
357
 
353
358
  #### CardDetectedEvent
354
359
 
355
- | Prop | Type | Description |
356
- | --------------------- | ----------------------------------- | ---------------------------------------------------------------------------- |
357
- | **`name`** | <code>string</code> | Best guess for the card name (topmost line of text on the card). |
358
- | **`collectorNumber`** | <code>string</code> | Collector number, e.g. `025/165`. |
359
- | **`text`** | <code>string</code> | All text read on the card. |
360
- | **`lines`** | <code>TextLine[]</code> | |
361
- | **`cardBox`** | <code><a href="#box">Box</a></code> | Where the card is in the camera frame. Missing if no card outline was found. |
362
- | **`image`** | <code>string</code> | Base64 JPEG of the card, when `includeImage` is true. |
360
+ | Prop | Type | Description |
361
+ | --------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
362
+ | **`name`** | <code>string</code> | Best guess for the card name (topmost line of text on the card). |
363
+ | **`collectorNumber`** | <code>string</code> | Collector number, e.g. `025/165`. |
364
+ | **`text`** | <code>string</code> | All text read on the card. |
365
+ | **`lines`** | <code>TextLine[]</code> | |
366
+ | **`cardBox`** | <code><a href="#box">Box</a></code> | Where the card is in the camera frame. Missing if no card outline was found. |
367
+ | **`image`** | <code>string</code> | Base64 JPEG of the card, when `includeImage` is true. |
368
+ | **`imageHash`** | <code>string</code> | 64-bit perceptual hash of the card image (16 hex characters). Photos of the same card give hashes that differ in only a few bits. |
363
369
 
364
370
 
365
371
  #### TextLine