-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathiViewXAPI.m
685 lines (570 loc) · 26.4 KB
/
iViewXAPI.m
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
% IVIEWXAPI provides a nice interface to the functions defined in
% iViewXAPIHeader
%
% Part of the SMITE toolbox (https://github.com/dcnieho/SMITE), but can be
% used independently. When using this convenience interface (which is
% recommended because of several fixes that have been made compared to the
% code released by SMI), please cite the following paper:
% Niehorster, D.C., & Nyström, M., (2019). SMITE: A toolbox for creating
% Psychtoolbox and Psychopy experiments with SMI eye trackers.
% doi: 10.3758/s13428-019-01226-0.
classdef iViewXAPI < handle
methods
function obj = iViewXAPI()
% load dll if not yet loaded
if ~libisloaded('iViewXAPI')
input = {@iViewXAPIHeader,'alias','iViewXAPI'};
if strcmp(computer('arch'), 'win64')
libfile = 'iViewXAPI64.dll';
else
libfile = 'iViewXAPI.dll';
end
try
loadlibrary(libfile, input{:});
catch %#ok<CTCH>
% iViewXAPI failed. Most likely cause would be "invalid
% MEX file error" due to iViewXAPI failing to link
% against required DLL's.
% The old drill: temporarily add (likely) location of
% DLL. Retry. If this was the culprit, then the linker
% should load, link and init iViewXAPI and we should
% succeed. Otherwise we fail again. Try some common
% paths...
if exist('C:\Program Files\SMI\iView X SDK\bin','dir')
temppath = 'C:\Program Files\SMI\iView X SDK\bin';
elseif exist('C:\Program Files (x86)\SMI\iView X SDK\bin','dir')
temppath = 'C:\Program Files (x86)\SMI\iView X SDK\bin';
else
error('failed to load %s, and cannot find it in common locations. Please make sure the iView X SDK is installed and that it''s bin directory is in the Windows path variable',libfile);
end
addpath(temppath);
loadlibrary(libfile, input{:});
rmpath(temppath);
end
end
end
end
methods(Static) % this whole class is static, it has no state as it just forwards calls to the dll
function ret = abortCalibration()
ret = calllib('iViewXAPI', 'iV_AbortCalibration');
end
function ret = abortCalibrationPoint()
ret = calllib('iViewXAPI', 'iV_AbortCalibrationPoint');
end
function ret = acceptCalibrationPoint()
ret = calllib('iViewXAPI', 'iV_AcceptCalibrationPoint');
end
function ret = calibrate()
ret = calllib('iViewXAPI', 'iV_Calibrate');
end
function ret = changeCalibrationPoint(number, positionX , positionY)
ret = calllib('iViewXAPI', 'iV_ChangeCalibrationPoint', number, positionX , positionY);
end
function ret = clearAOI()
ret = calllib('iViewXAPI', 'iV_ClearAOI');
end
function ret = clearRecordingBuffer()
ret = calllib('iViewXAPI', 'iV_ClearRecordingBuffer');
end
function ret = configureFilter(filter, action, data)
% filter: enum FilterType
% action: enum FilterAction
ret = calllib('iViewXAPI', 'iV_ConfigureFilter', filter, action, data);
end
function ret = connect(sendIPAddress, sendPort, recvIPAddress, receivePort)
ret = calllib('iViewXAPI', 'iV_Connect', sendIPAddress, sendPort, recvIPAddress, receivePort);
end
function ret = connectLocal()
ret = calllib('iViewXAPI', 'iV_ConnectLocal');
end
function ret = continueEyetracking()
ret = calllib('iViewXAPI', 'iV_ContinueEyetracking', etMessage);
end
function ret = continueRecording(etMessage)
ret = calllib('iViewXAPI', 'iV_ContinueRecording', etMessage);
end
function ret = defineAOI(aoiData)
% aoiData type: AOIStruct
ret = calllib('iViewXAPI', 'iV_DefineAOI', aoiData);
end
function ret = defineAOIPort(port)
ret = calllib('iViewXAPI', 'iV_DefineAOIPort', port);
end
function ret = deleteREDGeometry(setupName)
ret = calllib('iViewXAPI', 'iV_DeleteREDGeometry', setupName);
end
function ret = disableAOI(aoiName)
ret = calllib('iViewXAPI', 'iV_DisableAOI', aoiName);
end
function ret = disableAOIGroup(aoiGroup)
ret = calllib('iViewXAPI', 'iV_DisableAOIGroup', aoiGroup);
end
function ret = disableGazeDataFilter()
ret = calllib('iViewXAPI', 'iV_DisableGazeDataFilter');
end
function ret = disableProcessorHighPerformanceMode()
ret = calllib('iViewXAPI', 'iV_DisableProcessorHighPerformanceMode');
end
function ret = disconnect()
ret = calllib('iViewXAPI', 'iV_Disconnect');
end
function ret = enableAOI(aoiName)
ret = calllib('iViewXAPI', 'iV_EnableAOI', aoiName);
end
function ret = enableAOIGroup(aoiGroup)
ret = calllib('iViewXAPI', 'iV_EnableAOIGroup', aoiGroup);
end
function ret = enableGazeDataFilter()
ret = calllib('iViewXAPI', 'iV_EnableGazeDataFilter');
end
function ret = enableProcessorHighPerformanceMode()
ret = calllib('iViewXAPI', 'iV_EnableProcessorHighPerformanceMode');
end
function [ret,accuracy] = getAccuracy(pAccuracyData, visualization)
if isempty(pAccuracyData)
pAccuracyData = SMIStructEnum.Accuracy;
end
ret = calllib('iViewXAPI', 'iV_GetAccuracy', pAccuracyData, visualization);
accuracy = struct(pAccuracyData);
end
function [ret,image] = getAccuracyImage(pImageData)
if nargin==0
pImageData = SMIStructEnum.Image;
end
ret = calllib('iViewXAPI', 'iV_GetAccuracyImage', pImageData);
image = getImage(ret,pImageData,'BGR');
end
function ret = getAOIOutputValue(aoiOutputValue)
ret = calllib('iViewXAPI', 'iV_GetAOIOutputValue', aoiOutputValue);
end
function [ret,LPTNames] = getAvailableLptPorts()
bufSize = 2048;
[ret,LPTNames] = calllib('iViewXAPI', 'iV_GetAvailableLptPorts', blanks(bufSize), bufSize);
end
function [ret,calibrationData] = getCalibrationParameter(pCalibrationData)
if nargin==0
pCalibrationData = SMIStructEnum.Calibration;
end
ret = calllib('iViewXAPI', 'iV_GetCalibrationParameter', pCalibrationData);
calibrationData = struct(pCalibrationData);
end
function ret = getCalibrationPoint(calibrationPointNumber, calibrationPoint)
ret = calllib('iViewXAPI', 'iV_GetCalibrationPoint', calibrationPointNumber, calibrationPoint);
end
function [ret,calibrationPointQualityLeft,calibrationPointQualityRight] = getCalibrationQuality(calibrationPointNumber, pCalibrationPointQualityLeft, pCalibrationPointQualityRight)
if nargin<2
pCalibrationPointQualityLeft = SMIStructEnum.CalibrationPointQuality;
end
if nargin<3
pCalibrationPointQualityRight = SMIStructEnum.CalibrationPointQuality;
end
ret = calllib('iViewXAPI', 'iV_GetCalibrationQuality', calibrationPointNumber, pCalibrationPointQualityLeft, pCalibrationPointQualityRight);
calibrationPointQualityLeft = struct(pCalibrationPointQualityLeft);
calibrationPointQualityRight = struct(pCalibrationPointQualityRight);
end
function [ret,image] = getCalibrationQualityImage(pImageData)
if nargin==0
pImageData = SMIStructEnum.Image;
end
ret = calllib('iViewXAPI', 'iV_GetCalibrationQualityImage', pImageData);
image = getImage(ret,pImageData,'BGR');
end
function [ret,calStatus] = getCalibrationStatus(calibrationStatus)
if nargin==0
calibrationStatus = SMIStructEnum.CalibrationStatus;
end
ret = calllib('iViewXAPI', 'iV_GetCalibrationStatus', calibrationStatus);
calStatus = calibrationStatus.Value;
end
function ret = getCurrentCalibrationPoint(calibrationPoint)
ret = calllib('iViewXAPI', 'iV_GetCurrentCalibrationPoint', calibrationPoint);
end
function [ret,redGeometry] = getCurrentREDGeometry(pRedGeometry)
if nargin==0
pRedGeometry = SMIStructEnum.REDGeometryStruct;
end
ret = calllib('iViewXAPI', 'iV_GetCurrentREDGeometry', pRedGeometry);
redGeometry = struct(pRedGeometry);
end
function [ret,time] = getCurrentTimestamp()
pTime = libpointer('int64Ptr',int64(0));
ret = calllib('iViewXAPI', 'iV_GetCurrentTimestamp', pTime);
time = [];
if ret==1
time = pTime.Value;
end
end
function [ret,name] = getDeviceName()
pName = libpointer('voidPtr',zeros(1,64,'uint8'));
ret = calllib('iViewXAPI', 'iV_GetDeviceName', pName);
name = '';
if ret==1
name = char(pName.Value);
name(name==0) = [];
end
end
function [ret,eventDataSample] = getEvent(pEventDataSample)
if nargin==0
pEventDataSample = SMIStructEnum.Event;
end
ret = calllib('iViewXAPI', 'iV_GetEvent', pEventDataSample);
eventDataSample = struct(pEventDataSample);
end
function [ret,eventDataSample] = getEvent32(pEventDataSample)
if nargin==0
pEventDataSample = SMIStructEnum.Event32;
end
ret = calllib('iViewXAPI', 'iV_GetEvent32', pEventDataSample);
eventDataSample = struct(pEventDataSample);
end
function [ret,image] = getEyeImage(pImageData)
if nargin==0
pImageData = SMIStructEnum.Image;
end
ret = calllib('iViewXAPI', 'iV_GetEyeImage', pImageData);
image = getImage(ret,pImageData,'mono');
end
function [ret,key] = getFeatureKey()
pKey = libpointer('int64Ptr',int64(0));
ret = calllib('iViewXAPI', 'iV_GetFeatureKey', pKey);
key = [];
if ret==1
key = pKey.Value;
end
end
function [ret,qualityData] = getGazeChannelQuality(pQualityData)
if nargin==0
pQualityData = SMIStructEnum.GazeChannelQuality;
end
ret = calllib('iViewXAPI', 'iV_GetGazeChannelQuality', pQualityData);
qualityData = struct(pQualityData);
end
function [ret,profNames] = getGeometryProfiles()
bufSize = 2048;
[ret,profNames] = calllib('iViewXAPI', 'iV_GetGeometryProfiles', bufSize, blanks(bufSize));
end
function [ret,licenseDueDate] = getLicenseDueDate(pLicenseDueDate)
if nargin==0
pLicenseDueDate = SMIStructEnum.GazeChannelQuality;
end
ret = calllib('iViewXAPI', 'iV_GetLicenseDueDate', pLicenseDueDate);
licenseDueDate = struct(pLicenseDueDate);
end
function [ret,recordingState] = getRecordingState(pRecordingState)
if nargin==0
pRecordingState = SMIStructEnum.RecordingState;
end
ret = calllib('iViewXAPI', 'iV_GetRecordingState', pRecordingState);
recordingState = struct(pRecordingState);
end
function [ret,redGeometry] = getREDGeometry(profileName,pRedGeometry)
if nargin<2
pRedGeometry = SMIStructEnum.REDGeometryStruct;
end
ret = calllib('iViewXAPI', 'iV_GetREDGeometry', profileName, pRedGeometry);
redGeometry = struct(pRedGeometry);
end
function [ret,sample] = getSample(pSampleData)
if nargin==0
pSampleData = SMIStructEnum.Sample;
end
ret = calllib('iViewXAPI', 'iV_GetSample', pSampleData);
sample = struct(pSampleData);
end
function [ret,sample] = getSample32(pSampleData)
if nargin==0
pSampleData = SMIStructEnum.Sample32;
end
ret = calllib('iViewXAPI', 'iV_GetSample32', pSampleData);
sample = struct(pSampleData);
end
function [ret,image] = getSceneVideo(pImageData)
if nargin==0
pImageData = SMIStructEnum.Image;
end
ret = calllib('iViewXAPI', 'iV_GetSceneVideo', pImageData);
image = getImage(ret,pImageData,'RGB');
end
function [ret,serial] = getSerialNumber()
pSerial = libpointer('voidPtr',zeros(1,64,'uint8'));
ret = calllib('iViewXAPI', 'iV_GetSerialNumber', pSerial);
serial = '';
if ret==1
serial = char(pSerial.Value);
serial(serial==0) = [];
end
end
function [ret,speedModes] = getSpeedModes(pSpeedModes)
if nargin==0
pSpeedModes = SMIStructEnum.SpeedMode;
end
ret = calllib('iViewXAPI', 'iV_GetSpeedModes', pSpeedModes);
speedModes = struct(pSpeedModes);
end
function [ret,sysInfo] = getSystemInfo(pSystemInfoData)
if nargin==0
pSystemInfoData = SMIStructEnum.SystemInfo;
end
ret = calllib('iViewXAPI', 'iV_GetSystemInfo', pSystemInfoData);
sysInfo = struct(pSystemInfoData);
end
function [ret,mode] = getTrackingMode(trackingMode)
if nargin==0
trackingMode = SMIStructEnum.TrackingMode;
end
ret = calllib('iViewXAPI', 'iV_GetTrackingMode', trackingMode);
mode = trackingMode.Value;
end
function [ret,image] = getTrackingMonitor(pImageData)
ret = calllib('iViewXAPI', 'iV_GetTrackingMonitor', pImageData);
image = getImage(ret,pImageData,'BGR');
end
function [ret,tStatus] = getTrackingStatus(pTrackingStatus)
if nargin==0
pTrackingStatus = SMIStructEnum.TrackingStatus;
end
ret = calllib('iViewXAPI', 'iV_GetTrackingStatus', pTrackingStatus);
tStatus = struct(pTrackingStatus);
end
function [ret,enableKeys] = getUseCalibrationKeys()
pKey = libpointer('int32Ptr',int32(0));
ret = calllib('iViewXAPI', 'iV_GetUseCalibrationKeys', pKey);
enableKeys = [];
if ret==1
enableKeys = pKey.Value;
end
end
function ret = hideAccuracyMonitor()
ret = calllib('iViewXAPI', 'iV_HideAccuracyMonitor');
end
function ret = hideEyeImageMonitor()
ret = calllib('iViewXAPI', 'iV_HideEyeImageMonitor');
end
function ret = hideSceneVideoMonitor()
ret = calllib('iViewXAPI', 'iV_HideSceneVideoMonitor');
end
function ret = hideTrackingMonitor()
ret = calllib('iViewXAPI', 'iV_HideTrackingMonitor');
end
function ret = isConnected()
ret = calllib('iViewXAPI', 'iV_IsConnected');
end
function ret = loadCalibration(name)
ret = calllib('iViewXAPI', 'iV_LoadCalibration', name);
end
function ret = log(logMessage)
ret = calllib('iViewXAPI', 'iV_Log', logMessage);
end
function ret = pauseEyetracking()
ret = calllib('iViewXAPI', 'iV_PauseEyetracking');
end
function ret = pauseRecording()
ret = calllib('iViewXAPI', 'iV_PauseRecording');
end
function ret = quit()
ret = calllib('iViewXAPI', 'iV_Quit');
end
function ret = recalibrateOnePoint(number)
ret = calllib('iViewXAPI', 'iV_RecalibrateOnePoint', number);
end
function ret = releaseAOIPort()
ret = calllib('iViewXAPI', 'iV_ReleaseAOIPort');
end
function ret = removeAOI(aoiName)
ret = calllib('iViewXAPI', 'iV_RemoveAOI', aoiName);
end
function ret = resetCalibrationPoints()
ret = calllib('iViewXAPI', 'iV_ResetCalibrationPoints');
end
function ret = saveCalibration(name)
ret = calllib('iViewXAPI', 'iV_SaveCalibration', name);
end
function ret = saveData(filename, description, user, overwrite)
ret = calllib('iViewXAPI', 'iV_SaveData', filename, description, user, overwrite);
end
function ret = selectREDGeometry(profileName)
ret = calllib('iViewXAPI', 'iV_SelectREDGeometry', profileName);
end
function ret = sendCommand(etMessage)
ret = calllib('iViewXAPI', 'iV_SendCommand', etMessage);
end
function ret = sendImageMessage(etMessage)
ret = calllib('iViewXAPI', 'iV_SendImageMessage', etMessage);
end
function ret = setConnectionTimeout(time)
ret = calllib('iViewXAPI', 'iV_SetConnectionTimeout', time);
end
function ret = setEventDetectionParameter(minDuration, maxDispersion)
ret = calllib('iViewXAPI', 'iV_SetEventDetectionParameter', minDuration, maxDispersion);
end
function ret = setLicense(licenseKey)
ret = calllib('iViewXAPI', 'iV_SetLicense', licenseKey);
end
function ret = setLogger(logLevel,filename)
ret = calllib('iViewXAPI', 'iV_SetLogger', logLevel, filename);
end
function ret = setREDGeometry(redGeometry)
% redGeometry type: REDGeometryStruct
ret = calllib('iViewXAPI', 'iV_SetREDGeometry', redGeometry);
end
function ret = setResolution(stimulusWidth, stimulusHeight)
ret = calllib('iViewXAPI', 'iV_SetResolution', stimulusWidth, stimulusHeight);
end
function ret = setSpeedMode(speedMode)
ret = calllib('iViewXAPI', 'iV_SetSpeedMode', speedMode);
end
function ret = setTrackingMode(mode)
% type mode: enum TrackingMode
ret = calllib('iViewXAPI', 'iV_SetTrackingMode', mode);
end
function ret = setTrackingParameter(ET_PARAM_EYE, ET_PARAM, value)
% for ET_PARAM_EYE and ET_PARAM, can input the string values in the map
% below, or the corresponding numerical values directly
map = {
'ET_PARAM_EYE_LEFT',0
'ET_PARAM_EYE_RIGHT',1
'ET_PARAM_EYE_BOTH',2
'ET_PARAM_PUPIL_THRESHOLD',0
'ET_PARAM_REFLEX_THRESHOLD',1
'ET_PARAM_SHOW_AOI',2
'ET_PARAM_SHOW_CONTOUR',3
'ET_PARAM_SHOW_PUPIL',4
'ET_PARAM_SHOW_REFLEX',5
'ET_PARAM_DYNAMIC_THRESHOLD',6
'ET_PARAM_PUPIL_AREA',11
'ET_PARAM_PUPIL_PERIMETER',12
'ET_PARAM_PUPIL_DENSITY',13
'ET_PARAM_REFLEX_PERIMETER',14
'ET_PARAM_REFLEX_PUPIL_DISTANCE',15
'ET_PARAM_MONOCULAR',16
'ET_PARAM_SMARTBINOCULAR',17
'ET_PARAM_BINOCULAR',18
'ET_PARAM_SMARTTRACKING',19};
% these are not enums sadly, but macro defs. Search in map for corresponding value
if ischar(ET_PARAM_EYE)
qFound = strcmp(ET_PARAM_EYE,map(:,1));
assert(sum(qFound)==1,'SMI iV_SetTrackingParameter: The EyeTrackingParameter "%s" is not understood',ET_PARAM_EYE)
ET_PARAM_EYE = map{qFound,2};
end
if ischar(ET_PARAM)
qFound = strcmp(ET_PARAM,map(:,1));
assert(sum(qFound)==1,'SMI iV_SetTrackingParameter: The EyeTrackingParameter "%s" is not understood',ET_PARAM)
ET_PARAM = map{qFound,2};
end
ret = calllib('iViewXAPI', 'iV_SetTrackingParameter', ET_PARAM_EYE, ET_PARAM, value);
end
function ret = setupCalibration(pCalibrationData)
ret = calllib('iViewXAPI', 'iV_SetupCalibration', pCalibrationData);
end
function ret = setupDebugMode(enableDebugMode)
ret = calllib('iViewXAPI', 'iV_SetupDebugMode', enableDebugMode);
end
function ret = setupLptRecording(portName, enableRecording)
ret = calllib('iViewXAPI', 'iV_SetupLptRecording', portName, enableRecording);
end
function ret = setUseCalibrationKeys(enableKeys)
ret = calllib('iViewXAPI', 'iV_SetUseCalibrationKeys', enableKeys);
end
function ret = showAccuracyMonitor()
ret = calllib('iViewXAPI', 'iV_ShowAccuracyMonitor');
end
function ret = showEyeImageMonitor()
ret = calllib('iViewXAPI', 'iV_ShowEyeImageMonitor');
end
function ret = showSceneVideoMonitor()
ret = calllib('iViewXAPI', 'iV_ShowSceneVideoMonitor');
end
function ret = showTrackingMonitor()
ret = calllib('iViewXAPI', 'iV_ShowTrackingMonitor');
end
function ret = start(etApplication)
% etApplication type: enum ETApplication
ret = calllib('iViewXAPI', 'iV_Start', etApplication);
end
function ret = startRecording()
ret = calllib('iViewXAPI', 'iV_StartRecording');
end
function ret = stopRecording()
ret = calllib('iViewXAPI', 'iV_StopRecording');
end
function ret = testTTL(value)
ret = calllib('iViewXAPI', 'iV_TestTTL', value);
end
function ret = validate()
ret = calllib('iViewXAPI', 'iV_Validate');
end
function ret = setupMonitorAttachedGeometry(monitorAttachedGeometry)
% monitorAttachedGeometry type: MonitorAttachedGeometryStruct
ret = calllib('iViewXAPI', 'iV_SetupMonitorAttachedGeometry', monitorAttachedGeometry);
end
function ret = setupStandAloneMode(standAloneModeGeometry)
% standAloneModeGeometry type: StandAloneModeGeometryStruct
ret = calllib('iViewXAPI', 'iV_SetupStandAloneMode', standAloneModeGeometry);
end
function ret = setupREDMonitorAttachedGeometry(attachedModeGeometry)
% attachedModeGeometry type: REDMonitorAttachedGeometryStruct
ret = calllib('iViewXAPI', 'iV_SetupREDMonitorAttachedGeometry', attachedModeGeometry);
end
function ret = setupREDStandAloneMode(standAloneModeGeometry)
% standAloneModeGeometry type: REDStandAloneModeStruct
ret = calllib('iViewXAPI', 'iV_SetupREDStandAloneMode', standAloneModeGeometry);
end
function [ret,monitorAttachedGeometry] = getMonitorAttachedGeometry(profileName, pMonitorAttachedGeometry)
if nargin==0
pMonitorAttachedGeometry = SMIStructEnum.TrackingStatus;
end
ret = calllib('iViewXAPI', 'iV_GetMonitorAttachedGeometry', profileName, pMonitorAttachedGeometry);
monitorAttachedGeometry = struct(pMonitorAttachedGeometry);
end
function ret = setGeometryProfile(profileName)
ret = calllib('iViewXAPI', 'iV_SetGeometryProfile', profileName);
end
function ret = deleteMonitorAttachedGeometry(setupName)
ret = calllib('iViewXAPI', 'iV_DeleteMonitorAttachedGeometry', setupName);
end
function ret = deleteStandAloneGeometry(setupName)
ret = calllib('iViewXAPI', 'iV_DeleteStandAloneGeometry', setupName);
end
end
end
% helpers
function image = getImage(ret,pImageData,type)
if ret~=1
image = [];
return;
end
% tell matlab how many elements there are to read
if isa(pImageData.imageBuffer,'lib.pointer')
pImageData.imageBuffer.setdatatype(pImageData.imageBuffer.DataType,1,pImageData.imageSize);
else
assert(numel(pImageData.imageBuffer)==pImageData.imageSize,'You can only reuse ImageStructs for images of same size')
end
% get image data to manipulate. NB: do not write to pImageData.imageBuffer,
% or you'l leak the original buffer!
image = pImageData.imageBuffer;
switch type
case 'mono'
% iV_GetEyeImage
%
% grayscale, one row of pixels at a time. Transpose to conform with
% matlab conventions.
image = reshape(image,pImageData.imageWidth,pImageData.imageHeight).';
case 'BGR'
% iV_GetTrackingMonitor, iV_GetAccuracyImage,
% iV_GetCalibrationQualityImage
%
% BGR format, [B G R B G R ...] one row of pixels at a time. Turn
% into three planes and then flip(...,3) to change BGR into RGB
image = flip(permute(...
reshape(image,3,pImageData.imageWidth,pImageData.imageHeight),...
[3 2 1]),3);
case 'RGB'
% iV_GetSceneVideo
%
% untested. HED not supported by us. But this should probably do
% the trick
image = permute(...
reshape(image,3,pImageData.imageWidth,pImageData.imageHeight),...
[3 2 1]);
end
end