int main()
#endif
{
  unsigned char *img1, *img2;
  KLT_TrackingContext tc;
  KLT_FeatureList fl;
  int nFeatures = 100;
  int ncols, nrows;

  tc = KLTCreateTrackingContext();
  fl = KLTCreateFeatureList(nFeatures);

  img1 = pgmReadFile("img0.pgm", NULL, &ncols, &nrows);
  img2 = pgmReadFile("img1.pgm", NULL, &ncols, &nrows);

  KLTSelectGoodFeatures(tc, img1, ncols, nrows, fl);

  KLTWriteFeatureListToPPM(fl, img1, ncols, nrows, "feat1.ppm");
  KLTWriteFeatureList(fl, "feat1.txt", "%3d");

  KLTTrackFeatures(tc, img1, img2, ncols, nrows, fl);
  KLTReplaceLostFeatures(tc, img2, ncols, nrows, fl);

  KLTWriteFeatureListToPPM(fl, img2, ncols, nrows, "feat2.ppm");
  KLTWriteFeatureList(fl, "feat2.txt", "%3d");

  return 0;
}
Beispiel #2
0
int main()
#endif
{
  KLT_FeatureList fl;
  KLT_FeatureHistory fh;
  KLT_FeatureTable ft;
  int i;

  ft = KLTReadFeatureTable(NULL, "features.txt");
  fl = KLTCreateFeatureList(ft->nFeatures);
  KLTExtractFeatureList(fl, ft, 1);
  KLTWriteFeatureList(fl, "feat1.txt", "%3d");
  KLTReadFeatureList(fl, "feat1.txt");
  KLTStoreFeatureList(fl, ft, 2);
  KLTWriteFeatureTable(ft, "ft2.txt", "%3d");

  fh = KLTCreateFeatureHistory(ft->nFrames);
  KLTExtractFeatureHistory(fh, ft, 5);

  printf("The feature history of feature number 5:\n\n");
  for (i = 0 ; i < fh->nFrames ; i++)
    printf("%d: (%5.1f,%5.1f) = %d\n",
           i, fh->feature[i]->x, fh->feature[i]->y,
           fh->feature[i]->val);

  KLTStoreFeatureHistory(fh, ft, 8);
  KLTWriteFeatureTable(ft, "ft3.txt", "%6.1f");

  return 0;
}
Beispiel #3
0
void main()
{
  unsigned char *img1, *img2;
  KLT_TrackingContext tc;
  KLT_FeatureList fl;
  int nFeatures = 100;
  int ncols, nrows;
  int i;

  tc = KLTCreateTrackingContext();
  KLTPrintTrackingContext(tc);
  fl = KLTCreateFeatureList(nFeatures);

  img1 = pgmReadFile("img0.pgm", NULL, &ncols, &nrows);
  img2 = pgmReadFile("img1.pgm", NULL, &ncols, &nrows);

  KLTSelectGoodFeatures(tc, img1, ncols, nrows, fl);

  printf("\nIn first image:\n");
  for (i = 0 ; i < fl->nFeatures ; i++)  {
    printf("Feature #%d:  (%f,%f) with value of %d\n",
           i, fl->feature[i]->x, fl->feature[i]->y,
           fl->feature[i]->val);
  }

  KLTWriteFeatureListToPPM(fl, img1, ncols, nrows, "feat1.ppm");
  KLTWriteFeatureList(fl, "feat1.txt", "%3d");

  KLTTrackFeatures(tc, img1, img2, ncols, nrows, fl);

  printf("\nIn second image:\n");
  for (i = 0 ; i < fl->nFeatures ; i++)  {
    printf("Feature #%d:  (%f,%f) with value of %d\n",
           i, fl->feature[i]->x, fl->feature[i]->y,
           fl->feature[i]->val);
  }

  KLTWriteFeatureListToPPM(fl, img2, ncols, nrows, "feat2.ppm");
  KLTWriteFeatureList(fl, "feat2.fl", NULL);      /* binary file */
  KLTWriteFeatureList(fl, "feat2.txt", "%5.1f");  /* text file   */
}