Arff2Coord.m 907 B

123456789101112131415161718192021222324
  1. % Arff2Coord.m
  2. %
  3. % This function converts an ARFF file to its .coord representation.
  4. %
  5. % input:
  6. % arrfFile - input ARFF file
  7. % coordFile - coord file to sore results
  8. function Arff2Coord(arffFile, coordFile)
  9. [data, metadata, attributes, relation] = LoadArff(arffFile);
  10. timeInd = GetAttPositionArff(attributes, 'time');
  11. xInd = GetAttPositionArff(attributes, 'x');
  12. yInd = GetAttPositionArff(attributes, 'y');
  13. confInd = GetAttPositionArff(attributes, 'confidence');
  14. fid = fopen(coordFile, 'w');
  15. fprintf(fid, 'gaze %d %d\n', metadata.width_px, metadata.height_px);
  16. fprintf(fid, 'geometry distance %.2f width %.2f height %.2f\n', metadata.distance_mm/1000, metadata.width_mm/1000, metadata.height_mm/1000);
  17. for i=1:size(data,1)
  18. fprintf(fid, '%d %.2f %.2f %.2f\n', data(i,timeInd), data(i,xInd), data(i,yInd), data(i, confInd));
  19. end
  20. fclose(fid);
  21. end