This is example 14. This example demonstrates the following:

  1. Processing validation results on validation procedure completion

This example is based on example 6. It extends the onModeChange() event handler function to print validation results.

Source code

Source file: example14.c

onModeChange()

In the onModeChange() event handler function we dump validation results on completion of the validation procedure.

static int onModeChange(EyeVec* eyevec, int64_t eventtime,
    const EyeVecModeChangeEventData* modedata, void* cldata)
{
    (void)eyevec;

    ClientData* clientdata = (ClientData*)cldata;
    if (clientdata == NULL) return 0;

    clientdata->trackermode = modedata->newmode;

    if (clientdata->showmodechanges) {
        printf("onModeChange:\n");
        printf("    eventtime:                  %" PRId64 "\n",
            eventtime);
        printf("    oldmode:                    %s\n",
            eyevec_tracker_mode_string(modedata->oldmode));
        printf("    newmode:                    %s\n",
            eyevec_tracker_mode_string(modedata->newmode));
        printf("    exitstatus:                 %s\n",
            eyevec_exit_status_string(modedata->exitstatus));
//        printf("    deviceerror:                %d\n",
//            modedata->deviceerror);
    }

    EyeVecResult err;
    int status;
    switch (modedata->oldmode) { (1)
        case EYEVEC_TRACKER_MODE_OFF:
        case EYEVEC_TRACKER_MODE_IDLE:
        case EYEVEC_TRACKER_MODE_SETUP:
        case EYEVEC_TRACKER_MODE_SETUP_TEST:
        case EYEVEC_TRACKER_MODE_SETUP_EVALUATION:
        case EYEVEC_TRACKER_MODE_SETUP_BASELINE:
        case EYEVEC_TRACKER_MODE_SETUP_CALIBRATION:
            break;
        case EYEVEC_TRACKER_MODE_SETUP_VALIDATION: (1)
            if (clientdata->showprocresults < 1) break;
            if (modedata->exitstatus != EYEVEC_EXIT_STATUS_OK) break; (2)
            err = eyevec_get_validation_status(eyevec, &status); (3)
            if (err)
                printError("eyevec_get_validation_status()", err);
            else {
                printf("eyevec_get_validation_status() -> %d\n", status);
                if (status <= 0) break; // No validation performed.
                EyeVecValidationResult result;
                err = eyevec_get_validation_result(eyevec, &result); (4)
                if (err) {
                    printError("eyevec_get_validation_result()", err);
                }
                else {
                    printf("eyevec_get_validation_result() ->\n");
                    if (result.havedata) { (5)
                        printf("    npoints                     %d\n",
                            result.npoints);
                        printf("    npointsskipped              %d\n",
                            result.npointsskipped);
                        printf("    npointsinvalid              %d\n",
                            result.npointsinvalid);
                        printf("    npointsbad                  %d\n",
                            result.npointsbad);
                        printf("    npointspoor                 %d\n",
                            result.npointspoor);
                        printf("    npointsfair                 %d\n",
                            result.npointsfair);
                        printf("    npointsgood                 %d\n",
                            result.npointsgood);
                        for (int n = EYEVEC_RIGHT_EYE; n <= EYEVEC_MEAN_EYE;
                                n++) {
                            if (result.haveeye[n]) {
                                printf("    mean_mm[%d]                  %.3f\n",
                                    n,
                                    (double)result.mean_mm[n]);
                                printf("    sd_mm[%d]                    %.3f\n",
                                    n,
                                    (double)result.sd_mm[n]);
                                printf("    min_mm[%d]                   %.3f\n",
                                    n,
                                    (double)result.min_mm[n]);
                                printf("    max_mm[%d]                   %.3f\n",
                                    n,
                                    (double)result.max_mm[n]);
                                printf("    mean_deg[%d]                 %.3f\n",
                                    n,
                                    (double)result.mean_deg[n]);
                                printf("    sd_deg[%d]                   %.3f\n",
                                    n,
                                    (double)result.sd_deg[n]);
                                printf("    min_deg[%d]                  %.3f\n",
                                    n,
                                    (double)result.min_deg[n]);
                                printf("    max_deg[%d]                  %.3f\n",
                                    n,
                                    (double)result.max_deg[n]);
                            }
                        }
                    }
                    else {
                        printf("    no data\n");
                    }
                }

                if (clientdata->showprocresults < 2) break;
                EyeVecValidationPointResult pointresult;
                . (6)
                .
                .
            }
            break;
        case EYEVEC_TRACKER_MODE_SETUP_DRIFT_CHECK:
        case EYEVEC_TRACKER_MODE_SETUP_RECORDING:
        case EYEVEC_TRACKER_MODE_DATA:
        case EYEVEC_TRACKER_MODE_DRIFT_CHECK:
        case EYEVEC_TRACKER_MODE_RECORDING:
            break;
    }
    switch (modedata->newmode) {
        case EYEVEC_TRACKER_MODE_OFF:
        case EYEVEC_TRACKER_MODE_IDLE:
        case EYEVEC_TRACKER_MODE_SETUP:
        case EYEVEC_TRACKER_MODE_SETUP_TEST:
        case EYEVEC_TRACKER_MODE_SETUP_EVALUATION:
        case EYEVEC_TRACKER_MODE_SETUP_BASELINE:
        case EYEVEC_TRACKER_MODE_SETUP_CALIBRATION:
        case EYEVEC_TRACKER_MODE_SETUP_VALIDATION:
        case EYEVEC_TRACKER_MODE_SETUP_DRIFT_CHECK:
        case EYEVEC_TRACKER_MODE_SETUP_RECORDING:
        case EYEVEC_TRACKER_MODE_DATA:
        case EYEVEC_TRACKER_MODE_DRIFT_CHECK:
        case EYEVEC_TRACKER_MODE_RECORDING:
            break;
    }

    return 0;
}
1 Check if the eye-tracker is leaving validation mode, signifying validation procedure completion.
2 Check exitstatus of the validation procedure. If not OK, there’s nothing to print.
3 Check if validation results are available.
4 Retrieve the validationresults into an EyeVecValidationResult struct.
5 Check if the result struct contains data and if so proceed with printing the validation results.
6 Processing validation point results omitted for brevity. See source file.

