C語言的實現
#include <stdio.h>
FILE *fpo;
FILE *fpt;
int main( int argc, char** argv )
{
fpo=fopen("po.txt", "w+");
fpt=fopen("pt.txt", "w+");
fprintf(fpo, "%d\t%d\n", pt1.x, pt1.y );
fprintf(fpt, "%d\t%d\n", pt2.x, pt2.y ); // 注意如果整型資料採用浮點形式輸出時,結果為0
fclose(fpo);
fclose(fpt);
printf("\n同時ALT鍵和滑鼠右鍵按下將縮小匹配結果圖\n\n"); // 輸出資料到顯示終端
fprintf( stderr, "Finding features in %s...\n", img2_file );
}
/////////////////////////////////////
C++語言的實現
#include <iostream>
#include <fstream>
using namespace std;
int main( int argc, char** argv )
{
ofstream poi1,poi2;
poi1.open("point_O.txt",ios::out|ios::app);
poi1.setf(ios::fixed, ios::floatfield);
poi1.setf(ios::showpoint);
poi2.open("point_T.txt",ios::out|ios::app);
poi2.setf(ios::fixed, ios::floatfield);
poi2.setf(ios::showpoint);
poi1<< matches[i].first.x << "\t" << matches[i].first.y << endl;
poi2<< matches[i].second.x << "\t" << matches[i].second.y << endl;
poi1.close();
poi2.close();
std::cout<< "Matches: " << matches.size(); // 輸出資料到顯示終端
}
// 注意如果在尾碼為C的源檔案上,採用C++輸出方法來輸出資料到txt檔案,VS2008編譯器可能報錯。解決方案是將尾碼改為CPP,並另建一個新的工程,然後採用c++的輸出方法,這樣比較方便些。如果C檔案中使用了一些非法關鍵字,那麼修改這些變數的定義,以免與c++的關鍵字重複定義。
http://blog.sina.com.cn/s/blog_702eac8701013k5m.html