cronapp-plugin-mlkit 1.0.3 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cronapp-plugin-mlkit",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "cordova": {
6
6
  "id": "cronapp-plugin-mlkit",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cronapp-plugin-mlkit" version="1.0.3" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <plugin id="cronapp-plugin-mlkit" version="1.0.4" 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">
@@ -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
- let options = FaceDetectorOptions()
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
- guard let data = Data(base64Encoded: imageURL
172
- .replacingOccurrences(of: "data:image/jpeg;base64,", with: "")
173
- .replacingOccurrences(of: "data:image/png;base64,", with: "")),
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,