Running

After a succesful build run the program:

  1. Press x to call eyevec_set_show_gui_on_setup_mode(). This sets the show-gui-on-setup-mode flag to make the user-interface show on setup mode enter.

  2. Press o to call eyevec_open(). Eye-tracker should go from off mode to idle mode.

  3. Press s to call eyevec_enter_setup_mode(). Eye-tracker should go from idle mode to setup mode. Now perform the baseline measurement, calibration and valdation.

  4. Press q to quit.

Output might look like this (empty lines added for clarity):

eyevec_create_thread(): OK
eyevec_initialize(): OK
Type q to quit, ? for help.

[x]
eyevec_set_show_gui_on_setup_mode(true): OK

[o]
eyevec_open(): OK

onModeChange:
    eventtime:                  1750680276307582
    oldmode:                    TRACKER_MODE_OFF
    newmode:                    TRACKER_MODE_IDLE
    exitstatus:                 EXIT_STATUS_NONE

[s]
onModeChange:
    eventtime:                  1750680278769514
    oldmode:                    TRACKER_MODE_IDLE
    newmode:                    TRACKER_MODE_SETUP
    exitstatus:                 EXIT_STATUS_NONE
eyevec_enter_setup_mode(): OK

onModeChange:
    eventtime:                  1750680280725775
    oldmode:                    TRACKER_MODE_SETUP
    newmode:                    TRACKER_MODE_SETUP_BASELINE
    exitstatus:                 EXIT_STATUS_NONE
onModeChange:
    eventtime:                  1750680284821336
    oldmode:                    TRACKER_MODE_SETUP_BASELINE
    newmode:                    TRACKER_MODE_SETUP
    exitstatus:                 EXIT_STATUS_OK

onModeChange:
    eventtime:                  1750680286947982
    oldmode:                    TRACKER_MODE_SETUP
    newmode:                    TRACKER_MODE_SETUP_CALIBRATION
    exitstatus:                 EXIT_STATUS_NONE
onModeChange:
    eventtime:                  1750680297527351
    oldmode:                    TRACKER_MODE_SETUP_CALIBRATION
    newmode:                    TRACKER_MODE_SETUP
    exitstatus:                 EXIT_STATUS_OK

onModeChange:
    eventtime:                  1750680299014467
    oldmode:                    TRACKER_MODE_SETUP
    newmode:                    TRACKER_MODE_SETUP_VALIDATION
    exitstatus:                 EXIT_STATUS_NONE
onModeChange:
    eventtime:                  1750680309998252
    oldmode:                    TRACKER_MODE_SETUP_VALIDATION
    newmode:                    TRACKER_MODE_SETUP
    exitstatus:                 EXIT_STATUS_OK

eyevec_get_validation_status() -> 1
eyevec_get_validation_result() ->
    npoints                     5
    npointsskipped              0
    npointsinvalid              0
    npointsbad                  0
    npointspoor                 0
    npointsfair                 2
    npointsgood                 3
    mean_mm[0]                  4.440
    sd_mm[0]                    2.264
    min_mm[0]                   0.487
    max_mm[0]                   5.770
    mean_deg[0]                 0.305
    sd_deg[0]                   0.156
    min_deg[0]                  0.033
    max_deg[0]                  0.415
    mean_mm[1]                  6.748
    sd_mm[1]                    1.671
    min_mm[1]                   4.131
    max_mm[1]                   8.577
    mean_deg[1]                 0.464
    sd_deg[1]                   0.125
    min_deg[1]                  0.290
    max_deg[1]                  0.623
    mean_mm[2]                  5.471
    sd_mm[2]                    1.026
    min_mm[2]                   4.054
    max_mm[2]                   6.570
    mean_deg[2]                 0.376
    sd_deg[2]                   0.080
    min_deg[2]                  0.272
    max_deg[2]                  0.477

[q]
eyevec_cleanup(): OK
eyevec_destroy_thread(): OK

The results printed are the same as shown in the user-interface.

Repeating the above with showprocresults in the client data struct raised to 2 will output additional results for each validation target.