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
