diff --git a/cordova-plugin-hms-mltext/LICENSE b/cordova-plugin-hms-mltext/LICENSE new file mode 100644 index 00000000..490b5c70 --- /dev/null +++ b/cordova-plugin-hms-mltext/LICENSE @@ -0,0 +1,53 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and +You must cause any modified files to carry prominent notices stating that You changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/README.md b/cordova-plugin-hms-mltext/README.md new file mode 100644 index 00000000..26eb5fc7 --- /dev/null +++ b/cordova-plugin-hms-mltext/README.md @@ -0,0 +1,72 @@ +

+

Cordova HMS ML Text

+

+

+ downloads + NPM version + License +

+ +---- + +This plugin enables communication between Huawei ML SDK and Cordova platform. It exposes all +functionality provided by Huawei ML SDK. + +[> Learn More](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/introduction-0000001050765773?ha_source=hms1) + +## Installation + +### Cordova + +```bash +$ cordova plugin add @hmscore/cordova-plugin-hms-mltext +``` + +### Ionic with Cordova Runtime + +```bash +$ ionic cordova plugin add @hmscore/cordova-plugin-hms-mltext +``` + +### Ionic with Capacitor Runtime + +```bash +$ npm install @hmscore/cordova-plugin-hms-mltext +``` + +### Ionic Native Wrappers + +```bash +$ npm install @hmscore/ionic-native-hms-mltext +``` + +## Documentation + +- [Quick Start](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/preparedevenv-0000001051005805?ha_source=hms1) +- [Reference](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-References/introduction-0000001051088632?ha_source=hms1) + +### Additional Topics + +- [Text Recognition](hhttps://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/text-recognition-0000001051005809?ha_source=hms1) +- [Face Detection](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/face-detection-0000001051005815?ha_source=hms1) + +## Questions or Issues + +If you have questions about how to use HMS samples, try the following options: + +- [Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services) is the best + place for any programming questions. Be sure to tag your question with `huawei-mobile-services`. +- [GitHub](https://github.com/HMS-Core/hms-cordova-plugin) is the official repository for these + plugins, You can open an issue or submit your ideas. +- [Huawei Developer Forum](https://forums.developer.huawei.com/forumPortal/en/home?fid=0101187876626530001&ha_source=hms1) + HMS Core Module is great for general questions, or seeking recommendations and opinions. +- [Huawei Developer Docs](https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1) + is place to official documentation for all HMS Core Kits, you can find detailed documentations in + there. + +If you run into a bug in our samples, please submit an issue to +the [GitHub repository](https://github.com/HMS-Core/hms-cordova-plugin). + +## License + +Huawei ML Text Kit Cordova Plugin is licensed under the [Apache 2.0 license](LICENSE). diff --git a/cordova-plugin-hms-mltext/example/cordova/.docs/images/api_key.png b/cordova-plugin-hms-mltext/example/cordova/.docs/images/api_key.png new file mode 100644 index 00000000..1654d0ce Binary files /dev/null and b/cordova-plugin-hms-mltext/example/cordova/.docs/images/api_key.png differ diff --git a/cordova-plugin-hms-mltext/example/cordova/.docs/images/config_xml.png b/cordova-plugin-hms-mltext/example/cordova/.docs/images/config_xml.png new file mode 100644 index 00000000..2bc11566 Binary files /dev/null and b/cordova-plugin-hms-mltext/example/cordova/.docs/images/config_xml.png differ diff --git a/cordova-plugin-hms-mltext/example/cordova/.docs/images/enablemlkit.png b/cordova-plugin-hms-mltext/example/cordova/.docs/images/enablemlkit.png new file mode 100644 index 00000000..0b2950dc Binary files /dev/null and b/cordova-plugin-hms-mltext/example/cordova/.docs/images/enablemlkit.png differ diff --git a/cordova-plugin-hms-mltext/example/cordova/LICENSE b/cordova-plugin-hms-mltext/example/cordova/LICENSE new file mode 100644 index 00000000..490b5c70 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/LICENSE @@ -0,0 +1,53 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and +You must cause any modified files to carry prominent notices stating that You changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/OpenSourceSoftwareNotice.html b/cordova-plugin-hms-mltext/example/cordova/OpenSourceSoftwareNotice.html new file mode 100644 index 00000000..822f61d6 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/OpenSourceSoftwareNotice.html @@ -0,0 +1,61 @@ +

OPEN SOURCE SOFTWARE NOTICE

+ +

 

+ +

Please note we provide an open source software notice along with this product and/or this product firmware (in the following just “this product”). The open source software licenses are granted by the respective right holders. And the open source licenses prevail all other license information with regard to the respective open source software contained in the product, including but not limited to End User Software Licensing Agreement. This notice is provided on behalf of Huawei Technologies Co. Ltd. and any of its local subsidiaries which may have provided this product to you in your local country.

+ +

 

+ +

Warranty Disclaimer    

+ +

THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.

+ +

 

+ +

Copyright Notice and License Texts

+ +

Software: cordova-plugin-chooser 1.3.2

+ +

Copyright notice:

+ +

Copyright (c) 2020, Cyph, Inc., Don Coleman, Ibby Hadeed, and Impossibles

+ +

 

+ +

 

+ +

License: The Apache License

+ +

Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at

+ +

    http://www.apache.org/licenses/LICENSE-2.0

+ +

Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.

+ +

 

+ +

 

+ +

 Written Offer  

+ +

This product contains software whose rights holders license it on the terms of the GNU General Public License, version 2 (GPLv2) and/or other open source software licenses. We will provide you and any third party with the source code of the software licensed under an open source software license if you send us a written request by mail or email to the following addresses:

+ +

foss@huawei.com

+ +

detailing the name of the product and the firmware version for which you need the source code and indicating how we can contact you.

+ +

Please note you need to make a payment before you obtain the complete Corresponding Source Code from us. For how much you will pay and how we will deliver the complete Corresponding Source Code to you, we will further discuss it by mail or email.

+ +

This offer is valid to anyone in receipt of this information.

+ +

 

+ +

THIS OFFER IS VALID FOR THREE YEARS FROM THE MOMENT WE DISTRIBUTED THE PRODUCT OR FIRMWARE .

+ +

 

diff --git a/cordova-plugin-hms-mltext/example/cordova/README.md b/cordova-plugin-hms-mltext/example/cordova/README.md new file mode 100644 index 00000000..24f55f84 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/README.md @@ -0,0 +1,154 @@ +# HMS ML Text Cordova Demo + +## Contents + +- [1. Introduction](#1-introduction) +- [2. Installation Guide](#2-installation-guide) + - [2.1. Creating a Project in AppGallery Connect](#21-creating-a-project-in-appgallery-connect) + - [2.2. Configuring the Signing Certificate Fingerprint and Obtaining agconnect-services.json](#22-configuring-the-signing-certificate-fingerprint-and-obtaining-agconnect-servicesjson) + - [2.3. Cordova](#23-cordova) +- [3. Configuration and Description](#3-configuration-and-description) +- [4. Questions or Issues](#4-questions-or-issues) +- [5. Licensing and Terms](#5-licensing-and-terms) + +--- + +## 1. Introduction + +This demo application demonstrates the usage of the HMS ML Text Cordova plugin. + +--- + +## 2. Installation Guide + +Before you get started, you must register as a HUAWEI Developer and complete identity verification on the [HUAWEI Developer](https://developer.huawei.com/consumer/en/?ha_source=hms1) website. For details, please refer to [Register a HUAWEI ID](https://developer.huawei.com/consumer/en/doc/10104?ha_source=hms1). + +### 2.1. Creating a Project in AppGallery Connect + +Creating an app in AppGallery Connect is required in order to communicate with the Huawei services. To create an app, perform the following steps: + +1. Sign in to [AppGallery Connect](https://developer.huawei.com/consumer/en/service/josp/agc/index.html?ha_source=hms1) and select **My projects**. +2. Select your project from the project list or create a new one by clicking the **Add Project** button. +3. Go to **Project Setting** > **General information**, and click **Add app**. + - If an app exists in the project and you need to add a new one, expand the app selection area on the top of the page and click **Add app**. +4. On the **Add app** page, enter the app information, and click **OK**. + +### 2.2. Configuring the Signing Certificate Fingerprint and Obtaining agconnect-services.json + +A signing certificate fingerprint is used to verify the authenticity of an app when it attempts to access an HMS Core (APK) through the HMS SDK. Before using the HMS Core (APK), you must locally generate a signing certificate fingerprint and configure it in the **AppGallery Connect**. You can refer to 3rd and 4th steps of [Generating a Signing Certificate](https://developer.huawei.com/consumer/en/codelab/HMSPreparation/index.html?ha_source=hms1#2) Codelab tutorial for the certificate generation. Perform the following steps after you have generated the certificate. + +1. Sign in to [AppGallery Connect](https://developer.huawei.com/consumer/en/service/josp/agc/index.html?ha_source=hms1) and select your project from **My Projects**. Then go to **Project Setting** > **General information**. In the **App information** field, click the icon next to SHA-256 certificate fingerprint, and enter the obtained **SHA-256 certificate fingerprint**. +2. After completing the configuration, click **OK** to save the changes. (Check mark icon) +3. In the same page, click **agconnect-services.json** button to download the configuration file. + +### 2.3. Cordova + +1. Install Cordova CLI if haven't done before. + + ```bash + npm install -g cordova + ``` + +2. Open the demo project's root folder. + +3. Update the widget **`id`** property which is specified in the **`config.xml`** file. It must be same with **client > package_name** value of the **`agconnect-services.json`** file. + +4. Add the **Android platform** to the project. + + ```bash + cordova platform add android + ``` + +5. Install `HMS ML Text plugin` to the project. + + ```bash + cordova plugin add @hmscore/cordova-plugin-hms-mltext + ``` + +6. Copy **`agconnect-services.json`** file to **`/platforms/android/app`** directory. + +7. Add **`keystore(.jks)`** and **`build.json`** files to your project's root directory. + + - You can refer to 3rd and 4th steps of [Generating a Signing Certificate](https://developer.huawei.com/consumer/en/codelab/HMSPreparation/index.html?ha_source=hms1#2) Codelab tutorial page for generating keystore file. + + - Fill **`build.json`** file according to your keystore. For example: + + ```json + { + "android": { + "debug": { + "keystore": ".jks", + "storePassword": "", + "alias": "", + "password": "" + }, + "release": { + "keystore": ".jks", + "storePassword": "", + "alias": "", + "password": "" + } + } + } + ``` + +8. Update the API key which is specified in 'www/js/index.js' file. It should be same as the API key which is defined in agconnect-services.json file. + + >![api_key](.docs/images/api_key.png) + +9. Run the app. + + ```bash + cordova run android --device + ``` + +--- + +## 3. Configuration and Description + +### Configuring Obfuscation Scripts + +Before building the APK, configure the obfuscation configuration file to prevent the HMS Core SDK from being obfuscated. + +**NOTE**: This step is required only if you want to minify and obfuscate your app. By default obfuscation is disabled in Cordova and Ionic apps. + +The obfuscation is done by **ProGuard.** By default, in Cordova and Ionic apps ProGuard is disabled. Even though ProGuard is not available, ProGuard support can be added through 3rd party ProGuard plugins. If ProGuard is enabled in your project, the Huawei ML plugin's ProGuard rules need to be added to your project. These rules are as follows: + +```text +-ignorewarnings +-keepattributes *Annotation* +-keepattributes Exceptions +-keepattributes InnerClasses +-keepattributes Signature +-keep class com.huawei.hianalytics.**{*;} +-keep class com.huawei.updatesdk.**{*;} +-keep class com.huawei.hms.**{*;} +-dontwarn com.huawei.** +-keep class com.huawei.** {*;} +-dontwarn org.slf4j.** +-keep class org.slf4j.** {*;} +-dontwarn org.springframework.** +-keep class org.springframework.** {*;} +-dontwarn com.fasterxml.jackson.** +-keep class com.fasterxml.jackson.** {*;} +-repackageclasses +``` + +--- + +## 4. Questions or Issues + +If you have questions about how to use HMS samples, try the following options: + +- [Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services) is the best place for any programming questions. Be sure to tag your question with **`huawei-mobile-services`**. +- [GitHub](https://github.com/HMS-Core/hms-cordova-plugin) is the official repository for these plugins, You can open an issue or submit your ideas. +- [Huawei Developer Forum](https://forums.developer.huawei.com/forumPortal/en/home?fid=0101187876626530001&ha_source=hms1) HMS Core Module is great for general questions, or seeking recommendations and opinions. +- [Huawei Developer Docs](https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1) is place to official documentation for all HMS Core Kits, you can find detailed documentations in there. + +If you run into a bug in our samples, please submit an issue to the [GitHub repository](https://github.com/HMS-Core/hms-cordova-plugin). + +--- + +## 5. Licensing and Terms + +Huawei ML Kit Cordova Plugin is licensed under the [Apache 2.0 license](LICENSE). diff --git a/cordova-plugin-hms-mltext/example/cordova/config.xml b/cordova-plugin-hms-mltext/example/cordova/config.xml new file mode 100644 index 00000000..9b384cab --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/config.xml @@ -0,0 +1,24 @@ + + + + cordova-hms-mltext-demo + + + A sample Apache Cordova application that demonstarates the usage of cordova-plugin-hms-mltext. + + + + + + + + + + + + + + + + + diff --git a/cordova-plugin-hms-mltext/example/cordova/package.json b/cordova-plugin-hms-mltext/example/cordova/package.json new file mode 100644 index 00000000..a8af90dd --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/package.json @@ -0,0 +1,39 @@ +{ + "name": "cordova-hms-mltext-demo", + "displayName": "HMSMLDemo", + "version": "3.12.0-300", + "description": "A sample Apache Cordova application that demonstrates the usage of cordova-plugin-hms-mltext", + "license": "Apache-2.0", + "licenseFilename": "LICENSE", + "readmeFilename": "README.md", + "main": "./www/js/index.js", + "keywords": [ + "cordova", + "ecosystem:cordova", + "ml", + "hms-ml", + "huawei-ml", + "hms", + "huawei" + ], + "devDependencies": { + "cordova-plugin-chooser": "1.3.2" + }, + "cordova": { + "plugins": { + "cordova-plugin-chooser": {} + }, + "platforms": [ + "android" + ] + }, + "files": [ + ".docs", + "www", + "config.xml", + "LICENSE", + "package.json", + "README.md", + "OpenSourceSoftwareNotice.html" + ] +} diff --git a/cordova-plugin-hms-mltext/example/cordova/www/bcr.html b/cordova-plugin-hms-mltext/example/cordova/www/bcr.html new file mode 100644 index 00000000..7b6a2065 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/bcr.html @@ -0,0 +1,78 @@ + + + + + + + + + + + + + Cordova MLKit Demo + + + +
+ + +
+ +
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+ Please click bankCardDetector +
+ + + + + + + \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/css/index.css b/cordova-plugin-hms-mltext/example/cordova/www/css/index.css new file mode 100644 index 00000000..c3b6db0e --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/css/index.css @@ -0,0 +1,327 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +* { + -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ +} + +body { + -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */ + -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */ + -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ + background-color:#ffffff; + background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); + font-family: system-ui, -apple-system, -apple-system-font, 'Segoe UI', 'Roboto', sans-serif; + font-size:12px; + height:100vh; + margin:0px; + padding:0px; + /* Padding to avoid the "unsafe" areas behind notches in the screen */ + padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-right, 0px); + text-transform:uppercase; + width:100%; +} + +/* Portrait layout (default) */ +.app { + background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */ + position:absolute; /* position in the center of the screen */ + left:50%; + top:50%; + height:50px; /* text area height */ + width:225px; /* text area width */ + text-align:center; + padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */ + margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */ + /* offset horizontal: half of text area width */ +} + +/* Landscape layout (with min-width) */ +@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) { + .app { + background-position:left center; + padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */ + margin:-90px 0px 0px -198px; /* offset vertical: half of image height */ + /* offset horizontal: half of image width and text area width */ + } +} + +h1 { + font-size:24px; + font-weight:normal; + margin:0px; + overflow:visible; + padding:0px; + text-align:center; +} + +.event { + border-radius:4px; + -webkit-border-radius:4px; + color:#FFFFFF; + font-size:12px; + margin:0px 30px; + padding:2px 0px; +} + +.event.listening { + background-color:#333333; + display:block; +} + +.event.received { + background-color:#f7ded8; + display:none; +} + +@keyframes fade { + from { opacity: 1.0; } + 50% { opacity: 0.4; } + to { opacity: 1.0; } +} + +@-webkit-keyframes fade { + from { opacity: 1.0; } + 50% { opacity: 0.4; } + to { opacity: 1.0; } +} + +.blink { + animation:fade 3000ms infinite; + -webkit-animation:fade 3000ms infinite; +} + +/*Index.html buttons and div css */ +.clear {clear: both; } + +.textAlignDiv { text-align: center; } + +.textProp { font-size: 18px; } + +.selectedTextProp { + font-size: 14px; + font-weight: bold; + margin-top: 3px; +} +.twoDivProp { + width: 40%; + display: inline-block; +} +.main_div { + width: 100%; + margin-right: auto; + margin-left: auto; + background-color: gray; + margin-top: 3px; +} +.div { + display: inline-block; + width: 47%; + color: #FFF; +} +.threeDivProp { + width: 30%; +} +.fourDivProp{ + width: 24%; +} +.btn { + margin-top: 5px; + display: block; + border: 1px; + border-color: #b01228; + background-color: whitesmoke; + color: #c4142c; + width: 100%; + height: 50px; + border: none; +} + +.segmentImgCss { + height: 250px; + width: 100%; +} + +.mllogo { + text-align: center; + margin-top: 10px; + margin-bottom: 15px; +} + +.imgDiv { + margin-bottom: 10px; +} + +.mllogoText { + font-weight: bold; + margin-top: 20px; +} + +.servicesDiv { + margin-left: 20px; + height: 80px; + width: 90px; + border: 1px solid gray; + border-radius: 5px; + position: relative; + background-color: #f9e8ea; +} + +.servicesImg { + height: 50px; + width: 70px; + position: absolute; + left: 10px; + top: 5px; + margin: auto; + text-align: center; +} + +.servicesImgText { + height: 50px; + width: 70px; + position: absolute; + left: 10px; + top: 5px; + margin: auto; + text-align: center; + color:black; +} + +.newPageHref { + float: left; + margin-top: 15px; +} + +.divText { + border: 2px solid black; + padding: 5px; + margin: 5px; +} + +input[type=text] { + width: 100%; + font-size: 20px; +} + +.switch { + position: relative; + display: inline-block; + width: 60px; + height: 34px; + color:#b01228; +} + +.switch input { + opacity: 0; + width: 0; + height: 0; +} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: .4s; + transition: .4s; +} + +.slider:before { + position: absolute; + content: ""; + height: 26px; + width: 26px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; +} + +input:checked+.slider { + background-color: #c4142c; +} + +input:focus+.slider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked+.slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); +} + +/* Rounded sliders */ +.slider.round { + border-radius: 34px; +} + +.slider.round:before { + border-radius: 50%; +} + +.mllogo { + text-align: center; + margin-top: 20px; + margin-bottom: 30px; +} + +.imgDiv { + margin-bottom: 10px; +} + +.mllogoText { + font-weight: bold; + margin-top: 20px; +} + +.servicesDiv { + margin-left: 20px; + height: 80px; + width: 90px; + border: 1px solid gray; + border-radius: 5px; + position: relative; + background-color: honeydew; +} + +.servicesImg { + height: 50px; + width: 70px; + position: absolute; + left: 10px; + top: 5px; + margin: auto; + text-align: center; +} + +.servicesImgText { + position: absolute; + left: 30px; + bottom: 1px; +} + +.newPageHref { + float: left; + margin-top: 15px; +} +.textViewAFT{ + width: 200px; +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/doc.html b/cordova-plugin-hms-mltext/example/cordova/www/doc.html new file mode 100644 index 00000000..f10261eb --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/doc.html @@ -0,0 +1,62 @@ + + + + + + + + + + + + + Cordova MLKit Demo + + + +
+
+
+
+
+
+
+
+
+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/formrecog.html b/cordova-plugin-hms-mltext/example/cordova/www/formrecog.html new file mode 100644 index 00000000..c8e717a7 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/formrecog.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + Cordova MLKit Demo + + + +
+
+
+
+
+
+
+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/gcr.html b/cordova-plugin-hms-mltext/example/cordova/www/gcr.html new file mode 100644 index 00000000..a6b49506 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/gcr.html @@ -0,0 +1,55 @@ + + + + + + + + + + + + + Cordova MLKit Demo + + + + + +
+
+
+
+
+
Please click image segmentation button
+
+ + + + + + \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/icrcn.html b/cordova-plugin-hms-mltext/example/cordova/www/icrcn.html new file mode 100644 index 00000000..3636d858 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/icrcn.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + + Cordova MLKit Demo + + + + + +
+
+
+
+
+
+
+
+
+
+
Please click image segmentation button
+
+ + + + + + \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/icrvn.html b/cordova-plugin-hms-mltext/example/cordova/www/icrvn.html new file mode 100644 index 00000000..a59031af --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/icrvn.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + + Cordova MLKit Demo + + + + + +
+
+
+
+
+
+
+ +
+
+
+
Please click image segmentation button
+
+ + + + + + \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/img/icon_record.png b/cordova-plugin-hms-mltext/example/cordova/www/img/icon_record.png new file mode 100644 index 00000000..cb1f03e6 Binary files /dev/null and b/cordova-plugin-hms-mltext/example/cordova/www/img/icon_record.png differ diff --git a/cordova-plugin-hms-mltext/example/cordova/www/img/logo.png b/cordova-plugin-hms-mltext/example/cordova/www/img/logo.png new file mode 100644 index 00000000..be3964eb Binary files /dev/null and b/cordova-plugin-hms-mltext/example/cordova/www/img/logo.png differ diff --git a/cordova-plugin-hms-mltext/example/cordova/www/index.html b/cordova-plugin-hms-mltext/example/cordova/www/index.html new file mode 100644 index 00000000..54813654 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/index.html @@ -0,0 +1,159 @@ + + + + + + + + + + + + Cordova MLKit Demo + + + + + + +
+ + +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ + + + + diff --git a/cordova-plugin-hms-mltext/example/cordova/www/js/bcr.js b/cordova-plugin-hms-mltext/example/cordova/www/js/bcr.js new file mode 100644 index 00000000..185b3d86 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/js/bcr.js @@ -0,0 +1,106 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +var $imageResult = null; +var device = true; + +document.addEventListener("DOMContentLoaded", function () { + const detectType = document.getElementById("detectorType").value; + document.getElementById("bankCardDetector").addEventListener("click", () => bankCardDetector(detectType)); + document.getElementById("stopBankCardDetector").addEventListener("click", () => stopBankCardDetector()); + document.getElementById("getBankCardPicker").addEventListener("click", function () { getimgPicker(); }); + document.getElementById("startCustomViewMode").addEventListener("click", () => startCustomViewMode()); +}, false); + +async function getimgPicker() { + (async ()=>{ + const file=await chooser.getFile(); + $imageResult=file.uri; + })(); + + } + +const detectType = document.getElementById("detectorType").value; +async function bankCardDetector() { + var bankCardSDKDetectorReq = { + detectType: 0, + filePath: $imageResult, + mLBcrAnalyzerSetting: { + langType: "zh", + resultType: HMSMLTextPlugin.MLBcrResultConfig.RESULT_ALL + }, + }; + var bankCardPluginDetectorReq = { + detectType: 1, + mLBcrCaptureConfig: { + orientation: HMSMLTextPlugin.MLBcrCaptureConfig.ORIENTATION_AUTO, + resultType: HMSMLTextPlugin.MLBcrResultConfig.RESULT_ALL + }, + }; + try { + if (device == true) { + const result = await HMSMLText.bankCardDetector(bankCardSDKDetectorReq); + document.getElementById("bankCardImage").src = "data:image/jpeg;base64," + result.originalBitmap; + document.getElementById("cardNumber").value = JSON.stringify(result.number); + document.getElementById("cardExpire").value = JSON.stringify(result.expire); + document.getElementById("imageUri").value = JSON.stringify(result.originalBitmap); + } else { + const result = await HMSMLText.bankCardDetector(bankCardPluginDetectorReq); + document.getElementById("bankCardImage").src = "data:image/jpeg;base64," + result.originalBitmap; + document.getElementById("cardNumber").value = JSON.stringify(result.number); + document.getElementById("cardExpire").value = JSON.stringify(result.expire); + document.getElementById("imageUri").value = JSON.stringify(result.originalBitmap); + } + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} +async function stopBankCardDetector() { + try { + const result = await HMSMLText.stopBankCardDetector(); + alert(result) + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} + + +async function startCustomViewMode() { + var customViewModeRequest = { + isTitleAvailable: true, + title: "Place the card within the frame", + heightFactor: 0.8, + widthFactor: 0.8, + isFlashAvailable: true, + resultType: HMSMLText.MLBcrResultConfig.RESULT_ALL, + recMode: HMSMLText.RecMode.WEAK_MODE, + }; + const result = await HMSMLText.startCustomizedView(customViewModeRequest); + document.getElementById("bankCardImage").src = "data:image/jpeg;base64," + result.originalBitmap; + document.getElementById("cardNumber").value = JSON.stringify(result.number); + document.getElementById("cardExpire").value = JSON.stringify(result.expire); + document.getElementById("imageUri").value = JSON.stringify(result.originalBitmap); +} + +var checkbox = document.querySelector('input[type="checkbox"]'); +checkbox.addEventListener('change', function () { + if (checkbox.checked) { + document.getElementById("detectorType").value = "Device Detector"; + device = true; + } else { + document.getElementById("detectorType").value = "Plugin Detector"; + device = false; + } +}); \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/js/doc.js b/cordova-plugin-hms-mltext/example/cordova/www/js/doc.js new file mode 100644 index 00000000..1b277dad --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/js/doc.js @@ -0,0 +1,55 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +var $imageResult = null; +document.addEventListener("DOMContentLoaded", function () { + document.getElementById("documentImageAnalyser").addEventListener("click", () => getDocumentImageAnalyser()); + document.getElementById("stopDocumentImageAnalyser").addEventListener("click", () => stopDocumentImageAnalyser()); + document.getElementById("getDocumentImagePicker").addEventListener("click", function () { getimgPicker(); }); +}, false); + +async function getimgPicker($selectedImage) { + (async ()=>{ + const file=await chooser.getFile(); + $imageResult=file.uri; + })(); + + } + +async function getDocumentImageAnalyser() { + var documentImageReq = { + documentSetting: { + borderType: HMSMLTextPlugin.MLRemoteTextSetting.ARC, + possibleLanguages: ["en", "zh", "tr"], + enableFingerprintVerification: true, + }, + filePath: $imageResult, + }; + try { + const result = await HMSMLText.documentImageAnalyser(documentImageReq); + document.getElementById("textView").value = JSON.stringify(result.stringValue); + } catch (Ex) { + alert(JSON.stringify(Ex)) + } +} + +async function stopDocumentImageAnalyser() { + try { + const result = await HMSMLText.stopDocumentImageAnalyser(); + alert(result) + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/js/formrecog.js b/cordova-plugin-hms-mltext/example/cordova/www/js/formrecog.js new file mode 100644 index 00000000..40ff0ce5 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/js/formrecog.js @@ -0,0 +1,41 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +var $imageResult = null; +document.addEventListener("DOMContentLoaded", function () { + document.getElementById("formImageAnalyser").addEventListener("click", () => getFormImageAnalyser()); + document.getElementById("getFormImagePicker").addEventListener("click", function () { getimgPicker(); }); +}, false); + +async function getimgPicker() { + (async ()=>{ + const file=await chooser.getFile(); + $imageResult=file.uri; + })(); + + } + +async function getFormImageAnalyser() { + var formReq = { + filePath: $imageResult, + }; + try { + const result = await HMSMLText.formRecognitionAnalyser(formReq); + document.getElementById("textView").value = JSON.stringify(result); + console.log(JSON.stringify(result)); + } catch (Ex) { + alert(JSON.stringify(Ex)) + } +} diff --git a/cordova-plugin-hms-mltext/example/cordova/www/js/gcr.js b/cordova-plugin-hms-mltext/example/cordova/www/js/gcr.js new file mode 100644 index 00000000..1e2cacfa --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/js/gcr.js @@ -0,0 +1,56 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +var $imageResult_template = null; + +document.addEventListener("DOMContentLoaded", function () { + document.getElementById("generalCardDetector").addEventListener("click", () => generalCardDetector()); + document.getElementById("AnalyserPicker_template").addEventListener("click", function () { getimgPicker_template(); }); +}, false); + + + + +async function getimgPicker_template() { + (async ()=>{ + const file1=await chooser.getFile(); + $imageResult_template=file1.uri; + })(); + } + + + +async function generalCardDetector() { + var generalCardDetectorReq = { + gcrCaptureConfig: { + language: "en", + }, + gcrCaptureUIConfig: { + orientation: HMSMLTextPlugin.MLGcrCaptureUIConfig.ORIENTATION_AUTO, + tipTextColor: HMSMLTextPlugin.Colors.GREEN, + tipText: "Scan a card", + scanBoxCornerColor: HMSMLTextPlugin.Colors.BLUE, + } + }; + try { + const result = await HMSMLText.generalCardDetector(generalCardDetectorReq); + alert(JSON.stringify(result.text)); + console.log(JSON.stringify(result)); + document.getElementById("detectedGeneralCardImage").src = "data:image/jpeg;base64," + result.cardBitmap; + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/js/icrcn.js b/cordova-plugin-hms-mltext/example/cordova/www/js/icrcn.js new file mode 100644 index 00000000..1c5bbe8e --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/js/icrcn.js @@ -0,0 +1,81 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +var $imageResult = null; + +document.addEventListener("DOMContentLoaded", function () { + + document.getElementById("IcrCnCardAnalyserPicker").addEventListener("click", function () { getimgPicker(); }); + document.getElementById("icrCnDetector").addEventListener("click", () => icrCnDetector()); + document.getElementById("captureImage").addEventListener("click", () => captureImage()); + document.getElementById("localAnalyzer").addEventListener("click", () => localAnalyzer()); + + +}, false); + +async function getimgPicker() { + (async () => { + const file = await chooser.getFile(); + $imageResult = file.uri; + })(); +} + +async function captureImage() { + var icrCnDetectorReq = { + captureType: 1, + filePath: $imageResult, + isFront: false, + }; + try { + const result = await HMSMLText.icrCnCardDetector(icrCnDetectorReq); + alert(JSON.stringify(result)); + console.log(JSON.stringify(result)); + document.getElementById("detectedIcrCnCardImage").src = "data:image/jpeg;base64," + result.cardBitmap; + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} + +async function icrCnDetector() { + var icrCnDetectorReq = { + captureType: 0, + isFront: true, + }; + try { + const result = await HMSMLText.icrCnCardDetector(icrCnDetectorReq); + alert(JSON.stringify(result)); + console.log(JSON.stringify(result)); + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} + +async function localAnalyzer() { + var localAnalyserReq = { + mlIcrAnalyzerSetting: { + countryCode: "CN", + sideType: "FRONT", + }, + + filePath: $imageResult, + }; + try { + const result = await HMSMLText.icrLocalAnalyser(localAnalyserReq); + alert(JSON.stringify(result)); + console.log(JSON.stringify(result)); + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} diff --git a/cordova-plugin-hms-mltext/example/cordova/www/js/icrvn.js b/cordova-plugin-hms-mltext/example/cordova/www/js/icrvn.js new file mode 100644 index 00000000..135c90b0 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/js/icrvn.js @@ -0,0 +1,80 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +var $imageResult = null; + +document.addEventListener("DOMContentLoaded", function () { + + document.getElementById("IcrVnCardAnalyserPicker").addEventListener("click", function () { getimgPicker(); }); + document.getElementById("icrVnDetector").addEventListener("click", () => icrVnDetector()); + document.getElementById("captureImage").addEventListener("click", () => captureImage()); + document.getElementById("localAnalyzer").addEventListener("click", () => localAnalyzer()); + + +}, false); + +async function getimgPicker() { + (async () => { + const file = await chooser.getFile(); + $imageResult = file.uri; + })(); +} + +async function captureImage() { + var icrVnDetectorReq = { + captureType: 1, + filePath: $imageResult, + }; + try { + const result = await HMSMLText.icrVnCardDetector(icrVnDetectorReq); + alert(JSON.stringify(result.cardBitmap)); + + document.getElementById("detectedIcrVnCardImage").src = "data:image/jpeg;base64," + result.cardBitmap; + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} + +async function icrVnDetector() { + var icrVnDetectorReq = { + captureType: 0, + }; + try { + const result = await HMSMLText.icrVnCardDetector(icrVnDetectorReq); + alert(JSON.stringify(result)); + console.log(JSON.stringify(result)); + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} + +async function localAnalyzer() { + var localAnalyzerReq = { + + mlIcrAnalyzerSetting: { + countryCode: "VN", + sideType: "FRONT", + }, + filePath: $imageResult, + + }; + try { + const result = await HMSMLText.icrLocalAnalyser(localAnalyzerReq); + alert(JSON.stringify(result)); + console.log(JSON.stringify(result)); + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} diff --git a/cordova-plugin-hms-mltext/example/cordova/www/js/index.js b/cordova-plugin-hms-mltext/example/cordova/www/js/index.js new file mode 100644 index 00000000..f769e967 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/js/index.js @@ -0,0 +1,85 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +var $imageResult = null; +var selectedImage; +var app = { + // Application Constructor + initialize: function () { + document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); + }, + + // deviceready Event Handler + // + // Bind any cordova events here. Common events are: + // 'pause', 'resume', etc. + onDeviceReady: function () { + try { + var config = { + apiKey: "", + //accessToken: "", + }; + HMSMLTextPlugin.serviceInitializer(config); + } catch (ex) { + console.log(JSON.stringify(ex)); + } + + document.getElementById("formRecogHref").addEventListener("click", function () { window.location = "formrecog.html" }); + document.getElementById("bcrHref").addEventListener("click", function () { window.location = "bcr.html" }); + document.getElementById("textHref").addEventListener("click", function () { window.location = "text.html" }); + document.getElementById("docHref").addEventListener("click", function () { window.location = "doc.html" }); + document.getElementById("generalCardHref").addEventListener("click", function () { window.location = "gcr.html" }); + document.getElementById("icrVnHref").addEventListener("click", function () { window.location = "icrvn.html" }); + document.getElementById("icrCnHref").addEventListener("click", function () { window.location = "icrcn.html" }); + + + }, + + // Update DOM on a Received Event + receivedEvent: function (id) { + + var parentElement = document.getElementById(id); + var listeningElement = parentElement.querySelector('.listening'); + var receivedElement = parentElement.querySelector('.received'); + listeningElement.setAttribute('style', 'display:none;'); + receivedElement.setAttribute('style', 'display:block;'); + console.log('Received Event: ' + id); + } +}; + +async function requestPermissions() { + try { + await HMSMLTextPlugin.requestPermissions({ + permissionList: ["camera", "readExternalStorage", "audio", "writeExternalStorage"], + }); + } catch (ex) { + alert(JSON.stringify(ex)); + } +} +async function checkPermissions() { + var permissionListReq = { + permissionList: ["camera", "readExternalStorage", "audio", "writeExternalStorage"], + } + try { + const result = await HMSMLTextPlugin.hasPermissions(permissionListReq); + alert("Camera Permission: " + result.camera.hasPermission + "\nRead External Storage Permission: " + + result.readExternalStorage.hasPermission + "\nWrite External Storage Permission" + result.writeExternalStorage.hasPermission + + "\nAudio Permission" + result.audio.hasPermission); + } catch (ex) { + alert(JSON.stringify(ex)) + } +} + +app.initialize(); \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/js/text.js b/cordova-plugin-hms-mltext/example/cordova/www/js/text.js new file mode 100644 index 00000000..5dbacb76 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/js/text.js @@ -0,0 +1,97 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +var $imageResult = null; +var device = true; +document.addEventListener("DOMContentLoaded", function () { + const detectType = document.getElementById("detectorType").value; + document.getElementById("getTextAnalyserimgPicker").addEventListener("click", function () { getimgPicker(); }); + document.getElementById("ImageTextAnalyser").addEventListener("click", () => ImageTextAnalyser()); + document.getElementById("getTextAnalyserInfo").addEventListener("click", () => getTextAnalyserInfo()); + document.getElementById("stopTextAnalyser").addEventListener("click", () => stopTextAnalyser()); +}, false); + +async function getimgPicker() { + (async ()=>{ + const file=await chooser.getFile(); + $imageResult=file.uri; + })(); + + } + const detectType = document.getElementById("detectorType").value; + async function ImageTextAnalyser() { + + var ImageTextReq = { + ocrType: 1, + analyseMode: 1, + remoteTextSetting: { + textDensityScene: HMSMLTextPlugin.MLRemoteTextSetting.OCR_COMPACT_SCENE, + languageList: ["en", "zh", "tr"], + borderType: HMSMLTextPlugin.MLRemoteTextSetting.ARC, + }, + filePath: $imageResult, + }; + var localTextReq={ + ocrType: 0, + analyseMode: 0, + localTextSetting: { + language: "en" + }, + filePath: $imageResult, + } + try { + if (device == true) { + const result = await HMSMLText.imageTextAnalyser(localTextReq); + console.log(JSON.stringify(result)); + document.getElementById("textView").value += JSON.stringify(result.stringValue); + + + } else { + const result = await HMSMLText.imageTextAnalyser(ImageTextReq); + console.log(JSON.stringify(result)); + document.getElementById("textView").value += JSON.stringify(result.stringValue); + + } + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} +async function getTextAnalyserInfo() { + try { + const result = await HMSMLText.getTextAnalyserInfo(); + alert(JSON.stringify(result)); + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} + +async function stopTextAnalyser() { + try { + const result = await HMSMLText.stopTextAnalyser(); + alert(result) + } catch (Ex) { + alert(JSON.stringify(Ex)); + } +} +var checkbox = document.querySelector('input[type="checkbox"]'); +checkbox.addEventListener('change', function () { + if (checkbox.checked) { + document.getElementById("detectorType").value = "Device Detector"; + device = true; + } else { + document.getElementById("detectorType").value = "Plugin Detector"; + device = false; + } +}); \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/cordova/www/text.html b/cordova-plugin-hms-mltext/example/cordova/www/text.html new file mode 100644 index 00000000..ff549436 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/cordova/www/text.html @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ +
+
+
+
+
+
+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/.docs/images/agconnect_hms.PNG b/cordova-plugin-hms-mltext/example/ionic/.docs/images/agconnect_hms.PNG new file mode 100644 index 00000000..086e3f17 Binary files /dev/null and b/cordova-plugin-hms-mltext/example/ionic/.docs/images/agconnect_hms.PNG differ diff --git a/cordova-plugin-hms-mltext/example/ionic/.docs/images/appbuildgradle.png b/cordova-plugin-hms-mltext/example/ionic/.docs/images/appbuildgradle.png new file mode 100644 index 00000000..57805a4e Binary files /dev/null and b/cordova-plugin-hms-mltext/example/ionic/.docs/images/appbuildgradle.png differ diff --git a/cordova-plugin-hms-mltext/example/ionic/.docs/images/dependencies_app.png b/cordova-plugin-hms-mltext/example/ionic/.docs/images/dependencies_app.png new file mode 100644 index 00000000..9472adbb Binary files /dev/null and b/cordova-plugin-hms-mltext/example/ionic/.docs/images/dependencies_app.png differ diff --git a/cordova-plugin-hms-mltext/example/ionic/.docs/images/enablemlkit.png b/cordova-plugin-hms-mltext/example/ionic/.docs/images/enablemlkit.png new file mode 100644 index 00000000..0b2950dc Binary files /dev/null and b/cordova-plugin-hms-mltext/example/ionic/.docs/images/enablemlkit.png differ diff --git a/cordova-plugin-hms-mltext/example/ionic/LICENSE b/cordova-plugin-hms-mltext/example/ionic/LICENSE new file mode 100644 index 00000000..490b5c70 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/LICENSE @@ -0,0 +1,53 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and +You must cause any modified files to carry prominent notices stating that You changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/OpenSourceSoftwareNotice.html b/cordova-plugin-hms-mltext/example/ionic/OpenSourceSoftwareNotice.html new file mode 100644 index 00000000..07aea55f --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/OpenSourceSoftwareNotice.html @@ -0,0 +1,94 @@ +

OPEN SOURCE SOFTWARE NOTICE

+ +

 

+ +

Please note we provide an open source software notice along with this product and/or this product firmware (in the following just “this product”). The open source software licenses are granted by the respective right holders. And the open source licenses prevail all other license information with regard to the respective open source software contained in the product, including but not limited to End User Software Licensing Agreement. This notice is provided on behalf of Huawei Technologies Co. Ltd. and any of its local subsidiaries which may have provided this product to you in your local country.

+ +

 

+ +

Warranty Disclaimer    

+ +

THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.

+ +

 

+ +

Copyright Notice and License Texts

+ +

Software: cordova-plugin-filechooser 1.2.0

+ +

Copyright notice:

+ +

Copyright 2013-2014 Don Coleman

+ +

 

+ +

 

+ +

License: The Apache License

+ +

Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at

+ +

    http://www.apache.org/licenses/LICENSE-2.0

+ +

Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.

+ +

 

+ +

Software: @ionic-native/file-chooser 5.28.0

+ +

Copyright notice:

+ +

Copyright 2015-present Drifty Co.

+ +

 

+ +

 

+ +

License: The MIT License

+ +

Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:

+ +

The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.

+ +

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ +

 

+ +

 

+ +

 Written Offer  

+ +

This product contains software whose rights holders license it on the terms of the GNU General Public License, version 2 (GPLv2) and/or other open source software licenses. We will provide you and any third party with the source code of the software licensed under an open source software license if you send us a written request by mail or email to the following addresses:

+ +

foss@huawei.com

+ +

detailing the name of the product and the firmware version for which you need the source code and indicating how we can contact you.

+ +

Please note you need to make a payment before you obtain the complete Corresponding Source Code from us. For how much you will pay and how we will deliver the complete Corresponding Source Code to you, we will further discuss it by mail or email.

+ +

This offer is valid to anyone in receipt of this information.

+ +

 

+ +

THIS OFFER IS VALID FOR THREE YEARS FROM THE MOMENT WE DISTRIBUTED THE PRODUCT OR FIRMWARE .

+ +

 

diff --git a/cordova-plugin-hms-mltext/example/ionic/README.md b/cordova-plugin-hms-mltext/example/ionic/README.md new file mode 100644 index 00000000..11deff73 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/README.md @@ -0,0 +1,305 @@ +# HMS ML Text Ionic Demo + +## Contents + +- [1. Introduction](#1-introduction) +- [2. Installation Guide](#2-installation-guide) + - [2.1. Creating a Project in AppGallery Connect](#21-creating-a-project-in-appgallery-connect) + - [2.2. Configuring the Signing Certificate Fingerprint and Obtaining agconnect-services.json](#22-configuring-the-signing-certificate-fingerprint-and-obtaining-agconnect-servicesjson) + - [2.3. Ionic](#23-ionic) + - [2.3.1. With Cordova Runtime](#231-with-cordova-runtime) + - [2.3.2. With Capacitor Runtime](#232-with-capacitor-runtime) +- [3. Configuration and Description](#3-configuration-and-description) +- [4. Questions or Issues](#4-questions-or-issues) +- [5. Licensing and Terms](#5-licensing-and-terms) + +--- + +## 1. Introduction + +This demo application demonstrates the usage of the HMS ML Text Kit Cordova plugin. + +--- + +## 2. Installation Guide + +Before you get started, you must register as a HUAWEI Developer and complete identity verification on the [HUAWEI Developer](https://developer.huawei.com/consumer/en/?ha_source=hms1) website. For details, please refer to [Register a HUAWEI ID](https://developer.huawei.com/consumer/en/doc/10104?ha_source=hms1). + +### 2.1. Creating a Project in AppGallery Connect + +Creating an app in AppGallery Connect is required in order to communicate with the Huawei services. To create an app, perform the following steps: + +1. Sign in to [AppGallery Connect](https://developer.huawei.com/consumer/en/service/josp/agc/index.html?ha_source=hms1) and select **My projects**. +2. Select your project from the project list or create a new one by clicking the **Add Project** button. +3. Go to **Project Setting** > **General information**, and click **Add app**. + - If an app exists in the project and you need to add a new one, expand the app selection area on the top of the page and click **Add app**. +4. On the **Add app** page, enter the app information, and click **OK**. + +### 2.2. Configuring the Signing Certificate Fingerprint and Obtaining agconnect-services.json + +A signing certificate fingerprint is used to verify the authenticity of an app when it attempts to access an HMS Core (APK) through the HMS SDK. Before using the HMS Core (APK), you must locally generate a signing certificate fingerprint and configure it in the **AppGallery Connect**. You can refer to 3rd and 4th steps of [Generating a Signing Certificate](https://developer.huawei.com/consumer/en/codelab/HMSPreparation/index.html?ha_source=hms1#2) Codelab tutorial for the certificate generation. Perform the following steps after you have generated the certificate. + +1. Sign in to [AppGallery Connect](https://developer.huawei.com/consumer/en/service/josp/agc/index.html?ha_source=hms1) and select your project from **My Projects**. Then go to **Project Setting** > **General information**. In the **App information** field, click the icon next to SHA-256 certificate fingerprint, and enter the obtained **SHA-256 certificate fingerprint**. +2. After completing the configuration, click **OK** to save the changes. (Check mark icon) +3. In the same page, click **agconnect-services.json** button to download the configuration file. + +### 2.3. Ionic + +1. Install Ionic CLI and other required tools if haven't done before. + + ```bash + npm install -g @ionic/cli cordova-res native-run + ``` + +2. Open the demo project's root directory. + +3. Install project dependencies. + + ```bash + npm install + ``` + +#### 2.3.1. With Cordova Runtime + +1. Enable the **Cordova integration**. + + ```bash + ionic integrations enable cordova + ``` + +2. Update the widget **`id`** property which is specified in the **`config.xml`** file. It must be same with **client > package_name** value of the **`agconnect-services.json`** file. + +3. Add the **Android platform** to the project. + + ```bash + ionic cordova platform add android + ``` + +4. Install `HMS ML Text plugin` to the project. + + ```bash + ionic cordova plugin add @hmscore/cordova-plugin-hms-mltext + ``` + +5. Install HMS ML Text Ionic Native wrappers. + + ```bash + npm install @ionic-native/core @hmscore/ionic-native-hms-mltext + ``` + +6. Copy **`agconnect-services.json`** file to **`/platforms/android/app`** directory. + +7. Add **`keystore(.jks)`** and **`build.json`** files to your project's root directory. + + - You can refer to 3rd and 4th steps of [Generating a Signing Certificate](https://developer.huawei.com/consumer/en/codelab/HMSPreparation/index.html?ha_source=hms1#2) Codelab tutorial page for generating keystore file. + + - Fill **`build.json`** file according to your keystore. For example: + + ```json + { + "android": { + "debug": { + "keystore": ".jks", + "storePassword": "", + "alias": "", + "password": "" + }, + "release": { + "keystore": ".jks", + "storePassword": "", + "alias": "", + "password": "" + } + } + } + ``` + +8. Build Ionic app to generate resource files. + + ```bash + ionic build + ``` + +9. Run the app. + + ```bash + ionic cordova run android --device + ``` + +#### 2.3.2. With Capacitor Runtime + +1. Enable the **Capacitor integration**. + + ```bash + ionic integrations enable capacitor + ``` + +2. Initialize **Capacitor**. + + ```bash + npx cap init [appName] [appId] + ``` + + - For more details please follow [Initialize Capacitor with your app information](https://capacitorjs.com/docs/getting-started/with-ionic#initialize-capacitor-with-your-app-information). + +3. Update the **`appId`** property which is specified in the **`capacitor.config.json`** file according to your project. It must be same with **client > package_name** value of the **`agconnect-services.json`** file. + +4. Install `HMS ML Text plugin` to the project. + + ```bash + npm install @hmscore/cordova-plugin-hms-mltext + ``` + +5. Install HMS ML Text Ionic Native wrappers. + + ```bash + npm install @ionic-native/core @hmscore/ionic-native-hms-mltext + ``` + +6. Build Ionic app to generate resource files. + + ```bash + ionic build + ``` + +7. Add the **Android platform** to the project. + + ```bash + npx cap add android + ``` + +8. Copy **`keystore(.jks)`** and **`agconnect-services.json`** files to **`/android/app`** directory. + + - You can refer to 3rd and 4th steps of [Generating a Signing Certificate](https://developer.huawei.com/consumer/en/codelab/HMSPreparation/index.html?ha_source=hms1#2) Codelab tutorial page for generating keystore file. + +9. Open the **`build.gradle`** file in the **`/android/app`** directory. + + - Add `signingConfigs` entry to the **android** section and modify it according to your keystore. + + - Enable `signingConfig` configuration for **debug** and **release** flavors. + + ```groovy + ... + + android { + + ... + + // Modify signingConfigs according to your keystore + signingConfigs { + config { + storeFile file('.jks') + storePassword '' + keyAlias '' + keyPassword '' + } + } + buildTypes { + debug { + signingConfig signingConfigs.config // Enable signingConfig for debug flavor + } + release { + signingConfig signingConfigs.config // Enable signingConfig for release flavor + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + } + + ... + ``` + +10. Open the **`build.gradle`** file in the **`/android`** directory. Add **Huawei's maven repositories** and **agconnect classpath** to the file. + + ```groovy + buildscript { + repositories { + /* + + */ + maven { url 'https://developer.huawei.com/repo/' } + } + dependencies { + /* + + */ + classpath 'com.huawei.agconnect:agcp:1.9.1.300' + } + } + + /* + + */ + + allprojects { + repositories { + /* + + */ + maven { url 'https://developer.huawei.com/repo/' } + } + } + ``` + +11. Updates dependencies, and copy any web assets to your project. + + ```bash + npx cap sync + ``` + +12. Open the project in Android Studio and run it. + + ```bash + npx cap open android + ``` + +--- + +## 3. Configuration and Description + +### Configuring Obfuscation Scripts + +Before building the APK, configure the obfuscation configuration file to prevent the HMS Core SDK from being obfuscated. + +**NOTE**: This step is required only if you want to minify and obfuscate your app. By default obfuscation is disabled in Cordova and Ionic apps. + +The obfuscation is done by **ProGuard.** By default, in Cordova and Ionic apps ProGuard is disabled. Even though ProGuard is not available, ProGuard support can be added through 3rd party ProGuard plugins. If ProGuard is enabled in your project, the Huawei Cordova ML plugin's ProGuard rules need to be added to your project. These rules are as follows: + +```text +-ignorewarnings +-keepattributes *Annotation* +-keepattributes Exceptions +-keepattributes InnerClasses +-keepattributes Signature +-keep class com.huawei.hianalytics.**{*;} +-keep class com.huawei.updatesdk.**{*;} +-keep class com.huawei.hms.**{*;} +-dontwarn com.huawei.** +-keep class com.huawei.** {*;} +-dontwarn org.slf4j.** +-keep class org.slf4j.** {*;} +-dontwarn org.springframework.** +-keep class org.springframework.** {*;} +-dontwarn com.fasterxml.jackson.** +-keep class com.fasterxml.jackson.** {*;} +-repackageclasses +``` + +--- + +## 4. Questions or Issues + +If you have questions about how to use HMS samples, try the following options: + +- [Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services) is the best place for any programming questions. Be sure to tag your question with **`huawei-mobile-services`**. +- [GitHub](https://github.com/HMS-Core/hms-cordova-plugin) is the official repository for these plugins, You can open an issue or submit your ideas. +- [Huawei Developer Forum](https://forums.developer.huawei.com/forumPortal/en/home?fid=0101187876626530001&ha_source=hms1) HMS Core Module is great for general questions, or seeking recommendations and opinions. +- [Huawei Developer Docs](https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1) is place to official documentation for all HMS Core Kits, you can find detailed documentations in there. + +If you run into a bug in our samples, please submit an issue to the [GitHub repository](https://github.com/HMS-Core/hms-cordova-plugin). + +--- + +## 5. Licensing and Terms + +Huawei ML Text Kit Cordova Plugin is licensed under the [Apache 2.0 license](LICENSE). diff --git a/cordova-plugin-hms-mltext/example/ionic/angular.json b/cordova-plugin-hms-mltext/example/ionic/angular.json new file mode 100644 index 00000000..cb1a43d9 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/angular.json @@ -0,0 +1,190 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "defaultProject": "app", + "newProjectRoot": "projects", + "projects": { + "app": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "www", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.app.json", + "assets": [ + { + "glob": "**/*", + "input": "src/assets", + "output": "assets" + }, + { + "glob": "**/*.svg", + "input": "node_modules/ionicons/dist/ionicons/svg", + "output": "./svg" + } + ], + "styles": [ + { + "input": "src/theme/variables.scss" + }, + { + "input": "src/global.scss" + } + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + } + ] + }, + "ci": { + "progress": false + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "app:build" + }, + "configurations": { + "production": { + "browserTarget": "app:build:production" + }, + "ci": { + "progress": false + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "app:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "styles": [], + "scripts": [], + "assets": [ + { + "glob": "favicon.ico", + "input": "src/", + "output": "/" + }, + { + "glob": "**/*", + "input": "src/assets", + "output": "/assets" + } + ] + }, + "configurations": { + "ci": { + "progress": false, + "watch": false + } + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "tsconfig.app.json", + "tsconfig.spec.json", + "e2e/tsconfig.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + }, + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "app:serve" + }, + "configurations": { + "production": { + "devServerTarget": "app:serve:production" + }, + "ci": { + "devServerTarget": "app:serve:ci" + } + } + }, + "ionic-cordova-build": { + "builder": "@ionic/cordova-builders:cordova-build", + "options": { + "browserTarget": "app:build" + }, + "configurations": { + "production": { + "browserTarget": "app:build:production" + } + } + }, + "ionic-cordova-serve": { + "builder": "@ionic/cordova-builders:cordova-serve", + "options": { + "cordovaBuildTarget": "app:ionic-cordova-build", + "devServerTarget": "app:serve" + }, + "configurations": { + "production": { + "cordovaBuildTarget": "app:ionic-cordova-build:production", + "devServerTarget": "app:serve:production" + } + } + } + } + } + }, + "cli": { + "defaultCollection": "@ionic/angular-toolkit", + "analytics": false + }, + "schematics": { + "@ionic/angular-toolkit:component": { + "styleext": "scss" + }, + "@ionic/angular-toolkit:page": { + "styleext": "scss" + } + } +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/browserslist b/cordova-plugin-hms-mltext/example/ionic/browserslist new file mode 100644 index 00000000..b15c7fae --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/browserslist @@ -0,0 +1,12 @@ +# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. +# For additional information regarding the format and rule options, please see: +# https://github.com/browserslist/browserslist#queries + +# You can see what browsers were selected by your queries by running: +# npx browserslist + +> 0.5% +last 2 versions +Firefox ESR +not dead +not IE 9-11 # For IE 9-11 support, remove 'not'. diff --git a/cordova-plugin-hms-mltext/example/ionic/e2e/protractor.conf.js b/cordova-plugin-hms-mltext/example/ionic/e2e/protractor.conf.js new file mode 100644 index 00000000..ef5976ed --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/e2e/protractor.conf.js @@ -0,0 +1,40 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +const { SpecReporter } = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + './src/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + onPrepare() { + require('ts-node').register({ + project: require('path').join(__dirname, './tsconfig.json') + }); + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +}; diff --git a/cordova-plugin-hms-mltext/example/ionic/e2e/src/app.e2e-spec.ts b/cordova-plugin-hms-mltext/example/ionic/e2e/src/app.e2e-spec.ts new file mode 100644 index 00000000..80395ed3 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/e2e/src/app.e2e-spec.ts @@ -0,0 +1,29 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { AppPage } from './app.po'; + +describe('new App', () => { + let page: AppPage; + + beforeEach(() => { + page = new AppPage(); + }); + + it('should be blank', () => { + page.navigateTo(); + expect(page.getParagraphText()).toContain('Start with Ionic UI Components'); + }); +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/e2e/src/app.po.ts b/cordova-plugin-hms-mltext/example/ionic/e2e/src/app.po.ts new file mode 100644 index 00000000..a9e59f1b --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/e2e/src/app.po.ts @@ -0,0 +1,26 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { browser, by, element } from 'protractor'; + +export class AppPage { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.deepCss('app-root ion-content')).getText(); + } +} diff --git a/cordova-plugin-hms-mltext/example/ionic/e2e/tsconfig.json b/cordova-plugin-hms-mltext/example/ionic/e2e/tsconfig.json new file mode 100644 index 00000000..77d311e8 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/e2e/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/app", + "module": "commonjs", + "target": "es5", + "types": [ + "jasmine", + "jasminewd2", + "node" + ] + } +} diff --git a/cordova-plugin-hms-mltext/example/ionic/ionic.config.json b/cordova-plugin-hms-mltext/example/ionic/ionic.config.json new file mode 100644 index 00000000..bf53c3b9 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/ionic.config.json @@ -0,0 +1,7 @@ +{ + "name": "ionic-hms-mltext-demo", + "integrations": { + + }, + "type": "angular" +} diff --git a/cordova-plugin-hms-mltext/example/ionic/karma.conf.js b/cordova-plugin-hms-mltext/example/ionic/karma.conf.js new file mode 100644 index 00000000..fafc49ce --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/karma.conf.js @@ -0,0 +1,46 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../coverage'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/cordova-plugin-hms-mltext/example/ionic/package.json b/cordova-plugin-hms-mltext/example/ionic/package.json new file mode 100644 index 00000000..653acd96 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/package.json @@ -0,0 +1,90 @@ +{ + "name": "ionic-hms-mltext-demo", + "description": "A demo application which shows the usage of HMS ML Text plugin.", + "version": "3.12.0-300", + "homepage": "https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin", + "license": "Apache-2.0", + "licenseFilename": "LICENSE", + "readmeFilename": "README.md", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e" + }, + "dependencies": { + "@angular/common": "15.0.0", + "@angular/core": "15.0.0", + "@angular/forms": "15.0.0", + "@angular/platform-browser": "15.0.0", + "@angular/platform-browser-dynamic": "15.0.0", + "@angular/router": "15.0.0", + "@ionic-native/core": "^5.36.0", + "@ionic-native/splash-screen": "5.36.0", + "@ionic-native/status-bar": "5.36.0", + "@ionic/angular": "6.1.9", + "@ionic/cordova-builders": "^9.0.0", + "@ionic-native/file-chooser": "5.28.0", + "rxjs": "6.6.0", + "tslib": "2.3.0", + "zone.js": "0.11.4" + }, + "devDependencies": { + "@angular-devkit/build-angular": "15.0.0", + "@angular/cli": "15.0.0", + "@angular/compiler": "15.0.0", + "@angular/compiler-cli": "15.0.0", + "@angular/language-service": "15.0.0", + "@capacitor/cli": "2.4.5", + "@ionic/angular-toolkit": "9.0.0", + "@types/jasmine": "4.0.0", + "@types/jasminewd2": "2.0.3", + "@types/node": "12.11.1", + "codelyzer": "6.0.0", + "jasmine-core": "4.3.0", + "jasmine-spec-reporter": "5.0.0", + "karma": "6.4.0", + "karma-chrome-launcher": "3.1.0", + "karma-coverage-istanbul-reporter": "3.0.2", + "karma-jasmine": "5.1.0", + "karma-jasmine-html-reporter": "2.0.0", + "@ionic-native/file-chooser": "5.30.0", + "cordova-plugin-filechooser": "^1.2.0", + "protractor": "7.0.0", + "ts-node": "8.3.0", + "tslint": "6.1.0", + "typescript": "4.8.4" + }, + "files": [ + ".docs", + "e2e", + "src", + "angular.json", + "browserslist", + "ionic.config.json", + "karma.conf.js", + "LICENSE", + "package.json", + "README.md", + "OpenSourceSoftwareNotice.html", + "tsconfig.app.json", + "tsconfig.json", + "tsconfig.spec.json", + "tslint.json" + ], + "cordova": { + "plugins": { + "cordova-plugin-filechooser": {}, + "cordova-plugin-statusbar": {}, + "cordova-plugin-device": {}, + "cordova-plugin-splashscreen": {}, + "cordova-plugin-ionic-webview": {}, + "cordova-plugin-ionic-keyboard": {} + }, + "platforms": [ + "android" + ] + } +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/app-routing.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/app-routing.module.ts new file mode 100644 index 00000000..893f3d62 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/app-routing.module.ts @@ -0,0 +1,77 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { PreloadAllModules, RouterModule, Routes } from "@angular/router"; + +const routes: Routes = [ + { + path: "home", + loadChildren: () => + import("./home/home.module").then((m) => m.HomePageModule), + }, + { + path: "", + redirectTo: "home", + pathMatch: "full", + }, + { + path: "icrVn", + loadChildren: () => + import("./icrVn/icrVn.module").then((m) => m.icrVnPageModule), + }, + + { + path: "icrCn", + loadChildren: () => + import("./icrCn/icrCn.module").then((m) => m.icrCnPageModule), + }, + { + path: "bcr", + loadChildren: () => import("./bcr/bcr.module").then((m) => m.BcrPageModule), + }, + { + path: "text", + loadChildren: () => + import("./text/text.module").then((m) => m.TextPageModule), + }, + { + path: "document", + loadChildren: () => + import("./document/document.module").then((m) => m.DocumentPageModule), + }, + { + path: "generalcard", + loadChildren: () => + import("./generalcard/generalcard.module").then( + (m) => m.GeneralcardPageModule + ), + }, + { + path: "formrecognition", + loadChildren: () => + import("./formrecognition/formrecognition.module").then( + (m) => m.FormrecognitionPageModule + ), + }, +]; + +@NgModule({ + imports: [ + RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }), + ], + exports: [RouterModule], +}) +export class AppRoutingModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.html b/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.html new file mode 100644 index 00000000..7d0d7610 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.html @@ -0,0 +1,18 @@ + + + + diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.scss b/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.scss new file mode 100644 index 00000000..60547ee2 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.scss @@ -0,0 +1,15 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.spec.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.spec.ts new file mode 100644 index 00000000..798b002e --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.spec.ts @@ -0,0 +1,58 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { TestBed, async } from '@angular/core/testing'; +import { Platform } from '@ionic/angular'; +import { SplashScreen } from '@ionic-native/splash-screen/ngx'; +import { StatusBar } from '@ionic-native/status-bar/ngx'; +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + + let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; + + beforeEach(async(() => { + statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); + splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); + platformReadySpy = Promise.resolve(); + platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy }); + + TestBed.configureTestingModule({ + declarations: [AppComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + providers: [ + { provide: StatusBar, useValue: statusBarSpy }, + { provide: SplashScreen, useValue: splashScreenSpy }, + { provide: Platform, useValue: platformSpy }, + ], + }).compileComponents(); + })); + + it('should create the app', () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app).toBeTruthy(); + }); + + it('should initialize the app', async () => { + TestBed.createComponent(AppComponent); + expect(platformSpy.ready).toHaveBeenCalled(); + await platformReadySpy; + expect(statusBarSpy.styleDefault).toHaveBeenCalled(); + expect(splashScreenSpy.hide).toHaveBeenCalled(); + }); + +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.ts new file mode 100644 index 00000000..d7faeae8 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/app.component.ts @@ -0,0 +1,41 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Component } from '@angular/core'; +import { Platform } from '@ionic/angular'; +import { SplashScreen } from '@ionic-native/splash-screen/ngx'; +import { StatusBar } from '@ionic-native/status-bar/ngx'; + +@Component({ + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.scss'] +}) +export class AppComponent { + constructor( + private platform: Platform, + private splashScreen: SplashScreen, + private statusBar: StatusBar + ) { + this.initializeApp(); + } + + initializeApp() { + this.platform.ready().then(() => { + this.statusBar.styleDefault(); + this.splashScreen.hide(); + }); + } +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/app.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/app.module.ts new file mode 100644 index 00000000..59b03f04 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/app.module.ts @@ -0,0 +1,37 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { RouteReuseStrategy } from '@angular/router'; +import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; +import { SplashScreen } from '@ionic-native/splash-screen/ngx'; +import { StatusBar } from '@ionic-native/status-bar/ngx'; +import { AppComponent } from './app.component'; +import { AppRoutingModule } from './app-routing.module'; + + +@NgModule({ + declarations: [AppComponent], + entryComponents: [], + imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule], + providers: [ + StatusBar, + SplashScreen, + { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } + ], + bootstrap: [AppComponent] +}) +export class AppModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr-routing.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr-routing.module.ts new file mode 100644 index 00000000..0e7224a8 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr-routing.module.ts @@ -0,0 +1,31 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { BcrPage } from './bcr.page'; + +const routes: Routes = [ + { + path: '', + component: BcrPage + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class BcrPageRoutingModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.module.ts new file mode 100644 index 00000000..9e84cb91 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.module.ts @@ -0,0 +1,30 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; +import { FormsModule } from "@angular/forms"; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +import { IonicModule } from "@ionic/angular"; +import { HMSMLText } from "@hmscore/ionic-native-hms-mltext/ngx"; +import { BcrPageRoutingModule } from "./bcr-routing.module"; +import { BcrPage } from "./bcr.page"; + +@NgModule({ + imports: [CommonModule, FormsModule, IonicModule, BcrPageRoutingModule], + declarations: [BcrPage], + providers: [FileChooser, HMSMLText] +}) +export class BcrPageModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.html b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.html new file mode 100644 index 00000000..c4a9889b --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.html @@ -0,0 +1,55 @@ + + +
+ Bankcard Recognition +
+ + + + + + +
+
+ Card Number + +
+
+ Card Expire + +
+
+ Recognized Image Saved URI + +
+
+ +
+ Select Image +
+
+ Start Recognition +
+
+ Stop Recognition +
+
+ Custom View +
+ + +
\ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.scss b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.scss new file mode 100644 index 00000000..8e216e13 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.scss @@ -0,0 +1,19 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +.inputDiv{ + border:2px solid black; + margin-top: 12px; +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.spec.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.spec.ts new file mode 100644 index 00000000..00ba0e2b --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.spec.ts @@ -0,0 +1,38 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; +import { BcrPage } from './bcr.page'; + +describe('BcrPage', () => { + let component: BcrPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ BcrPage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(BcrPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.ts new file mode 100644 index 00000000..8bc1b583 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/bcr/bcr.page.ts @@ -0,0 +1,110 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Component, OnInit } from '@angular/core'; +import { FileChooser } from '@ionic-native/file-chooser/ngx'; + +declare var HMSMLText; +@Component({ + selector: 'app-bcr', + templateUrl: './bcr.page.html', + styleUrls: ['./bcr.page.scss'], +}) +export class BcrPage { + toggle: boolean = false; + filePath: string = ""; + toogleName: string = ""; + cardNumber:string; + cardExpire:string; + cardURI:string; + + constructor(private fileChooser: FileChooser) { + this.toogleName = "Device"; + } + public async changeToogle() { + if (this.toggle == false) { + this.toogleName = "Plugin"; + } else { + this.toogleName = "Device"; + } + } + + + public async getFile() { + this.fileChooser.open() + .then(uri => this.filePath = uri) + .catch(e => console.log(e)); + } + + public async bankCardDetector() { + var bankCardSDKDetectorInput = { + detectType: 0, + filePath: this.filePath, + mLBcrAnalyzerSetting: { + langType: "zh" + }, + }; + var bankCardPluginDetectorInput = { + detectType: 1, + mLBcrCaptureConfig: { + orientation: HMSMLText.MLBcrCaptureConfig.ORIENTATION_AUTO, + }, + }; + try { + if (this.toggle == false) { + var result = await HMSMLText.bankCardDetector(bankCardSDKDetectorInput); + } else { + result = await HMSMLText.bankCardDetector(bankCardPluginDetectorInput); + } + this.cardNumber=JSON.stringify(result.number); + this.cardExpire= JSON.stringify(result.expire); + this.cardURI=JSON.stringify(result.originalBitmap); + } catch (ex) { + alert(ex) + } + } + + public async stopbankCardDetector() { + + try { + alert(await HMSMLText.stopBankCardDetector()); + } catch (ex) { + alert(ex) + } + } + + + + public async startCustomViewMode() { + var customViewModeRequest = { + isTitleAvailable: true, + title: "Place the card within the frame", + heightFactor: 0.8, + widthFactor: 0.8, + isFlashAvailable: true, + resultType: HMSMLText.MLBcrResultConfig.RESULT_ALL, + recMode: HMSMLText.RecMode.WEAK_MODE, + }; + try { + var result = await HMSMLText.startCustomizedView(customViewModeRequest); + this.cardNumber=JSON.stringify(result.number); + this.cardExpire= JSON.stringify(result.expire); + this.cardURI=JSON.stringify(result.originalBitmap); + } catch (ex) { + alert(ex) + } + } + +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/document/document-routing.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document-routing.module.ts new file mode 100644 index 00000000..9d636852 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document-routing.module.ts @@ -0,0 +1,31 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { DocumentPage } from './document.page'; + +const routes: Routes = [ + { + path: '', + component: DocumentPage + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class DocumentPageRoutingModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.module.ts new file mode 100644 index 00000000..27c998df --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.module.ts @@ -0,0 +1,30 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; +import { FormsModule } from "@angular/forms"; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +import { IonicModule } from "@ionic/angular"; +import { HMSMLText } from "@hmscore/ionic-native-hms-mltext/ngx"; +import { DocumentPageRoutingModule } from "./document-routing.module"; +import { DocumentPage } from "./document.page"; + +@NgModule({ + imports: [CommonModule, FormsModule, IonicModule, DocumentPageRoutingModule], + declarations: [DocumentPage], + providers: [FileChooser, HMSMLText] +}) +export class DocumentPageModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.html b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.html new file mode 100644 index 00000000..c48b2e10 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.html @@ -0,0 +1,31 @@ + + +
+ + + +
+ +
+ Select Image +
+ +
+ Start Analyse +
+
diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.scss b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.scss new file mode 100644 index 00000000..60547ee2 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.scss @@ -0,0 +1,15 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.spec.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.spec.ts new file mode 100644 index 00000000..b83fa983 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.spec.ts @@ -0,0 +1,39 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; +import { DocumentPage } from './document.page'; + +describe('DocumentPage', () => { + let component: DocumentPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DocumentPage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(DocumentPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.ts new file mode 100644 index 00000000..28e8d7e5 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/document/document.page.ts @@ -0,0 +1,52 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Component, OnInit } from '@angular/core'; +import { FileChooser } from '@ionic-native/file-chooser/ngx'; +declare var HMSMLText; +@Component({ + selector: 'app-document', + templateUrl: './document.page.html', + styleUrls: ['./document.page.scss'], +}) +export class DocumentPage { + imageResult: string = ""; + documentRecognitionOutput: string = ""; + constructor(private fileChooser: FileChooser ) { } + + public async getFile() { + this.fileChooser.open() + .then(uri => this.imageResult = uri) + .catch(e => console.log(e)); + } + + public async getDocumentImageAnalyser() { + var documentImageAnalyserInput = { + documentSetting: { + borderType: HMSMLText.MLRemoteTextSetting.ARC, + LanguageList: ["en", "zh", "tr"], + enableFingerprintVerification:true + }, + filePath: this.imageResult + }; + try { + const result = await HMSMLText.documentImageAnalyser(documentImageAnalyserInput); + this.documentRecognitionOutput = JSON.stringify(result.stringValue); + } catch (ex) { + alert(ex) + } + } + +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition-routing.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition-routing.module.ts new file mode 100644 index 00000000..0ecc926d --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition-routing.module.ts @@ -0,0 +1,32 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +import { FormrecognitionPage } from './formrecognition.page'; + +const routes: Routes = [ + { + path: '', + component: FormrecognitionPage + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class FormrecognitionPageRoutingModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.module.ts new file mode 100644 index 00000000..be651e79 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.module.ts @@ -0,0 +1,31 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; +import { FormsModule } from "@angular/forms"; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +import { IonicModule } from "@ionic/angular"; +import { HMSMLText } from "@hmscore/ionic-native-hms-mltext/ngx"; +import { FormrecognitionPageRoutingModule } from "./formrecognition-routing.module"; + +import { FormrecognitionPage } from "./formrecognition.page"; + +@NgModule({ + imports: [CommonModule, FormsModule, IonicModule, FormrecognitionPageRoutingModule], + declarations: [FormrecognitionPage], + providers: [FileChooser, HMSMLText] +}) +export class FormrecognitionPageModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.html b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.html new file mode 100644 index 00000000..e44e3c64 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.html @@ -0,0 +1,31 @@ + + +
+ + + +
+ +
+ Select Image +
+ +
+ Start Analyse +
+
diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.scss b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.scss new file mode 100644 index 00000000..60547ee2 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.scss @@ -0,0 +1,15 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.spec.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.spec.ts new file mode 100644 index 00000000..b7787f33 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.spec.ts @@ -0,0 +1,39 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; + +import { FormrecognitionPage } from './formrecognition.page'; + +describe('FormrecognitionPage', () => { + let component: FormrecognitionPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FormrecognitionPage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(FormrecognitionPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.ts new file mode 100644 index 00000000..4231406c --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/formrecognition/formrecognition.page.ts @@ -0,0 +1,50 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Component, OnInit } from '@angular/core'; +import { FileChooser } from '@ionic-native/file-chooser/ngx'; +declare var HMSMLText; +@Component({ + selector: 'app-formrecognition', + templateUrl: './formrecognition.page.html', + styleUrls: ['./formrecognition.page.scss'], +}) +export class FormrecognitionPage{ + + imageResult: string = ""; + formRecognitionOutput: string = ""; + constructor(private fileChooser: FileChooser) { } + + public async getFile() { + this.fileChooser.open() + .then(uri => this.imageResult = uri) + .catch(e => console.log(e)); + } + + public async formRecognitionAnalyser() { + var formRecognitionreq = { + filePath: this.imageResult, + syncType:0 + }; + try { + var result = await HMSMLText.formRecognitionAnalyser(formRecognitionreq); + this.formRecognitionOutput = JSON.stringify(result); + } catch (ex) { + alert(ex) + } + } + + +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard-routing.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard-routing.module.ts new file mode 100644 index 00000000..ccb23626 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard-routing.module.ts @@ -0,0 +1,31 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { GeneralcardPage } from './generalcard.page'; + +const routes: Routes = [ + { + path: '', + component: GeneralcardPage + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class GeneralcardPageRoutingModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.module.ts new file mode 100644 index 00000000..dc7ea9ea --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.module.ts @@ -0,0 +1,29 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; +import { FormsModule } from "@angular/forms"; +import { IonicModule } from "@ionic/angular"; +import { HMSMLText } from "@hmscore/ionic-native-hms-mltext/ngx"; +import { GeneralcardPageRoutingModule } from "./generalcard-routing.module"; +import { GeneralcardPage } from "./generalcard.page"; + +@NgModule({ + imports: [CommonModule, FormsModule, IonicModule, GeneralcardPageRoutingModule], + declarations: [GeneralcardPage], + providers: [HMSMLText] +}) +export class GeneralcardPageModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.html b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.html new file mode 100644 index 00000000..8917b8df --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.html @@ -0,0 +1,33 @@ + + +
+ Generalcard Recognition +
+ +
+ + + + +
+ +
+ Start Recognition +
+ + +
diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.scss b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.scss new file mode 100644 index 00000000..60547ee2 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.scss @@ -0,0 +1,15 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.spec.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.spec.ts new file mode 100644 index 00000000..5d258dd1 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.spec.ts @@ -0,0 +1,38 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; +import { GeneralcardPage } from './generalcard.page'; + +describe('GeneralcardPage', () => { + let component: GeneralcardPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ GeneralcardPage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(GeneralcardPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.ts new file mode 100644 index 00000000..cc7feb89 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/generalcard/generalcard.page.ts @@ -0,0 +1,48 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Component } from '@angular/core'; +declare var HMSMLText; +@Component({ + selector: 'app-generalcard', + templateUrl: './generalcard.page.html', + styleUrls: ['./generalcard.page.scss'], +}) +export class GeneralcardPage { + gcrCardRecognitionOutput: string = ""; + constructor() { } + + public async generalCardDetector() { + var generalCardDetectorInput = { + gcrCaptureConfig: { + language: "en", + }, + gcrCaptureUIConfig: { + orientation: HMSMLText.MLGcrCaptureUIConfig.ORIENTATION_AUTO, + tipTextColor: HMSMLText.Colors.GREEN, + tipText: "Scan a card", + scanBoxCornerColor: HMSMLText.Colors.BLUE, + } + }; + try { + const result = await HMSMLText.generalCardDetector(generalCardDetectorInput); + this.gcrCardRecognitionOutput = JSON.stringify(result.text); + console.log(JSON.stringify(result)); + } catch (ex) { + alert(ex) + } + } + +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/home/home-routing.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home-routing.module.ts new file mode 100644 index 00000000..d2ab2fd4 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home-routing.module.ts @@ -0,0 +1,33 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { HomePage } from './home.page'; + +const routes: Routes = [ + { + path: '', + component: HomePage, + }, + +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class HomePageRoutingModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.module.ts new file mode 100644 index 00000000..0dccd1c7 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.module.ts @@ -0,0 +1,33 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { IonicModule } from '@ionic/angular'; +import { FormsModule } from '@angular/forms'; +import { HomePage } from './home.page'; +import { HomePageRoutingModule } from './home-routing.module'; + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + IonicModule, + HomePageRoutingModule + ], + declarations: [HomePage] +}) +export class HomePageModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.html b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.html new file mode 100644 index 00000000..ce748f77 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.html @@ -0,0 +1,84 @@ + + + + + HMS ML Text + + + +
+
+ +
+ + +
+
+ + BCR + + +
+ +
+ + Text + + +
+ +
+ + Document + +
+ + +
+ + General
Card +
+ +
+ +
+ + Form
Recog. +
+ +
+ +
+ + ICR
VN. +
+ +
+ + +
+ + ICR
CN. +
+ +
+ +
+
\ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.scss b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.scss new file mode 100644 index 00000000..5bef5ac8 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.scss @@ -0,0 +1,272 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +#container { + text-align: center; + + position: absolute; + left: 0; + right: 0; + top: 150%; + transform: translateY(-50%); +} + +#container strong { + font-size: 20px; + line-height: 26px; +} + +#container p { + font-size: 16px; + line-height: 22px; + color: #8c8c8c; + + margin: 0; +} + +#container a { + text-decoration: none; +} + +/*Index.html buttons and div css */ +.clear {clear: both; } + +.textAlignDiv { text-align: center; } + +.textProp { font-size: 18px; } + +.selectedTextProp { + font-size: 14px; + font-weight: bold; + margin-top: 3px; +} +.twoDivProp { + width: 40%; + display: inline-block; +} +.main_div { + width: 100%; + margin-right: auto; + margin-left: auto; + background-color: gray; + margin-top: 3px; +} +.div { + display: inline-block; + width: 47%; + color: #FFF; +} +.threeDivProp { + width: 30%; +} +.fourDivProp{ + width: 24%; +} +.btn { + margin-top: 5px; + display: block; + background-color: cornflowerblue; + color: white; + width: 100%; + height: 50px; + border: none; +} + +.segmentImgCss { + height: 250px; + width: 100%; +} + +.mllogo { + text-align: center; + margin-top: 20px; + margin-bottom: 30px; +} + +.imgDiv { + margin-bottom: 10px; +} + +.mllogoText { + font-weight: bold; + margin-top: 20px; +} + +.servicesDiv { + margin-left: 20px; + height: 80px; + width: 90px; + border: 1px solid gray; + border-radius: 5px; + position: relative; + background-color: whitesmoke; + color: #c4142c; +} + +.servicesImg { + height: 50px; + width: 70px; + position: absolute; + left: 10px; + top: 5px; + margin: auto; + text-align: center; +} + +.servicesImgText { + position: absolute; + left: 30px; + bottom: 1px; +} + +.newPageHref { + float: left; + margin-top: 15px; +} + +.divText { + border: 2px solid black; + padding: 5px; +} + +input[type=text] { + width: 100%; + font-size: 20px; +} + +.switch { + position: relative; + display: inline-block; + width: 60px; + height: 34px; +} + +.switch input { + opacity: 0; + width: 0; + height: 0; +} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: .4s; + transition: .4s; +} + +.slider:before { + position: absolute; + content: ""; + height: 26px; + width: 26px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; +} + +input:checked+.slider { + background-color: #2196F3; +} + +input:focus+.slider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked+.slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); +} + +/* Rounded sliders */ +.slider.round { + border-radius: 34px; +} + +.slider.round:before { + border-radius: 50%; +} + +.mllogo { + text-align: center; + margin-left: 20px; + height: 80px; + width: 90px; + border-radius: 5px; + position: relative; +} + +.imgDiv { + margin-bottom: 10px; +} + +.mllogoText { + font-weight: bold; + margin-top: 20px; +} + +.servicesDiv { + margin-left: 20px; + height: 90px; + width: 90px; + border: 1px solid gray; + border-radius: 5px; + position: relative; + background-color: whitesmoke; + color: #c4142c; +} + +.servicesImg { + height: 50px; + width: 70px; + position: absolute; + left: 10px; + top: 5px; + margin: auto; + text-align: center; +} + +.servicesImgText { + position: absolute; + left: 30px; + bottom: 1px; +} + +.newPageHref { + float: left; + margin-top: 15px; +} + +.logoImg { + width:100%; + height:auto; + max-width: 300px; + display: block; + margin-left: auto; + margin-right: auto; +} + +.faceCss{ + height: 50px; + width: 70px; + text-align: center; +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.spec.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.spec.ts new file mode 100644 index 00000000..62c66a26 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.spec.ts @@ -0,0 +1,39 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; +import { HomePage } from './home.page'; + +describe('HomePage', () => { + let component: HomePage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ HomePage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(HomePage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.ts new file mode 100644 index 00000000..08b34267 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/home/home.page.ts @@ -0,0 +1,57 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Component } from "@angular/core"; +import { Router } from "@angular/router"; +import { Platform } from "@ionic/angular"; +declare var HMSMLTextPlugin; +@Component({ + selector: "app-home", + templateUrl: "home.page.html", + styleUrls: ["home.page.scss"], +}) +export class HomePage { + constructor(private router: Router, public platform: Platform) {} + ionViewWillEnter() { + this.platform.ready().then(() => { + var configInput = { + apiKey: "your_apiKey", + }; + HMSMLTextPlugin.serviceInitializer(configInput); + }); + } + + bcrPage() { + this.router.navigate(["bcr"]); + } + textPage() { + this.router.navigate(["text"]); + } + documentPage() { + this.router.navigate(["document"]); + } + gcrPage() { + this.router.navigate(["generalcard"]); + } + formRecogPage() { + this.router.navigate(["formrecognition"]); + } + icrVnPage() { + this.router.navigate(["icrVn"]); + } + icrCnPage() { + this.router.navigate(["icrCn"]); + } +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn-routing.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn-routing.module.ts new file mode 100644 index 00000000..962bdfaf --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn-routing.module.ts @@ -0,0 +1,31 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { Routes, RouterModule } from "@angular/router"; +import { icrCnPage } from "./icrCn.page"; + +const routes: Routes = [ + { + path: "", + component: icrCnPage, + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class icrCnRoutingModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.module.ts new file mode 100644 index 00000000..3666c903 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.module.ts @@ -0,0 +1,30 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; +import { FormsModule } from "@angular/forms"; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +import { IonicModule } from "@ionic/angular"; +import { HMSMLText } from "@hmscore/ionic-native-hms-mltext/ngx"; +import { icrCnRoutingModule } from "./icrCn-routing.module"; +import { icrCnPage } from "./icrCn.page"; + +@NgModule({ + imports: [CommonModule, FormsModule, IonicModule, icrCnRoutingModule], + declarations: [icrCnPage], + providers: [FileChooser, HMSMLText], +}) +export class icrCnPageModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.html b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.html new file mode 100644 index 00000000..850b5e18 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.html @@ -0,0 +1,34 @@ + + +
+ ICR Cn +
+ +
+ ICR Cn Detect +
+ +
+ Select ICR Cn Picture +
+
+ Capture Image +
+ +
+ +
diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.scss b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.scss new file mode 100644 index 00000000..60547ee2 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.scss @@ -0,0 +1,15 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.spec.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.spec.ts new file mode 100644 index 00000000..6504d3f0 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.spec.ts @@ -0,0 +1,38 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { async, ComponentFixture, TestBed } from "@angular/core/testing"; +import { IonicModule } from "@ionic/angular"; +import { icrCnPage } from "./icrCn.page"; + +describe("icrCnPage", () => { + let component: icrCnPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [icrCnPage], + imports: [IonicModule.forRoot()], + }).compileComponents(); + + fixture = TestBed.createComponent(icrCnPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.ts new file mode 100644 index 00000000..ccbc55c3 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrCn/icrCn.page.ts @@ -0,0 +1,64 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Component, OnInit } from "@angular/core"; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +declare var HMSMLText; +@Component({ + selector: "app-face", + templateUrl: "./icrCn.page.html", + styleUrls: ["./icrCn.page.scss"], +}) +export class icrCnPage { + filePath: string = ""; + + constructor(private fileChooser: FileChooser) {} + + public async getFile() { + this.fileChooser + .open() + .then((uri) => (this.filePath = uri)) + .catch((e) => console.log(e)); + } + + public async captureImage() { + var icrCnDetectorReq = { + captureType: 1, + filePath: this.filePath, + }; + try { + const result = await HMSMLText.icrCnCardDetector( + icrCnDetectorReq + ); + alert(JSON.stringify(result)); + console.log(JSON.stringify(result)); + } catch (Ex) { + alert(JSON.stringify(Ex)); + } + } + + public async icrCnDetector() { + var icrCnDetectorReq = {}; + try { + alert( + JSON.stringify( + await HMSMLText.icrCnCardDetector(icrCnDetectorReq) + ) + ); + } catch (ex) { + alert(JSON.stringify(ex)); + } + } +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn-routing.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn-routing.module.ts new file mode 100644 index 00000000..97174768 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn-routing.module.ts @@ -0,0 +1,31 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { Routes, RouterModule } from "@angular/router"; +import { icrVnPage } from "./icrVn.page"; + +const routes: Routes = [ + { + path: "", + component: icrVnPage, + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class icrVnRoutingModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.module.ts new file mode 100644 index 00000000..7722eb15 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.module.ts @@ -0,0 +1,30 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; +import { FormsModule } from "@angular/forms"; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +import { IonicModule } from "@ionic/angular"; +import { HMSMLText } from "@hmscore/ionic-native-hms-mltext/ngx"; +import { icrVnRoutingModule } from "./icrVn-routing.module"; +import { icrVnPage } from "./icrVn.page"; + +@NgModule({ + imports: [CommonModule, FormsModule, IonicModule, icrVnRoutingModule], + declarations: [icrVnPage], + providers: [FileChooser, HMSMLText], +}) +export class icrVnPageModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.html b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.html new file mode 100644 index 00000000..90aa0081 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.html @@ -0,0 +1,35 @@ + + +
+ ICR VN +
+ +
+ ICR VN Detect +
+ +
+ Select ICR VN Picture +
+
+ Capture Image +
+ + +
+ +
diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.scss b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.scss new file mode 100644 index 00000000..60547ee2 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.scss @@ -0,0 +1,15 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.spec.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.spec.ts new file mode 100644 index 00000000..86995dc3 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.spec.ts @@ -0,0 +1,38 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { async, ComponentFixture, TestBed } from "@angular/core/testing"; +import { IonicModule } from "@ionic/angular"; +import { icrVnPage } from "./icrVn.page"; + +describe("icrVnPage", () => { + let component: icrVnPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [icrVnPage], + imports: [IonicModule.forRoot()], + }).compileComponents(); + + fixture = TestBed.createComponent(icrVnPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.ts new file mode 100644 index 00000000..81c3eca5 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/icrVn/icrVn.page.ts @@ -0,0 +1,64 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Component, OnInit } from "@angular/core"; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +declare var HMSMLText; +@Component({ + selector: "app-face", + templateUrl: "./icrVn.page.html", + styleUrls: ["./icrVn.page.scss"], +}) +export class icrVnPage { + filePath: string = ""; + + constructor(private fileChooser: FileChooser) {} + + public async getFile() { + this.fileChooser + .open() + .then((uri) => (this.filePath = uri)) + .catch((e) => console.log(e)); + } + + public async captureImage() { + var icrVnDetectorReq = { + captureType: 1, + filePath: this.filePath, + }; + try { + const result = await HMSMLText.icrVnCardDetector( + icrVnDetectorReq + ); + alert(JSON.stringify(result)); + console.log(JSON.stringify(result)); + } catch (Ex) { + alert(JSON.stringify(Ex)); + } + } + + public async icrVnDetector() { + var icrVnDetectorReq = {}; + try { + alert( + JSON.stringify( + await HMSMLText.icrVnCardDetector(icrVnDetectorReq) + ) + ); + } catch (ex) { + alert(JSON.stringify(ex)); + } + } +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/text/text-routing.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text-routing.module.ts new file mode 100644 index 00000000..c7c26aeb --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text-routing.module.ts @@ -0,0 +1,31 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { TextPage } from './text.page'; + +const routes: Routes = [ + { + path: '', + component: TextPage + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class TextPageRoutingModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.module.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.module.ts new file mode 100644 index 00000000..977975d6 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.module.ts @@ -0,0 +1,30 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { NgModule } from "@angular/core"; +import { CommonModule } from "@angular/common"; +import { FormsModule } from "@angular/forms"; +import { IonicModule } from "@ionic/angular"; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +import { TextPageRoutingModule } from "./text-routing.module"; +import { HMSMLText } from "@hmscore/ionic-native-hms-mltext/ngx"; +import { TextPage } from "./text.page"; + +@NgModule({ + imports: [CommonModule, FormsModule, IonicModule, TextPageRoutingModule], + declarations: [TextPage], + providers: [FileChooser, HMSMLText] +}) +export class TextPageModule {} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.html b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.html new file mode 100644 index 00000000..48b5c40f --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.html @@ -0,0 +1,41 @@ + + +
+ Text Recognition Analyser +
+ +
+ + + + +
+ +
+ Select Image +
+
+ Start Analyse +
+
+
+ Info Analyser +
+
+ Stop Analyse +
+
\ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.scss b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.scss new file mode 100644 index 00000000..60547ee2 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.scss @@ -0,0 +1,15 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.spec.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.spec.ts new file mode 100644 index 00000000..626e1492 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.spec.ts @@ -0,0 +1,38 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; +import { TextPage } from './text.page'; + +describe('TextPage', () => { + let component: TextPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TextPage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(TextPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.ts b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.ts new file mode 100644 index 00000000..f3f97ae3 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/app/text/text.page.ts @@ -0,0 +1,72 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Component, OnInit } from '@angular/core'; +import { FileChooser } from '@ionic-native/file-chooser/ngx'; +declare var HMSMLText; +@Component({ + selector: 'app-text', + templateUrl: './text.page.html', + styleUrls: ['./text.page.scss'], +}) +export class TextPage { + imageResult: string = ""; + textRecognitionOutput: string = ""; + constructor(private fileChooser: FileChooser) { } + + public async getFile() { + this.fileChooser.open() + .then(uri => this.imageResult = uri) + .catch(e => console.log(e)); + } + + public async ImageTextAnalyser() { + var localImageTextAnalyserInput = { + ocrType: 0, + analyseMode: 0, + localTextSetting: { + ocrMode:1, + language: "en", + }, + filePath: this.imageResult, + }; + try { + const result = await HMSMLText.imageTextAnalyser(localImageTextAnalyserInput); + this.textRecognitionOutput = JSON.stringify(result.stringValue); + } catch (ex) { + alert(JSON.stringify(ex)) + } + + } + public async ImageTextAnalyserInfo() { + try { + const result = await HMSMLText.getTextAnalyserInfo(); + alert( JSON.stringify(result)); + } catch (ex) { + alert(JSON.stringify(ex)) + } + + } + public async ImageTextAnalyserStop() { + try { + const result = await HMSMLText.stopTextAnalyser(); + alert(JSON.stringify(result)); + } catch (ex) { + alert(JSON.stringify(ex)) + } + + } + +} diff --git a/cordova-plugin-hms-mltext/example/ionic/src/assets/icon_record.png b/cordova-plugin-hms-mltext/example/ionic/src/assets/icon_record.png new file mode 100644 index 00000000..cb1f03e6 Binary files /dev/null and b/cordova-plugin-hms-mltext/example/ionic/src/assets/icon_record.png differ diff --git a/cordova-plugin-hms-mltext/example/ionic/src/assets/logo.png b/cordova-plugin-hms-mltext/example/ionic/src/assets/logo.png new file mode 100644 index 00000000..be3964eb Binary files /dev/null and b/cordova-plugin-hms-mltext/example/ionic/src/assets/logo.png differ diff --git a/cordova-plugin-hms-mltext/example/ionic/src/environments/environment.prod.ts b/cordova-plugin-hms-mltext/example/ionic/src/environments/environment.prod.ts new file mode 100644 index 00000000..1be814dd --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/environments/environment.prod.ts @@ -0,0 +1,18 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +export const environment = { + production: true +}; diff --git a/cordova-plugin-hms-mltext/example/ionic/src/environments/environment.ts b/cordova-plugin-hms-mltext/example/ionic/src/environments/environment.ts new file mode 100644 index 00000000..512f59b6 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/environments/environment.ts @@ -0,0 +1,27 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +export const environment = { + production: false +}; + +/* + * For easier debugging in development mode, you can import the following file + * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. + * + * This import should be commented out in production mode because it will have a negative impact + * on performance if an error is thrown. + */ +// import 'zone.js/dist/zone-error'; // Included with Angular CLI. diff --git a/cordova-plugin-hms-mltext/example/ionic/src/global.scss b/cordova-plugin-hms-mltext/example/ionic/src/global.scss new file mode 100644 index 00000000..d854de84 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/global.scss @@ -0,0 +1,26 @@ +/* + * App Global CSS + * ---------------------------------------------------------------------------- + * Put style rules here that you want to apply globally. These styles are for + * the entire app and not just one component. Additionally, this file can be + * used as an entry point to import other CSS/Sass files to be included in the + * output CSS. + * For more information on global stylesheets, visit the documentation: + * https://ionicframework.com/docs/layout/global-stylesheets + */ + +/* Core CSS required for Ionic components to work properly */ +@import "~@ionic/angular/css/core.css"; + +/* Basic CSS for apps built with Ionic */ +@import "~@ionic/angular/css/normalize.css"; +@import "~@ionic/angular/css/structure.css"; +@import "~@ionic/angular/css/typography.css"; +@import '~@ionic/angular/css/display.css'; + +/* Optional CSS utils that can be commented out */ +@import "~@ionic/angular/css/padding.css"; +@import "~@ionic/angular/css/float-elements.css"; +@import "~@ionic/angular/css/text-alignment.css"; +@import "~@ionic/angular/css/text-transformation.css"; +@import "~@ionic/angular/css/flex-utils.css"; diff --git a/cordova-plugin-hms-mltext/example/ionic/src/index.html b/cordova-plugin-hms-mltext/example/ionic/src/index.html new file mode 100644 index 00000000..06b65608 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/index.html @@ -0,0 +1,40 @@ + + + + + + + Ionic App + + + + + + + + + + + + + + + + + + + diff --git a/cordova-plugin-hms-mltext/example/ionic/src/main.ts b/cordova-plugin-hms-mltext/example/ionic/src/main.ts new file mode 100644 index 00000000..0c7f1c99 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/main.ts @@ -0,0 +1,27 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { enableProdMode } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app/app.module'; +import { environment } from './environments/environment'; + +if (environment.production) { + enableProdMode(); +} + +platformBrowserDynamic().bootstrapModule(AppModule) + .catch(err => console.log(err)); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/polyfills.ts b/cordova-plugin-hms-mltext/example/ionic/src/polyfills.ts new file mode 100644 index 00000000..aec6fbd8 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/polyfills.ts @@ -0,0 +1,17 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import './zone-flags'; +import 'zone.js/dist/zone'; // Included with Angular CLI. diff --git a/cordova-plugin-hms-mltext/example/ionic/src/test.ts b/cordova-plugin-hms-mltext/example/ionic/src/test.ts new file mode 100644 index 00000000..bf9150f0 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/test.ts @@ -0,0 +1,35 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/zone-testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: any; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); diff --git a/cordova-plugin-hms-mltext/example/ionic/src/theme/variables.scss b/cordova-plugin-hms-mltext/example/ionic/src/theme/variables.scss new file mode 100644 index 00000000..63d627fc --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/theme/variables.scss @@ -0,0 +1,228 @@ +// Ionic Variables and Theming. For more info, please see: +// http://ionicframework.com/docs/theming/ + +/** Ionic CSS Variables **/ +:root { + /** primary **/ + --ion-color-primary: #3880ff; + --ion-color-primary-rgb: 56, 128, 255; + --ion-color-primary-contrast: #ffffff; + --ion-color-primary-contrast-rgb: 255, 255, 255; + --ion-color-primary-shade: #3171e0; + --ion-color-primary-tint: #4c8dff; + + /** secondary **/ + --ion-color-secondary: #3dc2ff; + --ion-color-secondary-rgb: 61, 194, 255; + --ion-color-secondary-contrast: #ffffff; + --ion-color-secondary-contrast-rgb: 255, 255, 255; + --ion-color-secondary-shade: #36abe0; + --ion-color-secondary-tint: #50c8ff; + + /** tertiary **/ + --ion-color-tertiary: #5260ff; + --ion-color-tertiary-rgb: 82, 96, 255; + --ion-color-tertiary-contrast: #ffffff; + --ion-color-tertiary-contrast-rgb: 255, 255, 255; + --ion-color-tertiary-shade: #4854e0; + --ion-color-tertiary-tint: #6370ff; + + /** success **/ + --ion-color-success: #2dd36f; + --ion-color-success-rgb: 45, 211, 111; + --ion-color-success-contrast: #ffffff; + --ion-color-success-contrast-rgb: 255, 255, 255; + --ion-color-success-shade: #28ba62; + --ion-color-success-tint: #42d77d; + + /** warning **/ + --ion-color-warning: #ffc409; + --ion-color-warning-rgb: 255, 196, 9; + --ion-color-warning-contrast: #000000; + --ion-color-warning-contrast-rgb: 0, 0, 0; + --ion-color-warning-shade: #e0ac08; + --ion-color-warning-tint: #ffca22; + + /** danger **/ + --ion-color-danger: #eb445a; + --ion-color-danger-rgb: 235, 68, 90; + --ion-color-danger-contrast: #ffffff; + --ion-color-danger-contrast-rgb: 255, 255, 255; + --ion-color-danger-shade: #cf3c4f; + --ion-color-danger-tint: #ed576b; + + /** dark **/ + --ion-color-dark: #222428; + --ion-color-dark-rgb: 34, 36, 40; + --ion-color-dark-contrast: #ffffff; + --ion-color-dark-contrast-rgb: 255, 255, 255; + --ion-color-dark-shade: #1e2023; + --ion-color-dark-tint: #383a3e; + + /** medium **/ + --ion-color-medium: #92949c; + --ion-color-medium-rgb: 146, 148, 156; + --ion-color-medium-contrast: #ffffff; + --ion-color-medium-contrast-rgb: 255, 255, 255; + --ion-color-medium-shade: #808289; + --ion-color-medium-tint: #9d9fa6; + + /** light **/ + --ion-color-light: #f4f5f8; + --ion-color-light-rgb: 244, 245, 248; + --ion-color-light-contrast: #000000; + --ion-color-light-contrast-rgb: 0, 0, 0; + --ion-color-light-shade: #d7d8da; + --ion-color-light-tint: #f5f6f9; +} + +@media (prefers-color-scheme: dark) { + /* + * Dark Colors + * ------------------------------------------- + */ + + body { + --ion-color-primary: #428cff; + --ion-color-primary-rgb: 66,140,255; + --ion-color-primary-contrast: #ffffff; + --ion-color-primary-contrast-rgb: 255,255,255; + --ion-color-primary-shade: #3a7be0; + --ion-color-primary-tint: #5598ff; + + --ion-color-secondary: #50c8ff; + --ion-color-secondary-rgb: 80,200,255; + --ion-color-secondary-contrast: #ffffff; + --ion-color-secondary-contrast-rgb: 255,255,255; + --ion-color-secondary-shade: #46b0e0; + --ion-color-secondary-tint: #62ceff; + + --ion-color-tertiary: #6a64ff; + --ion-color-tertiary-rgb: 106,100,255; + --ion-color-tertiary-contrast: #ffffff; + --ion-color-tertiary-contrast-rgb: 255,255,255; + --ion-color-tertiary-shade: #5d58e0; + --ion-color-tertiary-tint: #7974ff; + + --ion-color-success: #2fdf75; + --ion-color-success-rgb: 47,223,117; + --ion-color-success-contrast: #000000; + --ion-color-success-contrast-rgb: 0,0,0; + --ion-color-success-shade: #29c467; + --ion-color-success-tint: #44e283; + + --ion-color-warning: #ffd534; + --ion-color-warning-rgb: 255,213,52; + --ion-color-warning-contrast: #000000; + --ion-color-warning-contrast-rgb: 0,0,0; + --ion-color-warning-shade: #e0bb2e; + --ion-color-warning-tint: #ffd948; + + --ion-color-danger: #ff4961; + --ion-color-danger-rgb: 255,73,97; + --ion-color-danger-contrast: #ffffff; + --ion-color-danger-contrast-rgb: 255,255,255; + --ion-color-danger-shade: #e04055; + --ion-color-danger-tint: #ff5b71; + + --ion-color-dark: #f4f5f8; + --ion-color-dark-rgb: 244,245,248; + --ion-color-dark-contrast: #000000; + --ion-color-dark-contrast-rgb: 0,0,0; + --ion-color-dark-shade: #d7d8da; + --ion-color-dark-tint: #f5f6f9; + + --ion-color-medium: #989aa2; + --ion-color-medium-rgb: 152,154,162; + --ion-color-medium-contrast: #000000; + --ion-color-medium-contrast-rgb: 0,0,0; + --ion-color-medium-shade: #86888f; + --ion-color-medium-tint: #a2a4ab; + + --ion-color-light: #222428; + --ion-color-light-rgb: 34,36,40; + --ion-color-light-contrast: #ffffff; + --ion-color-light-contrast-rgb: 255,255,255; + --ion-color-light-shade: #1e2023; + --ion-color-light-tint: #383a3e; + } + + /* + * iOS Dark Theme + * ------------------------------------------- + */ + + .ios body { + --ion-background-color: #000000; + --ion-background-color-rgb: 0,0,0; + + --ion-text-color: #ffffff; + --ion-text-color-rgb: 255,255,255; + + --ion-color-step-50: #0d0d0d; + --ion-color-step-100: #1a1a1a; + --ion-color-step-150: #262626; + --ion-color-step-200: #333333; + --ion-color-step-250: #404040; + --ion-color-step-300: #4d4d4d; + --ion-color-step-350: #595959; + --ion-color-step-400: #666666; + --ion-color-step-450: #737373; + --ion-color-step-500: #808080; + --ion-color-step-550: #8c8c8c; + --ion-color-step-600: #999999; + --ion-color-step-650: #a6a6a6; + --ion-color-step-700: #b3b3b3; + --ion-color-step-750: #bfbfbf; + --ion-color-step-800: #cccccc; + --ion-color-step-850: #d9d9d9; + --ion-color-step-900: #e6e6e6; + --ion-color-step-950: #f2f2f2; + + --ion-toolbar-background: #0d0d0d; + + --ion-item-background: #000000; + } + + + /* + * Material Design Dark Theme + * ------------------------------------------- + */ + + .md body { + --ion-background-color: #121212; + --ion-background-color-rgb: 18,18,18; + + --ion-text-color: #ffffff; + --ion-text-color-rgb: 255,255,255; + + --ion-border-color: #222222; + + --ion-color-step-50: #1e1e1e; + --ion-color-step-100: #2a2a2a; + --ion-color-step-150: #363636; + --ion-color-step-200: #414141; + --ion-color-step-250: #4d4d4d; + --ion-color-step-300: #595959; + --ion-color-step-350: #656565; + --ion-color-step-400: #717171; + --ion-color-step-450: #7d7d7d; + --ion-color-step-500: #898989; + --ion-color-step-550: #949494; + --ion-color-step-600: #a0a0a0; + --ion-color-step-650: #acacac; + --ion-color-step-700: #b8b8b8; + --ion-color-step-750: #c4c4c4; + --ion-color-step-800: #d0d0d0; + --ion-color-step-850: #dbdbdb; + --ion-color-step-900: #e7e7e7; + --ion-color-step-950: #f3f3f3; + + --ion-item-background: #1e1e1e; + + --ion-toolbar-background: #1f1f1f; + + --ion-tab-bar-background: #1f1f1f; + } +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/src/zone-flags.ts b/cordova-plugin-hms-mltext/example/ionic/src/zone-flags.ts new file mode 100644 index 00000000..a79d4e35 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/src/zone-flags.ts @@ -0,0 +1,17 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +(window as any).__Zone_disable_customElements = true; diff --git a/cordova-plugin-hms-mltext/example/ionic/tsconfig.app.json b/cordova-plugin-hms-mltext/example/ionic/tsconfig.app.json new file mode 100644 index 00000000..91b32f2f --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/tsconfig.app.json @@ -0,0 +1,18 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.ts", + "src/**/*.d.ts" + ], + "exclude": [ + "src/**/*.spec.ts" + ] +} diff --git a/cordova-plugin-hms-mltext/example/ionic/tsconfig.json b/cordova-plugin-hms-mltext/example/ionic/tsconfig.json new file mode 100644 index 00000000..00482e7b --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "skipLibCheck": true, + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "module": "esnext", + "moduleResolution": "node", + "importHelpers": true, + "target": "es2015", + "lib": [ + "es2018", + "dom" + ] + }, + "angularCompilerOptions": { + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true + } +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/tsconfig.spec.json b/cordova-plugin-hms-mltext/example/ionic/tsconfig.spec.json new file mode 100644 index 00000000..b5bda534 --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/tsconfig.spec.json @@ -0,0 +1,18 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/spec", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "src/test.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/example/ionic/tslint.json b/cordova-plugin-hms-mltext/example/ionic/tslint.json new file mode 100644 index 00000000..21329f4e --- /dev/null +++ b/cordova-plugin-hms-mltext/example/ionic/tslint.json @@ -0,0 +1,149 @@ +{ + "extends": "tslint:recommended", + "rules": { + "align": { + "options": [ + "parameters", + "statements" + ] + }, + "array-type": false, + "arrow-return-shorthand": true, + "curly": true, + "deprecation": { + "severity": "warning" + }, + "component-class-suffix": [true, "Page", "Component"], + "contextual-lifecycle": true, + "directive-class-suffix": true, + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], + "eofline": true, + "import-blacklist": [ + true, + "rxjs/Rx" + ], + "import-spacing": true, + "indent": { + "options": [ + "spaces" + ] + }, + "max-classes-per-file": false, + "max-line-length": [ + true, + 140 + ], + "member-ordering": [ + true, + { + "order": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } + ], + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-empty": false, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-non-null-assertion": true, + "no-redundant-jsdoc": true, + "no-switch-case-fall-through": true, + "no-var-requires": false, + "object-literal-key-quotes": [ + true, + "as-needed" + ], + "quotemark": [ + true, + "single" + ], + "semicolon": { + "options": [ + "always" + ] + }, + "space-before-function-paren": { + "options": { + "anonymous": "never", + "asyncArrow": "always", + "constructor": "never", + "method": "never", + "named": "never" + } + }, + "typedef-whitespace": { + "options": [ + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + } + ] + }, + "variable-name": { + "options": [ + "ban-keywords", + "check-format", + "allow-pascal-case" + ] + }, + "whitespace": { + "options": [ + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type", + "check-typecast" + ] + }, + "no-conflicting-lifecycle": true, + "no-host-metadata-property": true, + "no-input-rename": true, + "no-inputs-metadata-property": true, + "no-output-native": true, + "no-output-on-prefix": true, + "no-output-rename": true, + "no-outputs-metadata-property": true, + "template-banana-in-box": true, + "template-no-negated-async": true, + "use-lifecycle-interface": true, + "use-pipe-transform-interface": true, + "object-literal-sort-keys": false + }, + "rulesDirectory": [ + "codelyzer" + ] +} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/hooks/FSUtils.js b/cordova-plugin-hms-mltext/hooks/FSUtils.js new file mode 100644 index 00000000..ccc77170 --- /dev/null +++ b/cordova-plugin-hms-mltext/hooks/FSUtils.js @@ -0,0 +1,43 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +"use strict"; + +var fs = require("fs"); + +var FSUtils = (function () { + var api = {}; + + api.exists = function (path) { + try { + return fs.existsSync(path); + } catch (err) { + /*No need to handle*/ + } + return false; + }; + + api.readFile = function (path, encoding) { + return fs.readFileSync(path, encoding); + }; + + api.writeFile = function (path, content) { + fs.writeFileSync(path, content); + }; + + return api; +})(); + +module.exports = FSUtils; diff --git a/cordova-plugin-hms-mltext/hooks/after_plugin_install.js b/cordova-plugin-hms-mltext/hooks/after_plugin_install.js new file mode 100644 index 00000000..e7513f98 --- /dev/null +++ b/cordova-plugin-hms-mltext/hooks/after_plugin_install.js @@ -0,0 +1,97 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +"use strict"; + +var FSUtils = require("./FSUtils"); + +var ROOT_BUILD_GRADLE_FILE = "platforms/android/build.gradle"; +var ROOT_REPOSITORIES_GRADLE_FILE = "platforms/android/repositories.gradle"; +var APP_REPOSITORIES_GRADLE_FILE = "platforms/android/app/repositories.gradle"; +var COMMENT = "//This line is added by cordova-plugin-hms-mltext plugin"; +var NEW_LINE = "\n"; + +module.exports = function (context) { + if (!FSUtils.exists(ROOT_BUILD_GRADLE_FILE)) { + console.log("root gradle file does not exist. after_plugin_install script wont be executed."); + } + + var rootGradleContent = FSUtils.readFile(ROOT_BUILD_GRADLE_FILE, "UTF-8"); + var lines = rootGradleContent.split(NEW_LINE); + + var depAddedLines = addAGConnectDependency(lines); + var repoAddedLines = addHuaweiRepo(depAddedLines); + + FSUtils.writeFile(ROOT_BUILD_GRADLE_FILE, repoAddedLines.join(NEW_LINE)); + + updateRepositoriesGradle(ROOT_REPOSITORIES_GRADLE_FILE); + updateRepositoriesGradle(APP_REPOSITORIES_GRADLE_FILE); +}; + +function addAGConnectDependency(lines) { + var AG_CONNECT_DEPENDENCY = "classpath 'com.huawei.agconnect:agcp:1.9.1.300' " + COMMENT; + var pattern = /(\s*)classpath(\s+)[\',\"]com.android.tools.build:gradle.*[^\]\n]/m; + var index; + + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; + if (pattern.test(line)) { + index = i; + break; + } + } + + lines.splice(index + 1, 0, AG_CONNECT_DEPENDENCY); + return lines; +} + +function addHuaweiRepo(lines) { + var HUAWEI_REPO = "maven { url 'https://developer.huawei.com/repo/' } " + COMMENT; + var pattern = /(\s*)jcenter\(\)/m; + var indexList = []; + + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; + if (pattern.test(line)) { + indexList.push(i); + } + } + + for (var i = 0; i < indexList.length; i++) { + lines.splice(indexList[i] + 1, 0, HUAWEI_REPO); + if (i < indexList.length - 1) { + indexList[i + 1] = indexList[i + 1] + 1; + } + } + + return lines; +} + +function updateRepositoriesGradle(file) { + if (FSUtils.exists(file)) { + var repoGradleContent = FSUtils.readFile(file, "UTF-8"); + if (repoGradleContent.indexOf("developer.huawei.com/repo") === -1) { + var lastIndexOfCurlyBracket = repoGradleContent.lastIndexOf("}"); + + repoGradleContent = + repoGradleContent.substring(0, lastIndexOfCurlyBracket) + + " maven { url 'https://developer.huawei.com/repo/' } "+COMMENT+" \n}" + + repoGradleContent.substring(lastIndexOfCurlyBracket + 1); + + FSUtils.writeFile(file, repoGradleContent); + } + } +} diff --git a/cordova-plugin-hms-mltext/hooks/before_plugin_uninstall.js b/cordova-plugin-hms-mltext/hooks/before_plugin_uninstall.js new file mode 100644 index 00000000..e6c91fb4 --- /dev/null +++ b/cordova-plugin-hms-mltext/hooks/before_plugin_uninstall.js @@ -0,0 +1,64 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +"use strict"; + +var FSUtils = require("./FSUtils"); + +var ROOT_GRADLE_FILE = "platforms/android/build.gradle"; +var ROOT_REPOSITORIES_GRADLE_FILE = "platforms/android/repositories.gradle"; +var APP_REPOSITORIES_GRADLE_FILE = "platforms/android/app/repositories.gradle"; +var COMMENT = "//This line is added by cordova-plugin-hms-mltext plugin"; +var NEW_LINE = "\n"; + +module.exports = function (context) { + removeLinesFromGradle(ROOT_GRADLE_FILE); + removeLinesFromGradle(ROOT_REPOSITORIES_GRADLE_FILE); + removeLinesFromGradle(APP_REPOSITORIES_GRADLE_FILE); +}; + +function removeLinesFromGradle(repositoryPath) { + if (!FSUtils.exists(repositoryPath)) { + return + } + + var rootGradleContent = FSUtils.readFile(repositoryPath, "UTF-8"); + var lines = rootGradleContent.split(NEW_LINE); + var linesAfterRemove = removeLinesAddedByPlugin(lines); + FSUtils.writeFile(repositoryPath, linesAfterRemove.join(NEW_LINE)); +} + +function removeLinesAddedByPlugin(lines) { + var indexList = []; + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; + if (line.includes(COMMENT)) { + indexList.push(i); + } + } + + for (var i = 0; i < indexList.length; i++) { + lines.splice(indexList[i], 1); + + //if a line is removed, indexes are changed + if (i !== indexList.length - 1) { + for (var j = i + 1; j < indexList.length; j++) { + indexList[j] = indexList[j] - 1; + } + } + } + + return lines; +} diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/LICENSE b/cordova-plugin-hms-mltext/ionic-native/dist/LICENSE new file mode 100644 index 00000000..490b5c70 --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/LICENSE @@ -0,0 +1,53 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and +You must cause any modified files to carry prominent notices stating that You changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/README.md b/cordova-plugin-hms-mltext/ionic-native/dist/README.md new file mode 100644 index 00000000..183142a7 --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/README.md @@ -0,0 +1,82 @@ +

+

Ionic Native HMS ML Text

+

+ +

+ downloads + NPM version + License +

+ +---- + +## 1. About + +Ionic Native wrappers for +the [cordova-plugin-hms-mltext](https://www.npmjs.com/package/@hmscore/cordova-plugin-hms-mltext). + +--- + +## 2. Installation + +### 2.1 With Cordova Runtime + +```bash +$ ionic cordova plugin add @hmscore/cordova-plugin-hms-mltext +``` + +```bash +$ npm install @ionic-native/core @hmscore/ionic-native-hms-mltext +``` + +### 2.2 With Capacitor Runtime + +```bash +$ npm install @hmscore/cordova-plugin-hms-mltext +``` + +```bash +$ npm install @ionic-native/core @hmscore/ionic-native-hms-mltext +``` + +--- + +## 3. Usage Documentation + +- [GitHub repository](https://github.com/HMS-Core/hms-cordova-plugin) + +- [API reference and sample codes](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-References-V1/introduction-0000001051088632-V1?ha_source=hms1) + +--- + +## 4. Sample Project + +You can find the sample projects +on [HMS Core > Samples > ML Text Kit](https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1) +page. + +--- + +## 5. Questions or Issues + +If you have questions about how to use HMS samples, try the following options: + +- [Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services) is the best + place for any programming questions. Be sure to tag your question + with **`huawei-mobile-services`**. +- [GitHub](https://github.com/HMS-Core/hms-cordova-plugin) is the official repository for these + plugins, You can open an issue or submit your ideas. +- [Huawei Developer Forum](https://forums.developer.huawei.com/forumPortal/en/home?fid=0101187876626530001&ha_source=hms1) + HMS Core Module is great for general questions, or seeking recommendations and opinions. +- [Huawei Developer Docs](https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1) + is place to official documentation for all HMS Core Kits, you can find detailed documentations in + there. + +If you run into a bug in our samples, please submit an issue to +the [GitHub repository](https://github.com/HMS-Core/hms-cordova-plugin). + +--- + +## 6. Licensing and Terms + +Ionic Native HMS ML Text is licensed under the [Apache 2.0 license](LICENSE). diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/index.d.ts b/cordova-plugin-hms-mltext/ionic-native/dist/index.d.ts new file mode 100644 index 00000000..50756ba8 --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/index.d.ts @@ -0,0 +1,591 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { IonicNativePlugin } from "@ionic-native/core"; +export declare class HMSMLTextPluginOriginal extends IonicNativePlugin { + MLLocalTextSetting: typeof MLLocalTextSetting; + icrVnCaptureType: typeof icrCaptureType; + MLTextConfig: typeof MLTextConfig; + MLRemoteTextSetting: typeof MLRemoteTextSetting; + MLBcrCaptureConfig: typeof MLBcrCaptureConfig; + MLGcrCaptureUIConfig: typeof MLGcrCaptureUIConfig; + MLBcrResultConfig: typeof MLBcrResultConfig; + ImgSuperResolutionConfig: typeof ImgSuperResolutionConfig; + MLFormRecogitionConfig: typeof MLFormRecogitionConfig; + MLProductConfig: typeof MLProductConfig; + gcrCaptureType: typeof gcrCaptureType; + Colors: typeof Colors; + /** + * Monitors photographing. + * @returns Promise + */ + photograph(): Promise; + /** + * Close lens engine. + * @returns Promise + */ + destroy(): Promise; + /** + * Obtains the size of the preview image of a camera. + * @returns Promise + */ + getDisplayDimension(): Promise; + /** + * An app information class used to store basic information about apps with the HMS Core ML SDK integrated and complete the initialization of ML Text Kit. When using cloud services of the ML Text Kit, you need to set the apiKey of your app. + * @param {appSettingReq} appSettingReq Represents the parameter required. + * @returns Promise + */ + appSetting(appSettingReq: appSettingReq): Promise; + /** + * Determines whether to collect statistics on the current app. + * @param {any} any + * @returns Promise + */ + setStatistic(any: any): Promise; + /** + * Determines whether to collect statistics on the current app. + ** @param {any} any + * @returns Promise + */ + getStatistic(any: any): Promise; + /** + * This service enable logger service. + * @returns Promise + */ + enableLogger(): Promise; + /** + * This service disable logger service. + * @returns Promise + */ + disableLogger(): Promise; +} +export declare class HMSMLTextOriginal extends IonicNativePlugin { + icrVnCaptureType: typeof icrCaptureType; + gcrCaptureType: typeof gcrCaptureType; + MLLocalTextSetting: typeof MLLocalTextSetting; + MLTextConfig: typeof MLTextConfig; + MLRemoteTextSetting: typeof MLRemoteTextSetting; + MLBcrCaptureConfig: typeof MLBcrCaptureConfig; + MLGcrCaptureUIConfig: typeof MLGcrCaptureUIConfig; + MLBcrResultConfig: typeof MLBcrResultConfig; + ImgSuperResolutionConfig: typeof ImgSuperResolutionConfig; + MLFormRecogitionConfig: typeof MLFormRecogitionConfig; + MLProductConfig: typeof MLProductConfig; + Colors: typeof Colors; + RecMode: typeof RecMode; + /** + * This method start the Text analyzer. + * @param {localImageTextReq|remoteImageTextReq} ImageTextAnalyserInput Reperesents the necessary parameters to convert images to text format. + * @returns Promise + */ + imageTextAnalyser(ImageTextAnalyserInput: localImageTextReq | remoteImageTextReq): Promise; + /** + * This method stop the Text analyzer. + * @returns Promise + */ + stopTextAnalyser(): Promise; + /** + * This method gives Text Analyser information. + * @returns Promise + */ + getTextAnalyserInfo(): Promise; + /** + * This method provides a document recognition component that recognizes text from images of documents. + * @param {documentImageAnalyserReq} documentImageAnalyserReq Reperesents the necessary parameter to convert document images to text format. + * @returns Promise + */ + documentImageAnalyser(documentImageAnalyserReq: documentImageAnalyserReq): Promise; + /** + * This method stop the Document analyzer. + * @returns Promise + */ + stopDocumentImageAnalyser(): Promise; + /** + * This method close the Document analyzer. + * @returns Promise + */ + closeDocumentImageAnalyser(): Promise; + /** + * This method returns the Document analyzer setting. + * @returns Promise + */ + getDocumentImageAnalyserSetting(): Promise; + /** + * This method returns the Image analyzer setting. + * @returns Promise + */ + getTextAnalyserSetting(): Promise; + /** + * This method returns the GCR setting. + * @returns Promise + */ + getGCRSetting(): Promise; + /** + * This method stop the Form Recognition Analyzer. + * @returns Promise + */ + stopFormRecognitionAnalyser(): Promise; + /** + * The bank card recognition service recognizes bank cards in camera streams within angle offset of 15 degrees and extracts key information such as card number and validity period. + * @param {bankCardSDKDetectorReq|bankCardPluginDetectorReq} bankCardDetecterInput Represents the parameter required for bank card recognition. + * @returns Promise | Promise + */ + bankCardDetector(bankCardDetecterInput: bankCardSDKDetectorReq | bankCardPluginDetectorReq): Promise; + /** + * This method stop bankcard recognition service. + * @returns Promise + */ + stopBankCardDetector(): Promise; + setResultTypeBcr(mLBcrCaptureConfig: mLBcrCaptureConfig): Promise; + setRecModeBcr(mLBcrCaptureConfig: mLBcrCaptureConfig): Promise; + /** + * This method returns the BCR setting. + * @returns Promise + */ + getBankCardDetectorSetting(): Promise; + /** + * The general card recognition service provides a universal development framework based on the text recognition technology. + * @param {generalCardDetectorReq} generalCardDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + generalCardDetector(generalCardDetectorReq: generalCardDetectorReq): Promise; + /** + * The general Vietnam id card recognition service provides a universal development framework based on the text recognition technology. + * @param {icrVnDetectorReq} icrVnDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + icrVnCardDetector(icrVnDetectorReq: icrVnDetectorReq): Promise; + /** + * The form recognition service uses AI technologies to recognize and return form structure information (including rows, columns, and coordinates of cells) and form text in Chinese and English (including punctuation) from input images. + * @param {formRecognizerAnalyserReq} formRecognizerAnalyserReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + formRecognitionAnalyser(formRecognizerAnalyserReq: formRecognizerAnalyserReq): Promise; + icrLocalAnalyser(localAnalyserReq: localAnalyserReq): Promise; + icrLocalAnalyserCreateIdCard(createIdCardReq: createIdCardReq): Promise; + icrLocalAnalyserStop(): Promise; + geticrCnCardInstance(): Promise; + icrCnCardCreate(): Promise; + geticrVnCardInstance(): Promise; + icrVnCardCreate(): Promise; + getIcrVnCapture(): Promise; + startCustomizedView(userProps: CustomViewModeRequest): Promise; + switchLight(): Promise; + getLightStatus(): Promise; + setUserRegion(region: Region): Promise; + getCountryCode(): Promise; +} +export interface CustomViewModeRequest { + isTitleAvailable: boolean; + title: string; + heightFactor: number; + widthFactor: number; + isFlashAvailable: boolean; + resultType: MLBcrResultConfig; + recMode: RecMode; +} +export interface configReq { + apiKey: string; +} +export interface appSettingReq { + apiKey?: string | null; + applicationId?: string | null; + certFingerprint?: string | null; +} +export interface bankCardSDKDetectorReq { + filePath: any; + detectType: 0; + mLBcrAnalyzerSetting?: MLBcrAnalyzerSetting | null; +} +export interface MLBcrAnalyzerSetting { + langType?: string | null; + resultType?: MLBcrResultConfig | null; +} +export interface bankCardPluginDetectorReq { + detectType: 1; + mLBcrCaptureConfig?: mLBcrCaptureConfig | null; +} +export interface mLBcrCaptureConfig { + orientation?: MLBcrCaptureConfig | null; + resultType?: MLBcrResultConfig | null; + recMode?: RecMode | null; +} +export declare enum RecMode { + WEAK_MODE = 0, + STRICT_MODE = 1 +} +export declare enum MLBcrCaptureConfig { + ERROR_CODE_INIT_CAMERA_FAILED = 10101, + RESULT_NUM_ONLY = 0, + ORIENTATION_AUTO = 0, + WEAK_MODE = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2, + RESULT_ALL = 2, + RESULT_SIMPLE = 1, + STRICT_MODE = 1 +} +export declare enum MLBcrResultConfig { + RESULT_NUM_ONLY = 0, + RESULT_SIMPLE = 1, + RESULT_ALL = 2 +} +export interface MLBcrCaptureResult { + errorCode?: MLBcrCaptureErrorCode | null; + expire?: String | null; + issuer?: String | null; + number?: String | null; + numberBitmap?: any; + organization?: String | null; + riginalBitmap?: any; + type?: String | null; +} +export declare enum MLBcrCaptureErrorCode { + ERROR_CODE_INIT_CAMERA_FAILED = 10101 +} +export interface documentImageAnalyserReq { + documentSetting?: DocumentSetting | null; + filePath: any; +} +export interface DocumentSetting { + borderType?: MLRemoteTextSetting | null; + languageList?: Array | null; + enableFingerprintVerification: boolean | null; +} +export declare enum MLRemoteTextSetting { + OCR_LOOSE_SCENE = 1, + OCR_COMPACT_SCENE = 2, + NGON = "NGON", + ARC = "ARC", + OTHER = 5, + NEW_LINE_CHARACTER = 8, + SPACE = 6 +} +export interface formRecognizerAnalyserReq { + filePath: any; + syncType: MLFormRecogitionConfig; +} +export declare enum MLFormRecogitionConfig { + SYNC_TYPE = 1, + ASYNC_TYPE = 0 +} +export interface generalCardDetectorReq { + gcrCaptureConfig?: gcrCaptureConfig; + gcrCaptureUIConfig?: gcrCaptureUIConfig; + captureType?: gcrCaptureType | null; +} +export interface gcrCaptureConfig { + language: string; +} +export declare enum gcrCaptureType { + CAPTURE_ACTIVITY = 0, + CAPTURE_PHOTO = 1, + CAPTURE_IMAGE = 2 +} +export interface gcrCaptureUIConfig { + orientation?: MLGcrCaptureUIConfig | null; + tipText?: string | null; + tipTextColor?: number | null; + photoButtonResId?: number | null; + scanBoxCornerColor?: number | null; + backButtonRedId?: number | null; + torchRedId?: number | null; +} +export interface gcrSettingResults { + gcrConfigLanguage: String; + torchOnResId: number; + tipTextColor: number; + tipText: String; + backButtonResId: number; + orientation: number; + photoButtonResId: number; + scanBoxScreenRatio: number; + scanBoxCornerColor: number; + scanBoxAspectRatio: number; +} +export declare enum MLGcrCaptureUIConfig { + ORIENTATION_AUTO = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2 +} +export interface icrVnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; +} +export interface icrCnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; + isFront?: boolean | null; +} +export declare enum icrCaptureType { + CAPTURE_CAMERA = 0, + CAPTURE_IMAGE = 1 +} +export interface createIdCardReq { + mlIcrAnalyzerSetting?: MLIcrAnalyzerSetting | null; +} +export interface localAnalyserReq { + settings: MLIcrAnalyzerSetting; + filePath?: any | null; +} +export interface MLIcrAnalyzerSetting { + countryCode: string; + hashCode?: number | null; + sideType?: MLIcrSideType | null; +} +export declare enum MLIcrSideType { + FRONT = "FRONT", + BACK = "BACK" +} +export interface imageSuperResolutionReq { + filePath: any; + imgSuperResolutionSetting?: ImgSuperResolutionSetting | null; + syncType?: MLFormRecogitionConfig | null; +} +export interface ImgSuperResolutionSetting { + scaleType?: ImgSuperResolutionConfig; +} +export declare enum ImgSuperResolutionConfig { + ISR_SCALE_1X = 1, + ISR_SCALE_3X = 3 +} +export interface productReq { + filePath?: any | null; + detectType?: number; + mlProductSetting?: mlProductSetting | null; +} +export interface mlProductSetting { + largestNumOfReturns?: number | null; + productSetId?: string | null; + region?: MLProductConfig | null; +} +export declare enum MLProductConfig { + REGION_DR_CHINA = 1002, + REGION_DR_AFILA = 1003, + REGION_DR_EUROPE = 1004, + REGION_DR_RUSSIA = 1005, + REGION_DR_GERMAN = 1006, + REGION_DR_SIANGAPORE = 1007 +} +export interface localImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + localTextSetting?: localTextSetting | null; + filePath: any; +} +export interface localTextSetting { + ocrMode?: MLLocalTextSetting; + language?: string; +} +export declare enum MLLocalTextSetting { + OCR_DETECT_MODE = 1, + OCR_TRACKING_MODE = 2 +} +export declare enum MLTextConfig { + OCR_LOCAL_TYPE = 0, + OCR_REMOTE_TYPE = 1 +} +export interface remoteImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + remoteTextSetting?: remoteTextSetting; + filePath: any; +} +export interface remoteTextSetting { + textDensityScene?: MLRemoteTextSetting; + languageList?: Array; + borderType?: MLRemoteTextSetting; +} +export interface MLBankCard { + number: string; + expire: string; + issuer: string; + type: string; + organization: string; + originalBitmap: any; + numberBitmap: any; +} +export interface Border { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} +export interface MLDocument { + stringValue: string; + blocks?: Blocks[]; +} +export interface LanguageList { + language: string; +} +export interface MLVnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; +} +export interface MLCnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + authority: string; + validDate: string; +} +export interface MLIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + validDate: string; +} +export interface MLGcrCaptureResult { + text: string; + cardBitmap: Bitmap; +} +export interface Rect { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} +export interface Bitmap { + mGalleryCached: boolean; + mHeight: number; + mNativePtr: number; + mWidth: number; +} +export interface MLText { + stringValue: string; + blocks?: Blocks[]; +} +export interface Blocks { + contents?: Contents[]; +} +export interface Contents { + stringValue: string; + border: Border; + language: string; + languageList?: LanguageList[]; + vertexes?: Vertexes[]; +} +export interface LanguageList { + language: string; +} +export interface Vertexes { + x: number; + y: number; + describeContents: number; +} +export interface MLFormRecogitionResult { + retCode: number; + tableContent: TableContent; +} +export interface TableContent { + tableCount: number; + tables?: TablesEntity[] | null; +} +export interface TablesEntity { + tableID: number; + headerInfo: string; + footerInfo: string; + tableBody?: TableBodyEntity[] | null; +} +export interface TableBodyEntity { + startRow: number; + endRow: number; + startCol: number; + endCol: number; + cellCoordinate: CellCoordinate; + textInfo: string; +} +export interface CellCoordinate { + topLeft_x: number; + topLeft_y: number; + topRight_x: number; + topRight_y: number; + bottomLeft_x: number; + bottomLeft_y: number; + bottomRight_x: number; + bottomRight_y: number; +} +export declare enum Colors { + RED = -65536, + DKGRAY = -12303292, + GRAY = -7829368, + WHITE = -1, + BLUE = -16776961, + BLACK = -16777216, + LTGRAY = -3355444, + MAGENTA = -65281, + YELLOW = -256, + CYAN = -16711681, + GREEN = -16711936, + TRANSPARENT = 0 +} +export declare enum CordovaErrors { + UNKNOWN = -1, + SUCCESS = 0, + DISCARDED = 1, + INNER = 2, + INACTIVE = 3, + NOT_SUPPORTED = 4, + ILLEGAL_PARAMETER = 5, + OVERDUE = 6, + NO_FOUND = 7, + DUPLICATE_FOUND = 8, + NO_PERMISSION = 9, + INSUFFICIENT_RESOURCE = 10, + ANALYSIS_FAILURE = 11, + INTERRUPTED = 12, + EXCEED_RANGE = 13, + DATA_MISSING = 14, + AUTHENTICATION_REQUIRED = 15, + TFLITE_NOT_COMPATIBLE = 16, + INSUFFICIENT_SPACE = 17, + HASH_MISS = 18, + TOKEN_INVALID = 19, + SERVICE_FAILURE = 20, + ANALYSIS_NULL = 21 +} +export declare enum Region { + REGION_DR_UNKNOWN = 1001, + REGION_DR_CHINA = 1002, + REGION_DR_RUSSIA = 1005, + REGION_DR_GERMAN = 1006, + REGION_DR_SINGAPORE = 1007 +} + +export declare const HMSMLTextPlugin: HMSMLTextPluginOriginal; +export declare const HMSMLText: HMSMLTextOriginal; \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/index.js b/cordova-plugin-hms-mltext/ionic-native/dist/index.js new file mode 100644 index 00000000..7c606c27 --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/index.js @@ -0,0 +1,489 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +import { IonicNativePlugin, cordova, cordovaPropertyGet, cordovaPropertySet } from "@ionic-native/core"; +var HMSMLTextPluginOriginal = /** @class */ (function (_super) { + __extends(HMSMLTextPluginOriginal, _super); + function HMSMLTextPluginOriginal() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Monitors photographing. + * @returns Promise + */ + HMSMLTextPluginOriginal.prototype.photograph = function () { return cordova(this, "photograph", { "otherPromise": true }, arguments); }; + /** + * Close lens engine. + * @returns Promise + */ + HMSMLTextPluginOriginal.prototype.destroy = function () { return cordova(this, "destroy", { "otherPromise": true }, arguments); }; + /** + * Obtains the size of the preview image of a camera. + * @returns Promise + */ + HMSMLTextPluginOriginal.prototype.getDisplayDimension = function () { return cordova(this, "getDisplayDimension", { "otherPromise": true }, arguments); }; + /** + * An app information class used to store basic information about apps with the HMS Core ML SDK integrated and complete the initialization of ML Text Kit. When using cloud services of the ML Text Kit, you need to set the apiKey of your app. + * @param {appSettingReq} appSettingReq Represents the parameter required. + * @returns Promise + */ + HMSMLTextPluginOriginal.prototype.appSetting = function (appSettingReq) { return cordova(this, "appSetting", { "otherPromise": true }, arguments); }; + /** + * Determines whether to collect statistics on the current app. + * @param {any} any + * @returns Promise + */ + HMSMLTextPluginOriginal.prototype.setStatistic = function (any) { return cordova(this, "setStatistic", { "otherPromise": true }, arguments); }; + /** + * Determines whether to collect statistics on the current app. + ** @param {any} any + * @returns Promise + */ + HMSMLTextPluginOriginal.prototype.getStatistic = function (any) { return cordova(this, "getStatistic", { "otherPromise": true }, arguments); }; + /** + * This service enable logger service. + * @returns Promise + */ + HMSMLTextPluginOriginal.prototype.enableLogger = function () { return cordova(this, "enableLogger", { "otherPromise": true }, arguments); }; + /** + * This service disable logger service. + * @returns Promise + */ + HMSMLTextPluginOriginal.prototype.disableLogger = function () { return cordova(this, "disableLogger", { "otherPromise": true }, arguments); }; + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "MLLocalTextSetting", { + get: function () { return cordovaPropertyGet(this, "MLLocalTextSetting"); }, + set: function (value) { cordovaPropertySet(this, "MLLocalTextSetting", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "icrVnCaptureType", { + get: function () { return cordovaPropertyGet(this, "icrVnCaptureType"); }, + set: function (value) { cordovaPropertySet(this, "icrVnCaptureType", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "MLTextConfig", { + get: function () { return cordovaPropertyGet(this, "MLTextConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLTextConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "MLRemoteTextSetting", { + get: function () { return cordovaPropertyGet(this, "MLRemoteTextSetting"); }, + set: function (value) { cordovaPropertySet(this, "MLRemoteTextSetting", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "MLBcrCaptureConfig", { + get: function () { return cordovaPropertyGet(this, "MLBcrCaptureConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLBcrCaptureConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "MLGcrCaptureUIConfig", { + get: function () { return cordovaPropertyGet(this, "MLGcrCaptureUIConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLGcrCaptureUIConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "MLBcrResultConfig", { + get: function () { return cordovaPropertyGet(this, "MLBcrResultConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLBcrResultConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "ImgSuperResolutionConfig", { + get: function () { return cordovaPropertyGet(this, "ImgSuperResolutionConfig"); }, + set: function (value) { cordovaPropertySet(this, "ImgSuperResolutionConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "MLFormRecogitionConfig", { + get: function () { return cordovaPropertyGet(this, "MLFormRecogitionConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLFormRecogitionConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "MLProductConfig", { + get: function () { return cordovaPropertyGet(this, "MLProductConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLProductConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "gcrCaptureType", { + get: function () { return cordovaPropertyGet(this, "gcrCaptureType"); }, + set: function (value) { cordovaPropertySet(this, "gcrCaptureType", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPluginOriginal.prototype, "Colors", { + get: function () { return cordovaPropertyGet(this, "Colors"); }, + set: function (value) { cordovaPropertySet(this, "Colors", value); }, + enumerable: false, + configurable: true + }); + HMSMLTextPluginOriginal.pluginName = "HMSMLTextPlugin"; + HMSMLTextPluginOriginal.plugin = "cordova-plugin-hms-mltext"; + HMSMLTextPluginOriginal.pluginRef = "HMSMLTextPlugin"; + HMSMLTextPluginOriginal.platforms = ["Android"]; + return HMSMLTextPluginOriginal; +}(IonicNativePlugin)); +var HMSMLTextPlugin = new HMSMLTextPluginOriginal(); +export { HMSMLTextPlugin }; +var HMSMLTextOriginal = /** @class */ (function (_super) { + __extends(HMSMLTextOriginal, _super); + function HMSMLTextOriginal() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * This method start the Text analyzer. + * @param {localImageTextReq|remoteImageTextReq} ImageTextAnalyserInput Reperesents the necessary parameters to convert images to text format. + * @returns Promise + */ + HMSMLTextOriginal.prototype.imageTextAnalyser = function (ImageTextAnalyserInput) { return cordova(this, "imageTextAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method stop the Text analyzer. + * @returns Promise + */ + HMSMLTextOriginal.prototype.stopTextAnalyser = function () { return cordova(this, "stopTextAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method gives Text Analyser information. + * @returns Promise + */ + HMSMLTextOriginal.prototype.getTextAnalyserInfo = function () { return cordova(this, "getTextAnalyserInfo", { "otherPromise": true }, arguments); }; + /** + * This method provides a document recognition component that recognizes text from images of documents. + * @param {documentImageAnalyserReq} documentImageAnalyserReq Reperesents the necessary parameter to convert document images to text format. + * @returns Promise + */ + HMSMLTextOriginal.prototype.documentImageAnalyser = function (documentImageAnalyserReq) { return cordova(this, "documentImageAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method stop the Document analyzer. + * @returns Promise + */ + HMSMLTextOriginal.prototype.stopDocumentImageAnalyser = function () { return cordova(this, "stopDocumentImageAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method close the Document analyzer. + * @returns Promise + */ + HMSMLTextOriginal.prototype.closeDocumentImageAnalyser = function () { return cordova(this, "closeDocumentImageAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method returns the Document analyzer setting. + * @returns Promise + */ + HMSMLTextOriginal.prototype.getDocumentImageAnalyserSetting = function () { return cordova(this, "getDocumentImageAnalyserSetting", { "otherPromise": true }, arguments); }; + /** + * This method returns the Image analyzer setting. + * @returns Promise + */ + HMSMLTextOriginal.prototype.getTextAnalyserSetting = function () { return cordova(this, "getTextAnalyserSetting", { "otherPromise": true }, arguments); }; + /** + * This method returns the GCR setting. + * @returns Promise + */ + HMSMLTextOriginal.prototype.getGCRSetting = function () { return cordova(this, "getGCRSetting", { "otherPromise": true }, arguments); }; + /** + * This method stop the Form Recognition Analyzer. + * @returns Promise + */ + HMSMLTextOriginal.prototype.stopFormRecognitionAnalyser = function () { return cordova(this, "stopFormRecognitionAnalyser", { "otherPromise": true }, arguments); }; + /** + * The bank card recognition service recognizes bank cards in camera streams within angle offset of 15 degrees and extracts key information such as card number and validity period. + * @param {bankCardSDKDetectorReq|bankCardPluginDetectorReq} bankCardDetecterInput Represents the parameter required for bank card recognition. + * @returns Promise | Promise + */ + HMSMLTextOriginal.prototype.bankCardDetector = function (bankCardDetecterInput) { + return; + }; + /** + * This method stop bankcard recognition service. + * @returns Promise + */ + HMSMLTextOriginal.prototype.stopBankCardDetector = function () { return cordova(this, "stopBankCardDetector", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.setResultTypeBcr = function (mLBcrCaptureConfig) { return cordova(this, "setResultTypeBcr", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.setRecModeBcr = function (mLBcrCaptureConfig) { return cordova(this, "setRecModeBcr", { "otherPromise": true }, arguments); }; + /** + * This method returns the BCR setting. + * @returns Promise + */ + HMSMLTextOriginal.prototype.getBankCardDetectorSetting = function () { return cordova(this, "getBankCardDetectorSetting", { "otherPromise": true }, arguments); }; + /** + * The general card recognition service provides a universal development framework based on the text recognition technology. + * @param {generalCardDetectorReq} generalCardDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + HMSMLTextOriginal.prototype.generalCardDetector = function (generalCardDetectorReq) { return cordova(this, "generalCardDetector", { "otherPromise": true }, arguments); }; + /** + * The general Vietnam id card recognition service provides a universal development framework based on the text recognition technology. + * @param {icrVnDetectorReq} icrVnDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + HMSMLTextOriginal.prototype.icrVnCardDetector = function (icrVnDetectorReq) { return cordova(this, "icrVnCardDetector", { "otherPromise": true }, arguments); }; + /** + * The form recognition service uses AI technologies to recognize and return form structure information (including rows, columns, and coordinates of cells) and form text in Chinese and English (including punctuation) from input images. + * @param {formRecognizerAnalyserReq} formRecognizerAnalyserReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + HMSMLTextOriginal.prototype.formRecognitionAnalyser = function (formRecognizerAnalyserReq) { return cordova(this, "formRecognitionAnalyser", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.icrLocalAnalyser = function (localAnalyserReq) { return cordova(this, "icrLocalAnalyser", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.icrLocalAnalyserCreateIdCard = function (createIdCardReq) { return cordova(this, "icrLocalAnalyserCreateIdCard", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.icrLocalAnalyserStop = function () { return cordova(this, "icrLocalAnalyserStop", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.geticrCnCardInstance = function () { return cordova(this, "geticrCnCardInstance", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.icrCnCardCreate = function () { return cordova(this, "icrCnCardCreate", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.geticrVnCardInstance = function () { return cordova(this, "geticrVnCardInstance", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.icrVnCardCreate = function () { return cordova(this, "icrVnCardCreate", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.getIcrVnCapture = function () { return cordova(this, "getIcrVnCapture", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.startCustomizedView = function (userProps) { return cordova(this, "startCustomizedView", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.switchLight = function () { return cordova(this, "switchLight", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.getLightStatus = function () { return cordova(this, "getLightStatus", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.setUserRegion = function (region) { return cordova(this, "setUserRegion", { "otherPromise": true }, arguments); }; + HMSMLTextOriginal.prototype.getCountryCode = function () { return cordova(this, "getCountryCode", { "otherPromise": true }, arguments); }; + Object.defineProperty(HMSMLTextOriginal.prototype, "icrVnCaptureType", { + get: function () { return cordovaPropertyGet(this, "icrVnCaptureType"); }, + set: function (value) { cordovaPropertySet(this, "icrVnCaptureType", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "gcrCaptureType", { + get: function () { return cordovaPropertyGet(this, "gcrCaptureType"); }, + set: function (value) { cordovaPropertySet(this, "gcrCaptureType", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "MLLocalTextSetting", { + get: function () { return cordovaPropertyGet(this, "MLLocalTextSetting"); }, + set: function (value) { cordovaPropertySet(this, "MLLocalTextSetting", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "MLTextConfig", { + get: function () { return cordovaPropertyGet(this, "MLTextConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLTextConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "MLRemoteTextSetting", { + get: function () { return cordovaPropertyGet(this, "MLRemoteTextSetting"); }, + set: function (value) { cordovaPropertySet(this, "MLRemoteTextSetting", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "MLBcrCaptureConfig", { + get: function () { return cordovaPropertyGet(this, "MLBcrCaptureConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLBcrCaptureConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "MLGcrCaptureUIConfig", { + get: function () { return cordovaPropertyGet(this, "MLGcrCaptureUIConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLGcrCaptureUIConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "MLBcrResultConfig", { + get: function () { return cordovaPropertyGet(this, "MLBcrResultConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLBcrResultConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "ImgSuperResolutionConfig", { + get: function () { return cordovaPropertyGet(this, "ImgSuperResolutionConfig"); }, + set: function (value) { cordovaPropertySet(this, "ImgSuperResolutionConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "MLFormRecogitionConfig", { + get: function () { return cordovaPropertyGet(this, "MLFormRecogitionConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLFormRecogitionConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "MLProductConfig", { + get: function () { return cordovaPropertyGet(this, "MLProductConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLProductConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "Colors", { + get: function () { return cordovaPropertyGet(this, "Colors"); }, + set: function (value) { cordovaPropertySet(this, "Colors", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextOriginal.prototype, "RecMode", { + get: function () { return cordovaPropertyGet(this, "RecMode"); }, + set: function (value) { cordovaPropertySet(this, "RecMode", value); }, + enumerable: false, + configurable: true + }); + HMSMLTextOriginal.pluginName = "HMSMLText"; + HMSMLTextOriginal.plugin = "cordova-plugin-hms-mltext"; + HMSMLTextOriginal.pluginRef = "HMSMLText"; + HMSMLTextOriginal.platforms = ["Android"]; + return HMSMLTextOriginal; +}(IonicNativePlugin)); +var HMSMLText = new HMSMLTextOriginal(); +export { HMSMLText }; +export var RecMode; +(function (RecMode) { + RecMode[RecMode["WEAK_MODE"] = 0] = "WEAK_MODE"; + RecMode[RecMode["STRICT_MODE"] = 1] = "STRICT_MODE"; +})(RecMode || (RecMode = {})); +export var MLBcrCaptureConfig; +(function (MLBcrCaptureConfig) { + MLBcrCaptureConfig[MLBcrCaptureConfig["ERROR_CODE_INIT_CAMERA_FAILED"] = 10101] = "ERROR_CODE_INIT_CAMERA_FAILED"; + MLBcrCaptureConfig[MLBcrCaptureConfig["RESULT_NUM_ONLY"] = 0] = "RESULT_NUM_ONLY"; + MLBcrCaptureConfig[MLBcrCaptureConfig["ORIENTATION_AUTO"] = 0] = "ORIENTATION_AUTO"; + MLBcrCaptureConfig[MLBcrCaptureConfig["WEAK_MODE"] = 0] = "WEAK_MODE"; + MLBcrCaptureConfig[MLBcrCaptureConfig["ORIENTATION_LANDSCAPE"] = 1] = "ORIENTATION_LANDSCAPE"; + MLBcrCaptureConfig[MLBcrCaptureConfig["ORIENTATION_PORTRAIT"] = 2] = "ORIENTATION_PORTRAIT"; + MLBcrCaptureConfig[MLBcrCaptureConfig["RESULT_ALL"] = 2] = "RESULT_ALL"; + MLBcrCaptureConfig[MLBcrCaptureConfig["RESULT_SIMPLE"] = 1] = "RESULT_SIMPLE"; + MLBcrCaptureConfig[MLBcrCaptureConfig["STRICT_MODE"] = 1] = "STRICT_MODE"; +})(MLBcrCaptureConfig || (MLBcrCaptureConfig = {})); +export var MLBcrResultConfig; +(function (MLBcrResultConfig) { + MLBcrResultConfig[MLBcrResultConfig["RESULT_NUM_ONLY"] = 0] = "RESULT_NUM_ONLY"; + MLBcrResultConfig[MLBcrResultConfig["RESULT_SIMPLE"] = 1] = "RESULT_SIMPLE"; + MLBcrResultConfig[MLBcrResultConfig["RESULT_ALL"] = 2] = "RESULT_ALL"; +})(MLBcrResultConfig || (MLBcrResultConfig = {})); +export var MLBcrCaptureErrorCode; +(function (MLBcrCaptureErrorCode) { + MLBcrCaptureErrorCode[MLBcrCaptureErrorCode["ERROR_CODE_INIT_CAMERA_FAILED"] = 10101] = "ERROR_CODE_INIT_CAMERA_FAILED"; +})(MLBcrCaptureErrorCode || (MLBcrCaptureErrorCode = {})); +export var MLRemoteTextSetting; +(function (MLRemoteTextSetting) { + MLRemoteTextSetting[MLRemoteTextSetting["OCR_LOOSE_SCENE"] = 1] = "OCR_LOOSE_SCENE"; + MLRemoteTextSetting[MLRemoteTextSetting["OCR_COMPACT_SCENE"] = 2] = "OCR_COMPACT_SCENE"; + MLRemoteTextSetting["NGON"] = "NGON"; + MLRemoteTextSetting["ARC"] = "ARC"; + MLRemoteTextSetting[MLRemoteTextSetting["OTHER"] = 5] = "OTHER"; + MLRemoteTextSetting[MLRemoteTextSetting["NEW_LINE_CHARACTER"] = 8] = "NEW_LINE_CHARACTER"; + MLRemoteTextSetting[MLRemoteTextSetting["SPACE"] = 6] = "SPACE"; +})(MLRemoteTextSetting || (MLRemoteTextSetting = {})); +export var MLFormRecogitionConfig; +(function (MLFormRecogitionConfig) { + MLFormRecogitionConfig[MLFormRecogitionConfig["SYNC_TYPE"] = 1] = "SYNC_TYPE"; + MLFormRecogitionConfig[MLFormRecogitionConfig["ASYNC_TYPE"] = 0] = "ASYNC_TYPE"; +})(MLFormRecogitionConfig || (MLFormRecogitionConfig = {})); +export var gcrCaptureType; +(function (gcrCaptureType) { + gcrCaptureType[gcrCaptureType["CAPTURE_ACTIVITY"] = 0] = "CAPTURE_ACTIVITY"; + gcrCaptureType[gcrCaptureType["CAPTURE_PHOTO"] = 1] = "CAPTURE_PHOTO"; + gcrCaptureType[gcrCaptureType["CAPTURE_IMAGE"] = 2] = "CAPTURE_IMAGE"; +})(gcrCaptureType || (gcrCaptureType = {})); +export var MLGcrCaptureUIConfig; +(function (MLGcrCaptureUIConfig) { + MLGcrCaptureUIConfig[MLGcrCaptureUIConfig["ORIENTATION_AUTO"] = 0] = "ORIENTATION_AUTO"; + MLGcrCaptureUIConfig[MLGcrCaptureUIConfig["ORIENTATION_LANDSCAPE"] = 1] = "ORIENTATION_LANDSCAPE"; + MLGcrCaptureUIConfig[MLGcrCaptureUIConfig["ORIENTATION_PORTRAIT"] = 2] = "ORIENTATION_PORTRAIT"; +})(MLGcrCaptureUIConfig || (MLGcrCaptureUIConfig = {})); +export var icrCaptureType; +(function (icrCaptureType) { + icrCaptureType[icrCaptureType["CAPTURE_CAMERA"] = 0] = "CAPTURE_CAMERA"; + icrCaptureType[icrCaptureType["CAPTURE_IMAGE"] = 1] = "CAPTURE_IMAGE"; +})(icrCaptureType || (icrCaptureType = {})); +export var MLIcrSideType; +(function (MLIcrSideType) { + MLIcrSideType["FRONT"] = "FRONT"; + MLIcrSideType["BACK"] = "BACK"; +})(MLIcrSideType || (MLIcrSideType = {})); +export var ImgSuperResolutionConfig; +(function (ImgSuperResolutionConfig) { + ImgSuperResolutionConfig[ImgSuperResolutionConfig["ISR_SCALE_1X"] = 1] = "ISR_SCALE_1X"; + ImgSuperResolutionConfig[ImgSuperResolutionConfig["ISR_SCALE_3X"] = 3] = "ISR_SCALE_3X"; +})(ImgSuperResolutionConfig || (ImgSuperResolutionConfig = {})); +export var MLProductConfig; +(function (MLProductConfig) { + MLProductConfig[MLProductConfig["REGION_DR_CHINA"] = 1002] = "REGION_DR_CHINA"; + MLProductConfig[MLProductConfig["REGION_DR_AFILA"] = 1003] = "REGION_DR_AFILA"; + MLProductConfig[MLProductConfig["REGION_DR_EUROPE"] = 1004] = "REGION_DR_EUROPE"; + MLProductConfig[MLProductConfig["REGION_DR_RUSSIA"] = 1005] = "REGION_DR_RUSSIA"; + MLProductConfig[MLProductConfig["REGION_DR_GERMAN"] = 1006] = "REGION_DR_GERMAN"; + MLProductConfig[MLProductConfig["REGION_DR_SIANGAPORE"] = 1007] = "REGION_DR_SIANGAPORE"; +})(MLProductConfig || (MLProductConfig = {})); +export var MLLocalTextSetting; +(function (MLLocalTextSetting) { + MLLocalTextSetting[MLLocalTextSetting["OCR_DETECT_MODE"] = 1] = "OCR_DETECT_MODE"; + MLLocalTextSetting[MLLocalTextSetting["OCR_TRACKING_MODE"] = 2] = "OCR_TRACKING_MODE"; +})(MLLocalTextSetting || (MLLocalTextSetting = {})); +export var MLTextConfig; +(function (MLTextConfig) { + MLTextConfig[MLTextConfig["OCR_LOCAL_TYPE"] = 0] = "OCR_LOCAL_TYPE"; + MLTextConfig[MLTextConfig["OCR_REMOTE_TYPE"] = 1] = "OCR_REMOTE_TYPE"; +})(MLTextConfig || (MLTextConfig = {})); +export var Colors; +(function (Colors) { + Colors[Colors["RED"] = -65536] = "RED"; + Colors[Colors["DKGRAY"] = -12303292] = "DKGRAY"; + Colors[Colors["GRAY"] = -7829368] = "GRAY"; + Colors[Colors["WHITE"] = -1] = "WHITE"; + Colors[Colors["BLUE"] = -16776961] = "BLUE"; + Colors[Colors["BLACK"] = -16777216] = "BLACK"; + Colors[Colors["LTGRAY"] = -3355444] = "LTGRAY"; + Colors[Colors["MAGENTA"] = -65281] = "MAGENTA"; + Colors[Colors["YELLOW"] = -256] = "YELLOW"; + Colors[Colors["CYAN"] = -16711681] = "CYAN"; + Colors[Colors["GREEN"] = -16711936] = "GREEN"; + Colors[Colors["TRANSPARENT"] = 0] = "TRANSPARENT"; +})(Colors || (Colors = {})); +export var CordovaErrors; +(function (CordovaErrors) { + CordovaErrors[CordovaErrors["UNKNOWN"] = -1] = "UNKNOWN"; + CordovaErrors[CordovaErrors["SUCCESS"] = 0] = "SUCCESS"; + CordovaErrors[CordovaErrors["DISCARDED"] = 1] = "DISCARDED"; + CordovaErrors[CordovaErrors["INNER"] = 2] = "INNER"; + CordovaErrors[CordovaErrors["INACTIVE"] = 3] = "INACTIVE"; + CordovaErrors[CordovaErrors["NOT_SUPPORTED"] = 4] = "NOT_SUPPORTED"; + CordovaErrors[CordovaErrors["ILLEGAL_PARAMETER"] = 5] = "ILLEGAL_PARAMETER"; + CordovaErrors[CordovaErrors["OVERDUE"] = 6] = "OVERDUE"; + CordovaErrors[CordovaErrors["NO_FOUND"] = 7] = "NO_FOUND"; + CordovaErrors[CordovaErrors["DUPLICATE_FOUND"] = 8] = "DUPLICATE_FOUND"; + CordovaErrors[CordovaErrors["NO_PERMISSION"] = 9] = "NO_PERMISSION"; + CordovaErrors[CordovaErrors["INSUFFICIENT_RESOURCE"] = 10] = "INSUFFICIENT_RESOURCE"; + CordovaErrors[CordovaErrors["ANALYSIS_FAILURE"] = 11] = "ANALYSIS_FAILURE"; + CordovaErrors[CordovaErrors["INTERRUPTED"] = 12] = "INTERRUPTED"; + CordovaErrors[CordovaErrors["EXCEED_RANGE"] = 13] = "EXCEED_RANGE"; + CordovaErrors[CordovaErrors["DATA_MISSING"] = 14] = "DATA_MISSING"; + CordovaErrors[CordovaErrors["AUTHENTICATION_REQUIRED"] = 15] = "AUTHENTICATION_REQUIRED"; + CordovaErrors[CordovaErrors["TFLITE_NOT_COMPATIBLE"] = 16] = "TFLITE_NOT_COMPATIBLE"; + CordovaErrors[CordovaErrors["INSUFFICIENT_SPACE"] = 17] = "INSUFFICIENT_SPACE"; + CordovaErrors[CordovaErrors["HASH_MISS"] = 18] = "HASH_MISS"; + CordovaErrors[CordovaErrors["TOKEN_INVALID"] = 19] = "TOKEN_INVALID"; + CordovaErrors[CordovaErrors["SERVICE_FAILURE"] = 20] = "SERVICE_FAILURE"; + CordovaErrors[CordovaErrors["ANALYSIS_NULL"] = 21] = "ANALYSIS_NULL"; +})(CordovaErrors || (CordovaErrors = {})); +export var Region; +(function (Region) { + Region[Region["REGION_DR_UNKNOWN"] = 1001] = "REGION_DR_UNKNOWN"; + Region[Region["REGION_DR_CHINA"] = 1002] = "REGION_DR_CHINA"; + Region[Region["REGION_DR_RUSSIA"] = 1005] = "REGION_DR_RUSSIA"; + Region[Region["REGION_DR_GERMAN"] = 1006] = "REGION_DR_GERMAN"; + Region[Region["REGION_DR_SINGAPORE"] = 1007] = "REGION_DR_SINGAPORE"; +})(Region || (Region = {})); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvQGlvbmljLW5hdGl2ZS9wbHVnaW5zL25hdGl2ZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7O0FBaUJBLE9BQU8sc0VBS04sTUFBTSxvQkFBb0IsQ0FBQzs7SUFTUyxtQ0FBaUI7Ozs7S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m9taXNlOiB0cnVlIH0pXG4gICAgLyoqXG4gICAgICogVGhpcyBtZXRob2QgY2xvc2UgdGhlIERvY3VtZW50IGFuYWx5emVyLlxuICAgICAqIEByZXR1cm5zIFByb21pc2U8YW55PlxuICAgICAqL1xuICAgIGNsb3NlRG9jdW1lbnRJbWFnZUFuYWx5c2VyKCk6IFByb21pc2U8YW55PiB7XG4gICAgICAgIHJldHVybjtcbiAgICB9XG4gICAgQENvcmRvdmEoeyBvdGhlclByb21pc2U6IHRydWUgfSlcbiAgICAvKipcbiAgICAgKiBUaGlzIG1ldGhvZCByZXR1cm5zIHRoZSBEb2N1bWVudCBhbmFseXplciBzZXR0aW5nLlxuICAgICAqIEByZXR1cm5zIFByb21pc2U8YW55PlxuICAgICAqL1xuICAgIGdldERvY3VtZW50SW1hZ2VBbmFseXNlclNldHRpbmcoKTogUHJvbWlzZTxhbnk+IHtcbiAgICAgICAgcmV0dXJuO1xuICAgIH1cbiAgICBAQ29yZG92YSh7IG90aGVyUHJvbWlzZTogdHJ1ZSB9KVxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgdGhlIEltYWdlIGFuYWx5emVyIHNldHRpbmcuXG4gICAgICogQHJldHVybnMgUHJvbWlzZTxhbnk+XG4gICAgICovXG4gICAgZ2V0VGV4dEFuYWx5c2VyU2V0dGluZygpOiBQcm9taXNlPGFueT4ge1xuICAgICAgICByZXR1cm47XG4gICAgfVxuICAgIEBDb3Jkb3ZhKHsgb3RoZXJQcm9taXNlOiB0cnVlIH0pXG4gICAgLyoqXG4gICAgICogVGhpcyBtZXRob2QgcmV0dXJucyB0aGUgR0NSIHNldHRpbmcuXG4gICAgICogQHJldHVybnMgUHJvbWlzZTxhbnk+XG4gICAgICovXG4gICAgZ2V0R0NSU2V0dGluZygpOiBQcm9taXNlPGdjclNldHRpbmdSZXN1bHRzPiB7XG4gICAgICAgIHJldHVybjtcbiAgICB9XG4gICAgQENvcmRvdmEoeyBvdGhlclByb21pc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VHSU9OX0RSX0NISU5BID0gMTAwMixcblJFR0lPTl9EUl9SVVNTSUEgPSAxMDA1LFxuUkVHSU9OX0RSX0dFUk1BTiA9IDEwMDYsXG5SRUdJT05fRFJfU0lOR0FQT1JFID0gMTAwN1xufVxuIl19 \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/ngx/LICENSE b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/LICENSE new file mode 100644 index 00000000..490b5c70 --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/LICENSE @@ -0,0 +1,53 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and +You must cause any modified files to carry prominent notices stating that You changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/ngx/index.d.ts b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/index.d.ts new file mode 100644 index 00000000..be1cfd9d --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/index.d.ts @@ -0,0 +1,588 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { IonicNativePlugin } from "@ionic-native/core"; +export declare class HMSMLTextPlugin extends IonicNativePlugin { + MLLocalTextSetting: typeof MLLocalTextSetting; + icrVnCaptureType: typeof icrCaptureType; + MLTextConfig: typeof MLTextConfig; + MLRemoteTextSetting: typeof MLRemoteTextSetting; + MLBcrCaptureConfig: typeof MLBcrCaptureConfig; + MLGcrCaptureUIConfig: typeof MLGcrCaptureUIConfig; + MLBcrResultConfig: typeof MLBcrResultConfig; + ImgSuperResolutionConfig: typeof ImgSuperResolutionConfig; + MLFormRecogitionConfig: typeof MLFormRecogitionConfig; + MLProductConfig: typeof MLProductConfig; + gcrCaptureType: typeof gcrCaptureType; + Colors: typeof Colors; + /** + * Monitors photographing. + * @returns Promise + */ + photograph(): Promise; + /** + * Close lens engine. + * @returns Promise + */ + destroy(): Promise; + /** + * Obtains the size of the preview image of a camera. + * @returns Promise + */ + getDisplayDimension(): Promise; + /** + * An app information class used to store basic information about apps with the HMS Core ML SDK integrated and complete the initialization of ML Text Kit. When using cloud services of the ML Text Kit, you need to set the apiKey of your app. + * @param {appSettingReq} appSettingReq Represents the parameter required. + * @returns Promise + */ + appSetting(appSettingReq: appSettingReq): Promise; + /** + * Determines whether to collect statistics on the current app. + * @param {any} any + * @returns Promise + */ + setStatistic(any: any): Promise; + /** + * Determines whether to collect statistics on the current app. + ** @param {any} any + * @returns Promise + */ + getStatistic(any: any): Promise; + /** + * This service enable logger service. + * @returns Promise + */ + enableLogger(): Promise; + /** + * This service disable logger service. + * @returns Promise + */ + disableLogger(): Promise; +} +export declare class HMSMLText extends IonicNativePlugin { + icrVnCaptureType: typeof icrCaptureType; + gcrCaptureType: typeof gcrCaptureType; + MLLocalTextSetting: typeof MLLocalTextSetting; + MLTextConfig: typeof MLTextConfig; + MLRemoteTextSetting: typeof MLRemoteTextSetting; + MLBcrCaptureConfig: typeof MLBcrCaptureConfig; + MLGcrCaptureUIConfig: typeof MLGcrCaptureUIConfig; + MLBcrResultConfig: typeof MLBcrResultConfig; + ImgSuperResolutionConfig: typeof ImgSuperResolutionConfig; + MLFormRecogitionConfig: typeof MLFormRecogitionConfig; + MLProductConfig: typeof MLProductConfig; + Colors: typeof Colors; + RecMode: typeof RecMode; + /** + * This method start the Text analyzer. + * @param {localImageTextReq|remoteImageTextReq} ImageTextAnalyserInput Reperesents the necessary parameters to convert images to text format. + * @returns Promise + */ + imageTextAnalyser(ImageTextAnalyserInput: localImageTextReq | remoteImageTextReq): Promise; + /** + * This method stop the Text analyzer. + * @returns Promise + */ + stopTextAnalyser(): Promise; + /** + * This method gives Text Analyser information. + * @returns Promise + */ + getTextAnalyserInfo(): Promise; + /** + * This method provides a document recognition component that recognizes text from images of documents. + * @param {documentImageAnalyserReq} documentImageAnalyserReq Reperesents the necessary parameter to convert document images to text format. + * @returns Promise + */ + documentImageAnalyser(documentImageAnalyserReq: documentImageAnalyserReq): Promise; + /** + * This method stop the Document analyzer. + * @returns Promise + */ + stopDocumentImageAnalyser(): Promise; + /** + * This method close the Document analyzer. + * @returns Promise + */ + closeDocumentImageAnalyser(): Promise; + /** + * This method returns the Document analyzer setting. + * @returns Promise + */ + getDocumentImageAnalyserSetting(): Promise; + /** + * This method returns the Image analyzer setting. + * @returns Promise + */ + getTextAnalyserSetting(): Promise; + /** + * This method returns the GCR setting. + * @returns Promise + */ + getGCRSetting(): Promise; + /** + * This method stop the Form Recognition Analyzer. + * @returns Promise + */ + stopFormRecognitionAnalyser(): Promise; + /** + * The bank card recognition service recognizes bank cards in camera streams within angle offset of 15 degrees and extracts key information such as card number and validity period. + * @param {bankCardSDKDetectorReq|bankCardPluginDetectorReq} bankCardDetecterInput Represents the parameter required for bank card recognition. + * @returns Promise | Promise + */ + bankCardDetector(bankCardDetecterInput: bankCardSDKDetectorReq | bankCardPluginDetectorReq): Promise; + /** + * This method stop bankcard recognition service. + * @returns Promise + */ + stopBankCardDetector(): Promise; + setResultTypeBcr(mLBcrCaptureConfig: mLBcrCaptureConfig): Promise; + setRecModeBcr(mLBcrCaptureConfig: mLBcrCaptureConfig): Promise; + /** + * This method returns the BCR setting. + * @returns Promise + */ + getBankCardDetectorSetting(): Promise; + /** + * The general card recognition service provides a universal development framework based on the text recognition technology. + * @param {generalCardDetectorReq} generalCardDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + generalCardDetector(generalCardDetectorReq: generalCardDetectorReq): Promise; + /** + * The general Vietnam id card recognition service provides a universal development framework based on the text recognition technology. + * @param {icrVnDetectorReq} icrVnDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + icrVnCardDetector(icrVnDetectorReq: icrVnDetectorReq): Promise; + /** + * The form recognition service uses AI technologies to recognize and return form structure information (including rows, columns, and coordinates of cells) and form text in Chinese and English (including punctuation) from input images. + * @param {formRecognizerAnalyserReq} formRecognizerAnalyserReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + formRecognitionAnalyser(formRecognizerAnalyserReq: formRecognizerAnalyserReq): Promise; + icrLocalAnalyser(localAnalyserReq: localAnalyserReq): Promise; + icrLocalAnalyserCreateIdCard(createIdCardReq: createIdCardReq): Promise; + icrLocalAnalyserStop(): Promise; + geticrCnCardInstance(): Promise; + icrCnCardCreate(): Promise; + geticrVnCardInstance(): Promise; + icrVnCardCreate(): Promise; + getIcrVnCapture(): Promise; + startCustomizedView(userProps: CustomViewModeRequest): Promise; + switchLight(): Promise; + getLightStatus(): Promise; + setUserRegion(region: Region): Promise; + getCountryCode(): Promise; +} +export interface CustomViewModeRequest { + isTitleAvailable: boolean; + title: string; + heightFactor: number; + widthFactor: number; + isFlashAvailable: boolean; + resultType: MLBcrResultConfig; + recMode: RecMode; +} +export interface configReq { + apiKey: string; +} +export interface appSettingReq { + apiKey?: string | null; + applicationId?: string | null; + certFingerprint?: string | null; +} +export interface bankCardSDKDetectorReq { + filePath: any; + detectType: 0; + mLBcrAnalyzerSetting?: MLBcrAnalyzerSetting | null; +} +export interface MLBcrAnalyzerSetting { + langType?: string | null; + resultType?: MLBcrResultConfig | null; +} +export interface bankCardPluginDetectorReq { + detectType: 1; + mLBcrCaptureConfig?: mLBcrCaptureConfig | null; +} +export interface mLBcrCaptureConfig { + orientation?: MLBcrCaptureConfig | null; + resultType?: MLBcrResultConfig | null; + recMode?: RecMode | null; +} +export declare enum RecMode { + WEAK_MODE = 0, + STRICT_MODE = 1 +} +export declare enum MLBcrCaptureConfig { + ERROR_CODE_INIT_CAMERA_FAILED = 10101, + RESULT_NUM_ONLY = 0, + ORIENTATION_AUTO = 0, + WEAK_MODE = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2, + RESULT_ALL = 2, + RESULT_SIMPLE = 1, + STRICT_MODE = 1 +} +export declare enum MLBcrResultConfig { + RESULT_NUM_ONLY = 0, + RESULT_SIMPLE = 1, + RESULT_ALL = 2 +} +export interface MLBcrCaptureResult { + errorCode?: MLBcrCaptureErrorCode | null; + expire?: String | null; + issuer?: String | null; + number?: String | null; + numberBitmap?: any; + organization?: String | null; + riginalBitmap?: any; + type?: String | null; +} +export declare enum MLBcrCaptureErrorCode { + ERROR_CODE_INIT_CAMERA_FAILED = 10101 +} +export interface documentImageAnalyserReq { + documentSetting?: DocumentSetting | null; + filePath: any; +} +export interface DocumentSetting { + borderType?: MLRemoteTextSetting | null; + languageList?: Array | null; + enableFingerprintVerification: boolean | null; +} +export declare enum MLRemoteTextSetting { + OCR_LOOSE_SCENE = 1, + OCR_COMPACT_SCENE = 2, + NGON = "NGON", + ARC = "ARC", + OTHER = 5, + NEW_LINE_CHARACTER = 8, + SPACE = 6 +} +export interface formRecognizerAnalyserReq { + filePath: any; + syncType: MLFormRecogitionConfig; +} +export declare enum MLFormRecogitionConfig { + SYNC_TYPE = 1, + ASYNC_TYPE = 0 +} +export interface generalCardDetectorReq { + gcrCaptureConfig?: gcrCaptureConfig; + gcrCaptureUIConfig?: gcrCaptureUIConfig; + captureType?: gcrCaptureType | null; +} +export interface gcrCaptureConfig { + language: string; +} +export declare enum gcrCaptureType { + CAPTURE_ACTIVITY = 0, + CAPTURE_PHOTO = 1, + CAPTURE_IMAGE = 2 +} +export interface gcrCaptureUIConfig { + orientation?: MLGcrCaptureUIConfig | null; + tipText?: string | null; + tipTextColor?: number | null; + photoButtonResId?: number | null; + scanBoxCornerColor?: number | null; + backButtonRedId?: number | null; + torchRedId?: number | null; +} +export interface gcrSettingResults { + gcrConfigLanguage: String; + torchOnResId: number; + tipTextColor: number; + tipText: String; + backButtonResId: number; + orientation: number; + photoButtonResId: number; + scanBoxScreenRatio: number; + scanBoxCornerColor: number; + scanBoxAspectRatio: number; +} +export declare enum MLGcrCaptureUIConfig { + ORIENTATION_AUTO = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2 +} +export interface icrVnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; +} +export interface icrCnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; + isFront?: boolean | null; +} +export declare enum icrCaptureType { + CAPTURE_CAMERA = 0, + CAPTURE_IMAGE = 1 +} +export interface createIdCardReq { + mlIcrAnalyzerSetting?: MLIcrAnalyzerSetting | null; +} +export interface localAnalyserReq { + settings: MLIcrAnalyzerSetting; + filePath?: any | null; +} +export interface MLIcrAnalyzerSetting { + countryCode: string; + hashCode?: number | null; + sideType?: MLIcrSideType | null; +} +export declare enum MLIcrSideType { + FRONT = "FRONT", + BACK = "BACK" +} +export interface imageSuperResolutionReq { + filePath: any; + imgSuperResolutionSetting?: ImgSuperResolutionSetting | null; + syncType?: MLFormRecogitionConfig | null; +} +export interface ImgSuperResolutionSetting { + scaleType?: ImgSuperResolutionConfig; +} +export declare enum ImgSuperResolutionConfig { + ISR_SCALE_1X = 1, + ISR_SCALE_3X = 3 +} +export interface productReq { + filePath?: any | null; + detectType?: number; + mlProductSetting?: mlProductSetting | null; +} +export interface mlProductSetting { + largestNumOfReturns?: number | null; + productSetId?: string | null; + region?: MLProductConfig | null; +} +export declare enum MLProductConfig { + REGION_DR_CHINA = 1002, + REGION_DR_AFILA = 1003, + REGION_DR_EUROPE = 1004, + REGION_DR_RUSSIA = 1005, + REGION_DR_GERMAN = 1006, + REGION_DR_SIANGAPORE = 1007 +} +export interface localImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + localTextSetting?: localTextSetting | null; + filePath: any; +} +export interface localTextSetting { + ocrMode?: MLLocalTextSetting; + language?: string; +} +export declare enum MLLocalTextSetting { + OCR_DETECT_MODE = 1, + OCR_TRACKING_MODE = 2 +} +export declare enum MLTextConfig { + OCR_LOCAL_TYPE = 0, + OCR_REMOTE_TYPE = 1 +} +export interface remoteImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + remoteTextSetting?: remoteTextSetting; + filePath: any; +} +export interface remoteTextSetting { + textDensityScene?: MLRemoteTextSetting; + languageList?: Array; + borderType?: MLRemoteTextSetting; +} +export interface MLBankCard { + number: string; + expire: string; + issuer: string; + type: string; + organization: string; + originalBitmap: any; + numberBitmap: any; +} +export interface Border { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} +export interface MLDocument { + stringValue: string; + blocks?: Blocks[]; +} +export interface LanguageList { + language: string; +} +export interface MLVnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; +} +export interface MLCnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + authority: string; + validDate: string; +} +export interface MLIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + validDate: string; +} +export interface MLGcrCaptureResult { + text: string; + cardBitmap: Bitmap; +} +export interface Rect { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} +export interface Bitmap { + mGalleryCached: boolean; + mHeight: number; + mNativePtr: number; + mWidth: number; +} +export interface MLText { + stringValue: string; + blocks?: Blocks[]; +} +export interface Blocks { + contents?: Contents[]; +} +export interface Contents { + stringValue: string; + border: Border; + language: string; + languageList?: LanguageList[]; + vertexes?: Vertexes[]; +} +export interface LanguageList { + language: string; +} +export interface Vertexes { + x: number; + y: number; + describeContents: number; +} +export interface MLFormRecogitionResult { + retCode: number; + tableContent: TableContent; +} +export interface TableContent { + tableCount: number; + tables?: TablesEntity[] | null; +} +export interface TablesEntity { + tableID: number; + headerInfo: string; + footerInfo: string; + tableBody?: TableBodyEntity[] | null; +} +export interface TableBodyEntity { + startRow: number; + endRow: number; + startCol: number; + endCol: number; + cellCoordinate: CellCoordinate; + textInfo: string; +} +export interface CellCoordinate { + topLeft_x: number; + topLeft_y: number; + topRight_x: number; + topRight_y: number; + bottomLeft_x: number; + bottomLeft_y: number; + bottomRight_x: number; + bottomRight_y: number; +} +export declare enum Colors { + RED = -65536, + DKGRAY = -12303292, + GRAY = -7829368, + WHITE = -1, + BLUE = -16776961, + BLACK = -16777216, + LTGRAY = -3355444, + MAGENTA = -65281, + YELLOW = -256, + CYAN = -16711681, + GREEN = -16711936, + TRANSPARENT = 0 +} +export declare enum CordovaErrors { + UNKNOWN = -1, + SUCCESS = 0, + DISCARDED = 1, + INNER = 2, + INACTIVE = 3, + NOT_SUPPORTED = 4, + ILLEGAL_PARAMETER = 5, + OVERDUE = 6, + NO_FOUND = 7, + DUPLICATE_FOUND = 8, + NO_PERMISSION = 9, + INSUFFICIENT_RESOURCE = 10, + ANALYSIS_FAILURE = 11, + INTERRUPTED = 12, + EXCEED_RANGE = 13, + DATA_MISSING = 14, + AUTHENTICATION_REQUIRED = 15, + TFLITE_NOT_COMPATIBLE = 16, + INSUFFICIENT_SPACE = 17, + HASH_MISS = 18, + TOKEN_INVALID = 19, + SERVICE_FAILURE = 20, + ANALYSIS_NULL = 21 +} +export declare enum Region { + REGION_DR_UNKNOWN = 1001, + REGION_DR_CHINA = 1002, + REGION_DR_RUSSIA = 1005, + REGION_DR_GERMAN = 1006, + REGION_DR_SINGAPORE = 1007 +} diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/ngx/index.js b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/index.js new file mode 100644 index 00000000..2b55df58 --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/index.js @@ -0,0 +1,482 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { __extends } from "tslib"; +import { Injectable } from "@angular/core"; +import { IonicNativePlugin, cordova, cordovaPropertyGet, cordovaPropertySet } from "@ionic-native/core"; +var HMSMLTextPlugin = /** @class */ (function (_super) { + __extends(HMSMLTextPlugin, _super); + function HMSMLTextPlugin() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Monitors photographing. + * @returns Promise + */ + HMSMLTextPlugin.prototype.photograph = function () { return cordova(this, "photograph", { "otherPromise": true }, arguments); }; + /** + * Close lens engine. + * @returns Promise + */ + HMSMLTextPlugin.prototype.destroy = function () { return cordova(this, "destroy", { "otherPromise": true }, arguments); }; + /** + * Obtains the size of the preview image of a camera. + * @returns Promise + */ + HMSMLTextPlugin.prototype.getDisplayDimension = function () { return cordova(this, "getDisplayDimension", { "otherPromise": true }, arguments); }; + /** + * An app information class used to store basic information about apps with the HMS Core ML SDK integrated and complete the initialization of ML Text Kit. When using cloud services of the ML Text Kit, you need to set the apiKey of your app. + * @param {appSettingReq} appSettingReq Represents the parameter required. + * @returns Promise + */ + HMSMLTextPlugin.prototype.appSetting = function (appSettingReq) { return cordova(this, "appSetting", { "otherPromise": true }, arguments); }; + /** + * Determines whether to collect statistics on the current app. + * @param {any} any + * @returns Promise + */ + HMSMLTextPlugin.prototype.setStatistic = function (any) { return cordova(this, "setStatistic", { "otherPromise": true }, arguments); }; + /** + * Determines whether to collect statistics on the current app. + ** @param {any} any + * @returns Promise + */ + HMSMLTextPlugin.prototype.getStatistic = function (any) { return cordova(this, "getStatistic", { "otherPromise": true }, arguments); }; + /** + * This service enable logger service. + * @returns Promise + */ + HMSMLTextPlugin.prototype.enableLogger = function () { return cordova(this, "enableLogger", { "otherPromise": true }, arguments); }; + /** + * This service disable logger service. + * @returns Promise + */ + HMSMLTextPlugin.prototype.disableLogger = function () { return cordova(this, "disableLogger", { "otherPromise": true }, arguments); }; + Object.defineProperty(HMSMLTextPlugin.prototype, "MLLocalTextSetting", { + get: function () { return cordovaPropertyGet(this, "MLLocalTextSetting"); }, + set: function (value) { cordovaPropertySet(this, "MLLocalTextSetting", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "icrVnCaptureType", { + get: function () { return cordovaPropertyGet(this, "icrVnCaptureType"); }, + set: function (value) { cordovaPropertySet(this, "icrVnCaptureType", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "MLTextConfig", { + get: function () { return cordovaPropertyGet(this, "MLTextConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLTextConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "MLRemoteTextSetting", { + get: function () { return cordovaPropertyGet(this, "MLRemoteTextSetting"); }, + set: function (value) { cordovaPropertySet(this, "MLRemoteTextSetting", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "MLBcrCaptureConfig", { + get: function () { return cordovaPropertyGet(this, "MLBcrCaptureConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLBcrCaptureConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "MLGcrCaptureUIConfig", { + get: function () { return cordovaPropertyGet(this, "MLGcrCaptureUIConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLGcrCaptureUIConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "MLBcrResultConfig", { + get: function () { return cordovaPropertyGet(this, "MLBcrResultConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLBcrResultConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "ImgSuperResolutionConfig", { + get: function () { return cordovaPropertyGet(this, "ImgSuperResolutionConfig"); }, + set: function (value) { cordovaPropertySet(this, "ImgSuperResolutionConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "MLFormRecogitionConfig", { + get: function () { return cordovaPropertyGet(this, "MLFormRecogitionConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLFormRecogitionConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "MLProductConfig", { + get: function () { return cordovaPropertyGet(this, "MLProductConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLProductConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "gcrCaptureType", { + get: function () { return cordovaPropertyGet(this, "gcrCaptureType"); }, + set: function (value) { cordovaPropertySet(this, "gcrCaptureType", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLTextPlugin.prototype, "Colors", { + get: function () { return cordovaPropertyGet(this, "Colors"); }, + set: function (value) { cordovaPropertySet(this, "Colors", value); }, + enumerable: false, + configurable: true + }); + HMSMLTextPlugin.pluginName = "HMSMLTextPlugin"; + HMSMLTextPlugin.plugin = "cordova-plugin-hms-mltext"; + HMSMLTextPlugin.pluginRef = "HMSMLTextPlugin"; + HMSMLTextPlugin.platforms = ["Android"]; + HMSMLTextPlugin.decorators = [ + { type: Injectable } + ]; + return HMSMLTextPlugin; +}(IonicNativePlugin)); +export { HMSMLTextPlugin }; +var HMSMLText = /** @class */ (function (_super) { + __extends(HMSMLText, _super); + function HMSMLText() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * This method start the Text analyzer. + * @param {localImageTextReq|remoteImageTextReq} ImageTextAnalyserInput Reperesents the necessary parameters to convert images to text format. + * @returns Promise + */ + HMSMLText.prototype.imageTextAnalyser = function (ImageTextAnalyserInput) { return cordova(this, "imageTextAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method stop the Text analyzer. + * @returns Promise + */ + HMSMLText.prototype.stopTextAnalyser = function () { return cordova(this, "stopTextAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method gives Text Analyser information. + * @returns Promise + */ + HMSMLText.prototype.getTextAnalyserInfo = function () { return cordova(this, "getTextAnalyserInfo", { "otherPromise": true }, arguments); }; + /** + * This method provides a document recognition component that recognizes text from images of documents. + * @param {documentImageAnalyserReq} documentImageAnalyserReq Reperesents the necessary parameter to convert document images to text format. + * @returns Promise + */ + HMSMLText.prototype.documentImageAnalyser = function (documentImageAnalyserReq) { return cordova(this, "documentImageAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method stop the Document analyzer. + * @returns Promise + */ + HMSMLText.prototype.stopDocumentImageAnalyser = function () { return cordova(this, "stopDocumentImageAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method close the Document analyzer. + * @returns Promise + */ + HMSMLText.prototype.closeDocumentImageAnalyser = function () { return cordova(this, "closeDocumentImageAnalyser", { "otherPromise": true }, arguments); }; + /** + * This method returns the Document analyzer setting. + * @returns Promise + */ + HMSMLText.prototype.getDocumentImageAnalyserSetting = function () { return cordova(this, "getDocumentImageAnalyserSetting", { "otherPromise": true }, arguments); }; + /** + * This method returns the Image analyzer setting. + * @returns Promise + */ + HMSMLText.prototype.getTextAnalyserSetting = function () { return cordova(this, "getTextAnalyserSetting", { "otherPromise": true }, arguments); }; + /** + * This method returns the GCR setting. + * @returns Promise + */ + HMSMLText.prototype.getGCRSetting = function () { return cordova(this, "getGCRSetting", { "otherPromise": true }, arguments); }; + /** + * This method stop the Form Recognition Analyzer. + * @returns Promise + */ + HMSMLText.prototype.stopFormRecognitionAnalyser = function () { return cordova(this, "stopFormRecognitionAnalyser", { "otherPromise": true }, arguments); }; + /** + * The bank card recognition service recognizes bank cards in camera streams within angle offset of 15 degrees and extracts key information such as card number and validity period. + * @param {bankCardSDKDetectorReq|bankCardPluginDetectorReq} bankCardDetecterInput Represents the parameter required for bank card recognition. + * @returns Promise | Promise + */ + HMSMLText.prototype.bankCardDetector = function (bankCardDetecterInput) { + return; + }; + /** + * This method stop bankcard recognition service. + * @returns Promise + */ + HMSMLText.prototype.stopBankCardDetector = function () { return cordova(this, "stopBankCardDetector", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.setResultTypeBcr = function (mLBcrCaptureConfig) { return cordova(this, "setResultTypeBcr", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.setRecModeBcr = function (mLBcrCaptureConfig) { return cordova(this, "setRecModeBcr", { "otherPromise": true }, arguments); }; + /** + * This method returns the BCR setting. + * @returns Promise + */ + HMSMLText.prototype.getBankCardDetectorSetting = function () { return cordova(this, "getBankCardDetectorSetting", { "otherPromise": true }, arguments); }; + /** + * The general card recognition service provides a universal development framework based on the text recognition technology. + * @param {generalCardDetectorReq} generalCardDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + HMSMLText.prototype.generalCardDetector = function (generalCardDetectorReq) { return cordova(this, "generalCardDetector", { "otherPromise": true }, arguments); }; + /** + * The general Vietnam id card recognition service provides a universal development framework based on the text recognition technology. + * @param {icrVnDetectorReq} icrVnDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + HMSMLText.prototype.icrVnCardDetector = function (icrVnDetectorReq) { return cordova(this, "icrVnCardDetector", { "otherPromise": true }, arguments); }; + /** + * The form recognition service uses AI technologies to recognize and return form structure information (including rows, columns, and coordinates of cells) and form text in Chinese and English (including punctuation) from input images. + * @param {formRecognizerAnalyserReq} formRecognizerAnalyserReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + HMSMLText.prototype.formRecognitionAnalyser = function (formRecognizerAnalyserReq) { return cordova(this, "formRecognitionAnalyser", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.icrLocalAnalyser = function (localAnalyserReq) { return cordova(this, "icrLocalAnalyser", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.icrLocalAnalyserCreateIdCard = function (createIdCardReq) { return cordova(this, "icrLocalAnalyserCreateIdCard", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.icrLocalAnalyserStop = function () { return cordova(this, "icrLocalAnalyserStop", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.geticrCnCardInstance = function () { return cordova(this, "geticrCnCardInstance", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.icrCnCardCreate = function () { return cordova(this, "icrCnCardCreate", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.geticrVnCardInstance = function () { return cordova(this, "geticrVnCardInstance", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.icrVnCardCreate = function () { return cordova(this, "icrVnCardCreate", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.getIcrVnCapture = function () { return cordova(this, "getIcrVnCapture", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.startCustomizedView = function (userProps) { return cordova(this, "startCustomizedView", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.switchLight = function () { return cordova(this, "switchLight", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.getLightStatus = function () { return cordova(this, "getLightStatus", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.setUserRegion = function (region) { return cordova(this, "setUserRegion", { "otherPromise": true }, arguments); }; + HMSMLText.prototype.getCountryCode = function () { return cordova(this, "getCountryCode", { "otherPromise": true }, arguments); }; + Object.defineProperty(HMSMLText.prototype, "icrVnCaptureType", { + get: function () { return cordovaPropertyGet(this, "icrVnCaptureType"); }, + set: function (value) { cordovaPropertySet(this, "icrVnCaptureType", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "gcrCaptureType", { + get: function () { return cordovaPropertyGet(this, "gcrCaptureType"); }, + set: function (value) { cordovaPropertySet(this, "gcrCaptureType", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "MLLocalTextSetting", { + get: function () { return cordovaPropertyGet(this, "MLLocalTextSetting"); }, + set: function (value) { cordovaPropertySet(this, "MLLocalTextSetting", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "MLTextConfig", { + get: function () { return cordovaPropertyGet(this, "MLTextConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLTextConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "MLRemoteTextSetting", { + get: function () { return cordovaPropertyGet(this, "MLRemoteTextSetting"); }, + set: function (value) { cordovaPropertySet(this, "MLRemoteTextSetting", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "MLBcrCaptureConfig", { + get: function () { return cordovaPropertyGet(this, "MLBcrCaptureConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLBcrCaptureConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "MLGcrCaptureUIConfig", { + get: function () { return cordovaPropertyGet(this, "MLGcrCaptureUIConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLGcrCaptureUIConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "MLBcrResultConfig", { + get: function () { return cordovaPropertyGet(this, "MLBcrResultConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLBcrResultConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "ImgSuperResolutionConfig", { + get: function () { return cordovaPropertyGet(this, "ImgSuperResolutionConfig"); }, + set: function (value) { cordovaPropertySet(this, "ImgSuperResolutionConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "MLFormRecogitionConfig", { + get: function () { return cordovaPropertyGet(this, "MLFormRecogitionConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLFormRecogitionConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "MLProductConfig", { + get: function () { return cordovaPropertyGet(this, "MLProductConfig"); }, + set: function (value) { cordovaPropertySet(this, "MLProductConfig", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "Colors", { + get: function () { return cordovaPropertyGet(this, "Colors"); }, + set: function (value) { cordovaPropertySet(this, "Colors", value); }, + enumerable: false, + configurable: true + }); + Object.defineProperty(HMSMLText.prototype, "RecMode", { + get: function () { return cordovaPropertyGet(this, "RecMode"); }, + set: function (value) { cordovaPropertySet(this, "RecMode", value); }, + enumerable: false, + configurable: true + }); + HMSMLText.pluginName = "HMSMLText"; + HMSMLText.plugin = "cordova-plugin-hms-mltext"; + HMSMLText.pluginRef = "HMSMLText"; + HMSMLText.platforms = ["Android"]; + HMSMLText.decorators = [ + { type: Injectable } + ]; + return HMSMLText; +}(IonicNativePlugin)); +export { HMSMLText }; +export var RecMode; +(function (RecMode) { + RecMode[RecMode["WEAK_MODE"] = 0] = "WEAK_MODE"; + RecMode[RecMode["STRICT_MODE"] = 1] = "STRICT_MODE"; +})(RecMode || (RecMode = {})); +export var MLBcrCaptureConfig; +(function (MLBcrCaptureConfig) { + MLBcrCaptureConfig[MLBcrCaptureConfig["ERROR_CODE_INIT_CAMERA_FAILED"] = 10101] = "ERROR_CODE_INIT_CAMERA_FAILED"; + MLBcrCaptureConfig[MLBcrCaptureConfig["RESULT_NUM_ONLY"] = 0] = "RESULT_NUM_ONLY"; + MLBcrCaptureConfig[MLBcrCaptureConfig["ORIENTATION_AUTO"] = 0] = "ORIENTATION_AUTO"; + MLBcrCaptureConfig[MLBcrCaptureConfig["WEAK_MODE"] = 0] = "WEAK_MODE"; + MLBcrCaptureConfig[MLBcrCaptureConfig["ORIENTATION_LANDSCAPE"] = 1] = "ORIENTATION_LANDSCAPE"; + MLBcrCaptureConfig[MLBcrCaptureConfig["ORIENTATION_PORTRAIT"] = 2] = "ORIENTATION_PORTRAIT"; + MLBcrCaptureConfig[MLBcrCaptureConfig["RESULT_ALL"] = 2] = "RESULT_ALL"; + MLBcrCaptureConfig[MLBcrCaptureConfig["RESULT_SIMPLE"] = 1] = "RESULT_SIMPLE"; + MLBcrCaptureConfig[MLBcrCaptureConfig["STRICT_MODE"] = 1] = "STRICT_MODE"; +})(MLBcrCaptureConfig || (MLBcrCaptureConfig = {})); +export var MLBcrResultConfig; +(function (MLBcrResultConfig) { + MLBcrResultConfig[MLBcrResultConfig["RESULT_NUM_ONLY"] = 0] = "RESULT_NUM_ONLY"; + MLBcrResultConfig[MLBcrResultConfig["RESULT_SIMPLE"] = 1] = "RESULT_SIMPLE"; + MLBcrResultConfig[MLBcrResultConfig["RESULT_ALL"] = 2] = "RESULT_ALL"; +})(MLBcrResultConfig || (MLBcrResultConfig = {})); +export var MLBcrCaptureErrorCode; +(function (MLBcrCaptureErrorCode) { + MLBcrCaptureErrorCode[MLBcrCaptureErrorCode["ERROR_CODE_INIT_CAMERA_FAILED"] = 10101] = "ERROR_CODE_INIT_CAMERA_FAILED"; +})(MLBcrCaptureErrorCode || (MLBcrCaptureErrorCode = {})); +export var MLRemoteTextSetting; +(function (MLRemoteTextSetting) { + MLRemoteTextSetting[MLRemoteTextSetting["OCR_LOOSE_SCENE"] = 1] = "OCR_LOOSE_SCENE"; + MLRemoteTextSetting[MLRemoteTextSetting["OCR_COMPACT_SCENE"] = 2] = "OCR_COMPACT_SCENE"; + MLRemoteTextSetting["NGON"] = "NGON"; + MLRemoteTextSetting["ARC"] = "ARC"; + MLRemoteTextSetting[MLRemoteTextSetting["OTHER"] = 5] = "OTHER"; + MLRemoteTextSetting[MLRemoteTextSetting["NEW_LINE_CHARACTER"] = 8] = "NEW_LINE_CHARACTER"; + MLRemoteTextSetting[MLRemoteTextSetting["SPACE"] = 6] = "SPACE"; +})(MLRemoteTextSetting || (MLRemoteTextSetting = {})); +export var MLFormRecogitionConfig; +(function (MLFormRecogitionConfig) { + MLFormRecogitionConfig[MLFormRecogitionConfig["SYNC_TYPE"] = 1] = "SYNC_TYPE"; + MLFormRecogitionConfig[MLFormRecogitionConfig["ASYNC_TYPE"] = 0] = "ASYNC_TYPE"; +})(MLFormRecogitionConfig || (MLFormRecogitionConfig = {})); +export var gcrCaptureType; +(function (gcrCaptureType) { + gcrCaptureType[gcrCaptureType["CAPTURE_ACTIVITY"] = 0] = "CAPTURE_ACTIVITY"; + gcrCaptureType[gcrCaptureType["CAPTURE_PHOTO"] = 1] = "CAPTURE_PHOTO"; + gcrCaptureType[gcrCaptureType["CAPTURE_IMAGE"] = 2] = "CAPTURE_IMAGE"; +})(gcrCaptureType || (gcrCaptureType = {})); +export var MLGcrCaptureUIConfig; +(function (MLGcrCaptureUIConfig) { + MLGcrCaptureUIConfig[MLGcrCaptureUIConfig["ORIENTATION_AUTO"] = 0] = "ORIENTATION_AUTO"; + MLGcrCaptureUIConfig[MLGcrCaptureUIConfig["ORIENTATION_LANDSCAPE"] = 1] = "ORIENTATION_LANDSCAPE"; + MLGcrCaptureUIConfig[MLGcrCaptureUIConfig["ORIENTATION_PORTRAIT"] = 2] = "ORIENTATION_PORTRAIT"; +})(MLGcrCaptureUIConfig || (MLGcrCaptureUIConfig = {})); +export var icrCaptureType; +(function (icrCaptureType) { + icrCaptureType[icrCaptureType["CAPTURE_CAMERA"] = 0] = "CAPTURE_CAMERA"; + icrCaptureType[icrCaptureType["CAPTURE_IMAGE"] = 1] = "CAPTURE_IMAGE"; +})(icrCaptureType || (icrCaptureType = {})); +export var MLIcrSideType; +(function (MLIcrSideType) { + MLIcrSideType["FRONT"] = "FRONT"; + MLIcrSideType["BACK"] = "BACK"; +})(MLIcrSideType || (MLIcrSideType = {})); +export var ImgSuperResolutionConfig; +(function (ImgSuperResolutionConfig) { + ImgSuperResolutionConfig[ImgSuperResolutionConfig["ISR_SCALE_1X"] = 1] = "ISR_SCALE_1X"; + ImgSuperResolutionConfig[ImgSuperResolutionConfig["ISR_SCALE_3X"] = 3] = "ISR_SCALE_3X"; +})(ImgSuperResolutionConfig || (ImgSuperResolutionConfig = {})); +export var MLProductConfig; +(function (MLProductConfig) { + MLProductConfig[MLProductConfig["REGION_DR_CHINA"] = 1002] = "REGION_DR_CHINA"; + MLProductConfig[MLProductConfig["REGION_DR_AFILA"] = 1003] = "REGION_DR_AFILA"; + MLProductConfig[MLProductConfig["REGION_DR_EUROPE"] = 1004] = "REGION_DR_EUROPE"; + MLProductConfig[MLProductConfig["REGION_DR_RUSSIA"] = 1005] = "REGION_DR_RUSSIA"; + MLProductConfig[MLProductConfig["REGION_DR_GERMAN"] = 1006] = "REGION_DR_GERMAN"; + MLProductConfig[MLProductConfig["REGION_DR_SIANGAPORE"] = 1007] = "REGION_DR_SIANGAPORE"; +})(MLProductConfig || (MLProductConfig = {})); +export var MLLocalTextSetting; +(function (MLLocalTextSetting) { + MLLocalTextSetting[MLLocalTextSetting["OCR_DETECT_MODE"] = 1] = "OCR_DETECT_MODE"; + MLLocalTextSetting[MLLocalTextSetting["OCR_TRACKING_MODE"] = 2] = "OCR_TRACKING_MODE"; +})(MLLocalTextSetting || (MLLocalTextSetting = {})); +export var MLTextConfig; +(function (MLTextConfig) { + MLTextConfig[MLTextConfig["OCR_LOCAL_TYPE"] = 0] = "OCR_LOCAL_TYPE"; + MLTextConfig[MLTextConfig["OCR_REMOTE_TYPE"] = 1] = "OCR_REMOTE_TYPE"; +})(MLTextConfig || (MLTextConfig = {})); +export var Colors; +(function (Colors) { + Colors[Colors["RED"] = -65536] = "RED"; + Colors[Colors["DKGRAY"] = -12303292] = "DKGRAY"; + Colors[Colors["GRAY"] = -7829368] = "GRAY"; + Colors[Colors["WHITE"] = -1] = "WHITE"; + Colors[Colors["BLUE"] = -16776961] = "BLUE"; + Colors[Colors["BLACK"] = -16777216] = "BLACK"; + Colors[Colors["LTGRAY"] = -3355444] = "LTGRAY"; + Colors[Colors["MAGENTA"] = -65281] = "MAGENTA"; + Colors[Colors["YELLOW"] = -256] = "YELLOW"; + Colors[Colors["CYAN"] = -16711681] = "CYAN"; + Colors[Colors["GREEN"] = -16711936] = "GREEN"; + Colors[Colors["TRANSPARENT"] = 0] = "TRANSPARENT"; +})(Colors || (Colors = {})); +export var CordovaErrors; +(function (CordovaErrors) { + CordovaErrors[CordovaErrors["UNKNOWN"] = -1] = "UNKNOWN"; + CordovaErrors[CordovaErrors["SUCCESS"] = 0] = "SUCCESS"; + CordovaErrors[CordovaErrors["DISCARDED"] = 1] = "DISCARDED"; + CordovaErrors[CordovaErrors["INNER"] = 2] = "INNER"; + CordovaErrors[CordovaErrors["INACTIVE"] = 3] = "INACTIVE"; + CordovaErrors[CordovaErrors["NOT_SUPPORTED"] = 4] = "NOT_SUPPORTED"; + CordovaErrors[CordovaErrors["ILLEGAL_PARAMETER"] = 5] = "ILLEGAL_PARAMETER"; + CordovaErrors[CordovaErrors["OVERDUE"] = 6] = "OVERDUE"; + CordovaErrors[CordovaErrors["NO_FOUND"] = 7] = "NO_FOUND"; + CordovaErrors[CordovaErrors["DUPLICATE_FOUND"] = 8] = "DUPLICATE_FOUND"; + CordovaErrors[CordovaErrors["NO_PERMISSION"] = 9] = "NO_PERMISSION"; + CordovaErrors[CordovaErrors["INSUFFICIENT_RESOURCE"] = 10] = "INSUFFICIENT_RESOURCE"; + CordovaErrors[CordovaErrors["ANALYSIS_FAILURE"] = 11] = "ANALYSIS_FAILURE"; + CordovaErrors[CordovaErrors["INTERRUPTED"] = 12] = "INTERRUPTED"; + CordovaErrors[CordovaErrors["EXCEED_RANGE"] = 13] = "EXCEED_RANGE"; + CordovaErrors[CordovaErrors["DATA_MISSING"] = 14] = "DATA_MISSING"; + CordovaErrors[CordovaErrors["AUTHENTICATION_REQUIRED"] = 15] = "AUTHENTICATION_REQUIRED"; + CordovaErrors[CordovaErrors["TFLITE_NOT_COMPATIBLE"] = 16] = "TFLITE_NOT_COMPATIBLE"; + CordovaErrors[CordovaErrors["INSUFFICIENT_SPACE"] = 17] = "INSUFFICIENT_SPACE"; + CordovaErrors[CordovaErrors["HASH_MISS"] = 18] = "HASH_MISS"; + CordovaErrors[CordovaErrors["TOKEN_INVALID"] = 19] = "TOKEN_INVALID"; + CordovaErrors[CordovaErrors["SERVICE_FAILURE"] = 20] = "SERVICE_FAILURE"; + CordovaErrors[CordovaErrors["ANALYSIS_NULL"] = 21] = "ANALYSIS_NULL"; +})(CordovaErrors || (CordovaErrors = {})); +export var Region; +(function (Region) { + Region[Region["REGION_DR_UNKNOWN"] = 1001] = "REGION_DR_UNKNOWN"; + Region[Region["REGION_DR_CHINA"] = 1002] = "REGION_DR_CHINA"; + Region[Region["REGION_DR_RUSSIA"] = 1005] = "REGION_DR_RUSSIA"; + Region[Region["REGION_DR_GERMAN"] = 1006] = "REGION_DR_GERMAN"; + Region[Region["REGION_DR_SINGAPORE"] = 1007] = "REGION_DR_SINGAPORE"; +})(Region || (Region = {})); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJza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IDgsXG4gICAgTk9fUEVSTUlTU0lPTiA9IDksXG4gICAgSU5TVUZGSUNJRU5UX1JFU09VUkNFID0gMTAsXG4gICAgQU5BTFlTSVNfRkFJTFVSRSA9IDExLFxuICAgIElOVEVSUlVQVEVEID0gMTIsXG4gICAgRVhDRUVEX1JBTkdFID0gMTMsXG4gICAgREFUQV9NSVNTSU5HID0gMTQsXG4gICAgQVVUSEVOVElDQVRJT05fUkVRVUlSRUQgPSAxNSxcbiAgICBURkxJVEVfTk9UX0NPTVBBVElCTEUgPSAxNixcbiAgICBJTlNVRkZJQ0lFTlRfU1BBQ0UgPSAxNyxcbiAgICBIQVNIX01JU1MgPSAxOCxcbiAgICBUT0tFTl9JTlZBTElEID0gMTksXG4gICAgU0VSVklDRV9GQUlMVVJFID0gMjAsXG4gICAgQU5BTFlTSVNfTlVMTCA9IDIxLFxufVxuXG5cbmV4cG9ydCBlbnVtIFJlZ2lvbiB7XG5SRUdJT05fRFJfVU5LTk9XTiA9IDEwMDEsXG5SRUdJT05fRFJfQ0hJTkEgPSAxMDAyLFxuUkVHSU9OX0RSX1JVU1NJQSA9IDEwMDUsXG5SRUdJT05fRFJfR0VSTUFOID0gMTAwNixcblJFR0lPTl9EUl9TSU5HQVBPUkUgPSAxMDA3XG59XG4iXX0= \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/ngx/index.metadata.json b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/index.metadata.json new file mode 100644 index 00000000..83cab6ef --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/index.metadata.json @@ -0,0 +1 @@ +[{"__symbolic":"module","version":4,"metadata":{"HMSMLTextPlugin":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@ionic-native/core","name":"IonicNativePlugin","line":31,"character":37},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Plugin"},"arguments":[{"pluginName":"HMSMLTextPlugin","plugin":"cordova-plugin-hms-mltext","pluginRef":"HMSMLTextPlugin","platforms":["Android"]}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":30,"character":1}}],"members":{"MLLocalTextSetting":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"icrVnCaptureType":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLTextConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLRemoteTextSetting":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLBcrCaptureConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLGcrCaptureUIConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLBcrResultConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"ImgSuperResolutionConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLFormRecogitionConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLProductConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"gcrCaptureType":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"Colors":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"photograph":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"destroy":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getDisplayDimension":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"appSetting":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"setStatistic":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getStatistic":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"enableLogger":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"disableLogger":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}]}},"HMSMLText":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@ionic-native/core","name":"IonicNativePlugin","line":132,"character":31},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Plugin"},"arguments":[{"pluginName":"HMSMLText","plugin":"cordova-plugin-hms-mltext","pluginRef":"HMSMLText","platforms":["Android"]}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":131,"character":1}}],"members":{"icrVnCaptureType":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"gcrCaptureType":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLLocalTextSetting":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLTextConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLRemoteTextSetting":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLBcrCaptureConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLGcrCaptureUIConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLBcrResultConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"ImgSuperResolutionConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLFormRecogitionConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"MLProductConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"Colors":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"RecMode":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"CordovaProperty"}}]}],"imageTextAnalyser":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"stopTextAnalyser":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getTextAnalyserInfo":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"documentImageAnalyser":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"stopDocumentImageAnalyser":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"closeDocumentImageAnalyser":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getDocumentImageAnalyserSetting":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getTextAnalyserSetting":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getGCRSetting":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"stopFormRecognitionAnalyser":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"bankCardDetector":[{"__symbolic":"method"}],"stopBankCardDetector":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"setResultTypeBcr":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"setRecModeBcr":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getBankCardDetectorSetting":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"generalCardDetector":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"icrVnCardDetector":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"formRecognitionAnalyser":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"icrLocalAnalyser":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"icrLocalAnalyserCreateIdCard":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"icrLocalAnalyserStop":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"geticrCnCardInstance":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"icrCnCardCreate":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"geticrVnCardInstance":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"icrVnCardCreate":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getIcrVnCapture":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"startCustomizedView":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"switchLight":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getLightStatus":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"setUserRegion":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}],"getCountryCode":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Cordova"},"arguments":[{"otherPromise":true}]}]}]}},"CustomViewModeRequest":{"__symbolic":"interface"},"configReq":{"__symbolic":"interface"},"appSettingReq":{"__symbolic":"interface"},"bankCardSDKDetectorReq":{"__symbolic":"interface"},"MLBcrAnalyzerSetting":{"__symbolic":"interface"},"bankCardPluginDetectorReq":{"__symbolic":"interface"},"mLBcrCaptureConfig":{"__symbolic":"interface"},"RecMode":{"WEAK_MODE":0,"STRICT_MODE":1},"MLBcrCaptureConfig":{"ERROR_CODE_INIT_CAMERA_FAILED":10101,"RESULT_NUM_ONLY":0,"ORIENTATION_AUTO":0,"WEAK_MODE":0,"ORIENTATION_LANDSCAPE":1,"ORIENTATION_PORTRAIT":2,"RESULT_ALL":2,"RESULT_SIMPLE":1,"STRICT_MODE":1},"MLBcrResultConfig":{"RESULT_NUM_ONLY":0,"RESULT_SIMPLE":1,"RESULT_ALL":2},"MLBcrCaptureResult":{"__symbolic":"interface"},"MLBcrCaptureErrorCode":{"ERROR_CODE_INIT_CAMERA_FAILED":10101},"documentImageAnalyserReq":{"__symbolic":"interface"},"DocumentSetting":{"__symbolic":"interface"},"MLRemoteTextSetting":{"OCR_LOOSE_SCENE":1,"OCR_COMPACT_SCENE":2,"NGON":"NGON","ARC":"ARC","OTHER":5,"NEW_LINE_CHARACTER":8,"SPACE":6},"formRecognizerAnalyserReq":{"__symbolic":"interface"},"MLFormRecogitionConfig":{"SYNC_TYPE":1,"ASYNC_TYPE":0},"generalCardDetectorReq":{"__symbolic":"interface"},"gcrCaptureConfig":{"__symbolic":"interface"},"gcrCaptureType":{"CAPTURE_ACTIVITY":0,"CAPTURE_PHOTO":1,"CAPTURE_IMAGE":2},"gcrCaptureUIConfig":{"__symbolic":"interface"},"gcrSettingResults":{"__symbolic":"interface"},"MLGcrCaptureUIConfig":{"ORIENTATION_AUTO":0,"ORIENTATION_LANDSCAPE":1,"ORIENTATION_PORTRAIT":2},"icrVnDetectorReq":{"__symbolic":"interface"},"icrCnDetectorReq":{"__symbolic":"interface"},"icrCaptureType":{"CAPTURE_CAMERA":0,"CAPTURE_IMAGE":1},"createIdCardReq":{"__symbolic":"interface"},"localAnalyserReq":{"__symbolic":"interface"},"MLIcrAnalyzerSetting":{"__symbolic":"interface"},"MLIcrSideType":{"FRONT":"FRONT","BACK":"BACK"},"imageSuperResolutionReq":{"__symbolic":"interface"},"ImgSuperResolutionSetting":{"__symbolic":"interface"},"ImgSuperResolutionConfig":{"ISR_SCALE_1X":1,"ISR_SCALE_3X":3},"productReq":{"__symbolic":"interface"},"mlProductSetting":{"__symbolic":"interface"},"MLProductConfig":{"REGION_DR_CHINA":1002,"REGION_DR_AFILA":1003,"REGION_DR_EUROPE":1004,"REGION_DR_RUSSIA":1005,"REGION_DR_GERMAN":1006,"REGION_DR_SIANGAPORE":1007},"localImageTextReq":{"__symbolic":"interface"},"localTextSetting":{"__symbolic":"interface"},"MLLocalTextSetting":{"OCR_DETECT_MODE":1,"OCR_TRACKING_MODE":2},"MLTextConfig":{"OCR_LOCAL_TYPE":0,"OCR_REMOTE_TYPE":1},"remoteImageTextReq":{"__symbolic":"interface"},"remoteTextSetting":{"__symbolic":"interface"},"MLBankCard":{"__symbolic":"interface"},"Border":{"__symbolic":"interface"},"MLDocument":{"__symbolic":"interface"},"LanguageList":{"__symbolic":"interface"},"MLVnIcrCaptureResult":{"__symbolic":"interface"},"MLCnIcrCaptureResult":{"__symbolic":"interface"},"MLIcrCaptureResult":{"__symbolic":"interface"},"MLGcrCaptureResult":{"__symbolic":"interface"},"Rect":{"__symbolic":"interface"},"Bitmap":{"__symbolic":"interface"},"MLText":{"__symbolic":"interface"},"Blocks":{"__symbolic":"interface"},"Contents":{"__symbolic":"interface"},"Vertexes":{"__symbolic":"interface"},"MLFormRecogitionResult":{"__symbolic":"interface"},"TableContent":{"__symbolic":"interface"},"TablesEntity":{"__symbolic":"interface"},"TableBodyEntity":{"__symbolic":"interface"},"CellCoordinate":{"__symbolic":"interface"},"Colors":{"RED":-65536,"DKGRAY":-12303292,"GRAY":-7829368,"WHITE":-1,"BLUE":-16776961,"BLACK":-16777216,"LTGRAY":-3355444,"MAGENTA":-65281,"YELLOW":-256,"CYAN":-16711681,"GREEN":-16711936,"TRANSPARENT":0},"CordovaErrors":{"UNKNOWN":-1,"SUCCESS":0,"DISCARDED":1,"INNER":2,"INACTIVE":3,"NOT_SUPPORTED":4,"ILLEGAL_PARAMETER":5,"OVERDUE":6,"NO_FOUND":7,"DUPLICATE_FOUND":8,"NO_PERMISSION":9,"INSUFFICIENT_RESOURCE":10,"ANALYSIS_FAILURE":11,"INTERRUPTED":12,"EXCEED_RANGE":13,"DATA_MISSING":14,"AUTHENTICATION_REQUIRED":15,"TFLITE_NOT_COMPATIBLE":16,"INSUFFICIENT_SPACE":17,"HASH_MISS":18,"TOKEN_INVALID":19,"SERVICE_FAILURE":20,"ANALYSIS_NULL":21},"Region":{"REGION_DR_UNKNOWN":1001,"REGION_DR_CHINA":1002,"REGION_DR_RUSSIA":1005,"REGION_DR_GERMAN":1006,"REGION_DR_SINGAPORE":1007}}}] diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/ngx/package.json b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/package.json new file mode 100644 index 00000000..a6b630d1 --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/ngx/package.json @@ -0,0 +1,24 @@ +{ + "name": "@hmscore/ionic-native-hms-mltext", + "description": "Ionic Native wrappers for Cordova Plugin HMS ML Text", + "version": "3.12.0-300", + "zipVersion": "3.12.0.300", + "module": "index.js", + "typings": "index.d.ts", + "license": "Apache-2.0", + "licenseFilename": "LICENSE", + "repository": { + "type": "git", + "url": "https://github.com/HMS-Core/hms-cordova-plugin.git", + "directory": "cordova-plugin-hms-mltext" + }, + "bugs": "https://github.com/HMS-Core/hms-cordova-plugin/issues", + "homepage": "https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin", + "dependencies": { + "@types/cordova": "latest" + }, + "peerDependencies": { + "rxjs": "^5.5.0 || ^6.5.0", + "@ionic-native/core": "^5.1.0" + } +} diff --git a/cordova-plugin-hms-mltext/ionic-native/dist/package.json b/cordova-plugin-hms-mltext/ionic-native/dist/package.json new file mode 100644 index 00000000..a6b630d1 --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/dist/package.json @@ -0,0 +1,24 @@ +{ + "name": "@hmscore/ionic-native-hms-mltext", + "description": "Ionic Native wrappers for Cordova Plugin HMS ML Text", + "version": "3.12.0-300", + "zipVersion": "3.12.0.300", + "module": "index.js", + "typings": "index.d.ts", + "license": "Apache-2.0", + "licenseFilename": "LICENSE", + "repository": { + "type": "git", + "url": "https://github.com/HMS-Core/hms-cordova-plugin.git", + "directory": "cordova-plugin-hms-mltext" + }, + "bugs": "https://github.com/HMS-Core/hms-cordova-plugin/issues", + "homepage": "https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin", + "dependencies": { + "@types/cordova": "latest" + }, + "peerDependencies": { + "rxjs": "^5.5.0 || ^6.5.0", + "@ionic-native/core": "^5.1.0" + } +} diff --git a/cordova-plugin-hms-mltext/ionic-native/index.ts b/cordova-plugin-hms-mltext/ionic-native/index.ts new file mode 100644 index 00000000..d786572d --- /dev/null +++ b/cordova-plugin-hms-mltext/ionic-native/index.ts @@ -0,0 +1,851 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { Injectable } from "@angular/core"; +import { + Plugin, + Cordova, + CordovaProperty, + IonicNativePlugin, +} from "@ionic-native/core"; + +@Plugin({ + pluginName: "HMSMLTextPlugin", + plugin: "cordova-plugin-hms-mltext", // npm package name, example: cordova-plugin-camera + pluginRef: "HMSMLTextPlugin", // the variable reference to call the plugin, example: navigator.geolocation + platforms: ["Android"], // Array of platforms supported, example: ['Android', 'iOS'] +}) +@Injectable() +export class HMSMLTextPlugin extends IonicNativePlugin { + @CordovaProperty() + MLLocalTextSetting = MLLocalTextSetting; + @CordovaProperty() + icrVnCaptureType = icrCaptureType; + @CordovaProperty() + MLTextConfig = MLTextConfig; + @CordovaProperty() + MLRemoteTextSetting = MLRemoteTextSetting; + @CordovaProperty() + MLBcrCaptureConfig = MLBcrCaptureConfig; + @CordovaProperty() + MLGcrCaptureUIConfig = MLGcrCaptureUIConfig; + @CordovaProperty() + MLBcrResultConfig = MLBcrResultConfig; + @CordovaProperty() + ImgSuperResolutionConfig = ImgSuperResolutionConfig; + @CordovaProperty() + MLFormRecogitionConfig = MLFormRecogitionConfig; + @CordovaProperty() + MLProductConfig = MLProductConfig; + @CordovaProperty() + gcrCaptureType = gcrCaptureType; + @CordovaProperty() + Colors = Colors; + + @Cordova({ otherPromise: true }) + /** + * Monitors photographing. + * @returns Promise + */ + photograph(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * Close lens engine. + * @returns Promise + */ + destroy(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * Obtains the size of the preview image of a camera. + * @returns Promise + */ + getDisplayDimension(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * An app information class used to store basic information about apps with the HMS Core ML SDK integrated and complete the initialization of ML Text Kit. When using cloud services of the ML Text Kit, you need to set the apiKey of your app. + * @param {appSettingReq} appSettingReq Represents the parameter required. + * @returns Promise + */ + appSetting(appSettingReq: appSettingReq): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * Determines whether to collect statistics on the current app. + * @param {any} any + * @returns Promise + */ + setStatistic(any: any): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * Determines whether to collect statistics on the current app. + ** @param {any} any + * @returns Promise + */ + getStatistic(any: any): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This service enable logger service. + * @returns Promise + */ + enableLogger(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This service disable logger service. + * @returns Promise + */ + disableLogger(): Promise { + return; + } +} +@Plugin({ + pluginName: "HMSMLText", + plugin: "cordova-plugin-hms-mltext", // npm package name, example: cordova-plugin-camera + pluginRef: "HMSMLText", // the variable reference to call the plugin, example: navigator.geolocation + platforms: ["Android"], // Array of platforms supported, example: ['Android', 'iOS'] +}) +@Injectable() +export class HMSMLText extends IonicNativePlugin { + @CordovaProperty() + icrVnCaptureType = icrCaptureType; + @CordovaProperty() + gcrCaptureType = gcrCaptureType; + @CordovaProperty() + MLLocalTextSetting = MLLocalTextSetting; + @CordovaProperty() + MLTextConfig = MLTextConfig; + @CordovaProperty() + MLRemoteTextSetting = MLRemoteTextSetting; + @CordovaProperty() + MLBcrCaptureConfig = MLBcrCaptureConfig; + @CordovaProperty() + MLGcrCaptureUIConfig = MLGcrCaptureUIConfig; + @CordovaProperty() + MLBcrResultConfig = MLBcrResultConfig; + @CordovaProperty() + ImgSuperResolutionConfig = ImgSuperResolutionConfig; + @CordovaProperty() + MLFormRecogitionConfig = MLFormRecogitionConfig; + @CordovaProperty() + MLProductConfig = MLProductConfig; + @CordovaProperty() + Colors = Colors; + @CordovaProperty() + RecMode = RecMode; + + @Cordova({ otherPromise: true }) + /** + * This method start the Text analyzer. + * @param {localImageTextReq|remoteImageTextReq} ImageTextAnalyserInput Reperesents the necessary parameters to convert images to text format. + * @returns Promise + */ + imageTextAnalyser( + ImageTextAnalyserInput: localImageTextReq | remoteImageTextReq + ): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method stop the Text analyzer. + * @returns Promise + */ + stopTextAnalyser(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method gives Text Analyser information. + * @returns Promise + */ + getTextAnalyserInfo(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method provides a document recognition component that recognizes text from images of documents. + * @param {documentImageAnalyserReq} documentImageAnalyserReq Reperesents the necessary parameter to convert document images to text format. + * @returns Promise + */ + documentImageAnalyser( + documentImageAnalyserReq: documentImageAnalyserReq + ): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method stop the Document analyzer. + * @returns Promise + */ + stopDocumentImageAnalyser(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method close the Document analyzer. + * @returns Promise + */ + closeDocumentImageAnalyser(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method returns the Document analyzer setting. + * @returns Promise + */ + getDocumentImageAnalyserSetting(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method returns the Image analyzer setting. + * @returns Promise + */ + getTextAnalyserSetting(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method returns the GCR setting. + * @returns Promise + */ + getGCRSetting(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method stop the Form Recognition Analyzer. + * @returns Promise + */ + stopFormRecognitionAnalyser(): Promise { + return; + } + /** + * The bank card recognition service recognizes bank cards in camera streams within angle offset of 15 degrees and extracts key information such as card number and validity period. + * @param {bankCardSDKDetectorReq|bankCardPluginDetectorReq} bankCardDetecterInput Represents the parameter required for bank card recognition. + * @returns Promise | Promise + */ + bankCardDetector( + bankCardDetecterInput: + | bankCardSDKDetectorReq + | bankCardPluginDetectorReq + ): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method stop bankcard recognition service. + * @returns Promise + */ + stopBankCardDetector(): Promise { + return; + } + @Cordova({ otherPromise: true }) + setResultTypeBcr(mLBcrCaptureConfig: mLBcrCaptureConfig): Promise { + return; + } + @Cordova({ otherPromise: true }) + setRecModeBcr(mLBcrCaptureConfig: mLBcrCaptureConfig): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * This method returns the BCR setting. + * @returns Promise + */ + getBankCardDetectorSetting(): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * The general card recognition service provides a universal development framework based on the text recognition technology. + * @param {generalCardDetectorReq} generalCardDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + generalCardDetector( + generalCardDetectorReq: generalCardDetectorReq + ): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * The general Vietnam id card recognition service provides a universal development framework based on the text recognition technology. + * @param {icrVnDetectorReq} icrVnDetectorReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + icrVnCardDetector( + icrVnDetectorReq: icrVnDetectorReq + ): Promise { + return; + } + @Cordova({ otherPromise: true }) + /** + * The form recognition service uses AI technologies to recognize and return form structure information (including rows, columns, and coordinates of cells) and form text in Chinese and English (including punctuation) from input images. + * @param {formRecognizerAnalyserReq} formRecognizerAnalyserReq Represents the parameter required for general card recognition plug-in. + * @returns Promise + */ + formRecognitionAnalyser( + formRecognizerAnalyserReq: formRecognizerAnalyserReq + ): Promise { + return; + } + @Cordova({ otherPromise: true }) + icrLocalAnalyser( + localAnalyserReq: localAnalyserReq + ): Promise { + return; + } + + @Cordova({ otherPromise: true }) + icrLocalAnalyserCreateIdCard( + createIdCardReq: createIdCardReq + ): Promise { + return; + } + + @Cordova({ otherPromise: true }) + icrLocalAnalyserStop(): Promise { + return; + } + + @Cordova({ otherPromise: true }) + geticrCnCardInstance(): Promise { + return; + } + + @Cordova({ otherPromise: true }) + icrCnCardCreate(): Promise { + return; + } + @Cordova({ otherPromise: true }) + geticrVnCardInstance(): Promise { + return; + } + @Cordova({ otherPromise: true }) + icrVnCardCreate(): Promise { + return; + } + @Cordova({ otherPromise: true }) + getIcrVnCapture(): Promise { + return; + } + + @Cordova({ otherPromise: true }) + startCustomizedView(userProps: CustomViewModeRequest): Promise { + return; + } + @Cordova({ otherPromise: true }) + switchLight(): Promise { + return; + } + @Cordova({ otherPromise: true }) + getLightStatus(): Promise { + return; + } + @Cordova({ otherPromise: true }) + setUserRegion(region: Region): Promise { + return; + } + @Cordova({ otherPromise: true }) + getCountryCode(): Promise { + return; + } +} + +export interface CustomViewModeRequest { + isTitleAvailable: boolean; + title: string; + heightFactor: number; + widthFactor: number; + isFlashAvailable: boolean; + resultType: MLBcrResultConfig; + recMode: RecMode; + } + +// API KEY + +export interface configReq { + apiKey: string; +} + +export interface appSettingReq { + apiKey?: string | null; + applicationId?: string | null; + certFingerprint?: string | null; +} + + +// SDK BANK CARD ANALYSER + +export interface bankCardSDKDetectorReq { + filePath: any; + detectType: 0; + mLBcrAnalyzerSetting?: MLBcrAnalyzerSetting | null; +} + +export interface MLBcrAnalyzerSetting { + langType?: string | null; + resultType?: MLBcrResultConfig | null; +} + +// PLUGIN BANK CARD ANALYSER + +export interface bankCardPluginDetectorReq { + detectType: 1; + mLBcrCaptureConfig?: mLBcrCaptureConfig | null; +} + +export interface mLBcrCaptureConfig { + orientation?: MLBcrCaptureConfig | null; + resultType?: MLBcrResultConfig | null; + recMode?: RecMode | null; +} + +export enum RecMode { + WEAK_MODE = 0, + STRICT_MODE = 1, +} + +export enum MLBcrCaptureConfig { + ERROR_CODE_INIT_CAMERA_FAILED = 10101, + RESULT_NUM_ONLY = 0, + ORIENTATION_AUTO = 0, + WEAK_MODE = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2, + RESULT_ALL = 2, + RESULT_SIMPLE = 1, + STRICT_MODE = 1, +} +export enum MLBcrResultConfig { + RESULT_NUM_ONLY = 0, + RESULT_SIMPLE = 1, + RESULT_ALL = 2, +} + +export interface MLBcrCaptureResult { + errorCode?: MLBcrCaptureErrorCode | null; + expire?: String | null; + issuer?: String | null; + number?: String | null; + numberBitmap?: any; + organization?: String | null; + riginalBitmap?: any; + type?: String | null; +} + +export enum MLBcrCaptureErrorCode { + ERROR_CODE_INIT_CAMERA_FAILED = 10101, +} + + +//Document Analyser + +export interface documentImageAnalyserReq { + documentSetting?: DocumentSetting | null; + filePath: any; +} +export interface DocumentSetting { + borderType?: MLRemoteTextSetting | null; + languageList?: Array | null; + enableFingerprintVerification: boolean | null; +} + +export enum MLRemoteTextSetting { + OCR_LOOSE_SCENE = 1, + OCR_COMPACT_SCENE = 2, + NGON = "NGON", + ARC = "ARC", + OTHER = 5, + NEW_LINE_CHARACTER = 8, + SPACE = 6, +} + + + +//Form Recognizer Analyser + +export interface formRecognizerAnalyserReq { + filePath: any; + syncType: MLFormRecogitionConfig; +} +export enum MLFormRecogitionConfig { + SYNC_TYPE = 1, + ASYNC_TYPE = 0, +} + +// GENERAL CARD ANALYSER + +export interface generalCardDetectorReq { + gcrCaptureConfig?: gcrCaptureConfig; + gcrCaptureUIConfig?: gcrCaptureUIConfig; + captureType?: gcrCaptureType | null; +} + +export interface gcrCaptureConfig { + language: string; +} +export enum gcrCaptureType { + CAPTURE_ACTIVITY = 0, + CAPTURE_PHOTO = 1, + CAPTURE_IMAGE = 2, +} +export interface gcrCaptureUIConfig { + orientation?: MLGcrCaptureUIConfig | null; + tipText?: string | null; + tipTextColor?: number | null; + photoButtonResId?: number | null; + scanBoxCornerColor?: number | null; + backButtonRedId?: number | null; + torchRedId?: number | null; +} +export interface gcrSettingResults { + gcrConfigLanguage: String; + torchOnResId: number; + tipTextColor: number; + tipText: String; + backButtonResId: number; + orientation: number; + photoButtonResId: number; + scanBoxScreenRatio: number; + scanBoxCornerColor: number; + scanBoxAspectRatio: number; +} + +export enum MLGcrCaptureUIConfig { + ORIENTATION_AUTO = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2, +} + +// ID CARD ANALYSER + +export interface icrVnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; +} + +export interface icrCnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; + isFront?: boolean | null; +} + +export enum icrCaptureType { + CAPTURE_CAMERA = 0, + CAPTURE_IMAGE = 1, +} + +export interface createIdCardReq { + mlIcrAnalyzerSetting?: MLIcrAnalyzerSetting | null; +} + +export interface localAnalyserReq { + settings: MLIcrAnalyzerSetting; + filePath?: any | null; +} +export interface MLIcrAnalyzerSetting { + countryCode: string; + hashCode?: number | null; + sideType?: MLIcrSideType | null; +} + +export enum MLIcrSideType { + FRONT = "FRONT", + BACK = "BACK", +} + + +//Image Super Resolution + +export interface imageSuperResolutionReq { + filePath: any; + imgSuperResolutionSetting?: ImgSuperResolutionSetting | null; + syncType?: MLFormRecogitionConfig | null; +} +export interface ImgSuperResolutionSetting { + scaleType?: ImgSuperResolutionConfig; +} +export enum ImgSuperResolutionConfig { + ISR_SCALE_1X = 1.0, + ISR_SCALE_3X = 3.0, +} + +//Product Vision Analyser + +export interface productReq { + filePath?: any | null; + detectType?: number; + mlProductSetting?: mlProductSetting | null; +} +export interface mlProductSetting { + largestNumOfReturns?: number | null; + productSetId?: string | null; + region?: MLProductConfig | null; +} +export enum MLProductConfig { + REGION_DR_CHINA = 1002, + REGION_DR_AFILA = 1003, + REGION_DR_EUROPE = 1004, + REGION_DR_RUSSIA = 1005, + REGION_DR_GERMAN = 1006, + REGION_DR_SIANGAPORE = 1007, +} + + + +//Text Analyser + +export interface localImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + localTextSetting?: localTextSetting | null; + filePath: any; +} + +export interface localTextSetting { + ocrMode?: MLLocalTextSetting; + language?: string; +} + +export enum MLLocalTextSetting { + OCR_DETECT_MODE = 1, + OCR_TRACKING_MODE = 2, +} +export enum MLTextConfig { + OCR_LOCAL_TYPE = 0, + OCR_REMOTE_TYPE = 1, +} +export interface remoteImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + remoteTextSetting?: remoteTextSetting; + filePath: any; +} +export interface remoteTextSetting { + textDensityScene?: MLRemoteTextSetting; + languageList?: Array; + borderType?: MLRemoteTextSetting; +} + +export interface MLBankCard { + number: string; + expire: string; + issuer: string; + type: string; + organization: string; + originalBitmap: any; + numberBitmap: any; +} + + +export interface Border { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} + +export interface MLDocument { + stringValue: string; + blocks?: Blocks[]; +} + +export interface LanguageList { + language: string; +} + + +export interface MLVnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; +} + +export interface MLCnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + authority: string; + validDate: string; +} + +export interface MLIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + validDate: string; +} + +export interface MLGcrCaptureResult { + text: string; + cardBitmap: Bitmap; +} + + +export interface Rect { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} + +export interface Bitmap { + mGalleryCached: boolean; + mHeight: number; + mNativePtr: number; + mWidth: number; +} + +export interface MLText { + stringValue: string; + blocks?: Blocks[]; +} +export interface Blocks { + contents?: Contents[]; +} +export interface Contents { + stringValue: string; + border: Border; + language: string; + languageList?: LanguageList[]; + vertexes?: Vertexes[]; +} +export interface LanguageList { + language: string; +} +export interface Vertexes { + x: number; + y: number; + describeContents: number; +} + +export interface MLFormRecogitionResult { + retCode: number; + tableContent: TableContent; +} + +export interface TableContent { + tableCount: number; + tables?: TablesEntity[] | null; +} +export interface TablesEntity { + tableID: number; + headerInfo: string; + footerInfo: string; + tableBody?: TableBodyEntity[] | null; +} +export interface TableBodyEntity { + startRow: number; + endRow: number; + startCol: number; + endCol: number; + cellCoordinate: CellCoordinate; + textInfo: string; +} +export interface CellCoordinate { + topLeft_x: number; + topLeft_y: number; + topRight_x: number; + topRight_y: number; + bottomLeft_x: number; + bottomLeft_y: number; + bottomRight_x: number; + bottomRight_y: number; +} + +export enum Colors { + RED = -65536, + DKGRAY = -12303292, + GRAY = -7829368, + WHITE = -1, + BLUE = -16776961, + BLACK = -16777216, + LTGRAY = -3355444, + MAGENTA = -65281, + YELLOW = -256, + CYAN = -16711681, + GREEN = -16711936, + TRANSPARENT = 0, +} + +export enum CordovaErrors { + UNKNOWN = -1, + SUCCESS = 0, + DISCARDED = 1, + INNER = 2, + INACTIVE = 3, + NOT_SUPPORTED = 4, + ILLEGAL_PARAMETER = 5, + OVERDUE = 6, + NO_FOUND = 7, + DUPLICATE_FOUND = 8, + NO_PERMISSION = 9, + INSUFFICIENT_RESOURCE = 10, + ANALYSIS_FAILURE = 11, + INTERRUPTED = 12, + EXCEED_RANGE = 13, + DATA_MISSING = 14, + AUTHENTICATION_REQUIRED = 15, + TFLITE_NOT_COMPATIBLE = 16, + INSUFFICIENT_SPACE = 17, + HASH_MISS = 18, + TOKEN_INVALID = 19, + SERVICE_FAILURE = 20, + ANALYSIS_NULL = 21, +} + + +export enum Region { +REGION_DR_UNKNOWN = 1001, +REGION_DR_CHINA = 1002, +REGION_DR_RUSSIA = 1005, +REGION_DR_GERMAN = 1006, +REGION_DR_SINGAPORE = 1007 +} diff --git a/cordova-plugin-hms-mltext/package.json b/cordova-plugin-hms-mltext/package.json new file mode 100644 index 00000000..d3067de6 --- /dev/null +++ b/cordova-plugin-hms-mltext/package.json @@ -0,0 +1,55 @@ +{ + "name": "@hmscore/cordova-plugin-hms-mltext", + "description": "Cordova HMS ML Text Plugin", + "version": "3.12.0-300", + "main": "./www/index.js", + "types": "./types/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/HMS-Core/hms-cordova-plugin.git", + "directory": "cordova-plugin-hms-mltext" + }, + "bugs": "https://github.com/HMS-Core/hms-cordova-plugin/issues", + "homepage": "https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin", + "license": "Apache-2.0", + "licenseFilename": "LICENSE", + "readmeFilename": "README.md", + "cordova": { + "id": "cordova-plugin-hms-mltext", + "platforms": [ + "android" + ] + }, + "keywords": [ + "cordova", + "ecosystem:cordova", + "cordova-android", + "ml", + "hms-mltext", + "huawei-mltext", + "hms", + "huawei" + ], + "files": [ + "hooks", + "ionic-native", + "src", + "types", + "www", + "LICENSE", + "package.json", + "plugin.xml", + "README.md" + ], + "dependencies": { + "@types/cordova": "0.0.34" + }, + "devDependencies": { + "typescript": "3.9.5" + }, + "scripts": { + "build:core": "node ./node_modules/typescript/bin/tsc", + "build": "npm run build:core", + "watch": "node ./node_modules/typescript/bin/tsc --watch" + } +} diff --git a/cordova-plugin-hms-mltext/plugin.xml b/cordova-plugin-hms-mltext/plugin.xml new file mode 100644 index 00000000..cca93cee --- /dev/null +++ b/cordova-plugin-hms-mltext/plugin.xml @@ -0,0 +1,174 @@ + + + + HMS ML Text + + + Cordova HMS ML Text Plugin + + + Apache 2.0 + + + cordova,ml,hms-mltext,huawei-mltext,hms,huawei + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cordova-plugin-hms-mltext/src/android/build-extras.gradle b/cordova-plugin-hms-mltext/src/android/build-extras.gradle new file mode 100644 index 00000000..bc3ead73 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/build-extras.gradle @@ -0,0 +1,71 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +def pluginMinSdk = 19 +def needAGC = true + +try { + // Use try-catch to check that project's runtime is Capacitor + if (rootProject.ext.minSdkVersion < pluginMinSdk) { + rootProject.ext.minSdkVersion = pluginMinSdk + } + if (needAGC) { + rootProject.subprojects { + if (name == "app") { + if (!plugins.hasPlugin('com.huawei.agconnect')) { + rootProject.ext.postBuildExtras = { + apply plugin: 'com.huawei.agconnect' + } + } + } + } + } +} catch (e1) { + // Project runtime is Cordova + try { + if (needAGC) { + cdvPluginPostBuildExtras.add({ + afterEvaluate { + rootProject.subprojects { + if (name == "app") { + if (!plugins.hasPlugin('com.huawei.agconnect')) { + apply plugin: 'com.huawei.agconnect' + } + } + } + } + }) + } + } catch (e2) { + println("WARNING: Huawei AGConnect is not set") + } + + // Cordova 9.X + try { + if (defaultMinSdkVersion < pluginMinSdk) { + cdvMinSdkVersion = pluginMinSdk + } + } catch (e3) { + // Cordova 10.X + try { + if (cordovaConfig.MIN_SDK_VERSION < pluginMinSdk) { + cordovaConfig.MIN_SDK_VERSION = pluginMinSdk + } + } catch (e4) { + println("WARNING: Huawei Min SDK is not set") + } + } +} diff --git a/cordova-plugin-hms-mltext/src/android/build.gradle b/cordova-plugin-hms-mltext/src/android/build.gradle new file mode 100644 index 00000000..4a65ac5a --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.library' + +buildscript { + repositories { + google() + jcenter() + maven { url 'https://developer.huawei.com/repo/' } + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.6.0' + } +} + +repositories { + google() + jcenter() + maven { url 'https://developer.huawei.com/repo/' } +} + +android { + compileSdkVersion 31 + buildToolsVersion '31.0.0' + + defaultConfig { + minSdkVersion 19 + targetSdkVersion 31 + } + + lintOptions { + abortOnError false + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + aaptOptions { + noCompress "ms", "mnn", "cambricon" + cruncherEnabled false + useNewCruncher false + } +} + +dependencies { + implementation 'org.apache.cordova:framework:8.1.0' + implementation "com.huawei.hms:ml-computer-vision-ocr-latin-model:3.11.0.301" + implementation "com.huawei.hms:ml-computer-vision-ocr-cn-model:3.11.0.301" + implementation "com.huawei.hms:ml-computer-vision-ocr-jk-model:3.11.0.301" + implementation "com.huawei.hms:ml-computer-vision-ocr:3.11.0.301" + implementation "com.huawei.hms:ml-computer-card-gcr-plugin:3.11.0.301" + implementation "com.huawei.hms:ml-computer-vision-cloud:3.11.0.301" + implementation "com.huawei.hms:ml-computer-card-icr-vn:3.7.0.303" + implementation "com.huawei.hms:ml-computer-card-icr-cn:3.5.0.300" + implementation "com.huawei.hms:ml-computer-card-bcr:3.7.0.302" + implementation "com.huawei.hms:ml-computer-vision-formrecognition-model:3.7.0.301" + implementation "com.huawei.hms:ml-computer-vision-formrecognition:3.11.0.301" + +} diff --git a/cordova-plugin-hms-mltext/src/android/gradle.properties b/cordova-plugin-hms-mltext/src/android/gradle.properties new file mode 100644 index 00000000..d015431a --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/gradle.properties @@ -0,0 +1,2 @@ +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/src/android/gradle/wrapper/gradle-wrapper.properties b/cordova-plugin-hms-mltext/src/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..442d9132 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/cordova-plugin-hms-mltext/src/android/gradlew b/cordova-plugin-hms-mltext/src/android/gradlew new file mode 100644 index 00000000..c53aefaa --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/cordova-plugin-hms-mltext/src/android/gradlew.bat b/cordova-plugin-hms-mltext/src/android/gradlew.bat new file mode 100644 index 00000000..107acd32 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/cordova-plugin-hms-mltext/src/android/src/main/AndroidManifest.xml b/cordova-plugin-hms-mltext/src/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..4c18d650 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/AndroidManifest.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/HMSMLText.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/HMSMLText.java new file mode 100644 index 00000000..0597e2b0 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/HMSMLText.java @@ -0,0 +1,347 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext; + +import static android.app.Activity.RESULT_OK; + +import android.content.Intent; +import android.graphics.Bitmap; +import android.util.Log; + +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.providers.textproviders.bankcard.CustomViewHandler; +import com.huawei.hms.cordova.mltext.providers.textproviders.bankcard.MLBankCardAnalyser; +import com.huawei.hms.cordova.mltext.providers.textproviders.document.MLImageDocumentAnalyser; +import com.huawei.hms.cordova.mltext.providers.textproviders.formrecognition.MLFormRecognitionAnalyser; +import com.huawei.hms.cordova.mltext.providers.textproviders.generalcard.MLGeneralCardAnalyser; +import com.huawei.hms.cordova.mltext.providers.textproviders.idcard.MLIcrCardAnalyser; +import com.huawei.hms.cordova.mltext.providers.textproviders.idcard.MLIcrCnCardAnalyser; +import com.huawei.hms.cordova.mltext.providers.textproviders.idcard.MLIcrVnCardAnalyser; +import com.huawei.hms.cordova.mltext.providers.textproviders.text.MLImageTextAnalyser; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; + +public class HMSMLText extends CordovaPlugin { + + public static final String TAG = HMSMLText.class.getSimpleName(); + + private static CallbackContext callbackCtx; + + private MLImageTextAnalyser mlTextService; + + private MLImageDocumentAnalyser mlDocumentService; + + private MLBankCardAnalyser bcrAnalyse; + + private MLGeneralCardAnalyser generalCardAnalyse; + + private MLIcrVnCardAnalyser icrVnCardAnalyser; + + private MLIcrCardAnalyser mlIcrCardAnalyser; + + private MLIcrCnCardAnalyser mlIcrCnCardAnalyser; + + private MLFormRecognitionAnalyser formRecognitionAnalyser; + + private CustomViewHandler customViewHandler; + + private static final int REQUEST_CODE_SCAN_CUSTOMIZED = 14; + + public static CallbackContext getCallbackContext() { + return callbackCtx; + } + + public static void setCallbackContext(final CallbackContext callbackContext) { + callbackCtx = callbackContext; + } + + public void pluginInitialize() { + mlTextService = CordovaHelpers.initializeProvider(new MLImageTextAnalyser(cordova.getContext()), cordova, this); + mlDocumentService = CordovaHelpers.initializeProvider(new MLImageDocumentAnalyser(cordova.getContext()), + cordova, this); + generalCardAnalyse = CordovaHelpers.initializeProvider(new MLGeneralCardAnalyser(cordova.getContext()), cordova, + this); + formRecognitionAnalyser = CordovaHelpers.initializeProvider(new MLFormRecognitionAnalyser(cordova.getContext()), + cordova, this); + bcrAnalyse = CordovaHelpers.initializeProvider(new MLBankCardAnalyser(cordova.getContext()), cordova, this); + icrVnCardAnalyser = CordovaHelpers.initializeProvider(new MLIcrVnCardAnalyser(cordova.getContext()), cordova, + this); + mlIcrCnCardAnalyser = CordovaHelpers.initializeProvider(new MLIcrCnCardAnalyser(cordova.getContext()), cordova, + this); + + mlIcrCardAnalyser = CordovaHelpers.initializeProvider(new MLIcrCardAnalyser(cordova.getContext()), cordova, + this); + + customViewHandler = CordovaHelpers.initializeProvider( + new CustomViewHandler(cordova.getContext(), cordova.getActivity(), cordova, this), cordova, this); + + } + + public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) { + + setCallbackContext(callbackContext); + JSONObject params = args.optJSONObject(0); + int ocrType; + try { + switch (action) { + case "ACTION_IMAGE_TEXT_ANALYSER": { + if (!params.has("ocrType") || params.isNull("ocrType")) { + Log.e(TAG, "Illegal argument. ocrType field is mandatory and it must not be null."); + callbackContext.error("Illegal argument. ocrType field is mandatory and it must not be null."); + return false; + } + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("imageTextAnalyser"); + ocrType = params.getInt("ocrType"); + switch (ocrType) { + case 0: + Log.i(TAG, "ImageTextAnalyse: localImageTextAnalyser"); + mlTextService.initializeLocalImageTextAnalyser(params, callbackContext); + return true; + case 1: + Log.i(TAG, "ImageTextAnalyse: remoteImageTextAnalyser"); + mlTextService.initializeRemoteImageTextAnalyser(params, callbackContext); + return true; + default: + } + break; + } + case "ACTION_GET_IMAGE_TEXT_INFO": + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("imageTextAnalyserInfo"); + mlTextService.getImgTextAnalyserInfo(callbackContext, cordova); + return true; + case "ACTION_GET_IMAGE_TEXT_SETTING": + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("imageTextAnalyserSetting"); + mlTextService.getTextSetting(callbackContext); + return true; + case "ACTION_STOP_TEXT_ANALYSER": + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("imageTextAnalyserStop"); + mlTextService.closeImgTextAnalyser(callbackContext, cordova); + return true; + case "ACTION_GET_GCR_SETTING": + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("gcrAnalyserSetting"); + generalCardAnalyse.getGCRSetting(callbackContext); + return true; + case "ACTION_DOCUMENT_IMAGE_ANALYSER": { + cordova.getThreadPool().execute(() -> { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("documentImageAnalyser"); + mlDocumentService.initializeDocumentAnalyser(params, callbackContext); + }); + return true; + } + case "ACTION_STOP_DOCUMENT_IMAGE_ANALYSER": { + cordova.getThreadPool().execute(() -> { + HMSLogger.getInstance(cordova.getContext()) + .startMethodExecutionTimer("documentImageAnalyserStop"); + try { + mlDocumentService.stopDocumentAnalyser(callbackContext); + } catch (IOException e) { + Log.e(TAG, "documentImageAnalyserStop" + e.getMessage()); + } + }); + return true; + } + case "ACTION_CLOSE_DOCUMENT_IMAGE_ANALYSER": + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("documentImageAnalyserClose"); + mlDocumentService.closeDocumentAnalyser(callbackContext); + return true; + case "ACTION_GET_DOCUMENT_IMAGE_ANALYSER_SETTING": + HMSLogger.getInstance(cordova.getContext()) + .startMethodExecutionTimer("documentImageAnalyserSetting"); + mlDocumentService.getDocumentAnalyserSetting(callbackContext); + return true; + case "ACTION_FORM_RECOGNITION": { + cordova.getThreadPool().execute(() -> { + HMSLogger.getInstance(cordova.getContext()) + .startMethodExecutionTimer("formRecognitionAnalyser"); + try { + formRecognitionAnalyser.initializeFormRecognitionAnalyser(params, callbackContext); + } catch (JSONException e) { + Log.i(TAG, "formRecognition :" + e.getMessage()); + } + }); + return true; + } + case "ACTION_FORM_RECOGNITION_STOP": { + cordova.getThreadPool().execute(() -> { + HMSLogger.getInstance(cordova.getContext()) + .startMethodExecutionTimer("formRecognitionAnalyserStop"); + try { + formRecognitionAnalyser.stop(callbackContext); + } catch (IOException e) { + Log.e(TAG, "formRecognitionStop :" + e.getMessage()); + } + }); + return true; + } + case "ACTION_BANK_CARD_DETECTOR": { + cordova.getThreadPool().execute(() -> { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("bankCardDetector"); + bcrAnalyse.initializerBCRAnalyser(params, callbackContext); + }); + return true; + } + case "ACTION_STOP_BANK_CARD_DETECTOR": + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("bankCardDetectorStop"); + bcrAnalyse.stopBankCardAnalyser(callbackContext, cordova); + return true; + case "ACTION_BANK_CARD_SET_RESULT_CALLBACK": + HMSLogger.getInstance(cordova.getContext()) + .startMethodExecutionTimer("bankCardDetectorResultCallback"); + bcrAnalyse.setOnBcrResultCallback(callbackContext); + return true; + case "ACTION_BANK_CARD_SET_RESULT_TYPE": + HMSLogger.getInstance(cordova.getContext()) + .startMethodExecutionTimer("bankCardDetectorSetResultType"); + bcrAnalyse.setResultType(callbackContext, params); + return true; + case "ACTION_BANK_CARD_SET_RECMODE": + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("bankCardDetectorRecMode"); + bcrAnalyse.setRecMode(callbackContext, params); + return true; + + case "ACTION_GET_BANK_CARD_SETTING": + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("bankCardDetectorSetting"); + bcrAnalyse.getBCRSetting(callbackContext); + return true; + case "ACTION_GENERALCARD_PLUGIN_DETECTOR": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("generalcardPluginDetector"); + generalCardAnalyse.initializeGeneralCardAnalyser(params, callbackContext); + return true; + } + case "ACTION_ICRVN_PLUGIN_DETECTOR": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("icrVnPluginDetector"); + icrVnCardAnalyser.initializeIcrVnCardAnalyser(params, callbackContext); + return true; + } + case "ACTION_ICRVN_CREATE": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("icrVnPluginCreate"); + icrVnCardAnalyser.create(callbackContext); + return true; + } + case "ACTION_ICRVN_CAPTURE": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("getIcrCapture()"); + icrVnCardAnalyser.getIcrVnCapture(callbackContext); + return true; + } + case "ACTION_ICRVN_GET_INSTANCE": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("getIcrCapture()"); + icrVnCardAnalyser.getInstance(callbackContext); + return true; + } + + case "ACTION_ICRCN_PLUGIN_DETECTOR": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("icrCnPluginDetector"); + mlIcrCnCardAnalyser.initializeIcrCnCardAnalyser(params, callbackContext); + return true; + } + case "ACTION_ICRCN_CAPTURE": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("getIcrCapture()"); + mlIcrCnCardAnalyser.getIcrCnCapture(callbackContext); + return true; + } + case "ACTION_ICRCN_CREATE": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("getIcrCreate()"); + mlIcrCnCardAnalyser.create(callbackContext); + return true; + } + case "ACTION_ICRCN_GET_INSTANCE": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("getIcrCapture()"); + mlIcrCnCardAnalyser.getInstance(callbackContext); + return true; + } + + case "ACTION_LOCAL_ANALYSER": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("localAnalyser"); + mlIcrCardAnalyser.initializeIcrCardAnalyser(params, callbackContext); + return true; + } + case "ACTION_LOCAL_ANALYSER_CREATE": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("localAnalyserCreate"); + mlIcrCardAnalyser.createIdCard(params, callbackContext); + return true; + } + case "ACTION_LOCAL_ANALYSER_STOP": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("localAnalyserStop"); + mlIcrCardAnalyser.stopIcrCard(callbackContext); + return true; + } + case "startCustomizedView": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("customViewMode"); + customViewHandler.startCustomizedView(params, callbackContext); + return true; + } + case "switchLight": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("switchLight"); + customViewHandler.switchLight(callbackContext); + return true; + } + case "getLightStatus": { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("getLightStatus"); + customViewHandler.getLightStatus(callbackContext); + return true; + } + default: + } + } catch (IOException | JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + + return false; + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent intent) { + if (resultCode != RESULT_OK) { + return; + } + if (resultCode == RESULT_OK) { + if (requestCode == REQUEST_CODE_SCAN_CUSTOMIZED) { + formatIdCardResult(intent); + } + } + } + + private void formatIdCardResult(Intent intent) { + + JSONObject jsonObject = new JSONObject(); + try { + jsonObject.putOpt("number", intent.getStringExtra("number")); + Bitmap originalBitmap = intent.getParcelableExtra("bitmap"); + Bitmap numberBitmap = intent.getParcelableExtra("numberBitmap"); + jsonObject.putOpt("expire", intent.getStringExtra("expire")); + jsonObject.putOpt("issuer", intent.getStringExtra("issuer")); + jsonObject.putOpt("type", intent.getStringExtra("type")); + jsonObject.putOpt("organization", intent.getStringExtra("organization")); + jsonObject.putOpt("originalBitmap", HMSMLUtils.bitmapToBase64(originalBitmap)); + jsonObject.putOpt("numberBitmap", HMSMLUtils.bitmapToBase64(numberBitmap)); + getCallbackContext().success(jsonObject); + HMSLogger.getInstance(cordova.getContext()).sendSingleEvent("bankCardDetector"); + } catch (JSONException e) { + getCallbackContext().error(e.getMessage()); + HMSLogger.getInstance(cordova.getContext()).sendSingleEvent("bankCardDetector", e.getMessage()); + } + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/HMSMLTextPlugin.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/HMSMLTextPlugin.java new file mode 100644 index 00000000..e97fc6a4 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/HMSMLTextPlugin.java @@ -0,0 +1,171 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext; + +import android.util.Log; + +import com.huawei.hms.cordova.mltext.common.MLHMSAnalyzer; +import com.huawei.hms.cordova.mltext.common.MLHMSApplication; +import com.huawei.hms.cordova.mltext.common.MLHMSFrame; +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.mlsdk.common.MLApplication; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.CordovaWebView; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +public class HMSMLTextPlugin extends CordovaPlugin { + private static final String TAG = HMSMLTextPlugin.class.getSimpleName(); + + private static CallbackContext callbackCtx; + + List permissionLists = new ArrayList<>(); + + private CordovaInterface cordovaInterface; + + private CallbackContext callbackContext; + + private MLHMSApplication mlhmsApplication; + + private MLHMSAnalyzer mlhmsAnalyzer; + + private MLHMSFrame mlhmsFrame; + + private boolean isStart = false; + + public static CallbackContext getCallbackContext() { + return callbackCtx; + } + + public static void setCallbackContext(final CallbackContext callbackContext) { + callbackCtx = callbackContext; + } + + public void initialize(CordovaInterface cordova, CordovaWebView webView) { + super.initialize(cordova, webView); + } + + public void pluginInitialize() { + mlhmsApplication = CordovaHelpers.initializeProvider(new MLHMSApplication(cordova.getContext()), cordova, this); + mlhmsAnalyzer = CordovaHelpers.initializeProvider(new MLHMSAnalyzer(cordova.getContext()), cordova, this); + mlhmsFrame = CordovaHelpers.initializeProvider(new MLHMSFrame(cordova.getContext()), cordova, this); + } + + public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) { + this.cordovaInterface = cordova; + this.callbackContext = callbackContext; + setCallbackContext(callbackContext); + permissionLists.add("camera"); + permissionLists.add("readExternalStorage"); + permissionLists.add("writeExternalStorage"); + permissionLists.add("audio"); + JSONObject params = args.optJSONObject(0); + JSONObject userProps = args.optJSONObject(1); + Log.i(TAG, "actionName:" + action); + try { + if (action.equals("HMSMLKIT_INITILALIZER")) { + cordovaInterface.getThreadPool().execute(() -> { + try { + mlKitInitializer(params); + } catch (JSONException e) { + Log.e(TAG, "execute: error ->" + e.getMessage()); + } + }); + return true; + } + if (action.equals("ACTION_APP_SETTING")) { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("appSetting"); + mlhmsApplication.applicationSetting(params, callbackContext); + return true; + } + if (action.equals("ACTION_MLANALYSER_SETSTATISTIC")) { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("mlAnalyzerSetStatistic"); + mlhmsAnalyzer.setStatisticsAllowed(params, callbackContext); + return true; + } + if (action.equals("ACTION_MLANALYSER_GETSTATISTIC")) { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("mlAnalyzergetStatistic"); + mlhmsAnalyzer.getStatisticsAllowed(callbackContext); + return true; + } + if (action.equals("ACTION_MLFRAME")) { + HMSLogger.getInstance(cordova.getContext()).startMethodExecutionTimer("mlFrameAnalyser"); + mlhmsFrame.initializeMLFrame(params, callbackContext); + return true; + } + + if (action.equals("enableLogger")) { + enableLogger(callbackContext); + return true; + } + if (action.equals("disableLogger")) { + disableLogger(callbackContext); + return true; + } + if (action.equals("setUserRegion")) { + mlhmsApplication.setUserRegion(params, callbackContext); + return true; + } + if (action.equals("getCountryCode")) { + mlhmsApplication.getCountryCode(callbackContext); + return true; + } + } catch (JSONException e) { + Log.e(TAG, "execute ->" + e.getMessage()); + } + return false; + } + + public void mlKitInitializer(final JSONObject config) throws JSONException { + HMSLogger.getInstance(cordovaInterface.getContext()).startMethodExecutionTimer("mlKitInitializer"); + + if ((!config.has("apiKey") || config.isNull("apiKey")) && (!config.has("accessToken") || config.isNull( + "accessToken"))) { + callbackContext.error( + "Illegal argument. apiKey or accessToken field is mandatory and it must not be null."); + HMSLogger.getInstance(cordovaInterface.getContext()).sendSingleEvent("mlKitInitializer", "-1"); + return; + } + if (config.has("apiKey")) { + MLApplication.getInstance().setApiKey(config.getString("apiKey")); + HMSLogger.getInstance(cordovaInterface.getContext()).sendSingleEvent("mlKitInitializer"); + } + if (config.has("accessToken")) { + MLApplication.getInstance().setAccessToken(config.getString("accessToken")); + HMSLogger.getInstance(cordovaInterface.getContext()).sendSingleEvent("mlKitInitializer"); + } + } + + public void enableLogger(final CallbackContext callbackContext) { + HMSLogger.getInstance(cordovaInterface.getContext()).enableLogger(); + callbackContext.success(); + } + + public void disableLogger(final CallbackContext callbackContext) { + HMSLogger.getInstance(cordovaInterface.getContext()).disableLogger(); + callbackContext.success(); + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/camera/GraphicOverlay.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/camera/GraphicOverlay.java new file mode 100644 index 00000000..0db1f470 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/camera/GraphicOverlay.java @@ -0,0 +1,180 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.camera; + +import android.content.Context; +import android.graphics.Canvas; +import android.util.AttributeSet; +import android.view.View; + +import com.huawei.hms.mlsdk.common.LensEngine; + +import java.util.HashSet; +import java.util.Set; + +public class GraphicOverlay extends View { + private final Object mLock = new Object(); + + private int mPreviewWidth; + + private float mWidthScaleFactor = 1.0f; + + private int mPreviewHeight; + + private float mHeightScaleFactor = 1.0f; + + private int mFacing = LensEngine.BACK_LENS; + + private Set mGraphics = new HashSet<>(); + + public GraphicOverlay(Context context, AttributeSet attrs) { + super(context, attrs); + } + + /** + * Removes all graphics from the overlay. + */ + public void clear() { + synchronized (mLock) { + mGraphics.clear(); + } + postInvalidate(); + } + + /** + * Adds a graphic to the overlay. + */ + public void add(Graphic graphic) { + synchronized (mLock) { + mGraphics.add(graphic); + } + postInvalidate(); + } + + /** + * Removes a graphic from the overlay. + */ + public void remove(Graphic graphic) { + synchronized (mLock) { + mGraphics.remove(graphic); + } + postInvalidate(); + } + + /** + * Sets the camera attributes for size and facing direction, which informs how to transform image coordinates + * later. + */ + public void setCameraInfo(int previewWidth, int previewHeight, int facing) { + synchronized (mLock) { + mPreviewWidth = previewWidth; + mPreviewHeight = previewHeight; + mFacing = facing; + } + postInvalidate(); + } + + /** + * Draws the overlay with its associated graphic objects. + */ + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + synchronized (mLock) { + if ((mPreviewWidth != 0) && (mPreviewHeight != 0)) { + mWidthScaleFactor = (float) canvas.getWidth() / (float) mPreviewWidth; + mHeightScaleFactor = (float) canvas.getHeight() / (float) mPreviewHeight; + } + + for (Graphic graphic : mGraphics) { + graphic.draw(canvas); + } + } + } + + /** + * Base class for a custom graphics object to be rendered within the graphic overlay. Subclass this and implement + * the {@link Graphic#draw(Canvas)} method to define the graphics element. Add instances to the overlay using {@link + * GraphicOverlay#add(Graphic)}. + */ + public static abstract class Graphic { + private GraphicOverlay mOverlay; + + public Graphic(GraphicOverlay overlay) { + mOverlay = overlay; + } + + /** + * Draw the graphic on the supplied canvas. Drawing should use the following methods to convert to view + * coordinates for the graphics that are drawn: + *
    + *
  1. {@link Graphic#scaleX(float)} and {@link Graphic#scaleY(float)} adjust the size of + * the supplied value from the preview scale to the view scale.
  2. + *
  3. {@link Graphic#translateX(float)} and {@link Graphic#translateY(float)} adjust the + * coordinate from the preview's coordinate system to the view coordinate system.
  4. + *
+ * + * @param canvas drawing canvas + */ + public abstract void draw(Canvas canvas); + + /** + * Adjusts a horizontal value of the supplied value from the preview scale to the view scale. + */ + public float scaleX(float horizontal) { + return horizontal * mOverlay.mWidthScaleFactor; + } + + public float unScaleX(float horizontal) { + return horizontal / mOverlay.mWidthScaleFactor; + } + + /** + * Adjusts a vertical value of the supplied value from the preview scale to the view scale. + */ + public float scaleY(float vertical) { + return vertical * mOverlay.mHeightScaleFactor; + } + + public float unScaleY(float vertical) { + return vertical / mOverlay.mHeightScaleFactor; + } + + /** + * Adjusts the x coordinate from the preview's coordinate system to the view coordinate system. + */ + public float translateX(float x) { + if (mOverlay.mFacing == LensEngine.FRONT_LENS) { + return mOverlay.getWidth() - scaleX(x); + } else { + return scaleX(x); + } + } + + /** + * Adjusts the y coordinate from the preview's coordinate system to the view coordinate system. + */ + public float translateY(float y) { + return scaleY(y); + } + + public void postInvalidate() { + mOverlay.postInvalidate(); + } + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/camera/LensEnginePreview.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/camera/LensEnginePreview.java new file mode 100644 index 00000000..87177ef7 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/camera/LensEnginePreview.java @@ -0,0 +1,192 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.camera; + +import android.content.Context; +import android.content.res.Configuration; +import android.util.AttributeSet; +import android.util.Log; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.ViewGroup; + +import com.huawei.hms.common.size.Size; +import com.huawei.hms.mlsdk.common.LensEngine; + +import java.io.IOException; + +public class LensEnginePreview extends ViewGroup { + private static final String TAG = LensEnginePreview.class.getSimpleName(); + + private Context mContext; + + private SurfaceView mSurfaceView; + + private boolean mStartRequested; + + private boolean mSurfaceAvailable; + + private LensEngine mLensEngine; + + private GraphicOverlay mOverlay; + + public LensEnginePreview(final Context context, final AttributeSet attrs) { + super(context, attrs); + this.mContext = context; + this.mStartRequested = false; + this.mSurfaceAvailable = false; + + this.mSurfaceView = new SurfaceView(context); + this.mSurfaceView.getHolder().addCallback(new SurfaceCallback()); + this.addView(this.mSurfaceView); + } + + public void start(final LensEngine lensEngine) throws IOException { + if (lensEngine == null) { + this.stop(); + } + + this.mLensEngine = lensEngine; + + if (this.mLensEngine != null) { + this.mStartRequested = true; + this.startIfReady(); + } + } + + public void start(final LensEngine lensEngine, final GraphicOverlay overlay) throws IOException { + this.mOverlay = overlay; + this.start(lensEngine); + } + + public void stop() { + if (this.mLensEngine != null) { + this.mLensEngine.close(); + } + } + + public void release() { + if (this.mLensEngine != null) { + this.mLensEngine.release(); + this.mLensEngine = null; + } + } + + private void startIfReady() throws IOException { + if (this.mStartRequested && this.mSurfaceAvailable) { + this.mLensEngine.run(this.mSurfaceView.getHolder()); + if (this.mOverlay != null) { + Size size = this.mLensEngine.getDisplayDimension(); + int min = Math.min(size.getWidth(), size.getHeight()); + int max = Math.max(size.getWidth(), size.getHeight()); + if (this.isPortraitMode()) { + this.mOverlay.setCameraInfo(min, max, this.mLensEngine.getLensType()); + } else { + this.mOverlay.setCameraInfo(max, min, this.mLensEngine.getLensType()); + } + this.mOverlay.clear(); + } + this.mStartRequested = false; + } + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + int previewWidth = 480; + int previewHeight = 360; + if (this.mLensEngine != null) { + Size size = this.mLensEngine.getDisplayDimension(); + if (size != null) { + previewWidth = size.getWidth(); + previewHeight = size.getHeight(); + } + } + + if (this.isPortraitMode()) { + int tmp = previewWidth; + previewWidth = previewHeight; + previewHeight = tmp; + } + + final int viewWidth = right - left; + final int viewHeight = bottom - top; + + int childWidth; + int childHeight; + int childXOffset = 0; + int childYOffset = 0; + float widthRatio = (float) viewWidth / (float) previewWidth; + float heightRatio = (float) viewHeight / (float) previewHeight; + + if (widthRatio > heightRatio) { + childWidth = viewWidth; + childHeight = (int) ((float) previewHeight * widthRatio); + childYOffset = (childHeight - viewHeight) / 2; + } else { + childWidth = (int) ((float) previewWidth * heightRatio); + childHeight = viewHeight; + childXOffset = (childWidth - viewWidth) / 2; + } + + for (int i = 0; i < this.getChildCount(); ++i) { + + this.getChildAt(i) + .layout(-1 * childXOffset, -1 * childYOffset, childWidth - childXOffset, childHeight - childYOffset); + } + + try { + this.startIfReady(); + } catch (IOException e) { + Log.e(LensEnginePreview.TAG, "Could not start camera source.", e); + } + } + + private boolean isPortraitMode() { + int orientation = this.mContext.getResources().getConfiguration().orientation; + if (orientation == Configuration.ORIENTATION_LANDSCAPE) { + return false; + } + if (orientation == Configuration.ORIENTATION_PORTRAIT) { + return true; + } + + Log.d(LensEnginePreview.TAG, "isPortraitMode returning false by default"); + return false; + } + + private class SurfaceCallback implements SurfaceHolder.Callback { + @Override + public void surfaceCreated(SurfaceHolder surface) { + LensEnginePreview.this.mSurfaceAvailable = true; + try { + LensEnginePreview.this.startIfReady(); + } catch (IOException e) { + Log.e(LensEnginePreview.TAG, "Could not start camera source.", e); + } + } + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + } + + @Override + public void surfaceDestroyed(SurfaceHolder surface) { + LensEnginePreview.this.mSurfaceAvailable = false; + } + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/common/MLHMSAnalyzer.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/common/MLHMSAnalyzer.java new file mode 100644 index 00000000..37654900 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/common/MLHMSAnalyzer.java @@ -0,0 +1,47 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.common; + +import android.content.Context; + +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.mlsdk.MLAnalyzerFactory; + +import org.apache.cordova.CallbackContext; +import org.json.JSONObject; + +public class MLHMSAnalyzer extends HMSProvider { + private static String TAG = MLHMSAnalyzer.class.getSimpleName(); + + public MLHMSAnalyzer(Context ctx) { + super(ctx); + } + + public void setStatisticsAllowed(JSONObject params, final CallbackContext callbackContext) { + boolean isAllowed = params.optBoolean("isAllowed", false); + MLAnalyzerFactory.getInstance().setStatisticsAllowed(isAllowed); + callbackContext.success("statisticsAllowed:" + isAllowed); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlAnalyzerSetStatistic"); + + } + + public void getStatisticsAllowed(final CallbackContext callbackContext) { + callbackContext.success("statisticsAllowed:" + MLAnalyzerFactory.getInstance().isStatisticsAllowed()); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlAnalyzerGetStatistic"); + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/common/MLHMSApplication.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/common/MLHMSApplication.java new file mode 100644 index 00000000..47a2bbbb --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/common/MLHMSApplication.java @@ -0,0 +1,71 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.common; + +import android.content.Context; + +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.utils.TextUtils; +import com.huawei.hms.mlsdk.common.MLApplication; +import com.huawei.hms.mlsdk.common.MLApplicationSetting; + +import org.apache.cordova.CallbackContext; +import org.json.JSONException; +import org.json.JSONObject; + +public class MLHMSApplication extends HMSProvider { + + public MLHMSApplication(Context ctx) { + super(ctx); + } + + public void applicationSetting(final JSONObject params, final CallbackContext callbackContext) + throws JSONException { + JSONObject applicationSetting = params.optJSONObject("mlApplicationSetting"); + String apiKey; + String applicationId; + String certFingerprint; + MLApplicationSetting mlApplicationSetting = null; + if (applicationSetting != null) { + apiKey = params.optString("apiKey"); + applicationId = params.optString("applicationId"); + certFingerprint = params.optString("certFingerprint"); + mlApplicationSetting = new MLApplicationSetting.Factory().setApiKey(apiKey) + .setApplicationId(applicationId) + .setCertFingerprint(certFingerprint) + .create(); + } else { + mlApplicationSetting = new MLApplicationSetting.Factory().create(); + } + callbackContext.success(TextUtils.getApplicationSetting(mlApplicationSetting)); + HMSLogger.getInstance(getContext()).sendSingleEvent("appSetting"); + + } + + public void getCountryCode(final CallbackContext callbackContext) { + String countryCode = MLApplication.getInstance().getCountryCode(); + callbackContext.success(countryCode); + } + + public void setUserRegion(final JSONObject params, final CallbackContext callbackContext) { + int region = params.optInt("region"); + MLApplication.getInstance().setUserRegion(region); + callbackContext.success(); + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/common/MLHMSFrame.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/common/MLHMSFrame.java new file mode 100644 index 00000000..4d4092c7 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/common/MLHMSFrame.java @@ -0,0 +1,81 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.common; + +import android.content.Context; + +import com.huawei.hms.cordova.mltext.helpers.CordovaErrors; +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; +import com.huawei.hms.mlsdk.common.MLFrame; + +import org.apache.cordova.CallbackContext; +import org.json.JSONException; +import org.json.JSONObject; + +public class MLHMSFrame extends HMSProvider { + private static final String TAG = MLHMSFrame.class.getSimpleName(); + + private CallbackContext callbackContext; + + private MLFrame frame; + + public MLHMSFrame(Context ctx) { + super(ctx); + } + + public void initializeMLFrame(final JSONObject params, final CallbackContext callbackContext) throws JSONException { + String actionName = params.getString("actionName"); + this.callbackContext = callbackContext; + this.frame = HMSMLUtils.getFrame(getContext(), params); + + CordovaHelpers.frameController(frame, getContext(), callbackContext, "initializeMLFrame"); + switch (actionName) { + case "getPreviewBitmap": + getPreviewBitmap(); + break; + case "readBitmap": + readBitmap(); + break; + case "rotate": + rotate(params); + break; + default: + callbackContext.error(CordovaErrors.ILLEGAL_PARAMETER); + break; + } + } + + private void getPreviewBitmap() { + callbackContext.success(HMSMLUtils.bitmapToBase64(frame.getPreviewBitmap())); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlFrameAnalyser"); + } + + private void readBitmap() { + callbackContext.success(HMSMLUtils.bitmapToBase64(frame.readBitmap())); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlFrameAnalyser"); + } + + private void rotate(final JSONObject params) throws JSONException { + int quadrant = params.getInt("quadrant"); + callbackContext.success(HMSMLUtils.bitmapToBase64(frame.rotate(frame.readBitmap(), quadrant))); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlFrameAnalyser"); + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/helpers/CordovaErrors.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/helpers/CordovaErrors.java new file mode 100644 index 00000000..a15bc4e6 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/helpers/CordovaErrors.java @@ -0,0 +1,119 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.helpers; + +import android.util.Log; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +public class CordovaErrors { + + public static final int UNKNOWN = -1; + + public static final int SUCCESS = 0; + + public static final int DISCARDED = 1; + + public static final int INNER = 2; + + public static final int INACTIVE = 3; + + public static final int NOT_SUPPORTED = 4; + + public static final int ILLEGAL_PARAMETER = 5; + + public static final int OVERDUE = 6; + + public static final int NO_FOUND = 7; + + public static final int DUPLICATE_FOUND = 8; + + public static final int NO_PERMISSION = 9; + + public static final int INSUFFICIENT_RESOURCE = 10; + + public static final int ANALYSIS_FAILURE = 11; + + public static final int INTERRUPTED = 12; + + public static final int EXCEED_RANGE = 13; + + public static final int DATA_MISSING = 14; + + public static final int AUTHENTICATION_REQUIRED = 15; + + public static final int TFLITE_NOT_COMPATIBLE = 16; + + public static final int INSUFFICIENT_SPACE = 17; + + public static final int HASH_MISS = 18; + + public static final int TOKEN_INVALID = 19; + + public static final int SERVICE_FAILURE = 20; + + public static final int ANALYSIS_NULL = 21; + + static final Map ERROR_MSGS = new HashMap<>(); + + static { + + ERROR_MSGS.put(UNKNOWN, "UNKNOWN Error"); + ERROR_MSGS.put(SUCCESS, "Succesed"); + ERROR_MSGS.put(DISCARDED, "Operation canceled."); + ERROR_MSGS.put(INNER, "Internal error."); + ERROR_MSGS.put(INACTIVE, "Service unavailable."); + ERROR_MSGS.put(NOT_SUPPORTED, "Operation not supported."); + ERROR_MSGS.put(ILLEGAL_PARAMETER, "Incorrect parameter. This exception is irrelevant to services."); + ERROR_MSGS.put(OVERDUE, "Operation timed out."); + ERROR_MSGS.put(NO_FOUND, "Requested resource not found or not exist."); + ERROR_MSGS.put(DUPLICATE_FOUND, "Resource created repeatedly."); + ERROR_MSGS.put(NO_PERMISSION, "No operation permission."); + ERROR_MSGS.put(INSUFFICIENT_RESOURCE, + "Resources exhausted. The system resources or resources of the current user may be insufficient."); + ERROR_MSGS.put(ANALYSIS_FAILURE, "Operation failed because the system was not ready."); + ERROR_MSGS.put(INTERRUPTED, "Operation interrupted, possibly due to concurrent operations."); + ERROR_MSGS.put(EXCEED_RANGE, "Out-of-bounds access."); + ERROR_MSGS.put(DATA_MISSING, "Unrecoverable data damage or loss."); + ERROR_MSGS.put(AUTHENTICATION_REQUIRED, "Identity authentication required."); + ERROR_MSGS.put(TFLITE_NOT_COMPATIBLE, "Downloaded model incompatible with the running model."); + ERROR_MSGS.put(INSUFFICIENT_SPACE, "Insufficient disk space."); + ERROR_MSGS.put(HASH_MISS, "Unexpected hash value of the downloaded model."); + ERROR_MSGS.put(TOKEN_INVALID, "Invalid token."); + ERROR_MSGS.put(SERVICE_FAILURE, "Service failed."); + ERROR_MSGS.put(ANALYSIS_NULL, "Null analyser"); + } + + public CordovaErrors() { + } + + public static JSONObject toErrorJSON(int errorCode) { + try { + return new JSONObject().put("errorCode", errorCode).put("errorMessage", ERROR_MSGS.get(errorCode)); + } catch (JSONException e) { + Log.e("toErrorJSON get error: ", Objects.requireNonNull(e.getMessage())); + } + return new JSONObject(); + } +} + + diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/helpers/CordovaHelpers.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/helpers/CordovaHelpers.java new file mode 100644 index 00000000..2da9a2ad --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/helpers/CordovaHelpers.java @@ -0,0 +1,81 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.helpers; + +import android.content.Context; +import android.util.Log; + +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.mlsdk.common.MLFrame; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.CordovaWebViewEngine; +import org.json.JSONObject; + +public class CordovaHelpers { + private static String TAG = CordovaHelpers.class.getSimpleName(); + + public static void sendEvent(final CordovaPlugin plugin, final String eventName, final JSONObject params) { + runJS(plugin, "hmsEventHandler('" + eventName + "', " + params.toString() + ");"); + } + + public static void runJS(final CordovaPlugin plugin, final String jsCode) { + runJS(plugin, jsCode, null); + } + + public static void runJS(final CordovaPlugin plugin, final String jsCode, Runnable onFinished) { + Log.d(TAG, "runJS()"); + + plugin.cordova.getActivity().runOnUiThread(() -> { + CordovaWebViewEngine engine = plugin.webView.getEngine(); + if (engine == null) { + plugin.webView.loadUrl("javascript:" + jsCode); + if (onFinished != null) { + onFinished.run(); + } + } else { + engine.evaluateJavascript(jsCode, (result) -> { + if (onFinished != null) { + onFinished.run(); + } + }); + } + }); + } + + public static T initializeProvider(T provider, CordovaInterface cordova, + CordovaPlugin plugin) { + provider.setActivityHolder(cordova::getActivity); + provider.setCordovaPlugin(plugin); + + return provider; + } + + + + public static void frameController(MLFrame frame, Context context, CallbackContext callbackContext, String name) { + if (frame == null) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ILLEGAL_PARAMETER)); + HMSLogger.getInstance(context).sendSingleEvent(name, String.valueOf(CordovaErrors.ILLEGAL_PARAMETER)); + return; + } + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/interfaces/ActivityHolder.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/interfaces/ActivityHolder.java new file mode 100644 index 00000000..cd50eb2e --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/interfaces/ActivityHolder.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.interfaces; + +import android.app.Activity; + +public interface ActivityHolder { + /** + * Returns the current activity. + * + * @return Activity + */ + Activity getActivity(); +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/interfaces/HMSProvider.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/interfaces/HMSProvider.java new file mode 100644 index 00000000..f9fff1d6 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/interfaces/HMSProvider.java @@ -0,0 +1,57 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.interfaces; + +import android.app.Activity; +import android.content.Context; + +import org.apache.cordova.CordovaPlugin; + +public abstract class HMSProvider { + private Context ctx; + + private ActivityHolder activityHolder; + + private CordovaPlugin cordovaPlugin; + + public HMSProvider(Context ctx) { + this.ctx = ctx; + } + + public CordovaPlugin getCordovaPlugin() { + return cordovaPlugin; + } + + public void setCordovaPlugin(CordovaPlugin cordovaPlugin) { + this.cordovaPlugin = cordovaPlugin; + } + + public Activity getActivity() { + if (this.activityHolder == null) { + return null; + } + return this.activityHolder.getActivity(); + } + + public Context getContext() { + return this.ctx; + } + + public void setActivityHolder(ActivityHolder activityHolder) { + this.activityHolder = activityHolder; + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/interfaces/JSONMapper.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/interfaces/JSONMapper.java new file mode 100644 index 00000000..54857d8c --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/interfaces/JSONMapper.java @@ -0,0 +1,30 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.interfaces; + +import org.json.JSONException; + +public interface JSONMapper { + /** + * A simple transformation operation. + * + * @param in T + * @return R + * @throws JSONException + */ + R map(T in) throws JSONException; +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/logger/HMSLogger.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/logger/HMSLogger.java new file mode 100644 index 00000000..adc22cd5 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/logger/HMSLogger.java @@ -0,0 +1,443 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.logger; + +import static android.os.Build.DEVICE; + +import android.content.Context; +import android.content.pm.PackageManager; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.util.Log; + +import com.huawei.agconnect.config.AGConnectServicesConfig; +import com.huawei.hms.support.hianalytics.HiAnalyticsUtils; +import com.huawei.hms.utils.HMSBIInitializer; + +import java.lang.ref.WeakReference; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public final class HMSLogger { + private static final String TAG = "HMSLogger"; + + private static final String KIT = "ML"; + + private static final String PLATFORM = "Cordova"; + + private static final String VERSION = "2.0.5.303"; + + private static final String SERVICE = "Cross-Platform"; + + private static final String SUCCESS = "0"; + + private static final String UNKNOWN = "UNKNOWN"; + + private static final String NOT_AVAILABLE = "NOT_AVAILABLE"; + + private static final String SINGLE_EVENT_ID = "60000"; + + private static final String PERIODIC_EVENT_ID = "60001"; + + private static final String NETWORK_TYPE_WIFI = "WIFI"; + + private static volatile HMSLogger instance; + + private final WeakReference weakContext; + + private final HiAnalyticsUtils hiAnalyticsUtils; + + private final ConnectivityManager connectivityManager; + + private final Map singleEventMap = new HashMap<>(); + + private final Map periodicEventMap = new HashMap<>(); + + private final Map allCountMap = new HashMap<>(); + + private final Map failCountMap = new HashMap<>(); + + private final Map startTimeMap = new HashMap<>(); + + private final Map firstReceiveTimeMap = new HashMap<>(); + + private final Map lastReceiveTimeMap = new HashMap<>(); + + private final Map> resultCodeCountMap = new HashMap<>(); + + private final Map networkTypeMap = createNetworkTypeMap(); + + private boolean isEnabled = false; + + /** + * Private constructor of this class. + * + * @param context Application's context + */ + private HMSLogger(final Context context) { + weakContext = new WeakReference<>(context); + hiAnalyticsUtils = HiAnalyticsUtils.getInstance(); + connectivityManager = objectCast(context.getSystemService(Context.CONNECTIVITY_SERVICE), + ConnectivityManager.class); + + hiAnalyticsUtils.enableLog(); + HMSBIInitializer.getInstance(context).initBI(); + setupEventMap(singleEventMap); + setupEventMap(periodicEventMap); + enableLogger(); + } + + /** + * Returns the instance of this class. + * + * @param context Context object + * @return HMSLogger instance + */ + public static synchronized HMSLogger getInstance(final Context context) { + if (instance == null) { + synchronized (HMSLogger.class) { + if (instance == null) { + instance = new HMSLogger(context.getApplicationContext()); + } + } + } + return instance; + } + + /** + * Returns actual context reference. + * + * @return Actual context reference + */ + private synchronized Context getContext() { + return weakContext.get(); + } + + /** + * Enables HMSLogger. + */ + public synchronized void enableLogger() { + isEnabled = true; + Log.d(TAG, "HMS Plugin Dotting is Enabled!"); + } + + /** + * Disables HMSLogger. + */ + public synchronized void disableLogger() { + isEnabled = false; + Log.d(TAG, "HMS Plugin Dotting is Disabled!"); + } + + /** + * Sets method start time for given method name. + * + * @param methodName Name of the method that will be logged + */ + public synchronized void startMethodExecutionTimer(final String methodName) { + startTimeMap.put(methodName, System.currentTimeMillis()); + } + + /** + * Sends successful single event. + * + * @param methodName The name of the method called + */ + public synchronized void sendSingleEvent(final String methodName) { + sendEvent(SINGLE_EVENT_ID, methodName, SUCCESS); + } + + /** + * Sends unsuccessful single event + * + * @param methodName The name of the method called. + * @param errorCode API error code + */ + public synchronized void sendSingleEvent(final String methodName, final String errorCode) { + sendEvent(SINGLE_EVENT_ID, methodName, errorCode); + } + + /** + * Sends successful periodic event. + * + * @param methodName The name of the method called + */ + public synchronized void sendPeriodicEvent(final String methodName) { + sendEvent(PERIODIC_EVENT_ID, methodName, SUCCESS); + } + + /** + * Sends unsuccessful periodic event. + * + * @param methodName The name of the method called + * @param errorCode API error code + */ + public synchronized void sendPeriodicEvent(final String methodName, final String errorCode) { + sendEvent(PERIODIC_EVENT_ID, methodName, errorCode); + } + + /** + * Sends the event based on eventId, methodName, and resultCode. + * + * @param eventId Constant id of the event + * @param methodName The name of the method called + * @param resultCode Code of the method's result. "0" for success, others for error + */ + private synchronized void sendEvent(final String eventId, final String methodName, final String resultCode) { + if (isEnabled) { + final long currentTime = System.currentTimeMillis(); + + if (eventId.equals(SINGLE_EVENT_ID)) { + putToSingleEventMap(methodName, resultCode, currentTime); + hiAnalyticsUtils.onNewEvent(getContext(), SINGLE_EVENT_ID, singleEventMap); + + Log.d(TAG, "singleEventMap -> " + singleEventMap); + } else { + putToPeriodicEventMap(methodName, resultCode, currentTime); + hiAnalyticsUtils.onNewEvent(getContext(), PERIODIC_EVENT_ID, periodicEventMap); + + Log.d(TAG, "periodicEventMap -> " + periodicEventMap); + } + } + } + + /** + * Gets "client/app_id" value from agconnect-services.json file. + * + * @return app_id value or NOT_AVAILABLE if not found + */ + private synchronized String getAppId() { + try { + return AGConnectServicesConfig.fromContext(getContext()).getString("client/app_id"); + } catch (final NullPointerException e) { + Log.d(TAG, "AgConnect is not found. Setting appId value to " + NOT_AVAILABLE); + } + return NOT_AVAILABLE; + } + + /** + * Gets app version name. + * + * @param packageName Package name of the app + * @return App version name in String type + */ + private synchronized String getAppVersionName(final String packageName) { + try { + return getContext().getPackageManager().getPackageInfo(packageName, 0).versionName; + } catch (final PackageManager.NameNotFoundException e) { + Log.e(TAG, "getAppVersionName -> Could not get appVersionName!"); + return NOT_AVAILABLE; + } + } + + /** + * Detects current network type. + * + * @return Human readable network type; such as WIFI, 4G + */ + private synchronized String getNetworkType() { + if (connectivityManager != null) { + final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); + if (networkInfo != null && networkInfo.isConnected()) { + final int networkType = networkInfo.getType(); + if (ConnectivityManager.TYPE_WIFI == networkType) { + return NETWORK_TYPE_WIFI; + } else if (ConnectivityManager.TYPE_MOBILE == networkType) { + final int networkSubType = networkInfo.getSubtype(); + return getOrDefault(networkTypeMap, networkSubType, UNKNOWN); + } else { + return UNKNOWN; + } + } else { + return NOT_AVAILABLE; + } + } else { + return NOT_AVAILABLE; + } + } + + /** + * Sets default values to given map. + * + * @param map HashMap to put default values + */ + private synchronized void setupEventMap(final Map map) { + map.put("kit", KIT); + map.put("platform", PLATFORM); + map.put("version", VERSION); + map.put("service", SERVICE); + map.put("appid", getAppId()); + map.put("package", getContext().getPackageName()); + map.put("cpAppVersion", getAppVersionName(getContext().getPackageName())); + map.put("model", DEVICE); + } + + /** + * Prepares sing-event map according to input parameters. + * + * @param methodName The name of the method called + * @param resultCode Code of the method's result. "0" for success, others for error + * @param currentTime Current timestamp in millisecond + */ + private synchronized void putToSingleEventMap(final String methodName, final String resultCode, + final long currentTime) { + final long startTime = getOrDefault(startTimeMap, methodName, currentTime); + final int costTime = (int) (currentTime - startTime); + singleEventMap.put("apiName", methodName); + singleEventMap.put("result", resultCode); + singleEventMap.put("callTime", currentTime); + singleEventMap.put("costTime", costTime); + singleEventMap.put("networkType", getNetworkType()); + } + + /** + * Prepares periodic-event map according to input parameters. + * + * @param methodName The name of the method called + * @param resultCode Code of the method's result. "0" for success, others for error + * @param currentTime Current timestamp in millisecond + */ + private synchronized void putToPeriodicEventMap(final String methodName, final String resultCode, + final long currentTime) { + increaseResultCodeCount(methodName, resultCode); + increaseMapValue(methodName, allCountMap); + + if (!resultCode.equals(SUCCESS)) { + increaseMapValue(methodName, failCountMap); + } + + final long firstReceiveTime = getOrDefault(firstReceiveTimeMap, methodName, currentTime); + periodicEventMap.put("callTime", firstReceiveTime); + + final long lastReceiveTime = getOrDefault(lastReceiveTimeMap, methodName, currentTime); + final int costTime = (int) (currentTime - lastReceiveTime); + periodicEventMap.put("costTime", costTime); + + periodicEventMap.put("apiName", methodName); + periodicEventMap.put("result", resultCodeCountMap.get(methodName)); + + final long allCount = getOrDefault(allCountMap, methodName, 0L); + periodicEventMap.put("allCnt", allCount); + + final long failCount = getOrDefault(failCountMap, methodName, 0L); + periodicEventMap.put("failCnt", failCount); + + periodicEventMap.put("lastCallTime", currentTime); + periodicEventMap.put("networkType", getNetworkType()); + + putIfAbsent(firstReceiveTimeMap, methodName, currentTime); + lastReceiveTimeMap.put(methodName, currentTime); + } + + /** + * Prepares HashMap of network type id and its human-readable string pairs. + * + * @return HashMap of human readable network type names + */ + private synchronized Map createNetworkTypeMap() { + final Map map = new HashMap<>(); + map.put(0, UNKNOWN); + map.put(1, "2G"); + map.put(2, "2G"); + map.put(3, "3G"); + map.put(4, "3G"); + map.put(5, "3G"); + map.put(6, "3G"); + map.put(7, "2G"); + map.put(8, "3G"); + map.put(9, "3G"); + map.put(10, "3G"); + map.put(11, "2G"); + map.put(12, "3G"); + map.put(13, "4G"); + map.put(14, "3G"); + map.put(15, "3G"); + map.put(16, "2G"); + map.put(17, "3G"); + map.put(18, "4G"); + map.put(19, "4G"); + map.put(20, "5G"); + + return Collections.unmodifiableMap(map); + } + + /** + * Increases count of the given result code. + * + * @param methodName Name of the calling method + * @param resultCode Code of the method's result. "0" for success, others for error + */ + private synchronized void increaseResultCodeCount(final String methodName, final String resultCode) { + final Map map = getOrDefault(resultCodeCountMap, methodName, new HashMap<>()); + + increaseMapValue(resultCode, map); + resultCodeCountMap.put(methodName, map); + } + + /** + * Increases the value of the corresponding key which in the map. + * + * @param key Key for map lookup + * @param map The Map that contains the key and its corresponding value + */ + private synchronized void increaseMapValue(final String key, final Map map) { + map.put(key, getOrDefault(map, key, 0L) + 1); + } + + /** + * Get the corresponding value of the key. If the key does not exist in the map then the default value is returned. + * + * @param map The Map + * @param key Lookup key + * @param defaultValue The default value will be returned if the key is absent + * @param Generic type of the key + * @param Generic type of the value + * @return Corresponding value or default value + */ + private synchronized V getOrDefault(final Map map, final K key, final V defaultValue) { + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * Put key-value pair to map if the key is absent. + * + * @param map The Map + * @param key Lookup key + * @param value The value will be put to the map if the key is absent + * @param Generic type of the key + * @param Generic type of the value + */ + private synchronized void putIfAbsent(final Map map, final K key, final V value) { + if (!map.containsKey(key)) { + map.put(key, value); + } + } + + /** + * Utility method that castes given object to given class type. + * + * @param source Source object to be casted + * @param clazz Class that object will be casted to its type + * @param Source object's type + * @param Destination type + * @return Object that casted to D type + */ + private synchronized D objectCast(final S source, final Class clazz) { + return clazz.cast(source); + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/logger/HMSMethod.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/logger/HMSMethod.java new file mode 100644 index 00000000..3ff84ebc --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/logger/HMSMethod.java @@ -0,0 +1,62 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.logger; + +import android.app.Activity; + +public class HMSMethod { + private String name; + + private boolean periodical = false; + + public HMSMethod(String name) { + this.name = name; + } + + public HMSMethod(String name, boolean isPeriodical) { + this(name); + this.periodical = isPeriodical; + } + + public static void enableLogger(Activity activity) { + HMSLogger.getInstance(activity).enableLogger(); + } + + public static void disableLogger(Activity activity) { + HMSLogger.getInstance(activity).disableLogger(); + } + + public String getName() { + return name; + } + + public void sendLoggerEvent(Activity activity) { + if (periodical) { + HMSLogger.getInstance(activity).sendPeriodicEvent(name); + return; + } + HMSLogger.getInstance(activity).sendSingleEvent(name); + } + + public void sendLoggerEvent(Activity activity, String errorCode) { + if (periodical) { + HMSLogger.getInstance(activity).sendPeriodicEvent(name, errorCode); + return; + } + HMSLogger.getInstance(activity).sendSingleEvent(name, errorCode); + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/CustomViewActivity.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/CustomViewActivity.java new file mode 100644 index 00000000..c577db3d --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/CustomViewActivity.java @@ -0,0 +1,382 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.bankcard; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.graphics.Point; +import android.graphics.Rect; +import android.os.Build; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.Display; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.mlplugin.card.bcr.CustomView; +import com.huawei.hms.mlplugin.card.bcr.MLBcrCaptureResult; + +import java.lang.reflect.InvocationTargetException; + +public class CustomViewActivity extends Activity { + private static final String TAG = CustomViewActivity.class.getSimpleName(); + + private static final double TOP_OFFSET_RATIO = 0.4d; + + private Context mContext; + + private CustomView remoteView; + + private ImageView flashButton; + + private FrameLayout frameLayout; + + private View titleLayout; + + private TextView title; + + private View lightLayout; + + private ViewfinderView viewfinderView; + + private HMSLogger mLogger; + + private float scanFrameWidthFactor = 0.8f; + + private float scanFrameHeightFactor = 0.63084f; + + Intent intent; + + Bundle bundle; + + private int[] img; + + private View customView; + + private static final String ACTIVITY_CUSTOM = "activity_custom"; + + public static final String FLASH_LIGHT_ON = "flash_light_on"; + + public static final String FLASH_LIGHT_OFF = "flash_light_off"; + + public enum Event { + ON_START("onStart"), + ON_RESUME("onResume"), + ON_PAUSE("onPause"), + ON_DESTROY("onDestroy"), + ON_STOP("onStop"); + + private String eventName; + + Event(String eventName) { + this.eventName = eventName; + } + + public String getName() { + return eventName; + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mContext = this.getApplicationContext(); + mLogger = HMSLogger.getInstance(mContext); + + img = new int[] {getDrawableId(mContext, "FLASH_LIGHT_ON"), getDrawableId(mContext, "FLASH_LIGHT_OFF")}; + + intent = getIntent(); + try { + bundle = intent.getExtras(); + } catch (Exception e) { + Log.i("Customized-Exception", e.getMessage()); + } + + initView(); + + Rect mScanRect = createScanRectFromCamera(); + + remoteView = new CustomView.Builder().setContext(this) + // Set the rectangular coordinate setting of the scan frame, required, otherwise it will not be recognized. + .setBoundingBox(mScanRect) + // Set the type of result that the bank card identification expects to return. + // MLBcrCaptureConfig.RESULT_SIMPLE:Only identify the card number and validity period information. + // MLBcrCaptureConfig.RESULT_ALL:Identify information such as card number, expiration date, issuing bank, issuing organization, and card type. + .setResultType(bundle.getInt("resultType")).setRecMode(bundle.getInt("recMode")) + // Set result monitoring + .setOnBcrResultCallback(callback).build(); + + CustomViewHandler.setViews(remoteView, flashButton); + + mLogger.startMethodExecutionTimer("CustomizedViewActivity.customizedView"); + + remoteView.onCreate(savedInstanceState); + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT); + frameLayout.addView(remoteView, params); + + addMainView(mScanRect); + + } + + private CustomView.OnBcrResultCallback callback = new CustomView.OnBcrResultCallback() { + @Override + public void onBcrResult(MLBcrCaptureResult idCardResult) { + Intent intent = new Intent(); + Bitmap bitmap = idCardResult.getOriginalBitmap(); + bitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth() / 2, bitmap.getHeight() / 2, true); + Bitmap numberBitmap = idCardResult.getNumberBitmap(); + numberBitmap = Bitmap.createScaledBitmap(numberBitmap, numberBitmap.getWidth() / 2, + numberBitmap.getHeight() / 2, true); + // Because the set mode is MLBcrCaptureConfig.RESULT_SIMPLE, only the corresponding data is returned + intent.putExtra("bitmap", bitmap); + intent.putExtra("numberBitmap", numberBitmap); + intent.putExtra("number", idCardResult.getNumber()); + intent.putExtra("expire", idCardResult.getExpire()); + intent.putExtra("issuer", idCardResult.getIssuer()); + intent.putExtra("organization", idCardResult.getOrganization()); + setResult(Activity.RESULT_OK, intent); + finish(); + } + }; + + private void initView() { + + requestWindowFeature(Window.FEATURE_NO_TITLE); + customView = this.getLayoutInflater().inflate(getTemplate(), null); + setContentView(customView); + frameLayout = (FrameLayout) handleResources("rim"); + lightLayout = handleResources("light_layout"); + flashButton = (ImageView) handleResources("imageButton2"); + titleLayout = handleResources("title_layout"); + title = (TextView) handleResources("title"); + + if (bundle.getBoolean("isTitleAvailable")) { + titleLayout.setVisibility(View.VISIBLE); + } else { + titleLayout.setVisibility(View.GONE); + } + + if (bundle.containsKey("title")) { + title.setText(bundle.getString("title")); + } + + if (bundle.getBoolean("isFlashAvailable")) { + lightLayout.setVisibility(View.VISIBLE); + setFlashOperation(); + } else { + lightLayout.setVisibility(View.GONE); + } + setBackOperation(); + setRectFactors(); + } + + private View handleResources(String resourceName) { + return customView.findViewById( + mContext.getResources().getIdentifier(resourceName, "id", mContext.getPackageName())); + } + + private int getTemplate() { + try { + return mContext.getResources() + .getIdentifier((String) CustomViewActivity.class.getDeclaredField("ACTIVITY_CUSTOM").get(null), + "layout", mContext.getPackageName()); + } catch (NoSuchFieldException | IllegalAccessException e) { + Log.e(TAG, e.getMessage()); + return -1; + } + } + + private int getDrawableId(Context context, String resourceName) { + try { + return context.getResources() + .getIdentifier((String) CustomViewActivity.class.getDeclaredField(resourceName).get(null), "drawable", + context.getPackageName()); + } catch (NoSuchFieldException | IllegalAccessException e) { + Log.e("PluginNativeAdManager", e.getMessage()); + return -1; + } + } + + private void setRectFactors() { + if (bundle.containsKey("widthFactor")) { + scanFrameWidthFactor = bundle.getFloat("widthFactor"); + } + if (bundle.containsKey("heightFactor")) { + scanFrameHeightFactor = bundle.getFloat("heightFactor"); + } + } + + private void setBackOperation() { + ImageView backButton = (ImageView) handleResources("back_img"); + backButton.setOnClickListener(v -> CustomViewActivity.this.finish()); + } + + /** + * Get real screen size information + * + * @return Point + */ + private Point getRealScreenSize() { + int heightPixels = 0; + int widthPixels = 0; + Point point = null; + WindowManager manager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); + + if (manager != null) { + Display d = manager.getDefaultDisplay(); + DisplayMetrics metrics = new DisplayMetrics(); + d.getMetrics(metrics); + heightPixels = metrics.heightPixels; + widthPixels = metrics.widthPixels; + Log.i(TAG, "heightPixels=" + heightPixels + " widthPixels=" + widthPixels); + + if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) { + try { + heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d); + widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d); + Log.i(TAG, "2 heightPixels=" + heightPixels + " widthPixels=" + widthPixels); + } catch (IllegalArgumentException e) { + Log.w(TAG, "getRealScreenSize exception"); + } catch (IllegalAccessException e) { + Log.w(TAG, "getRealScreenSize exception"); + } catch (InvocationTargetException e) { + Log.w(TAG, "getRealScreenSize exception"); + } catch (NoSuchMethodException e) { + Log.w(TAG, "getRealScreenSize exception"); + } + } else if (Build.VERSION.SDK_INT >= 17) { + Point realSize = new Point(); + try { + Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize); + heightPixels = realSize.y; + widthPixels = realSize.x; + Log.i(TAG, "3 heightPixels=" + heightPixels + " widthPixels=" + widthPixels); + } catch (IllegalArgumentException e) { + Log.w(TAG, "getRealScreenSize exception"); + } catch (IllegalAccessException e) { + Log.w(TAG, "getRealScreenSize exception"); + } catch (InvocationTargetException e) { + Log.w(TAG, "getRealScreenSize exception"); + } catch (NoSuchMethodException e) { + Log.w(TAG, "getRealScreenSize exception"); + } + } + } + Log.i(TAG, "getRealScreenSize widthPixels=" + widthPixels + " heightPixels=" + heightPixels); + point = new Point(widthPixels, heightPixels); + return point; + } + + private Rect createScanRect(int screenWidth, int screenHeight) { + final float heightFactor = scanFrameHeightFactor; + final float mCardScale = scanFrameWidthFactor; + int width = Math.round(screenWidth * heightFactor); + int height = Math.round((float) width * mCardScale); + int leftOffset = (screenWidth - width) / 2; + int topOffset = (int) (screenHeight * TOP_OFFSET_RATIO) - height / 2; + Log.i(TAG, + "screenWidth=" + screenWidth + " screenHeight=" + screenHeight + " rect width=" + width + " leftOffset " + + leftOffset + " topOffset " + topOffset); + return new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height); + } + + private Rect createScanRectFromCamera() { + Point point = getRealScreenSize(); + int screenWidth = point.x; + int screenHeight = point.y; + return createScanRect(screenWidth, screenHeight); + } + + private void setFlashOperation() { + lightLayout.setOnClickListener(v -> { + if (remoteView.getLightStatus()) { + remoteView.switchLight(); + flashButton.setImageResource(img[1]); + } else { + remoteView.switchLight(); + flashButton.setImageResource(img[0]); + } + }); + } + + /** + * Call the lifecycle management method of the remoteView activity. + * Cordova callbacks. + */ + @Override + protected void onStart() { + super.onStart(); + Window window = getWindow(); + View decorView = window.getDecorView(); + int option = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; + decorView.setSystemUiVisibility(option); + if (Build.VERSION.SDK_INT >= 21) { + window.setStatusBarColor(Color.TRANSPARENT); + window.setNavigationBarColor(Color.TRANSPARENT); + } + remoteView.onStart(); + mLogger.sendSingleEvent(Event.ON_START.getName()); + } + + @Override + protected void onResume() { + super.onResume(); + remoteView.onResume(); + mLogger.sendSingleEvent(Event.ON_RESUME.getName()); + } + + @Override + protected void onPause() { + super.onPause(); + remoteView.onPause(); + mLogger.sendSingleEvent(Event.ON_PAUSE.getName()); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + remoteView.onDestroy(); + mLogger.sendSingleEvent(Event.ON_DESTROY.getName()); + } + + @Override + protected void onStop() { + super.onStop(); + remoteView.onStop(); + mLogger.sendSingleEvent(Event.ON_STOP.getName()); + } + + private void addMainView(Rect frameRect) { + this.viewfinderView = new ViewfinderView(this, frameRect); + this.viewfinderView.setLayoutParams( + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + this.frameLayout.addView(this.viewfinderView); + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/CustomViewHandler.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/CustomViewHandler.java new file mode 100644 index 00000000..168988ce --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/CustomViewHandler.java @@ -0,0 +1,169 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.bankcard; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.util.Log; +import android.widget.ImageView; + +import androidx.annotation.NonNull; + +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.mlplugin.card.bcr.CustomView; +import com.huawei.hms.mlplugin.card.bcr.MLBcrCaptureResult; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaInterface; +import org.apache.cordova.CordovaPlugin; +import org.json.JSONException; +import org.json.JSONObject; + +public class CustomViewHandler extends HMSProvider { + private Context mContext; + + private Activity mActivity; + + private HMSLogger logger; + + private static MLBcrCaptureResult cardResult; + + private CordovaInterface mCordova; + + private CordovaPlugin mPlugin; + + private int[] img = {getDrawableId(getContext(), "FLASH_LIGHT_ON"), getDrawableId(getContext(), "FLASH_LIGHT_OFF")}; + + private static final int REQUEST_CODE_SCAN_CUSTOMIZED = 14; + + @SuppressLint("StaticFieldLeak") + private static CustomView remoteView; + + @SuppressLint("StaticFieldLeak") + private static ImageView flashImage; + + private CallbackContext mCallbackContext; + + private int getDrawableId(Context context, String resourceName) { + try { + return context.getResources() + .getIdentifier((String) CustomViewActivity.class.getDeclaredField(resourceName).get(null), "drawable", + context.getPackageName()); + } catch (NoSuchFieldException | IllegalAccessException e) { + Log.e("PluginNativeAdManager", e.getMessage()); + return -1; + } + } + + public static void setViews(CustomView remoteView, ImageView flashImage) { + CustomViewHandler.remoteView = remoteView; + CustomViewHandler.flashImage = flashImage; + } + + public static void setCardResult(MLBcrCaptureResult result) { + cardResult = result; + } + + public CustomViewHandler(@NonNull Context context, Activity activity, CordovaInterface cordova, + CordovaPlugin plugin) { + super(context); + this.mContext = context; + this.mActivity = activity; + this.mCordova = cordova; + this.mPlugin = plugin; + + logger = HMSLogger.getInstance(mContext); + } + + public void startCustomizedView(JSONObject jsonObject, CallbackContext context) throws JSONException { + this.mCallbackContext = context; + + mCordova.setActivityResultCallback(mPlugin); + + int resultType = 0; + if (jsonObject.has("resultType")) { + resultType = jsonObject.getInt("resultType"); + } + + int recMode = 0; + if (jsonObject.has("recMode")) { + recMode = jsonObject.getInt("recMode"); + } + + boolean isFlashAvailable = false; + if (jsonObject.has("isFlashAvailable")) { + isFlashAvailable = jsonObject.getBoolean("isFlashAvailable"); + } + + boolean isTitleAvailable = true; + if (jsonObject.has("isTitleAvailable")) { + isTitleAvailable = jsonObject.getBoolean("isTitleAvailable"); + } + + String title = "Place the card within the frame"; + if (jsonObject.has("title")) { + title = jsonObject.getString("title"); + } + float heightFactor = 0.63084f; + if (jsonObject.has("heightFactor")) { + heightFactor = (float) jsonObject.getDouble("heightFactor"); + } + + float widthFactor = 0.8f; + if (jsonObject.has("widthFactor")) { + widthFactor = (float) jsonObject.getDouble("widthFactor"); + } + + Intent intent = new Intent(mContext, CustomViewActivity.class); + + intent.putExtra("widthFactor", widthFactor); + intent.putExtra("heightFactor", heightFactor); + intent.putExtra("resultType", resultType); + intent.putExtra("recMode", recMode); + + intent.putExtra("isFlashAvailable", isFlashAvailable); + intent.putExtra("isTitleAvailable", isTitleAvailable); + intent.putExtra("title", title); + + mActivity.startActivityForResult(intent, REQUEST_CODE_SCAN_CUSTOMIZED); + } + + public void switchLight(final CallbackContext callbackContext) { + if (remoteView != null) { + remoteView.switchLight(); + if (remoteView.getLightStatus()) { + flashImage.setImageResource(img[1]); + } else { + flashImage.setImageResource(img[0]); + } + callbackContext.success(); + } else { + callbackContext.error("View is null"); + } + } + + public void getLightStatus(final CallbackContext callbackContext) { + if (remoteView != null) { + callbackContext.success(String.valueOf(remoteView.getLightStatus())); + } else { + callbackContext.error("View is null"); + } + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/MLBankCardAnalyser.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/MLBankCardAnalyser.java new file mode 100644 index 00000000..09d0282b --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/MLBankCardAnalyser.java @@ -0,0 +1,291 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.bankcard; + +import android.content.Context; +import android.graphics.Bitmap; +import android.util.Log; + +import com.huawei.hmf.tasks.Task; +import com.huawei.hms.cordova.mltext.helpers.CordovaErrors; +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.logger.HMSMethod; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; +import com.huawei.hms.cordova.mltext.utils.PlatformUtils; +import com.huawei.hms.cordova.mltext.utils.TextUtils; +import com.huawei.hms.mlplugin.card.bcr.CustomView; +import com.huawei.hms.mlplugin.card.bcr.MLBcrCapture; +import com.huawei.hms.mlplugin.card.bcr.MLBcrCaptureConfig; +import com.huawei.hms.mlplugin.card.bcr.MLBcrCaptureFactory; +import com.huawei.hms.mlplugin.card.bcr.MLBcrCaptureResult; +import com.huawei.hms.mlsdk.card.MLBcrAnalyzerFactory; +import com.huawei.hms.mlsdk.card.bcr.MLBankCard; +import com.huawei.hms.mlsdk.card.bcr.MLBcrAnalyzer; +import com.huawei.hms.mlsdk.card.bcr.MLBcrAnalyzerSetting; +import com.huawei.hms.mlsdk.common.MLFrame; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaInterface; +import org.json.JSONException; +import org.json.JSONObject; + +public class MLBankCardAnalyser extends HMSProvider { + private static final String TAG = MLBankCardAnalyser.class.getName(); + + private MLBcrAnalyzer sdkAnalyzer; + + private CallbackContext callbackContext; + + CustomView.OnBcrResultCallback onBcrResultCallback = new CustomView.OnBcrResultCallback() { + @Override + public void onBcrResult(MLBcrCaptureResult idCardResult) { + + Log.i(TAG, "onBcrResultCallback onBcrResult"); + if (idCardResult.getErrorCode() == 0) { + try { + JSONObject icrResult = new JSONObject(); + Bitmap bitmap = idCardResult.getOriginalBitmap(); + icrResult.putOpt("bitmap", bitmap); + icrResult.putOpt("number", idCardResult.getNumber()); + callbackContext.success(icrResult); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlBCRPluginDetector"); + + } catch (JSONException e) { + Log.e(TAG, "MLBcrCapture.Callback: error ->" + e.getMessage()); + } + } else { + Log.i(TAG, "onBcrResultCallback onBcrResult idCardResult is null"); + callbackContext.error("idCardResult is null"); + } + + } + }; + + private int detectType; + + private MLBcrAnalyzerSetting mlBcrAnalyzerSetting; + + private MLBcrCaptureConfig config; + + private CustomView.Builder builder = null; + + private MLBcrCapture.Callback banCallback = new MLBcrCapture.Callback() { + @Override + public void onSuccess(MLBcrCaptureResult bankCardResult) { + if (bankCardResult == null) { + Log.i(MLBankCardAnalyser.TAG, "CallBack onRecSuccess idCardResult is null"); + } else { + formatIdCardResult(bankCardResult, callbackContext); + } + } + + @Override + public void onCanceled() { + onCanceledCallBack(callbackContext); + } + + @Override + public void onFailure(int recCode, Bitmap bitmap) { + JSONObject jsonObject = new JSONObject(); + try { + jsonObject.putOpt("redCode", recCode); + jsonObject.putOpt("Bitmap", HMSMLUtils.bitmapToBase64(bitmap)); + } catch (JSONException e) { + Log.e(TAG, "error" + e.getMessage()); + } + errorCallBack(jsonObject, callbackContext); + } + + @Override + public void onDenied() { + callBackOnDenied(callbackContext); + } + }; + + public MLBankCardAnalyser(Context ctx) { + super(ctx); + } + + public void initializerBCRAnalyser(final JSONObject params, final CallbackContext callbackContext) { + this.callbackContext = callbackContext; + + detectType = params.optInt("detectType", 0); + + switch (detectType) { + case 0: + Log.i(TAG, "initializerCallBack: BankCard Detect on SDK"); + bankCardAnalyser(params, callbackContext); + break; + case 1: + Log.i(TAG, "initializerCallBack: BankCard Detect with Plugin"); + startCaptureActivity(params, this.banCallback); + break; + default: + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ILLEGAL_PARAMETER)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("bankCardDetector", String.valueOf(CordovaErrors.ILLEGAL_PARAMETER)); + break; + } + } + + private void bankCardAnalyser(final JSONObject params, final CallbackContext callbackContext) { + HMSMethod method = new HMSMethod("bankCardDetector"); + MLFrame frame = HMSMLUtils.getFrame(getContext(), params); + CordovaHelpers.frameController(frame, getContext(), callbackContext, "bankCardDetector"); + JSONObject mLBcrAnalyzerSettingJSON = params.optJSONObject("mLBcrAnalyzerSetting"); + + if (mLBcrAnalyzerSettingJSON != null) { + String langType = mLBcrAnalyzerSettingJSON.optString("langType", "en"); + int resultType = mLBcrAnalyzerSettingJSON.optInt("resultType", 2); + if (!langType.isEmpty()) { + mlBcrAnalyzerSetting = new MLBcrAnalyzerSetting.Factory().setLangType(langType) + .setResultType(resultType) + .create(); + } else { + mlBcrAnalyzerSetting = new MLBcrAnalyzerSetting.Factory().create(); + } + } else { + mlBcrAnalyzerSetting = new MLBcrAnalyzerSetting.Factory().create(); + } + + sdkAnalyzer = MLBcrAnalyzerFactory.getInstance().getBcrAnalyzer(mlBcrAnalyzerSetting); + Task task = sdkAnalyzer.asyncAnalyseFrame(frame); + task.addOnSuccessListener( + PlatformUtils.successListener(method, getActivity(), callbackContext, TextUtils.FROM_BCR_TO_JSON_OBJECT)) + .addOnFailureListener(PlatformUtils.failureListener(method, getActivity(), callbackContext)); + + } + + public void startCaptureActivity(final JSONObject params, final MLBcrCapture.Callback callback) { + int resultType = 2; + int orientation = 0; + JSONObject mLBcrCaptureConfig = params.optJSONObject("mLBcrCaptureConfig"); + if (mLBcrCaptureConfig != null) { + resultType = mLBcrCaptureConfig.optInt("resultType", 2); + orientation = mLBcrCaptureConfig.optInt("orientation", 0); + } + config = new MLBcrCaptureConfig.Factory().setOrientation(orientation).setResultType(resultType).create(); + MLBcrCapture bcrCapture = MLBcrCaptureFactory.getInstance().getBcrCapture(config); + bcrCapture.captureFrame(getContext(), callback); + } + + private void formatIdCardResult(final MLBcrCaptureResult bankCardResult, final CallbackContext callbackContext) { + JSONObject jsonObject = new JSONObject(); + try { + jsonObject.putOpt("number", bankCardResult.getNumber()); + jsonObject.putOpt("errorCode", bankCardResult.getErrorCode()); + Bitmap originalBitmap = bankCardResult.getOriginalBitmap(); + Bitmap numberBitmap = bankCardResult.getNumberBitmap(); + jsonObject.putOpt("expire", bankCardResult.getExpire()); + jsonObject.putOpt("issuer", bankCardResult.getIssuer()); + jsonObject.putOpt("type", bankCardResult.getType()); + jsonObject.putOpt("organization", bankCardResult.getOrganization()); + jsonObject.putOpt("originalBitmap", HMSMLUtils.bitmapToBase64(originalBitmap)); + jsonObject.putOpt("numberBitmap", HMSMLUtils.bitmapToBase64(numberBitmap)); + callbackContext.success(jsonObject); + HMSLogger.getInstance(getContext()).sendSingleEvent("bankCardDetector"); + } catch (JSONException e) { + callbackContext.error(e.getMessage()); + HMSLogger.getInstance(getContext()).sendSingleEvent("bankCardDetector", e.getMessage()); + } + } + + private void errorCallBack(final JSONObject jsonObject, final CallbackContext callbackContext) { + callbackContext.error(jsonObject); + HMSLogger.getInstance(getContext()).sendSingleEvent("bankCardDetector", "-1"); + } + + private void onCanceledCallBack(final CallbackContext callbackContext) { + String result = "Call back on RecCanceled"; + callbackContext.error(result); + HMSLogger.getInstance(getContext()).sendSingleEvent("bankCardDetector", "-1"); + } + + private void callBackOnDenied(final CallbackContext callbackContext) { + String result = "Callback on Camera Denied"; + callbackContext.error(result); + HMSLogger.getInstance(getContext()).sendSingleEvent("bankCardDetector", "-1"); + } + + public void stopBankCardAnalyser(final CallbackContext callbackContext, CordovaInterface cordovaInterface) { + if (sdkAnalyzer == null) { + callbackContext.error("Analyser is not initialized."); + HMSLogger.getInstance(cordovaInterface.getContext()).sendSingleEvent("bankCardDetectorStop", "-1"); + } else { + sdkAnalyzer.stop(); + sdkAnalyzer = null; + callbackContext.success("Analyser stopped"); + HMSLogger.getInstance(cordovaInterface.getContext()).sendSingleEvent("bankCardDetectorStop"); + } + } + + public void setOnBcrResultCallback(final CallbackContext context) throws JSONException { + this.builder = new CustomView.Builder().setOnBcrResultCallback(onBcrResultCallback); + HMSLogger.getInstance(getContext()).sendSingleEvent("setOnBcrResultCallback"); + context.success(builder.toString()); + } + + public void setRecMode(final CallbackContext context, JSONObject params) throws JSONException { + if (params != null) { + int recMode = params.getInt("recMode"); + this.builder = new CustomView.Builder().setRecMode(recMode); + HMSLogger.getInstance(getContext()).sendSingleEvent("setRecMode"); + context.success(builder.toString()); + } else { + HMSLogger.getInstance(getContext()).sendSingleEvent("setRecMode failure"); + context.error(CordovaErrors.ANALYSIS_FAILURE); + } + + } + + public void setResultType(final CallbackContext context, JSONObject params) throws JSONException { + if (params != null) { + int resultType = params.getInt("resultType"); + this.builder = new CustomView.Builder().setResultType(resultType); + + HMSLogger.getInstance(getContext()).sendSingleEvent("resultType"); + context.success(builder.toString()); + } else { + HMSLogger.getInstance(getContext()).sendSingleEvent("resultType failure"); + context.error(CordovaErrors.ANALYSIS_FAILURE); + } + + } + + public void getBCRSetting(final CallbackContext callbackContext) throws JSONException { + if (sdkAnalyzer == null) { + callbackContext.error("Analyser is not initialized."); + HMSLogger.getInstance(getContext()).sendSingleEvent("bankCardDetectorSetting", "-1"); + } else { + JSONObject object = new JSONObject(); + if (detectType == 0) { + object.putOpt("langType", mlBcrAnalyzerSetting.getLangType()); + object.putOpt("recMode", mlBcrAnalyzerSetting.getRecMode()); + object.putOpt("resultType", mlBcrAnalyzerSetting.getResultType()); + object.putOpt("recType", mlBcrAnalyzerSetting.getRecType()); + } else { + object.putOpt("resultType", config.getResultType()); + object.putOpt("orientation", config.getOrientation()); + object.putOpt("recMode", config.getRecMode()); + } + callbackContext.success(object); + HMSLogger.getInstance(getContext()).sendSingleEvent("bankCardDetectorSetting"); + } + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/ViewfinderView.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/ViewfinderView.java new file mode 100644 index 00000000..0a2cabab --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/bankcard/ViewfinderView.java @@ -0,0 +1,103 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.bankcard; + +import android.content.Context; +import android.content.res.Configuration; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; +import android.util.Log; +import android.view.MotionEvent; +import android.view.View; + +import com.huawei.hms.mlplugin.card.bcr.R; + +public class ViewfinderView extends View { + private static final String TAG = ViewfinderView.class.getSimpleName(); + + private final Paint paint; + + private Rect frameRect; + + private Context context; + + private boolean isLandscape; + + /** + * Constructor + * + * @param context Activity + */ + public ViewfinderView(Context context, Rect frameRect) { + super(context); + this.context = context; + this.frameRect = frameRect; + this.isLandscape = isLandscape(context); + this.paint = new Paint(Paint.ANTI_ALIAS_FLAG); + } + + /** + * According to the context to determine whether the current horizontal screen + * + * @param context context + * @return true:Landscape;false:Portrait + */ + public static boolean isLandscape(Context context) { + int orientation = context.getResources().getConfiguration().orientation; + return orientation == Configuration.ORIENTATION_LANDSCAPE; + } + + @Override + public void onDraw(Canvas canvas) { + Log.i(TAG, "onDraw frameRect = " + frameRect); + // Scanning border drawing + // You can also draw other such as scan lines, masks, and draw prompts and other buttons according to your needs + drawBoarderFrame(canvas, frameRect); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + return false; + } + + private void drawBoarderFrame(Canvas canvas, Rect frame) { + final int lindDrawWidth = context.getResources().getDimensionPixelSize(R.dimen.mlkit_bcr_line_draw_width); + int lineWidth = isLandscape ? lindDrawWidth : lindDrawWidth >> 1; + int roundWidth = (frame.right - frame.left) / 12; + + canvas.save(); + canvas.drawRect((float) frame.left, (float) frame.top, (float) (frame.left + roundWidth + 1), + (float) (frame.top + lineWidth + 1), this.paint); + canvas.drawRect((float) frame.left, (float) frame.top, (float) (frame.left + lineWidth + 1), + (float) (frame.top + roundWidth + 1), this.paint); + canvas.drawRect((float) (frame.right - roundWidth), (float) frame.top, (float) (frame.right + 1), + (float) (frame.top + lineWidth + 1), this.paint); + canvas.drawRect((float) (frame.right - lineWidth), (float) frame.top, (float) (frame.right + 1), + (float) (frame.top + roundWidth + 1), this.paint); + + canvas.drawRect((float) frame.left, (float) (frame.bottom - lineWidth), (float) (frame.left + roundWidth + 1), + (float) (frame.bottom + 1), this.paint); + canvas.drawRect((float) frame.left, (float) (frame.bottom - roundWidth), (float) (frame.left + lineWidth + 1), + (float) (frame.bottom + 1), this.paint); + canvas.drawRect((float) (frame.right - roundWidth), (float) (frame.bottom - lineWidth), + (float) (frame.right + 1), (float) (frame.bottom + 1), this.paint); + canvas.drawRect((float) (frame.right - lineWidth), (float) (frame.bottom - roundWidth), + (float) (frame.right + 1), (float) (frame.bottom + 1), this.paint); + canvas.restore(); + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/document/MLImageDocumentAnalyser.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/document/MLImageDocumentAnalyser.java new file mode 100644 index 00000000..22d20de9 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/document/MLImageDocumentAnalyser.java @@ -0,0 +1,115 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.document; + +import android.content.Context; + +import com.huawei.hmf.tasks.Task; +import com.huawei.hms.cordova.mltext.helpers.CordovaErrors; +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.logger.HMSMethod; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; +import com.huawei.hms.cordova.mltext.utils.PlatformUtils; +import com.huawei.hms.cordova.mltext.utils.TextUtils; +import com.huawei.hms.mlsdk.MLAnalyzerFactory; +import com.huawei.hms.mlsdk.common.MLFrame; +import com.huawei.hms.mlsdk.document.MLDocument; +import com.huawei.hms.mlsdk.document.MLDocumentAnalyzer; +import com.huawei.hms.mlsdk.document.MLDocumentSetting; + +import org.apache.cordova.CallbackContext; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; + +public class MLImageDocumentAnalyser extends HMSProvider { + private static final String TAG = MLImageDocumentAnalyser.class.getName(); + + private MLDocumentAnalyzer analyzer; + + private MLDocumentSetting setting; + + ; + + public MLImageDocumentAnalyser(Context ctx) { + super(ctx); + } + + public void initializeDocumentAnalyser(final JSONObject params, final CallbackContext callbackContext) { + + MLFrame frame = HMSMLUtils.getFrame(getContext(), params); + HMSMethod method = new HMSMethod("documentImageAnalyser"); + CordovaHelpers.frameController(frame, getContext(), callbackContext, "documentImageAnalyser"); + JSONObject documentTextSetting = params.optJSONObject("documentSetting"); + + if (documentTextSetting != null) { + setting = TextUtils.toObject(documentTextSetting, MLDocumentSetting.class); + analyzer = MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer(setting); + } else { + analyzer = MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer(); + } + + Task task = analyzer.asyncAnalyseFrame(frame); + task.addOnSuccessListener( + PlatformUtils.successListener(method, getActivity(), callbackContext, TextUtils.FROM_MLDOC_TO_JSON_OBJECT)) + .addOnFailureListener(PlatformUtils.failureListener(method, getActivity(), callbackContext)); + } + + public void closeDocumentAnalyser(final CallbackContext callbackContext) throws IOException { + if (analyzer == null) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ANALYSIS_FAILURE)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("documentImageAnalyserClose", String.valueOf(CordovaErrors.ANALYSIS_FAILURE)); + } else { + analyzer.close(); + analyzer = null; + callbackContext.success("Analyser closed"); + HMSLogger.getInstance(getContext()).sendSingleEvent("documentImageAnalyserClose"); + } + } + + public void getDocumentAnalyserSetting(final CallbackContext callbackContext) throws IOException, JSONException { + if (analyzer == null) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ANALYSIS_FAILURE)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("documentImageAnalyserSetting", String.valueOf(CordovaErrors.ANALYSIS_FAILURE)); + } else { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("borderType", setting.getBorderType()); + jsonObject.putOpt("languageList", setting.getLanguageList()); + jsonObject.putOpt("isEnableFingerprintVerification", setting.isEnableFingerprintVerification()); + callbackContext.success(jsonObject); + HMSLogger.getInstance(getContext()).sendSingleEvent("documentImageAnalyserSetting"); + } + } + + public void stopDocumentAnalyser(final CallbackContext callbackContext) throws IOException { + if (analyzer == null) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ANALYSIS_FAILURE)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("documentImageAnalyserStop", String.valueOf(CordovaErrors.ANALYSIS_FAILURE)); + } else { + analyzer.stop(); + analyzer = null; + callbackContext.success("Analyser stopped"); + HMSLogger.getInstance(getContext()).sendSingleEvent("documentImageAnalyserStop"); + } + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/formrecognition/MLFormRecognitionAnalyser.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/formrecognition/MLFormRecognitionAnalyser.java new file mode 100644 index 00000000..dd60dc80 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/formrecognition/MLFormRecognitionAnalyser.java @@ -0,0 +1,117 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.formrecognition; + +import android.content.Context; +import android.util.SparseArray; + +import com.huawei.hmf.tasks.Task; +import com.huawei.hms.cordova.mltext.helpers.CordovaErrors; +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; +import com.huawei.hms.mlsdk.common.MLFrame; +import com.huawei.hms.mlsdk.fr.MLFormRecognitionAnalyzer; +import com.huawei.hms.mlsdk.fr.MLFormRecognitionAnalyzerFactory; +import com.huawei.hms.mlsdk.fr.MLFormRecognitionConstant; + +import com.google.gson.JsonObject; + +import org.apache.cordova.CallbackContext; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; + +public class MLFormRecognitionAnalyser extends HMSProvider { + private static final String TAG = MLFormRecognitionAnalyser.class.getName(); + + private MLFormRecognitionAnalyzer analyzer; + + public MLFormRecognitionAnalyser(Context ctx) { + super(ctx); + } + + public void initializeFormRecognitionAnalyser(final JSONObject params, final CallbackContext callbackContext) + throws JSONException { + + MLFrame frame = HMSMLUtils.getFrame(getContext(), params); + + CordovaHelpers.frameController(frame, getContext(), callbackContext, "formRecognitionAnalyser"); + + analyzer = MLFormRecognitionAnalyzerFactory.getInstance().getFormRecognitionAnalyzer(); + int syncType = params.optInt("sncyType", 1); + if (syncType == 0) { + Task task = analyzer.asyncAnalyseFrame(frame); + task.addOnSuccessListener(jsonObject -> { + if (jsonObject != null && jsonObject.get("retCode").getAsInt() == MLFormRecognitionConstant.SUCCESS) { + try { + JSONObject formResult = new JSONObject(String.valueOf(jsonObject)); + callbackContext.success(formResult); + HMSLogger.getInstance(getContext()).sendSingleEvent("formRecognitionAnalyser"); + } catch (JSONException e) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.SERVICE_FAILURE)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("formRecognitionAnalyser", String.valueOf(CordovaErrors.SERVICE_FAILURE)); + } + + } else if (jsonObject != null + && jsonObject.get("retCode").getAsInt() == MLFormRecognitionConstant.FAILED) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.SERVICE_FAILURE)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("formRecognitionAnalyser", String.valueOf(CordovaErrors.SERVICE_FAILURE)); + + } + + }).addOnFailureListener(e -> { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.SERVICE_FAILURE)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("formRecognitionAnalyser", String.valueOf(CordovaErrors.SERVICE_FAILURE)); + }); + } else { + SparseArray recognizeResult = analyzer.analyseFrame(frame); + if (recognizeResult != null + && recognizeResult.get(0).get("retCode").getAsInt() == MLFormRecognitionConstant.SUCCESS) { + JSONObject result = new JSONObject(); + for (int i = 0; i < recognizeResult.size(); i++) { + result.putOpt("" + i, recognizeResult.get(i)); + } + callbackContext.success(result); + } else { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.SERVICE_FAILURE)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("formRecognitionAnalyser", String.valueOf(CordovaErrors.SERVICE_FAILURE)); + } + } + + } + + public void stop(CallbackContext callbackContext) throws IOException { + if (analyzer == null) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ANALYSIS_FAILURE)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("formRecognitionAnalyserStop", String.valueOf(CordovaErrors.ANALYSIS_FAILURE)); + } else { + analyzer.stop(); + analyzer = null; + callbackContext.success("Analyser stopped"); + HMSLogger.getInstance(getContext()).sendSingleEvent("formRecognitionAnalyserStop"); + } + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/generalcard/MLGeneralCardAnalyser.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/generalcard/MLGeneralCardAnalyser.java new file mode 100644 index 00000000..ef060c16 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/generalcard/MLGeneralCardAnalyser.java @@ -0,0 +1,168 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.generalcard; + +import android.content.Context; +import android.graphics.Bitmap; +import android.util.Log; + +import com.huawei.hms.cordova.mltext.helpers.CordovaErrors; +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; +import com.huawei.hms.cordova.mltext.utils.TextUtils; +import com.huawei.hms.mlplugin.card.gcr.MLGcrCapture; +import com.huawei.hms.mlplugin.card.gcr.MLGcrCaptureConfig; +import com.huawei.hms.mlplugin.card.gcr.MLGcrCaptureFactory; +import com.huawei.hms.mlplugin.card.gcr.MLGcrCaptureResult; +import com.huawei.hms.mlplugin.card.gcr.MLGcrCaptureUIConfig; +import com.huawei.hms.mlsdk.common.MLFrame; + +import org.apache.cordova.CallbackContext; +import org.json.JSONException; +import org.json.JSONObject; + +public class MLGeneralCardAnalyser extends HMSProvider { + private static final String TAG = MLGeneralCardAnalyser.class.getName(); + + private MLGcrCaptureUIConfig mlGcrCaptureUIConfig; + + private CallbackContext cordovaCallBackContext; + + private MLGcrCaptureConfig cardConfig; + + private MLGcrCapture.Callback callback = new MLGcrCapture.Callback() { + @Override + public int onResult(MLGcrCaptureResult result, Object object) { + if (result == null) { + return MLGcrCaptureResult.CAPTURE_CONTINUE; + } + try { + JSONObject gcrResult = new JSONObject(); + gcrResult.putOpt("text", TextUtils.fromMLTextToJSON(result.text)); + Bitmap image = result.cardBitmap; + gcrResult.putOpt("cardBitmap", HMSMLUtils.bitmapToBase64(image)); + cordovaCallBackContext.success(gcrResult); + HMSLogger.getInstance(getContext()).sendSingleEvent("generalcardPluginDetector"); + + } catch (JSONException e) { + Log.e(TAG, "MLGcrCapture.Callback: error ->" + e.getMessage()); + } + return MLGcrCaptureResult.CAPTURE_STOP; + } + + @Override + public void onCanceled() { + cordovaCallBackContext.error("callback onCanceled"); + HMSLogger.getInstance(getContext()).sendSingleEvent("generalcardPluginDetector", "-1"); + Log.e(TAG, "callback onCanceled"); + } + + @Override + public void onFailure(int restCode, Bitmap var2) { + cordovaCallBackContext.error(restCode + " callback onFailure"); + HMSLogger.getInstance(getContext()).sendSingleEvent("generalcardPluginDetector", "-1"); + Log.e(TAG, "callback onFailure"); + } + + @Override + public void onDenied() { + cordovaCallBackContext.error("callback onCameraDenied"); + HMSLogger.getInstance(getContext()).sendSingleEvent("generalcardPluginDetector", "-1"); + Log.e(TAG, "callback onCameraDenied"); + } + }; + + public MLGeneralCardAnalyser(Context ctx) { + super(ctx); + } + + public void initializeGeneralCardAnalyser(final JSONObject params, final CallbackContext callbackContext) { + + cordovaCallBackContext = callbackContext; + MLGcrCapture ocrManager; + JSONObject gcrCaptureConfig = params.optJSONObject("gcrCaptureConfig"); + String language; + if (gcrCaptureConfig != null) { + language = gcrCaptureConfig.optString("language", "en"); + } else { + language = "en"; + } + cardConfig = new MLGcrCaptureConfig.Factory().setLanguage(language).create(); + JSONObject gcrCaptureUIConfig = params.optJSONObject("gcrCaptureUIConfig"); + if (gcrCaptureUIConfig != null) { + mlGcrCaptureUIConfig = TextUtils.toObject(gcrCaptureUIConfig, MLGcrCaptureUIConfig.class); + MLGcrCaptureUIConfig uiConfig = new MLGcrCaptureUIConfig.Factory().setTipText( + mlGcrCaptureUIConfig.getTipText()) + .setTipTextColor(mlGcrCaptureUIConfig.getTipTextColor()) + .setOrientation(mlGcrCaptureUIConfig.getOrientation()) + .create(); + ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig, uiConfig); + + } else { + ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig); + } + int captureType = params.optInt("captureType", 0); + if (captureType == 0) { + startCaptureActivity(ocrManager, callback); + } else if (captureType == 1) { + startCapturePhoto(ocrManager, callback); + } else if (captureType == 2) { + startCaptureImage(ocrManager, callback, callbackContext, params); + } + + } + + private void startCaptureActivity(MLGcrCapture ocrManager, MLGcrCapture.Callback callBack) { + ocrManager.capturePreview(getContext(), null, callBack); + } + + private void startCapturePhoto(MLGcrCapture ocrManager, MLGcrCapture.Callback callback) { + ocrManager.capturePhoto(getContext(), null, callback); + } + + private void startCaptureImage(MLGcrCapture ocrManager, MLGcrCapture.Callback callback, + CallbackContext callbackContext, JSONObject params) { + MLFrame frame = HMSMLUtils.getFrame(getContext(), params); + CordovaHelpers.frameController(frame, getContext(), callbackContext, "generalcardPluginDetector"); + ocrManager.captureImage(frame.getPreviewBitmap(), null, callback); + } + + public void getGCRSetting(final CallbackContext callbackContext) throws JSONException { + JSONObject jsonObject = new JSONObject(); + if (cardConfig != null && mlGcrCaptureUIConfig != null) { + jsonObject.putOpt("gcrConfigLanguage", cardConfig.getLanguage()); + jsonObject.putOpt("torchOnResId", mlGcrCaptureUIConfig.getTorchOnResId()); + jsonObject.putOpt("tipTextColor", mlGcrCaptureUIConfig.getTipTextColor()); + jsonObject.putOpt("tipText", mlGcrCaptureUIConfig.getTipText()); + jsonObject.putOpt("backButtonResId", mlGcrCaptureUIConfig.getBackButtonResId()); + jsonObject.putOpt("orientation", mlGcrCaptureUIConfig.getOrientation()); + jsonObject.putOpt("photoButtonResId", mlGcrCaptureUIConfig.getPhotoButtonResId()); + jsonObject.putOpt("scanBoxScreenRatio", mlGcrCaptureUIConfig.getScanBoxScreenRatio()); + jsonObject.putOpt("scanBoxCornerColor", mlGcrCaptureUIConfig.getScanBoxCornerColor()); + jsonObject.putOpt("scanBoxAspectRatio", mlGcrCaptureUIConfig.getScanBoxAspectRatio()); + callbackContext.success(jsonObject); + HMSLogger.getInstance(getContext()).sendSingleEvent("generalcardPluginDetector"); + } else { + callbackContext.error(CordovaErrors.ANALYSIS_NULL); + HMSLogger.getInstance(getContext()).sendSingleEvent("generalcardPluginDetector", "-1"); + } + + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/idcard/MLIcrCardAnalyser.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/idcard/MLIcrCardAnalyser.java new file mode 100644 index 00000000..861b4e23 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/idcard/MLIcrCardAnalyser.java @@ -0,0 +1,129 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.idcard; + +import android.content.Context; +import android.graphics.Bitmap; +import android.util.Log; + +import com.huawei.hmf.tasks.OnFailureListener; +import com.huawei.hmf.tasks.OnSuccessListener; +import com.huawei.hmf.tasks.Task; +import com.huawei.hms.cordova.mltext.helpers.CordovaErrors; +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; +import com.huawei.hms.cordova.mltext.utils.TextUtils; +import com.huawei.hms.mlsdk.card.MLCardAnalyzerFactory; +import com.huawei.hms.mlsdk.card.icr.MLIcrAnalyzer; +import com.huawei.hms.mlsdk.card.icr.MLIcrAnalyzerSetting; +import com.huawei.hms.mlsdk.card.icr.MLIdCard; +import com.huawei.hms.mlsdk.common.MLApplication; +import com.huawei.hms.mlsdk.common.MLFrame; + +import org.apache.cordova.CallbackContext; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; + +public class MLIcrCardAnalyser extends HMSProvider { + + private static final String TAG = MLIcrCardAnalyser.class.getName(); + + private MLIcrAnalyzer localAnalyzer; + + private MLIcrAnalyzerSetting setting = null; + + public MLIcrCardAnalyser(Context ctx) { + super(ctx); + } + + public void initializeIcrCardAnalyser(final JSONObject params, final CallbackContext callbackContext) + throws JSONException, IOException { + + JSONObject settings = params.optJSONObject("mlIcrAnalyzerSetting"); + if (settings != null) { + setting = TextUtils.toObject(settings, MLIcrAnalyzerSetting.class); + } else { + callbackContext.error(CordovaErrors.ILLEGAL_PARAMETER); + } + + MLFrame frame = HMSMLUtils.getFrame(getContext(), params); + localAnalyzer = MLCardAnalyzerFactory.getInstance().getIcrAnalyzer(setting); + + Task task = localAnalyzer.asyncAnalyseFrame(frame); + task.addOnSuccessListener(new OnSuccessListener() { + public void onSuccess(MLIdCard idCard) { + Log.i(TAG, "IdCallBack onRecSuccess"); + if (idCard == null) { + Log.i(TAG, "IdCallBack onRecSuccess idCardResult is null"); + return; + } + try { + JSONObject icrResult = new JSONObject(); + Bitmap bitmap = idCard.getCardBitmap(); + + if (setting.getSideType().equalsIgnoreCase("FRONT")) { + icrResult.putOpt("idNum", idCard.getIdNum()); + icrResult.putOpt("name", idCard.getName()); + icrResult.putOpt("retCıde", idCard.getRetCode()); + icrResult.putOpt("sex", idCard.getSex()); + icrResult.putOpt("sideType", idCard.getSideType()); + icrResult.putOpt("cardBitmap", HMSMLUtils.bitmapToBase64(bitmap)); + } else { + icrResult.putOpt("validDate", idCard.getValidDate()); + } + + callbackContext.success(icrResult); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlIcrPluginDetector"); + + } catch (JSONException e) { + Log.e(TAG, "MLVnIcrCapture.Callback: error ->" + e.getMessage()); + } + + } + }).addOnFailureListener(new OnFailureListener() { + public void onFailure(Exception e) { + callbackContext.error("callback onFailure"); + HMSLogger.getInstance(getContext()).sendSingleEvent("IcrPluginDetector", "-1"); + Log.e(TAG, "callback onCameraDenied"); + } + }); + } + + public void createIdCard(final JSONObject params, final CallbackContext callbackContext) { + final MLApplication mlApplication = MLApplication.getInstance(); + JSONObject mlIcrAnalyzerSetting = params.optJSONObject("mlIcrAnalyzerSetting "); + if (mlIcrAnalyzerSetting != null) { + setting = TextUtils.toObject(mlIcrAnalyzerSetting, MLIcrAnalyzerSetting.class); + } else { + HMSLogger.getInstance(getContext()).sendSingleEvent("IcrPluginDetector", "-1"); + callbackContext.error(CordovaErrors.ILLEGAL_PARAMETER); + } + HMSLogger.getInstance(getContext()).sendSingleEvent("mlIcrPlugin Create "); + MLIcrAnalyzer.create(mlApplication, setting); + callbackContext.success(); + } + + public void stopIcrCard(CallbackContext context) throws IOException { + this.localAnalyzer.stop(); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlIcrPlugin Stop "); + context.success(); + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/idcard/MLIcrCnCardAnalyser.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/idcard/MLIcrCnCardAnalyser.java new file mode 100644 index 00000000..3304adab --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/idcard/MLIcrCnCardAnalyser.java @@ -0,0 +1,162 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.idcard; + +import android.content.Context; +import android.graphics.Bitmap; +import android.net.Uri; +import android.provider.MediaStore; +import android.util.Log; + +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; +import com.huawei.hms.mlplugin.card.icr.cn.MLCnIcrCapture; +import com.huawei.hms.mlplugin.card.icr.cn.MLCnIcrCaptureConfig; +import com.huawei.hms.mlplugin.card.icr.cn.MLCnIcrCaptureFactory; +import com.huawei.hms.mlplugin.card.icr.cn.MLCnIcrCaptureResult; +import com.huawei.hms.mlsdk.common.MLFrame; + +import org.apache.cordova.CallbackContext; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; + +public class MLIcrCnCardAnalyser extends HMSProvider { + + private static final String TAG = MLIcrCnCardAnalyser.class.getName(); + + boolean isFront = true; + + private CallbackContext cordovaCallBackContext; + + private MLCnIcrCapture.CallBack idCallBack = new MLCnIcrCapture.CallBack() { + @Override + public void onSuccess(MLCnIcrCaptureResult mlCnIcrCaptureResult) { + Log.i(TAG, "IdCallBack onRecSuccess"); + + if (mlCnIcrCaptureResult == null) { + Log.i(TAG, "IdCallBack onRecSuccess idCardResult is null"); + return; + } + try { + + JSONObject icrResult = new JSONObject(); + JSONObject result = new JSONObject(); + if (isFront) { + icrResult.put("idNum", mlCnIcrCaptureResult.idNum); + icrResult.put("name", mlCnIcrCaptureResult.name); + icrResult.put("sex", mlCnIcrCaptureResult.sex); + icrResult.put("nation", mlCnIcrCaptureResult.nation); + icrResult.put("birthday", mlCnIcrCaptureResult.birthday); + icrResult.put("address", mlCnIcrCaptureResult.address); + } else { + icrResult.put("authority", mlCnIcrCaptureResult.authority); + icrResult.put("validDate", mlCnIcrCaptureResult.validDate); + } + result.putOpt("result", icrResult); + cordovaCallBackContext.success(result); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlIcrVnPluginDetector"); + } catch (JSONException e) { + Log.e(TAG, "MLVnIcrCapture.Callback: error ->" + e.getMessage()); + } + } + + @Override + public void onCanceled() { + cordovaCallBackContext.error("callback onCanceled"); + HMSLogger.getInstance(getContext()).sendSingleEvent("IcrVnPluginDetector", "-1"); + Log.e(TAG, "callback onCanceled"); + } + + @Override + public void onFailure(int restCode, Bitmap bitmap) { + cordovaCallBackContext.error(restCode + " callback onFailure"); + HMSLogger.getInstance(getContext()).sendSingleEvent("IcrVnPluginDetector", "-1"); + Log.e(TAG, "callback onFailure"); + } + + @Override + public void onDenied() { + cordovaCallBackContext.error("callback onCameraDenied"); + HMSLogger.getInstance(getContext()).sendSingleEvent("IcrVnPluginDetector", "-1"); + Log.e(TAG, "callback onCameraDenied"); + } + }; + + public MLIcrCnCardAnalyser(Context ctx) { + super(ctx); + } + + public void initializeIcrCnCardAnalyser(final JSONObject params, final CallbackContext callbackContext) + throws JSONException, IOException { + cordovaCallBackContext = callbackContext; + + int captureType = params.optInt("captureType", 0); + isFront = params.optBoolean("isFront"); + + if (captureType == 0) { + startCapture(idCallBack, isFront); + } else if (captureType == 1) { + startCaptureImage(idCallBack, params); + } + + } + + private void startCapture(MLCnIcrCapture.CallBack idCallBack, boolean isFlag) { + MLCnIcrCaptureConfig config = new MLCnIcrCaptureConfig.Factory().setFront(isFlag).create(); + MLCnIcrCapture icrCapture = MLCnIcrCaptureFactory.getInstance().getIcrCapture(config); + icrCapture.capture(idCallBack, getContext()); + } + + private void startCaptureImage(MLCnIcrCapture.CallBack idCallBack, JSONObject params) + throws JSONException, IOException { + Bitmap bitmap = null; + String filePath = params.getString("filePath"); + Uri uri = Uri.parse(filePath); + MLCnIcrCaptureConfig config = new MLCnIcrCaptureConfig.Factory().setFront(isFront).create(); + MLCnIcrCapture icrCapture = MLCnIcrCaptureFactory.getInstance().getIcrCapture(config); + if (!Uri.EMPTY.equals(uri)) { + bitmap = MediaStore.Images.Media.getBitmap(getContext().getContentResolver(), uri); + } + MLFrame frame = HMSMLUtils.getFrame(getContext(), params); + CordovaHelpers.frameController(frame, getContext(), cordovaCallBackContext, "IcrCnpluginDetector"); + icrCapture.captureImage(bitmap, idCallBack); + } + + public void create(CallbackContext context) { + MLCnIcrCaptureConfig config = new MLCnIcrCaptureConfig.Factory().create(); + HMSLogger.getInstance(getContext()).sendSingleEvent("create()"); + context.success(config.toString()); + } + + public void getIcrCnCapture(CallbackContext context) { + MLCnIcrCaptureConfig config = new MLCnIcrCaptureConfig.Factory().create(); + MLCnIcrCapture icrCapture = MLCnIcrCaptureFactory.getInstance().getIcrCapture(config); + HMSLogger.getInstance(getContext()).sendSingleEvent("getIcrCnCapture"); + context.success(icrCapture.toString()); + } + + public void getInstance(CallbackContext context) { + MLCnIcrCaptureFactory icrCapture = MLCnIcrCaptureFactory.getInstance(); + HMSLogger.getInstance(getContext()).sendSingleEvent("getIcrCnInstance"); + context.success(icrCapture.toString()); + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/idcard/MLIcrVnCardAnalyser.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/idcard/MLIcrVnCardAnalyser.java new file mode 100644 index 00000000..758e2cac --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/idcard/MLIcrVnCardAnalyser.java @@ -0,0 +1,157 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.idcard; + +import android.content.Context; +import android.graphics.Bitmap; +import android.net.Uri; +import android.provider.MediaStore; +import android.util.Log; + +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; +import com.huawei.hms.mlplugin.card.icr.vn.MLVnIcrCapture; +import com.huawei.hms.mlplugin.card.icr.vn.MLVnIcrCaptureConfig; +import com.huawei.hms.mlplugin.card.icr.vn.MLVnIcrCaptureFactory; +import com.huawei.hms.mlplugin.card.icr.vn.MLVnIcrCaptureResult; +import com.huawei.hms.mlsdk.common.MLFrame; + +import org.apache.cordova.CallbackContext; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; + +public class MLIcrVnCardAnalyser extends HMSProvider { + + private static final String TAG = MLIcrVnCardAnalyser.class.getName(); + + private CallbackContext cordovaCallBackContext; + + private MLVnIcrCapture.CallBack idCallBack = new MLVnIcrCapture.CallBack() { + + @Override + public void onSuccess(MLVnIcrCaptureResult idCardResult) { + Log.i(TAG, "IdCallBack onRecSuccess"); + + if (idCardResult == null) { + Log.i(TAG, "IdCallBack onRecSuccess idCardResult is null"); + return; + } + try { + JSONObject icrResult = new JSONObject(); + Bitmap bitmap = idCardResult.getCardBitmap(); + + icrResult.putOpt("birthday", idCardResult.getBirthday()); + icrResult.putOpt("idNum", idCardResult.getIdNum()); + icrResult.putOpt("name", idCardResult.getName()); + icrResult.putOpt("sex", idCardResult.getSex()); + icrResult.putOpt("cardBitmap", HMSMLUtils.bitmapToBase64(bitmap)); + + cordovaCallBackContext.success(icrResult); + HMSLogger.getInstance(getContext()).sendSingleEvent("mlIcrVnPluginDetector"); + + } catch (JSONException e) { + Log.e(TAG, "MLVnIcrCapture.Callback: error ->" + e.getMessage()); + } + + } + + @Override + public void onCanceled() { + cordovaCallBackContext.error("callback onCanceled"); + HMSLogger.getInstance(getContext()).sendSingleEvent("IcrVnPluginDetector", "-1"); + Log.e(TAG, "callback onCanceled"); + } + + @Override + public void onFailure(int restCode, Bitmap bitmap) { + cordovaCallBackContext.error(restCode + " callback onFailure"); + HMSLogger.getInstance(getContext()).sendSingleEvent("IcrVnPluginDetector", "-1"); + Log.e(TAG, "callback onFailure"); + } + + @Override + public void onDenied() { + cordovaCallBackContext.error("callback onCameraDenied"); + HMSLogger.getInstance(getContext()).sendSingleEvent("IcrVnPluginDetector", "-1"); + Log.e(TAG, "callback onCameraDenied"); + } + + }; + + public MLIcrVnCardAnalyser(Context ctx) { + super(ctx); + } + + public void initializeIcrVnCardAnalyser(final JSONObject params, final CallbackContext callbackContext) + throws JSONException, IOException { + + cordovaCallBackContext = callbackContext; + + int captureType = params.optInt("captureType"); + if (captureType == 0) { + startCapture(idCallBack); + } else if (captureType == 1) { + startCaptureImage(idCallBack, params); + } + } + + private void startCapture(MLVnIcrCapture.CallBack idCallBack) { + MLVnIcrCaptureConfig config = new MLVnIcrCaptureConfig.Factory().create(); + MLVnIcrCapture icrCapture = MLVnIcrCaptureFactory.getInstance().getIcrCapture(config); + icrCapture.capture(idCallBack, getContext()); + + } + + private void startCaptureImage(MLVnIcrCapture.CallBack idCallBack, JSONObject params) + throws JSONException, IOException { + Bitmap bitmap = null; + String filePath = params.getString("filePath"); + Uri uri = Uri.parse(filePath); + MLVnIcrCaptureConfig config = new MLVnIcrCaptureConfig.Factory().create(); + MLVnIcrCapture icrCapture = MLVnIcrCaptureFactory.getInstance().getIcrCapture(config); + if (!Uri.EMPTY.equals(uri)) { + bitmap = MediaStore.Images.Media.getBitmap(getContext().getContentResolver(), uri); + } + MLFrame frame = HMSMLUtils.getFrame(getContext(), params); + CordovaHelpers.frameController(frame, getContext(), cordovaCallBackContext, "IcrVnpluginDetector"); + icrCapture.captureImage(bitmap, idCallBack); + } + + public void create(CallbackContext context) { + MLVnIcrCaptureConfig config = new MLVnIcrCaptureConfig.Factory().create(); + HMSLogger.getInstance(getContext()).sendSingleEvent("create()"); + context.success(config.toString()); + } + + public void getIcrVnCapture(CallbackContext context) { + MLVnIcrCaptureConfig config = new MLVnIcrCaptureConfig.Factory().create(); + MLVnIcrCapture icrCapture = MLVnIcrCaptureFactory.getInstance().getIcrCapture(config); + HMSLogger.getInstance(getContext()).sendSingleEvent("getIcrVnCapture"); + context.success(icrCapture.toString()); + } + + public void getInstance(CallbackContext context) { + MLVnIcrCaptureFactory icrCapture = MLVnIcrCaptureFactory.getInstance(); + HMSLogger.getInstance(getContext()).sendSingleEvent("getIcrVnInstance"); + context.success(icrCapture.toString()); + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/text/MLImageTextAnalyser.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/text/MLImageTextAnalyser.java new file mode 100644 index 00000000..4adcc0a8 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/providers/textproviders/text/MLImageTextAnalyser.java @@ -0,0 +1,198 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.providers.textproviders.text; + +import android.content.Context; +import android.util.SparseArray; + +import com.huawei.hmf.tasks.Task; +import com.huawei.hms.cordova.mltext.helpers.CordovaErrors; +import com.huawei.hms.cordova.mltext.helpers.CordovaHelpers; +import com.huawei.hms.cordova.mltext.interfaces.HMSProvider; +import com.huawei.hms.cordova.mltext.logger.HMSLogger; +import com.huawei.hms.cordova.mltext.logger.HMSMethod; +import com.huawei.hms.cordova.mltext.utils.HMSMLUtils; +import com.huawei.hms.cordova.mltext.utils.PlatformUtils; +import com.huawei.hms.cordova.mltext.utils.TextUtils; +import com.huawei.hms.mlsdk.MLAnalyzerFactory; +import com.huawei.hms.mlsdk.common.MLFrame; +import com.huawei.hms.mlsdk.text.MLLocalTextSetting; +import com.huawei.hms.mlsdk.text.MLRemoteTextSetting; +import com.huawei.hms.mlsdk.text.MLText; +import com.huawei.hms.mlsdk.text.MLTextAnalyzer; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaInterface; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; + +public class MLImageTextAnalyser extends HMSProvider { + private String TAG = MLImageTextAnalyser.class.getSimpleName(); + + private MLTextAnalyzer analyzer; + + private boolean flag = false; + + private MLLocalTextSetting mlLocalTextSetting; + + private MLRemoteTextSetting mlRemoteTextSetting; + + private String language = "rm"; + + private int ocrMode = 1; + + public MLImageTextAnalyser(Context context) { + super(context); + } + + public void initializeLocalImageTextAnalyser(final JSONObject params, final CallbackContext callbackContext) + throws JSONException { + HMSMethod method = new HMSMethod("localImageTextAnalyser"); + MLFrame frame = HMSMLUtils.getFrame(getContext(), params); + CordovaHelpers.frameController(frame, getContext(), callbackContext, "localImageTextAnalyser"); + int analyseMode = params.getInt("analyseMode"); + JSONObject localTextSetting = params.optJSONObject("localTextSetting"); + if (localTextSetting != null) { + mlLocalTextSetting = TextUtils.toObject(localTextSetting, MLLocalTextSetting.class); + language = localTextSetting.optString("languae", "rm"); + ocrMode = localTextSetting.optInt("ocrMode", 1); + + } else { + mlLocalTextSetting = new MLLocalTextSetting.Factory().create(); + } + if (analyseMode == 0) { + analyzer = MLAnalyzerFactory.getInstance().getLocalTextAnalyzer(); + Task task = analyzer.asyncAnalyseFrame(frame); + task.addOnSuccessListener(PlatformUtils.successListener(method, getActivity(), callbackContext, + TextUtils.FROM_MLTEXT_TO_JSON_OBJECT)) + .addOnFailureListener(PlatformUtils.failureListener(method, getActivity(), callbackContext)); + } else if (analyseMode == 1) { + syncMode(language, ocrMode, callbackContext, frame); + } else { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ILLEGAL_PARAMETER)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("localImageTextAnalyser", String.valueOf(CordovaErrors.ILLEGAL_PARAMETER)); + } + + } + + public void initializeRemoteImageTextAnalyser(final JSONObject params, final CallbackContext callbackContext) + throws JSONException, IOException { + flag = true; + HMSMethod method = new HMSMethod("remoteImageTextAnalyser"); + MLFrame frame = HMSMLUtils.getFrame(getContext(), params); + CordovaHelpers.frameController(frame, getContext(), callbackContext, "remoteImageTextAnalyser"); + JSONObject remoteTextSetting = params.optJSONObject("remoteTextSetting"); + if (remoteTextSetting != null) { + mlRemoteTextSetting = TextUtils.toObject(remoteTextSetting, MLRemoteTextSetting.class); + language = remoteTextSetting.optString("languae", "rm"); + ocrMode = remoteTextSetting.optInt("ocrMode", 1); + } else { + mlRemoteTextSetting = new MLRemoteTextSetting.Factory().create(); + + } + int analyseRemoteMode = params.getInt("analyseMode"); + switch (analyseRemoteMode) { + case 1: { + syncMode(language, ocrMode, callbackContext, frame); + break; + } + case 0: { + analyzer = MLAnalyzerFactory.getInstance().getRemoteTextAnalyzer(mlRemoteTextSetting); + Task task = analyzer.asyncAnalyseFrame(frame); + task.addOnSuccessListener(PlatformUtils.successListener(method, getActivity(), callbackContext, + TextUtils.FROM_MLTEXT_TO_JSON_OBJECT)) + .addOnFailureListener(PlatformUtils.failureListener(method, getActivity(), callbackContext)); + break; + } + default: + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ILLEGAL_PARAMETER)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("localImageTextAnalyser", String.valueOf(CordovaErrors.ILLEGAL_PARAMETER)); + break; + } + + } + + private void syncMode(String language, int ocrMode, CallbackContext callbackContext, MLFrame frame) { + SparseArray analyseFrameSparseArray = new MLTextAnalyzer.Factory(getContext()).setLocalOCRMode( + ocrMode).setLanguage(language).create().analyseFrame(frame); + if (analyseFrameSparseArray != null) { + callbackContext.success(TextUtils.fromSparseArrayMLTextBlockToJSON(analyseFrameSparseArray)); + HMSLogger.getInstance(getContext()).sendSingleEvent("imageTextAnalyser"); + } + } + + public void closeImgTextAnalyser(final CallbackContext callbackContext, final CordovaInterface cordovaInterface) + throws IOException { + if (analyzer == null) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ANALYSIS_FAILURE)); + HMSLogger.getInstance(cordovaInterface.getContext()) + .sendSingleEvent("imageTextAnalyserStop", String.valueOf(CordovaErrors.ANALYSIS_FAILURE)); + } else { + analyzer.close(); + analyzer = null; + callbackContext.success("Analyzer closed"); + HMSLogger.getInstance(cordovaInterface.getContext()).sendSingleEvent("imageTextAnalyserStop"); + } + } + + public void getImgTextAnalyserInfo(final CallbackContext callbackContext, final CordovaInterface cordovaInterface) + throws JSONException { + int analyseType; + boolean isAnalyserAvailable; + if (analyzer == null) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ANALYSIS_NULL)); + HMSLogger.getInstance(cordovaInterface.getContext()) + .sendSingleEvent("imageTextAnalyserInfo", String.valueOf(CordovaErrors.ANALYSIS_NULL)); + return; + } + isAnalyserAvailable = analyzer.isAvailable(); + analyseType = analyzer.getAnalyseType(); + JSONObject analyserInfo = new JSONObject(); + analyserInfo.putOpt("isAnalyserAvailable", isAnalyserAvailable); + analyserInfo.putOpt("analyseType", analyseType); + callbackContext.success(analyserInfo); + HMSLogger.getInstance(cordovaInterface.getContext()).sendSingleEvent("imageTextAnalyserInfo"); + } + + public void getTextSetting(final CallbackContext callbackContext) throws JSONException { + if (analyzer == null) { + callbackContext.error(CordovaErrors.toErrorJSON(CordovaErrors.ANALYSIS_NULL)); + HMSLogger.getInstance(getContext()) + .sendSingleEvent("imageTextAnalyserSetting", String.valueOf(CordovaErrors.ANALYSIS_NULL)); + return; + } else { + JSONObject jsonObject = new JSONObject(); + if (flag) { + jsonObject.putOpt("borderType", mlRemoteTextSetting.getBorderType()); + jsonObject.putOpt("languageList", mlRemoteTextSetting.getLanguageList()); + jsonObject.putOpt("textDensityScene", mlRemoteTextSetting.getTextDensityScene()); + jsonObject.putOpt("isEnableFingerprintVerification", + mlRemoteTextSetting.isEnableFingerprintVerification()); + } else { + jsonObject.putOpt("language", mlLocalTextSetting.getLanguage()); + jsonObject.putOpt("ocrMode", mlLocalTextSetting.getOCRMode()); + } + callbackContext.success(jsonObject); + HMSLogger.getInstance(getContext()).sendSingleEvent("imageTextAnalyserSetting"); + } + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/HMSMLUtils.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/HMSMLUtils.java new file mode 100644 index 00000000..ff2bc1fc --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/HMSMLUtils.java @@ -0,0 +1,75 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.utils; + +import android.content.Context; +import android.graphics.Bitmap; +import android.net.Uri; +import android.provider.MediaStore; +import android.util.Base64; +import android.util.Log; + +import com.huawei.hms.mlsdk.common.MLFrame; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; + +public class HMSMLUtils { + private static String TAG = HMSMLUtils.class.getSimpleName(); + + private HMSMLUtils() { + } + + public static String bitmapToBase64(final Bitmap bitmap) { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); + byte[] byteArray = byteArrayOutputStream.toByteArray(); + return Base64.encodeToString(byteArray, Base64.DEFAULT); + } + + public static JSONArray listToJSONArray(final List list, final Mapper mapper) + throws JSONException { + JSONArray array = new JSONArray(); + for (T item : list) { + array.put(mapper.map(item)); + } + return array; + } + + public static MLFrame getFrame(final Context context, final JSONObject json) { + try { + if (json.has("filePath")) { + String filePath = json.getString("filePath"); + Uri uri = Uri.parse(filePath); + if (!Uri.EMPTY.equals(uri)) { + Bitmap bitmap = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri); + return new MLFrame.Creator().setBitmap(bitmap).create(); + } + } else { + Log.e(TAG, "getFrame: error -> invalid action"); + } + } catch (IOException | JSONException e) { + Log.e(TAG, "getFrame: error -> " + e.toString()); + } + return null; + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/MLError.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/MLError.java new file mode 100644 index 00000000..4a440847 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/MLError.java @@ -0,0 +1,74 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.utils; + +import android.util.Log; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; + +public class MLError { + public static final int ERROR_NO_CAMERA_PERMISSION = 1; + + public static final int ERROR_NO_READ_PERMISSION = 2; + + public static final int ERROR_NO_WRITE_PERMISSION = 3; + + public static final int ERROR_NO_AUDIO_PERMISSION = 4; + + static final Map ERROR_MSGS = new HashMap<>(); + + static { + ERROR_MSGS.put(ERROR_NO_CAMERA_PERMISSION, "App does not have camera permission"); + ERROR_MSGS.put(ERROR_NO_READ_PERMISSION, "App does not have read permission"); + ERROR_MSGS.put(ERROR_NO_WRITE_PERMISSION, "App does not have write permission"); + ERROR_MSGS.put(ERROR_NO_AUDIO_PERMISSION, "App does not have audio permission"); + } + + public MLError() { + } + + public static JSONObject toErrorJSON(final int errorCode) { + try { + return new JSONObject().put("errorCode", errorCode).put("errorMessage", ERROR_MSGS.get(errorCode)); + } catch (JSONException e) { + Log.e("toErrorJSON get error: ", e.getMessage()); + } + return new JSONObject(); + } + + public static JSONObject toErrorJSON(final int errorCode, final Throwable t) { + try { + return new JSONObject().put("errorCode", errorCode).put("errorMessage", t.getMessage()); + } catch (JSONException e) { + Log.e("toErrorJSON get error: ", e.getMessage()); + } + return new JSONObject(); + } + + public static JSONObject toErrorJSON(final int errorCode, final String t) { + try { + return new JSONObject().put("errorCode", errorCode).put("errorMessage", t); + } catch (JSONException e) { + Log.e("toErrorJSON get error: ", e.getMessage()); + } + return new JSONObject(); + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/Mapper.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/Mapper.java new file mode 100644 index 00000000..ea1416ee --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/Mapper.java @@ -0,0 +1,31 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.utils; + +import org.json.JSONException; + +@FunctionalInterface +public interface Mapper { + /** + * A simple mapping between X and Y. + * + * @param in X + * @return Y + * @throws JSONException Exception that may be thrown from JSONObject + */ + Y map(X in) throws JSONException; +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/PlatformUtils.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/PlatformUtils.java new file mode 100644 index 00000000..d085431d --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/PlatformUtils.java @@ -0,0 +1,114 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.utils; + +import android.app.Activity; +import android.util.Log; + +import com.huawei.hmf.tasks.OnFailureListener; +import com.huawei.hmf.tasks.OnSuccessListener; +import com.huawei.hms.cordova.mltext.interfaces.JSONMapper; +import com.huawei.hms.cordova.mltext.logger.HMSMethod; +import com.huawei.hms.mlsdk.common.MLException; + +import org.apache.cordova.CallbackContext; +import org.json.JSONException; +import org.json.JSONObject; + +public class PlatformUtils { + private final static String TAG = PlatformUtils.class.getSimpleName(); + + private static final int RESOLUTION_REQUEST = 66666; + + public static JSONObject keyValPair(String key, T val) { + JSONObject map = new JSONObject(); + try { + map.put(key, val); + } catch (JSONException e) { + Log.d(TAG, "JSONException :: " + e.getMessage()); + } + return map; + } + + public static OnSuccessListener successListener(HMSMethod method, Activity activity, + CallbackContext callback) { + return value -> { + Log.d(TAG, "successListener()"); + method.sendLoggerEvent(activity); + callback.success(); + }; + } + + public static OnSuccessListener successListener(HMSMethod method, Activity activity, + CallbackContext callback, Mapper mapper) { + return value -> { + Log.d(TAG, "successListener()"); + if (value == null) { + Log.e(TAG, "Value is null."); + callback.error("-1"); + method.sendLoggerEvent(activity, "-1"); + return; + } + method.sendLoggerEvent(activity); + try { + Log.i(TAG, "" + mapper.map(value)); + callback.success(mapper.map(value)); + } catch (JSONException e) { + Log.e(TAG, "successListener: error ->", e); + } + }; + } + + public static OnSuccessListener successListener(HMSMethod method, Activity activity, + CallbackContext callback, JSONObject json) { + return value -> { + Log.d(TAG, "successListener()"); + method.sendLoggerEvent(activity); + callback.success(json); + }; + } + + public static OnFailureListener failureListener(HMSMethod method, Activity activity, CallbackContext callback) { + return e -> { + Log.d(TAG, "failureListener() :: " + e.getMessage()); + + if (!(e instanceof MLException)) { + MLException mlException = (MLException) e; + String error = "error code: " + mlException.getErrCode() + "\n" + "error message: " + + mlException.getMessage(); + method.sendLoggerEvent(activity, "-1"); + callback.error(error); + } + }; + } + + public static Mapper mapperWrapper(JSONMapper jm, R def) { + return arg -> { + if (arg == null) { + return null; + } + + try { + return jm.map(arg); + } catch (JSONException | NullPointerException e) { + Log.e(TAG, "wrapper :: JSONException, " + e.getMessage()); + return def; + } + }; + } + +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/TextUtils.java b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/TextUtils.java new file mode 100644 index 00000000..c4c1806e --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/java/com/huawei/hms/cordova/mltext/utils/TextUtils.java @@ -0,0 +1,795 @@ +/* + * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.huawei.hms.cordova.mltext.utils; + +import static com.huawei.hms.cordova.mltext.utils.PlatformUtils.mapperWrapper; + +import android.graphics.Bitmap; +import android.graphics.Point; +import android.graphics.Rect; +import android.util.Log; +import android.util.SparseArray; + +import com.huawei.hms.common.size.Size; +import com.huawei.hms.mlplugin.card.icr.cn.MLCnIcrCaptureConfig; +import com.huawei.hms.mlsdk.card.bcr.MLBankCard; +import com.huawei.hms.mlsdk.classification.MLImageClassification; +import com.huawei.hms.mlsdk.common.MLApplicationSetting; +import com.huawei.hms.mlsdk.common.MLCoordinate; +import com.huawei.hms.mlsdk.common.MLFrame.Property; +import com.huawei.hms.mlsdk.common.MLPosition; +import com.huawei.hms.mlsdk.document.MLDocument; +import com.huawei.hms.mlsdk.dsc.MLDocumentSkewCorrectionResult; +import com.huawei.hms.mlsdk.face.MLFace; +import com.huawei.hms.mlsdk.face.MLFaceKeyPoint; +import com.huawei.hms.mlsdk.face.MLFaceShape; +import com.huawei.hms.mlsdk.face.face3d.ML3DFace; +import com.huawei.hms.mlsdk.imgseg.MLImageSegmentation; +import com.huawei.hms.mlsdk.landmark.MLRemoteLandmark; +import com.huawei.hms.mlsdk.objects.MLObject; +import com.huawei.hms.mlsdk.productvisionsearch.MLProductVisionSearch; +import com.huawei.hms.mlsdk.productvisionsearch.MLVisionSearchProduct; +import com.huawei.hms.mlsdk.productvisionsearch.MLVisionSearchProductImage; +import com.huawei.hms.mlsdk.text.MLText; +import com.huawei.hms.mlsdk.text.TextLanguage; + +import com.google.gson.Gson; + +import org.apache.cordova.CordovaInterface; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TextUtils { + public static final Mapper FROM_BCR_TO_JSON_OBJECT = mapperWrapper( + (MLBankCard mlBankCard) -> { + JSONObject map = new JSONObject(); + map.put("expire", mlBankCard.getExpire()); + map.put("number", mlBankCard.getNumber()); + map.put("retCode", mlBankCard.getRetCode()); + map.put("tipsCode", mlBankCard.getTipsCode()); + if (mlBankCard.getOriginalBitmap() != null) { + map.optString("originalBitmap", HMSMLUtils.bitmapToBase64(mlBankCard.getOriginalBitmap())); + } + if (mlBankCard.getNumberBitmap() != null) { + map.optString("numberBitmap", HMSMLUtils.bitmapToBase64(mlBankCard.getNumberBitmap())); + } + return map; + }, new JSONObject()); + + + public static final Mapper FROM_IMGSEG_TO_JSON_OBJECT = mapperWrapper( + (MLImageSegmentation mlImageSegmentation) -> { + JSONObject map = new JSONObject(); + Bitmap bitmapFore = mlImageSegmentation.getForeground(); + Bitmap bitmapGrayScale = mlImageSegmentation.getGrayscale(); + Bitmap bitmapOriginal = mlImageSegmentation.getOriginal(); + map.putOpt("bitmapForeground", HMSMLUtils.bitmapToBase64(bitmapFore)); + map.putOpt("bitmapGrayscale", HMSMLUtils.bitmapToBase64(bitmapGrayScale)); + map.putOpt("masks", mlImageSegmentation.getMasks()); + map.putOpt("bitmapOriginal", HMSMLUtils.bitmapToBase64(bitmapOriginal)); + return map; + }, new JSONObject()); + + + public static final Mapper, JSONObject> FROM_MLCLASS_TO_JSON_OBJECT = mapperWrapper( + (List mlImageClassification) -> { + JSONObject map = new JSONObject(); + JSONArray array = HMSMLUtils.listToJSONArray(mlImageClassification, TextUtils::classificationResultToJSON); + map.putOpt("result", array); + return map; + }, new JSONObject()); + + + public static final Mapper, JSONObject> FROM_ML3DFACE_TO_JSON_OBJECT = mapperWrapper( + (List mlFace) -> { + JSONObject map = new JSONObject(); + JSONArray array = HMSMLUtils.listToJSONArray(mlFace, TextUtils::ml3DFacetoJSON); + map.putOpt("result", array); + + return map; + }, new JSONObject()); + + + private static final String TAG = TextUtils.class.getSimpleName(); + + public static final Mapper, JSONObject> FROM_MLOBJECT_TO_JSON_OBJECT = mapperWrapper( + (List mlObjects) -> { + JSONObject map = new JSONObject(); + JSONArray array = HMSMLUtils.listToJSONArray(mlObjects, TextUtils::mlObjectsListTOJSON); + map.putOpt("result", array); + return map; + }, new JSONObject()); + + public static final Mapper FROM_MLTEXT_TO_JSON_OBJECT = mapperWrapper((MLText mlText) -> { + JSONObject map = new JSONObject(); + map.put("stringValue", mlText.getStringValue()); + map.put("blocks", HMSMLUtils.listToJSONArray(mlText.getBlocks(), TextUtils::fromMLTextBlockToJSON)); + return map; + }, new JSONObject()); + + public static final Mapper FROM_MLDOC_TO_JSON_OBJECT = mapperWrapper( + (MLDocument mlDocument) -> { + JSONObject map = new JSONObject(); + map.put("stringValue", mlDocument.getStringValue()); + map.put("blocks", HMSMLUtils.listToJSONArray(mlDocument.getBlocks(), TextUtils::fromMLDocumentBlockToJSON)); + return map; + }, new JSONObject()); + + public static final Mapper, JSONObject> FROM_MLFACE_TO_JSON_OBJECT = mapperWrapper( + (List mlFace) -> { + JSONObject map = new JSONObject(); + JSONArray array = HMSMLUtils.listToJSONArray(mlFace, TextUtils::mlFacetoJSON); + map.putOpt("result", array); + + return map; + }, new JSONObject()); + + public static final Mapper, JSONObject> FROM_MLREMOTELANDMARK_TO_JSON_OBJECT = mapperWrapper( + (List mlRemoteLandmarks) -> { + JSONObject map = new JSONObject(); + JSONArray array = HMSMLUtils.listToJSONArray(mlRemoteLandmarks, TextUtils::landmarkResultToJSON); + map.putOpt("result", array); + + return map; + }, new JSONObject()); + + + + private static Gson gson = new Gson(); + + + // MLDocument + public static JSONObject fromMLDocumentToJSON(final MLDocument document) { + JSONObject result = new JSONObject(); + try { + result.putOpt("stringValue", document.getStringValue()); + result.putOpt("blocks", + HMSMLUtils.listToJSONArray(document.getBlocks(), TextUtils::fromMLDocumentBlockToJSON)); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + public static JSONObject fromMLDocumentBlockToJSON(final MLDocument.Block block) { + JSONObject result = new JSONObject(); + try { + result.putOpt("stringValue", block.getStringValue()); + result.putOpt("possibility", block.getPossibility()); + result.putOpt("border", borderToJSON(block.getBorder())); + JSONObject interval = new JSONObject(); + interval.putOpt("intervalType", block.getInterval().getIntervalType()); + interval.putOpt("isTextFollowed", block.getInterval().isTextFollowed()); + result.putOpt("interval", interval); + result.putOpt("sections", + HMSMLUtils.listToJSONArray(block.getSections(), TextUtils::fromMLDocumentSectionsToJSON)); + result.putOpt("languageList", + HMSMLUtils.listToJSONArray(block.getLanguageList(), TextUtils::fromTextLanguageToJSON)); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + public static JSONObject fromMLDocumentSectionsToJSON(final MLDocument.Section section) { + JSONObject result = new JSONObject(); + try { + result.putOpt("stringValue", section.getStringValue()); + result.putOpt("border", borderToJSON(section.getBorder())); + JSONObject interval = new JSONObject(); + interval.putOpt("intervalType", section.getInterval().getIntervalType()); + interval.putOpt("isTextFollowed", section.getInterval().isTextFollowed()); + result.putOpt("interval", interval); + result.putOpt("possibility", section.getPossibility()); + result.putOpt("languageList", + HMSMLUtils.listToJSONArray(section.getLanguageList(), TextUtils::fromTextLanguageToJSON)); + result.putOpt("lineList", + HMSMLUtils.listToJSONArray(section.getLineList(), TextUtils::fromLineListLanguageToJSON)); + result.putOpt("wordList", HMSMLUtils.listToJSONArray(section.getWordList(), TextUtils::fromWordListToJSON)); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + private static JSONObject fromLineListLanguageToJSON(final MLDocument.Line line) { + JSONObject result = new JSONObject(); + try { + result.putOpt("stringValue", line.getStringValue()); + result.putOpt("border", borderToJSON(line.getBorder())); + result.putOpt("possibility", line.getPossibility()); + result.putOpt("languageList", + HMSMLUtils.listToJSONArray(line.getLanguageList(), TextUtils::fromTextLanguageToJSON)); + result.putOpt("wordList", HMSMLUtils.listToJSONArray(line.getWordList(), TextUtils::fromWordListToJSON)); + result.putOpt("points", HMSMLUtils.listToJSONArray(line.getPoints(), TextUtils::fromPointToJSON)); + JSONObject interval = new JSONObject(); + interval.putOpt("intervalType", line.getInterval().getIntervalType()); + interval.putOpt("isTextFollowed", line.getInterval().isTextFollowed()); + result.putOpt("interval", interval); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + public static JSONObject fromPointToJSON(Point point) { + JSONObject result = new JSONObject(); + try { + result.putOpt("x", point.x); + result.putOpt("y", point.y); + result.putOpt("describeContents", point.describeContents()); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + private static JSONObject fromWordListToJSON(final MLDocument.Word word) { + JSONObject result = new JSONObject(); + try { + result.putOpt("stringValue", word.getStringValue()); + result.putOpt("border", borderToJSON(word.getBorder())); + result.putOpt("characterList", + HMSMLUtils.listToJSONArray(word.getCharacterList(), TextUtils::fromCharacterListToJSON)); + result.putOpt("languageList", + HMSMLUtils.listToJSONArray(word.getLanguageList(), TextUtils::fromTextLanguageToJSON)); + result.putOpt("possibility", word.getPossibility()); + JSONObject interval = new JSONObject(); + interval.putOpt("intervalType", word.getInterval().getIntervalType()); + interval.putOpt("isTextFollowed", word.getInterval().isTextFollowed()); + result.putOpt("interval", interval); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + private static JSONObject fromCharacterListToJSON(final MLDocument.Character character) { + JSONObject result = new JSONObject(); + try { + JSONObject interval = new JSONObject(); + if (character.getInterval() != null) { + interval.putOpt("intervalType", character.getInterval().getIntervalType()); + interval.putOpt("isTextFollowed", character.getInterval().isTextFollowed()); + result.putOpt("interval", interval); + } + result.putOpt("stringValue", character.getStringValue()); + result.putOpt("possibility", character.getPossibility()); + result.putOpt("border", borderToJSON(character.getBorder())); + result.putOpt("languageList", + HMSMLUtils.listToJSONArray(character.getLanguageList(), TextUtils::fromTextLanguageToJSON)); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + // MlText + public static JSONObject fromMLTextToJSON(final MLText text) { + JSONObject result = new JSONObject(); + try { + result.putOpt("stringValue", text.getStringValue()); + result.putOpt("blocks", HMSMLUtils.listToJSONArray(text.getBlocks(), TextUtils::fromMLTextBlockToJSON)); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + public static JSONObject fromMLTextBlockToJSON(final MLText.Block block) { + JSONObject result = new JSONObject(); + try { + result.putOpt("contents", + HMSMLUtils.listToJSONArray(block.getContents(), TextUtils::fromBlockContentsToJSON)); + result.putOpt("stringValue", block.getStringValue()); + result.putOpt("possibility", block.getPossibility()); + result.putOpt("language", block.getLanguage()); + result.putOpt("border", borderToJSON(block.getBorder())); + result.putOpt("vertexes", + HMSMLUtils.listToJSONArray(Arrays.asList(block.getVertexes()), TextUtils::fromPointToJSON)); + result.putOpt("languageList", + HMSMLUtils.listToJSONArray(block.getLanguageList(), TextUtils::fromTextLanguageToJSON)); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + public static JSONObject fromBlockContentsToJSON(final MLText.TextLine line) { + JSONObject result = new JSONObject(); + try { + result.putOpt("stringValue", line.getStringValue()); + result.putOpt("rotatingDegree", line.getRotatingDegree()); + result.putOpt("isVertical", line.isVertical()); + result.putOpt("language", line.getLanguage()); + result.putOpt("border", borderToJSON(line.getBorder())); + result.putOpt("possibility", line.getPossibility()); + result.putOpt("contents", + HMSMLUtils.listToJSONArray(line.getContents(), TextUtils::fromLineContentsToJSON)); + result.putOpt("languageList", + HMSMLUtils.listToJSONArray(line.getLanguageList(), TextUtils::fromTextLanguageToJSON)); + result.putOpt("vertexes", + HMSMLUtils.listToJSONArray(Arrays.asList(line.getVertexes()), TextUtils::fromPointToJSON)); + + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + private static JSONObject fromLineContentsToJSON(final MLText.Word word) { + JSONObject result = new JSONObject(); + try { + result.putOpt("stringValue", word.getStringValue()); + result.putOpt("border", borderToJSON(word.getBorder())); + result.putOpt("language", word.getLanguage()); + result.putOpt("languageList", + HMSMLUtils.listToJSONArray(word.getLanguageList(), TextUtils::fromTextLanguageToJSON)); + result.putOpt("possibility", word.getPossibility()); + result.putOpt("vertexes", + HMSMLUtils.listToJSONArray(Arrays.asList(word.getVertexes()), TextUtils::fromPointToJSON)); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + public static JSONObject fromTextLanguageToJSON(final TextLanguage lang) { + JSONObject result = new JSONObject(); + try { + result.putOpt("language", lang.getLanguage()); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + public static JSONObject fromSparseArrayMLTextBlockToJSON(final SparseArray array) { + JSONObject json = new JSONObject(); + try { + for (int i = 0; i < array.size(); i++) { + int key = array.keyAt(i); + MLText.Block textBlock = array.get(key); + json.putOpt(String.valueOf(key), fromMLTextBlockToJSON(textBlock)); + } + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return json; + } + + public static JSONObject fromSparseArrayImageClassificationJSON(final SparseArray array) { + JSONObject json = new JSONObject(); + try { + for (int i = 0; i < array.size(); i++) { + int key = array.keyAt(i); + MLImageClassification classification = array.get(key); + json.putOpt(String.valueOf(key), fromImageClassificationToJSON(classification)); + } + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return json; + } + + public static JSONObject fromSparseArrayImageObjectJSON(final SparseArray array) { + JSONObject json = new JSONObject(); + try { + for (int i = 0; i < array.size(); i++) { + int key = array.keyAt(i); + MLObject object = array.get(key); + json.putOpt(String.valueOf(key), mlObjectsListTOJSON(object)); + } + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return json; + } + + public static MLCnIcrCaptureConfig.Factory xxx(final JSONObject jsonObject) { + final MLCnIcrCaptureConfig.Factory config = new MLCnIcrCaptureConfig.Factory(); + config.setFront(jsonObject.optBoolean("isFlag")); + + return config; + } + + public static JSONObject fromSparseArrayStillFaceAnalyseToJSON(final SparseArray array) { + JSONObject json = new JSONObject(); + try { + for (int i = 0; i < array.size(); i++) { + int key = array.keyAt(i); + MLFace mlFace = array.get(key); + json.putOpt(String.valueOf(key), mlFacetoJSON(mlFace)); + } + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return json; + } + + public static JSONObject fromSparseArrayStillFace3DAnalyseToJSON(final SparseArray array) { + JSONObject json = new JSONObject(); + try { + for (int i = 0; i < array.size(); i++) { + int key = array.keyAt(i); + ML3DFace mlFace = array.get(key); + json.putOpt(String.valueOf(key), ml3DFacetoJSON(mlFace)); + } + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return json; + } + + public static JSONObject fromSparseArrayImageSegmentationToJSON(final SparseArray array) { + JSONObject json = new JSONObject(); + try { + for (int i = 0; i < array.size(); i++) { + int key = array.keyAt(i); + MLImageSegmentation mlImageSegmentation = array.get(key); + json.putOpt(String.valueOf(key), getImageSegmentationResult(mlImageSegmentation)); + } + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return json; + } + + public static JSONObject bankCardResultToJSON(final MLBankCard bankCard) throws JSONException { + JSONObject bankCardResult = new JSONObject(); + bankCardResult.putOpt("expire", bankCard.getExpire()); + bankCardResult.putOpt("number", bankCard.getNumber()); + bankCardResult.putOpt("retCode", bankCard.getRetCode()); + bankCardResult.putOpt("tipsCode", bankCard.getTipsCode()); + if (bankCard.getOriginalBitmap() != null) { + bankCardResult.putOpt("originalBitmap", HMSMLUtils.bitmapToBase64(bankCard.getOriginalBitmap())); + } + if (bankCard.getNumberBitmap() != null) { + bankCardResult.putOpt("numberBitmap", HMSMLUtils.bitmapToBase64(bankCard.getNumberBitmap())); + } + return bankCardResult; + } + + public static JSONObject getImageSegmentationResult(final MLImageSegmentation imageSegmentationResult) + throws JSONException { + JSONObject jsonObject = new JSONObject(); + Bitmap bitmapFore = imageSegmentationResult.getForeground(); + Bitmap bitmapGrayScale = imageSegmentationResult.getGrayscale(); + Bitmap bitmapOriginal = imageSegmentationResult.getOriginal(); + jsonObject.putOpt("bitmapForeground", HMSMLUtils.bitmapToBase64(bitmapFore)); + jsonObject.putOpt("bitmapGrayscale", HMSMLUtils.bitmapToBase64(bitmapGrayScale)); + jsonObject.putOpt("masks", imageSegmentationResult.getMasks()); + jsonObject.putOpt("bitmapOriginal", HMSMLUtils.bitmapToBase64(bitmapOriginal)); + return jsonObject; + } + + + public static JSONObject mlFacetoJSON(final MLFace mlFace) throws JSONException { + JSONObject facesObject = new JSONObject(); + facesObject.putOpt("opennessOfLeftEye", mlFace.opennessOfLeftEye()); + facesObject.putOpt("tracingIdentity", mlFace.getTracingIdentity()); + facesObject.putOpt("possibilityOfSmiling", mlFace.possibilityOfSmiling()); + facesObject.putOpt("opennessOfRightEye", mlFace.opennessOfRightEye()); + facesObject.putOpt("rotationAngleX", mlFace.getRotationAngleX()); + facesObject.putOpt("rotationAngleY", mlFace.getRotationAngleY()); + facesObject.putOpt("rotationAngleZ", mlFace.getRotationAngleZ()); + facesObject.putOpt("height", mlFace.getHeight()); + facesObject.putOpt("width", mlFace.getWidth()); + facesObject.putOpt("border", TextUtils.borderToJSON(mlFace.getBorder())); + JSONObject featuresFace = new JSONObject(); + featuresFace.putOpt("sunGlassProbability", mlFace.getFeatures().getSunGlassProbability()); + featuresFace.putOpt("sexProbability", mlFace.getFeatures().getSexProbability()); + featuresFace.putOpt("rightEyeOpenProbability", mlFace.getFeatures().getRightEyeOpenProbability()); + featuresFace.putOpt("moustacheProbability", mlFace.getFeatures().getMoustacheProbability()); + featuresFace.putOpt("leftEyeOpenProbability", mlFace.getFeatures().getLeftEyeOpenProbability()); + featuresFace.putOpt("age", mlFace.getFeatures().getAge()); + featuresFace.putOpt("hatProbability", mlFace.getFeatures().getHatProbability()); + facesObject.putOpt("features", featuresFace); + JSONObject emotions = new JSONObject(); + emotions.putOpt("surpriseProbability", mlFace.getEmotions().getSurpriseProbability()); + emotions.putOpt("smilingProbability", mlFace.getEmotions().getSmilingProbability()); + emotions.putOpt("sadProbability", mlFace.getEmotions().getSadProbability()); + emotions.putOpt("neutralProbability", mlFace.getEmotions().getNeutralProbability()); + emotions.putOpt("fearProbability", mlFace.getEmotions().getFearProbability()); + emotions.putOpt("disgustProbability", mlFace.getEmotions().getDisgustProbability()); + emotions.putOpt("angryProbability", mlFace.getEmotions().getAngryProbability()); + facesObject.putOpt("emotions", emotions); + + facesObject.putOpt("allPoints", + HMSMLUtils.listToJSONArray(mlFace.getAllPoints(), TextUtils::faceAllPointToJSON)); + facesObject.putOpt("keyPoints", + HMSMLUtils.listToJSONArray(mlFace.getFaceKeyPoints(), TextUtils::faceKeyPointsToJSON)); + facesObject.putOpt("faceShapeList", + HMSMLUtils.listToJSONArray(mlFace.getFaceShapeList(), TextUtils::faceShapeListToJSON)); + return facesObject; + } + + public static JSONObject ml3DFacetoJSON(final ML3DFace mlFace) throws JSONException { + JSONObject facesObject = new JSONObject(); + facesObject.putOpt("3DfaceEulerX", mlFace.get3DFaceEulerX()); + facesObject.putOpt("3DfaceEulerY", mlFace.get3DFaceEulerY()); + facesObject.putOpt("3DfaceEulerZ", mlFace.get3DFaceEulerZ()); + facesObject.putOpt("3DAllVertexs", + HMSMLUtils.listToJSONArray(mlFace.get3DAllVertexs(), TextUtils::faceAllPointToJSON)); + + return facesObject; + } + + public static JSONObject fromImageClassificationToJSON(final MLImageClassification classification) { + JSONObject result = new JSONObject(); + try { + result.putOpt("classificationIdentity", classification.getClassificationIdentity()); + result.putOpt("possibility", classification.getPossibility()); + result.putOpt("name", classification.getName()); + + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return result; + } + + public static JSONObject borderToJSON(final Rect rect) { + JSONObject border = new JSONObject(); + try { + border.putOpt("bottom", rect.bottom); + border.putOpt("top", rect.top); + border.putOpt("left", rect.left); + border.putOpt("right", rect.right); + border.putOpt("exactCenterX", rect.exactCenterX()); + border.putOpt("centerY", rect.centerY()); + border.putOpt("centerX", rect.centerX()); + border.putOpt("describeContents", rect.describeContents()); + border.putOpt("height", rect.height()); + border.putOpt("width", rect.width()); + } catch (JSONException e) { + Log.e(TAG, "error:" + e.getMessage()); + } + return border; + } + + public static JSONObject faceAllPointToJSON(final MLPosition mlPosition) throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("X", mlPosition.getX()); + jsonObject.putOpt("Y", mlPosition.getY()); + jsonObject.putOpt("Z", mlPosition.getZ()); + return jsonObject; + } + + public static JSONObject faceKeyPointsToJSON(final MLFaceKeyPoint mlFaceKeyPoint) throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("type", mlFaceKeyPoint.getType()); + JSONObject points = new JSONObject(); + points.putOpt("X", mlFaceKeyPoint.getPoint().getX()); + points.putOpt("Y", mlFaceKeyPoint.getPoint().getY()); + points.putOpt("Z", mlFaceKeyPoint.getPoint().getZ()); + jsonObject.putOpt("point", points); + JSONObject coordinatePoint = new JSONObject(); + coordinatePoint.putOpt("x", mlFaceKeyPoint.getCoordinatePoint().x); + coordinatePoint.putOpt("y", mlFaceKeyPoint.getCoordinatePoint().y); + coordinatePoint.putOpt("describeContents", mlFaceKeyPoint.getCoordinatePoint().describeContents()); + points.putOpt("coordinatePoint", coordinatePoint); + return jsonObject; + } + + public static JSONObject faceShapeListToJSON(final MLFaceShape faceShape) throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("points", HMSMLUtils.listToJSONArray(faceShape.getPoints(), TextUtils::faceAllPointToJSON)); + jsonObject.putOpt("faceShapeType", faceShape.getFaceShapeType()); + return jsonObject; + } + + public static JSONObject classificationResultToJSON(final MLImageClassification mlImageClassification) + throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("identity", mlImageClassification.getClassificationIdentity()); + jsonObject.putOpt("name", mlImageClassification.getName()); + jsonObject.putOpt("possibility", mlImageClassification.getPossibility()); + jsonObject.putOpt("hashCode", mlImageClassification.hashCode()); + return jsonObject; + } + + public static JSONObject landmarkResultToJSON(final MLRemoteLandmark landmark) throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("landmark", landmark.getLandmark()); + jsonObject.putOpt("landmarkIdentity", landmark.getLandmarkIdentity()); + jsonObject.putOpt("possibility", landmark.getPossibility()); + jsonObject.putOpt("border", borderToJSON(landmark.getBorder())); + jsonObject.putOpt("positionInfo", + HMSMLUtils.listToJSONArray(landmark.getPositionInfos(), TextUtils::positionInfoToJSON)); + return jsonObject; + } + + public static JSONObject positionInfoToJSON(final MLCoordinate coordinate) throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("lng", coordinate.getLng()); + jsonObject.putOpt("lat", coordinate.getLat()); + return jsonObject; + } + + + public static JSONObject mlObjectsListTOJSON(final MLObject mlObject) throws JSONException { + JSONObject mlObjectsListJSON = new JSONObject(); + mlObjectsListJSON.putOpt("border", TextUtils.borderToJSON(mlObject.getBorder())); + mlObjectsListJSON.putOpt("tracingIdentity", mlObject.getTracingIdentity()); + mlObjectsListJSON.putOpt("typeIdentity", mlObject.getTypeIdentity()); + mlObjectsListJSON.putOpt("typePossibility", mlObject.getTypePossibility()); + return mlObjectsListJSON; + } + + + public static JSONArray mlProductListTOJSON(final List mlProductVisionSearch) + throws JSONException { + ArrayList> prdList = new ArrayList<>(); + for (int i = 0; i < mlProductVisionSearch.size(); i++) { + Map map = new HashMap<>(); + MLProductVisionSearch search = mlProductVisionSearch.get(i); + map.put("border", borderToJSON(search.getBorder())); + map.put("type", search.getType()); + map.put("productList", TextUtils.mlProductTOJSON(search.getProductList())); + prdList.add(map); + } + return new JSONArray(prdList); + } + + public static JSONArray mlProductTOJSON(final List mlVisionSearchProduct) + throws JSONException { + ArrayList> productList = new ArrayList<>(); + for (int i = 0; i < mlVisionSearchProduct.size(); i++) { + Map map = new HashMap<>(); + MLVisionSearchProduct product = mlVisionSearchProduct.get(i); + map.put("customContent", product.getCustomContent()); + map.put("imageList", TextUtils.mlProductImageTOJSON(product.getImageList())); + map.put("possibility", product.getPossibility()); + map.put("productId", product.getProductId()); + map.put("productUrl", product.getProductUrl()); + productList.add(map); + } + + return new JSONArray(productList); + } + + public static JSONArray mlProductImageTOJSON(final List mlVisionSearchProductImage) + throws JSONException { + ArrayList> imageList = new ArrayList<>(); + for (int i = 0; i < mlVisionSearchProductImage.size(); i++) { + Map map = new HashMap<>(); + MLVisionSearchProductImage image = mlVisionSearchProductImage.get(i); + map.put("possibility", image.getPossibility()); + map.put("imageId", image.getImageId()); + map.put("productId", image.getProductId()); + imageList.add(map); + } + return new JSONArray(imageList); + } + + public static boolean isNullOrEmpty(final String item) { + return null == item || item.isEmpty(); + } + + public static String toJSON(T obj) { + return gson.toJson(obj); + } + + public static T toObject(final JSONObject jsonObject, final Class clazz) { + if (jsonObject != null) { + return gson.fromJson(jsonObject.toString(), clazz); + } else { + return null; + } + + } + + + public static JSONObject propertyFunc(final Property property) throws JSONException { + JSONObject propertyJSON = new JSONObject(); + propertyJSON.putOpt("formatType", property.getFormatType()); + propertyJSON.putOpt("height", property.getHeight()); + propertyJSON.putOpt("itemIdentity", property.getItemIdentity()); + propertyJSON.putOpt("quadrant", property.getQuadrant()); + propertyJSON.putOpt("timestamp", property.getTimestamp()); + propertyJSON.putOpt("width", property.getWidth()); + return propertyJSON; + } + + + public static JSONObject fromSparseArrayCompositeToJSON(final SparseArray array) throws JSONException { + JSONObject json = new JSONObject(); + List list = new ArrayList<>(array.size()); + try { + for (int i = 0; i < array.size(); i++) { + list.add(array.get(i)); + } + json.putOpt("result", gson.toJson(list)); + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + + return json; + } + + public static JSONObject fromSparseArrayDocSkewToJSON(final SparseArray array) { + JSONObject json = new JSONObject(); + try { + for (int i = 0; i < array.size(); i++) { + int key = array.keyAt(i); + MLDocumentSkewCorrectionResult mlDocumentSkewCorrectionAnalyzer = array.get(key); + json.putOpt(String.valueOf(key), getDocSkewResult(mlDocumentSkewCorrectionAnalyzer)); + } + } catch (JSONException e) { + Log.e(TAG, "error: " + e.getMessage()); + } + return json; + } + + public static JSONObject mlSize(final Size size) throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("height", size.getHeight()); + jsonObject.putOpt("width", size.getWidth()); + return jsonObject; + } + + public static JSONObject getApplicationSetting(final MLApplicationSetting mlApplicationSetting) + throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("apiKey", mlApplicationSetting.getApiKey()); + jsonObject.putOpt("certFingerprint", mlApplicationSetting.getCertFingerprint()); + jsonObject.putOpt("appID", mlApplicationSetting.getAppId()); + jsonObject.putOpt("acceptHa", mlApplicationSetting.getAcceptHa()); + jsonObject.putOpt("sdkVersion", mlApplicationSetting.getMLSdkVersion()); + jsonObject.putOpt("packageName", mlApplicationSetting.getPackageName()); + jsonObject.putOpt("region", mlApplicationSetting.getRegion()); + jsonObject.putOpt("extProperties", mlApplicationSetting.getExtProperties()); + jsonObject.putOpt("serviceUrl", mlApplicationSetting.getMLServiceUrls()); + return jsonObject; + } + + public static JSONObject getDocSkewResult(final MLDocumentSkewCorrectionResult mlDocumentSkewCorrectionResult) + throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.putOpt("bitmap", HMSMLUtils.bitmapToBase64(mlDocumentSkewCorrectionResult.getCorrected())); + jsonObject.putOpt("resultCode", mlDocumentSkewCorrectionResult.getResultCode()); + + return jsonObject; + } + + + public static int resId(final CordovaInterface cordova, final String type, final String name) { + if (isNullOrEmpty(type) || isNullOrEmpty(name)) { + return -1; + } + return cordova.getContext().getResources().getIdentifier(name, type, cordova.getContext().getPackageName()); + } + + public static int rid(final CordovaInterface cordova, final String name) { + return resId(cordova, "id", name); + } + + public static int rlayout(final CordovaInterface cordova, final String name) { + return resId(cordova, "layout", name); + } + + public static int rdraw(final CordovaInterface cordova, final String name) { + return resId(cordova, "drawable", name); + } +} diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/back_img.png b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/back_img.png new file mode 100644 index 00000000..12d1637a Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/back_img.png differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/close.png b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/close.png new file mode 100644 index 00000000..14e565f5 Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/close.png differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/flash_light_off.png b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/flash_light_off.png new file mode 100644 index 00000000..78b68b10 Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/flash_light_off.png differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/flash_light_on.png b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/flash_light_on.png new file mode 100644 index 00000000..f58eee7a Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/flash_light_on.png differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/front_back_switch.png b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/front_back_switch.png new file mode 100644 index 00000000..d81b7ef0 Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/front_back_switch.png differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/hand.jpg b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/hand.jpg new file mode 100644 index 00000000..e3f25ef2 Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/hand.jpg differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/rn_eid_ic_hivision_light.png b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/rn_eid_ic_hivision_light.png new file mode 100644 index 00000000..0d2d7747 Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/rn_eid_ic_hivision_light.png differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/rn_eid_ic_hivision_light_act.png b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/rn_eid_ic_hivision_light_act.png new file mode 100644 index 00000000..eed396de Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/rn_eid_ic_hivision_light_act.png differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/screen.png b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/screen.png new file mode 100644 index 00000000..f7ad3cfa Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/screen.png differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/skeleton_image.JPG b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/skeleton_image.JPG new file mode 100644 index 00000000..ddfd80eb Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/skeleton_image.JPG differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/skeleton_template.jpg b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/skeleton_template.jpg new file mode 100644 index 00000000..ad77555b Binary files /dev/null and b/cordova-plugin-hms-mltext/src/android/src/main/res/drawable/skeleton_template.jpg differ diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/layout/activity_custom.xml b/cordova-plugin-hms-mltext/src/android/src/main/res/layout/activity_custom.xml new file mode 100644 index 00000000..56fcea66 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/res/layout/activity_custom.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + diff --git a/cordova-plugin-hms-mltext/src/android/src/main/res/values/multiimagechooser_strings_en.xml b/cordova-plugin-hms-mltext/src/android/src/main/res/values/multiimagechooser_strings_en.xml new file mode 100644 index 00000000..e3addba9 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/android/src/main/res/values/multiimagechooser_strings_en.xml @@ -0,0 +1,13 @@ + + + MultiImageChooser + Free version - Images left: %d + There was an error opening the images database. Please report the problem. + Requesting thumbnails, please be patient + Processing Images + This may take a few moments + Limit reached + You can only select %d photos at once. + Cancel + OK + diff --git a/cordova-plugin-hms-mltext/src/www/HMSMLText.ts b/cordova-plugin-hms-mltext/src/www/HMSMLText.ts new file mode 100644 index 00000000..e7f66c1d --- /dev/null +++ b/cordova-plugin-hms-mltext/src/www/HMSMLText.ts @@ -0,0 +1,252 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { asyncExec } from "./util"; +import * as MLKit from "./interfaces"; +export { + MLProductConfig, + MLFormRecogitionConfig, + ImgSuperResolutionConfig, + MLBcrResultConfig, + MLGcrCaptureUIConfig, + MLBcrCaptureConfig, + MLTextConfig, + MLRemoteTextSetting, + MLLocalTextSetting, + MLText, + MLDocument, + MLBankCard, + MLGcrCaptureResult, + MLFormRecogitionResult, + MLVnIcrCaptureResult, + MLCnIcrCaptureResult, + MLIcrCaptureResult, + MLBcrCaptureResult, + CordovaErrors, + MLBcrCaptureErrorCode, + Colors, + RecMode +} from "./interfaces"; + +//Text Provider + +export async function imageTextAnalyser( + ImageTextReq: MLKit.localImageTextReq | MLKit.remoteImageTextReq +): Promise { + return asyncExec("HMSMLText", "ACTION_IMAGE_TEXT_ANALYSER", [ + ImageTextReq, + ]); +} +export async function stopTextAnalyser(): Promise { + return asyncExec("HMSMLText", "ACTION_STOP_TEXT_ANALYSER", []); +} +export async function getTextAnalyserInfo(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_GET_IMAGE_TEXT_INFO", + [] + ); +} +export async function documentImageAnalyser( + documentImageReq: MLKit.documentImageAnalyserReq +): Promise { + return asyncExec( + "HMSMLText", + "ACTION_DOCUMENT_IMAGE_ANALYSER", + [documentImageReq] + ); +} +export async function closeDocumentImageAnalyser(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_CLOSE_DOCUMENT_IMAGE_ANALYSER", + [] + ); +} +export async function stopDocumentImageAnalyser(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_STOP_DOCUMENT_IMAGE_ANALYSER", + [] + ); +} +export async function getDocumentImageAnalyserSetting(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_GET_DOCUMENT_IMAGE_ANALYSER_SETTING", + [] + ); +} +export async function getTextAnalyserSetting(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_GET_IMAGE_TEXT_SETTING", + [] + ); +} +export async function getGCRSetting(): Promise { + return asyncExec("HMSMLText", "ACTION_GET_GCR_SETTING", []); +} +export async function stopFormRecognitionAnalyser(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_FORM_RECOGNITION_STOP", + [] + ); +} +export async function bankCardDetector( + bankCardDetecterReq: + | MLKit.bankCardSDKDetectorReq + | MLKit.bankCardPluginDetectorReq +): Promise { + return asyncExec("HMSMLText", "ACTION_BANK_CARD_DETECTOR", [ + bankCardDetecterReq, + ]); +} +export async function stopBankCardDetector(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_STOP_BANK_CARD_DETECTOR", + [] + ); +} + +export async function setResultCallbackBcr(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_BANK_CARD_SET_RESULT_CALLBACK", + [] + ); +} +export async function setResultTypeBcr( + mLBcrCaptureConfig: MLKit.mLBcrCaptureConfig +): Promise { + return asyncExec( + "HMSMLText", + "ACTION_BANK_CARD_SET_RESULT_TYPE", + [] + ); +} +export async function setRecModeBcr( + mLBcrCaptureConfig: MLKit.mLBcrCaptureConfig +): Promise { + return asyncExec( + "HMSMLText", + "ACTION_BANK_CARD_SET_RECMODE", + [] + ); +} + +export async function getBankCardDetectorSetting(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_GET_BANK_CARD_SETTING", + [] + ); +} + +export async function generalCardDetector( + generalCardDetectorReq: MLKit.generalCardDetectorReq +): Promise { + return asyncExec( + "HMSMLText", + "ACTION_GENERALCARD_PLUGIN_DETECTOR", + [generalCardDetectorReq] + ); +} + +export async function formRecognitionAnalyser( + formRecognizerAnalyserReq: MLKit.formRecognizerAnalyserReq +): Promise { + return asyncExec("HMSMLText", "ACTION_FORM_RECOGNITION", [ + formRecognizerAnalyserReq, + ]); +} + +export async function icrVnCardDetector( + icrVnDetectorReq: MLKit.icrVnDetectorReq +): Promise { + return asyncExec("HMSMLText", "ACTION_ICRVN_PLUGIN_DETECTOR", [ + icrVnDetectorReq, + ]); +} + +export async function icrVnCardCreate(): Promise { + return asyncExec("HMSMLText", "ACTION_ICRVN_CREATE", []); +} + +export async function getIcrVnCapture(): Promise { + return asyncExec("HMSMLText", "ACTION_ICRVN_CAPTURE", []); +} + +export async function geticrVnCardInstance(): Promise { + return asyncExec("HMSMLText", "ACTION_ICRVN_GET_INSTANCE", []); +} + +export async function icrCnCardCreate(): Promise { + return asyncExec("HMSMLText", "ACTION_ICRCN_CREATE", []); +} + +export async function geticrCnCardInstance(): Promise { + return asyncExec("HMSMLText", "ACTION_ICRCN_GET_INSTANCE", []); +} + +export async function getIcrCnCapture(): Promise { + return asyncExec("HMSMLText", "ACTION_ICRCN_CAPTURE", []); +} + +export async function icrCnCardDetector( + icrCnDetectorReq: MLKit.icrCnDetectorReq +): Promise { + return asyncExec("HMSMLText", "ACTION_ICRCN_PLUGIN_DETECTOR", [ + icrCnDetectorReq, + ]); +} + +export async function icrLocalAnalyser( + localAnalyserReq: MLKit.localAnalyserReq +): Promise { + return asyncExec("HMSMLText", "ACTION_LOCAL_ANALYSER", [ + localAnalyserReq, + ]); +} + +export async function icrLocalAnalyserCreateIdCard( + createIdCardReq: MLKit.createIdCardReq +): Promise { + return asyncExec("HMSMLText", "ACTION_LOCAL_ANALYSER_CREATE", [ + createIdCardReq, + ]); +} + +export async function icrLocalAnalyserStop(): Promise { + return asyncExec( + "HMSMLText", + "ACTION_LOCAL_ANALYSER_STOP", + [] + ); +} + +export async function startCustomizedView(userProps: MLKit.CustomViewModeRequest): Promise { + return asyncExec('HMSMLText', 'startCustomizedView', [userProps]); +}; + +export async function switchLight(): Promise { + return asyncExec('HMSMLText', 'switchLight', []); +}; + +export async function getLightStatus(): Promise { + return asyncExec('HMSMLText', 'getLightStatus', []); +}; diff --git a/cordova-plugin-hms-mltext/src/www/HMSMLTextPlugin.ts b/cordova-plugin-hms-mltext/src/www/HMSMLTextPlugin.ts new file mode 100644 index 00000000..dedf5b1f --- /dev/null +++ b/cordova-plugin-hms-mltext/src/www/HMSMLTextPlugin.ts @@ -0,0 +1,77 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { + ImgSuperResolutionConfig, + MLBcrResultConfig, + MLGcrCaptureUIConfig, + MLBcrCaptureConfig, + MLTextConfig, + MLRemoteTextSetting, + MLLocalTextSetting, + MLBcrCaptureResult, + CordovaErrors, + MLBcrCaptureErrorCode, + Colors, + Region, +} from "./interfaces"; +import { asyncExec } from "./util"; +import * as MLKit from "./interfaces"; +export { + ImgSuperResolutionConfig, + MLBcrResultConfig, + MLGcrCaptureUIConfig, + MLBcrCaptureConfig, + MLTextConfig, + MLRemoteTextSetting, + MLLocalTextSetting, + MLBcrCaptureResult, + CordovaErrors, + MLBcrCaptureErrorCode, + Colors, +} from "./interfaces"; + + +export async function serviceInitializer( + params: MLKit.configReq +): Promise { + return asyncExec("HMSMLTextPlugin", "HMSMLKIT_INITILALIZER", [params]); +} +export async function appSetting( + appSettingReq: MLKit.appSettingReq +): Promise { + return asyncExec("HMSMLTextPlugin", "ACTION_APP_SETTING", [appSettingReq]); +} +export function enableLogger(): Promise { + return asyncExec("HMSMLTextPlugin", "enableLogger", []); +} +export function disableLogger(): Promise { + return asyncExec("HMSMLTextPlugin", "disableLogger", []); +} +/// Sets a data processing location when you choose to manually manage and specify such a location. +/// +/// REGION_DR_UNKNOWN = 1001, +/// REGION_DR_CHINA = 1002, +/// REGION_DR_RUSSIA = 1005, +/// REGION_DR_GERMAN = 1006, +/// REGION_DR_SINGAPORE = 1007 +export async function setUserRegion( + region: number +): Promise { + return asyncExec("HMSMLTextPlugin", "setUserRegion", [region]); +} +export async function getCountryCode(): Promise { + return asyncExec("HMSMLTextPlugin", "getCountryCode", []); +} diff --git a/cordova-plugin-hms-mltext/src/www/index.ts b/cordova-plugin-hms-mltext/src/www/index.ts new file mode 100644 index 00000000..8b4c75f2 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/www/index.ts @@ -0,0 +1,19 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +export * from "./HMSMLTextPlugin"; +export * from "./HMSMLText"; +export * from "./interfaces"; +export * from "./util"; diff --git a/cordova-plugin-hms-mltext/src/www/interfaces.ts b/cordova-plugin-hms-mltext/src/www/interfaces.ts new file mode 100644 index 00000000..66c91124 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/www/interfaces.ts @@ -0,0 +1,484 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +export enum Region { + REGION_DR_UNKNOWN = 1001, + REGION_DR_CHINA = 1002, + REGION_DR_RUSSIA = 1005, + REGION_DR_GERMAN = 1006, + REGION_DR_SINGAPORE = 1007 +} + +export interface CustomViewModeRequest { + isTitleAvailable: boolean; + title: string; + heightFactor: number; + widthFactor: number; + isFlashAvailable: boolean; + resultType: MLBcrResultConfig; + recMode: RecMode; + } + +// API KEY + +export interface configReq { + apiKey: string; +} + +export interface appSettingReq { + apiKey?: string | null; + applicationId?: string | null; + certFingerprint?: string | null; +} + + +// SDK BANK CARD ANALYSER + +export interface bankCardSDKDetectorReq { + filePath: any; + detectType: 0; + mLBcrAnalyzerSetting?: MLBcrAnalyzerSetting | null; +} + +export interface MLBcrAnalyzerSetting { + langType?: string | null; + resultType?: MLBcrResultConfig | null; +} + +// PLUGIN BANK CARD ANALYSER + +export interface bankCardPluginDetectorReq { + detectType: 1; + mLBcrCaptureConfig?: mLBcrCaptureConfig | null; +} + +export interface mLBcrCaptureConfig { + orientation?: MLBcrCaptureConfig | null; + resultType?: MLBcrResultConfig | null; + recMode?: RecMode | null; +} + +export enum RecMode { + WEAK_MODE = 0, + STRICT_MODE = 1, +} + +export enum MLBcrCaptureConfig { + ERROR_CODE_INIT_CAMERA_FAILED = 10101, + RESULT_NUM_ONLY = 0, + ORIENTATION_AUTO = 0, + WEAK_MODE = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2, + RESULT_ALL = 2, + RESULT_SIMPLE = 1, + STRICT_MODE = 1, +} +export enum MLBcrResultConfig { + RESULT_NUM_ONLY = 0, + RESULT_SIMPLE = 1, + RESULT_ALL = 2, +} + +export interface MLBcrCaptureResult { + errorCode?: MLBcrCaptureErrorCode | null; + expire?: String | null; + issuer?: String | null; + number?: String | null; + numberBitmap?: any; + organization?: String | null; + riginalBitmap?: any; + type?: String | null; +} + +export enum MLBcrCaptureErrorCode { + ERROR_CODE_INIT_CAMERA_FAILED = 10101, +} + + +//Document Analyser + +export interface documentImageAnalyserReq { + documentSetting?: DocumentSetting | null; + filePath: any; +} +export interface DocumentSetting { + borderType?: MLRemoteTextSetting | null; + languageList?: Array | null; + enableFingerprintVerification: boolean | null; +} + +export enum MLRemoteTextSetting { + OCR_LOOSE_SCENE = 1, + OCR_COMPACT_SCENE = 2, + NGON = "NGON", + ARC = "ARC", + OTHER = 5, + NEW_LINE_CHARACTER = 8, + SPACE = 6, +} + + +//Form Recognizer Analyser + +export interface formRecognizerAnalyserReq { + filePath: any; + syncType: MLFormRecogitionConfig; +} +export enum MLFormRecogitionConfig { + SYNC_TYPE = 1, + ASYNC_TYPE = 0, +} + +// GENERAL CARD ANALYSER + +export interface generalCardDetectorReq { + gcrCaptureConfig?: gcrCaptureConfig; + gcrCaptureUIConfig?: gcrCaptureUIConfig; + captureType?: gcrCaptureType | null; +} + +export interface gcrCaptureConfig { + language: string; +} +export enum gcrCaptureType { + CAPTURE_ACTIVITY = 0, + CAPTURE_PHOTO = 1, + CAPTURE_IMAGE = 2, +} +export interface gcrCaptureUIConfig { + orientation?: MLGcrCaptureUIConfig | null; + tipText?: string | null; + tipTextColor?: number | null; + photoButtonResId?: number | null; + scanBoxCornerColor?: number | null; + backButtonRedId?: number | null; + torchRedId?: number | null; +} +export interface gcrSettingResults { + gcrConfigLanguage: String; + torchOnResId: number; + tipTextColor: number; + tipText: String; + backButtonResId: number; + orientation: number; + photoButtonResId: number; + scanBoxScreenRatio: number; + scanBoxCornerColor: number; + scanBoxAspectRatio: number; +} + +export enum MLGcrCaptureUIConfig { + ORIENTATION_AUTO = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2, +} + +// ID CARD ANALYSER + +export interface icrVnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; +} + +export interface icrCnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; + isFront?: boolean | null; +} + +export enum icrCaptureType { + CAPTURE_CAMERA = 0, + CAPTURE_IMAGE = 1, +} + +export interface createIdCardReq { + mlIcrAnalyzerSetting?: MLIcrAnalyzerSetting | null; +} + +export interface localAnalyserReq { + settings: MLIcrAnalyzerSetting; + filePath?: any | null; +} +export interface MLIcrAnalyzerSetting { + countryCode: string; + hashCode?: number | null; + sideType?: MLIcrSideType | null; +} + +export enum MLIcrSideType { + FRONT = "FRONT", + BACK = "BACK", +} + + +//Image Super Resolution + +export interface imageSuperResolutionReq { + filePath: any; + imgSuperResolutionSetting?: ImgSuperResolutionSetting | null; + syncType?: MLFormRecogitionConfig | null; +} +export interface ImgSuperResolutionSetting { + scaleType?: ImgSuperResolutionConfig; +} +export enum ImgSuperResolutionConfig { + ISR_SCALE_1X = 1.0, + ISR_SCALE_3X = 3.0, +} + +//Product Vision Analyser + +export interface productReq { + filePath?: any | null; + detectType?: number; + mlProductSetting?: mlProductSetting | null; +} +export interface mlProductSetting { + largestNumOfReturns?: number | null; + productSetId?: string | null; + region?: MLProductConfig | null; +} +export enum MLProductConfig { + REGION_DR_CHINA = 1002, + REGION_DR_AFILA = 1003, + REGION_DR_EUROPE = 1004, + REGION_DR_RUSSIA = 1005, + REGION_DR_GERMAN = 1006, + REGION_DR_SIANGAPORE = 1007, +} + + +//Text Analyser + +export interface localImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + localTextSetting?: localTextSetting | null; + filePath: any; +} + +export interface localTextSetting { + ocrMode?: MLLocalTextSetting; + language?: string; +} + +export enum MLLocalTextSetting { + OCR_DETECT_MODE = 1, + OCR_TRACKING_MODE = 2, +} +export enum MLTextConfig { + OCR_LOCAL_TYPE = 0, + OCR_REMOTE_TYPE = 1, +} +export interface remoteImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + remoteTextSetting?: remoteTextSetting; + filePath: any; +} +export interface remoteTextSetting { + textDensityScene?: MLRemoteTextSetting; + languageList?: Array; + borderType?: MLRemoteTextSetting; +} + +/* +----------------- return +*/ + +export interface MLBankCard { + number: string; + expire: string; + issuer: string; + type: string; + organization: string; + originalBitmap: any; + numberBitmap: any; +} + +export interface Border { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} + +export interface MLDocument { + stringValue: string; + blocks?: Blocks[]; +} +export interface LanguageList { + language: string; +} + +export interface MLVnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; +} + +export interface MLCnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + authority: string; + validDate: string; +} + +export interface MLIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + validDate: string; +} + +export interface MLGcrCaptureResult { + text: string; + cardBitmap: Bitmap; +} + + +export interface Rect { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} + +export interface MLText { + stringValue: string; + blocks?: Blocks[]; +} +export interface Blocks { + contents?: Contents[]; +} +export interface Contents { + stringValue: string; + border: Border; + language: string; + languageList?: LanguageList[]; + vertexes?: Vertexes[]; +} +export interface LanguageList { + language: string; +} +export interface Vertexes { + x: number; + y: number; + describeContents: number; +} + +export interface MLFormRecogitionResult { + retCode: number; + tableContent: TableContent; +} + +export interface TableContent { + tableCount: number; + tables?: TablesEntity[] | null; +} +export interface TablesEntity { + tableID: number; + headerInfo: string; + footerInfo: string; + tableBody?: TableBodyEntity[] | null; +} +export interface TableBodyEntity { + startRow: number; + endRow: number; + startCol: number; + endCol: number; + cellCoordinate: CellCoordinate; + textInfo: string; +} +export interface CellCoordinate { + topLeft_x: number; + topLeft_y: number; + topRight_x: number; + topRight_y: number; + bottomLeft_x: number; + bottomLeft_y: number; + bottomRight_x: number; + bottomRight_y: number; +} +export interface Bitmap { + mGalleryCached: boolean; + mHeight: number; + mNativePtr: number; + mWidth: number; +} +export enum Colors { + RED = -65536, + DKGRAY = -12303292, + GRAY = -7829368, + WHITE = -1, + BLUE = -16776961, + BLACK = -16777216, + LTGRAY = -3355444, + MAGENTA = -65281, + YELLOW = -256, + CYAN = -16711681, + GREEN = -16711936, + TRANSPARENT = 0, +} +export enum CordovaErrors { + UNKNOWN = -1, + SUCCESS = 0, + DISCARDED = 1, + INNER = 2, + INACTIVE = 3, + NOT_SUPPORTED = 4, + ILLEGAL_PARAMETER = 5, + OVERDUE = 6, + NO_FOUND = 7, + DUPLICATE_FOUND = 8, + NO_PERMISSION = 9, + INSUFFICIENT_RESOURCE = 10, + ANALYSIS_FAILURE = 11, + INTERRUPTED = 12, + EXCEED_RANGE = 13, + DATA_MISSING = 14, + AUTHENTICATION_REQUIRED = 15, + TFLITE_NOT_COMPATIBLE = 16, + INSUFFICIENT_SPACE = 17, + HASH_MISS = 18, + TOKEN_INVALID = 19, + SERVICE_FAILURE = 20, + ANALYSIS_NULL = 21, +} + diff --git a/cordova-plugin-hms-mltext/src/www/util.ts b/cordova-plugin-hms-mltext/src/www/util.ts new file mode 100644 index 00000000..34130130 --- /dev/null +++ b/cordova-plugin-hms-mltext/src/www/util.ts @@ -0,0 +1,54 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { exec } from "cordova"; + +export function asyncExec( + clazz: string, + func: string, + args: any[] = [] +): Promise { + return new Promise((resolve, reject) => { + exec(resolve, reject, clazz, func, args); + }); +} + +declare global { + interface Window { + hmsEvents: { + [key: string]: (data: any) => void; + }; + runHMSEvent: (eventName: string, data: any) => void; + subscribeHMSEvent: ( + eventName: string, + callback: (data: any) => void + ) => void; + [key: string]: any; + } +} + +function initEventHandler() { + if (window.hmsEvents != null) return; + window.hmsEvents = {}; + window.runHMSEvent = (eventName, data) => { + if (window.hmsEvents.hasOwnProperty(eventName)) + window.hmsEvents[eventName](data); + }; + window.subscribeHMSEvent = (eventName, handler) => { + window.hmsEvents[eventName] = handler; + }; +} + +initEventHandler(); diff --git a/cordova-plugin-hms-mltext/types/HMSMLText.d.ts b/cordova-plugin-hms-mltext/types/HMSMLText.d.ts new file mode 100644 index 00000000..00c3e22e --- /dev/null +++ b/cordova-plugin-hms-mltext/types/HMSMLText.d.ts @@ -0,0 +1,49 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import * as MLKit from "./interfaces"; +export { MLProductConfig, MLFormRecogitionConfig, ImgSuperResolutionConfig, MLBcrResultConfig, MLGcrCaptureUIConfig, MLBcrCaptureConfig, MLTextConfig, MLRemoteTextSetting, MLLocalTextSetting, MLText, MLDocument, MLBankCard, MLGcrCaptureResult, MLFormRecogitionResult, MLVnIcrCaptureResult, MLCnIcrCaptureResult, MLIcrCaptureResult, MLBcrCaptureResult, CordovaErrors, MLBcrCaptureErrorCode, Colors, RecMode } from "./interfaces"; +export declare function imageTextAnalyser(ImageTextReq: MLKit.localImageTextReq | MLKit.remoteImageTextReq): Promise; +export declare function stopTextAnalyser(): Promise; +export declare function getTextAnalyserInfo(): Promise; +export declare function documentImageAnalyser(documentImageReq: MLKit.documentImageAnalyserReq): Promise; +export declare function closeDocumentImageAnalyser(): Promise; +export declare function stopDocumentImageAnalyser(): Promise; +export declare function getDocumentImageAnalyserSetting(): Promise; +export declare function getTextAnalyserSetting(): Promise; +export declare function getGCRSetting(): Promise; +export declare function stopFormRecognitionAnalyser(): Promise; +export declare function bankCardDetector(bankCardDetecterReq: MLKit.bankCardSDKDetectorReq | MLKit.bankCardPluginDetectorReq): Promise; +export declare function stopBankCardDetector(): Promise; +export declare function setResultCallbackBcr(): Promise; +export declare function setResultTypeBcr(mLBcrCaptureConfig: MLKit.mLBcrCaptureConfig): Promise; +export declare function setRecModeBcr(mLBcrCaptureConfig: MLKit.mLBcrCaptureConfig): Promise; +export declare function getBankCardDetectorSetting(): Promise; +export declare function generalCardDetector(generalCardDetectorReq: MLKit.generalCardDetectorReq): Promise; +export declare function formRecognitionAnalyser(formRecognizerAnalyserReq: MLKit.formRecognizerAnalyserReq): Promise; +export declare function icrVnCardDetector(icrVnDetectorReq: MLKit.icrVnDetectorReq): Promise; +export declare function icrVnCardCreate(): Promise; +export declare function getIcrVnCapture(): Promise; +export declare function geticrVnCardInstance(): Promise; +export declare function icrCnCardCreate(): Promise; +export declare function geticrCnCardInstance(): Promise; +export declare function getIcrCnCapture(): Promise; +export declare function icrCnCardDetector(icrCnDetectorReq: MLKit.icrCnDetectorReq): Promise; +export declare function icrLocalAnalyser(localAnalyserReq: MLKit.localAnalyserReq): Promise; +export declare function icrLocalAnalyserCreateIdCard(createIdCardReq: MLKit.createIdCardReq): Promise; +export declare function icrLocalAnalyserStop(): Promise; +export declare function startCustomizedView(userProps: MLKit.CustomViewModeRequest): Promise; +export declare function switchLight(): Promise; +export declare function getLightStatus(): Promise; diff --git a/cordova-plugin-hms-mltext/types/HMSMLTextPlugin.d.ts b/cordova-plugin-hms-mltext/types/HMSMLTextPlugin.d.ts new file mode 100644 index 00000000..9988fed0 --- /dev/null +++ b/cordova-plugin-hms-mltext/types/HMSMLTextPlugin.d.ts @@ -0,0 +1,23 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import * as MLKit from "./interfaces"; +export { ImgSuperResolutionConfig, MLBcrResultConfig, MLGcrCaptureUIConfig, MLBcrCaptureConfig, MLTextConfig, MLRemoteTextSetting, MLLocalTextSetting, MLBcrCaptureResult, CordovaErrors, MLBcrCaptureErrorCode, Colors, } from "./interfaces"; +export declare function serviceInitializer(params: MLKit.configReq): Promise; +export declare function appSetting(appSettingReq: MLKit.appSettingReq): Promise; +export declare function enableLogger(): Promise; +export declare function disableLogger(): Promise; +export declare function setUserRegion(region: number): Promise; +export declare function getCountryCode(): Promise; diff --git a/cordova-plugin-hms-mltext/types/index.d.ts b/cordova-plugin-hms-mltext/types/index.d.ts new file mode 100644 index 00000000..8b4c75f2 --- /dev/null +++ b/cordova-plugin-hms-mltext/types/index.d.ts @@ -0,0 +1,19 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +export * from "./HMSMLTextPlugin"; +export * from "./HMSMLText"; +export * from "./interfaces"; +export * from "./util"; diff --git a/cordova-plugin-hms-mltext/types/interfaces.d.ts b/cordova-plugin-hms-mltext/types/interfaces.d.ts new file mode 100644 index 00000000..45eff6f2 --- /dev/null +++ b/cordova-plugin-hms-mltext/types/interfaces.d.ts @@ -0,0 +1,414 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +export declare enum Region { + REGION_DR_UNKNOWN = 1001, + REGION_DR_CHINA = 1002, + REGION_DR_RUSSIA = 1005, + REGION_DR_GERMAN = 1006, + REGION_DR_SINGAPORE = 1007 +} +export interface CustomViewModeRequest { + isTitleAvailable: boolean; + title: string; + heightFactor: number; + widthFactor: number; + isFlashAvailable: boolean; + resultType: MLBcrResultConfig; + recMode: RecMode; +} +export interface configReq { + apiKey: string; +} +export interface appSettingReq { + apiKey?: string | null; + applicationId?: string | null; + certFingerprint?: string | null; +} +export interface bankCardSDKDetectorReq { + filePath: any; + detectType: 0; + mLBcrAnalyzerSetting?: MLBcrAnalyzerSetting | null; +} +export interface MLBcrAnalyzerSetting { + langType?: string | null; + resultType?: MLBcrResultConfig | null; +} +export interface bankCardPluginDetectorReq { + detectType: 1; + mLBcrCaptureConfig?: mLBcrCaptureConfig | null; +} +export interface mLBcrCaptureConfig { + orientation?: MLBcrCaptureConfig | null; + resultType?: MLBcrResultConfig | null; + recMode?: RecMode | null; +} +export declare enum RecMode { + WEAK_MODE = 0, + STRICT_MODE = 1 +} +export declare enum MLBcrCaptureConfig { + ERROR_CODE_INIT_CAMERA_FAILED = 10101, + RESULT_NUM_ONLY = 0, + ORIENTATION_AUTO = 0, + WEAK_MODE = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2, + RESULT_ALL = 2, + RESULT_SIMPLE = 1, + STRICT_MODE = 1 +} +export declare enum MLBcrResultConfig { + RESULT_NUM_ONLY = 0, + RESULT_SIMPLE = 1, + RESULT_ALL = 2 +} +export interface MLBcrCaptureResult { + errorCode?: MLBcrCaptureErrorCode | null; + expire?: String | null; + issuer?: String | null; + number?: String | null; + numberBitmap?: any; + organization?: String | null; + riginalBitmap?: any; + type?: String | null; +} +export declare enum MLBcrCaptureErrorCode { + ERROR_CODE_INIT_CAMERA_FAILED = 10101 +} +export interface documentImageAnalyserReq { + documentSetting?: DocumentSetting | null; + filePath: any; +} +export interface DocumentSetting { + borderType?: MLRemoteTextSetting | null; + languageList?: Array | null; + enableFingerprintVerification: boolean | null; +} +export declare enum MLRemoteTextSetting { + OCR_LOOSE_SCENE = 1, + OCR_COMPACT_SCENE = 2, + NGON = "NGON", + ARC = "ARC", + OTHER = 5, + NEW_LINE_CHARACTER = 8, + SPACE = 6 +} +export interface formRecognizerAnalyserReq { + filePath: any; + syncType: MLFormRecogitionConfig; +} +export declare enum MLFormRecogitionConfig { + SYNC_TYPE = 1, + ASYNC_TYPE = 0 +} +export interface generalCardDetectorReq { + gcrCaptureConfig?: gcrCaptureConfig; + gcrCaptureUIConfig?: gcrCaptureUIConfig; + captureType?: gcrCaptureType | null; +} +export interface gcrCaptureConfig { + language: string; +} +export declare enum gcrCaptureType { + CAPTURE_ACTIVITY = 0, + CAPTURE_PHOTO = 1, + CAPTURE_IMAGE = 2 +} +export interface gcrCaptureUIConfig { + orientation?: MLGcrCaptureUIConfig | null; + tipText?: string | null; + tipTextColor?: number | null; + photoButtonResId?: number | null; + scanBoxCornerColor?: number | null; + backButtonRedId?: number | null; + torchRedId?: number | null; +} +export interface gcrSettingResults { + gcrConfigLanguage: String; + torchOnResId: number; + tipTextColor: number; + tipText: String; + backButtonResId: number; + orientation: number; + photoButtonResId: number; + scanBoxScreenRatio: number; + scanBoxCornerColor: number; + scanBoxAspectRatio: number; +} +export declare enum MLGcrCaptureUIConfig { + ORIENTATION_AUTO = 0, + ORIENTATION_LANDSCAPE = 1, + ORIENTATION_PORTRAIT = 2 +} +export interface icrVnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; +} +export interface icrCnDetectorReq { + captureType: icrCaptureType; + filePath?: any | null; + isFront?: boolean | null; +} +export declare enum icrCaptureType { + CAPTURE_CAMERA = 0, + CAPTURE_IMAGE = 1 +} +export interface createIdCardReq { + mlIcrAnalyzerSetting?: MLIcrAnalyzerSetting | null; +} +export interface localAnalyserReq { + settings: MLIcrAnalyzerSetting; + filePath?: any | null; +} +export interface MLIcrAnalyzerSetting { + countryCode: string; + hashCode?: number | null; + sideType?: MLIcrSideType | null; +} +export declare enum MLIcrSideType { + FRONT = "FRONT", + BACK = "BACK" +} +export interface imageSuperResolutionReq { + filePath: any; + imgSuperResolutionSetting?: ImgSuperResolutionSetting | null; + syncType?: MLFormRecogitionConfig | null; +} +export interface ImgSuperResolutionSetting { + scaleType?: ImgSuperResolutionConfig; +} +export declare enum ImgSuperResolutionConfig { + ISR_SCALE_1X = 1, + ISR_SCALE_3X = 3 +} +export interface productReq { + filePath?: any | null; + detectType?: number; + mlProductSetting?: mlProductSetting | null; +} +export interface mlProductSetting { + largestNumOfReturns?: number | null; + productSetId?: string | null; + region?: MLProductConfig | null; +} +export declare enum MLProductConfig { + REGION_DR_CHINA = 1002, + REGION_DR_AFILA = 1003, + REGION_DR_EUROPE = 1004, + REGION_DR_RUSSIA = 1005, + REGION_DR_GERMAN = 1006, + REGION_DR_SIANGAPORE = 1007 +} +export interface localImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + localTextSetting?: localTextSetting | null; + filePath: any; +} +export interface localTextSetting { + ocrMode?: MLLocalTextSetting; + language?: string; +} +export declare enum MLLocalTextSetting { + OCR_DETECT_MODE = 1, + OCR_TRACKING_MODE = 2 +} +export declare enum MLTextConfig { + OCR_LOCAL_TYPE = 0, + OCR_REMOTE_TYPE = 1 +} +export interface remoteImageTextReq { + ocrType: MLTextConfig; + analyseMode?: number; + remoteTextSetting?: remoteTextSetting; + filePath: any; +} +export interface remoteTextSetting { + textDensityScene?: MLRemoteTextSetting; + languageList?: Array; + borderType?: MLRemoteTextSetting; +} +export interface MLBankCard { + number: string; + expire: string; + issuer: string; + type: string; + organization: string; + originalBitmap: any; + numberBitmap: any; +} +export interface Border { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} +export interface MLDocument { + stringValue: string; + blocks?: Blocks[]; +} +export interface LanguageList { + language: string; +} +export interface MLVnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; +} +export interface MLCnIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + authority: string; + validDate: string; +} +export interface MLIcrCaptureResult { + birthday: string; + cardBitmap: Bitmap; + idNum: string; + name: string; + sex: string; + nation: string; + address: string; + validDate: string; +} +export interface MLGcrCaptureResult { + text: string; + cardBitmap: Bitmap; +} +export interface Rect { + bottom: number; + top: number; + left: number; + right: number; + exactCenterX: number; + centerY: number; + centerX: number; + describeContents: number; + height: number; + width: number; +} +export interface MLText { + stringValue: string; + blocks?: Blocks[]; +} +export interface Blocks { + contents?: Contents[]; +} +export interface Contents { + stringValue: string; + border: Border; + language: string; + languageList?: LanguageList[]; + vertexes?: Vertexes[]; +} +export interface LanguageList { + language: string; +} +export interface Vertexes { + x: number; + y: number; + describeContents: number; +} +export interface MLFormRecogitionResult { + retCode: number; + tableContent: TableContent; +} +export interface TableContent { + tableCount: number; + tables?: TablesEntity[] | null; +} +export interface TablesEntity { + tableID: number; + headerInfo: string; + footerInfo: string; + tableBody?: TableBodyEntity[] | null; +} +export interface TableBodyEntity { + startRow: number; + endRow: number; + startCol: number; + endCol: number; + cellCoordinate: CellCoordinate; + textInfo: string; +} +export interface CellCoordinate { + topLeft_x: number; + topLeft_y: number; + topRight_x: number; + topRight_y: number; + bottomLeft_x: number; + bottomLeft_y: number; + bottomRight_x: number; + bottomRight_y: number; +} +export interface Bitmap { + mGalleryCached: boolean; + mHeight: number; + mNativePtr: number; + mWidth: number; +} +export declare enum Colors { + RED = -65536, + DKGRAY = -12303292, + GRAY = -7829368, + WHITE = -1, + BLUE = -16776961, + BLACK = -16777216, + LTGRAY = -3355444, + MAGENTA = -65281, + YELLOW = -256, + CYAN = -16711681, + GREEN = -16711936, + TRANSPARENT = 0 +} +export declare enum CordovaErrors { + UNKNOWN = -1, + SUCCESS = 0, + DISCARDED = 1, + INNER = 2, + INACTIVE = 3, + NOT_SUPPORTED = 4, + ILLEGAL_PARAMETER = 5, + OVERDUE = 6, + NO_FOUND = 7, + DUPLICATE_FOUND = 8, + NO_PERMISSION = 9, + INSUFFICIENT_RESOURCE = 10, + ANALYSIS_FAILURE = 11, + INTERRUPTED = 12, + EXCEED_RANGE = 13, + DATA_MISSING = 14, + AUTHENTICATION_REQUIRED = 15, + TFLITE_NOT_COMPATIBLE = 16, + INSUFFICIENT_SPACE = 17, + HASH_MISS = 18, + TOKEN_INVALID = 19, + SERVICE_FAILURE = 20, + ANALYSIS_NULL = 21 +} diff --git a/cordova-plugin-hms-mltext/types/util.d.ts b/cordova-plugin-hms-mltext/types/util.d.ts new file mode 100644 index 00000000..c62d54af --- /dev/null +++ b/cordova-plugin-hms-mltext/types/util.d.ts @@ -0,0 +1,26 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +export declare function asyncExec(clazz: string, func: string, args?: any[]): Promise; +declare global { + interface Window { + hmsEvents: { + [key: string]: (data: any) => void; + }; + runHMSEvent: (eventName: string, data: any) => void; + subscribeHMSEvent: (eventName: string, callback: (data: any) => void) => void; + [key: string]: any; + } +} diff --git a/cordova-plugin-hms-mltext/www/HMSMLText.js b/cordova-plugin-hms-mltext/www/HMSMLText.js new file mode 100644 index 00000000..9354a80d --- /dev/null +++ b/cordova-plugin-hms-mltext/www/HMSMLText.js @@ -0,0 +1,253 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getLightStatus = exports.switchLight = exports.startCustomizedView = exports.icrLocalAnalyserStop = exports.icrLocalAnalyserCreateIdCard = exports.icrLocalAnalyser = exports.icrCnCardDetector = exports.getIcrCnCapture = exports.geticrCnCardInstance = exports.icrCnCardCreate = exports.geticrVnCardInstance = exports.getIcrVnCapture = exports.icrVnCardCreate = exports.icrVnCardDetector = exports.formRecognitionAnalyser = exports.generalCardDetector = exports.getBankCardDetectorSetting = exports.setRecModeBcr = exports.setResultTypeBcr = exports.setResultCallbackBcr = exports.stopBankCardDetector = exports.bankCardDetector = exports.stopFormRecognitionAnalyser = exports.getGCRSetting = exports.getTextAnalyserSetting = exports.getDocumentImageAnalyserSetting = exports.stopDocumentImageAnalyser = exports.closeDocumentImageAnalyser = exports.documentImageAnalyser = exports.getTextAnalyserInfo = exports.stopTextAnalyser = exports.imageTextAnalyser = exports.RecMode = exports.Colors = exports.MLBcrCaptureErrorCode = exports.CordovaErrors = exports.MLLocalTextSetting = exports.MLRemoteTextSetting = exports.MLTextConfig = exports.MLBcrCaptureConfig = exports.MLGcrCaptureUIConfig = exports.MLBcrResultConfig = exports.ImgSuperResolutionConfig = exports.MLFormRecogitionConfig = exports.MLProductConfig = void 0; +const util_1 = require("./util"); +var interfaces_1 = require("./interfaces"); +Object.defineProperty(exports, "MLProductConfig", { enumerable: true, get: function () { return interfaces_1.MLProductConfig; } }); +Object.defineProperty(exports, "MLFormRecogitionConfig", { enumerable: true, get: function () { return interfaces_1.MLFormRecogitionConfig; } }); +Object.defineProperty(exports, "ImgSuperResolutionConfig", { enumerable: true, get: function () { return interfaces_1.ImgSuperResolutionConfig; } }); +Object.defineProperty(exports, "MLBcrResultConfig", { enumerable: true, get: function () { return interfaces_1.MLBcrResultConfig; } }); +Object.defineProperty(exports, "MLGcrCaptureUIConfig", { enumerable: true, get: function () { return interfaces_1.MLGcrCaptureUIConfig; } }); +Object.defineProperty(exports, "MLBcrCaptureConfig", { enumerable: true, get: function () { return interfaces_1.MLBcrCaptureConfig; } }); +Object.defineProperty(exports, "MLTextConfig", { enumerable: true, get: function () { return interfaces_1.MLTextConfig; } }); +Object.defineProperty(exports, "MLRemoteTextSetting", { enumerable: true, get: function () { return interfaces_1.MLRemoteTextSetting; } }); +Object.defineProperty(exports, "MLLocalTextSetting", { enumerable: true, get: function () { return interfaces_1.MLLocalTextSetting; } }); +Object.defineProperty(exports, "CordovaErrors", { enumerable: true, get: function () { return interfaces_1.CordovaErrors; } }); +Object.defineProperty(exports, "MLBcrCaptureErrorCode", { enumerable: true, get: function () { return interfaces_1.MLBcrCaptureErrorCode; } }); +Object.defineProperty(exports, "Colors", { enumerable: true, get: function () { return interfaces_1.Colors; } }); +Object.defineProperty(exports, "RecMode", { enumerable: true, get: function () { return interfaces_1.RecMode; } }); +//Text Provider +function imageTextAnalyser(ImageTextReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_IMAGE_TEXT_ANALYSER", [ + ImageTextReq, + ]); + }); +} +exports.imageTextAnalyser = imageTextAnalyser; +function stopTextAnalyser() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_STOP_TEXT_ANALYSER", []); + }); +} +exports.stopTextAnalyser = stopTextAnalyser; +function getTextAnalyserInfo() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_GET_IMAGE_TEXT_INFO", []); + }); +} +exports.getTextAnalyserInfo = getTextAnalyserInfo; +function documentImageAnalyser(documentImageReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_DOCUMENT_IMAGE_ANALYSER", [documentImageReq]); + }); +} +exports.documentImageAnalyser = documentImageAnalyser; +function closeDocumentImageAnalyser() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_CLOSE_DOCUMENT_IMAGE_ANALYSER", []); + }); +} +exports.closeDocumentImageAnalyser = closeDocumentImageAnalyser; +function stopDocumentImageAnalyser() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_STOP_DOCUMENT_IMAGE_ANALYSER", []); + }); +} +exports.stopDocumentImageAnalyser = stopDocumentImageAnalyser; +function getDocumentImageAnalyserSetting() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_GET_DOCUMENT_IMAGE_ANALYSER_SETTING", []); + }); +} +exports.getDocumentImageAnalyserSetting = getDocumentImageAnalyserSetting; +function getTextAnalyserSetting() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_GET_IMAGE_TEXT_SETTING", []); + }); +} +exports.getTextAnalyserSetting = getTextAnalyserSetting; +function getGCRSetting() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_GET_GCR_SETTING", []); + }); +} +exports.getGCRSetting = getGCRSetting; +function stopFormRecognitionAnalyser() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_FORM_RECOGNITION_STOP", []); + }); +} +exports.stopFormRecognitionAnalyser = stopFormRecognitionAnalyser; +function bankCardDetector(bankCardDetecterReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_BANK_CARD_DETECTOR", [ + bankCardDetecterReq, + ]); + }); +} +exports.bankCardDetector = bankCardDetector; +function stopBankCardDetector() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_STOP_BANK_CARD_DETECTOR", []); + }); +} +exports.stopBankCardDetector = stopBankCardDetector; +function setResultCallbackBcr() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_BANK_CARD_SET_RESULT_CALLBACK", []); + }); +} +exports.setResultCallbackBcr = setResultCallbackBcr; +function setResultTypeBcr(mLBcrCaptureConfig) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_BANK_CARD_SET_RESULT_TYPE", []); + }); +} +exports.setResultTypeBcr = setResultTypeBcr; +function setRecModeBcr(mLBcrCaptureConfig) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_BANK_CARD_SET_RECMODE", []); + }); +} +exports.setRecModeBcr = setRecModeBcr; +function getBankCardDetectorSetting() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_GET_BANK_CARD_SETTING", []); + }); +} +exports.getBankCardDetectorSetting = getBankCardDetectorSetting; +function generalCardDetector(generalCardDetectorReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_GENERALCARD_PLUGIN_DETECTOR", [generalCardDetectorReq]); + }); +} +exports.generalCardDetector = generalCardDetector; +function formRecognitionAnalyser(formRecognizerAnalyserReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_FORM_RECOGNITION", [ + formRecognizerAnalyserReq, + ]); + }); +} +exports.formRecognitionAnalyser = formRecognitionAnalyser; +function icrVnCardDetector(icrVnDetectorReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_ICRVN_PLUGIN_DETECTOR", [ + icrVnDetectorReq, + ]); + }); +} +exports.icrVnCardDetector = icrVnCardDetector; +function icrVnCardCreate() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_ICRVN_CREATE", []); + }); +} +exports.icrVnCardCreate = icrVnCardCreate; +function getIcrVnCapture() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_ICRVN_CAPTURE", []); + }); +} +exports.getIcrVnCapture = getIcrVnCapture; +function geticrVnCardInstance() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_ICRVN_GET_INSTANCE", []); + }); +} +exports.geticrVnCardInstance = geticrVnCardInstance; +function icrCnCardCreate() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_ICRCN_CREATE", []); + }); +} +exports.icrCnCardCreate = icrCnCardCreate; +function geticrCnCardInstance() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_ICRCN_GET_INSTANCE", []); + }); +} +exports.geticrCnCardInstance = geticrCnCardInstance; +function getIcrCnCapture() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_ICRCN_CAPTURE", []); + }); +} +exports.getIcrCnCapture = getIcrCnCapture; +function icrCnCardDetector(icrCnDetectorReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_ICRCN_PLUGIN_DETECTOR", [ + icrCnDetectorReq, + ]); + }); +} +exports.icrCnCardDetector = icrCnCardDetector; +function icrLocalAnalyser(localAnalyserReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_LOCAL_ANALYSER", [ + localAnalyserReq, + ]); + }); +} +exports.icrLocalAnalyser = icrLocalAnalyser; +function icrLocalAnalyserCreateIdCard(createIdCardReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_LOCAL_ANALYSER_CREATE", [ + createIdCardReq, + ]); + }); +} +exports.icrLocalAnalyserCreateIdCard = icrLocalAnalyserCreateIdCard; +function icrLocalAnalyserStop() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLText", "ACTION_LOCAL_ANALYSER_STOP", []); + }); +} +exports.icrLocalAnalyserStop = icrLocalAnalyserStop; +function startCustomizedView(userProps) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)('HMSMLText', 'startCustomizedView', [userProps]); + }); +} +exports.startCustomizedView = startCustomizedView; +; +function switchLight() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)('HMSMLText', 'switchLight', []); + }); +} +exports.switchLight = switchLight; +; +function getLightStatus() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)('HMSMLText', 'getLightStatus', []); + }); +} +exports.getLightStatus = getLightStatus; +; +//# sourceMappingURL=HMSMLText.js.map \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/www/HMSMLText.js.map b/cordova-plugin-hms-mltext/www/HMSMLText.js.map new file mode 100644 index 00000000..e6d61e6b --- /dev/null +++ b/cordova-plugin-hms-mltext/www/HMSMLText.js.map @@ -0,0 +1 @@ +{"version":3,"file":"HMSMLText.js","sourceRoot":"","sources":["../src/www/HMSMLText.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;EAcE;AACF,iCAAmC;AAEnC,2CAuBsB;AAtBlB,6GAAA,eAAe,OAAA;AACf,oHAAA,sBAAsB,OAAA;AACtB,sHAAA,wBAAwB,OAAA;AACxB,+GAAA,iBAAiB,OAAA;AACjB,kHAAA,oBAAoB,OAAA;AACpB,gHAAA,kBAAkB,OAAA;AAClB,0GAAA,YAAY,OAAA;AACZ,iHAAA,mBAAmB,OAAA;AACnB,gHAAA,kBAAkB,OAAA;AAUlB,2GAAA,aAAa,OAAA;AACb,mHAAA,qBAAqB,OAAA;AACrB,oGAAA,MAAM,OAAA;AACN,qGAAA,OAAO,OAAA;AAGX,eAAe;AAEf,SAAsB,iBAAiB,CACnC,YAAgE;;QAEhE,OAAO,IAAA,gBAAS,EAAC,WAAW,EAAE,4BAA4B,EAAE;YACxD,YAAY;SACf,CAAC,CAAC;IACP,CAAC;CAAA;AAND,8CAMC;AACD,SAAsB,gBAAgB;;QAClC,OAAO,IAAA,gBAAS,EAAC,WAAW,EAAE,2BAA2B,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;CAAA;AAFD,4CAEC;AACD,SAAsB,mBAAmB;;QACrC,OAAO,IAAA,gBAAS,EACZ,WAAW,EACX,4BAA4B,EAC5B,EAAE,CACL,CAAC;IACN,CAAC;CAAA;AAND,kDAMC;AACD,SAAsB,qBAAqB,CACvC,gBAAgD;;QAEhD,OAAO,IAAA,gBAAS,EACZ,WAAW,EACX,gCAAgC,EAChC,CAAC,gBAAgB,CAAC,CACrB,CAAC;IACN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A;AAFD,kCAEC;AAAA,CAAC;AAEF,SAAsB,cAAc;;QAChC,OAAO,IAAA,gBAAS,EAAC,WAAW,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;CAAA;AAFD,wCAEC;AAAA,CAAC","sourcesContent":["/*\r\n Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved.\r\n\r\n Licensed under the Apache License, Version 2.0 (the \"License\")\r\n you may not use this file except in compliance with the License.\r\n You may obtain a copy of the License at\r\n\r\n https://www.apache.org/licenses/LICENSE-2.0\r\n\r\n Unless required by applicable law or agreed to in writing, software\r\n distributed under the License is distributed on an \"AS IS\" BASIS,\r\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n See the License for the specific language governing permissions and\r\n limitations under the License.\r\n*/\r\nimport { asyncExec } from \"./util\";\r\nimport * as MLKit from \"./interfaces\";\r\nexport {\r\n MLProductConfig,\r\n MLFormRecogitionConfig,\r\n ImgSuperResolutionConfig,\r\n MLBcrResultConfig,\r\n MLGcrCaptureUIConfig,\r\n MLBcrCaptureConfig,\r\n MLTextConfig,\r\n MLRemoteTextSetting,\r\n MLLocalTextSetting,\r\n MLText,\r\n MLDocument,\r\n MLBankCard,\r\n MLGcrCaptureResult,\r\n MLFormRecogitionResult,\r\n MLVnIcrCaptureResult,\r\n MLCnIcrCaptureResult,\r\n MLIcrCaptureResult,\r\n MLBcrCaptureResult,\r\n CordovaErrors,\r\n MLBcrCaptureErrorCode,\r\n Colors,\r\n RecMode\r\n} from \"./interfaces\";\r\n\r\n//Text Provider\r\n\r\nexport async function imageTextAnalyser(\r\n ImageTextReq: MLKit.localImageTextReq | MLKit.remoteImageTextReq\r\n): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_IMAGE_TEXT_ANALYSER\", [\r\n ImageTextReq,\r\n ]);\r\n}\r\nexport async function stopTextAnalyser(): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_STOP_TEXT_ANALYSER\", []);\r\n}\r\nexport async function getTextAnalyserInfo(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_GET_IMAGE_TEXT_INFO\",\r\n []\r\n );\r\n}\r\nexport async function documentImageAnalyser(\r\n documentImageReq: MLKit.documentImageAnalyserReq\r\n): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_DOCUMENT_IMAGE_ANALYSER\",\r\n [documentImageReq]\r\n );\r\n}\r\nexport async function closeDocumentImageAnalyser(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_CLOSE_DOCUMENT_IMAGE_ANALYSER\",\r\n []\r\n );\r\n}\r\nexport async function stopDocumentImageAnalyser(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_STOP_DOCUMENT_IMAGE_ANALYSER\",\r\n []\r\n );\r\n}\r\nexport async function getDocumentImageAnalyserSetting(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_GET_DOCUMENT_IMAGE_ANALYSER_SETTING\",\r\n []\r\n );\r\n}\r\nexport async function getTextAnalyserSetting(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_GET_IMAGE_TEXT_SETTING\",\r\n []\r\n );\r\n}\r\nexport async function getGCRSetting(): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_GET_GCR_SETTING\", []);\r\n}\r\nexport async function stopFormRecognitionAnalyser(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_FORM_RECOGNITION_STOP\",\r\n []\r\n );\r\n}\r\nexport async function bankCardDetector(\r\n bankCardDetecterReq:\r\n | MLKit.bankCardSDKDetectorReq\r\n | MLKit.bankCardPluginDetectorReq\r\n): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_BANK_CARD_DETECTOR\", [\r\n bankCardDetecterReq,\r\n ]);\r\n}\r\nexport async function stopBankCardDetector(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_STOP_BANK_CARD_DETECTOR\",\r\n []\r\n );\r\n}\r\n\r\nexport async function setResultCallbackBcr(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_BANK_CARD_SET_RESULT_CALLBACK\",\r\n []\r\n );\r\n}\r\nexport async function setResultTypeBcr(\r\n mLBcrCaptureConfig: MLKit.mLBcrCaptureConfig\r\n): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_BANK_CARD_SET_RESULT_TYPE\",\r\n []\r\n );\r\n}\r\nexport async function setRecModeBcr(\r\n mLBcrCaptureConfig: MLKit.mLBcrCaptureConfig\r\n): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_BANK_CARD_SET_RECMODE\",\r\n []\r\n );\r\n}\r\n\r\nexport async function getBankCardDetectorSetting(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_GET_BANK_CARD_SETTING\",\r\n []\r\n );\r\n}\r\n\r\nexport async function generalCardDetector(\r\n generalCardDetectorReq: MLKit.generalCardDetectorReq\r\n): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_GENERALCARD_PLUGIN_DETECTOR\",\r\n [generalCardDetectorReq]\r\n );\r\n}\r\n\r\nexport async function formRecognitionAnalyser(\r\n formRecognizerAnalyserReq: MLKit.formRecognizerAnalyserReq\r\n): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_FORM_RECOGNITION\", [\r\n formRecognizerAnalyserReq,\r\n ]);\r\n}\r\n\r\nexport async function icrVnCardDetector(\r\n icrVnDetectorReq: MLKit.icrVnDetectorReq\r\n): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_ICRVN_PLUGIN_DETECTOR\", [\r\n icrVnDetectorReq,\r\n ]);\r\n}\r\n\r\nexport async function icrVnCardCreate(): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_ICRVN_CREATE\", []);\r\n}\r\n\r\nexport async function getIcrVnCapture(): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_ICRVN_CAPTURE\", []);\r\n}\r\n\r\nexport async function geticrVnCardInstance(): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_ICRVN_GET_INSTANCE\", []);\r\n}\r\n\r\nexport async function icrCnCardCreate(): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_ICRCN_CREATE\", []);\r\n}\r\n\r\nexport async function geticrCnCardInstance(): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_ICRCN_GET_INSTANCE\", []);\r\n}\r\n\r\nexport async function getIcrCnCapture(): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_ICRCN_CAPTURE\", []);\r\n}\r\n\r\nexport async function icrCnCardDetector(\r\n icrCnDetectorReq: MLKit.icrCnDetectorReq\r\n): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_ICRCN_PLUGIN_DETECTOR\", [\r\n icrCnDetectorReq,\r\n ]);\r\n}\r\n\r\nexport async function icrLocalAnalyser(\r\n localAnalyserReq: MLKit.localAnalyserReq\r\n): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_LOCAL_ANALYSER\", [\r\n localAnalyserReq,\r\n ]);\r\n}\r\n\r\nexport async function icrLocalAnalyserCreateIdCard(\r\n createIdCardReq: MLKit.createIdCardReq\r\n): Promise {\r\n return asyncExec(\"HMSMLText\", \"ACTION_LOCAL_ANALYSER_CREATE\", [\r\n createIdCardReq,\r\n ]);\r\n}\r\n\r\nexport async function icrLocalAnalyserStop(): Promise {\r\n return asyncExec(\r\n \"HMSMLText\",\r\n \"ACTION_LOCAL_ANALYSER_STOP\",\r\n []\r\n );\r\n}\r\n\r\nexport async function startCustomizedView(userProps: MLKit.CustomViewModeRequest): Promise {\r\n return asyncExec('HMSMLText', 'startCustomizedView', [userProps]);\r\n};\r\n\r\nexport async function switchLight(): Promise {\r\n return asyncExec('HMSMLText', 'switchLight', []);\r\n};\r\n\r\nexport async function getLightStatus(): Promise {\r\n return asyncExec('HMSMLText', 'getLightStatus', []);\r\n};\r\n"]} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/www/HMSMLTextPlugin.js b/cordova-plugin-hms-mltext/www/HMSMLTextPlugin.js new file mode 100644 index 00000000..2cfc0c39 --- /dev/null +++ b/cordova-plugin-hms-mltext/www/HMSMLTextPlugin.js @@ -0,0 +1,79 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getCountryCode = exports.setUserRegion = exports.disableLogger = exports.enableLogger = exports.appSetting = exports.serviceInitializer = exports.Colors = exports.MLBcrCaptureErrorCode = exports.CordovaErrors = exports.MLLocalTextSetting = exports.MLRemoteTextSetting = exports.MLTextConfig = exports.MLBcrCaptureConfig = exports.MLGcrCaptureUIConfig = exports.MLBcrResultConfig = exports.ImgSuperResolutionConfig = void 0; +const util_1 = require("./util"); +var interfaces_1 = require("./interfaces"); +Object.defineProperty(exports, "ImgSuperResolutionConfig", { enumerable: true, get: function () { return interfaces_1.ImgSuperResolutionConfig; } }); +Object.defineProperty(exports, "MLBcrResultConfig", { enumerable: true, get: function () { return interfaces_1.MLBcrResultConfig; } }); +Object.defineProperty(exports, "MLGcrCaptureUIConfig", { enumerable: true, get: function () { return interfaces_1.MLGcrCaptureUIConfig; } }); +Object.defineProperty(exports, "MLBcrCaptureConfig", { enumerable: true, get: function () { return interfaces_1.MLBcrCaptureConfig; } }); +Object.defineProperty(exports, "MLTextConfig", { enumerable: true, get: function () { return interfaces_1.MLTextConfig; } }); +Object.defineProperty(exports, "MLRemoteTextSetting", { enumerable: true, get: function () { return interfaces_1.MLRemoteTextSetting; } }); +Object.defineProperty(exports, "MLLocalTextSetting", { enumerable: true, get: function () { return interfaces_1.MLLocalTextSetting; } }); +Object.defineProperty(exports, "CordovaErrors", { enumerable: true, get: function () { return interfaces_1.CordovaErrors; } }); +Object.defineProperty(exports, "MLBcrCaptureErrorCode", { enumerable: true, get: function () { return interfaces_1.MLBcrCaptureErrorCode; } }); +Object.defineProperty(exports, "Colors", { enumerable: true, get: function () { return interfaces_1.Colors; } }); +function serviceInitializer(params) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLTextPlugin", "HMSMLKIT_INITILALIZER", [params]); + }); +} +exports.serviceInitializer = serviceInitializer; +function appSetting(appSettingReq) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLTextPlugin", "ACTION_APP_SETTING", [appSettingReq]); + }); +} +exports.appSetting = appSetting; +function enableLogger() { + return (0, util_1.asyncExec)("HMSMLTextPlugin", "enableLogger", []); +} +exports.enableLogger = enableLogger; +function disableLogger() { + return (0, util_1.asyncExec)("HMSMLTextPlugin", "disableLogger", []); +} +exports.disableLogger = disableLogger; +/// Sets a data processing location when you choose to manually manage and specify such a location. +/// +/// REGION_DR_UNKNOWN = 1001, +/// REGION_DR_CHINA = 1002, +/// REGION_DR_RUSSIA = 1005, +/// REGION_DR_GERMAN = 1006, +/// REGION_DR_SINGAPORE = 1007 +function setUserRegion(region) { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLTextPlugin", "setUserRegion", [region]); + }); +} +exports.setUserRegion = setUserRegion; +function getCountryCode() { + return __awaiter(this, void 0, void 0, function* () { + return (0, util_1.asyncExec)("HMSMLTextPlugin", "getCountryCode", []); + }); +} +exports.getCountryCode = getCountryCode; +//# sourceMappingURL=HMSMLTextPlugin.js.map \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/www/HMSMLTextPlugin.js.map b/cordova-plugin-hms-mltext/www/HMSMLTextPlugin.js.map new file mode 100644 index 00000000..46a4b476 --- /dev/null +++ b/cordova-plugin-hms-mltext/www/HMSMLTextPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"HMSMLTextPlugin.js","sourceRoot":"","sources":["../src/www/HMSMLTextPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;AA6BA,iCAAmC;AAEnC,2CAYsB;AAXlB,sHAAA,wBAAwB,OAAA;AACxB,+GAAA,iBAAiB,OAAA;AACjB,kHAAA,oBAAoB,OAAA;AACpB,gHAAA,kBAAkB,OAAA;AAClB,0GAAA,YAAY,OAAA;AACZ,iHAAA,mBAAmB,OAAA;AACnB,gHAAA,kBAAkB,OAAA;AAElB,2GAAA,aAAa,OAAA;AACb,mHAAA,qBAAqB,OAAA;AACrB,oGAAA,MAAM,OAAA;AAIV,SAAsB,kBAAkB,CACpC,MAAuB;;QAEvB,OAAO,IAAA,gBAAS,EAAC,iBAAiB,EAAE,uBAAuB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3E,CAAC;CAAA;AAJD,gDAIC;AACD,SAAsB,UAAU,CAC5B,aAAkC;;QAElC,OAAO,IAAA,gBAAS,EAAC,iBAAiB,EAAE,oBAAoB,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/E,CAAC;CAAA;AAJD,gCAIC;AACD,SAAgB,YAAY;IACxB,OAAO,IAAA,gBAAS,EAAC,iBAAiB,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC;AAFD,oCAEC;AACD,SAAgB,aAAa;IACzB,OAAO,IAAA,gBAAS,EAAC,iBAAiB,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC;AAFD,sCAEC;AACD,mGAAmG;AACnG,GAAG;AACH,6BAA6B;AAC7B,2BAA2B;AAC3B,4BAA4B;AAC5B,4BAA4B;AAC5B,8BAA8B;AAC9B,SAAsB,aAAa,CAC/B,MAAc;;QAEd,OAAO,IAAA,gBAAS,EAAC,iBAAiB,EAAE,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACnE,CAAC;CAAA;AAJD,sCAIC;AACD,SAAsB,cAAc;;QAChC,OAAO,IAAA,gBAAS,EAAC,iBAAiB,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;CAAA;AAFD,wCAEC","sourcesContent":["/*\r\n Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved.\r\n\r\n Licensed under the Apache License, Version 2.0 (the \"License\")\r\n you may not use this file except in compliance with the License.\r\n You may obtain a copy of the License at\r\n\r\n https://www.apache.org/licenses/LICENSE-2.0\r\n\r\n Unless required by applicable law or agreed to in writing, software\r\n distributed under the License is distributed on an \"AS IS\" BASIS,\r\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n See the License for the specific language governing permissions and\r\n limitations under the License.\r\n*/\r\nimport {\r\n ImgSuperResolutionConfig,\r\n MLBcrResultConfig,\r\n MLGcrCaptureUIConfig,\r\n MLBcrCaptureConfig,\r\n MLTextConfig,\r\n MLRemoteTextSetting,\r\n MLLocalTextSetting,\r\n MLBcrCaptureResult,\r\n CordovaErrors,\r\n MLBcrCaptureErrorCode,\r\n Colors,\r\n Region,\r\n} from \"./interfaces\";\r\nimport { asyncExec } from \"./util\";\r\nimport * as MLKit from \"./interfaces\";\r\nexport {\r\n ImgSuperResolutionConfig,\r\n MLBcrResultConfig,\r\n MLGcrCaptureUIConfig,\r\n MLBcrCaptureConfig,\r\n MLTextConfig,\r\n MLRemoteTextSetting,\r\n MLLocalTextSetting,\r\n MLBcrCaptureResult,\r\n CordovaErrors,\r\n MLBcrCaptureErrorCode,\r\n Colors,\r\n} from \"./interfaces\";\r\n\r\n\r\nexport async function serviceInitializer(\r\n params: MLKit.configReq\r\n): Promise {\r\n return asyncExec(\"HMSMLTextPlugin\", \"HMSMLKIT_INITILALIZER\", [params]);\r\n}\r\nexport async function appSetting(\r\n appSettingReq: MLKit.appSettingReq\r\n): Promise {\r\n return asyncExec(\"HMSMLTextPlugin\", \"ACTION_APP_SETTING\", [appSettingReq]);\r\n}\r\nexport function enableLogger(): Promise {\r\n return asyncExec(\"HMSMLTextPlugin\", \"enableLogger\", []);\r\n}\r\nexport function disableLogger(): Promise {\r\n return asyncExec(\"HMSMLTextPlugin\", \"disableLogger\", []);\r\n}\r\n/// Sets a data processing location when you choose to manually manage and specify such a location.\r\n///\r\n/// REGION_DR_UNKNOWN = 1001,\r\n/// REGION_DR_CHINA = 1002,\r\n/// REGION_DR_RUSSIA = 1005,\r\n/// REGION_DR_GERMAN = 1006,\r\n/// REGION_DR_SINGAPORE = 1007\r\nexport async function setUserRegion(\r\n region: number\r\n): Promise {\r\n return asyncExec(\"HMSMLTextPlugin\", \"setUserRegion\", [region]);\r\n}\r\nexport async function getCountryCode(): Promise {\r\n return asyncExec(\"HMSMLTextPlugin\", \"getCountryCode\", []);\r\n}\r\n"]} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/www/index.js b/cordova-plugin-hms-mltext/www/index.js new file mode 100644 index 00000000..81691fc7 --- /dev/null +++ b/cordova-plugin-hms-mltext/www/index.js @@ -0,0 +1,36 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./HMSMLTextPlugin"), exports); +__exportStar(require("./HMSMLText"), exports); +__exportStar(require("./interfaces"), exports); +__exportStar(require("./util"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/www/index.js.map b/cordova-plugin-hms-mltext/www/index.js.map new file mode 100644 index 00000000..0217c562 --- /dev/null +++ b/cordova-plugin-hms-mltext/www/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/www/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;EAcE;AACF,oDAAkC;AAClC,8CAA4B;AAC5B,+CAA6B;AAC7B,yCAAuB","sourcesContent":["/*\r\n Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved.\r\n\r\n Licensed under the Apache License, Version 2.0 (the \"License\")\r\n you may not use this file except in compliance with the License.\r\n You may obtain a copy of the License at\r\n\r\n https://www.apache.org/licenses/LICENSE-2.0\r\n\r\n Unless required by applicable law or agreed to in writing, software\r\n distributed under the License is distributed on an \"AS IS\" BASIS,\r\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n See the License for the specific language governing permissions and\r\n limitations under the License.\r\n*/\r\nexport * from \"./HMSMLTextPlugin\";\r\nexport * from \"./HMSMLText\";\r\nexport * from \"./interfaces\";\r\nexport * from \"./util\";\r\n"]} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/www/interfaces.js b/cordova-plugin-hms-mltext/www/interfaces.js new file mode 100644 index 00000000..503480c7 --- /dev/null +++ b/cordova-plugin-hms-mltext/www/interfaces.js @@ -0,0 +1,156 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CordovaErrors = exports.Colors = exports.MLTextConfig = exports.MLLocalTextSetting = exports.MLProductConfig = exports.ImgSuperResolutionConfig = exports.MLIcrSideType = exports.icrCaptureType = exports.MLGcrCaptureUIConfig = exports.gcrCaptureType = exports.MLFormRecogitionConfig = exports.MLRemoteTextSetting = exports.MLBcrCaptureErrorCode = exports.MLBcrResultConfig = exports.MLBcrCaptureConfig = exports.RecMode = exports.Region = void 0; +var Region; +(function (Region) { + Region[Region["REGION_DR_UNKNOWN"] = 1001] = "REGION_DR_UNKNOWN"; + Region[Region["REGION_DR_CHINA"] = 1002] = "REGION_DR_CHINA"; + Region[Region["REGION_DR_RUSSIA"] = 1005] = "REGION_DR_RUSSIA"; + Region[Region["REGION_DR_GERMAN"] = 1006] = "REGION_DR_GERMAN"; + Region[Region["REGION_DR_SINGAPORE"] = 1007] = "REGION_DR_SINGAPORE"; +})(Region || (exports.Region = Region = {})); +var RecMode; +(function (RecMode) { + RecMode[RecMode["WEAK_MODE"] = 0] = "WEAK_MODE"; + RecMode[RecMode["STRICT_MODE"] = 1] = "STRICT_MODE"; +})(RecMode || (exports.RecMode = RecMode = {})); +var MLBcrCaptureConfig; +(function (MLBcrCaptureConfig) { + MLBcrCaptureConfig[MLBcrCaptureConfig["ERROR_CODE_INIT_CAMERA_FAILED"] = 10101] = "ERROR_CODE_INIT_CAMERA_FAILED"; + MLBcrCaptureConfig[MLBcrCaptureConfig["RESULT_NUM_ONLY"] = 0] = "RESULT_NUM_ONLY"; + MLBcrCaptureConfig[MLBcrCaptureConfig["ORIENTATION_AUTO"] = 0] = "ORIENTATION_AUTO"; + MLBcrCaptureConfig[MLBcrCaptureConfig["WEAK_MODE"] = 0] = "WEAK_MODE"; + MLBcrCaptureConfig[MLBcrCaptureConfig["ORIENTATION_LANDSCAPE"] = 1] = "ORIENTATION_LANDSCAPE"; + MLBcrCaptureConfig[MLBcrCaptureConfig["ORIENTATION_PORTRAIT"] = 2] = "ORIENTATION_PORTRAIT"; + MLBcrCaptureConfig[MLBcrCaptureConfig["RESULT_ALL"] = 2] = "RESULT_ALL"; + MLBcrCaptureConfig[MLBcrCaptureConfig["RESULT_SIMPLE"] = 1] = "RESULT_SIMPLE"; + MLBcrCaptureConfig[MLBcrCaptureConfig["STRICT_MODE"] = 1] = "STRICT_MODE"; +})(MLBcrCaptureConfig || (exports.MLBcrCaptureConfig = MLBcrCaptureConfig = {})); +var MLBcrResultConfig; +(function (MLBcrResultConfig) { + MLBcrResultConfig[MLBcrResultConfig["RESULT_NUM_ONLY"] = 0] = "RESULT_NUM_ONLY"; + MLBcrResultConfig[MLBcrResultConfig["RESULT_SIMPLE"] = 1] = "RESULT_SIMPLE"; + MLBcrResultConfig[MLBcrResultConfig["RESULT_ALL"] = 2] = "RESULT_ALL"; +})(MLBcrResultConfig || (exports.MLBcrResultConfig = MLBcrResultConfig = {})); +var MLBcrCaptureErrorCode; +(function (MLBcrCaptureErrorCode) { + MLBcrCaptureErrorCode[MLBcrCaptureErrorCode["ERROR_CODE_INIT_CAMERA_FAILED"] = 10101] = "ERROR_CODE_INIT_CAMERA_FAILED"; +})(MLBcrCaptureErrorCode || (exports.MLBcrCaptureErrorCode = MLBcrCaptureErrorCode = {})); +var MLRemoteTextSetting; +(function (MLRemoteTextSetting) { + MLRemoteTextSetting[MLRemoteTextSetting["OCR_LOOSE_SCENE"] = 1] = "OCR_LOOSE_SCENE"; + MLRemoteTextSetting[MLRemoteTextSetting["OCR_COMPACT_SCENE"] = 2] = "OCR_COMPACT_SCENE"; + MLRemoteTextSetting["NGON"] = "NGON"; + MLRemoteTextSetting["ARC"] = "ARC"; + MLRemoteTextSetting[MLRemoteTextSetting["OTHER"] = 5] = "OTHER"; + MLRemoteTextSetting[MLRemoteTextSetting["NEW_LINE_CHARACTER"] = 8] = "NEW_LINE_CHARACTER"; + MLRemoteTextSetting[MLRemoteTextSetting["SPACE"] = 6] = "SPACE"; +})(MLRemoteTextSetting || (exports.MLRemoteTextSetting = MLRemoteTextSetting = {})); +var MLFormRecogitionConfig; +(function (MLFormRecogitionConfig) { + MLFormRecogitionConfig[MLFormRecogitionConfig["SYNC_TYPE"] = 1] = "SYNC_TYPE"; + MLFormRecogitionConfig[MLFormRecogitionConfig["ASYNC_TYPE"] = 0] = "ASYNC_TYPE"; +})(MLFormRecogitionConfig || (exports.MLFormRecogitionConfig = MLFormRecogitionConfig = {})); +var gcrCaptureType; +(function (gcrCaptureType) { + gcrCaptureType[gcrCaptureType["CAPTURE_ACTIVITY"] = 0] = "CAPTURE_ACTIVITY"; + gcrCaptureType[gcrCaptureType["CAPTURE_PHOTO"] = 1] = "CAPTURE_PHOTO"; + gcrCaptureType[gcrCaptureType["CAPTURE_IMAGE"] = 2] = "CAPTURE_IMAGE"; +})(gcrCaptureType || (exports.gcrCaptureType = gcrCaptureType = {})); +var MLGcrCaptureUIConfig; +(function (MLGcrCaptureUIConfig) { + MLGcrCaptureUIConfig[MLGcrCaptureUIConfig["ORIENTATION_AUTO"] = 0] = "ORIENTATION_AUTO"; + MLGcrCaptureUIConfig[MLGcrCaptureUIConfig["ORIENTATION_LANDSCAPE"] = 1] = "ORIENTATION_LANDSCAPE"; + MLGcrCaptureUIConfig[MLGcrCaptureUIConfig["ORIENTATION_PORTRAIT"] = 2] = "ORIENTATION_PORTRAIT"; +})(MLGcrCaptureUIConfig || (exports.MLGcrCaptureUIConfig = MLGcrCaptureUIConfig = {})); +var icrCaptureType; +(function (icrCaptureType) { + icrCaptureType[icrCaptureType["CAPTURE_CAMERA"] = 0] = "CAPTURE_CAMERA"; + icrCaptureType[icrCaptureType["CAPTURE_IMAGE"] = 1] = "CAPTURE_IMAGE"; +})(icrCaptureType || (exports.icrCaptureType = icrCaptureType = {})); +var MLIcrSideType; +(function (MLIcrSideType) { + MLIcrSideType["FRONT"] = "FRONT"; + MLIcrSideType["BACK"] = "BACK"; +})(MLIcrSideType || (exports.MLIcrSideType = MLIcrSideType = {})); +var ImgSuperResolutionConfig; +(function (ImgSuperResolutionConfig) { + ImgSuperResolutionConfig[ImgSuperResolutionConfig["ISR_SCALE_1X"] = 1] = "ISR_SCALE_1X"; + ImgSuperResolutionConfig[ImgSuperResolutionConfig["ISR_SCALE_3X"] = 3] = "ISR_SCALE_3X"; +})(ImgSuperResolutionConfig || (exports.ImgSuperResolutionConfig = ImgSuperResolutionConfig = {})); +var MLProductConfig; +(function (MLProductConfig) { + MLProductConfig[MLProductConfig["REGION_DR_CHINA"] = 1002] = "REGION_DR_CHINA"; + MLProductConfig[MLProductConfig["REGION_DR_AFILA"] = 1003] = "REGION_DR_AFILA"; + MLProductConfig[MLProductConfig["REGION_DR_EUROPE"] = 1004] = "REGION_DR_EUROPE"; + MLProductConfig[MLProductConfig["REGION_DR_RUSSIA"] = 1005] = "REGION_DR_RUSSIA"; + MLProductConfig[MLProductConfig["REGION_DR_GERMAN"] = 1006] = "REGION_DR_GERMAN"; + MLProductConfig[MLProductConfig["REGION_DR_SIANGAPORE"] = 1007] = "REGION_DR_SIANGAPORE"; +})(MLProductConfig || (exports.MLProductConfig = MLProductConfig = {})); +var MLLocalTextSetting; +(function (MLLocalTextSetting) { + MLLocalTextSetting[MLLocalTextSetting["OCR_DETECT_MODE"] = 1] = "OCR_DETECT_MODE"; + MLLocalTextSetting[MLLocalTextSetting["OCR_TRACKING_MODE"] = 2] = "OCR_TRACKING_MODE"; +})(MLLocalTextSetting || (exports.MLLocalTextSetting = MLLocalTextSetting = {})); +var MLTextConfig; +(function (MLTextConfig) { + MLTextConfig[MLTextConfig["OCR_LOCAL_TYPE"] = 0] = "OCR_LOCAL_TYPE"; + MLTextConfig[MLTextConfig["OCR_REMOTE_TYPE"] = 1] = "OCR_REMOTE_TYPE"; +})(MLTextConfig || (exports.MLTextConfig = MLTextConfig = {})); +var Colors; +(function (Colors) { + Colors[Colors["RED"] = -65536] = "RED"; + Colors[Colors["DKGRAY"] = -12303292] = "DKGRAY"; + Colors[Colors["GRAY"] = -7829368] = "GRAY"; + Colors[Colors["WHITE"] = -1] = "WHITE"; + Colors[Colors["BLUE"] = -16776961] = "BLUE"; + Colors[Colors["BLACK"] = -16777216] = "BLACK"; + Colors[Colors["LTGRAY"] = -3355444] = "LTGRAY"; + Colors[Colors["MAGENTA"] = -65281] = "MAGENTA"; + Colors[Colors["YELLOW"] = -256] = "YELLOW"; + Colors[Colors["CYAN"] = -16711681] = "CYAN"; + Colors[Colors["GREEN"] = -16711936] = "GREEN"; + Colors[Colors["TRANSPARENT"] = 0] = "TRANSPARENT"; +})(Colors || (exports.Colors = Colors = {})); +var CordovaErrors; +(function (CordovaErrors) { + CordovaErrors[CordovaErrors["UNKNOWN"] = -1] = "UNKNOWN"; + CordovaErrors[CordovaErrors["SUCCESS"] = 0] = "SUCCESS"; + CordovaErrors[CordovaErrors["DISCARDED"] = 1] = "DISCARDED"; + CordovaErrors[CordovaErrors["INNER"] = 2] = "INNER"; + CordovaErrors[CordovaErrors["INACTIVE"] = 3] = "INACTIVE"; + CordovaErrors[CordovaErrors["NOT_SUPPORTED"] = 4] = "NOT_SUPPORTED"; + CordovaErrors[CordovaErrors["ILLEGAL_PARAMETER"] = 5] = "ILLEGAL_PARAMETER"; + CordovaErrors[CordovaErrors["OVERDUE"] = 6] = "OVERDUE"; + CordovaErrors[CordovaErrors["NO_FOUND"] = 7] = "NO_FOUND"; + CordovaErrors[CordovaErrors["DUPLICATE_FOUND"] = 8] = "DUPLICATE_FOUND"; + CordovaErrors[CordovaErrors["NO_PERMISSION"] = 9] = "NO_PERMISSION"; + CordovaErrors[CordovaErrors["INSUFFICIENT_RESOURCE"] = 10] = "INSUFFICIENT_RESOURCE"; + CordovaErrors[CordovaErrors["ANALYSIS_FAILURE"] = 11] = "ANALYSIS_FAILURE"; + CordovaErrors[CordovaErrors["INTERRUPTED"] = 12] = "INTERRUPTED"; + CordovaErrors[CordovaErrors["EXCEED_RANGE"] = 13] = "EXCEED_RANGE"; + CordovaErrors[CordovaErrors["DATA_MISSING"] = 14] = "DATA_MISSING"; + CordovaErrors[CordovaErrors["AUTHENTICATION_REQUIRED"] = 15] = "AUTHENTICATION_REQUIRED"; + CordovaErrors[CordovaErrors["TFLITE_NOT_COMPATIBLE"] = 16] = "TFLITE_NOT_COMPATIBLE"; + CordovaErrors[CordovaErrors["INSUFFICIENT_SPACE"] = 17] = "INSUFFICIENT_SPACE"; + CordovaErrors[CordovaErrors["HASH_MISS"] = 18] = "HASH_MISS"; + CordovaErrors[CordovaErrors["TOKEN_INVALID"] = 19] = "TOKEN_INVALID"; + CordovaErrors[CordovaErrors["SERVICE_FAILURE"] = 20] = "SERVICE_FAILURE"; + CordovaErrors[CordovaErrors["ANALYSIS_NULL"] = 21] = "ANALYSIS_NULL"; +})(CordovaErrors || (exports.CordovaErrors = CordovaErrors = {})); +//# sourceMappingURL=interfaces.js.map \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/www/interfaces.js.map b/cordova-plugin-hms-mltext/www/interfaces.js.map new file mode 100644 index 00000000..4ec19a6f --- /dev/null +++ b/cordova-plugin-hms-mltext/www/interfaces.js.map @@ -0,0 +1 @@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CAAkB,CAAA;IAClB,0CAAe,CAAA;IACf,sCAAU,CAAA;IACV,2CAAgB,CAAA;IAChB,6CAAiB,CAAA;IACjB,8CAAiB,CAAA;IACjB,8CAAgB,CAAA;IAChB,0CAAa,CAAA;IACb,2CAAgB,CAAA;IAChB,6CAAiB,CAAA;IACjB,iDAAe,CAAA;AACnB,CAAC,EAbW,MAAM,sBAAN,MAAM,QAajB;AACD,IAAY,aAwBX;AAxBD,WAAY,aAAa;IACrB,wDAAY,CAAA;IACZ,uDAAW,CAAA;IACX,2DAAa,CAAA;IACb,mDAAS,CAAA;IACT,yDAAY,CAAA;IACZ,mEAAiB,CAAA;IACjB,2EAAqB,CAAA;IACrB,uDAAW,CAAA;IACX,yDAAY,CAAA;IACZ,uEAAmB,CAAA;IACnB,mEAAiB,CAAA;IACjB,oFAA0B,CAAA;IAC1B,0EAAqB,CAAA;IACrB,gEAAgB,CAAA;IAChB,kEAAiB,CAAA;IACjB,kEAAiB,CAAA;IACjB,wFAA4B,CAAA;IAC5B,oFAA0B,CAAA;IAC1B,8EAAuB,CAAA;IACvB,4DAAc,CAAA;IACd,oEAAkB,CAAA;IAClB,wEAAoB,CAAA;IACpB,oEAAkB,CAAA;AACtB,CAAC,EAxBW,aAAa,6BAAb,aAAa,QAwBxB","sourcesContent":["/*\r\n Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved.\r\n\r\n Licensed under the Apache License, Version 2.0 (the \"License\")\r\n you may not use this file except in compliance with the License.\r\n You may obtain a copy of the License at\r\n\r\n https://www.apache.org/licenses/LICENSE-2.0\r\n\r\n Unless required by applicable law or agreed to in writing, software\r\n distributed under the License is distributed on an \"AS IS\" BASIS,\r\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n See the License for the specific language governing permissions and\r\n limitations under the License.\r\n*/\r\nexport enum Region {\r\n REGION_DR_UNKNOWN = 1001,\r\n REGION_DR_CHINA = 1002,\r\n REGION_DR_RUSSIA = 1005,\r\n REGION_DR_GERMAN = 1006,\r\n REGION_DR_SINGAPORE = 1007\r\n}\r\n\r\nexport interface CustomViewModeRequest {\r\n isTitleAvailable: boolean;\r\n title: string;\r\n heightFactor: number;\r\n widthFactor: number;\r\n isFlashAvailable: boolean;\r\n resultType: MLBcrResultConfig;\r\n recMode: RecMode;\r\n }\r\n\r\n// API KEY\r\n\r\nexport interface configReq {\r\n apiKey: string;\r\n}\r\n\r\nexport interface appSettingReq {\r\n apiKey?: string | null;\r\n applicationId?: string | null;\r\n certFingerprint?: string | null;\r\n}\r\n\r\n\r\n// SDK BANK CARD ANALYSER\r\n\r\nexport interface bankCardSDKDetectorReq {\r\n filePath: any;\r\n detectType: 0;\r\n mLBcrAnalyzerSetting?: MLBcrAnalyzerSetting | null;\r\n}\r\n\r\nexport interface MLBcrAnalyzerSetting {\r\n langType?: string | null;\r\n resultType?: MLBcrResultConfig | null;\r\n}\r\n\r\n// PLUGIN BANK CARD ANALYSER\r\n\r\nexport interface bankCardPluginDetectorReq {\r\n detectType: 1;\r\n mLBcrCaptureConfig?: mLBcrCaptureConfig | null;\r\n}\r\n\r\nexport interface mLBcrCaptureConfig {\r\n orientation?: MLBcrCaptureConfig | null;\r\n resultType?: MLBcrResultConfig | null;\r\n recMode?: RecMode | null;\r\n}\r\n\r\nexport enum RecMode {\r\n WEAK_MODE = 0,\r\n STRICT_MODE = 1,\r\n}\r\n\r\nexport enum MLBcrCaptureConfig {\r\n ERROR_CODE_INIT_CAMERA_FAILED = 10101,\r\n RESULT_NUM_ONLY = 0,\r\n ORIENTATION_AUTO = 0,\r\n WEAK_MODE = 0,\r\n ORIENTATION_LANDSCAPE = 1,\r\n ORIENTATION_PORTRAIT = 2,\r\n RESULT_ALL = 2,\r\n RESULT_SIMPLE = 1,\r\n STRICT_MODE = 1,\r\n}\r\nexport enum MLBcrResultConfig {\r\n RESULT_NUM_ONLY = 0,\r\n RESULT_SIMPLE = 1,\r\n RESULT_ALL = 2,\r\n}\r\n\r\nexport interface MLBcrCaptureResult {\r\n errorCode?: MLBcrCaptureErrorCode | null;\r\n expire?: String | null;\r\n issuer?: String | null;\r\n number?: String | null;\r\n numberBitmap?: any;\r\n organization?: String | null;\r\n riginalBitmap?: any;\r\n type?: String | null;\r\n}\r\n\r\nexport enum MLBcrCaptureErrorCode {\r\n ERROR_CODE_INIT_CAMERA_FAILED = 10101,\r\n}\r\n\r\n \r\n//Document Analyser\r\n\r\nexport interface documentImageAnalyserReq {\r\n documentSetting?: DocumentSetting | null;\r\n filePath: any;\r\n}\r\nexport interface DocumentSetting {\r\n borderType?: MLRemoteTextSetting | null;\r\n languageList?: Array | null;\r\n enableFingerprintVerification: boolean | null;\r\n}\r\n\r\nexport enum MLRemoteTextSetting {\r\n OCR_LOOSE_SCENE = 1,\r\n OCR_COMPACT_SCENE = 2,\r\n NGON = \"NGON\",\r\n ARC = \"ARC\",\r\n OTHER = 5,\r\n NEW_LINE_CHARACTER = 8,\r\n SPACE = 6,\r\n}\r\n\r\n\r\n//Form Recognizer Analyser\r\n\r\nexport interface formRecognizerAnalyserReq {\r\n filePath: any;\r\n syncType: MLFormRecogitionConfig;\r\n}\r\nexport enum MLFormRecogitionConfig {\r\n SYNC_TYPE = 1,\r\n ASYNC_TYPE = 0,\r\n}\r\n\r\n// GENERAL CARD ANALYSER \r\n\r\nexport interface generalCardDetectorReq {\r\n gcrCaptureConfig?: gcrCaptureConfig;\r\n gcrCaptureUIConfig?: gcrCaptureUIConfig;\r\n captureType?: gcrCaptureType | null;\r\n}\r\n\r\nexport interface gcrCaptureConfig {\r\n language: string;\r\n}\r\nexport enum gcrCaptureType {\r\n CAPTURE_ACTIVITY = 0,\r\n CAPTURE_PHOTO = 1,\r\n CAPTURE_IMAGE = 2,\r\n}\r\nexport interface gcrCaptureUIConfig {\r\n orientation?: MLGcrCaptureUIConfig | null;\r\n tipText?: string | null;\r\n tipTextColor?: number | null;\r\n photoButtonResId?: number | null;\r\n scanBoxCornerColor?: number | null;\r\n backButtonRedId?: number | null;\r\n torchRedId?: number | null;\r\n}\r\nexport interface gcrSettingResults {\r\n gcrConfigLanguage: String;\r\n torchOnResId: number;\r\n tipTextColor: number;\r\n tipText: String;\r\n backButtonResId: number;\r\n orientation: number;\r\n photoButtonResId: number;\r\n scanBoxScreenRatio: number;\r\n scanBoxCornerColor: number;\r\n scanBoxAspectRatio: number;\r\n}\r\n\r\nexport enum MLGcrCaptureUIConfig {\r\n ORIENTATION_AUTO = 0,\r\n ORIENTATION_LANDSCAPE = 1,\r\n ORIENTATION_PORTRAIT = 2,\r\n}\r\n\r\n// ID CARD ANALYSER\r\n\r\nexport interface icrVnDetectorReq {\r\n captureType: icrCaptureType;\r\n filePath?: any | null;\r\n}\r\n\r\nexport interface icrCnDetectorReq {\r\n captureType: icrCaptureType;\r\n filePath?: any | null;\r\n isFront?: boolean | null;\r\n}\r\n\r\nexport enum icrCaptureType {\r\n CAPTURE_CAMERA = 0,\r\n CAPTURE_IMAGE = 1,\r\n}\r\n\r\nexport interface createIdCardReq {\r\n mlIcrAnalyzerSetting?: MLIcrAnalyzerSetting | null;\r\n}\r\n\r\nexport interface localAnalyserReq {\r\n settings: MLIcrAnalyzerSetting;\r\n filePath?: any | null;\r\n}\r\nexport interface MLIcrAnalyzerSetting {\r\n countryCode: string;\r\n hashCode?: number | null;\r\n sideType?: MLIcrSideType | null;\r\n}\r\n\r\nexport enum MLIcrSideType {\r\n FRONT = \"FRONT\",\r\n BACK = \"BACK\",\r\n}\r\n\r\n\r\n//Image Super Resolution\r\n\r\nexport interface imageSuperResolutionReq {\r\n filePath: any;\r\n imgSuperResolutionSetting?: ImgSuperResolutionSetting | null;\r\n syncType?: MLFormRecogitionConfig | null;\r\n}\r\nexport interface ImgSuperResolutionSetting {\r\n scaleType?: ImgSuperResolutionConfig;\r\n}\r\nexport enum ImgSuperResolutionConfig {\r\n ISR_SCALE_1X = 1.0,\r\n ISR_SCALE_3X = 3.0,\r\n}\r\n\r\n//Product Vision Analyser\r\n\r\nexport interface productReq {\r\n filePath?: any | null;\r\n detectType?: number;\r\n mlProductSetting?: mlProductSetting | null;\r\n}\r\nexport interface mlProductSetting {\r\n largestNumOfReturns?: number | null;\r\n productSetId?: string | null;\r\n region?: MLProductConfig | null;\r\n}\r\nexport enum MLProductConfig {\r\n REGION_DR_CHINA = 1002,\r\n REGION_DR_AFILA = 1003,\r\n REGION_DR_EUROPE = 1004,\r\n REGION_DR_RUSSIA = 1005,\r\n REGION_DR_GERMAN = 1006,\r\n REGION_DR_SIANGAPORE = 1007,\r\n}\r\n\r\n\r\n//Text Analyser\r\n\r\nexport interface localImageTextReq {\r\n ocrType: MLTextConfig;\r\n analyseMode?: number;\r\n localTextSetting?: localTextSetting | null;\r\n filePath: any;\r\n}\r\n\r\nexport interface localTextSetting {\r\n ocrMode?: MLLocalTextSetting;\r\n language?: string;\r\n}\r\n\r\nexport enum MLLocalTextSetting {\r\n OCR_DETECT_MODE = 1,\r\n OCR_TRACKING_MODE = 2,\r\n}\r\nexport enum MLTextConfig {\r\n OCR_LOCAL_TYPE = 0,\r\n OCR_REMOTE_TYPE = 1,\r\n}\r\nexport interface remoteImageTextReq {\r\n ocrType: MLTextConfig;\r\n analyseMode?: number;\r\n remoteTextSetting?: remoteTextSetting;\r\n filePath: any;\r\n}\r\nexport interface remoteTextSetting {\r\n textDensityScene?: MLRemoteTextSetting;\r\n languageList?: Array;\r\n borderType?: MLRemoteTextSetting;\r\n}\r\n\r\n/*\r\n----------------- return\r\n*/\r\n\r\nexport interface MLBankCard {\r\n number: string;\r\n expire: string;\r\n issuer: string;\r\n type: string;\r\n organization: string;\r\n originalBitmap: any;\r\n numberBitmap: any;\r\n}\r\n\r\nexport interface Border {\r\n bottom: number;\r\n top: number;\r\n left: number;\r\n right: number;\r\n exactCenterX: number;\r\n centerY: number;\r\n centerX: number;\r\n describeContents: number;\r\n height: number;\r\n width: number;\r\n}\r\n\r\nexport interface MLDocument {\r\n stringValue: string;\r\n blocks?: Blocks[];\r\n}\r\nexport interface LanguageList {\r\n language: string;\r\n}\r\n\r\nexport interface MLVnIcrCaptureResult {\r\n birthday: string;\r\n cardBitmap: Bitmap;\r\n idNum: string;\r\n name: string;\r\n sex: string;\r\n}\r\n\r\nexport interface MLCnIcrCaptureResult {\r\n birthday: string;\r\n cardBitmap: Bitmap;\r\n idNum: string;\r\n name: string;\r\n sex: string;\r\n nation: string;\r\n address: string;\r\n authority: string;\r\n validDate: string;\r\n}\r\n\r\nexport interface MLIcrCaptureResult {\r\n birthday: string;\r\n cardBitmap: Bitmap;\r\n idNum: string;\r\n name: string;\r\n sex: string;\r\n nation: string;\r\n address: string;\r\n validDate: string;\r\n}\r\n\r\nexport interface MLGcrCaptureResult {\r\n text: string;\r\n cardBitmap: Bitmap;\r\n}\r\n\r\n\r\nexport interface Rect {\r\n bottom: number;\r\n top: number;\r\n left: number;\r\n right: number;\r\n exactCenterX: number;\r\n centerY: number;\r\n centerX: number;\r\n describeContents: number;\r\n height: number;\r\n width: number;\r\n}\r\n\r\nexport interface MLText {\r\n stringValue: string;\r\n blocks?: Blocks[];\r\n}\r\nexport interface Blocks {\r\n contents?: Contents[];\r\n}\r\nexport interface Contents {\r\n stringValue: string;\r\n border: Border;\r\n language: string;\r\n languageList?: LanguageList[];\r\n vertexes?: Vertexes[];\r\n}\r\nexport interface LanguageList {\r\n language: string;\r\n}\r\nexport interface Vertexes {\r\n x: number;\r\n y: number;\r\n describeContents: number;\r\n}\r\n\r\nexport interface MLFormRecogitionResult {\r\n retCode: number;\r\n tableContent: TableContent;\r\n}\r\n\r\nexport interface TableContent {\r\n tableCount: number;\r\n tables?: TablesEntity[] | null;\r\n}\r\nexport interface TablesEntity {\r\n tableID: number;\r\n headerInfo: string;\r\n footerInfo: string;\r\n tableBody?: TableBodyEntity[] | null;\r\n}\r\nexport interface TableBodyEntity {\r\n startRow: number;\r\n endRow: number;\r\n startCol: number;\r\n endCol: number;\r\n cellCoordinate: CellCoordinate;\r\n textInfo: string;\r\n}\r\nexport interface CellCoordinate {\r\n topLeft_x: number;\r\n topLeft_y: number;\r\n topRight_x: number;\r\n topRight_y: number;\r\n bottomLeft_x: number;\r\n bottomLeft_y: number;\r\n bottomRight_x: number;\r\n bottomRight_y: number;\r\n}\r\nexport interface Bitmap {\r\n mGalleryCached: boolean;\r\n mHeight: number;\r\n mNativePtr: number;\r\n mWidth: number;\r\n}\r\nexport enum Colors {\r\n RED = -65536,\r\n DKGRAY = -12303292,\r\n GRAY = -7829368,\r\n WHITE = -1,\r\n BLUE = -16776961,\r\n BLACK = -16777216,\r\n LTGRAY = -3355444,\r\n MAGENTA = -65281,\r\n YELLOW = -256,\r\n CYAN = -16711681,\r\n GREEN = -16711936,\r\n TRANSPARENT = 0,\r\n}\r\nexport enum CordovaErrors {\r\n UNKNOWN = -1,\r\n SUCCESS = 0,\r\n DISCARDED = 1,\r\n INNER = 2,\r\n INACTIVE = 3,\r\n NOT_SUPPORTED = 4,\r\n ILLEGAL_PARAMETER = 5,\r\n OVERDUE = 6,\r\n NO_FOUND = 7,\r\n DUPLICATE_FOUND = 8,\r\n NO_PERMISSION = 9,\r\n INSUFFICIENT_RESOURCE = 10,\r\n ANALYSIS_FAILURE = 11,\r\n INTERRUPTED = 12,\r\n EXCEED_RANGE = 13,\r\n DATA_MISSING = 14,\r\n AUTHENTICATION_REQUIRED = 15,\r\n TFLITE_NOT_COMPATIBLE = 16,\r\n INSUFFICIENT_SPACE = 17,\r\n HASH_MISS = 18,\r\n TOKEN_INVALID = 19,\r\n SERVICE_FAILURE = 20,\r\n ANALYSIS_NULL = 21,\r\n}\r\n\r\n"]} \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/www/util.js b/cordova-plugin-hms-mltext/www/util.js new file mode 100644 index 00000000..7db3e778 --- /dev/null +++ b/cordova-plugin-hms-mltext/www/util.js @@ -0,0 +1,39 @@ +/* + Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.asyncExec = void 0; +const cordova_1 = require("cordova"); +function asyncExec(clazz, func, args = []) { + return new Promise((resolve, reject) => { + (0, cordova_1.exec)(resolve, reject, clazz, func, args); + }); +} +exports.asyncExec = asyncExec; +function initEventHandler() { + if (window.hmsEvents != null) + return; + window.hmsEvents = {}; + window.runHMSEvent = (eventName, data) => { + if (window.hmsEvents.hasOwnProperty(eventName)) + window.hmsEvents[eventName](data); + }; + window.subscribeHMSEvent = (eventName, handler) => { + window.hmsEvents[eventName] = handler; + }; +} +initEventHandler(); +//# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/cordova-plugin-hms-mltext/www/util.js.map b/cordova-plugin-hms-mltext/www/util.js.map new file mode 100644 index 00000000..005f7896 --- /dev/null +++ b/cordova-plugin-hms-mltext/www/util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/www/util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;EAcE;AACF,qCAA+B;AAE/B,SAAgB,SAAS,CACrB,KAAa,EACb,IAAY,EACZ,OAAc,EAAE;IAEhB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,IAAA,cAAI,EAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC;AARD,8BAQC;AAgBD,SAAS,gBAAgB;IACrB,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI;QAAE,OAAO;IACrC,MAAM,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,MAAM,CAAC,WAAW,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE;QACrC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC;YAC1C,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC,CAAC;IACF,MAAM,CAAC,iBAAiB,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;QAC9C,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;IAC1C,CAAC,CAAC;AACN,CAAC;AAED,gBAAgB,EAAE,CAAC","sourcesContent":["/*\r\n Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved.\r\n\r\n Licensed under the Apache License, Version 2.0 (the \"License\")\r\n you may not use this file except in compliance with the License.\r\n You may obtain a copy of the License at\r\n\r\n https://www.apache.org/licenses/LICENSE-2.0\r\n\r\n Unless required by applicable law or agreed to in writing, software\r\n distributed under the License is distributed on an \"AS IS\" BASIS,\r\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n See the License for the specific language governing permissions and\r\n limitations under the License.\r\n*/\r\nimport { exec } from \"cordova\";\r\n\r\nexport function asyncExec(\r\n clazz: string,\r\n func: string,\r\n args: any[] = []\r\n): Promise {\r\n return new Promise((resolve, reject) => {\r\n exec(resolve, reject, clazz, func, args);\r\n });\r\n}\r\n\r\ndeclare global {\r\n interface Window {\r\n hmsEvents: {\r\n [key: string]: (data: any) => void;\r\n };\r\n runHMSEvent: (eventName: string, data: any) => void;\r\n subscribeHMSEvent: (\r\n eventName: string,\r\n callback: (data: any) => void\r\n ) => void;\r\n [key: string]: any;\r\n }\r\n}\r\n\r\nfunction initEventHandler() {\r\n if (window.hmsEvents != null) return;\r\n window.hmsEvents = {};\r\n window.runHMSEvent = (eventName, data) => {\r\n if (window.hmsEvents.hasOwnProperty(eventName))\r\n window.hmsEvents[eventName](data);\r\n };\r\n window.subscribeHMSEvent = (eventName, handler) => {\r\n window.hmsEvents[eventName] = handler;\r\n };\r\n}\r\n\r\ninitEventHandler();\r\n"]} \ No newline at end of file