├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── cla.yml ├── .gitignore ├── CLA.md ├── LICENSE ├── README.md ├── __tests__ ├── add_options_to_url.test.js ├── delete.test.js ├── get_full_url.test.js ├── isBase64.test.js ├── isPathRelative.test.js ├── isUrl.test.js ├── list.test.js └── upload.test.js ├── compreface.d.ts ├── core └── compre_face.js ├── coverage ├── clover.xml ├── coverage-final.json ├── lcov-report │ ├── base.css │ ├── block-navigation.js │ ├── endpoints │ │ ├── common_endpoints.js.html │ │ ├── index.html │ │ └── recognition_endpoints.js.html │ ├── favicon.png │ ├── functions │ │ ├── index.html │ │ └── index.js.html │ ├── index.html │ ├── index.js.html │ ├── prettify.css │ ├── prettify.js │ ├── sort-arrow-sprite.png │ └── sorter.js └── lcov.info ├── endpoints ├── __mocks__ │ └── list.js ├── common_endpoints.js ├── recognition_endpoints.js ├── subject_endpoints.js ├── upload.js └── verification_endpoints.js ├── face_founder_demo ├── .gitignore ├── README.md ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.js │ ├── App.test.js │ ├── assets │ │ └── functions.js │ ├── components │ │ ├── CustomToast.jsx │ │ ├── DisplayCropedImages.jsx │ │ ├── DisplayFoundImages.jsx │ │ ├── ShowBadImages.jsx │ │ └── UploadedImge.jsx │ ├── custom.css │ ├── image │ │ └── exadel.jpg │ ├── index.js │ └── setupTests.js └── yarn.lock ├── functions └── index.js ├── index.js ├── package.json ├── services ├── detection_service.js ├── recognition_service.js └── verification_service.js └── webcam_demo ├── .gitignore ├── README.md ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.css ├── App.js └── index.js /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Code example. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Logs** 20 | If applicable, add logs to help explain your problem. 21 | 22 | **Additional context** 23 | Add any other context about the problem here. 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/cla.yml: -------------------------------------------------------------------------------- 1 | name: "CLA Assistant" 2 | on: 3 | issue_comment: 4 | types: [created] 5 | pull_request_target: 6 | types: [opened,closed,synchronize] 7 | 8 | jobs: 9 | CLAssistant: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: "CLA Assistant" 13 | if: (github.event.comment.body == 'recheckcla' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' 14 | # Alpha Release 15 | uses: cla-assistant/github-action@v2.0.1-alpha 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 18 | PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} 19 | with: 20 | path-to-signatures: 'signatures/cla.json' 21 | path-to-cla-document: 'https://github.com/exadel-inc/compreface-javascript-sdk/blob/develop/CLA.md' 22 | branch: 'CLA-signatures' 23 | allowlist: bot* 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | package-lock.json 3 | .idea/ 4 | *.iml -------------------------------------------------------------------------------- /CLA.md: -------------------------------------------------------------------------------- 1 | # Contributor License Agreement 2 | 3 | Thank you for your interest in contributing to the **CompreFace** (“Material”) by Exadel, Inc. ("We" or "Us"). The present Contributor License Agreement (“CLA”) is for your protection as a Contributor as well as the protection of Us; it does not change your rights to use your own Contributions for any other purpose. 4 | 5 | You must agree to the terms of this CLA before making a Contribution to the Material. This CLA covers any and all Contributions that You, now or in the future, submit to the Material. This CLA shall come into effect upon Your acceptance of its terms and conditions. 6 | 7 | ## 1. Definitions 8 | a. "You" means the individual Сopyright owner who Submits a Contribution to Us. 9 | 10 | b. "Contribution" means source code and any other copyrightable materials Submitted by you to Us, including any associated comments and documentation. 11 | 12 | c. "Copyright" means all rights protecting works of authorship, including copyright, moral and neighboring rights, as appropriate, for the full term of their existence. 13 | 14 | d. "Material" means the software or documentation made available by Us to third parties. After You Submit the Contribution, it may be included in the Material. 15 | 16 | e. "Submit" means any act by which a Contribution is transferred to Us by You by means of tangible or intangible media, including but not limited to electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Us, but excluding any transfer that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution." 17 | 18 | ## 2. Grant of Copyright License 19 | 20 | Subject to the terms and conditions of this CLA, You hereby grant to Us and to recipients of Material distributed by Us 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 Your Contributions and such derivative works. 21 | 22 | ## 3. Grant of Patent License 23 | 24 | Subject to the terms and conditions of this CLA, You hereby grant to Us and to recipients of Material distributed by Us 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 Material, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by a combination of Your Contribution(s) with the Material to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Material to which you have contributed, constitutes a direct or contributory patent infringement, then any patent licenses granted to that entity under this CLA for that Contribution or Material shall terminate as of the date such litigation is filed. 25 | 26 | ## 4. Other rights reserved 27 | 28 | Each party reserves all rights not expressly granted in this CLA. No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are granted by implication, exhaustion, estoppel or otherwise. 29 | 30 | ## 5. Originality of Contributions 31 | 32 | You represent that you are legally entitled to grant the above licenses. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer or that your employer has waived such rights for your Contributions to Us. You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions. 33 | 34 | ## 6. Notice to Us 35 | 36 | You agree to notify Us of any facts or circumstances of which you become aware that would make the representations in this CLA inaccurate in any respect. 37 | 38 | ## 7. Disclaimer 39 | 40 | You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on "as is" basis. More particularly, all express or implied warranties including, without limitation, any implied warranty of satisfactory quality, fitness for a particular purpose, and non-infringement are expressly disclaimed by You to Us and by Us to You. To the extent that any such warranties cannot be disclaimed, such warranty is limited in duration and extent to the minimum period and extent permitted by applicable law. 41 | 42 | ## 8. Consequential Damage Waiver 43 | 44 | To the maximum extent permitted by applicable law, in no event will You or We be liable for any loss of profits, loss of anticipated savings, loss of data, indirect, special, incidental, consequential and exemplary damages arising out of this CLA regardless of the legal or equitable theory (contract, tort or otherwise) upon which the claim is based. 45 | 46 | 47 | ## 9. Information About Submissions 48 | 49 | You agree that this Material and Contributions to it are public and that a record of the Contribution (including all personal information you submit with it) is maintained indefinitely and may be redistributed consistent with this Material, compliance with the open source license(s) involved, and maintenance of authorship attribution. 50 | 51 | ## 11. Miscellaneous 52 | 53 | This CLA is the entire agreement between the parties and supersedes any and all prior agreements, understandings or communications, written or oral, between the parties relating to the subject matter hereof. You acknowledge that We are not obligated to use your Contribution as part of the Material distributed by Us and may make the decision to include any Contribution as We believe is appropriate. 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /__tests__/add_options_to_url.test.js: -------------------------------------------------------------------------------- 1 | import { common_functions } from '../functions/index.js'; 2 | 3 | test("Check passed options to services", () => { 4 | let url = 'http://localhost:8000/api/v1/detection/detect', 5 | global_options = { 6 | limit: 1 7 | }, 8 | local_options = { 9 | limit: 0, 10 | det_prob_threshold: 0.5, 11 | prediction_count: 1, 12 | face_plugins: 'age,gender', 13 | status: true 14 | }, 15 | required_url_parameters = { 16 | limit: true, 17 | det_prob_threshold: true, 18 | prediction_count: true, 19 | face_plugins: true, 20 | status: true 21 | }; 22 | let result = 'http://localhost:8000/api/v1/detection/detect?limit=1&det_prob_threshold=0.5&prediction_count=1&face_plugins=age,gender&status=true'; 23 | expect(common_functions.add_options_to_url(url, global_options, local_options, required_url_parameters)).toEqual(result); 24 | }) -------------------------------------------------------------------------------- /__tests__/delete.test.js: -------------------------------------------------------------------------------- 1 | import { recognition_endpoints } from '../endpoints/recognition_endpoints.js'; 2 | import { jest } from '@jest/globals'; 3 | 4 | jest.doMock('../endpoints/recognition_endpoints.js') 5 | 6 | const expected_res = {"image_id": "1d00114b-c1c1-4535-b881-ff5c53366e94", "subject": "Cute girl"}; 7 | 8 | it("Check delete endpoint", async () => { 9 | const result = await recognition_endpoints.delete_request("http://localhost:8000/api/v1/recognition/faces/1d00114b-c1c1-4535-b881-ff5c53366e94", '63a1f5cf-da50-4316-a1ce-50c13cac121b') 10 | expect(result.data.faces).toEqual(expected_res) 11 | expect.assertions(1); 12 | }) -------------------------------------------------------------------------------- /__tests__/get_full_url.test.js: -------------------------------------------------------------------------------- 1 | import { common_functions } from '../functions/index.js'; 2 | 3 | test("Construct full url from base url, server and port number", () => { 4 | let base_url = 'api/v1/detection/detect', 5 | server = 'http://localhost', 6 | port = 8000; 7 | let result = 'http://localhost:8000/api/v1/detection/detect'; 8 | 9 | expect(common_functions.get_full_url(base_url, server, port)).toEqual(result); 10 | }) -------------------------------------------------------------------------------- /__tests__/isBase64.test.js: -------------------------------------------------------------------------------- 1 | import { common_functions } from '../functions/index.js'; 2 | 3 | test("Check passed value is base64 or not", () => { 4 | let base64 = 'cGFzc3dvcmQ='; 5 | let result = true; 6 | 7 | expect(common_functions.isBase64(base64)).toEqual(result); 8 | }) -------------------------------------------------------------------------------- /__tests__/isPathRelative.test.js: -------------------------------------------------------------------------------- 1 | import { common_functions } from '../functions/index.js'; 2 | 3 | test("Check the path of image", () => { 4 | let path = '../img/girl.png'; 5 | 6 | expect(common_functions.isPathRelative(path)).toEqual(true); 7 | }) -------------------------------------------------------------------------------- /__tests__/isUrl.test.js: -------------------------------------------------------------------------------- 1 | import { common_functions } from '../functions/index.js'; 2 | 3 | test("Check passed value is url or not", () => { 4 | let url = "https://gmail.com"; 5 | let result = true; 6 | 7 | expect(common_functions.isUrl(url)).toEqual(result); 8 | }) -------------------------------------------------------------------------------- /__tests__/list.test.js: -------------------------------------------------------------------------------- 1 | import { recognition_endpoints } from '../endpoints/recognition_endpoints.js'; 2 | import { jest } from '@jest/globals'; 3 | 4 | jest.doMock('../endpoints/recognition_endpoints.js') 5 | 6 | const expected_res = [{"image_id": "d71b4c82-f02e-4d85-83d4-f2b9dae74640", "subject": "Cute girl"}, {"image_id": "1d00114b-c1c1-4535-b881-ff5c53366e94", "subject": "Cute girl"}]; 7 | 8 | it("Check list of images in face collection", async () => { 9 | const result = await recognition_endpoints.list_request("http://localhost:8000/api/v1/recognition/faces", '63a1f5cf-da50-4316-a1ce-50c13cac121b') 10 | expect(result.data.faces).toEqual(expected_res) 11 | expect.assertions(1); 12 | }) -------------------------------------------------------------------------------- /__tests__/upload.test.js: -------------------------------------------------------------------------------- 1 | import { common_endpoints } from '../endpoints/common_endpoints'; 2 | import { jest } from '@jest/globals'; 3 | 4 | jest.doMock('../endpoints/common_endpoints.js') 5 | 6 | it("Check upload function", () => { 7 | let url = "http://localhost:8000/api/v1/recognition/faces?subject=test"; 8 | let api_key = '63a1f5cf-da50-4316-a1ce-50c13cac121b'; 9 | let image_url = "https://media.gettyimages.com/photos/woman-standing-on-city-street-looking-at-camera-picture-id1292452761?s=2048x2048"; 10 | 11 | common_endpoints.upload_url(image_url, url, api_key) 12 | .then(result => { 13 | expect(result.data).toEqual(undefined) 14 | expect.assertions(1); 15 | }) 16 | .catch(error => console.log(error)) 17 | 18 | }) -------------------------------------------------------------------------------- /compreface.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | declare interface Options { 18 | limit: number, 19 | prediction_count?: number, 20 | face_plugins?: string, 21 | det_prob_threshold?: number, 22 | status?: boolean 23 | } 24 | declare interface FaceCollectionAddOptions { 25 | det_prob_threshold: string 26 | } 27 | 28 | declare interface ServiceOptions{ 29 | limit: number, 30 | face_plugins?: string, 31 | det_prob_threshold?: number, 32 | status?: boolean 33 | } 34 | 35 | declare interface Detection { 36 | detect(image_path: string, localOptions?: ServiceOptions): Promise; 37 | } 38 | 39 | declare interface Verification { 40 | verify(source_image_path: string, target_image_path: string, options: ServiceOptions): Promise 41 | } 42 | 43 | declare interface Recognition { 44 | recognize(image_path: string, options: Options): Promise; 45 | getFaceCollection(): FaceCollectionFunctions; 46 | subjectFunctions(): SubjectFunctions; 47 | } 48 | 49 | declare interface FaceCollectionFunctions { 50 | /** 51 | * View the list of images in face collection 52 | * @returns {Promise} 53 | */ 54 | list(): Promise, 55 | 56 | /** 57 | * Add image (with subject) to face collection 58 | * @param {String} image_path 59 | * @param {String} subject 60 | * @returns {Promise} 61 | */ 62 | add(image_path: string, subject: string, options?: FaceCollectionAddOptions): Promise; 63 | 64 | /** 65 | * Verify face from image 66 | * @param {String} image_path 67 | * @param {String} image_id 68 | * @returns {Promise} 69 | */ 70 | verify(image_path: string, image_id: string, options?: Options): Promise, 71 | 72 | /** 73 | * Delete image by id 74 | * @param {String} image_id 75 | * @returns {Promise} 76 | */ 77 | delete(image_id: string): Promise, 78 | 79 | /** 80 | * Delete multiple images 81 | * @param {String[]} image_ids 82 | * @returns {Promise} 83 | */ 84 | delete_multiple_images(image_ids: string[]): Promise, 85 | /** 86 | * Delete image by subject 87 | * @param {String} subject 88 | * @returns {Promise} 89 | */ 90 | delete_all_subject(subject: string): Promise, 91 | 92 | /** 93 | * Delete all images in face collection 94 | * @returns {Promise} 95 | */ 96 | delete_all(): Promise, 97 | } 98 | 99 | declare interface SubjectFunctions { 100 | 101 | /** 102 | * List the subjects 103 | * @returns {Promise} 104 | */ 105 | list(): Promise, 106 | 107 | /** 108 | * Add subject 109 | * @param {String} subject 110 | * @returns {Promise} 111 | */ 112 | add(subject: string): Promise, 113 | 114 | /** 115 | * Rename the subject 116 | * @param {String} presentSubjectName 117 | * @param {String} newSubjectName 118 | * @returns {Promise} 119 | */ 120 | rename(presentSubjectName: string, newSubjectName: string): Promise, 121 | 122 | /** 123 | * Delete a subject 124 | * @param {String} subject 125 | * @returns {Promise} 126 | */ 127 | delete(subject: string): Promise, 128 | 129 | /** 130 | * Delete all subject 131 | * @param {String} subject 132 | * @returns {Promise} 133 | */ 134 | deleteAll(): Promise; 135 | } 136 | 137 | export declare class CompreFace { 138 | constructor(server: string, port: number, options?: Options); 139 | 140 | /** 141 | * Initialize RecognitionService instance 142 | * @param {String} api_key 143 | * @returns {Object} 144 | */ 145 | initFaceRecognitionService(api_key: string): Recognition; 146 | 147 | /** 148 | * Initialize VerificationService instance 149 | * @param {String} api_key 150 | * @returns {Object} 151 | */ 152 | initFaceVerificationService(api_key: string): Verification; 153 | 154 | /** 155 | * Initialize DetectionService instance 156 | * @param {String} api_key 157 | * @returns {Object} 158 | */ 159 | initFaceDetectionService(api_key: string): Detection; 160 | } 161 | 162 | -------------------------------------------------------------------------------- /core/compre_face.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | import { RecognitionService } from '../services/recognition_service.js'; 17 | import { VerificationService } from '../services/verification_service.js'; 18 | import { DetectionService } from '../services/detection_service.js'; 19 | // main class 20 | class CompreFace { 21 | constructor(server, port, options){ 22 | this.server = server; 23 | this.port = port; 24 | this.options = options; 25 | } 26 | /** 27 | * Initialize RecognitionService instance 28 | * @param {String} api_key 29 | * @returns {Object} 30 | */ 31 | initFaceRecognitionService(api_key){ 32 | let recognition_object = new RecognitionService(this.server, this.port, this.options, api_key) 33 | return recognition_object; 34 | } 35 | 36 | /** 37 | * Initialize VerificationService instance 38 | * @param {String} api_key 39 | * @returns {Object} 40 | */ 41 | initFaceVerificationService(api_key){ 42 | let verification_object = new VerificationService(this.server, this.port, this.options, api_key) 43 | return verification_object; 44 | } 45 | 46 | /** 47 | * Initialize DetectionService instance 48 | * @param {String} api_key 49 | * @returns {Object} 50 | */ 51 | initFaceDetectionService(api_key){ 52 | let detection_object = new DetectionService(this.server, this.port, this.options, api_key) 53 | return detection_object; 54 | } 55 | } 56 | 57 | export { CompreFace }; -------------------------------------------------------------------------------- /coverage/clover.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /coverage/coverage-final.json: -------------------------------------------------------------------------------- 1 | {"D:\\Exadel\\Compare Face\\compreface-javascript-sdk\\endpoints\\common_endpoints.js": {"path":"D:\\Exadel\\Compare Face\\compreface-javascript-sdk\\endpoints\\common_endpoints.js","statementMap":{"0":{"start":{"line":21,"column":25},"end":{"line":105,"column":1}},"1":{"start":{"line":23,"column":27},"end":{"line":23,"column":41}},"2":{"start":{"line":24,"column":8},"end":{"line":24,"column":61}},"3":{"start":{"line":26,"column":8},"end":{"line":39,"column":10}},"4":{"start":{"line":27,"column":12},"end":{"line":38,"column":13}},"5":{"start":{"line":28,"column":33},"end":{"line":33,"column":18}},"6":{"start":{"line":35,"column":16},"end":{"line":35,"column":33}},"7":{"start":{"line":37,"column":16},"end":{"line":37,"column":29}},"8":{"start":{"line":50,"column":27},"end":{"line":50,"column":41}},"9":{"start":{"line":51,"column":8},"end":{"line":51,"column":116}},"10":{"start":{"line":53,"column":8},"end":{"line":67,"column":10}},"11":{"start":{"line":54,"column":12},"end":{"line":66,"column":13}},"12":{"start":{"line":55,"column":33},"end":{"line":61,"column":18}},"13":{"start":{"line":63,"column":16},"end":{"line":63,"column":33}},"14":{"start":{"line":65,"column":16},"end":{"line":65,"column":29}},"15":{"start":{"line":78,"column":27},"end":{"line":78,"column":41}},"16":{"start":{"line":80,"column":8},"end":{"line":101,"column":10}},"17":{"start":{"line":81,"column":12},"end":{"line":100,"column":18}},"18":{"start":{"line":83,"column":42},"end":{"line":83,"column":88}},"19":{"start":{"line":84,"column":20},"end":{"line":84,"column":93}},"20":{"start":{"line":85,"column":20},"end":{"line":96,"column":21}},"21":{"start":{"line":86,"column":36},"end":{"line":91,"column":26}},"22":{"start":{"line":93,"column":24},"end":{"line":93,"column":36}},"23":{"start":{"line":95,"column":24},"end":{"line":95,"column":37}},"24":{"start":{"line":99,"column":20},"end":{"line":99,"column":33}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":22,"column":4},"end":{"line":22,"column":5}},"loc":{"start":{"line":22,"column":45},"end":{"line":40,"column":5}},"line":22},"1":{"name":"(anonymous_1)","decl":{"start":{"line":26,"column":28},"end":{"line":26,"column":29}},"loc":{"start":{"line":26,"column":55},"end":{"line":39,"column":9}},"line":26},"2":{"name":"(anonymous_2)","decl":{"start":{"line":49,"column":5},"end":{"line":49,"column":6}},"loc":{"start":{"line":49,"column":49},"end":{"line":68,"column":5}},"line":49},"3":{"name":"(anonymous_3)","decl":{"start":{"line":53,"column":28},"end":{"line":53,"column":29}},"loc":{"start":{"line":53,"column":55},"end":{"line":67,"column":9}},"line":53},"4":{"name":"(anonymous_4)","decl":{"start":{"line":77,"column":4},"end":{"line":77,"column":5}},"loc":{"start":{"line":77,"column":45},"end":{"line":102,"column":5}},"line":77},"5":{"name":"(anonymous_5)","decl":{"start":{"line":80,"column":28},"end":{"line":80,"column":29}},"loc":{"start":{"line":80,"column":55},"end":{"line":101,"column":9}},"line":80},"6":{"name":"(anonymous_6)","decl":{"start":{"line":82,"column":23},"end":{"line":82,"column":24}},"loc":{"start":{"line":82,"column":43},"end":{"line":97,"column":17}},"line":82},"7":{"name":"(anonymous_7)","decl":{"start":{"line":98,"column":23},"end":{"line":98,"column":24}},"loc":{"start":{"line":98,"column":32},"end":{"line":100,"column":17}},"line":98}},"branchMap":{},"s":{"0":1,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":1,"16":1,"17":1,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0},"f":{"0":0,"1":0,"2":0,"3":0,"4":1,"5":1,"6":0,"7":0},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"719deb586771f188c1a142244ccbabff11d73c50"} 2 | ,"D:\\Exadel\\Compare Face\\compreface-javascript-sdk\\endpoints\\recognition_endpoints.js": {"path":"D:\\Exadel\\Compare Face\\compreface-javascript-sdk\\endpoints\\recognition_endpoints.js","statementMap":{"0":{"start":{"line":18,"column":30},"end":{"line":62,"column":1}},"1":{"start":{"line":26,"column":8},"end":{"line":38,"column":10}},"2":{"start":{"line":27,"column":12},"end":{"line":37,"column":13}},"3":{"start":{"line":28,"column":33},"end":{"line":32,"column":18}},"4":{"start":{"line":34,"column":16},"end":{"line":34,"column":33}},"5":{"start":{"line":36,"column":16},"end":{"line":36,"column":29}},"6":{"start":{"line":48,"column":8},"end":{"line":60,"column":10}},"7":{"start":{"line":49,"column":12},"end":{"line":59,"column":13}},"8":{"start":{"line":50,"column":33},"end":{"line":54,"column":18}},"9":{"start":{"line":56,"column":16},"end":{"line":56,"column":33}},"10":{"start":{"line":58,"column":16},"end":{"line":58,"column":29}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":25,"column":4},"end":{"line":25,"column":5}},"loc":{"start":{"line":25,"column":36},"end":{"line":39,"column":5}},"line":25},"1":{"name":"(anonymous_1)","decl":{"start":{"line":26,"column":28},"end":{"line":26,"column":29}},"loc":{"start":{"line":26,"column":55},"end":{"line":38,"column":9}},"line":26},"2":{"name":"(anonymous_2)","decl":{"start":{"line":47,"column":4},"end":{"line":47,"column":5}},"loc":{"start":{"line":47,"column":38},"end":{"line":61,"column":5}},"line":47},"3":{"name":"(anonymous_3)","decl":{"start":{"line":48,"column":28},"end":{"line":48,"column":29}},"loc":{"start":{"line":48,"column":55},"end":{"line":60,"column":9}},"line":48}},"branchMap":{},"s":{"0":2,"1":1,"2":1,"3":1,"4":1,"5":0,"6":1,"7":1,"8":1,"9":1,"10":0},"f":{"0":1,"1":1,"2":1,"3":1},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"ddf74093fffad257a8fe6ece0e9fa3abbad510ad"} 3 | ,"D:\\Exadel\\Compare Face\\compreface-javascript-sdk\\functions\\index.js": {"path":"D:\\Exadel\\Compare Face\\compreface-javascript-sdk\\functions\\index.js","statementMap":{"0":{"start":{"line":18,"column":25},"end":{"line":94,"column":1}},"1":{"start":{"line":24,"column":8},"end":{"line":24,"column":47}},"2":{"start":{"line":34,"column":23},"end":{"line":34,"column":103}},"3":{"start":{"line":35,"column":20},"end":{"line":35,"column":44}},"4":{"start":{"line":37,"column":8},"end":{"line":37,"column":21}},"5":{"start":{"line":46,"column":8},"end":{"line":46,"column":49}},"6":{"start":{"line":46,"column":37},"end":{"line":46,"column":49}},"7":{"start":{"line":47,"column":25},"end":{"line":47,"column":57}},"8":{"start":{"line":48,"column":8},"end":{"line":48,"column":27}},"9":{"start":{"line":61,"column":28},"end":{"line":61,"column":63}},"10":{"start":{"line":62,"column":32},"end":{"line":62,"column":58}},"11":{"start":{"line":65,"column":8},"end":{"line":90,"column":9}},"12":{"start":{"line":67,"column":12},"end":{"line":69,"column":13}},"13":{"start":{"line":68,"column":16},"end":{"line":68,"column":62}},"14":{"start":{"line":72,"column":12},"end":{"line":74,"column":13}},"15":{"start":{"line":73,"column":16},"end":{"line":73,"column":88}},"16":{"start":{"line":77,"column":12},"end":{"line":79,"column":13}},"17":{"start":{"line":78,"column":16},"end":{"line":78,"column":84}},"18":{"start":{"line":82,"column":12},"end":{"line":84,"column":13}},"19":{"start":{"line":83,"column":16},"end":{"line":83,"column":76}},"20":{"start":{"line":87,"column":12},"end":{"line":89,"column":13}},"21":{"start":{"line":88,"column":16},"end":{"line":88,"column":64}},"22":{"start":{"line":92,"column":8},"end":{"line":92,"column":19}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":23,"column":4},"end":{"line":23,"column":5}},"loc":{"start":{"line":23,"column":41},"end":{"line":25,"column":5}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":32,"column":4},"end":{"line":32,"column":5}},"loc":{"start":{"line":32,"column":20},"end":{"line":38,"column":5}},"line":32},"2":{"name":"(anonymous_2)","decl":{"start":{"line":45,"column":4},"end":{"line":45,"column":5}},"loc":{"start":{"line":45,"column":25},"end":{"line":49,"column":5}},"line":45},"3":{"name":"(anonymous_3)","decl":{"start":{"line":59,"column":4},"end":{"line":59,"column":5}},"loc":{"start":{"line":59,"column":77},"end":{"line":93,"column":5}},"line":59}},"branchMap":{"0":{"loc":{"start":{"line":46,"column":8},"end":{"line":46,"column":49}},"type":"if","locations":[{"start":{"line":46,"column":8},"end":{"line":46,"column":49}},{"start":{"line":46,"column":8},"end":{"line":46,"column":49}}],"line":46},"1":{"loc":{"start":{"line":65,"column":8},"end":{"line":90,"column":9}},"type":"if","locations":[{"start":{"line":65,"column":8},"end":{"line":90,"column":9}},{"start":{"line":65,"column":8},"end":{"line":90,"column":9}}],"line":65},"2":{"loc":{"start":{"line":67,"column":12},"end":{"line":69,"column":13}},"type":"if","locations":[{"start":{"line":67,"column":12},"end":{"line":69,"column":13}},{"start":{"line":67,"column":12},"end":{"line":69,"column":13}}],"line":67},"3":{"loc":{"start":{"line":67,"column":15},"end":{"line":67,"column":74}},"type":"binary-expr","locations":[{"start":{"line":67,"column":15},"end":{"line":67,"column":42}},{"start":{"line":67,"column":46},"end":{"line":67,"column":74}}],"line":67},"4":{"loc":{"start":{"line":72,"column":12},"end":{"line":74,"column":13}},"type":"if","locations":[{"start":{"line":72,"column":12},"end":{"line":74,"column":13}},{"start":{"line":72,"column":12},"end":{"line":74,"column":13}}],"line":72},"5":{"loc":{"start":{"line":72,"column":15},"end":{"line":72,"column":100}},"type":"binary-expr","locations":[{"start":{"line":72,"column":15},"end":{"line":72,"column":55}},{"start":{"line":72,"column":59},"end":{"line":72,"column":100}}],"line":72},"6":{"loc":{"start":{"line":77,"column":12},"end":{"line":79,"column":13}},"type":"if","locations":[{"start":{"line":77,"column":12},"end":{"line":79,"column":13}},{"start":{"line":77,"column":12},"end":{"line":79,"column":13}}],"line":77},"7":{"loc":{"start":{"line":77,"column":15},"end":{"line":77,"column":96}},"type":"binary-expr","locations":[{"start":{"line":77,"column":15},"end":{"line":77,"column":53}},{"start":{"line":77,"column":57},"end":{"line":77,"column":96}}],"line":77},"8":{"loc":{"start":{"line":82,"column":12},"end":{"line":84,"column":13}},"type":"if","locations":[{"start":{"line":82,"column":12},"end":{"line":84,"column":13}},{"start":{"line":82,"column":12},"end":{"line":84,"column":13}}],"line":82},"9":{"loc":{"start":{"line":82,"column":15},"end":{"line":82,"column":83}},"type":"binary-expr","locations":[{"start":{"line":82,"column":15},"end":{"line":82,"column":44}},{"start":{"line":82,"column":48},"end":{"line":82,"column":83}}],"line":82},"10":{"loc":{"start":{"line":87,"column":12},"end":{"line":89,"column":13}},"type":"if","locations":[{"start":{"line":87,"column":12},"end":{"line":89,"column":13}},{"start":{"line":87,"column":12},"end":{"line":89,"column":13}}],"line":87},"11":{"loc":{"start":{"line":87,"column":15},"end":{"line":87,"column":71}},"type":"binary-expr","locations":[{"start":{"line":87,"column":15},"end":{"line":87,"column":38}},{"start":{"line":87,"column":42},"end":{"line":87,"column":71}}],"line":87}},"s":{"0":4,"1":1,"2":1,"3":1,"4":1,"5":1,"6":0,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1},"f":{"0":1,"1":1,"2":1,"3":1},"b":{"0":[0,1],"1":[1,0],"2":[1,0],"3":[1,1],"4":[1,0],"5":[1,1],"6":[1,0],"7":[1,1],"8":[1,0],"9":[1,1],"10":[1,0],"11":[1,1]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"d3d8737f4b9aca2b0eb63559383e2ba7510b1605"} 4 | } 5 | -------------------------------------------------------------------------------- /coverage/lcov-report/base.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin:0; padding: 0; 3 | height: 100%; 4 | } 5 | body { 6 | font-family: Helvetica Neue, Helvetica, Arial; 7 | font-size: 14px; 8 | color:#333; 9 | } 10 | .small { font-size: 12px; } 11 | *, *:after, *:before { 12 | -webkit-box-sizing:border-box; 13 | -moz-box-sizing:border-box; 14 | box-sizing:border-box; 15 | } 16 | h1 { font-size: 20px; margin: 0;} 17 | h2 { font-size: 14px; } 18 | pre { 19 | font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; 20 | margin: 0; 21 | padding: 0; 22 | -moz-tab-size: 2; 23 | -o-tab-size: 2; 24 | tab-size: 2; 25 | } 26 | a { color:#0074D9; text-decoration:none; } 27 | a:hover { text-decoration:underline; } 28 | .strong { font-weight: bold; } 29 | .space-top1 { padding: 10px 0 0 0; } 30 | .pad2y { padding: 20px 0; } 31 | .pad1y { padding: 10px 0; } 32 | .pad2x { padding: 0 20px; } 33 | .pad2 { padding: 20px; } 34 | .pad1 { padding: 10px; } 35 | .space-left2 { padding-left:55px; } 36 | .space-right2 { padding-right:20px; } 37 | .center { text-align:center; } 38 | .clearfix { display:block; } 39 | .clearfix:after { 40 | content:''; 41 | display:block; 42 | height:0; 43 | clear:both; 44 | visibility:hidden; 45 | } 46 | .fl { float: left; } 47 | @media only screen and (max-width:640px) { 48 | .col3 { width:100%; max-width:100%; } 49 | .hide-mobile { display:none!important; } 50 | } 51 | 52 | .quiet { 53 | color: #7f7f7f; 54 | color: rgba(0,0,0,0.5); 55 | } 56 | .quiet a { opacity: 0.7; } 57 | 58 | .fraction { 59 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 60 | font-size: 10px; 61 | color: #555; 62 | background: #E8E8E8; 63 | padding: 4px 5px; 64 | border-radius: 3px; 65 | vertical-align: middle; 66 | } 67 | 68 | div.path a:link, div.path a:visited { color: #333; } 69 | table.coverage { 70 | border-collapse: collapse; 71 | margin: 10px 0 0 0; 72 | padding: 0; 73 | } 74 | 75 | table.coverage td { 76 | margin: 0; 77 | padding: 0; 78 | vertical-align: top; 79 | } 80 | table.coverage td.line-count { 81 | text-align: right; 82 | padding: 0 5px 0 20px; 83 | } 84 | table.coverage td.line-coverage { 85 | text-align: right; 86 | padding-right: 10px; 87 | min-width:20px; 88 | } 89 | 90 | table.coverage td span.cline-any { 91 | display: inline-block; 92 | padding: 0 5px; 93 | width: 100%; 94 | } 95 | .missing-if-branch { 96 | display: inline-block; 97 | margin-right: 5px; 98 | border-radius: 3px; 99 | position: relative; 100 | padding: 0 4px; 101 | background: #333; 102 | color: yellow; 103 | } 104 | 105 | .skip-if-branch { 106 | display: none; 107 | margin-right: 10px; 108 | position: relative; 109 | padding: 0 4px; 110 | background: #ccc; 111 | color: white; 112 | } 113 | .missing-if-branch .typ, .skip-if-branch .typ { 114 | color: inherit !important; 115 | } 116 | .coverage-summary { 117 | border-collapse: collapse; 118 | width: 100%; 119 | } 120 | .coverage-summary tr { border-bottom: 1px solid #bbb; } 121 | .keyline-all { border: 1px solid #ddd; } 122 | .coverage-summary td, .coverage-summary th { padding: 10px; } 123 | .coverage-summary tbody { border: 1px solid #bbb; } 124 | .coverage-summary td { border-right: 1px solid #bbb; } 125 | .coverage-summary td:last-child { border-right: none; } 126 | .coverage-summary th { 127 | text-align: left; 128 | font-weight: normal; 129 | white-space: nowrap; 130 | } 131 | .coverage-summary th.file { border-right: none !important; } 132 | .coverage-summary th.pct { } 133 | .coverage-summary th.pic, 134 | .coverage-summary th.abs, 135 | .coverage-summary td.pct, 136 | .coverage-summary td.abs { text-align: right; } 137 | .coverage-summary td.file { white-space: nowrap; } 138 | .coverage-summary td.pic { min-width: 120px !important; } 139 | .coverage-summary tfoot td { } 140 | 141 | .coverage-summary .sorter { 142 | height: 10px; 143 | width: 7px; 144 | display: inline-block; 145 | margin-left: 0.5em; 146 | background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; 147 | } 148 | .coverage-summary .sorted .sorter { 149 | background-position: 0 -20px; 150 | } 151 | .coverage-summary .sorted-desc .sorter { 152 | background-position: 0 -10px; 153 | } 154 | .status-line { height: 10px; } 155 | /* yellow */ 156 | .cbranch-no { background: yellow !important; color: #111; } 157 | /* dark red */ 158 | .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } 159 | .low .chart { border:1px solid #C21F39 } 160 | .highlighted, 161 | .highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ 162 | background: #C21F39 !important; 163 | } 164 | /* medium red */ 165 | .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } 166 | /* light red */ 167 | .low, .cline-no { background:#FCE1E5 } 168 | /* light green */ 169 | .high, .cline-yes { background:rgb(230,245,208) } 170 | /* medium green */ 171 | .cstat-yes { background:rgb(161,215,106) } 172 | /* dark green */ 173 | .status-line.high, .high .cover-fill { background:rgb(77,146,33) } 174 | .high .chart { border:1px solid rgb(77,146,33) } 175 | /* dark yellow (gold) */ 176 | .status-line.medium, .medium .cover-fill { background: #f9cd0b; } 177 | .medium .chart { border:1px solid #f9cd0b; } 178 | /* light yellow */ 179 | .medium { background: #fff4c2; } 180 | 181 | .cstat-skip { background: #ddd; color: #111; } 182 | .fstat-skip { background: #ddd; color: #111 !important; } 183 | .cbranch-skip { background: #ddd !important; color: #111; } 184 | 185 | span.cline-neutral { background: #eaeaea; } 186 | 187 | .coverage-summary td.empty { 188 | opacity: .5; 189 | padding-top: 4px; 190 | padding-bottom: 4px; 191 | line-height: 1; 192 | color: #888; 193 | } 194 | 195 | .cover-fill, .cover-empty { 196 | display:inline-block; 197 | height: 12px; 198 | } 199 | .chart { 200 | line-height: 0; 201 | } 202 | .cover-empty { 203 | background: white; 204 | } 205 | .cover-full { 206 | border-right: none !important; 207 | } 208 | pre.prettyprint { 209 | border: none !important; 210 | padding: 0 !important; 211 | margin: 0 !important; 212 | } 213 | .com { color: #999 !important; } 214 | .ignore-none { color: #999; font-weight: normal; } 215 | 216 | .wrapper { 217 | min-height: 100%; 218 | height: auto !important; 219 | height: 100%; 220 | margin: 0 auto -48px; 221 | } 222 | .footer, .push { 223 | height: 48px; 224 | } 225 | -------------------------------------------------------------------------------- /coverage/lcov-report/block-navigation.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | var jumpToCode = (function init() { 3 | // Classes of code we would like to highlight in the file view 4 | var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; 5 | 6 | // Elements to highlight in the file listing view 7 | var fileListingElements = ['td.pct.low']; 8 | 9 | // We don't want to select elements that are direct descendants of another match 10 | var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` 11 | 12 | // Selecter that finds elements on the page to which we can jump 13 | var selector = 14 | fileListingElements.join(', ') + 15 | ', ' + 16 | notSelector + 17 | missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` 18 | 19 | // The NodeList of matching elements 20 | var missingCoverageElements = document.querySelectorAll(selector); 21 | 22 | var currentIndex; 23 | 24 | function toggleClass(index) { 25 | missingCoverageElements 26 | .item(currentIndex) 27 | .classList.remove('highlighted'); 28 | missingCoverageElements.item(index).classList.add('highlighted'); 29 | } 30 | 31 | function makeCurrent(index) { 32 | toggleClass(index); 33 | currentIndex = index; 34 | missingCoverageElements.item(index).scrollIntoView({ 35 | behavior: 'smooth', 36 | block: 'center', 37 | inline: 'center' 38 | }); 39 | } 40 | 41 | function goToPrevious() { 42 | var nextIndex = 0; 43 | if (typeof currentIndex !== 'number' || currentIndex === 0) { 44 | nextIndex = missingCoverageElements.length - 1; 45 | } else if (missingCoverageElements.length > 1) { 46 | nextIndex = currentIndex - 1; 47 | } 48 | 49 | makeCurrent(nextIndex); 50 | } 51 | 52 | function goToNext() { 53 | var nextIndex = 0; 54 | 55 | if ( 56 | typeof currentIndex === 'number' && 57 | currentIndex < missingCoverageElements.length - 1 58 | ) { 59 | nextIndex = currentIndex + 1; 60 | } 61 | 62 | makeCurrent(nextIndex); 63 | } 64 | 65 | return function jump(event) { 66 | switch (event.which) { 67 | case 78: // n 68 | case 74: // j 69 | goToNext(); 70 | break; 71 | case 66: // b 72 | case 75: // k 73 | case 80: // p 74 | goToPrevious(); 75 | break; 76 | } 77 | }; 78 | })(); 79 | window.addEventListener('keydown', jumpToCode); 80 | -------------------------------------------------------------------------------- /coverage/lcov-report/endpoints/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Code coverage report for endpoints 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 20 |
21 |
22 |

All files endpoints

23 |
24 | 25 |
26 | 36.11% 27 | Statements 28 | 13/36 29 |
30 | 31 | 32 |
33 | 100% 34 | Branches 35 | 0/0 36 |
37 | 38 | 39 |
40 | 50% 41 | Functions 42 | 6/12 43 |
44 | 45 | 46 |
47 | 36.11% 48 | Lines 49 | 13/36 50 |
51 | 52 | 53 |
54 |

55 | Press n or j to go to the next uncovered block, b, p or k for the previous block. 56 |

57 |
58 |
59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 |
FileStatementsBranchesFunctionsLines
common_endpoints.js 78 |
79 |
16%4/25100%0/025%2/816%4/25
recognition_endpoints.js 93 |
94 |
81.82%9/11100%0/0100%4/481.82%9/11
107 |
108 |
109 |
110 | 115 | 116 | 117 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /coverage/lcov-report/endpoints/recognition_endpoints.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Code coverage report for endpoints/recognition_endpoints.js 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 20 |
21 |
22 |

All files / endpoints recognition_endpoints.js

23 |
24 | 25 |
26 | 81.82% 27 | Statements 28 | 9/11 29 |
30 | 31 | 32 |
33 | 100% 34 | Branches 35 | 0/0 36 |
37 | 38 | 39 |
40 | 100% 41 | Functions 42 | 4/4 43 |
44 | 45 | 46 |
47 | 81.82% 48 | Lines 49 | 9/11 50 |
51 | 52 | 53 |
54 |

55 | Press n or j to go to the next uncovered block, b, p or k for the previous block. 56 |

57 |
58 |
59 |

 60 | 
1 61 | 2 62 | 3 63 | 4 64 | 5 65 | 6 66 | 7 67 | 8 68 | 9 69 | 10 70 | 11 71 | 12 72 | 13 73 | 14 74 | 15 75 | 16 76 | 17 77 | 18 78 | 19 79 | 20 80 | 21 81 | 22 82 | 23 83 | 24 84 | 25 85 | 26 86 | 27 87 | 28 88 | 29 89 | 30 90 | 31 91 | 32 92 | 33 93 | 34 94 | 35 95 | 36 96 | 37 97 | 38 98 | 39 99 | 40 100 | 41 101 | 42 102 | 43 103 | 44 104 | 45 105 | 46 106 | 47 107 | 48 108 | 49 109 | 50 110 | 51 111 | 52 112 | 53 113 | 54 114 | 55 115 | 56 116 | 57 117 | 58 118 | 59 119 | 60 120 | 61 121 | 62 122 | 63 123 | 64 124 | 65 125 | 66  126 |   127 |   128 |   129 |   130 |   131 |   132 |   133 |   134 |   135 |   136 |   137 |   138 |   139 |   140 |   141 |   142 | 2x 143 |   144 |   145 |   146 |   147 |   148 |   149 |   150 | 1x 151 | 1x 152 | 1x 153 |   154 |   155 |   156 |   157 |   158 | 1x 159 |   160 |   161 |   162 |   163 |   164 |   165 |   166 |   167 |   168 |   169 |   170 |   171 |   172 | 1x 173 | 1x 174 | 1x 175 |   176 |   177 |   178 |   179 |   180 | 1x 181 |   182 |   183 |   184 |   185 |   186 |   187 |   188 |   189 |   190 |  
/*
191 |  * Copyright (c) 2020 the original author or authors
192 |  *
193 |  * Licensed under the Apache License, Version 2.0 (the "License");
194 |  * you may not use this file except in compliance with the License.
195 |  * You may obtain a copy of the License at
196 |  *
197 |  *      https://www.apache.org/licenses/LICENSE-2.0
198 |  *
199 |  * Unless required by applicable law or agreed to in writing, software
200 |  * distributed under the License is distributed on an "AS IS" BASIS,
201 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
202 |  * or implied. See the License for the specific language governing
203 |  * permissions and limitations under the License.
204 |  */
205 | import axios from 'axios';
206 |  
207 | const recognition_endpoints = {
208 |     /**
209 |      * View list of faces user tried
210 |      * @param {String} url 
211 |      * @param {String} api_key 
212 |      * @returns {Promise}
213 |      */
214 |     async list_request(url, api_key){
215 |         return new Promise( async (resolve, reject) => {
216 |             try {
217 |                 const response = await axios.get(url, { 
218 |                     headers: {
219 |                         "x-api-key": api_key 
220 |                     }
221 |                 })
222 |  
223 |                 resolve(response)
224 |             } catch (error) {
225 |                 reject(error)
226 |             }
227 |         })
228 |     },
229 |  
230 |     /**
231 |      * Delete image(s)
232 |      * @param {String} url 
233 |      * @param {String} api_key 
234 |      * @returns {Promise}
235 |      */
236 |     async delete_request(url, api_key){
237 |         return new Promise( async (resolve, reject) => {
238 |             try {
239 |                 const response = await axios.delete(url, { 
240 |                     headers: {
241 |                         "x-api-key": api_key
242 |                     }
243 |                 }) 
244 |  
245 |                 resolve(response)
246 |             } catch (error) {
247 |                 reject(error)
248 |             }
249 |         })
250 |     }
251 | } 
252 |  
253 | export { recognition_endpoints };
254 |  
255 |  
256 | 257 |
258 |
259 | 264 | 265 | 266 | 271 | 272 | 273 | 274 | 275 | -------------------------------------------------------------------------------- /coverage/lcov-report/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exadel-inc/compreface-javascript-sdk/95bcd3e9549075334db608717cbd66502cf94152/coverage/lcov-report/favicon.png -------------------------------------------------------------------------------- /coverage/lcov-report/functions/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Code coverage report for functions 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 20 |
21 |
22 |

All files functions

23 |
24 | 25 |
26 | 95.65% 27 | Statements 28 | 22/23 29 |
30 | 31 | 32 |
33 | 70.83% 34 | Branches 35 | 17/24 36 |
37 | 38 | 39 |
40 | 100% 41 | Functions 42 | 4/4 43 |
44 | 45 | 46 |
47 | 100% 48 | Lines 49 | 22/22 50 |
51 | 52 | 53 |
54 |

55 | Press n or j to go to the next uncovered block, b, p or k for the previous block. 56 |

57 |
58 |
59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 |
FileStatementsBranchesFunctionsLines
index.js 78 |
79 |
95.65%22/2370.83%17/24100%4/4100%22/22
92 |
93 |
94 |
95 | 100 | 101 | 102 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /coverage/lcov-report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Code coverage report for All files 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 20 |
21 |
22 |

All files

23 |
24 | 25 |
26 | 59.32% 27 | Statements 28 | 35/59 29 |
30 | 31 | 32 |
33 | 70.83% 34 | Branches 35 | 17/24 36 |
37 | 38 | 39 |
40 | 62.5% 41 | Functions 42 | 10/16 43 |
44 | 45 | 46 |
47 | 60.34% 48 | Lines 49 | 35/58 50 |
51 | 52 | 53 |
54 |

55 | Press n or j to go to the next uncovered block, b, p or k for the previous block. 56 |

57 |
58 |
59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 |
FileStatementsBranchesFunctionsLines
endpoints 78 |
79 |
36.11%13/36100%0/050%6/1236.11%13/36
functions 93 |
94 |
95.65%22/2370.83%17/24100%4/4100%22/22
107 |
108 |
109 |
110 | 115 | 116 | 117 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /coverage/lcov-report/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /coverage/lcov-report/prettify.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /coverage/lcov-report/sort-arrow-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exadel-inc/compreface-javascript-sdk/95bcd3e9549075334db608717cbd66502cf94152/coverage/lcov-report/sort-arrow-sprite.png -------------------------------------------------------------------------------- /coverage/lcov-report/sorter.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | var addSorting = (function() { 3 | 'use strict'; 4 | var cols, 5 | currentSort = { 6 | index: 0, 7 | desc: false 8 | }; 9 | 10 | // returns the summary table element 11 | function getTable() { 12 | return document.querySelector('.coverage-summary'); 13 | } 14 | // returns the thead element of the summary table 15 | function getTableHeader() { 16 | return getTable().querySelector('thead tr'); 17 | } 18 | // returns the tbody element of the summary table 19 | function getTableBody() { 20 | return getTable().querySelector('tbody'); 21 | } 22 | // returns the th element for nth column 23 | function getNthColumn(n) { 24 | return getTableHeader().querySelectorAll('th')[n]; 25 | } 26 | 27 | // loads all columns 28 | function loadColumns() { 29 | var colNodes = getTableHeader().querySelectorAll('th'), 30 | colNode, 31 | cols = [], 32 | col, 33 | i; 34 | 35 | for (i = 0; i < colNodes.length; i += 1) { 36 | colNode = colNodes[i]; 37 | col = { 38 | key: colNode.getAttribute('data-col'), 39 | sortable: !colNode.getAttribute('data-nosort'), 40 | type: colNode.getAttribute('data-type') || 'string' 41 | }; 42 | cols.push(col); 43 | if (col.sortable) { 44 | col.defaultDescSort = col.type === 'number'; 45 | colNode.innerHTML = 46 | colNode.innerHTML + ''; 47 | } 48 | } 49 | return cols; 50 | } 51 | // attaches a data attribute to every tr element with an object 52 | // of data values keyed by column name 53 | function loadRowData(tableRow) { 54 | var tableCols = tableRow.querySelectorAll('td'), 55 | colNode, 56 | col, 57 | data = {}, 58 | i, 59 | val; 60 | for (i = 0; i < tableCols.length; i += 1) { 61 | colNode = tableCols[i]; 62 | col = cols[i]; 63 | val = colNode.getAttribute('data-value'); 64 | if (col.type === 'number') { 65 | val = Number(val); 66 | } 67 | data[col.key] = val; 68 | } 69 | return data; 70 | } 71 | // loads all row data 72 | function loadData() { 73 | var rows = getTableBody().querySelectorAll('tr'), 74 | i; 75 | 76 | for (i = 0; i < rows.length; i += 1) { 77 | rows[i].data = loadRowData(rows[i]); 78 | } 79 | } 80 | // sorts the table using the data for the ith column 81 | function sortByIndex(index, desc) { 82 | var key = cols[index].key, 83 | sorter = function(a, b) { 84 | a = a.data[key]; 85 | b = b.data[key]; 86 | return a < b ? -1 : a > b ? 1 : 0; 87 | }, 88 | finalSorter = sorter, 89 | tableBody = document.querySelector('.coverage-summary tbody'), 90 | rowNodes = tableBody.querySelectorAll('tr'), 91 | rows = [], 92 | i; 93 | 94 | if (desc) { 95 | finalSorter = function(a, b) { 96 | return -1 * sorter(a, b); 97 | }; 98 | } 99 | 100 | for (i = 0; i < rowNodes.length; i += 1) { 101 | rows.push(rowNodes[i]); 102 | tableBody.removeChild(rowNodes[i]); 103 | } 104 | 105 | rows.sort(finalSorter); 106 | 107 | for (i = 0; i < rows.length; i += 1) { 108 | tableBody.appendChild(rows[i]); 109 | } 110 | } 111 | // removes sort indicators for current column being sorted 112 | function removeSortIndicators() { 113 | var col = getNthColumn(currentSort.index), 114 | cls = col.className; 115 | 116 | cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); 117 | col.className = cls; 118 | } 119 | // adds sort indicators for current column being sorted 120 | function addSortIndicators() { 121 | getNthColumn(currentSort.index).className += currentSort.desc 122 | ? ' sorted-desc' 123 | : ' sorted'; 124 | } 125 | // adds event listeners for all sorter widgets 126 | function enableUI() { 127 | var i, 128 | el, 129 | ithSorter = function ithSorter(i) { 130 | var col = cols[i]; 131 | 132 | return function() { 133 | var desc = col.defaultDescSort; 134 | 135 | if (currentSort.index === i) { 136 | desc = !currentSort.desc; 137 | } 138 | sortByIndex(i, desc); 139 | removeSortIndicators(); 140 | currentSort.index = i; 141 | currentSort.desc = desc; 142 | addSortIndicators(); 143 | }; 144 | }; 145 | for (i = 0; i < cols.length; i += 1) { 146 | if (cols[i].sortable) { 147 | // add the click event handler on the th so users 148 | // dont have to click on those tiny arrows 149 | el = getNthColumn(i).querySelector('.sorter').parentElement; 150 | if (el.addEventListener) { 151 | el.addEventListener('click', ithSorter(i)); 152 | } else { 153 | el.attachEvent('onclick', ithSorter(i)); 154 | } 155 | } 156 | } 157 | } 158 | // adds sorting functionality to the UI 159 | return function() { 160 | if (!getTable()) { 161 | return; 162 | } 163 | cols = loadColumns(); 164 | loadData(); 165 | addSortIndicators(); 166 | enableUI(); 167 | }; 168 | })(); 169 | 170 | window.addEventListener('load', addSorting); 171 | -------------------------------------------------------------------------------- /coverage/lcov.info: -------------------------------------------------------------------------------- 1 | TN: 2 | SF:endpoints\common_endpoints.js 3 | FN:22,(anonymous_0) 4 | FN:26,(anonymous_1) 5 | FN:49,(anonymous_2) 6 | FN:53,(anonymous_3) 7 | FN:77,(anonymous_4) 8 | FN:80,(anonymous_5) 9 | FN:82,(anonymous_6) 10 | FN:98,(anonymous_7) 11 | FNF:8 12 | FNH:2 13 | FNDA:0,(anonymous_0) 14 | FNDA:0,(anonymous_1) 15 | FNDA:0,(anonymous_2) 16 | FNDA:0,(anonymous_3) 17 | FNDA:1,(anonymous_4) 18 | FNDA:1,(anonymous_5) 19 | FNDA:0,(anonymous_6) 20 | FNDA:0,(anonymous_7) 21 | DA:21,1 22 | DA:23,0 23 | DA:24,0 24 | DA:26,0 25 | DA:27,0 26 | DA:28,0 27 | DA:35,0 28 | DA:37,0 29 | DA:50,0 30 | DA:51,0 31 | DA:53,0 32 | DA:54,0 33 | DA:55,0 34 | DA:63,0 35 | DA:65,0 36 | DA:78,1 37 | DA:80,1 38 | DA:81,1 39 | DA:83,0 40 | DA:84,0 41 | DA:85,0 42 | DA:86,0 43 | DA:93,0 44 | DA:95,0 45 | DA:99,0 46 | LF:25 47 | LH:4 48 | BRF:0 49 | BRH:0 50 | end_of_record 51 | TN: 52 | SF:endpoints\recognition_endpoints.js 53 | FN:25,(anonymous_0) 54 | FN:26,(anonymous_1) 55 | FN:47,(anonymous_2) 56 | FN:48,(anonymous_3) 57 | FNF:4 58 | FNH:4 59 | FNDA:1,(anonymous_0) 60 | FNDA:1,(anonymous_1) 61 | FNDA:1,(anonymous_2) 62 | FNDA:1,(anonymous_3) 63 | DA:18,2 64 | DA:26,1 65 | DA:27,1 66 | DA:28,1 67 | DA:34,1 68 | DA:36,0 69 | DA:48,1 70 | DA:49,1 71 | DA:50,1 72 | DA:56,1 73 | DA:58,0 74 | LF:11 75 | LH:9 76 | BRF:0 77 | BRH:0 78 | end_of_record 79 | TN: 80 | SF:functions\index.js 81 | FN:23,(anonymous_0) 82 | FN:32,(anonymous_1) 83 | FN:45,(anonymous_2) 84 | FN:59,(anonymous_3) 85 | FNF:4 86 | FNH:4 87 | FNDA:1,(anonymous_0) 88 | FNDA:1,(anonymous_1) 89 | FNDA:1,(anonymous_2) 90 | FNDA:1,(anonymous_3) 91 | DA:18,4 92 | DA:24,1 93 | DA:34,1 94 | DA:35,1 95 | DA:37,1 96 | DA:46,1 97 | DA:47,1 98 | DA:48,1 99 | DA:61,1 100 | DA:62,1 101 | DA:65,1 102 | DA:67,1 103 | DA:68,1 104 | DA:72,1 105 | DA:73,1 106 | DA:77,1 107 | DA:78,1 108 | DA:82,1 109 | DA:83,1 110 | DA:87,1 111 | DA:88,1 112 | DA:92,1 113 | LF:22 114 | LH:22 115 | BRDA:46,0,0,0 116 | BRDA:46,0,1,1 117 | BRDA:65,1,0,1 118 | BRDA:65,1,1,0 119 | BRDA:67,2,0,1 120 | BRDA:67,2,1,0 121 | BRDA:67,3,0,1 122 | BRDA:67,3,1,1 123 | BRDA:72,4,0,1 124 | BRDA:72,4,1,0 125 | BRDA:72,5,0,1 126 | BRDA:72,5,1,1 127 | BRDA:77,6,0,1 128 | BRDA:77,6,1,0 129 | BRDA:77,7,0,1 130 | BRDA:77,7,1,1 131 | BRDA:82,8,0,1 132 | BRDA:82,8,1,0 133 | BRDA:82,9,0,1 134 | BRDA:82,9,1,1 135 | BRDA:87,10,0,1 136 | BRDA:87,10,1,0 137 | BRDA:87,11,0,1 138 | BRDA:87,11,1,1 139 | BRF:24 140 | BRH:17 141 | end_of_record 142 | -------------------------------------------------------------------------------- /endpoints/__mocks__/list.js: -------------------------------------------------------------------------------- 1 | const images = { 2 | image_id: "6b135f5b-a365-4522-b1f1-4c9ac2dd0728", 3 | subject: "subject1", 4 | 5 | image_id: "6b135f5b-a365-4522-b1f1-4c9ac2dd0728", 6 | subject: "subject2", 7 | } 8 | 9 | const list = (url, api_key) => { 10 | return new Promise((resolve, reject) => { 11 | process.nextTick(() => { 12 | url && api_key 13 | ? resolve(JSON.stringify(images)) 14 | : reject({ error: "Something went wrong" }) 15 | }) 16 | }) 17 | 18 | } 19 | 20 | export default list; -------------------------------------------------------------------------------- /endpoints/common_endpoints.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | import axios from 'axios'; 17 | import fs from 'fs'; 18 | import FormData from 'form-data'; 19 | 20 | // Collection of common endpoints that used by almost all services 21 | const common_endpoints = { 22 | /** 23 | * @param {String} base64string 24 | * @param {String} url 25 | * @param {String} api_key 26 | * @returns {Promise} 27 | */ 28 | async upload_base64(base64string, url, api_key){ 29 | let data = { 30 | file: base64string 31 | } 32 | 33 | return new Promise( async (resolve, reject) => { 34 | try { 35 | const response = await axios.post( url, JSON.stringify(data), { 36 | headers: { 37 | 'Content-Type': 'application/json', 38 | "x-api-key": api_key 39 | }, 40 | }) 41 | 42 | resolve(response) 43 | } catch (error) { 44 | reject(error) 45 | } 46 | }) 47 | }, 48 | 49 | /** 50 | * @param {Object} blobData 51 | * @param {String} url 52 | * @param {String} api_key 53 | * @returns {Promise} 54 | */ 55 | async upload_blob(blobData, url, api_key){ 56 | var bodyFormData = new FormData(); 57 | bodyFormData.append('file', blobData, 'example.jpg'); 58 | 59 | return new Promise( async (resolve, reject) => { 60 | try { 61 | const response = await axios.post( url, bodyFormData, { 62 | headers: { 63 | 'Content-Type': 'multipart/form-data', 64 | "x-api-key": api_key 65 | }, 66 | }) 67 | 68 | resolve(response) 69 | } catch (error) { 70 | reject(error) 71 | } 72 | }) 73 | }, 74 | 75 | /** 76 | * Upload from local machine 77 | * @param {String} image_path 78 | * @param {String} url 79 | * @param {String} api_key 80 | * @returns {Promise} 81 | */ 82 | async upload_path(image_path, url, api_key ){ 83 | var bodyFormData = new FormData(); 84 | bodyFormData.append('file', fs.createReadStream(image_path), { knownLength: fs.statSync(image_path).size }); 85 | 86 | return new Promise( async (resolve, reject) => { 87 | try { 88 | const response = await axios.post( url, bodyFormData, { 89 | headers: { 90 | ...bodyFormData.getHeaders(), 91 | "Content-Length": bodyFormData.getLengthSync(), 92 | "x-api-key": api_key 93 | }, 94 | }) 95 | 96 | resolve(response) 97 | } catch (error) { 98 | reject(error) 99 | } 100 | }) 101 | }, 102 | 103 | /** 104 | * Add image (from url) with subject 105 | * @param {String} image_url 106 | * @param {String} url 107 | * @param {String} api_key 108 | * @returns {Promise} 109 | */ 110 | async upload_url(image_url, url, api_key){ 111 | var bodyFormData = new FormData(); 112 | 113 | return new Promise( async (resolve, reject) => { 114 | await axios.get(image_url, { responseType: 'stream' }) 115 | .then( async (response) => { 116 | let image_extention = response.headers['content-type'].split("/")[1] 117 | bodyFormData.append('file', response.data, `example.${image_extention}`); 118 | try { 119 | const res = await axios.post( url, bodyFormData, { 120 | headers: { 121 | ...bodyFormData.getHeaders(), 122 | "x-api-key": api_key 123 | }, 124 | }) 125 | 126 | resolve(res) 127 | } catch (error) { 128 | reject(error) 129 | } 130 | }) 131 | .catch(error => { 132 | reject(error) 133 | }) 134 | }) 135 | }, 136 | } 137 | 138 | export { common_endpoints } -------------------------------------------------------------------------------- /endpoints/recognition_endpoints.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | import axios from 'axios'; 17 | 18 | const recognition_endpoints = { 19 | /** 20 | * View list of faces user tried 21 | * @param {String} url 22 | * @param {String} api_key 23 | * @returns {Promise} 24 | */ 25 | async list_request(url, api_key){ 26 | return new Promise( async (resolve, reject) => { 27 | try { 28 | const response = await axios.get(url, { 29 | headers: { 30 | "x-api-key": api_key 31 | } 32 | }) 33 | 34 | resolve(response) 35 | } catch (error) { 36 | reject(error) 37 | } 38 | }) 39 | }, 40 | 41 | /** 42 | * Delete image(s) 43 | * @param {String} url 44 | * @param {String} api_key 45 | * @returns {Promise} 46 | */ 47 | async delete_request(url, api_key){ 48 | return new Promise( async (resolve, reject) => { 49 | try { 50 | const response = await axios.delete(url, { 51 | headers: { 52 | "x-api-key": api_key 53 | } 54 | }) 55 | 56 | resolve(response) 57 | } catch (error) { 58 | reject(error) 59 | } 60 | }) 61 | }, 62 | 63 | /** 64 | * Delete multiple images 65 | * @param {String} url 66 | * @param {String} api_key 67 | * @param {String[]} image_ids 68 | * @returns {Promise} 69 | */ 70 | async delete_multiple(url, api_key, image_ids){ 71 | return new Promise( async (resolve, reject) => { 72 | try { 73 | const response = await axios.post(url, image_ids, { 74 | headers: { 75 | "x-api-key": api_key 76 | } 77 | }) 78 | 79 | resolve(response) 80 | } catch (error) { 81 | reject(error) 82 | } 83 | }) 84 | } 85 | 86 | } 87 | 88 | export { recognition_endpoints }; 89 | 90 | -------------------------------------------------------------------------------- /endpoints/subject_endpoints.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | import axios from 'axios'; 17 | 18 | const subject_endpoints = { 19 | list(url, api_key){ 20 | console.log(url, api_key) 21 | return new Promise( async (resolve, reject) => { 22 | try { 23 | const response = await axios.get(url, { 24 | headers: { 25 | 'Content-Type': 'application/json', 26 | "x-api-key": api_key 27 | } 28 | }) 29 | 30 | resolve(response) 31 | } catch (error) { 32 | reject(error) 33 | } 34 | }) 35 | }, 36 | 37 | add(subject, url, api_key){ 38 | let data = { subject }; 39 | return new Promise( async (resolve, reject) => { 40 | try { 41 | const response = await axios.post( url, JSON.stringify(data), { 42 | headers: { 43 | 'Content-Type': 'application/json', 44 | "x-api-key": api_key 45 | }, 46 | }) 47 | 48 | resolve(response) 49 | } catch (error) { 50 | reject(error) 51 | } 52 | }) 53 | }, 54 | 55 | rename(subject, url, api_key){ 56 | let data = { subject }; 57 | return new Promise( async (resolve, reject) => { 58 | try { 59 | const response = await axios.put( url, JSON.stringify(data), { 60 | headers: { 61 | 'Content-Type': 'application/json', 62 | "x-api-key": api_key 63 | }, 64 | }) 65 | 66 | resolve(response) 67 | } catch (error) { 68 | reject(error) 69 | } 70 | }) 71 | }, 72 | 73 | deleteSubject(url, api_key){ 74 | return new Promise( async (resolve, reject) => { 75 | try { 76 | const response = await axios.delete(url, { 77 | headers: { 78 | 'Content-Type': 'application/json', 79 | "x-api-key": api_key 80 | } 81 | }) 82 | 83 | resolve(response) 84 | } catch (error) { 85 | reject(error) 86 | } 87 | }) 88 | } 89 | } 90 | 91 | export { subject_endpoints } -------------------------------------------------------------------------------- /endpoints/upload.js: -------------------------------------------------------------------------------- 1 | import { common_functions } from '../functions/index.js'; 2 | import { common_endpoints } from '../endpoints/common_endpoints.js'; 3 | 4 | const upload = (image_data, url, api_key) => { 5 | const{ isUrl, isPathRelative, isBase64 } = common_functions; 6 | const { upload_blob, upload_path, upload_url, upload_base64 } = common_endpoints; 7 | 8 | let imageFromUrl = isUrl(image_data), 9 | imageFromPath = isPathRelative(image_data), 10 | imageFromBase64 = isBase64(image_data); 11 | 12 | return new Promise((resolve, reject) => { 13 | if(imageFromUrl){ 14 | upload_url(image_data, url, api_key) 15 | .then(response => { 16 | resolve(response.data) 17 | }) 18 | .catch(error => { 19 | reject(error) 20 | }) 21 | }else if(imageFromBase64){ 22 | upload_base64(image_data, url, api_key) 23 | .then(response => { 24 | resolve(response.data) 25 | }) 26 | .catch(error => { 27 | reject(error) 28 | }) 29 | }else if(imageFromPath){ 30 | upload_path(image_data, url, api_key) 31 | .then(response => { 32 | resolve(response.data) 33 | }) 34 | .catch(error => { 35 | reject(error) 36 | }) 37 | }else { 38 | upload_blob(image_data, url, api_key) 39 | .then(response => { 40 | resolve(response.data) 41 | }) 42 | .catch(error => { 43 | reject(error) 44 | }) 45 | } 46 | }) 47 | } 48 | 49 | export { upload }; -------------------------------------------------------------------------------- /endpoints/verification_endpoints.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | import axios from 'axios'; 17 | import fs from 'fs'; 18 | import FormData from 'form-data'; 19 | 20 | const verification_endpoints = { 21 | /** 22 | * Verify face(s) from given image 23 | * @param {String} source_image_path 24 | * @param {String} target_image_path 25 | * @param {String} url 26 | * @param {String} api_key 27 | * @returns {Promise} 28 | */ 29 | async verify_face_request(source_image_path, target_image_path, url, api_key ){ 30 | var bodyFormData = new FormData(); 31 | bodyFormData.append('source_image', fs.createReadStream(source_image_path), { knownLength: fs.statSync(source_image_path).size }); 32 | bodyFormData.append('target_image', fs.createReadStream(target_image_path), { knownLength: fs.statSync(target_image_path).size }); 33 | 34 | return new Promise( async (resolve, reject) => { 35 | try { 36 | const response = await axios.post( url, bodyFormData, { 37 | headers: { 38 | ...bodyFormData.getHeaders(), 39 | "Content-Length": bodyFormData.getLengthSync(), 40 | "x-api-key": api_key 41 | }, 42 | }) 43 | 44 | resolve(response) 45 | } catch (error) { 46 | reject(error) 47 | } 48 | }) 49 | }, 50 | 51 | /** 52 | * Verify face(s) from given image urls 53 | * @param {String} source_image_path 54 | * @param {String} target_image_path 55 | * @param {String} url 56 | * @param {String} api_key 57 | * @returns {Promise} 58 | */ 59 | both_url_request( source_image_url, target_image_url, url, api_key){ 60 | let bodyFormData = new FormData(); 61 | let source_image_request = axios.get(source_image_url, { responseType: "stream" }); 62 | let target_image_request = axios.get(target_image_url, { responseType: "stream" }); 63 | 64 | return new Promise( async (resolve, reject) => { 65 | await axios.all([source_image_request, target_image_request]) 66 | .then( axios.spread( async (...responses) => { 67 | let source_image_extention = responses[0].headers['content-type'].split("/")[1]; 68 | let target_image_extention = responses[1].headers['content-type'].split("/")[1]; 69 | 70 | bodyFormData.append('source_image', responses[0].data, `example.${source_image_extention}`); 71 | bodyFormData.append('target_image', responses[1].data, `example1.${target_image_extention}`); 72 | 73 | try { 74 | const res = await axios.post( url, bodyFormData, { 75 | headers: { 76 | ...bodyFormData.getHeaders(), 77 | "x-api-key": api_key 78 | }, 79 | }) 80 | 81 | resolve(res) 82 | } catch (error) { 83 | reject(error) 84 | } 85 | })) 86 | .catch(error => { 87 | reject(error) 88 | }) 89 | }) 90 | }, 91 | 92 | /** 93 | * Verify face(s) from given image urls 94 | * @param {String} source_image_path 95 | * @param {String} target_image_path 96 | * @param {Boolean} isSourceImageUrl 97 | * @param {String} url 98 | * @param {String} api_key 99 | * @returns {Promise} 100 | */ 101 | one_url_request(source_image_path, isSourceImageUrl, target_image_path, url, api_key ){ 102 | var bodyFormData = new FormData(); 103 | let path_is_url = []; 104 | let path_is_relative = []; 105 | 106 | if(isSourceImageUrl){ 107 | path_is_url[0] = "source_image"; 108 | path_is_url[1] = source_image_path; 109 | 110 | path_is_relative[0] = "target_image"; 111 | path_is_relative[1] = target_image_path; 112 | }else{ 113 | path_is_url[0] = "target_image"; 114 | path_is_url[1] = target_image_path; 115 | 116 | path_is_relative[0] = "source_image"; 117 | path_is_relative[1] = source_image_path; 118 | } 119 | bodyFormData.append(path_is_relative[0], fs.createReadStream(path_is_relative[1]), { knownLength: fs.statSync(path_is_relative[1]).size }); 120 | 121 | return new Promise( async (resolve, reject) => { 122 | await axios.get(path_is_url[1], { responseType: 'stream' }) 123 | .then( async (response) => { 124 | let image_extention = response.headers['content-type'].split("/")[1] 125 | bodyFormData.append(path_is_url[0], response.data, `example.${image_extention}`); 126 | 127 | try { 128 | const res = await axios.post( url, bodyFormData, { 129 | headers: { 130 | ...bodyFormData.getHeaders(), 131 | "x-api-key": api_key 132 | }, 133 | }) 134 | 135 | resolve(res) 136 | } catch (error) { 137 | reject(error) 138 | } 139 | }) 140 | .catch(error => { 141 | reject(error) 142 | }) 143 | }) 144 | }, 145 | /** 146 | * Verify face(s) from given blob data 147 | * @param {String} source_image_path 148 | * @param {String} target_image_path 149 | * @param {Boolean} isSourceBlob 150 | * @param {String} url 151 | * @param {String} api_key 152 | * @returns {Promise} 153 | */ 154 | url_blob_request(source_image_path, isSourceImageUrl, target_image_path, url, api_key){ 155 | let bodyFormData = new FormData(); 156 | let path_is_url = []; 157 | let path_is_blob = []; 158 | 159 | if(isSourceImageUrl){ 160 | path_is_url[0] = "source_image"; 161 | path_is_url[1] = source_image_path; 162 | 163 | path_is_blob[0] = "target_image"; 164 | path_is_blob[1] = target_image_path; 165 | }else{ 166 | path_is_url = "target_image"; 167 | path_is_url[1] = target_image_path; 168 | 169 | path_is_blob = "source_image"; 170 | path_is_blob[1] = source_image_path; 171 | } 172 | bodyFormData.append(path_is_blob[0], path_is_blob[1], 'example.jpg'); 173 | 174 | return new Promise( async (resolve, reject) => { 175 | await axios.get(path_is_url[1], { responseType: 'stream' }) 176 | .then( async (response) => { 177 | let image_extention = response.headers['content-type'].split("/")[1] 178 | bodyFormData.append(path_is_url[0], response.data, `example.${image_extention}`); 179 | 180 | try { 181 | const res = await axios.post( url, bodyFormData, { 182 | headers: { 183 | ...bodyFormData.getHeaders(), 184 | "x-api-key": api_key 185 | }, 186 | }) 187 | 188 | resolve(res) 189 | } catch (error) { 190 | reject(error) 191 | } 192 | }) 193 | .catch(error => { 194 | reject(error) 195 | }) 196 | }) 197 | }, 198 | 199 | /** 200 | * Both source and target images are blob 201 | * @param {Blob} source_image_blob 202 | * @param {Blob} target_image_blob 203 | * @param {String} url 204 | * @param {String} api_key 205 | */ 206 | both_blob_request(source_image_blob, target_image_blob, url, api_key){ 207 | var bodyFormData = new FormData(); 208 | 209 | bodyFormData.append('source_image', source_image_blob, 'example.jpg'); 210 | bodyFormData.append('target_image', target_image_blob, 'example1.jpg'); 211 | 212 | return new Promise( async (resolve, reject) => { 213 | try { 214 | const response = await axios.post( url, bodyFormData, { 215 | headers: { 216 | 'Content-Type': 'multipart/form-data', 217 | "x-api-key": api_key 218 | }, 219 | }) 220 | 221 | resolve(response) 222 | } catch (error) { 223 | reject(error) 224 | } 225 | }) 226 | }, 227 | 228 | one_blob_request(source_image_path, isSourceImageBlob, target_image_path, url, api_key ){ 229 | var bodyFormData = new FormData(); 230 | let path_is_blob = []; 231 | let path_is_relative = []; 232 | 233 | if(isSourceImageBlob){ 234 | path_is_blob[0] = "source_image"; 235 | path_is_blob[1] = source_image_path; 236 | 237 | path_is_relative[0] = "target_image"; 238 | path_is_relative[1] = target_image_path; 239 | }else{ 240 | path_is_blob = "target_image"; 241 | path_is_blob[1] = target_image_path; 242 | 243 | path_is_relative = "source_image"; 244 | path_is_relative[1] = source_image_path; 245 | } 246 | 247 | bodyFormData.append(path_is_relative[0], fs.createReadStream(path_is_relative[1]), { knownLength: fs.statSync(path_is_relative[1]).size }); 248 | bodyFormData.append(path_is_blob[0], path_is_blob[1], 'example.jpg'); 249 | 250 | return new Promise( async (resolve, reject) => { 251 | try { 252 | const response = await axios.post( url, bodyFormData, { 253 | headers: { 254 | 'Content-Type': 'multipart/form-data', 255 | "x-api-key": api_key 256 | }, 257 | }) 258 | 259 | resolve(response) 260 | } catch (error) { 261 | reject(error) 262 | } 263 | }) 264 | }, 265 | 266 | /** 267 | * Verify face(s) from given base64 268 | * @param {String} source_image_path 269 | * @param {String} target_image_path 270 | * @param {String} url 271 | * @param {String} api_key 272 | * @returns {Promise} 273 | */ 274 | base64_request(source_image_path, target_image_path, url, api_key ){ 275 | let data = { 276 | source_image: source_image_path, 277 | target_image: target_image_path 278 | } 279 | 280 | return new Promise( async (resolve, reject) => { 281 | try { 282 | const response = await axios.post( url, JSON.stringify(data), { 283 | headers: { 284 | 'Content-Type': 'application/json', 285 | "x-api-key": api_key 286 | }, 287 | }) 288 | 289 | resolve(response) 290 | } catch (error) { 291 | reject(error) 292 | } 293 | }) 294 | } 295 | 296 | 297 | } 298 | 299 | export { verification_endpoints } -------------------------------------------------------------------------------- /face_founder_demo/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | # IntellijIdea files 22 | *.iml 23 | .idea 24 | out 25 | 26 | npm-debug.log* 27 | yarn-debug.log* 28 | yarn-error.log* 29 | .idea/ 30 | *.iml -------------------------------------------------------------------------------- /face_founder_demo/README.md: -------------------------------------------------------------------------------- 1 | # Face founder Demo 2 | 3 | In this documentation we show how to use our recognition and detection service with pictures. **NOTE:** we have chosen reactjs as it is today's one of the most popular UI library. 4 | 5 | 1. Clone our repository 6 | 2. Enter to ```face_founder_demo``` folder 7 | 8 | ``` cd face_founder_demo``` 9 | 10 | 3. Install packages 11 | 12 | ```npm install``` 13 | 14 | 4. Start project 15 | 16 | ```npm start``` 17 | 18 | 5. Take recognition, detection keys and select folder with images and click ```upload folder``` button. -------------------------------------------------------------------------------- /face_founder_demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "face-list", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@exadel/compreface-js-sdk": "^1.0.0", 7 | "@testing-library/jest-dom": "^5.11.4", 8 | "@testing-library/react": "^11.1.0", 9 | "@testing-library/user-event": "^12.1.10", 10 | "ansi-html": "0.0.7", 11 | "axios": "^0.25.0", 12 | "bootstrap": "^4.6.0", 13 | "browserslist": "^4.19.1", 14 | "follow-redirects": "^1.14.7", 15 | "glob-parent": "^6.0.2", 16 | "immer": "^9.0.12", 17 | "node-forge": "^1.2.1", 18 | "nth-check": "^2.0.1", 19 | "react": "^17.0.2", 20 | "react-bootstrap": "^1.6.1", 21 | "react-confirm-alert": "^2.7.0", 22 | "react-dom": "^17.0.2", 23 | "react-notifications": "^1.7.2", 24 | "react-scripts": "4.0.3", 25 | "react-toastify": "^7.0.4", 26 | "tar": "^6.1.11", 27 | "tmpl": "^1.0.5", 28 | "url-parse": "^1.5.4", 29 | "web-vitals": "^1.0.1" 30 | }, 31 | "scripts": { 32 | "start": "react-scripts start", 33 | "build": "react-scripts build", 34 | "test": "react-scripts test", 35 | "eject": "react-scripts eject" 36 | }, 37 | "eslintConfig": { 38 | "extends": [ 39 | "react-app", 40 | "react-app/jest" 41 | ] 42 | }, 43 | "browserslist": { 44 | "production": [ 45 | ">0.2%", 46 | "not dead", 47 | "not op_mini all" 48 | ], 49 | "development": [ 50 | "last 1 chrome version", 51 | "last 1 firefox version", 52 | "last 1 safari version" 53 | ] 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /face_founder_demo/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exadel-inc/compreface-javascript-sdk/95bcd3e9549075334db608717cbd66502cf94152/face_founder_demo/public/favicon.ico -------------------------------------------------------------------------------- /face_founder_demo/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /face_founder_demo/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exadel-inc/compreface-javascript-sdk/95bcd3e9549075334db608717cbd66502cf94152/face_founder_demo/public/logo192.png -------------------------------------------------------------------------------- /face_founder_demo/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exadel-inc/compreface-javascript-sdk/95bcd3e9549075334db608717cbd66502cf94152/face_founder_demo/public/logo512.png -------------------------------------------------------------------------------- /face_founder_demo/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /face_founder_demo/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /face_founder_demo/src/App.js: -------------------------------------------------------------------------------- 1 | import { CompreFace } from '@exadel/compreface-js-sdk'; 2 | import './custom.css'; 3 | import { useState, useRef, useEffect } from 'react'; 4 | import { Container, Row, Form, Col, ProgressBar, Spinner } from 'react-bootstrap'; 5 | import UploadedImage from './components/UploadedImge'; 6 | import DisplayFoundImages from './components/DisplayFoundImages'; 7 | import DisplayCropedImage from './components/DisplayCropedImages'; 8 | import { confirmAlert } from 'react-confirm-alert'; 9 | import {NotificationContainer, NotificationManager} from 'react-notifications'; 10 | import ShowBadImages from './components/ShowBadImages'; 11 | import 'react-confirm-alert/src/react-confirm-alert.css'; 12 | 13 | function App() { 14 | const [ personsImage, setPersonsImage ] = useState(null); 15 | const [ imageFolder, setImageFolder ] = useState(null); 16 | const [ uploadedImage, setUploadedImage ] = useState(null); 17 | const [ foundFaces, setFoundFaces ] = useState([]); 18 | const [ counter, setCounter ] = useState(0); 19 | const [ recognitionKey, setRecognitionKey ] = useState(null); 20 | const [ detectionKey, setDetectionKey ] = useState(null); 21 | const [ rate, setRate ] = useState(90); 22 | const [ fullData, setFullData ] = useState(null) 23 | const [ similarityRate, setSimilarityRate ] = useState([]) 24 | const [ recognitionError, setRecognitionError ] = useState(false); 25 | const [ recError, setRecError ] = useState([]); 26 | const [ detError, setDetError ] = useState([]); 27 | const [ showInvalidFiles, setVisibilityInvalidFiles ] = useState(false); 28 | const [ bigImage, setBigImages ] = useState([]); 29 | const [ loading, setLoading ] = useState(false); 30 | 31 | useEffect(() => { 32 | if(imageFolder !== null) { 33 | findImages(); 34 | } 35 | }, [imageFolder]); 36 | 37 | const canvasElement = useRef(null); 38 | const imageElement = useRef(null); 39 | 40 | let server = "http://localhost"; 41 | let port = 8000; 42 | 43 | let core = new CompreFace(server, port); 44 | 45 | let recognitionService = core.initFaceRecognitionService(recognitionKey); 46 | let faceCollection = recognitionService.getFaceCollection(); 47 | let detectionService = core.initFaceDetectionService(detectionKey) 48 | 49 | const removeDublicates = (array) =>{ 50 | let tempArray = []; 51 | let saveDublicate = []; 52 | 53 | for(let i = 0; i < array.length; i++){ 54 | if(!saveDublicate.includes(array[i].subject)) tempArray.push([array[i].subject, array[i].similarity]) 55 | 56 | saveDublicate.push(array[i].subject) 57 | } 58 | 59 | return tempArray; 60 | } 61 | 62 | const onRecognitionKeyChange = e => { 63 | setRecognitionKey(e.target.value) 64 | } 65 | 66 | const onDetectionKeyChange = e => { 67 | setDetectionKey(e.target.value) 68 | } 69 | 70 | const onChangePersonPhoto = e => { 71 | if(e.target.files[0]){ 72 | setLoading(true) 73 | setFoundFaces([]); 74 | setCounter(0) 75 | setRecError(prevArray => [...new Set(prevArray)]) 76 | setVisibilityInvalidFiles(true); 77 | 78 | const reader = new FileReader(); 79 | reader.onload = myEvent => { 80 | setUploadedImage( myEvent.target.result ) 81 | let sendata = myEvent.target.result.split(',')[1]; 82 | 83 | recognitionService.recognize(sendata, {limit:10, prediction_count: 100, face_plugins: "age,gender"}) 84 | .then(res => { 85 | setLoading(false) 86 | setFullData(res.result[0].subjects); 87 | let filtered = res.result[0].subjects.filter(subobj => subobj.similarity * 100 >= rate) 88 | let tmp = removeDublicates(filtered) 89 | 90 | setSimilarityRate(tmp) 91 | setRecognitionError(true) 92 | 93 | tmp.forEach(subject => { 94 | for(let i = 0; i < Object.values(imageFolder).length; i++){ 95 | if(subject[0] === imageFolder[i]['name']) setFoundFaces(oldFaces => [...oldFaces, imageFolder[i]]) 96 | } 97 | }) 98 | }) 99 | .catch(error => { 100 | setRecognitionError(false) 101 | setLoading(false) 102 | NotificationManager.error("No face found in given image", "Error", 3000) 103 | }) 104 | } 105 | reader.readAsDataURL(e.target.files[0]) 106 | } 107 | } 108 | 109 | const onRateChanges = e => { 110 | let number = e.target.value; 111 | setFoundFaces([]); 112 | setRate(number); 113 | 114 | let filtered = fullData.filter(subobj => subobj.similarity * 100 >= number); 115 | let tmp = removeDublicates(filtered) 116 | setSimilarityRate(tmp) 117 | 118 | tmp.forEach(subject => { 119 | for(let i = 0; i < Object.values(imageFolder).length; i++ ){ 120 | if(subject[0] === imageFolder[i]['name']) setFoundFaces(oldFaces => [...oldFaces, imageFolder[i]]) 121 | } 122 | }) 123 | } 124 | 125 | const onChangeImageFolder = event => { 126 | setRate(90) 127 | setCounter(0) 128 | setFoundFaces([]) 129 | setImageFolder(event.target.files) 130 | } 131 | 132 | const getBase64 = file => { 133 | return new Promise((resolve, reject) => { 134 | const reader = new FileReader(); 135 | reader.readAsDataURL(file); 136 | 137 | reader.onload = () => resolve({ base64: reader.result, fileName: file.name }); 138 | reader.onerror = error => reject(error); 139 | }); 140 | } 141 | 142 | const drawFace = (ctx, aface, index, fileName, lengthOfDetectedFaces, callback, itaration) => { 143 | ctx.drawImage(imageElement.current, aface.box.x_min, aface.box.y_min, aface.box.x_max - aface.box.x_min, aface.box.y_max - aface.box.y_min, 0, 0, aface.box.x_max - aface.box.x_min, aface.box.y_max - aface.box.y_min); 144 | 145 | canvasElement.current.toBlob( blob => { 146 | faceCollection.add(blob, fileName) 147 | .then(data => { 148 | if(lengthOfDetectedFaces === index + 1){ 149 | itaration++; 150 | setCounter(itaration); 151 | callback(itaration) 152 | ctx.clearRect(0, 0, 700, 850); 153 | } 154 | }) 155 | .catch(error => { 156 | setRecError(prevArray => [...prevArray, fileName]); 157 | if(lengthOfDetectedFaces === index + 1){ 158 | confirmAlert({ 159 | title: 'Recognition error', 160 | message: `Face not found in ${fileName}`, 161 | buttons: [ 162 | { 163 | label: 'OK', 164 | onClick: () => { 165 | itaration++; 166 | setCounter(itaration); 167 | callback(itaration); 168 | ctx.clearRect(0, 0, 700, 850); 169 | 170 | } 171 | } 172 | ], 173 | closeOnClickOutside: false, 174 | closeOnEscape: false 175 | }); 176 | } 177 | }) 178 | }, 'image/jpeg', 0.95) 179 | } 180 | 181 | const findImages = e => { 182 | setDetError([]); 183 | setRecError([]); 184 | setVisibilityInvalidFiles(false); 185 | 186 | let internalCounter = 0; 187 | 188 | const uploadRecursivley = (intarator) => { 189 | // stop processing at the end of file 190 | if(!imageFolder.item(intarator)){ 191 | NotificationManager.success("Compeleted!", "Image processing completed!", 3000) 192 | return null; 193 | } 194 | 195 | // check size of image 196 | if(imageFolder.item(intarator).size < 5000000){ 197 | // get base64 format of image 198 | getBase64(imageFolder.item(intarator)) 199 | .then(customData => { 200 | setPersonsImage(customData.base64) 201 | let sendata = customData.base64.split(',')[1]; 202 | let ctx = canvasElement.current.getContext('2d'); 203 | 204 | detectionService.detect(sendata) 205 | .then(res => { 206 | res.result.forEach((aface, index) => { 207 | drawFace(ctx, aface, index, customData.fileName, res.result.length, uploadRecursivley, intarator) 208 | }) 209 | }) 210 | .catch(error => { 211 | setDetError(prevArray => [...prevArray, customData.fileName]) 212 | confirmAlert({ 213 | title: 'Detection error', 214 | message: `Face not found in ${customData.fileName}`, 215 | buttons: [ 216 | { 217 | label: 'OK', 218 | onClick: () => { 219 | intarator++; 220 | setCounter(intarator); 221 | uploadRecursivley(intarator) 222 | } 223 | } 224 | ], 225 | closeOnClickOutside: false, 226 | closeOnEscape: false 227 | }); 228 | }) 229 | }) 230 | .catch(error => console.log(error)) 231 | }else { 232 | setBigImages(prevArray => [...prevArray, imageFolder.item(intarator).name]) 233 | intarator++; 234 | setCounter(intarator) 235 | uploadRecursivley(intarator); 236 | } 237 | } 238 | 239 | uploadRecursivley(internalCounter) 240 | } 241 | 242 | return ( 243 | 244 |
245 | 246 | 247 | 248 | Recognition key 249 | 250 | 251 | 252 | 253 | 254 | Detection key 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | Similarity rate is {rate}% 271 | 272 | 273 | 274 | 275 |
276 | 277 | 278 | { uploadedImage && } 279 | { showInvalidFiles &&
280 | { recError.length && } 281 | { detError.length && } 282 | { bigImage.length && } 283 |
} 284 | 285 | 286 | { loading &&
287 | 288 | Loading... 289 | 290 |
} 291 | 292 | { foundFaces.length > 0 && } 293 | 294 |
295 | { counter > 0 && 296 | 297 | 298 | { counter === Object.values(imageFolder).length ?
299 | Done you can select persons image 300 |
:
Processing images
} 301 | 302 |
} 303 | { personsImage && } 304 | 305 |
306 | ); 307 | } 308 | 309 | export default App; 310 | -------------------------------------------------------------------------------- /face_founder_demo/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /face_founder_demo/src/assets/functions.js: -------------------------------------------------------------------------------- 1 | export const common_functions = { 2 | removeDublicates: function (array){ 3 | let tempArray = []; 4 | let saveDublicate = []; 5 | 6 | for(let i = 0; i < array.length; i++){ 7 | if(!saveDublicate.includes(array[i].subject)) tempArray.push([array[i].subject, array[i].similarity]) 8 | 9 | saveDublicate.push(array[i].subject) 10 | } 11 | 12 | return tempArray; 13 | } 14 | } -------------------------------------------------------------------------------- /face_founder_demo/src/components/CustomToast.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Toast } from 'react-bootstrap'; 3 | 4 | const CustomToast = ({ errorType, errorName, imageName }) => { 5 | return ( 6 | 7 | 8 | {errorType} 9 | 10 | 11 | {imageName} 12 |
13 | {errorName} 14 |
15 |
16 |
17 | ) 18 | } 19 | 20 | export default CustomToast; 21 | 22 | 23 | // onClose={ () => { setDetectionError(detectionError.splice(index, 0, undefined)) }} -------------------------------------------------------------------------------- /face_founder_demo/src/components/DisplayCropedImages.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Container, Row, Col, Image } from 'react-bootstrap'; 3 | 4 | const DisplayCropedImage = ({ personsImage, imageElement, canvasElement }) => { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | 12 | Exadel 13 | 14 | 15 | 16 | ) 17 | } 18 | 19 | export default DisplayCropedImage; -------------------------------------------------------------------------------- /face_founder_demo/src/components/DisplayFoundImages.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Container, Row, Col, Image } from 'react-bootstrap'; 3 | import '../custom.css'; 4 | 5 | const DisplayFoundImages = ({ foundFaces, similarityRate }) => { 6 | return ( 7 | <> 8 |
9 | Matched image(s) 10 |
11 | 12 | 13 | { foundFaces.map((faceFile, index) => 14 |
{similarityRate[index][1]}
15 | 16 | ) } 17 |
18 |
19 | 20 | ) 21 | } 22 | 23 | export default DisplayFoundImages; -------------------------------------------------------------------------------- /face_founder_demo/src/components/ShowBadImages.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const ShowBadImages = props => { 4 | const { data, badTitle } = props; 5 | return ( 6 |
7 | 8 |
    9 | {data.map( (fileName, index) => ( 10 |
  • {fileName}
  • ))} 11 |
12 |
13 | ) 14 | } 15 | 16 | export default ShowBadImages; -------------------------------------------------------------------------------- /face_founder_demo/src/components/UploadedImge.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Container, Row ,Col, Image} from 'react-bootstrap'; 3 | 4 | const UploadedImage = ({ uploadedImage }) => { 5 | return ( 6 | <> 7 |
8 | Uploaded image 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ) 19 | } 20 | 21 | export default UploadedImage; -------------------------------------------------------------------------------- /face_founder_demo/src/custom.css: -------------------------------------------------------------------------------- 1 | .custom-container { 2 | padding: 15px; 3 | width: 75% !important; 4 | background-color: lightcyan; 5 | } 6 | 7 | .custom-form { 8 | border: 1px solid #fff; 9 | margin-top: 15px; 10 | padding: 15px; 11 | border-radius: 15px; 12 | box-shadow: 0 0 1rem 0 rgba(0, 0, 0, 0.2); 13 | overflow: hidden; 14 | position: relative; 15 | } 16 | 17 | .custom-form::before{ 18 | background-color: rgba(255, 255, 255, 0.3); 19 | backdrop-filter: blur(10px) saturate(100%) contrast(45%) brightness(130%); 20 | content: ''; 21 | height: 100%; 22 | left: 0; 23 | top: 0; 24 | position: absolute; 25 | width: 100%; 26 | } 27 | 28 | .custom-image{ 29 | display: block; 30 | max-width:100%; 31 | width: auto; 32 | height: auto; 33 | margin-top: 15px; 34 | } 35 | 36 | .full-width-image { 37 | width: 100%; 38 | margin-top: 15px; 39 | } 40 | 41 | .uploaded-image{ 42 | width: 200px; 43 | height: 200px; 44 | } 45 | 46 | .custom-logo{ 47 | width: 100px; 48 | height: 100px; 49 | -webkit-animation:spin 2s linear infinite; 50 | -moz-animation:spin 2s linear infinite; 51 | animation:spin 2s linear infinite; 52 | } 53 | 54 | .found-images { 55 | margin-top: 20px; 56 | background: lightcyan; 57 | border: 2px solid lightblue; 58 | font-weight: bold; 59 | padding: 5px; 60 | border-radius: 5px; 61 | } 62 | 63 | .found-images-container { 64 | background-color: lightblue; 65 | padding: '5px'; 66 | border-radius: '3px'; 67 | width: 'fit-content'; 68 | } 69 | 70 | .marginTop-15{ 71 | margin-top: 15px; 72 | } 73 | 74 | .toast-container { 75 | position: absolute; 76 | top: 5px; 77 | right: 37px; 78 | z-index: 1111; 79 | } 80 | 81 | .bigText { 82 | margin-top: 5px; 83 | font-size: large; 84 | font-weight: bold 85 | } 86 | 87 | @-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } } 88 | @-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } } 89 | @keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } } -------------------------------------------------------------------------------- /face_founder_demo/src/image/exadel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exadel-inc/compreface-javascript-sdk/95bcd3e9549075334db608717cbd66502cf94152/face_founder_demo/src/image/exadel.jpg -------------------------------------------------------------------------------- /face_founder_demo/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | import 'bootstrap/dist/css/bootstrap.min.css'; 5 | import 'react-notifications/lib/notifications.css'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | -------------------------------------------------------------------------------- /face_founder_demo/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /functions/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // Collection of common functions that used by almost all services 18 | const common_functions = { 19 | /** 20 | * Construct full url from given parameters 21 | * @returns {String} 22 | */ 23 | get_full_url(base_url, server, port) { 24 | return `${server}:${port}/${base_url}`; 25 | }, 26 | 27 | /** 28 | * Check url 29 | * @param {String} image_url 30 | * @returns {Boolean} 31 | */ 32 | isUrl(image_url){ 33 | // regex to check passed parameter is url or relative path 34 | let urlRegEX = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/; 35 | let isUrl = urlRegEX.test(image_url); 36 | 37 | return isUrl; 38 | }, 39 | 40 | /** 41 | * Check whether string is base64 42 | * @param {String} path 43 | * @returns 44 | */ 45 | isBase64(image_data){ 46 | let base64regex = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/; 47 | let isBase64 = base64regex.test(image_data); 48 | 49 | return isBase64; 50 | }, 51 | 52 | /** 53 | * Check whether string is relative path or not 54 | * @param {String} path 55 | * @returns 56 | */ 57 | isPathRelative(path) { 58 | if(typeof path !== 'string') return false; 59 | let isAbsolute = /^([A-Za-z]:|\.)/.test(path); 60 | 61 | return isAbsolute; 62 | }, 63 | 64 | /** 65 | * Add extra options to url 66 | * @param {String} url 67 | * @param {Object} globalOptions 68 | * @param {Object} localOptions 69 | * @param {Object} required_parameters 70 | * @returns {String} 71 | */ 72 | add_options_to_url(url, globalOptions, localOptions, required_parameters){ 73 | // merge options passed by localy and globally NOTE: global options will override local on if same value passed from both of them 74 | let uniqueOptions = {...localOptions, ...globalOptions}; 75 | let isThereAnyOptions = Object.keys(uniqueOptions); 76 | let isLimitOptionExist = false; 77 | 78 | // check whether any parameters passed 79 | if(isThereAnyOptions.length > 0){ 80 | // check limit parameter passed and it is allowed for particular endpoint (ex: it is not requrid for add()) 81 | if(uniqueOptions['limit'] >= 0 && required_parameters['limit']){ 82 | isLimitOptionExist = true; 83 | url = `${url}?limit=${uniqueOptions['limit']}` 84 | } 85 | 86 | // check det_prob_threshold parameter passed and is it allowed for particular endpoint 87 | if(uniqueOptions['det_prob_threshold'] >= 0 && required_parameters['det_prob_threshold']){ 88 | url = `${url}${isLimitOptionExist ? '&' : '?'}det_prob_threshold=${uniqueOptions['det_prob_threshold']}` 89 | } 90 | 91 | // check prediction_count passed and is it allowed for particular endpoint 92 | if(uniqueOptions['prediction_count'] >= 0 && required_parameters['prediction_count']){ 93 | url = `${url}${isLimitOptionExist ? '&' : '?'}prediction_count=${uniqueOptions['prediction_count']}` 94 | } 95 | 96 | // check face_plugins passed and is it allowed for particular endpoint 97 | if(uniqueOptions['face_plugins'] && required_parameters['face_plugins']){ 98 | url = `${url}${isLimitOptionExist ? '&' : '?'}face_plugins=${uniqueOptions['face_plugins']}` 99 | } 100 | 101 | // check status passed and is it allowed for particular endpoint 102 | if(uniqueOptions['status'] && required_parameters['status']){ 103 | url = `${url}${isLimitOptionExist ? '&' : '?'}status=${uniqueOptions['status']}` 104 | } 105 | } 106 | 107 | return url; 108 | } 109 | } 110 | 111 | export { common_functions } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | import { CompreFace } from './core/compre_face.js'; 17 | 18 | export { CompreFace } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@exadel/compreface-js-sdk", 3 | "version": "1.0.0", 4 | "license": "Apache-2.0", 5 | "description": "JavaScript SDK for CompreFace - free and open-source face recognition system from Exadel", 6 | "main": "index.js", 7 | "type": "module", 8 | "types":"compreface.d.ts", 9 | "scripts": { 10 | "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/exadel-inc/compreface-javascript-sdk.git" 15 | }, 16 | "keywords": [ 17 | "CompreFace", 18 | "Face Recognition", 19 | "Face Detection", 20 | "Face Verification", 21 | "Face Identification", 22 | "Age Recognition", 23 | "Gender Recognition", 24 | "Mask Detection", 25 | "Computer Vision", 26 | "SDK" 27 | ], 28 | "contributors": [ 29 | { 30 | "name": "Dostonbek Oripjonov", 31 | "email": "doripjonov@exadel.com" 32 | }, 33 | { 34 | "name": "Serhii Pospielov", 35 | "email": "spospielov@exadel.com" 36 | }, 37 | { 38 | "name": "Volodymyr Vasko", 39 | "email": "vvasko@exadel.com" 40 | }, 41 | { 42 | "name": "Saba Mchedlidze", 43 | "email": "smchedlidze@exadel.com" 44 | } 45 | ], 46 | "bugs": { 47 | "url": "https://github.com/exadel-inc/compreface-javascript-sdk/issues" 48 | }, 49 | "homepage": "https://exadel.com/solutions/compreface/", 50 | "dependencies": { 51 | "axios": "^0.21.1", 52 | "form-data": "^4.0.0" 53 | }, 54 | "devDependencies": { 55 | "jest": "^26.6.0" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /services/detection_service.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | import { common_functions } from '../functions/index.js'; 17 | import { upload } from '../endpoints/upload.js'; 18 | 19 | class DetectionService { 20 | constructor(server, port, options, key){ 21 | this.server = server; 22 | this.port = port; 23 | this.options = options; 24 | this.key = key; 25 | this.base_url = 'api/v1/detection/detect'; 26 | } 27 | 28 | /** 29 | * Detect faces from given image 30 | * @param {String} image_path 31 | * @param {Object} options 32 | * @returns 33 | */ 34 | detect(image_path, localOptions){ 35 | const { get_full_url, add_options_to_url, isUrl, isPathRelative } = common_functions; 36 | // add_options_to_url() adds this parameter to url if user passes some value as option otherwise function ignores this parameter 37 | let required_url_parameters = { 38 | limit: true, 39 | det_prob_threshold: true, 40 | face_plugins: true, 41 | status: true 42 | }; 43 | let full_url = get_full_url(this.base_url, this.server, this.port) 44 | // add parameters to basic url 45 | let url = add_options_to_url(full_url, this.options, localOptions, required_url_parameters); 46 | 47 | return new Promise((resolve, reject) => { 48 | upload(image_path, url, this.key) 49 | .then(response => { 50 | resolve(response) 51 | }) 52 | .catch(error => { 53 | reject(error) 54 | }) 55 | }) 56 | } 57 | } 58 | 59 | export { DetectionService } -------------------------------------------------------------------------------- /services/recognition_service.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | import { recognition_endpoints } from '../endpoints/recognition_endpoints.js'; 17 | import { common_functions } from '../functions/index.js'; 18 | import { subject_endpoints } from '../endpoints/subject_endpoints.js'; 19 | import { upload } from '../endpoints/upload.js'; 20 | 21 | class RecognitionService { 22 | constructor(server, port, options, key){ 23 | this.server = server; 24 | this.port = port; 25 | this.options = options; 26 | this.key = key; 27 | this.base_url = 'api/v1/recognition/faces'; 28 | this.recognize_base_url = "api/v1/recognition/recognize"; 29 | } 30 | 31 | /** 32 | * Recognize face(s) from given image 33 | * @param {String} image_path 34 | * @returns {Promise} 35 | */ 36 | recognize(image_path, options){ 37 | const{ get_full_url, add_options_to_url, isUrl, isPathRelative } = common_functions; 38 | // add_options_to_url() adds this parameter to url if user passes some value as option otherwise function ignores this parameter 39 | let required_url_parameters = { 40 | limit: true, 41 | det_prob_threshold: true, 42 | prediction_count: true, 43 | face_plugins: true, 44 | status: true 45 | }; 46 | 47 | if (!options.limit) { 48 | options = { ...options, limit: 0 }; 49 | } 50 | 51 | // add parameters to basic url 52 | let full_url = get_full_url(this.recognize_base_url, this.server, this.port) 53 | let url = add_options_to_url(full_url, this.options, options, required_url_parameters); 54 | 55 | return new Promise((resolve, reject) => { 56 | upload(image_path, url, this.key) 57 | .then(response => { 58 | resolve(response) 59 | }) 60 | .catch(error => { 61 | reject(error) 62 | }) 63 | 64 | }) 65 | } 66 | 67 | /** 68 | * Contains functions related to face collection 69 | * @returns {Object} 70 | */ 71 | getFaceCollection(){ 72 | const{ get_full_url, add_options_to_url, isUrl, isPathRelative } = common_functions; 73 | 74 | let url = get_full_url(this.base_url, this.server, this.port) 75 | let key = this.key; 76 | let that = this; 77 | 78 | const faceCollectionFunctions = { 79 | /** 80 | * View the list of images in face collection 81 | * @returns {Promise} 82 | */ 83 | list(){ 84 | return new Promise((resolve, reject) => { 85 | recognition_endpoints.list_request(url, key) 86 | .then(response => { 87 | resolve(response.data) 88 | }) 89 | .catch(error => { 90 | reject(error) 91 | }) 92 | }) 93 | }, 94 | 95 | /** 96 | * Add image (with subject) to face collection 97 | * @param {String} image_path 98 | * @param {String} subject 99 | * @returns {Promise} 100 | */ 101 | add(image_path, subject, options){ 102 | // add_options_to_url() adds this parameter to url if user passes some value as option otherwise function ignores this parameter 103 | let required_url_parameters = { det_prob_threshold: true }; 104 | 105 | // add parameters to basic url 106 | let url = get_full_url(that.base_url, that.server, that.port) 107 | url = `${url}?subject=${subject}` 108 | url = add_options_to_url(url, that.options, options, required_url_parameters); 109 | 110 | return new Promise((resolve, reject) => { 111 | upload(image_path, url, key) 112 | .then(response => { 113 | resolve(response) 114 | }) 115 | .catch(error => { 116 | reject(error) 117 | }) 118 | }) 119 | }, 120 | 121 | /** 122 | * Verify face from image 123 | * @param {String} image_path 124 | * @param {String} image_id 125 | * @returns {Promise} 126 | */ 127 | verify(image_path, image_id, options){ 128 | // add_options_to_url() adds this parameter to url if user passes some value as option otherwise function ignores this parameter 129 | let required_url_parameters = { 130 | limit: true, 131 | det_prob_threshold: true, 132 | face_plugins: true, 133 | status: true 134 | }; 135 | // add parameters to basic url 136 | url = `${url}/${image_id}/verify`; 137 | url = add_options_to_url(url, that.options, options, required_url_parameters); 138 | 139 | return new Promise((resolve, reject) => { 140 | upload(image_path, url, key) 141 | .then(response => { 142 | resolve(response) 143 | }) 144 | .catch(error => { 145 | reject(error) 146 | }) 147 | }) 148 | }, 149 | 150 | /** 151 | * Delete image by id 152 | * @param {String} image_id 153 | * @returns {Promise} 154 | */ 155 | delete(image_id){ 156 | url = `${url}/${image_id}`; 157 | 158 | return new Promise((resolve, reject) => { 159 | recognition_endpoints.delete_request(url, key,) 160 | .then(response => { 161 | resolve(response.data); 162 | }) 163 | .catch(error => { 164 | reject(error); 165 | }) 166 | }) 167 | }, 168 | 169 | /** 170 | * Delete multiple images 171 | * @param {String[]} image_ids 172 | * @returns {Promise} 173 | */ 174 | delete_multiple_images(image_ids) { 175 | url = `${url}/delete`; 176 | 177 | return new Promise((resolve, reject) => { 178 | recognition_endpoints.delete_multiple(url, key, image_ids) 179 | .then((response) => { 180 | resolve(response.data); 181 | }) 182 | .catch((error) => { 183 | reject(error); 184 | }); 185 | }); 186 | }, 187 | 188 | /** 189 | * Delete image by subject 190 | * @param {String} subject 191 | * @returns {Promise} 192 | */ 193 | delete_all_subject(subject){ 194 | url = `${url}?subject=${subject}`; 195 | 196 | return new Promise((resolve, reject) => { 197 | recognition_endpoints.delete_request(url, key) 198 | .then(response => { 199 | resolve(response.data); 200 | }) 201 | .catch(error => { 202 | reject(error); 203 | }) 204 | }) 205 | }, 206 | 207 | /** 208 | * Delete all images in face collection 209 | * @returns {Promise} 210 | */ 211 | delete_all(){ 212 | return new Promise((resolve, reject) => { 213 | recognition_endpoints.delete_request(url, key) 214 | .then(response => { 215 | resolve(response.data); 216 | }) 217 | .catch(error => { 218 | reject(error); 219 | }) 220 | }) 221 | } 222 | } 223 | 224 | return faceCollectionFunctions; 225 | } 226 | 227 | getSubjects(){ 228 | const { get_full_url } = common_functions; 229 | const { list, add, rename, deleteSubject } = subject_endpoints; 230 | 231 | let base_subject_url = this.base_url.replace('faces', 'subjects'); 232 | let url = get_full_url(base_subject_url, this.server, this.port) 233 | let key = this.key; 234 | 235 | const subjectFunctions = { 236 | /** 237 | * List the subjects 238 | * @returns {Promise} 239 | */ 240 | list(){ 241 | return new Promise((resolve, reject) => { 242 | list(url, key) 243 | .then(response => { 244 | resolve(response.data) 245 | }) 246 | .catch(error => { 247 | reject(error) 248 | }) 249 | }) 250 | }, 251 | 252 | /** 253 | * Add subject 254 | * @param {String} subject 255 | * @returns {Promise} 256 | */ 257 | add(subject){ 258 | return new Promise((resolve, reject) => { 259 | add(subject, url, key) 260 | .then(response => { 261 | resolve(response.data) 262 | }) 263 | .catch(error => { 264 | reject(error) 265 | }) 266 | }) 267 | }, 268 | 269 | /** 270 | * Rename the subject 271 | * @param {String} presentSubjectName 272 | * @param {String} newSubjectName 273 | * @returns {Promise} 274 | */ 275 | rename(presentSubjectName, newSubjectName ){ 276 | url = `${url}/${presentSubjectName}` 277 | return new Promise((resolve, reject) => { 278 | rename(newSubjectName, url, key) 279 | .then(response => { 280 | resolve(response.data) 281 | }) 282 | .catch(error => { 283 | reject(error) 284 | }) 285 | }) 286 | }, 287 | 288 | /** 289 | * Delete a subject 290 | * @param {String} subject 291 | * @returns {Promise} 292 | */ 293 | delete(subject){ 294 | url = `${url}/${subject}` 295 | return new Promise((resolve, reject) => { 296 | deleteSubject(url, key) 297 | .then(response => { 298 | resolve(response.data) 299 | }) 300 | .catch(error => { 301 | reject(error) 302 | }) 303 | }) 304 | }, 305 | 306 | /** 307 | * Delete all subject 308 | * @param {String} subject 309 | * @returns {Promise} 310 | */ 311 | deleteAll(){ 312 | return new Promise((resolve, reject) => { 313 | deleteSubject(url, key) 314 | .then(response => { 315 | resolve(response.data) 316 | }) 317 | .catch(error => { 318 | reject(error) 319 | }) 320 | }) 321 | }, 322 | } 323 | 324 | return subjectFunctions; 325 | } 326 | } 327 | 328 | export { RecognitionService } -------------------------------------------------------------------------------- /services/verification_service.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 the original author or authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | import { verification_endpoints } from '../endpoints/verification_endpoints.js' 18 | import { common_functions } from '../functions/index.js'; 19 | 20 | class VerificationService { 21 | constructor(server, port, options, key){ 22 | this.server = server; 23 | this.port = port; 24 | this.options = options; 25 | this.key = key; 26 | this.base_url = 'api/v1/verification/verify'; 27 | } 28 | 29 | verify(source_image_path, target_image_path, options){ 30 | const { get_full_url, add_options_to_url, isUrl, isPathRelative, isBase64 } = common_functions; 31 | // add extra parameter(s) name with true value if it is referenced in API documentation for particular endpoint 32 | // add_options_to_url() adds this parameter to url if user passes some value as option otherwise function ignores this parameter 33 | let required_url_parameters = { 34 | limit: true, 35 | det_prob_threshold: true, 36 | face_plugins: true, 37 | status: true 38 | }; 39 | 40 | let full_url = get_full_url(this.base_url, this.server, this.port) 41 | // add parameters to basic url 42 | let url = add_options_to_url(full_url, this.options, options, required_url_parameters); 43 | 44 | let isSourceImageUrl = isUrl(source_image_path); 45 | let isTargetImageUrl = isUrl(target_image_path); 46 | 47 | let isSourceRelativePath = isPathRelative(source_image_path); 48 | let isTargetRelativePath = isPathRelative(target_image_path); 49 | 50 | let isSourceBase64 = isBase64(source_image_path); 51 | let isTargetBase64 = isBase64(target_image_path); 52 | 53 | return new Promise((resolve, reject) => { 54 | if(isSourceImageUrl){ 55 | if(isTargetImageUrl){ 56 | verification_endpoints.both_url_request(source_image_path, target_image_path, url, this.key) 57 | .then(response => { 58 | resolve(response.data) 59 | }) 60 | .catch(error => { 61 | reject(error) 62 | }) 63 | }else if(isTargetRelativePath){ 64 | verification_endpoints.one_url_request(source_image_path, isSourceImageUrl, target_image_path, url, this.key) 65 | .then(response => { 66 | resolve(response.data) 67 | }) 68 | .catch(error => { 69 | reject(error) 70 | }) 71 | }else { 72 | verification_endpoints.url_blob_request(source_image_path, isSourceImageUrl, target_image_path, url, this.key) 73 | .then(response => { 74 | resolve(response.data) 75 | }) 76 | .catch(error => { 77 | reject(error) 78 | }) 79 | } 80 | }else if(isSourceRelativePath){ 81 | if(isTargetImageUrl){ 82 | console.log("hey I'm here", isSourceImageUrl) 83 | verification_endpoints.one_url_request(source_image_path, isSourceImageUrl, target_image_path, url, this.key) 84 | .then(response => { 85 | resolve(response.data) 86 | }) 87 | .catch(error => { 88 | reject(error) 89 | }) 90 | }else if(isTargetRelativePath){ 91 | verification_endpoints.verify_face_request(source_image_path, target_image_path, url, this.key) 92 | .then(response => { 93 | resolve(response.data) 94 | }) 95 | .catch(error => { 96 | reject(error) 97 | }) 98 | }else { 99 | verification_endpoints.one_blob_request(source_image_path, false, target_image_path, url, this.key) 100 | .then(response => { 101 | resolve(response.data) 102 | }) 103 | .catch(error => { 104 | reject(error) 105 | }) 106 | } 107 | }else if(isSourceBase64){ 108 | verification_endpoints.base64_request(source_image_path, target_image_path, url, this.key) 109 | .then(response => { 110 | resolve(response.data) 111 | }) 112 | .catch(error => { 113 | reject(error) 114 | }) 115 | }else { 116 | if(isTargetImageUrl){ 117 | verification_endpoints.url_blob_request(source_image_path, isSourceImageUrl, target_image_path, url, this.key) 118 | .then(response => { 119 | resolve(response.data) 120 | }) 121 | .catch(error => { 122 | reject(error) 123 | }) 124 | }else if(isTargetRelativePath){ 125 | verification_endpoints.one_blob_request(source_image_path, true, target_image_path, url, this.key) 126 | .then(response => { 127 | resolve(response.data) 128 | }) 129 | .catch(error => { 130 | reject(error) 131 | }) 132 | }else { 133 | verification_endpoints.both_blob_request(source_image_path, target_image_path, url, this.key) 134 | .then(response => { 135 | resolve(response.data) 136 | }) 137 | .catch(error => { 138 | reject(error) 139 | }) 140 | } 141 | } 142 | }) 143 | } 144 | } 145 | 146 | export { VerificationService } -------------------------------------------------------------------------------- /webcam_demo/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /webcam_demo/README.md: -------------------------------------------------------------------------------- 1 | # Webcam Demo 2 | 3 | In this documentation we show how to use our detection service with webcamera. **NOTE:** we have chosen reactjs as it is today's one of the most popular UI library. 4 | 5 | 1. Clone our repository 6 | 2. Enter to ```webcam_demo``` folder and install packages 7 | 8 | ``` cd webcam_demo``` 9 | 10 | ```npm install``` 11 | 12 | 3. Change detection API key inside ```src > App.js``` line ```40``` 13 | 14 | 4. Start project 15 | 16 | ```npm start``` 17 | 18 | 5. Click ```video start``` button to start your webcamera 19 | 20 | *OR follow below instructions to create project by yourself* 21 | 22 | 1. Install reactjs 23 | 24 | ```npx create-react-app compreface-demo``` 25 | 26 | 2. Enter to project folder 27 | 28 | ```cd compreface-demo``` 29 | 30 | 3. Install CompreFace SDK 31 | 32 | ```npm i @exadel/compreface-js-sdk``` 33 | 34 | 4. Create your component and copy/past following code. NOTE: We have used functional component and video tag used to connect to your webcamera and canvas tags used for drawing square and some extra data. 35 | 36 | ``` 37 | import { useRef } from 'react' 38 | import { CompreFace } from '@exadel/compreface-js-sdk'; 39 | 40 | function App() { 41 | const videoTag = useRef(null); 42 | const canvas1 = useRef(null); 43 | const canvas2 = useRef(null); 44 | const canvas3 = useRef(null); 45 | 46 | const handleVideoStart = () => { 47 | console.log("Click is working") 48 | } 49 | 50 | return ( 51 |
52 | 53 | 54 | 55 | 56 | 57 |
58 | 59 |
60 |
61 | ); 62 | } 63 | 64 | export default App; 65 | ``` 66 | 67 | 5. Add ability to start webcamera when user clicks "Start video" button. Put following code into ```handleVideoStart()``` function. ```Navigator.mediaDevices``` is built in read-only property of browser which enables user to access webcamera. 68 | 69 | ``` 70 | navigator.mediaDevices.getUserMedia({ video: true}) 71 | .then(stream => videoTag.current.srcObject = stream) 72 | .catch( error => console.error(error) ) 73 | ``` 74 | 75 | 6. Initialize CompreFace instances and catch video event which fired when webcamera starts working. Your code should look like as following example. ```Play``` event listener fires when webcamera starts working and this is place where we need to use CompreFace SDK. NOTE: ```next_frame``` custom event created in order to create kind of recursion effect when we drawing square on face. 76 | ``` 77 | import { useRef } from 'react' 78 | import { CompreFace } from '@exadel/compreface-js-sdk'; 79 | 80 | function App() { 81 | const videoTag = useRef(null); 82 | const canvas1 = useRef(null); 83 | const canvas2 = useRef(null); 84 | const canvas3 = useRef(null); 85 | 86 | const handleVideoStart = () => { 87 | navigator.mediaDevices.getUserMedia({ video: true}) 88 | .then(stream => videoTag.current.srcObject = stream) 89 | .catch( error => console.error(error) ) 90 | 91 | videoTag.current.addEventListener('play', () => { 92 | // CompreFace init 93 | let server = "http://localhost"; 94 | let port = 8000; 95 | let detection_key = "your_api_key_for_detection_service"; 96 | 97 | let core = new CompreFace(server, port); 98 | let detection_service = core.initFaceDetectionService(detection_key); 99 | // end of CompreFace init 100 | 101 | let ctx1 = canvas1.current.getContext('2d'); 102 | let ctx2 = canvas2.current.getContext('2d'); 103 | let ctx3 = canvas3.current.getContext("2d"); 104 | 105 | document.addEventListener('next_frame', () => { 106 | ctx1.drawImage(videoTag.current, 0, 0, 640, 480) 107 | canvas1.current.toBlob( blob => { 108 | detection_service.detect(blob, { limit: 1, face_plugins: 'age,gender' }) 109 | .then(res => { 110 | /** 111 | 112 | We need call draw function which draws square on face of user in front of webcamera 113 | 114 | */ 115 | }) 116 | .catch(error => console.log(error)) 117 | }, 'image/jpeg', 0.95) 118 | }) 119 | 120 | const evt = new Event("next_frame", {"bubbles":true, "cancelable":false}); 121 | document.dispatchEvent(evt); 122 | }) 123 | } 124 | 125 | return ( 126 |
127 | 128 | 129 | 130 | 131 | 132 |
133 | 134 |
135 |
136 | ); 137 | } 138 | 139 | export default App; 140 | ``` 141 | 142 | 7. Add draw function. NOTE: You can extra canvas elemets which shows extra info related to detected face. 143 | 144 | ``` 145 | const drawFace = (canvasElement, faceData, extraCanvas) => { 146 | const evt = new Event("next_frame", {"bubbles":true, "cancelable":false}); 147 | document.dispatchEvent(evt); 148 | let box = faceData.result[0].box; 149 | 150 | canvasElement.clearRect(0, 0, 640, 480); 151 | extraCanvas.clearRect(0, 0, 640, 480); 152 | 153 | canvasElement.strokeStyle = 'green'; 154 | extraCanvas.strokeStyle = "blue"; 155 | extraCanvas.fillStyle = "white" 156 | 157 | extraCanvas.lineWidth = 5; 158 | canvasElement.lineWidth = 5; 159 | 160 | canvasElement.strokeRect(box.x_min, box.y_min, box.x_max - box.x_min, box.y_max - box.y_min); 161 | extraCanvas.fillText( Number.parseFloat(box.probability).toPrecision(5) + ' ' + faceData.result[0].gender + ' ' + faceData.result[0].age[0] + '-' + faceData.result[0].age[1], box.x_min, box.y_min - 10) 162 | } 163 | ``` 164 | 165 | 8. Final code should look like this. 166 | 167 | ``` 168 | import { useRef } from 'react' 169 | import { CompreFace } from '@exadel/compreface-js-sdk'; 170 | 171 | function App() { 172 | const videoTag = useRef(null); 173 | const canvas1 = useRef(null); 174 | const canvas2 = useRef(null); 175 | const canvas3 = useRef(null); 176 | 177 | const drawFace = (canvasElement, faceData, extraCanvas) => { 178 | const evt = new Event("next_frame", {"bubbles":true, "cancelable":false}); 179 | document.dispatchEvent(evt); 180 | let box = faceData.result[0].box; 181 | 182 | canvasElement.clearRect(0, 0, 640, 480); 183 | extraCanvas.clearRect(0, 0, 640, 480); 184 | 185 | canvasElement.strokeStyle = 'green'; 186 | extraCanvas.strokeStyle = "blue"; 187 | extraCanvas.fillStyle = "white" 188 | 189 | extraCanvas.lineWidth = 5; 190 | canvasElement.lineWidth = 5; 191 | 192 | canvasElement.strokeRect(box.x_min, box.y_min, box.x_max - box.x_min, box.y_max - box.y_min); 193 | extraCanvas.fillText( Number.parseFloat(box.probability).toPrecision(5) + ' ' + faceData.result[0].gender + ' ' + faceData.result[0].age[0] + '-' + faceData.result[0].age[1], box.x_min, box.y_min - 10) 194 | } 195 | 196 | const handleVideoStart = () => { 197 | navigator.mediaDevices.getUserMedia({ video: true}) 198 | .then(stream => videoTag.current.srcObject = stream) 199 | .catch( error => console.error(error) ) 200 | 201 | videoTag.current.addEventListener('play', () => { 202 | // CompreFace init 203 | let server = "http://localhost"; 204 | let port = 8000; 205 | let detection_key = "your_api_key_for_detection_service"; 206 | 207 | let core = new CompreFace(server, port); 208 | let detection_service = core.initFaceDetectionService(detection_key); 209 | // end of CompreFace init 210 | 211 | let ctx1 = canvas1.current.getContext('2d'); 212 | let ctx2 = canvas2.current.getContext('2d'); 213 | let ctx3 = canvas3.current.getContext("2d"); 214 | 215 | document.addEventListener('next_frame', () => { 216 | ctx1.drawImage(videoTag.current, 0, 0, 640, 480) 217 | canvas1.current.toBlob( blob => { 218 | detection_service.detect(blob, { limit: 1, face_plugins: 'age,gender' }) 219 | .then(res => { 220 | drawFace(ctx2, res, ctx3) 221 | }) 222 | .catch(error => console.log(error)) 223 | }, 'image/jpeg', 0.95) 224 | }) 225 | 226 | const evt = new Event("next_frame", {"bubbles":true, "cancelable":false}); 227 | document.dispatchEvent(evt); 228 | }) 229 | } 230 | 231 | return ( 232 |
233 | 234 | 235 | 236 | 237 | 238 |
239 | 240 |
241 |
242 | ); 243 | } 244 | 245 | export default App; 246 | ``` 247 | -------------------------------------------------------------------------------- /webcam_demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webcam-tutorial", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@exadel/compreface-js-sdk": "^1.0.0", 7 | "@testing-library/jest-dom": "^5.11.4", 8 | "@testing-library/react": "^11.1.0", 9 | "@testing-library/user-event": "^12.1.10", 10 | "react": "^17.0.2", 11 | "react-dom": "^17.0.2", 12 | "react-scripts": "4.0.3", 13 | "web-vitals": "^1.0.1" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "test": "react-scripts test", 19 | "eject": "react-scripts eject" 20 | }, 21 | "eslintConfig": { 22 | "extends": [ 23 | "react-app", 24 | "react-app/jest" 25 | ] 26 | }, 27 | "browserslist": { 28 | "production": [ 29 | ">0.2%", 30 | "not dead", 31 | "not op_mini all" 32 | ], 33 | "development": [ 34 | "last 1 chrome version", 35 | "last 1 firefox version", 36 | "last 1 safari version" 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /webcam_demo/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exadel-inc/compreface-javascript-sdk/95bcd3e9549075334db608717cbd66502cf94152/webcam_demo/public/favicon.ico -------------------------------------------------------------------------------- /webcam_demo/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /webcam_demo/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exadel-inc/compreface-javascript-sdk/95bcd3e9549075334db608717cbd66502cf94152/webcam_demo/public/logo192.png -------------------------------------------------------------------------------- /webcam_demo/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exadel-inc/compreface-javascript-sdk/95bcd3e9549075334db608717cbd66502cf94152/webcam_demo/public/logo512.png -------------------------------------------------------------------------------- /webcam_demo/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /webcam_demo/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /webcam_demo/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /webcam_demo/src/App.js: -------------------------------------------------------------------------------- 1 | import { useRef } from 'react' 2 | import { CompreFace } from '@exadel/compreface-js-sdk'; 3 | import './App.css'; 4 | 5 | function App() { 6 | const videoTag = useRef(null); 7 | const canvas1 = useRef(null); 8 | const canvas2 = useRef(null); 9 | const canvas3 = useRef(null); 10 | 11 | const drawFace = (canvasElement, faceData, extraCanvas) => { 12 | const evt = new Event("next_frame", {"bubbles":true, "cancelable":false}); 13 | document.dispatchEvent(evt); 14 | let box = faceData.result[0].box; 15 | 16 | canvasElement.clearRect(0, 0, 640, 480); 17 | extraCanvas.clearRect(0, 0, 640, 480); 18 | 19 | canvasElement.strokeStyle = 'green'; 20 | extraCanvas.strokeStyle = "blue"; 21 | extraCanvas.fillStyle = "white" 22 | 23 | extraCanvas.lineWidth = 5; 24 | canvasElement.lineWidth = 5; 25 | 26 | canvasElement.strokeRect(box.x_min, box.y_min, box.x_max - box.x_min, box.y_max - box.y_min); 27 | extraCanvas.fillText( Number.parseFloat(box.probability).toPrecision(5) + ' ' + faceData.result[0].gender.value + ' ' + faceData.result[0].age.low + '-' + faceData.result[0].age.high, box.x_min, box.y_min - 10) 28 | 29 | } 30 | 31 | const handleVideoStart = () => { 32 | navigator.mediaDevices.getUserMedia({ video: true}) 33 | .then(stream => videoTag.current.srcObject = stream) 34 | .catch( error => console.error(error) ) 35 | 36 | videoTag.current.addEventListener('play', () => { 37 | // CompreFace init 38 | let server = "http://localhost"; 39 | let port = 8000; 40 | let detection_key = "00000000-0000-0000-0000-000000000003"; 41 | 42 | let core = new CompreFace(server, port); 43 | let detection_service = core.initFaceDetectionService(detection_key); 44 | // end of CompreFace init 45 | 46 | let ctx1 = canvas1.current.getContext('2d'); 47 | let ctx2 = canvas2.current.getContext('2d'); 48 | let ctx3 = canvas3.current.getContext("2d"); 49 | 50 | document.addEventListener('next_frame', () => { 51 | ctx1.drawImage(videoTag.current, 0, 0, 640, 480) 52 | canvas1.current.toBlob( blob => { 53 | detection_service.detect(blob, { limit: 1, face_plugins: 'age,gender' }) 54 | .then(res => { 55 | drawFace(ctx2, res, ctx3) 56 | }) 57 | .catch(error => console.log(error)) 58 | }, 'image/jpeg', 0.95) 59 | }) 60 | 61 | const evt = new Event("next_frame", {"bubbles":true, "cancelable":false}); 62 | document.dispatchEvent(evt); 63 | }) 64 | } 65 | 66 | return ( 67 |
68 |
69 | 70 | 71 | 72 | 73 | 74 |
75 | 76 |
77 | 78 |
79 |
80 | ); 81 | } 82 | 83 | export default App; 84 | -------------------------------------------------------------------------------- /webcam_demo/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render( 6 | 7 | 8 | , 9 | document.getElementById('root') 10 | ); 11 | --------------------------------------------------------------------------------