Skip to content

Commit 36f781b

Browse files
authored
Merge pull request #9 from exadel-inc/sdk-0.5.1
Sdk 0.5.1
2 parents cc71d41 + 85fe04f commit 36f781b

38 files changed

+2042
-217
lines changed

README.md

+20-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ CompreFace JavaScript SDK makes face recognition into your application even easi
99
- [Initialization](#initialization)
1010
- [Adding faces into a face collection](#adding-faces-into-a-face-collection)
1111
- [Recognition](#recognition)
12+
- [Enviroments](#enviroments)
13+
- [Webcam demo](#webcam-demo)
1214
- [Reference](#reference)
1315
- [CompreFace Global Object](#compreface-global-object)
1416
- [Recognition Service](#recognition-service)
@@ -36,7 +38,7 @@ Before using our SDK make sure you have installed CompreFace and Nodejs on your
3638
| CompreFace JS SDK version | CompreFace 0.4.x | CompreFace 0.5.x |
3739
| --------------------------| ---------------- | ---------------- |
3840
| 0.4.1 |||
39-
| 0.5.0 |||
41+
| 0.5.x |||
4042

4143
## Installation
4244
To add CompreFace JS SDK to your project, run the following command in the project folder:
@@ -102,6 +104,17 @@ recognitionService.recognize(path_to_image)
102104
})
103105
```
104106

107+
### Enviroments
108+
NOTE: We provide 3 ways of uploading image to our SDK. They are url, blob and relative path (from local machine).
109+
110+
| Enviroments | from URL | with Blob format | from local machine|
111+
| ------------|--------- | ---------------- | ---------------- |
112+
| Browser ||||
113+
| Nodejs ||||
114+
115+
### Webcam demo
116+
[Documentation is here](/webcam_demo)
117+
105118
## Reference
106119

107120
### CompreFace Global Object
@@ -209,7 +222,7 @@ The first argument is the image location, it could be a URL or a path on the loc
209222

210223
| Argument | Type | Required | Notes |
211224
| --------------- | ------ | -------- | ----------------------------------------- |
212-
| image_location | string | required | URL or local machine path to the image you want to recognize |
225+
| image_location | string | required | URL, image in BLOB format or image from your local machine|
213226
| options | string | optional | Object that defines recognition options |
214227

215228
Supported options:
@@ -315,7 +328,7 @@ Adds an image to your face collection.
315328

316329
| Argument | Type | Required | Notes |
317330
| --------------- | ------ | -------- | ----------------------------------------- |
318-
| image_location | string | required | URL or local machine path to the image you want to add to face collection |
331+
| image_location | string | required | URL, image in BLOB format or image from your local machine |
319332
| subject | string | required | Name or any other person ID. It can be just a random string you generate and save for further identification |
320333
| options | string | optional | Object that defines adding options |
321334

@@ -481,7 +494,7 @@ Compares similarities of given image with image from your face collection.
481494

482495
| Argument | Type | Required | Notes |
483496
| --------------- | ------ | -------- | ----------------------------------------- |
484-
| image_location | string | required | URL or local machine path to the image you want to recognize |
497+
| image_location | string | required | URL, image in BLOB format or image from your local machine |
485498
| options | string | optional | Object that defines recognition options |
486499

487500
Supported options:
@@ -576,7 +589,7 @@ The first argument is the image location, it could be a URL or a path on the loc
576589

577590
| Argument | Type | Required | Notes |
578591
| --------------- | ------ | -------- | ----------------------------------------- |
579-
| image_location | string | required | URL or local machine path to the image you want to recognize |
592+
| image_location | string | required | URL, image in BLOB format or image from your local machine |
580593
| options | string | optional | Object that defines detection options |
581594

582595
Supported options:
@@ -667,8 +680,8 @@ The first two arguments are the image location, it could be a URL or a path on t
667680

668681
| Argument | Type | Required | Notes |
669682
| ---------------------- | ------ | -------- | ----------------------------------------- |
670-
| source_image_location | string | required | URL or local machine path to the source image you want to compare |
671-
| target_image_location | string | required | URL or local machine path to the target image you want to compare |
683+
| source_image_location | string | required | URL, source image in BLOB format or source image from your local machine |
684+
| target_image_location | string | required | URL, target image in BLOB format or target image from your local machine |
672685
| options | string | optional | Object that defines detection options |
673686

674687
Supported options:

__tests__/add_options_to_url.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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__/get_full_url.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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__/isPathRelative.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
})

coverage/clover.xml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<coverage generated="1621495096365" clover="3.2.0">
3+
<project timestamp="1621495096365" name="All files">
4+
<metrics statements="22" coveredstatements="22" conditionals="24" coveredconditionals="17" methods="4" coveredmethods="4" elements="50" coveredelements="43" complexity="0" loc="22" ncloc="22" packages="1" files="1" classes="1"/>
5+
<file name="index.js" path="D:\Exadel\Compare Face\compreface-javascript-sdk\functions\index.js">
6+
<metrics statements="22" coveredstatements="22" conditionals="24" coveredconditionals="17" methods="4" coveredmethods="4"/>
7+
<line num="18" count="4" type="stmt"/>
8+
<line num="24" count="1" type="stmt"/>
9+
<line num="34" count="1" type="stmt"/>
10+
<line num="35" count="1" type="stmt"/>
11+
<line num="37" count="1" type="stmt"/>
12+
<line num="46" count="1" type="cond" truecount="1" falsecount="1"/>
13+
<line num="47" count="1" type="stmt"/>
14+
<line num="48" count="1" type="stmt"/>
15+
<line num="61" count="1" type="stmt"/>
16+
<line num="62" count="1" type="stmt"/>
17+
<line num="65" count="1" type="cond" truecount="1" falsecount="1"/>
18+
<line num="67" count="1" type="cond" truecount="3" falsecount="1"/>
19+
<line num="68" count="1" type="stmt"/>
20+
<line num="72" count="1" type="cond" truecount="3" falsecount="1"/>
21+
<line num="73" count="1" type="stmt"/>
22+
<line num="77" count="1" type="cond" truecount="3" falsecount="1"/>
23+
<line num="78" count="1" type="stmt"/>
24+
<line num="82" count="1" type="cond" truecount="3" falsecount="1"/>
25+
<line num="83" count="1" type="stmt"/>
26+
<line num="87" count="1" type="cond" truecount="3" falsecount="1"/>
27+
<line num="88" count="1" type="stmt"/>
28+
<line num="92" count="1" type="stmt"/>
29+
</file>
30+
</project>
31+
</coverage>

coverage/coverage-final.json

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"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"}
2+
}

coverage/lcov-report/base.css

+224
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
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+
}

0 commit comments

Comments
 (0)