-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.html
143 lines (133 loc) · 6.71 KB
/
result.html
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="result.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script language = "javascript">
function formatScore(score){
var result = Math.round(score*1000);
//result = result * 100;
result = result/10 + "%";
return result;
}
$.ajax({
url: "http://localhost:28017/test/images/",
type: "GET",
crossDomain: 'true',
dataType: 'jsonp',
jsonp: 'jsonp'
})
.done (function(json) {
//json = JSON.parse(data);
$.each(json.rows, function(i, pic) {
rowid = "row" + i
row = $("#output").append("<div class='row-container'><div class='row' id='"+rowid+"'></div></div>");
$("#"+rowid).append("<div class='imagebox'><img src='"+pic.filename+"' /></div>");
$("#"+rowid).append("<div class='results'>");
//watson data
$("#"+rowid+"> .results").append("<div class='result col span_1_of_3 watson' id='watson"+rowid+"'></div>");
$("#watson"+rowid).append("<h1>IBM Watson</h1>");
$("#watson"+rowid).append("<h2>Tags</h2><ul class='tags'></ul>");
$.each(pic.watson.tags, function(n, word) {
paraid = "watsontag" + i + "-" + n;
$("#watson"+rowid+"> .tags").append("<li id='"+paraid+"'></li>");
$("#"+paraid).append(word.name + " : " + formatScore(word.score));
});
//msft data
$("#"+rowid+"> .results").append("<div class='result col span_1_of_3 msft' id='msft"+rowid+"'></div>");
$("#msft"+rowid).append("<h1>Microsoft</h1>");
$("#msft"+rowid).append("<h2>Tags</h2><ul class='tags'></ul>");
$.each(pic.msft.tags, function(n, word) {
paraid = "msfttag" + i + "-" + n;
$("#msft"+rowid+"> .tags").append("<li id='"+paraid+"'></li>");
$("#"+paraid).append(word.name + " : " + formatScore(word.score));
});
$("#msft"+rowid).append("<h2>Colors</h2><div class='colorlist'></div>");
$.each(pic.msft.colors, function(n, col) {
paraid = "msftcolor" + i + "-" + n;
$("#msft"+rowid+"> .colorlist").append("<div class='colorblock' id='"+paraid+"'></div>");
$("#"+paraid).css("background-color", col.color);
var bgcolor = '0x' + col.color.slice(1);
var textcolor = ('000000' + (('0xffffff' ^ bgcolor).toString(16))).slice(-6);
$("#"+paraid).css("color", "#"+textcolor);
$("#"+paraid).append("<span>"+formatScore(col.score)+"</span>");
});
$("#msft"+rowid).append("<h2>Adult</h2><ul class='adultresults'></ul>");
$.each(pic.msft.adult, function(key, value){
paraid = "msftadult" + i + '-' + key;
$("#msft"+rowid+"> .adultresults").append("<li id='"+paraid+"'></li>");
if((typeof value === 'boolean') || isNaN(value)){
$("#"+paraid).append(key +" : "+value);
}
else{
$("#"+paraid).append(key +" : "+formatScore(value));
}
});
$("#msft"+rowid).append("<h2>Caption</h2><ul class='captions'></ul>");
$.each(pic.msft.captions, function(n, blob){
paraid = "msfttext" + i + '-' + n;
$("#msft"+rowid + "> .captions").append("<li id='"+paraid+"'></li>");
$("#"+paraid).append(blob.text +" : "+formatScore(blob.score));
});
//to do: bounding boxes on faces
$("#msft"+rowid).append("<h2>People</h2><ul class='people'></ul>");
$.each(pic.msft.people, function(n, blob){
paraid = "msftperson" + i + '-' + n;
$("#msft"+rowid + "> .people").append("<li id='"+paraid+"'></li>");
$("#"+paraid).append(blob.name +" : "+formatScore(blob.confidence));
});
if(pic.msft.people < 1){ $("#msft"+rowid + "> .people").append("<li id='"+paraid+"'>No people found</li>"); }
//google data
$("#"+rowid+"> .results").append("<div class='result col span_1_of_3 google' id='google"+rowid+"'></div>");
$("#google"+rowid).append("<h1>Google</h1>");
$("#google"+rowid).append("<h2>Tags</h2><ul class='tags'></ul>");
$.each(pic.google.tags, function(n, word) {
paraid = "googlepara" + i + "-" + n;
$("#google"+rowid +"> .tags").append("<li id='"+paraid+"'></li>");
$("#"+paraid).append(word.name + " : " + formatScore(word.score));
});
$("#google"+rowid).append("<h2>Colors</h2><div class='colorlist'></div>");
$.each(pic.google.colors, function(n, col) {
paraid = "googlecolor" + i + "-" + n;
$("#google"+rowid+"> .colorlist").append("<div class='colorblock' id='"+paraid+"'></div>");
$("#"+paraid).css("background-color", col.color);
var bgcolor = '0x' + col.color.slice(1);
var textcolor = ('000000' + (('0xffffff' ^ bgcolor).toString(16))).slice(-6);
$("#"+paraid).css("color", "#"+textcolor);
$("#"+paraid).append("<span>"+formatScore(col.score)+"</span>");
});
$("#google"+rowid).append("<h2>Adult</h2><ul class='adultresults'></ul>");
$.each(pic.google.adult, function(key, value){
paraid = "googleadult" + i + '-' + key;
$("#google"+rowid +"> .adultresults").append("<li id='"+paraid+"'></li>");
if(isNaN(value)){
$("#"+paraid).append(key +" : "+value);
}
else{
$("#"+paraid).append(key +" : "+formatScore(value));
}
});
$("#google"+rowid).append("<h2>Text</h2><div class='googletext'></div>");
$.each(pic.google.text, function(n, blob){
paraid = "googletext" + i + '-' + n;
if (blob.locale) {
//todo: bounding boxes on text
$("#google"+rowid+"> .googletext").append("<p id='"+paraid+"'>");
$("#"+paraid).append(blob.text +"["+blob.locale+"]");
}
});
if(pic.google.text < 1){ $("#google"+rowid+"> .googletext").append("<p id='"+paraid+"'>No text found</p>"); }
});
});
</script>
</head>
<body>
<div id="output">
<div class="row-container"><div class="row">
<h1 class="title">Computer Vision API Comparison</h1>
<p>This project shows the different capabilities and responses of Google, Microsoft, and IBM Watson's vision APIs.</p>
</div>
</div>
</div>
</body>
</html>