GDAL提供的gdalwarp.exe可以纠正有控制点信息和rpb文件的原始遥感影像,可以直接在命令行中调用,也可以在C++中调用,或者在Qt中使用界面传递参数。如果需要投影需要使用"-t_srs " + WKT格式的投影信息输出带有投影信息的校正影像。GDAL默认重采样为线性内插,可以通过-r \" bilinear\"设置重采样方式,-multi为使用多线程校正,这在校正多幅影像时比较有用。
#include <iostream>
using namespace std;
void main(int argc, char* argv[])
{
argv[1] = "C:\\Users\\Desktop\\test.tiff";
argv[2] = "C:\\Users\\Desktop\\rpc.tiff";
string srcFullPath = argv[1];
string outPath = argv[2];
string GDALWARP_EXE = "C:\\Users\\Desktop\\apps\\gdalwarp.exe";
string arguments = "--config GDAL_FILENAME_IS_UTF8 NO -rpc -r \"bilinear\" -multi " + srcFullPath + " " + outPath;
cout << "开始校正......" << endl;
char s[1000];
sprintf_s(s, "%s %s", GDALWARP_EXE.c_str(), arguments.c_str());
system(s);
cout << "校正完成!" << endl;
}
其效果如下: