Statistics
| Branch: | Revision:

gazetk / DesktopConnector / DeviceServer_SMI_REDm / iViewXAPI.py @ 5444009a

History | View | Annotate | Download (3.639 KB)

1
# -----------------------------------------------------------------------
2
#
3
# (c) Copyright 1997-2013, SensoMotoric Instruments GmbH
4
# 
5
# Permission  is  hereby granted,  free  of  charge,  to any  person  or
6
# organization  obtaining  a  copy  of  the  software  and  accompanying
7
# documentation  covered  by  this  license  (the  "Software")  to  use,
8
# reproduce,  display, distribute, execute,  and transmit  the Software,
9
# and  to  prepare derivative  works  of  the  Software, and  to  permit
10
# third-parties to whom the Software  is furnished to do so, all subject
11
# to the following:
12
# 
13
# The  copyright notices  in  the Software  and  this entire  statement,
14
# including the above license  grant, this restriction and the following
15
# disclaimer, must be  included in all copies of  the Software, in whole
16
# or  in part, and  all derivative  works of  the Software,  unless such
17
# copies   or   derivative   works   are   solely   in   the   form   of
18
# machine-executable  object   code  generated  by   a  source  language
19
# processor.
20
# 
21
# THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
22
# EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
23
# MERCHANTABILITY,   FITNESS  FOR  A   PARTICULAR  PURPOSE,   TITLE  AND
24
# NON-INFRINGEMENT. IN  NO EVENT SHALL  THE COPYRIGHT HOLDERS  OR ANYONE
25
# DISTRIBUTING  THE  SOFTWARE  BE   LIABLE  FOR  ANY  DAMAGES  OR  OTHER
26
# LIABILITY, WHETHER  IN CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT
27
# OF OR IN CONNECTION WITH THE  SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
# THE SOFTWARE.
29
#
30
# -----------------------------------------------------------------------
31
# iViewXAPI.py
32
#
33
# Demonstrates features of iView API 
34
# Defines structures 
35
# Loads in iViewXAPI.dll
36
# This script shows how to set up an experiment with Python 2.7.1 (with ctypes Library) 
37

    
38

    
39
from ctypes import *
40

    
41

    
42
#===========================
43
#                Struct Definition
44
#===========================
45

    
46
class CSystem(Structure):
47
        _fields_ = [("samplerate", c_int),
48
        ("iV_MajorVersion", c_int),
49
        ("iV_MinorVersion", c_int),
50
        ("iV_Buildnumber", c_int),
51
        ("API_MajorVersion", c_int),
52
        ("API_MinorVersion", c_int),
53
        ("API_Buildnumber", c_int),
54
        ("iV_ETDevice", c_int)]
55

    
56
class CCalibration(Structure):
57
        _fields_ = [("method", c_int),
58
        ("visualization", c_int),
59
        ("displayDevice", c_int),
60
        ("speed", c_int),
61
        ("autoAccept", c_int),
62
        ("foregroundBrightness", c_int),
63
        ("backgroundBrightness", c_int),
64
        ("targetShape", c_int),
65
        ("targetSize", c_int),
66
        ("targetFilename", c_char * 256)]
67

    
68
class CEye(Structure):
69
        _fields_ = [("gazeX", c_double),
70
        ("gazeY", c_double),
71
        ("diam", c_double),
72
        ("eyePositionX", c_double),
73
        ("eyePositionY", c_double),
74
        ("eyePositionZ", c_double)]
75

    
76
class CSample(Structure):
77
        _fields_ = [("timestamp", c_longlong),
78
        ("leftEye", CEye),
79
        ("rightEye", CEye),
80
        ("planeNumber", c_int)]
81

    
82
class CEvent(Structure):
83
        _fields_ = [("eventType", c_char),
84
        ("eye", c_char),
85
        ("startTime", c_longlong),
86
        ("endTime", c_longlong),
87
        ("duration", c_longlong),
88
        ("positionX", c_double),
89
        ("positionY", c_double)]
90

    
91
class CAccuracy(Structure):
92
        _fields_ = [("deviationLX",c_double),
93
                                ("deviationLY",c_double),                                
94
                                ("deviationRX",c_double),
95
                                ("deviationRY",c_double)]
96
                                
97
                                
98
#===========================
99
#                Loading iViewX.dll 
100
#===========================
101

    
102
iViewXAPI = windll.LoadLibrary("iViewXAPI.dll")
103

    
104

    
105
#===========================
106
#                Initializing Structs
107
#===========================
108

    
109
systemData = CSystem(0, 0, 0, 0, 0, 0, 0, 0)
110
calibrationData = CCalibration(5, 1, 0, 0, 1, 20, 239, 1, 15, b"")
111
leftEye = CEye(0,0,0)
112
rightEye = CEye(0,0,0)
113
sampleData = CSample(0,leftEye,rightEye,0)
114
eventData = CEvent('F', 'L', 0, 0, 0, 0, 0)
115
accuracyData = CAccuracy(0,0,0,0)
116

    
117