File: eyeimagetest.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (138 lines) | stat: -rw-r--r-- 4,336 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
% iviewx

    %   14-12-04 volgende zaken uitgeprobeerd.
    %   ET_SIM: start eye image
    %   ET_EIM: end eye image
    %   ET_IMG : image size
    
    %   er komt wel informatie over, maar het is onduidelijk wat deze
    %   precies betekent. (stukjes van 1336 char, en af en toe ook 15 char
    %   (die laatste lijken alleen spaces te zijn). Eye image is 384x288
    %   groot.
    
    
    %   ET_MOV ET_POS
    %   worden niet herkend door iviewx 1.6 build 10




fprintf([mfilename ' start\n']);
clear;
try

    red.right=KbName('RightArrow');
    red.left=KbName('LeftArrow');
    red.up=KbName('UpArrow');
    red.down=KbName('DownArrow');
    red.pos=KbName('p');
    
    
    pnet('closeall');

    host='192.168.1.2';
    port=4444;
    ivx=iViewXInitDefaults; %([],[], host, port);
    ivx;
    [result, ivx]=iViewXComm('open', ivx);
    result
    [result, ivx]=iViewXComm('check', ivx);
    result
    [success, ivx]=iViewX('setscreensize', ivx);
    
    result=iViewXComm('send', ivx, ['ET_SIM']); % start eye_image
%     [result, ivx]=iViewX('stoprecording', ivx);

%     params='ET_REC';
%     [result, ivx]=iViewX('command', ivx, params);
%     params='ET_CAL 9';
%     [result, ivx]=iViewX('command', ivx, params);

    tEnd=getsecs+300;
    while getsecs<tEnd
        [keyIsDown,secs,keyCode] = KbCheck;
        if 1==keyCode(ivx.modifierKey) && 1==keyCode(ivx.breakKey)
            result=-1;
            return;
            break;
        end
% duration=10;
%         if 1==keyCode(red.left)
%             result=iViewXComm('send', ivx, ['ET_MOV' ' LEFT ' num2str(duration)]);
%         elseif 1==keyCode(red.right)
%             result=iViewXComm('send', ivx, ['ET_MOV' ' RIGHT ' num2str(duration)]);
%         elseif 1==keyCode(red.up)
%             result=iViewXComm('send', ivx, ['ET_MOV' ' UP ' num2str(duration)]);
%         elseif 1==keyCode(red.down)
%             result=iViewXComm('send', ivx, ['ET_MOV' ' DOWN ' num2str(duration)]);
%         end
% 
        if 1==keyCode(red.left)
            result=iViewXComm('send', ivx, ['ET_MOV' ' LEFT ']);
        elseif 1==keyCode(red.right)
            result=iViewXComm('send', ivx, ['ET_MOV' ' RIGHT ']);
        elseif 1==keyCode(red.up)
            result=iViewXComm('send', ivx, ['ET_MOV' ' UP ' ]);
        elseif 1==keyCode(red.down)
            result=iViewXComm('send', ivx, ['ET_MOV' ' DOWN ' ]);
        end
        
        
        if 1==keyCode(red.down)
            result=iViewXComm('send', ivx, ['ET_MOV' ' POS ' num2str(100) ' ' num2str(100) ]);
        end

        [data, ivx]=iViewXComm('receive', ivx);

        if ~isempty(data)
           data;
            if strfind(data, 'ET_SPL')
            elseif strfind(data, 'ET_CHG')
                pt=str2num(data(8:end));
                fprintf('Change to point: %d\n', pt);
            elseif strfind(data, 'ET_PNT')
                coords=str2num(data(8:end));
                fprintf('Coords for point %d:\t%d\t%d\n', coords(1), coords(2), coords(3));
            elseif strfind(data, 'ET_CSZ')
                scr_size=str2num(data(8:end));
                fprintf('Screen: %d\t%d\n', scr_size(1), scr_size(2));
            elseif strfind(data, 'ET_IMG')
                eye_size=str2num(data(8:end));
                fprintf('Eye image: %d\t%d (total: %d)\n', eye_size(1), eye_size(2), eye_size(1)* eye_size(2));
                ivx.udpmaxread=eye_size(1)* eye_size(2);
                ivx.udpreadtimeout=1.0;
                [data, ivx]=iViewXComm('receive', ivx);
                ivx.udpmaxread=1000;
                ivx.udpreadtimeout=0.1;
                size(data)
                decdata=base64decode(data)
%                 if length(data)==15
%                     data
%                 end
                
            end
        end
       % result
        i=i+1;
        drawnow;
    end
    [result, ivx]=iViewXComm('close', ivx);
    
    result=iViewXComm('send', ivx, ['ET_EIM']);
    

    result
    
    [result, ivx]=iViewX('stoprecording', ivx);

    result
    pnet('closeall');
    fprintf([mfilename ' end\n']);

catch
    %this "catch" section executes in case of an error in the "try" section
    %above.  Importantly, it closes the onscreen window if its open.
    pnet('closeall');
    Screen('CloseAll');    rethrow(lasterror);
end %try..catch..