📄 chpt6.html
字号:
<title> </title><a href = "../index.html"><IMG SRC="../home_motif.gif" ALIGN=bottom></a><a href = "index.html"><IMG SRC="../toc_motif.gif" ALIGN=bottom></a><a href = "chpt5.html"><IMG SRC="../previous_motif.gif" ALIGN=bottom></a><a href = "chpt7.html"><IMG SRC="../next_motif.gif" ALIGN=bottom></a><hr><h2> Chapter 6: Reading from Files and Storing/Extracting Between Structures </h2>Now that we have tracked the features through the entire imagesequence and have saved the result to a file, we can read thefile and access the data without having to process the images again.The following example shows how this is done. Once again, we will examine theunfamiliar lines.<p><b>KLTReadFeatureTable()</b> reads the feature table from thefile "features.txt". Since the first parameter is <code>NULL</code>, a featuretable of the appropriate size is created and returned.<p><b>KLTExtractFeatureList()</b> copies the <i>(i+1)</i>th column ofa feature table into a feature list, where <i>i</i> is given by thethird parameter (in this case 1). In other words, <i>i=0</i> refers tothe first column.<p>Although in this example the call <b>KLTReadFeatureList()</b> isunnecessary, it is given here to show its syntax, which is identicalto that of KLTReadFeatureTable(). Because the first parameter isnot <code>NULL</code>, the data is written into the given feature list.<p><b>KLTStoreFeatureList()</b> copies a feature list into a particular column of a feature table (in this case the third column, forwhich <i>i=2</i>). Now, the second and third columns of the table are identical.<p>The second half of this example involves a <b>feature history</b>,which is a single row of a feature table in the same waythat a feature list is a single column. That is, a featurehistory contains a particular features' locations in all theframes. The syntax for dealing with a feature history is identical tothat of a feature list and should be clear from the example.<p>NOTE: Unlike this example, in which every KLTWriteFeature...() callproduces a text file, you will most likely want to produce binaryfiles. See the explanation in Chapter 2.<p><hr><h3> Example 4</h3><pre width=80>/**********************************************************************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 theeighth feature is overwritten with the fifth feature, and the resultingtable 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");}</pre><hr><a href = "../index.html"><IMG SRC="../home_motif.gif" ALIGN=bottom></a><a href = "index.html"><IMG SRC="../toc_motif.gif" ALIGN=bottom></a><a href = "chpt5.html"><IMG SRC="../previous_motif.gif" ALIGN=bottom></a><a href = "chpt7.html"><IMG SRC="../next_motif.gif" ALIGN=bottom></a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -