Skip to content

Instantly share code, notes, and snippets.

@breuderink
Created December 6, 2012 15:11
Show Gist options
  • Save breuderink/4225152 to your computer and use it in GitHub Desktop.
Save breuderink/4225152 to your computer and use it in GitHub Desktop.
MindPlay Lua example
-- 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