cronapp-plugin-mlkit 1.0.3 → 4.4.0-RC.8
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/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
<?xml version=
|
|
2
|
-
<plugin id="cronapp-plugin-mlkit" version="
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<plugin id="cronapp-plugin-mlkit" version="4.4.0-RC.8" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
3
|
<name>CronappMLKitPlugin</name>
|
|
4
4
|
|
|
5
5
|
<js-module name="CronappMLKitPlugin" src="www/cronapp-mlkit.js">
|
|
6
|
-
<clobbers target="CronappMLKitPlugin"
|
|
6
|
+
<clobbers target="CronappMLKitPlugin"/>
|
|
7
7
|
</js-module>
|
|
8
8
|
<platform name="ios">
|
|
9
9
|
<dependency id="cordova-plugin-add-swift-support" version="2.0.2"/>
|
|
10
10
|
|
|
11
11
|
<config-file target="config.xml" parent="/*">
|
|
12
12
|
<feature name="CronappMLKitPlugin">
|
|
13
|
-
<param name="ios-package" value="CronappMLKitPlugin"
|
|
14
|
-
<param name="onload" value="true"
|
|
13
|
+
<param name="ios-package" value="CronappMLKitPlugin"/>
|
|
14
|
+
<param name="onload" value="true"/>
|
|
15
15
|
</feature>
|
|
16
16
|
</config-file>
|
|
17
17
|
|
|
18
|
-
<source-file src="src/ios/CronappMLKitPlugin.swift"
|
|
19
|
-
<source-file src="src/ios/CronappMLKitExtensions.swift"
|
|
18
|
+
<source-file src="src/ios/CronappMLKitPlugin.swift"/>
|
|
19
|
+
<source-file src="src/ios/CronappMLKitExtensions.swift"/>
|
|
20
20
|
|
|
21
21
|
<podspec>
|
|
22
22
|
<config>
|
|
@@ -32,20 +32,18 @@
|
|
|
32
32
|
</platform>
|
|
33
33
|
|
|
34
34
|
<platform name="android">
|
|
35
|
-
<dependency id="cordova-plugin-androidx" version="^2.0.0"
|
|
36
|
-
<dependency id="cordova-plugin-androidx-adapter" version="^1.1.1"
|
|
35
|
+
<dependency id="cordova-plugin-androidx" version="^2.0.0"/>
|
|
36
|
+
<dependency id="cordova-plugin-androidx-adapter" version="^1.1.1"/>
|
|
37
37
|
|
|
38
38
|
<config-file target="res/xml/config.xml" parent="/*">
|
|
39
39
|
<feature name="CronappMLKitPlugin">
|
|
40
|
-
<param name="android-package" value="io.cronapp.mlkit.CronappMLKitPlugin"
|
|
41
|
-
<param name="onload" value="true"
|
|
40
|
+
<param name="android-package" value="io.cronapp.mlkit.CronappMLKitPlugin"/>
|
|
41
|
+
<param name="onload" value="true"/>
|
|
42
42
|
</feature>
|
|
43
43
|
</config-file>
|
|
44
44
|
|
|
45
45
|
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
|
46
|
-
<meta-data
|
|
47
|
-
android:name="com.google.mlkit.vision.DEPENDENCIES"
|
|
48
|
-
android:value="ocr" />
|
|
46
|
+
<meta-data android:name="com.google.mlkit.vision.DEPENDENCIES" android:value="ocr"/>
|
|
49
47
|
</config-file>
|
|
50
48
|
|
|
51
49
|
<source-file src="src/android/CronappMLKitPlugin.java" target-dir="io/cronapp/mlkit"/>
|
|
@@ -62,4 +60,4 @@
|
|
|
62
60
|
<framework src="com.google.mlkit:face-detection:$MKLKIT_VERSION_FACE"/>
|
|
63
61
|
|
|
64
62
|
</platform>
|
|
65
|
-
</plugin>
|
|
63
|
+
</plugin>
|
|
@@ -222,7 +222,7 @@ public class CronappMLKitPlugin extends CordovaPlugin {
|
|
|
222
222
|
message = message
|
|
223
223
|
.replace("data:image/png;base64,", "")
|
|
224
224
|
.replace("data:image/jpeg;base64,", "");
|
|
225
|
-
byte[] decodedString = Base64.decode(message, Base64.DEFAULT);
|
|
225
|
+
byte[] decodedString = Base64.decode(message.trim(), Base64.DEFAULT);
|
|
226
226
|
Bitmap bitMap = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
|
|
227
227
|
InputImage image = InputImage.fromBitmap(bitMap, 0);
|
|
228
228
|
return image;
|
|
@@ -87,11 +87,7 @@ class CronappMLKitPlugin: CDVPlugin {
|
|
|
87
87
|
let pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAs: error.localizedDescription)
|
|
88
88
|
self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
|
|
89
89
|
} else {
|
|
90
|
-
|
|
91
|
-
options.performanceMode = .fast
|
|
92
|
-
options.classificationMode = .all
|
|
93
|
-
|
|
94
|
-
let faceDetector = FaceDetector.faceDetector(options: self.createFaceDetectorOptions(from: optionsDict as AnyObject))
|
|
90
|
+
let faceDetector = FaceDetector.faceDetector(options: self.createFaceDetectorOptions(from: optionsDict as AnyObject))
|
|
95
91
|
let visionImage = VisionImage(image: image!)
|
|
96
92
|
faceDetector.process(visionImage) { (faces, error) in
|
|
97
93
|
if let error = error {
|
|
@@ -168,9 +164,11 @@ class CronappMLKitPlugin: CDVPlugin {
|
|
|
168
164
|
|
|
169
165
|
private func getImage(imageURL: String, _ completion: @escaping (_ image: UIImage?, _ error: Error?) -> Void) {
|
|
170
166
|
if imageURL.contains("data:") {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
let b64 = imageURL
|
|
168
|
+
.replacingOccurrences(of: "data:image/jpeg;base64,", with: "")
|
|
169
|
+
.replacingOccurrences(of: "data:image/png;base64,", with: "")
|
|
170
|
+
.trimmingCharacters(in: NSCharacterSet.whitespacesAndNewlines)
|
|
171
|
+
guard let data = Data(base64Encoded: b64),
|
|
174
172
|
let image = UIImage(data: data) else {
|
|
175
173
|
let error = NSError(domain: "cronapp-plugin-mlkit",
|
|
176
174
|
code: -1,
|