[][src]Function libeyelink_sys::eyelink_calculate_velocity_x_y

pub unsafe extern "C" fn eyelink_calculate_velocity_x_y(
    slen: c_int,
    xvel: *mut f32,
    yvel: *mut f32,
    vel_sample: *mut FSAMPLE
) -> c_int

@ingroup velocity_acceleration Calculates left x velocity, left y velocity, right x velocity and right y velocity from queue of samples. @param[in] slen Sample model to use for velocity calculation. Acceptable models are \c FIVE_SAMPLE_MODEL, \c NINE_SAMPLE_MODEL, \c SEVENTEEN_SAMPLE_MODEL and \c EL1000_TRACKER_MODEL. @param[out] xvel Left and right x velocity. Expects an array of 2 elements of floats. The array is filled with left and right velocity values. Upon return of this function xvel[0] contains the left x velocity data and xvel[1] contains right x velocity data. If velocity cannot be calculated for any reason(eg. insufficient samples, no data) MISSING_DATA is filled for the given velocity. @param[out] yvel Left and right y velocity. Expects an array of 2 elements of floats. The array is filled with left and right velocity values. Upon return of this function yvel[0] contains the left y velocity data and xvel[1] contains right y velocity data. If velocity cannot be calculated for any reason(eg. insufficient samples, no data) MISSING_DATA is filled for the given velocity. @param[out] vel_sample Velocity for sample. Expects a FSAMPLE structure to fill in the sample, the velocity is calculated for.

\b Example:

@code
#include 
#include 

int main(int argc, char ** argv)
{
if(open_eyelink_connection(0)) // connect to tracker
{
return -1;
}

eyecmd_printf("link_sample_data  = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS"); // tell the tracker to stuff the sample with
if(start_recording(0,0,1,0)) // start recording failed.
{
close_eyelink_connection();
return -1;
}

if(!eyelink_wait_for_block_start(100, 1, 0)) // wait for block start
{
stop_recording();
close_eyelink_connection();
return -1;
}
else
{
UINT32 st = current_time();
while(current_time()-st<10000) // record for 10 seconds
{
FSAMPLE fs;
float xvel[2];
float yvel[2];
if(check_recording()!=0)
{
close_eyelink_connection();
return -4; // recording aborted.
}
eyelink_calculate_velocity_x_y(FIVE_SAMPLE_MODEL,xvel,yvel,&fs);
printf("%lu %f %f %f %f\n",fs.time,xvel[0],yvel[0], xvel[1], yvel[1]);
pump_delay(100); // we check the velocity every 100 ms.
}
stop_recording();
close_eyelink_connection();
return 0;
}
}
@endcode