Skip to content

Instantly share code, notes, and snippets.

@lamvann
Created October 19, 2017 20:02
Show Gist options
  • Save lamvann/bb5408403aa6f3686951c363e5f5999d to your computer and use it in GitHub Desktop.
Save lamvann/bb5408403aa6f3686951c363e5f5999d to your computer and use it in GitHub Desktop.
This J program triggers a executable (Leap.exe) using the Leap motion sensor C++ SDK to read bone length from the user's hand, saves info as a vector profile and stores it. It is also capable of comparing a new reading against existing profiles and returns the model's best estimates of whose hand the readings are.
NB. Some utilities written by me were loaded at started to make this program work. Will upload definitions later as definitions.ijs
load'csv'
load'jd'
jdadmin'Leap'
NB.Nouns
P =. 'C:\Users\Ivann\Documents\FIU\Fall 2016\Security IoT\Leap\file.csv'
P1 =. 'C:\Users\Ivann\Documents\Visual Studio 2015\Projects\Leap\Leap\'c
TABLE=. readcsv p
NB.Verbs
p =.'C:\Users\Ivann\Documents\Visual Studio 2015\Projects\Leap\Leap\'c,],'.csv'c
names=. (rtb e o ([:<"1[:0 1 f jd o ('read fname from profiles'c)))
file =. ([:,/ (({. , ( {: e @:({.@}.)) , {:)) t ([:-. ('5'c)=0 f)"1 o ])
set20 =. (],' ' #~20 c - #)
prep =.(([:>{.o|:o}.o(}."1) o ]) L:1 o ((jd o ('read from profiles where fname ="'c ,],'"'c)) L:0 o (rtb e o ([:<"1[:0 1 f jd o ('read fname from profiles'c)))))
fingerlist =. (,o(((1 f ,~ 'b'c),~(' 'c), 0 f ,~ 'f'c)"1 o }. o ([:~.[:}:"1 file o readcsv)))
diff =. (~.L:1 o (}:"1 </. ])) o ([:,/ (({. , ( {: e @:({.@}.)) , {:)) t ([:-. ('5'c)=0 f)"1 o ]) o readcsv
get =. z
insert=.[:jd (<@('insert profiles'c),,o|:o ((<@(1 20 $ set20)@[,]),:~<@('fname'c),' ' Tokenize fingerlist o (p c)))
addmanual =. [ insert get o ]
compares =. (names ,:] ([:|o(+/)[-])L:1 0 ([:([:,o>o}.{:"1) L:1 jd o ('read from profiles where fname ="'c,],'"'c) e o ([:(rtb e o <"1)0 1 f o (jd o ('read fname from profiles'c)))))
getAllProfiles =. ([:>{.o|:o}.o(}."1) o ]) L:1 ((jd o ('read from profiles where fname ="'c ,],'"'c)) L:0 o (rtb e o ([:<"1[:0 1 f jd o ('read fname from profiles'c))))
getall =. (names ,: getAllProfiles)
NB.Method 2
csvinput =. ([:}.o>([:do _1 f"1)L:1 o (}:"1 </. ]) o readcsv)
user =.([:<"1 o>( [:{.o{.o|:o>o}.o{: jd o ('reads from profiles where fname = "'c,],'"'c))e o ([:rtb e o (<"1) o (1 0 f) jd o ('reads fname from profiles'c)))
compares2 =. (names,:<"0 o ([:+/"1 (+/%#)"1 o|o>o (csvinput ([-]) L:1 0 user)))
adduser =. 4 : 0
_1 fork 'cmd /k Leap.exe && exit'
x insert get y
cc =: get y
)
read =: 3 : 0
_1 fork 'cmd /k Leap.exe && exit'
bb =: get y
aa =: > bb
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment