Skip to content

Commit

Permalink
several improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ddetommaso committed Dec 19, 2018
1 parent 6e6a4b5 commit eec39d1
Show file tree
Hide file tree
Showing 10 changed files with 787 additions and 412 deletions.
959 changes: 647 additions & 312 deletions LICENSE

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ connect with the device.
tobiiglasses = TobiiGlassesController()
```

If you do not pass any parameter to the constructor, A set of discovery packets
If you do not pass any parameter to the constructor, a set of discovery packets
will be sent through all the network interfaces of your system waiting for an
answer from the glasses.

Expand All @@ -62,17 +62,21 @@ tobiiglasses = TobiiGlassesController("192.168.71.50")
```

Once a wireless connection with the glasses is established you can run the
controller providing the ipv4 address to the constructor.
controller providing the IPv4 address to the constructor.


### 3. Ethernet connection (be sure that it is configured as link-local IPv6).
### 3. Ethernet connection

You can use both IPv4 or IPv6. In case you are using IPv4, ensure to have
a DHCP server running in your machine. In case of IPv6, ensure that the network
is configured as link-local.

```
tobiiglasses = TobiiGlassesController("fe80::76fe:48ff:ff00:hell")
```

In case you have multiple network interfaces in your system, please specify
the network interface name when you create a TobiiGlassesController object:
the network interface-name when you create a TobiiGlassesController object:

For Linux systems you should specify the name of the net interface ...

Expand All @@ -94,5 +98,5 @@ The following Python examples are available:
* connect.py - A Python script to connect with the eye-tracker.
* calibrate_and_record.py - A Python script for managing calibrations and recordings.
* streaming.py - A Python script for receiving live data from the eye-tracker
* live_scene.py - A Python script for receiving live scene from the eye-tracker camera.
* live_scene_and_gaze.py - A Python script for receiving live scene and synchronized gaze.
* live_scene.py - A Python script for receiving live scene from the eye-tracker camera (works only with IPv4).
* live_scene_and_gaze.py - A Python script for receiving live scene and synchronized gaze (works only with IPv4).
30 changes: 15 additions & 15 deletions examples/calibrate_and_record.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# calibrate_and_record.py : A demo code for calibrating and recording
#
# Copyright (C) 2018 Davide De Tommaso
# Copyright (C) 2019 Davide De Tommaso
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>

import time
import sys
import time
sys.path.append('..')

from tobiiglassesctrl import TobiiGlassesController
from tobiiglassesctrl.controller import TobiiGlassesController

if hasattr(__builtins__, 'raw_input'):
input=raw_input
Expand Down Expand Up @@ -55,9 +55,9 @@ def main():
print("Important! The recording will be stored in the SD folder projects/%s/recordings/%s" % (project_id, recording_id))
input("Press enter to start recording")
tobiiglasses.start_recording(recording_id)
tobiiglasses.send_event("start_recording", "Start of the recording ")
tobiiglasses.send_custom_event("start_recording", "Start of the recording ")
input("Press enter to stop recording")
tobiiglasses.send_event("stop_recording", "Stop of the recording " + str(recording_id))
tobiiglasses.send_custom_event("stop_recording", "Stop of the recording " + str(recording_id))
tobiiglasses.stop_recording(recording_id)


Expand Down
40 changes: 25 additions & 15 deletions examples/connect.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# connect.py : A demo code for connecting with the Tobii Pro Glasses 2
#
# Copyright (C) 2018 Davide De Tommaso
# Copyright (C) 2019 Davide De Tommaso
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>

import sys
sys.path.append('..')

from tobiiglassesctrl import TobiiGlassesController
from tobiiglassesctrl.controller import TobiiGlassesController

def main():

