2016-08-05 4 views
0

初心者からPythonとゲーム。 PygameのLSL(lab streaming layer)ラッパーはありますか?脳波コンピュータインターフェイスアプリケーションを作成するために脳波信号を使ってゲームを作りたいと思っています。どんな助力も深く感謝します。ありがとう! :)LSLのパイロットゲームのラッパー

答えて

0

pylslと呼ばれるPython用のLSLモジュールがあります。これをゲームループに組み込むことができるはずです。

次のコードは、this exampleから適応されました:

from pylsl import StreamInlet, resolve_stream 
import pygame 

# first resolve an EEG stream on the lab network 
streams = resolve_stream('type', 'EEG') 

# create a new inlet to read from the stream 
inlet = StreamInlet(streams[0]) 


# Pygame setup 
pygame.init() 
size = width, height = 320, 240 

screen = pygame.display.set_mode(size) 

samples = [] 
while True: 
    # get a new sample (you can also omit the timestamp part if you're not 
    # interested in it) 

    # Get a sample from the inlet stream 
    sample, timestamp = inlet.pull_sample() 
    samples.push(sample) 

    #TODO: interperate stream and update game objects accordingly. 
    # You'll probably need to keep a few samples to interpret this data. 


    #TODO: draw game 
    ... 
    pygame.display.flip() 
+0

パーフェクト感謝:) –