Created
December 6, 2012 15:11
-
-
Save breuderink/4225152 to your computer and use it in GitHub Desktop.
MindPlay Lua example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Initialize API: | |
mp = mindplay.init('localhost:5000', 'test_user', '1') | |
for i=0,10000 do | |
print('Frame ' .. i .. '.'); | |
-- Update transfers in progress: | |
if (i % math.floor(FPS/3)) == 0 then | |
-- Perform (non-blocking) request for a detection: | |
print('Requesting prediction...') | |
response = mindplay.request_detection(mp) | |
end | |
mindplay.update(mp) | |
-- Try to read the probability from the response. If it is not yet | |
-- received, ready, we get a NaN. | |
if (response ~= nil) then | |
p = mindplay.detection(response, 'blink') | |
if not isnan(p) then | |
print('Detected blink: '.. p) | |
mindplay.response_destroy(mp, response) | |
response = nil | |
end | |
end | |
sleep(1/FPS) | |
end | |
mindplay.destroy(mp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment