@scr2em/capacitor-scanner 6.0.11 → 6.0.18
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 +85 -18
- package/android/build.gradle +29 -18
- package/android/src/main/java/com/leadliaion/capacitorscanner/CapacitorScannerPlugin.java +1226 -190
- package/android/src/main/java/com/leadliaion/capacitorscanner/DetectionOverlay.java +82 -0
- package/android/src/main/libs/rectangle-detector/build.gradle +73 -0
- package/android/src/main/libs/rectangle-detector/consumer-rules.pro +0 -0
- package/android/src/main/libs/rectangle-detector/proguard-rules.pro +21 -0
- package/android/src/main/libs/rectangle-detector/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/DetectionAccuracy.kt +32 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/RectangleDetector.kt +17 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/RectangleDetectorImpl.kt +84 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/dto/DetectionResult.kt +11 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/dto/Rectangle.kt +94 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/extension/BitmapExt.kt +10 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/strategy/AdaptiveThresholdStrategy.kt +38 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/strategy/CannyAlgorithmStrategy.kt +62 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/strategy/CompositeContourDetectionStrategy.kt +15 -0
- package/android/src/main/libs/rectangle-detector/src/main/java/jp/co/smartbank/rectangledetector/strategy/ContourDetectionStrategy.kt +44 -0
- package/dist/docs.json +101 -28
- package/dist/esm/definitions.d.ts +20 -0
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorScannerPlugin/CapacitorScannerPlugin.swift +584 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,10 @@ npx cap sync
|
|
|
22
22
|
* [`flipCamera()`](#flipcamera)
|
|
23
23
|
* [`toggleFlash()`](#toggleflash)
|
|
24
24
|
* [`addListener('barcodeScanned', ...)`](#addlistenerbarcodescanned-)
|
|
25
|
+
* [`addListener('rectangleDetected', ...)`](#addlistenerrectangledetected-)
|
|
25
26
|
* [`removeAllListeners()`](#removealllisteners)
|
|
27
|
+
* [`enableObjectDetection(...)`](#enableobjectdetection)
|
|
28
|
+
* [`disableObjectDetection()`](#disableobjectdetection)
|
|
26
29
|
* [Type Aliases](#type-aliases)
|
|
27
30
|
* [Enums](#enums)
|
|
28
31
|
|
|
@@ -34,45 +37,51 @@ npx cap sync
|
|
|
34
37
|
### startScanning(...)
|
|
35
38
|
|
|
36
39
|
```typescript
|
|
37
|
-
startScanning(options?: ScannerOptions | undefined) =>
|
|
40
|
+
startScanning(options?: ScannerOptions | undefined) => any
|
|
38
41
|
```
|
|
39
42
|
|
|
40
43
|
| Param | Type |
|
|
41
44
|
| ------------- | --------------------------------------------------------- |
|
|
42
45
|
| **`options`** | <code><a href="#scanneroptions">ScannerOptions</a></code> |
|
|
43
46
|
|
|
47
|
+
**Returns:** <code>any</code>
|
|
48
|
+
|
|
44
49
|
--------------------
|
|
45
50
|
|
|
46
51
|
|
|
47
52
|
### stopScanning()
|
|
48
53
|
|
|
49
54
|
```typescript
|
|
50
|
-
stopScanning() =>
|
|
55
|
+
stopScanning() => any
|
|
51
56
|
```
|
|
52
57
|
|
|
58
|
+
**Returns:** <code>any</code>
|
|
59
|
+
|
|
53
60
|
--------------------
|
|
54
61
|
|
|
55
62
|
|
|
56
63
|
### openSettings()
|
|
57
64
|
|
|
58
65
|
```typescript
|
|
59
|
-
openSettings() =>
|
|
66
|
+
openSettings() => any
|
|
60
67
|
```
|
|
61
68
|
|
|
69
|
+
**Returns:** <code>any</code>
|
|
70
|
+
|
|
62
71
|
--------------------
|
|
63
72
|
|
|
64
73
|
|
|
65
74
|
### capturePhoto(...)
|
|
66
75
|
|
|
67
76
|
```typescript
|
|
68
|
-
capturePhoto(options?: CapturePhotoOptions | undefined) =>
|
|
77
|
+
capturePhoto(options?: CapturePhotoOptions | undefined) => any
|
|
69
78
|
```
|
|
70
79
|
|
|
71
80
|
| Param | Type |
|
|
72
81
|
| ------------- | ------------------------------------------------------------------- |
|
|
73
82
|
| **`options`** | <code><a href="#capturephotooptions">CapturePhotoOptions</a></code> |
|
|
74
83
|
|
|
75
|
-
**Returns:** <code>
|
|
84
|
+
**Returns:** <code>any</code>
|
|
76
85
|
|
|
77
86
|
--------------------
|
|
78
87
|
|
|
@@ -80,10 +89,10 @@ capturePhoto(options?: CapturePhotoOptions | undefined) => Promise<CapturePhotoR
|
|
|
80
89
|
### checkPermissions()
|
|
81
90
|
|
|
82
91
|
```typescript
|
|
83
|
-
checkPermissions() =>
|
|
92
|
+
checkPermissions() => any
|
|
84
93
|
```
|
|
85
94
|
|
|
86
|
-
**Returns:** <code>
|
|
95
|
+
**Returns:** <code>any</code>
|
|
87
96
|
|
|
88
97
|
--------------------
|
|
89
98
|
|
|
@@ -91,10 +100,10 @@ checkPermissions() => Promise<PermissionsResult>
|
|
|
91
100
|
### requestPermissions()
|
|
92
101
|
|
|
93
102
|
```typescript
|
|
94
|
-
requestPermissions() =>
|
|
103
|
+
requestPermissions() => any
|
|
95
104
|
```
|
|
96
105
|
|
|
97
|
-
**Returns:** <code>
|
|
106
|
+
**Returns:** <code>any</code>
|
|
98
107
|
|
|
99
108
|
--------------------
|
|
100
109
|
|
|
@@ -102,19 +111,21 @@ requestPermissions() => Promise<PermissionsResult>
|
|
|
102
111
|
### flipCamera()
|
|
103
112
|
|
|
104
113
|
```typescript
|
|
105
|
-
flipCamera() =>
|
|
114
|
+
flipCamera() => any
|
|
106
115
|
```
|
|
107
116
|
|
|
117
|
+
**Returns:** <code>any</code>
|
|
118
|
+
|
|
108
119
|
--------------------
|
|
109
120
|
|
|
110
121
|
|
|
111
122
|
### toggleFlash()
|
|
112
123
|
|
|
113
124
|
```typescript
|
|
114
|
-
toggleFlash() =>
|
|
125
|
+
toggleFlash() => any
|
|
115
126
|
```
|
|
116
127
|
|
|
117
|
-
**Returns:** <code>
|
|
128
|
+
**Returns:** <code>any</code>
|
|
118
129
|
|
|
119
130
|
--------------------
|
|
120
131
|
|
|
@@ -122,7 +133,7 @@ toggleFlash() => Promise<FlashResult>
|
|
|
122
133
|
### addListener('barcodeScanned', ...)
|
|
123
134
|
|
|
124
135
|
```typescript
|
|
125
|
-
addListener(event: 'barcodeScanned', listenerFunc: (result: BarcodeScannedEvent) => void) =>
|
|
136
|
+
addListener(event: 'barcodeScanned', listenerFunc: (result: BarcodeScannedEvent) => void) => any
|
|
126
137
|
```
|
|
127
138
|
|
|
128
139
|
| Param | Type |
|
|
@@ -130,15 +141,61 @@ addListener(event: 'barcodeScanned', listenerFunc: (result: BarcodeScannedEvent)
|
|
|
130
141
|
| **`event`** | <code>'barcodeScanned'</code> |
|
|
131
142
|
| **`listenerFunc`** | <code>(result: <a href="#barcodescannedevent">BarcodeScannedEvent</a>) => void</code> |
|
|
132
143
|
|
|
144
|
+
**Returns:** <code>any</code>
|
|
145
|
+
|
|
146
|
+
--------------------
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### addListener('rectangleDetected', ...)
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
addListener(event: 'rectangleDetected', listenerFunc: (result: RectangleDetectedEvent) => void) => any
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
| Param | Type |
|
|
156
|
+
| ------------------ | ---------------------------------------------------------------------------------------------- |
|
|
157
|
+
| **`event`** | <code>'rectangleDetected'</code> |
|
|
158
|
+
| **`listenerFunc`** | <code>(result: <a href="#rectangledetectedevent">RectangleDetectedEvent</a>) => void</code> |
|
|
159
|
+
|
|
160
|
+
**Returns:** <code>any</code>
|
|
161
|
+
|
|
133
162
|
--------------------
|
|
134
163
|
|
|
135
164
|
|
|
136
165
|
### removeAllListeners()
|
|
137
166
|
|
|
138
167
|
```typescript
|
|
139
|
-
removeAllListeners() =>
|
|
168
|
+
removeAllListeners() => any
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Returns:** <code>any</code>
|
|
172
|
+
|
|
173
|
+
--------------------
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
### enableObjectDetection(...)
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
enableObjectDetection({ types }: ObjectDetectionOptions) => any
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
| Param | Type |
|
|
183
|
+
| --------- | ------------------------------------------------------------------------- |
|
|
184
|
+
| **`__0`** | <code><a href="#objectdetectionoptions">ObjectDetectionOptions</a></code> |
|
|
185
|
+
|
|
186
|
+
**Returns:** <code>any</code>
|
|
187
|
+
|
|
188
|
+
--------------------
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
### disableObjectDetection()
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
disableObjectDetection() => any
|
|
140
195
|
```
|
|
141
196
|
|
|
197
|
+
**Returns:** <code>any</code>
|
|
198
|
+
|
|
142
199
|
--------------------
|
|
143
200
|
|
|
144
201
|
|
|
@@ -150,14 +207,14 @@ removeAllListeners() => Promise<void>
|
|
|
150
207
|
<code>{ formats?: BarcodeFormat[]; cameraDirection?: 'BACK' | 'FRONT'; debounceTimeInMilli?: number }</code>
|
|
151
208
|
|
|
152
209
|
|
|
153
|
-
####
|
|
210
|
+
#### CapturePhotoOptions
|
|
154
211
|
|
|
155
|
-
<code>{
|
|
212
|
+
<code>{ /** * The desired quality of the captured image, expressed as a value between 0.0 (lowest quality, smallest file size) * and 1.0 (highest quality, largest file size). Defaults to 1.0. * This parameter directly influences the compression level of the resulting JPEG image. */ qualityRatio?: number; }</code>
|
|
156
213
|
|
|
157
214
|
|
|
158
|
-
####
|
|
215
|
+
#### CapturePhotoResult
|
|
159
216
|
|
|
160
|
-
<code>{
|
|
217
|
+
<code>{ imageBase64: string }</code>
|
|
161
218
|
|
|
162
219
|
|
|
163
220
|
#### PermissionsResult
|
|
@@ -175,6 +232,16 @@ removeAllListeners() => Promise<void>
|
|
|
175
232
|
<code>{ scannedCode: string; format: string }</code>
|
|
176
233
|
|
|
177
234
|
|
|
235
|
+
#### RectangleDetectedEvent
|
|
236
|
+
|
|
237
|
+
<code>{ detected: true }</code>
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
#### ObjectDetectionOptions
|
|
241
|
+
|
|
242
|
+
<code>{ types: ('barcode' | 'businessCard')[], /** * Optional padding ratio to apply around detected rectangles when cropping. * Value must be between 0 and 1, where: * - 0 = no padding * - 1 = 100% padding (not recommended) * Default is 0.01 (1%) if not specified. */ paddingRatio?: number }</code>
|
|
243
|
+
|
|
244
|
+
|
|
178
245
|
### Enums
|
|
179
246
|
|
|
180
247
|
|
package/android/build.gradle
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
ext {
|
|
2
2
|
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
-
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.
|
|
4
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.
|
|
5
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
|
|
6
|
+
|
|
7
|
+
// Rectangle detector variables
|
|
8
|
+
compile_sdk_version = 35
|
|
9
|
+
min_sdk_version = 23
|
|
10
|
+
target_sdk_version = 35
|
|
11
|
+
version_code = 1
|
|
12
|
+
version_name = "1.0.0"
|
|
13
|
+
junit_version = '4.13.2'
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
buildscript {
|
|
@@ -11,7 +19,9 @@ buildscript {
|
|
|
11
19
|
mavenCentral()
|
|
12
20
|
}
|
|
13
21
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:8.
|
|
22
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
23
|
+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10'
|
|
24
|
+
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:2.1.0'
|
|
15
25
|
}
|
|
16
26
|
}
|
|
17
27
|
|
|
@@ -19,10 +29,10 @@ apply plugin: 'com.android.library'
|
|
|
19
29
|
|
|
20
30
|
android {
|
|
21
31
|
namespace "com.leadliaion.capacitorscanner"
|
|
22
|
-
|
|
32
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
33
|
defaultConfig {
|
|
24
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
25
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
34
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
35
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
36
|
versionCode 1
|
|
27
37
|
versionName "1.0"
|
|
28
38
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -56,19 +66,20 @@ dependencies {
|
|
|
56
66
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
67
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
68
|
|
|
59
|
-
// CameraX dependencies
|
|
60
|
-
implementation "androidx.camera:camera-core:1.1.0"
|
|
61
|
-
implementation "androidx.camera:camera-camera2:1.1.0"
|
|
62
|
-
implementation "androidx.camera:camera-lifecycle:1.1.0"
|
|
63
|
-
implementation "androidx.camera:camera-view:1.1.0"
|
|
64
|
-
|
|
65
69
|
// ML Kit Barcode Scanning
|
|
66
70
|
implementation "com.google.mlkit:barcode-scanning:17.3.0"
|
|
67
71
|
|
|
68
72
|
// Other dependencies
|
|
69
|
-
implementation "androidx.lifecycle:lifecycle-common-java8:2.
|
|
70
|
-
implementation "com.google.guava:guava:
|
|
73
|
+
implementation "androidx.lifecycle:lifecycle-common-java8:2.9.4"
|
|
74
|
+
implementation "com.google.guava:guava:33.5.0-android" // For ListenableFuture
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
//
|
|
74
|
-
|
|
76
|
+
|
|
77
|
+
// Exposed as 'api' so consuming apps get them transitively
|
|
78
|
+
api 'org.opencv:opencv:4.12.0'
|
|
79
|
+
implementation files('libs/rectangle-detector-release.aar')
|
|
80
|
+
api "androidx.camera:camera-core:1.5.1"
|
|
81
|
+
api "androidx.camera:camera-camera2:1.5.1"
|
|
82
|
+
api "androidx.camera:camera-lifecycle:1.5.1"
|
|
83
|
+
api "androidx.camera:camera-view:1.5.1"
|
|
84
|
+
|
|
85
|
+
}
|