I am working in Ubuntu on OpenCV. I am trying to read a text file which contains numbers, but I keep getting garbage values and the same value repeats every time the function loops. Here is that part of the code:
FILE* fid = fopen("/trial","r");
while (fgetc(fid) != EOF)
{
fscanf(fid, "%f", &trainsample);
cout << trainsample << endl;
cvSetReal2D(traindata, i, j, trainsample);
j = j + 1;
if (j == 6)
i = i + 1;
}