Program in text version.
/*###===-- Convertor for mocap program --===###*/
/* James Answer - u9702646 */
/*-------------------------------------------------------------*/
/*---------------------[ Header files ]------------------------*/
/*-------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
int main(int argc, char *argv[])
{
int basepos[300][2] = {{0},{0}};
int n,xpos,ypos,pointnum,frame;
char filename[50];
FILE *ofPtr; /* Pointer to output file */
FILE *ifPtr; /* Pointer to input file */
if(argc != 1)
{
printf("Usage: converter number_of_points_to_convert");
return 1;
}
pointnum = atoi(argv[1]);
// Open files for input and output
if ((ofPtr = fopen("output.txt", "w")) == NULL)
printf("Error opening output.txt");
if ((ifPtr = fopen("0.txt", "r")) == NULL)
printf("Error opening 0.txt");
while (!feof(ifPtr)) {
fscanf(ifPtr, "%d%d%d",&frame,&xpos,&ypos);
basepos[frame][1] = xpos;
basepos[frame][2] = ypos;
}
for(n = 1; n <= pointnum; n++)
{
sprintf(filename,"%d.txt",n);
if ((ifPtr = fopen(filename, "r")) == NULL)
printf("Error opening %s.txt",filename);
frame = 1;
while (!feof(ifPtr)) {
fscanf(ifPtr, "%d%d%d",&frame,&xpos,&ypos);
xpos = (xpos - basepos[frame][1]);
ypos = (ypos - basepos[frame][2]);
fprintf(ofPtr, "%d %d %d %d\n",n, frame, xpos, ypos);
frame ++;
}
}
fclose(ofPtr);
fclose(ifPtr);
return 0;
}
Return to Motion Capture.
Home. |