#include <stdio.h>
#include <stdlib.h>
char* filename = "saved_calibration.bin";
char* serial_number;
FILE* f = fopen(filename, "wb");
return;
if (calibration_data->
size != 0) {
printf("Saving calibration to file for eye tracker with serial number %s.\n", serial_number);
fwrite(calibration_data->
data, calibration_data->
size, 1, f);
} else {
printf("No calibration available for eye tracker with serial number %s.\n", serial_number);
}
fclose(f);
{
FILE *calibration_file = fopen(filename, "rb" );
size_t file_size;
if( !calibration_file ) {
printf("Calibration file not found!\n");
return;
}
fseek(calibration_file, 0, SEEK_END);
file_size = (size_t)ftell(calibration_file);
rewind(calibration_file);
if(file_size <= 0) {
printf("Calibration file is empty!\n");
return;
};
calibration_data_to_write.
data = malloc(file_size);
calibration_data_to_write.
size = file_size;
file_size = fread(calibration_data_to_write.
data, calibration_data_to_write.
size, 1, calibration_file);
if (file_size > 0) {
printf("Applying calibration on eye tracker with serial number %s.\n", serial_number);
}
free(calibration_data_to_write.
data);
fclose(calibration_file);
}
}