print "Found headset with serial number: ", headset.serial_number

    info = pylsl.stream_info('Emotiv EEG', 'EEG', len(headset.channel_mask),
                             headset.sampling_rate, pylsl.cf_int16,
                             str(headset.serial_number))

    info_desc = info.desc()
    info_desc.append_child_value("manufacturer", "Emotiv")
    channels = info_desc.append_child("channels")

    for ch in headset.channel_mask:
        channels.append_child("channel").append_child_value(
            "label", ch).append_child_value("unit",
                                            "microvolts").append_child_value(
                                                "type", "EEG")

    # Outgoing buffer size = 360 seconds, transmission chunk size = 32 samples
    outlet = pylsl.stream_outlet(info, 1, 32)

    while True:
        try:
            s = headset.get_sample()
        except epoc.EPOCTurnedOffError, e:
            print "Headset is turned off, waiting..."
            time.sleep(0.02)
        else:
            if s:
                outlet.push_sample(pylsl.vectori(s), pylsl.local_clock())

    headset.disconnect()
Exemplo n.º 2
0
        "EEG",
        len(headset.channel_mask),
        headset.sampling_rate,
        pylsl.cf_int16,
        str(headset.serial_number),
    )

    info_desc = info.desc()
    info_desc.append_child_value("manufacturer", "Emotiv")
    channels = info_desc.append_child("channels")

    for ch in headset.channel_mask:
        channels.append_child("channel").append_child_value("label", ch).append_child_value(
            "unit", "microvolts"
        ).append_child_value("type", "EEG")

    # Outgoing buffer size = 360 seconds, transmission chunk size = 32 samples
    outlet = pylsl.stream_outlet(info, 1, 32)

    while True:
        try:
            s = headset.get_sample()
        except epoc.EPOCTurnedOffError, e:
            print "Headset is turned off, waiting..."
            time.sleep(0.02)
        else:
            if s:
                outlet.push_sample(pylsl.vectori(s), pylsl.local_clock())

    headset.disconnect()
from PIL import Image
import struct

info = pylsl.stream_info('VideoFrameCommandStream','Markers',1,0,pylsl.cf_string,'dgeyurtutu567sdf');

outlet = pylsl.stream_outlet(info)

print("looking for video frame stream...")
streams = pylsl.resolve_stream('type','VideoRaw')

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

print("now sending markers...")

flatFrame = pylsl.vectori()
i=0
while True:
	# choose a marker string randomly and store it as a pylsl.vectorstr (note that this is actually a list since there can be multiple channels in the sample, even though it is of little use for markers)
	mysample = pylsl.vectorstr([ 'Request Image' ])
	# now send it and wait for a bit
	outlet.push_sample(mysample)

	if(inlet.pull_sample(flatFrame,1)):
		print 'got frame'
		buf = struct.pack('b'*len(flatFrame), *flatFrame)
		#It is possible to load the width and height from the stream header, but not implemented here.
		img = Image.frombuffer('RGB', (640,480), buf)
		if i==0:
			#this opens your default graphics program to show the image. Not wonderful.
			img.show()