Expand All @@ -27,10 +27,20 @@ def main():
"""
other ways to connect with the tobii glasses
TobiiGlassesController("fe80::76fe:48ff:ff00:hell%eth0") #if you know the ipv6 addr of the tobii glasses and the net interface of your host system
TobiiGlassesController("192.168.71.50") #if you know the ipv4 addr of the tobii glasses (in case of wifi connection)
"""
1. If you know the IPv6 addr of the tobii glasses
TobiiGlassesController("fe80::76fe:48ff:ff00:hell")
2. If you know the IPv6 addr of the tobii glasses and the net interface
of your host system (in case of multiple interfaces)
TobiiGlassesController("fe80::76fe:48ff:ff00:hell%eth0")
3. If you know the IPv4 addr of the tobii glasses (WLAN or LAN connections)
TobiiGlassesController("192.168.71.50")
"""

if __name__ == '__main__':
main()
24 changes: 12 additions & 12 deletions examples/live_scene.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# live_scene.py : A demo for video streaming
#
# Copyright (C) 2018 Davide De Tommaso
# Copyright (C) 2019 Davide De Tommaso
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>

import cv2
import numpy as np

ipv4_address = "192.168.71.50"
cap = cv2.VideoCapture("rtsp://%s/live/scene" % ipv4_address)
cap = cv2.VideoCapture("rtsp://%s:8554/live/scene" % ipv4_address)

# Check if camera opened successfully
if (cap.isOpened()== False):
Expand Down
16 changes: 11 additions & 5 deletions examples/live_scene_and_gaze.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,27 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>

import sys
import cv2
import numpy as np
from tobiiglassesctrl import TobiiGlassesController

if hasattr(__builtins__, 'raw_input'):
input=raw_input

sys.path.append('..')
from tobiiglassesctrl.controller import TobiiGlassesController

ipv4_address = "192.168.71.50"

tobiiglasses = TobiiGlassesController(ipv4_address, True)
tobiiglasses = TobiiGlassesController(ipv4_address, video_scene=True)

project_id = tobiiglasses.create_project("Test live_scene_and_gaze.py")

participant_id = tobiiglasses.create_participant(project_id, "participant_test")

calibration_id = tobiiglasses.create_calibration(project_id, participant_id)

raw_input("Put the calibration marker in front of the user, then press enter to calibrate")
input("Put the calibration marker in front of the user, then press enter to calibrate")
tobiiglasses.start_calibration(calibration_id)

res = tobiiglasses.wait_until_calibration_is_done(calibration_id)
Expand All @@ -45,9 +51,9 @@

frame_duration = 1000.0/float(video_freq) #frame duration in ms

raw_input("Press ENTER to start the video scene")
input("Press ENTER to start the video scene")

cap = cv2.VideoCapture("rtsp://%s/live/scene" % ipv4_address)
cap = cv2.VideoCapture("rtsp://%s:8554/live/scene" % ipv4_address)

# Check if camera opened successfully
if (cap.isOpened()== False):
Expand Down
24 changes: 12 additions & 12 deletions examples/streaming.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# streaming.py : A demo for data streaming
#
# Copyright (C) 2018 Davide De Tommaso
# Copyright (C) 2019 Davide De Tommaso
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>

import time
import json
import sys
sys.path.append('..')

from tobiiglassesctrl import TobiiGlassesController
from tobiiglassesctrl.controller import TobiiGlassesController


def main():
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

setup(
name='tobiiglassesctrl',
version='1.1.9',
version='2.0-a1',
description='A Python controller for Tobii Pro Glasses 2',
url='https://github.com/ddetommaso/TobiiProGlasses2_PyCtrl',
download_url='https://github.com/ddetommaso/TobiiProGlasses2_PyCtrl/archive/1.1.9.tar.gz',
download_url='https://github.com/ddetommaso/TobiiProGlasses2_PyCtrl/archive/2.0-a1.tar.gz',
install_requires=['netifaces'],
author='Davide De Tommaso',
author_email='dtmdvd@gmail.com',
author_email='ing.davidedetommaso@gmail.com',
keywords=['eye-tracker','tobii','glasses', 'tobii pro glasses 2', 'tobii glasses', 'eye tracking'],
py_modules=["tobiiglassesctrl"],
classifiers = [
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5'
],
)
)
Empty file added tobiiglassesctrl/__init__.py
Empty file.
Loading

0 comments on commit eec39d1

Please sign in to comment.