example4.c

来自「学习跟踪的好程序」· C语言 代码 · 共 40 行

C
40
字号
/**********************************************************************
Reads the feature table from "features.txt", copies the features from 
the second frame to those of the third frame, writes the features to 
"feat2.txt", and writes the new feature table to "ft2.txt".  Then the
eighth feature is overwritten with the fifth feature, and the resulting
table is saved to "ft3.txt".
**********************************************************************/

#include <stdio.h>
#include "klt.h"

void main()
{
  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");
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?