-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalgo-scratch-pad.txt
238 lines (172 loc) · 5.71 KB
/
algo-scratch-pad.txt
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
Architecture idea for V2
-------------------------------
Local built in server :
remote server
* History
* Data sync : high res photo, low res photo, points, scores, times, session
* View sync :
* all : update photo and score display, browse history, start new photo
* 2 way commands :
* push : on event, source device -> HTTP POST target device.
* query : on event or timer, target device -> HTTP POST source device
* example use case :
* web browser query directly the android VotAR device (like current version)
* VotAR android device upload to a VotAR server, then live web browser query the server or LMS query the server to integrate onto course content.
-------------------------------
-----------------------------------------------------
COMPUTATIONS
------------------------------------------
Formula to compute hue difference : primary component part
first formula:
--------------------------
diff=weak/csum;
80 | 20 | 40 ... 140
diff1 = 40/140 = 0.28
80 | 40 | 20 ... 140
diff2 = 20/140 = 0.14
70 | 60 | 20 ... 150
diff3 = 0.13
0 | 100 | 0 ... 100
diff4 = 0/100 = 0
0 | 100 | 100 = 200
diff5 = 100/200 =0.5
90 | 70 | 60 ... 230
diff6 = 60/230 = 0.26 ******************* when the color is too bright, weak increase too much, we can't have it directly on the fraction
80 | 30 | 10 ... 120
diff7 =
if the primary component is not the one supposed to be, we just cut off the square, based on this method,
we abandon completely the principle of a primary component formula.
----------------------------------------
Formula to compute hue difference : secondary component part
first formula:
--------------------------
80 | 20 | 40
diff = abs(r-b)/avg
= 80/46-20/46 = 1.73 - 0.43 = 1.3
80 | 40 | 20
diff2 = 80/46 - 40 / 46 = 0.869
70 | 60 | 20
diff3 = 70/46 - 60/46 = 0.21
0 | 100 | 0 = 33.333
diff4 = 100/33.3 = 3
0 | 100 | 100 = 66.666
diff5 = 100/66.6 = 1.5 *************** inconsistant because getting a higher weak color is not supposed to lower the difference
second formula: < FINAL !!!
--------------------------------
80 | 20 | 40 ... 140 | 100
diff = abs(r-b)/(r+b)
= (80-20)/100 = 0.6
80 | 40 | 20 ... 140 | 120
diff2 = (80-40)/120 = 0.3333
70 | 60 | 20 ... 140 | 120
diff3 = (70-60)/120 = 0.1
0 | 100 | 0 ... 100 | 100
diff4 = 100/100 = 1
0 | 100 | 100 = 200 | 100
diff5 = 100/100 = 1
90 | 70 | 60 ... 230 | 160
diff6 = 20 / 170 = 0.11
80 | 30 | 10 ... .. | 110
diff7 = 50 / 110 = 0.46
I thought last result was inconsistant with diff2 (proportionnally similar but diff value very low)
But in that case, it's perfect, because incorrect hue with less saturation should be less penalized
and we penalize low saturation with rsat already
Not perfect because if g vary from b to r we do nothing about it
third formula : abandoned
--------------------------------
80 | 20 | 40 ... 60
diff = abs(r-b)/(max(r,g,b)-min(r,g,b)+1)
= (80-20)/ 60 = 1
80 | 40 | 20 ... 60
diff2 = (80-40)/60 = 0.666
70 | 60 | 20 ... 50
diff3 = (70-60)/50 = 0.2
0 | 100 | 0 ... 100
diff4 = 100/100 = 1
0 | 100 | 100 = 100
diff5 = 100/100 = 1
90 | 70 | 60 ... 30
diff6 = 20 / 30 = 0.6666
Must apply a non-linear scale to diff :
1 = worst possible subsquare, square is almost dead
0.90 = bad subsquare but not strictly impossible
0.66 = not ideal but works
0.5 = fine
0.2 = good
diff=diff*0x100
0x100 = worst possible subsquare, square is almost dead
0x90 = very bad subsquare but not strictly impossible
0x66 = not ideal but works
0x50 = fine
0x20 = good
<- this part is still up for discussion
-------------------------
-------------------------
Implementation of remote result display with embedded nanohttpd in the app + web browser for the presentation laptop
Usable networks :
- ad'hoc
- wifi tethering
- smartphone and laptop connected to the same wifi network
Data :
- picture.jpg (high res, progressive)
- points[]{x,y,index}
- datatimestamp=-inf
app
prepare for server (write picture.jpg + points.json)
- when analyze start
* pictureURI=null
* pointsURI=null
* pictureLock.aquire()
* pointsLock.aquire()
* datatimestamp=nanotime() in shared memory
- when picture.jpg is ready
* save it, put pictureURI in shared memory
* pictureLock.release()
- when points.json is ready
* save it, put pointsURI in shared memory
* pointsLock.release()
server :
reply to client request
- /datatimestamp : return the datatimestamp
- /photo : wait for photoLock + send the file in pictureURI
- /points : wait for pointsLock + send the file in pointsURI
- / : return the static client webpage
web browser (client) :
- request from server
* datatimestamp=-inf
* GET datatimestamp on /datatimestamp
* if more recent :
* update datatimestamp value
* GET /picture + draw pictures
* GET /points + draw points + compute scores
Web GUI :
---------------------------------
< DATE1 | DATE2 | *TODAY* |
< 1 2 3 | 1 2 3 4 5 6 | 1 2 |
---------------------------------
---------------------- a: 30%
| | ======
| | b: 5
| | =
| PICTURE | c: 50%
| | ==========
| | d: 15%
---------------------- ===
storage of multiple results is not included in version 1
-----------------------------------------------------------------------
-----------------------------------------------------------------------
Possible features :
Quit with back button (v1.x)
Help screen (v2)
Options : (v3)
- wifi on/off
- port
- web password
- move gallery import to options
Local history (1+ year project)
- daily / monthly timeline
- select old photos
- switch app GUI to java-served html5
remote/cloud server (2+ years project) :
- sync device <-> server <-> laptop
- prepare questions ahead