上传正射C++代码

main
tian jiax 2024-02-20 10:28:15 +08:00
parent fc26347b44
commit f0f2a1552a
159 changed files with 38250 additions and 0 deletions

View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@ -0,0 +1,56 @@
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
*.dll
x64/
x64/*
.vs/
.vs/*
/x64/*
/.vs/*
./x64/*
./.vs/*
./x64/*
/x64/*
*.ipch
*.db
*.pdb
*.tlog
*.log
*.pdb
*.db
*.tiff
*.tif
*.jpg
Temporary*/

View File

@ -0,0 +1,510 @@
#pragma once
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// 本地方法
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <omp.h>
#include "baseTool.h"
#include "simptsn.h"
#include "SateOrbit.h"
#include <gdal_utils.h>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
#include "ImageMatch.h"
#include <opencv2/core/eigen.hpp>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace Eigen;
using namespace cv;
/// <summary>
/// cpnvert gdal to jpg
/// </summary>
/// <param name="gdal_path"></param>
/// <param name="jpg_path"></param>
/// <param name="band_ids"></param>
/// <returns></returns>
int ImageMatch::gdal2JPG(std::string gdal_path, std::string jpg_path, int band_ids)
{
std::cout << "convert gdal to jpg , beigining : \t" << getCurrentTimeString() << endl;
gdalImage gdalimg(gdal_path);
cv::Mat img(gdalimg.height, gdalimg.width, CV_8U);
{
int start_ids = 0;
int line_invert = int(80000000 / gdalimg.width);
Eigen::MatrixXd temp(line_invert, gdalimg.width);
double min_value = 0, temp_min = 0;
double max_value = 0, temp_max = 0;
// 线性拉伸2%
Eigen::MatrixXd hist = gdalimg.getHist(band_ids);
int count = 0;
int sum_count = gdalimg.height * gdalimg.width;
int rows = hist.rows();
for (int i = 0; i < rows; i++) {
if ((count+ hist(i, 1)) / sum_count > 0.01) {
min_value = hist(i, 0);
break;
}
count = count + hist(i, 1);
}
count = 0;
for (int i = rows - 1; i >= 0; i--) {
if ((count + hist(i, 1)) / sum_count > 0.01) {
max_value = hist(i, 0);
break;
}
count = count + hist(i, 1);
}
// 重新缩放最大值,最小值
std::cout << "min value \t" << min_value << "\n";
std::cout << "max value \t" << max_value << "\n";
start_ids = 0;
do {
line_invert = line_invert + start_ids < gdalimg.height ? line_invert : gdalimg.height - start_ids;
temp = gdalimg.getData(start_ids, 0, line_invert, gdalimg.width, band_ids);
temp = (temp.array() - min_value) * 250 / (max_value - min_value);
for (int i = 0; i < line_invert; i++) {
for (int j = 0; j < gdalimg.width; j++) {
if (temp(i, j) < 0) { temp(i, j) = 0; }
if (temp(i, j) > 250) { temp(i, j) = 250; }
uchar tempvalue = uchar(temp(i, j));;
img.at<uchar>(i + start_ids, j) = tempvalue;
}
}
start_ids = start_ids + line_invert;
} while (start_ids < gdalimg.height);
cv::Mat result1(gdalimg.height, gdalimg.width, CV_8U);
result1 = img;
//bilateralFilter(img, result1, 10, 80, 50);
vector<int> compression_params;
compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); //选择jpeg
compression_params.push_back(100); //在这个填入你要的图片质量
cv::Mat out = result1;
//cv::resize(img, out, cv::Size(img.cols, img.rows), cv::INTER_AREA);
cv::imwrite(jpg_path, out, compression_params);
}
std::cout << "convert gdal to jpg , overing : \t" << getCurrentTimeString() << endl;
std::cout << "=========================================\n";
std::cout << " convert gdal to jpg :\n";
std::cout << "input gdal img file path \t" << gdal_path << "\n";
std::cout << "input gdal img band \t" << band_ids << "\n";
std::cout << "out jpg file path \t" << jpg_path << "\n";
std::cout << "=========================================\n";
return 0;
}
/// <summary>
/// 获取模型匹配点
/// </summary>
/// <param name="ori_power_path"></param>
/// <param name="sim_sum_path"></param>
/// <returns></returns>
Eigen::MatrixXd ImageMatch::ImageMatch_ori_sim(std::string ori_power_path, std::string sim_sum_path, int roughSize, int PreciseSize, int scale, int searchSize, int roughStep,int preciseStep)
{
std::cout << "match point between ori and sim , overing : \t" << getCurrentTimeString() << endl;
std::cout << "match parameters : \n";
std::cout << "rough match templet size : \t" << roughSize << endl;
std::cout << "Precise match templet size : \t" << PreciseSize << endl;
std::cout << "Precise match wait search size : \t" << searchSize << endl;
std::cout << "Precise match scale : \t" << scale << endl;
std::cout << "Precise match step : \t" << preciseStep << endl;
std::cout << "input ori image path : \t" << ori_power_path << endl;
std::cout << "input sim image path : \t" << sim_sum_path << endl;
//读取影像
cv::Mat ori = openJPG(ori_power_path);
cv::Mat sim = openJPG(sim_sum_path);
int sim_rows = sim.rows;
int sim_cols = sim.cols;
int BlockCount = 0;
for (int i = 0; i < sim_rows; i=i+ roughSize) {
for (int j = 0; j < sim_cols; j=j+ roughSize) {
if (i + 2 * roughSize < sim_rows && j + 2 * roughSize < sim_cols) {
BlockCount++;
}
}
}
Eigen::MatrixXd sim_block(BlockCount,3);
BlockCount = 0;
for (int i = 0; i < sim_rows; i = i + roughSize) {
for (int j = 0; j < sim_cols; j = j + roughSize) {
if (i + 2 * roughSize < sim_rows && j + 2 * roughSize < sim_cols) {
sim_block(BlockCount, 0) = i;
sim_block(BlockCount, 1) = j;
BlockCount++;
}
}
}
Eigen::MatrixXd Tempmatchpoints(BlockCount, 6);
Tempmatchpoints = Tempmatchpoints.array() * 0;
int count = 0;
#pragma omp parallel for num_threads(8)
for (int ii = 0; ii < BlockCount; ii++) {
int i = sim_block(ii, 0);
int j = sim_block(ii, 1);
cv::Mat templet_mat = sim(Rect(j, i, 2 * roughSize, 2 * roughSize));
cv::Scalar mean1;
cv::Mat stddevMat;
cv::meanStdDev(templet_mat, mean1, stddevMat);
double minvalue = 0;
double maxvalue = 0;
cv::minMaxLoc(templet_mat, &minvalue, &maxvalue, NULL, NULL);//用于检测矩阵中最大值和最小值的位置
double sig = (stddevMat.at<double>(0, 0)) / (maxvalue - minvalue);
if (sig >1) {
//continue;
}
// 构建搜索域
int search_i = i - 2 * searchSize >= 0 ? i - 2 * searchSize >= 0 : 0;
int search_j = j - 2 * searchSize >= 0 ? j - 2 * searchSize >= 0 : 0;
int len_i = search_i + 4 * searchSize;
int len_j = search_j + 4 * searchSize;
len_i = search_i + len_i < ori.rows ? len_i : ori.rows - search_i - 1;
len_j = search_j + len_j < ori.cols ? len_j : ori.rows - search_j - 1;
cv::Mat serch = ori(Rect(search_j, search_i, len_j, len_i));
// 检索
cv::Mat result;
matchTemplate(serch, templet_mat, result, cv::TM_CCOEFF_NORMED);
Point minLoc;
Point maxLoc;
Point matchLoc;
double tempminVal = 100, tempmaxVal = 0;
cv::minMaxLoc(result, &tempminVal, &tempmaxVal, &minLoc, &maxLoc);//用于检测矩阵中最大值和最小值的位置
double offset_j = maxLoc.x + search_j;
double offset_i = maxLoc.y + search_i;
//cv::Scalar mean1;
//cv::Mat stddevMat;
//cv::meanStdDev(templet_mat, mean1, stddevMat);
Tempmatchpoints(ii, 0) = double(j); //sim_x
Tempmatchpoints(ii, 1) = double(i); //sim_y
Tempmatchpoints(ii, 2) = offset_j; // sim_x
Tempmatchpoints(ii, 3) = offset_i; // sim_y
Tempmatchpoints(ii, 4) = tempmaxVal; // maxVal
Tempmatchpoints(ii, 5) = sig; // maxVal
std::cout << 100.0*count/ BlockCount<<"\t:\t"<< count << " / " << BlockCount<<"\t" << Tempmatchpoints(ii, 0) << "\t" << Tempmatchpoints(ii, 1) << "\t" << Tempmatchpoints(ii, 2)
<< "\t" << Tempmatchpoints(ii, 3) << "\t" << Tempmatchpoints(ii, 4) << "\t" << Tempmatchpoints(ii, 5) << endl;
count++;
}
//BlockCount = 0;
count = 0;
for (int ii = 0; ii < BlockCount; ii++) {
if (Tempmatchpoints(ii, 4) > 0.7) {
std::cout << Tempmatchpoints(ii, 0) << "\t" << Tempmatchpoints(ii, 1) << "\t" << Tempmatchpoints(ii, 2)
<< "\t" << Tempmatchpoints(ii, 3) << "\t" << Tempmatchpoints(ii, 4) << "\t" << Tempmatchpoints(ii, 5) << endl;
//BlockCount++;
count++;
}
}
Eigen::MatrixXd matchpoints(count, 5);
count = 0;
for (int ii = 0; ii < BlockCount; ii++) {
if (Tempmatchpoints(ii, 4) > 0.7) {
matchpoints(count, 0)=Tempmatchpoints(ii, 0); //sim_x
matchpoints(count, 1) = Tempmatchpoints(ii, 1); //sim_y
matchpoints(count, 2) = Tempmatchpoints(ii, 2);// sim_x
matchpoints(count, 3) = Tempmatchpoints(ii, 3);// sim_y
matchpoints(count, 4) = Tempmatchpoints(ii, 4); // maxVal
count++;
}
}
/*
// step 1: 粗匹配,分块均匀匹配
std::cout << "rough match , begining : \t" << getCurrentTimeString() << endl;
double offset_x = 0, offset_y = 0;
cv::Mat mask = sim;
cv::Mat temp_ori = ori;
int offsetcount = 0;
Eigen::MatrixXd matchpoints;
{
int row_count = ori.rows;
int col_count = ori.cols;
int count = 0;
for (int i = roughSize; i < row_count; i = i + roughSize + 500) { // y
for (int j = roughSize; j < col_count; j = j + roughSize + 200) { //x
count = count + 1;
}
}
matchpoints= Eigen::MatrixXd::Zero(count, 5);//ori_x,ori_y,sim_x,sim_y,maxval
double minVal = 100, maxVal = 0.7;
omp_lock_t lock;
std::cout << "ori_x\tori_y\tsim_x\tsim_y\tmaxval \t" << endl;
omp_init_lock(&lock); // 初始化互斥锁
count = 0;
int search_count = 0;
#pragma omp parallel for num_threads(8)
for (int i = roughSize; i < row_count; i = i + roughSize+ 500) { // y
double tempminVal = 100, tempmaxVal = 0;
cv::Mat templet_mat;
cv::Mat result;
for (int j = roughSize; j < col_count; j = j + roughSize+ 200) { //x
templet_mat = ori(Rect(j - roughSize, i - roughSize, roughSize, roughSize));
matchTemplate(sim, templet_mat, result, cv::TM_CCOEFF_NORMED);
//normalize(result, result, 1, 0, cv::NORM_MINMAX);
// 通过函数 minMaxLoc 定位最匹配的位置;
omp_set_lock(&lock); //获得互斥器
Point minLoc;
Point maxLoc;
Point matchLoc;
cv::minMaxLoc(result, &tempminVal, &tempmaxVal, &minLoc, &maxLoc);//用于检测矩阵中最大值和最小值的位置
if (tempmaxVal >= maxVal) {
offset_x = maxLoc.x - (j - roughSize);
offset_y = maxLoc.y - (i - roughSize);
//maxVal = tempmaxVal;
matchpoints(count, 0) = (j - roughSize); //ori_x
matchpoints(count, 1) = (i - roughSize); //ori_y
double temp= maxLoc.x;
matchpoints(count, 2) = temp; // sim_x
temp = maxLoc.y;
matchpoints(count, 3) = temp; // sim_y
matchpoints(count, 4) = tempmaxVal; // maxVal
count = count + 1;
offsetcount += 1;
}
search_count = search_count + 1;
std::cout << j - roughSize << "\t" << i - roughSize << "\t" << maxLoc.x << "\t" << maxLoc.y << "\t" << tempmaxVal << "\t" << search_count << "\t" << matchpoints.rows() << endl;
omp_unset_lock(&lock); //释放互斥器
}
}
omp_destroy_lock(&lock); //销毁互斥器
offset_x = offset_x*1.0 / offsetcount;
offset_y = offset_y * 1.0 / offsetcount;
std::cout << "rough match point : "<< offsetcount <<"\n" << endl;
std::cout << "offset X : \t" << offset_x << endl;
std::cout << "offset Y : \t" << offset_y << endl;
std::cout << "maxVal : \t" << maxVal << endl;
}
std::cout << "rough match out : \t" << getCurrentTimeString() << endl;
// step1.1: 粗匹配绘制结果
std::string rough_math_path = sim_sum_path;
boost::algorithm::replace_last(rough_math_path, ".", "_ori_in_sim.");
std::cout << "ori in sim :\t" << rough_math_path << endl;
cv::Mat ori_in_sim = sim;
cv::rectangle(ori_in_sim, cv::Point(offset_x, offset_y), Point(offset_x + ori.cols, offset_y + ori.rows), Scalar(0, 255, 0), 2, 8, 0);
vector<int> compression_params;
compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); //选择jpeg
compression_params.push_back(100); //在这个填入你要的图片质量
cv::Mat out = ori_in_sim;
cv::imwrite(rough_math_path, out, compression_params);
if (offsetcount == 0) { // 表示全局粗匹配失败,无法进行精校准,考虑直接定位法
std::cout << "there are not effective point in rought match \t" << endl;
return Eigen::MatrixXd(0, 5);
}
Eigen::MatrixXd matchpointstemp(offsetcount,5);
for (int i = 0; i < matchpoints.rows(); i++) {
if (matchpoints(i, 4) > 0.7) {
for (int j = 0; j < matchpoints.cols(); j++) {
matchpointstemp(i, j) = matchpoints(i, j);
}
}
}
matchpoints = matchpointstemp;
*/
//std::cout << "rough match , overing : \t" << getCurrentTimeString() << endl;
//// step 2: 精匹配,
//std::cout << "Precise match , begining : \t" << getCurrentTimeString() << endl;
//Eigen::MatrixXd matchpoints;
//{
// int row_count = ori.rows;
// int col_count = ori.cols;
// int count = 0;
// for (int i = PreciseSize; i < row_count; i = i + preciseStep) { // y
// for (int j = PreciseSize; j < col_count; j = j + preciseStep) { //x
// count = count + 1;
// }
// }
// matchpoints(count, 5);//ori_x,ori_y,sim_x,sim_y,maxval
// double templeta_size = PreciseSize * scale;
// double search_size = searchSize * scale;
// count = 0;
// double ori_start_x, ori_start_y;
// double sim_start_x, sim_start_y;
// row_count = row_count - PreciseSize;
// col_count = col_count - PreciseSize;
// omp_lock_t lock;
// omp_init_lock(&lock); // 初始化互斥锁
// // 以搜索范围为核心计算
// #pragma omp parallel for num_threads(8)
// for (int i = searchSize + offset_y; i < row_count; i = i + preciseStep) { // y
// cv::Mat templet_mat;
// cv::Mat search_mat;
// cv::Mat resample_templet_mat;
// cv::Mat resample_search_mat;
// cv::Mat result;
// double minVal = 100, maxVal = 0;
// for (int j = searchSize + offset_x; j < col_count; j = j + preciseStep) { //x
// // 计算 起始点
// sim_start_x = j - searchSize;
// sim_start_y = i - searchSize;
// ori_start_x = (j - searchSize / 2) - PreciseSize / 2;
// ori_start_y = (i - searchSize / 2) - PreciseSize / 2;
// // 匹配模板,待匹配模板
// templet_mat = ori(Rect(ori_start_x, ori_start_y, PreciseSize, PreciseSize));
// search_mat = ori(Rect(sim_start_x, sim_start_y, searchSize, searchSize));
// resample_templet_mat = resampledMat(templet_mat, templeta_size);
// resample_search_mat = resampledMat(search_mat, search_size);
// matchTemplate(sim, templet_mat, result, cv::TM_CCORR_NORMED);
// // 通过函数 minMaxLoc 定位最匹配的位置;
// cv::Point minLoc; cv::Point maxLoc;
// cv::Point matchLoc;
// cv::minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc);//用于检测矩阵中最大值和最小值的位置
// if (maxVal > 0.7) {
// omp_set_lock(&lock); //获得互斥器
//
// matchpoints(count, 0) = ori_start_x; //ori_x
// matchpoints(count, 1) = ori_start_y; //ori_y
// matchpoints(count, 2) = sim_start_x + maxLoc.x * 1.0 / scale; // sim_x
// matchpoints(count, 3) = sim_start_y + maxLoc.y * 1.0 / scale; // sim_y
// matchpoints(count, 4) = maxVal; // maxVal
// count = count + 1;
//
// omp_unset_lock(&lock); //释放互斥器
// }
// }
// }
// omp_destroy_lock(&lock); //销毁互斥器
//}
//
std::cout << "Precise match , ending : \t" << getCurrentTimeString() << endl;
std::cout << "=======================================================================" << endl;
std::cout << "match point result: \t" << getCurrentTimeString() << endl;
std::cout << "=======================================================================" << endl;
{
std::cout << "ori_x\tori_y\tsim_x\tsim_y\tmaxval \t" << endl;
int count = matchpoints.rows();
for (int i = 0; i < count; i++) {
std::cout << matchpoints(i, 0) << "\t" << matchpoints(i, 1) << "\t" << matchpoints(i, 2) << "\t" << matchpoints(i, 3) << "\t" << matchpoints(i, 4) << endl;
}
}
std::cout << "=======================================================================" << endl;
return matchpoints;
}
Eigen::MatrixXd ImageMatch::CreateMatchModel(Eigen::MatrixXd offsetXY_matrix)
{
// ori_x,oir_y,to_x,to_y,maxval
// 0 1 2 3 4
Eigen::MatrixXd offset_x= offsetXY_matrix.col(2) - offsetXY_matrix.col(0);
Eigen::MatrixXd offset_y = offsetXY_matrix.col(3) - offsetXY_matrix.col(1);
// 计算最小二乘法模型
Eigen::MatrixXd temp(offset_x.rows(), 6);
temp.col(0) = temp.col(0).array()*0+1; //1
temp.col(1) = offsetXY_matrix.col(3).array(); // r
temp.col(2) = offsetXY_matrix.col(2).array(); // c
temp.col(3) = offsetXY_matrix.col(3).array().pow(2);//r2
temp.col(4) = offsetXY_matrix.col(2).array().pow(2);//c2
temp.col(5) = offsetXY_matrix.col(2).array()* offsetXY_matrix.col(3).array();//r*c
Eigen::MatrixXd matchmodel(2, 6);
Eigen::MatrixXd tempx= temp.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(offset_x);//x c
Eigen::MatrixXd tempy = temp.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(offset_y);//y r
matchmodel.row(1) = tempx;
matchmodel.row(0) = tempy;
return matchmodel;
}
Eigen::MatrixXd ImageMatch::correctMatchModel(Eigen::MatrixXd r, Eigen::MatrixXd c)
{
Eigen::MatrixXd a0 = Eigen::MatrixXd::Ones(1,r.cols());
Eigen::MatrixXd a1 = r.array();
Eigen::MatrixXd a2 = c.array();
Eigen::MatrixXd a3 = r.array().pow(2);
Eigen::MatrixXd a4 = c.array().pow(2);
Eigen::MatrixXd a5 = r.array() * c.array();
Eigen::MatrixXd offset(2, r.cols());//r,c
offset.row(0) = r.array() + this->match_model(0, 0) * a0.array() + this->match_model(0, 1) * a1.array() + this->match_model(0, 2) * a2.array() + this->match_model(0, 3) * a3.array() + this->match_model(0, 4) * a4.array() + this->match_model(0, 5) * a5.array();
offset.row(1) = c.array() + this->match_model(1, 0) * a0.array() + this->match_model(1, 1) * a1.array() + this->match_model(1, 2) * a2.array() + this->match_model(1, 3) * a3.array() + this->match_model(1, 4) * a4.array() + this->match_model(1, 5) * a5.array();
return offset;
}
int ImageMatch::outMatchModel(std::string matchmodel_path)
{
ofstream fout(matchmodel_path, ios::trunc);
fout << "model:" << endl;
fout << this->match_model(0, 0) << " " << this->match_model(0, 1) << " " << this->match_model(0, 2) << " " << this->match_model(0, 3) << " " << this->match_model(0, 4) << " " << this->match_model(0, 5) << endl;
fout << this->match_model(1, 0) << " " << this->match_model(1, 1) << " " << this->match_model(1, 2) << " " << this->match_model(1, 3) << " " << this->match_model(1, 4) << " " << this->match_model(1, 5) << endl;
fout << "model_points:" << endl;
std::cout << "ori_x\tori_y\tsim_x\tsim_y\tmaxval \t" << endl;
int count = this->offsetXY_matrix.rows();
for (int i = 0; i < count; i++) {
std::cout << this->offsetXY_matrix(i, 0) << "\t" << this->offsetXY_matrix(i, 1) << "\t" << this->offsetXY_matrix(i, 2) << "\t" << this->offsetXY_matrix(i, 3) << "\t" << this->offsetXY_matrix(i, 4) << endl;
}
fout.close();
return 0;
}
/// <summary>
/// 读取jpg 文件
/// </summary>
/// <param name="jpg_path"></param>
/// <returns></returns>
cv::Mat openJPG(std::string jpg_path)
{
cv::Mat image = cv::imread(jpg_path);
if (image.data == nullptr) //nullptr是c++11新出现的空指针常量
{
throw new exception("图片文件不存在");
}
return image;
}
cv::Mat resampledMat(cv::Mat& image, int targetSize, int interpolation)
{
cv::Mat out;
cv::resize(image, out, cv::Size(targetSize, targetSize), interpolation);
return out;
}

View File

@ -0,0 +1,39 @@
#pragma once
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// ±¾µØ·½·¨
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <boost/filesystem.hpp>
#include <omp.h>
#include "baseTool.h"
#include "simptsn.h"
#include "SateOrbit.h"
#include <gdal_utils.h>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
using namespace std;
using namespace Eigen;
class ImageMatch
{
public:
int gdal2JPG(std::string gdal_path,std::string jpg_path,int band_ids);
Eigen::MatrixXd ImageMatch_ori_sim(std::string ori_power_path, std::string sim_sum_path, int roughSize=500, int Precise=300,int scale=5, int searchSize=1000,int roughStep=400 ,int preciseStep=300);
Eigen::MatrixXd CreateMatchModel(Eigen::MatrixXd offsetXY_matrix);
Eigen::MatrixXd correctMatchModel(Eigen::MatrixXd r, Eigen::MatrixXd c);
int outMatchModel(std::string matchmodel_path);
//²ÎÊý
Eigen::MatrixXd offsetXY_matrix;
Eigen::MatrixXd match_model;
};
cv::Mat openJPG(std::string jpg_path);
cv::Mat resampledMat(cv::Mat& templet, int targetSize, int interpolation = cv::INTER_AREA);

View File

@ -0,0 +1 @@
#include "OctreeNode.h"

View File

@ -0,0 +1,264 @@
#pragma once
#include <iostream>
using namespace std;
//定义八叉树节点类
template<class T>
struct OctreeNode
{
T data; //节点数据
T xmin, xmax; //节点坐标,即六面体个顶点的坐标
T ymin, ymax;
T zmin, zmax;
OctreeNode <T>* top_left_front, * top_left_back; //该节点的个子结点
OctreeNode <T>* top_right_front, * top_right_back;
OctreeNode <T>* bottom_left_front, * bottom_left_back;
OctreeNode <T>* bottom_right_front, * bottom_right_back;
OctreeNode //节点类
(T nodeValue = T(),
T xminValue = T(), T xmaxValue = T(),
T yminValue = T(), T ymaxValue = T(),
T zminValue = T(), T zmaxValue = T(),
OctreeNode<T>* top_left_front_Node = NULL,
OctreeNode<T>* top_left_back_Node = NULL,
OctreeNode<T>* top_right_front_Node = NULL,
OctreeNode<T>* top_right_back_Node = NULL,
OctreeNode<T>* bottom_left_front_Node = NULL,
OctreeNode<T>* bottom_left_back_Node = NULL,
OctreeNode<T>* bottom_right_front_Node = NULL,
OctreeNode<T>* bottom_right_back_Node = NULL)
:data(nodeValue),
xmin(xminValue), xmax(xmaxValue),
ymin(yminValue), ymax(ymaxValue),
zmin(zminValue), zmax(zmaxValue),
top_left_front(top_left_front_Node),
top_left_back(top_left_back_Node),
top_right_front(top_right_front_Node),
top_right_back(top_right_back_Node),
bottom_left_front(bottom_left_front_Node),
bottom_left_back(bottom_left_back_Node),
bottom_right_front(bottom_right_front_Node),
bottom_right_back(bottom_right_back_Node) {}
};
//创建八叉树
template <class T>
void createOctree(OctreeNode<T>*& root, int maxdepth, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
{
//cout<<"处理中,请稍候……"<<endl;
maxdepth = maxdepth - 1; //每递归一次就将最大递归深度-1
if (maxdepth >= 0)
{
root = new OctreeNode<T>();
//cout << "请输入节点值:";
//root->data =9;//为节点赋值可以存储节点信息如物体可见性。由于是简单实现八叉树功能简单赋值为9。
cin >> root->data; //为节点赋值
root->xmin = xmin; //为节点坐标赋值
root->xmax = xmax;
root->ymin = ymin;
root->ymax = ymax;
root->zmin = zmin;
root->zmax = zmax;
double xm = (xmax - xmin) / 2;//计算节点个维度上的半边长
double ym = (ymax - ymin) / 2;
double zm = (ymax - ymin) / 2;
//递归创建子树,根据每一个节点所处(是几号节点)的位置决定其子结点的坐标。
createOctree(root->top_left_front, maxdepth, xmin, xmax - xm, ymax - ym, ymax, zmax - zm, zmax);
createOctree(root->top_left_back, maxdepth, xmin, xmax - xm, ymin, ymax - ym, zmax - zm, zmax);
createOctree(root->top_right_front, maxdepth, xmax - xm, xmax, ymax - ym, ymax, zmax - zm, zmax);
createOctree(root->top_right_back, maxdepth, xmax - xm, xmax, ymin, ymax - ym, zmax - zm, zmax);
createOctree(root->bottom_left_front, maxdepth, xmin, xmax - xm, ymax - ym, ymax, zmin, zmax - zm);
createOctree(root->bottom_left_back, maxdepth, xmin, xmax - xm, ymin, ymax - ym, zmin, zmax - zm);
createOctree(root->bottom_right_front, maxdepth, xmax - xm, xmax, ymax - ym, ymax, zmin, zmax - zm);
createOctree(root->bottom_right_back, maxdepth, xmax - xm, xmax, ymin, ymax - ym, zmin, zmax - zm);
}
}
int i = 1;
//先序遍历八叉树
template <class T>
void preOrder(OctreeNode<T>*& p)
{
if (p)
{
//cout << i << ".当前节点的值为:" << p->data << "\n坐标为";
//cout << "xmin: " << p->xmin << " xmax: " << p->xmax;
//cout << "ymin: " << p->ymin << " ymax: " << p->ymax;
//cout << "zmin: " << p->zmin << " zmax: " << p->zmax;
i += 1;
cout << endl;
preOrder(p->top_left_front);
preOrder(p->top_left_back);
preOrder(p->top_right_front);
preOrder(p->top_right_back);
preOrder(p->bottom_left_front);
preOrder(p->bottom_left_back);
preOrder(p->bottom_right_front);
preOrder(p->bottom_right_back);
cout << endl;
}
}
//求八叉树的深度
template<class T>
int depth(OctreeNode<T>*& p)
{
if (p == NULL)
return -1;
int h = depth(p->top_left_front);
return h + 1;
}
template<class T>
int num(OctreeNode<T>*& p)
{
if (p == NULL)
return 0;
return 1 + num(p->top_left_front) + num(p->top_left_back) + num(p->top_right_back) + num(p->top_right_front) + num(p->bottom_left_back) + num(p->bottom_left_front) + num(p->bottom_right_back) + num(p->bottom_right_front);
}
//计算单位长度,为查找点做准备
int cal(int num)
{
int result = 1;
if (1 == num)
result = 1;
else
{
for (int i = 1; i < num; i++)
result = 2 * result;
}
return result;
}
template<class T>
int find(OctreeNode<T>*& p, double x, double y, double z)
{
//查找点
int maxdepth = 0;
int times = 0;
static double xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0;
int tmaxdepth = 0;
double txm = 1, tym = 1, tzm = 1;
double xm = (p->xmax - p->xmin) / 2;
double ym = (p->ymax - p->ymin) / 2;
double zm = (p->ymax - p->ymin) / 2;
times++;
if (x > xmax || x<xmin || y>ymax || y<ymin || z>zmax || z < zmin)
{
//cout << "该点不在场景中!" << endl;
return 0;
}
if (x <= p->xmin + txm && x >= p->xmax - txm && y <= p->ymin + tym && y >= p->ymax - tym && z <= p->zmin + tzm && z >= p->zmax - tzm)
{
//cout << endl << "找到该点!" << "该点位于" << endl;
//cout << "xmin: " << p->xmin << " xmax: " << p->xmax;
//cout << "ymin: " << p->ymin << " ymax: " << p->ymax;
//cout << "zmin: " << p->zmin << " zmax: " << p->zmax;
//cout << "节点内!" << endl;
//cout << "共经过" << times << "次递归!" << endl;
return 1;
}
else if (x < (p->xmax - xm) && y < (p->ymax - ym) && z < (p->zmax - zm))
{
find(p->bottom_left_back, x, y, z);
}
else if (x < (p->xmax - xm) && y<(p->ymax - ym) && z>(p->zmax - zm))
{
find(p->top_left_back, x, y, z);
}
else if (x > (p->xmax - xm) && y < (p->ymax - ym) && z < (p->zmax - zm))
{
find(p->bottom_right_back, x, y, z);
}
else if (x > (p->xmax - xm) && y<(p->ymax - ym) && z>(p->zmax - zm))
{
find(p->top_right_back, x, y, z);
}
else if (x<(p->xmax - xm) && y>(p->ymax - ym) && z < (p->zmax - zm))
{
find(p->bottom_left_front, x, y, z);
}
else if (x<(p->xmax - xm) && y>(p->ymax - ym) && z > (p->zmax - zm))
{
find(p->top_left_front, x, y, z);
}
else if (x > (p->xmax - xm) && y > (p->ymax - ym) && z < (p->zmax - zm))
{
find(p->bottom_right_front, x, y, z);
}
else if (x > (p->xmax - xm) && y > (p->ymax - ym) && z > (p->zmax - zm))
{
find(p->top_right_front, x, y, z);
}
}
//main函数
/*
int main()
{
OctreeNode<double>* rootNode = NULL;
int choiced = 0;
cout << "系统开始前请先创建八叉树" << endl;
cout << "请输入最大递归深度:" << endl;
cin >> maxdepth;
cout << "请输入外包盒坐标顺序如下xmin,xmax,ymin,ymax,zmin,zmax" << endl;
cin >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax;
if (maxdepth >= 0 || xmax > xmin || ymax > ymin || zmax > zmin || xmin > 0 || ymin > 0 || zmin > 0)
{
tmaxdepth = cal(maxdepth);
txm = (xmax - xmin) / tmaxdepth;
tym = (ymax - ymin) / tmaxdepth;
tzm = (zmax - zmin) / tmaxdepth;
createOctree(rootNode, maxdepth, xmin, xmax, ymin, ymax, zmin, zmax);
}
while (true)
{
system("cls");
cout << "请选择操作:\n";
cout << "\t1.计算空间中区域的个数\n";
cout << "\t2.先序遍历八叉树\n";
cout << "\t3.查看树深度\n";
cout << "\t4.查找节点 \n";
cout << "\t0.退出\n";
cin >> choiced;
if (choiced == 0)
return 0;
if (choiced == 1)
{
system("cls");
cout << "空间区域个数" << endl;
cout << num(rootNode);
}
if (choiced == 2)
{
system("cls");
cout << "先序遍历八叉树结果:/n";
i = 1;
preOrder(rootNode);
cout << endl;
system("pause");
}
if (choiced == 3)
{
system("cls");
int dep = depth(rootNode);
cout << "此八叉树的深度为" << dep + 1 << endl;
system("pause");
}
if (choiced == 4)
{
system("cls");
cout << "请输入您希望查找的点的坐标顺序如下x,y,z\n";
double x, y, z;
cin >> x >> y >> z;
times = 0;
cout << endl << "开始搜寻该点……" << endl;
find(rootNode, x, y, z);
system("pause");
}
else
{
system("cls");
cout << "\n\n错误选择!\n";
system("pause");
}
}
*/

View File

@ -0,0 +1,49 @@
// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <armadillo>
//using namespace arma;
using namespace std;
using namespace Eigen;
int main(int argc, char* argv[])
{
cout << cos(30) << endl;
cout << cos(45) << endl;
cout << cos(60) << endl;
cout << pow(1, 3) << endl;
cout << pow(2, 3) << endl;
Eigen::MatrixXd a = Eigen::MatrixXd::Ones(6, 3); // 随机初始化矩阵
Eigen::MatrixXd b = Eigen::MatrixXd::Ones(6,3).array()*2;
Eigen::Vector3d p(3, 1, 2);
double start = clock();
Eigen::MatrixXd c = (a.array()/b.array());// .rowwise().sum();
double endd = clock();
double thisTime = (double)(endd - start) / CLOCKS_PER_SEC;
cout << thisTime << endl;
cout << c.rows() << "," << c.cols() << endl;
cout << c(Eigen::all, { 0,1}) << endl;
system("PAUSE");
return 0;
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{db6d05f9-271e-4954-98ed-591ab27bb05e}</ProjectGuid>
<RootNamespace>ConsoleApplication1</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>Parallel</UseInteloneMKL>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\lib\release;C:\Program Files %28x86%29\Intel\oneAPI\compiler\2022.1.0\windows\compiler\lib\intel64_win;C:\Program Files %28x86%29\Intel\oneAPI\mkl\2022.1.0\lib\intel64;$(oneMKLOmpLibDir);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>mkl_scalapack_ilp64.lib;mkl_cdft_core.lib;mkl_intel_ilp64.lib;mkl_sequential.lib;mkl_core.lib;mkl_blacs_intelmpi_ilp64.lib;impi.lib;mkl_intel_thread.lib;libiomp5md.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ConsoleApplication1.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ConsoleApplication1.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@ -0,0 +1,191 @@
// PSTM_simulation_windows.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include <vector>
#include <memory>
#include <medparam.h>
#include <malloc.h>
#include <string>
#include "ParameterInFile.h"
#include <time.h>  
#include <crtdbg.h>
//
// 引用变量的空间
//
using namespace std;
int test(ParameterInFile parmas) {
cout << parmas.doppler_para[0] << endl;
return 0;
}
/// <summary>
/// 检查环境,主要检查内存情况
/// </summary>
/// <param name="parmas"></param>
/// <returns></returns>
bool check(ParameterInFile& parmas) {
return true;
}
sim_block testsimblock(int a = 1) {
sim_block result(1, 2, 1, 2, 1, 1);
return result;
}
int Fmaintest() {
sim_block temp = testsimblock(1);
point lla = point{ 110,22,33 };
point xyz = point{ -2023567.6297546995,5559706.3694903487,2374425.2573203994 };
point ttxyz = LLA2XYZ(lla);
point ttlla = XYZ2LLA(xyz);
VectorPoint v1 = getVector(xyz, ttxyz);
VectorPoint v2 = getVector(lla, ttlla);
cout << getModule(v1) << std::endl;
cout << getModule(v2) << std::endl;
return 0;
}
int main(int argc, char* argv[])
{
// try {
testPP();
std::cout << "PSTM_simulation_windows.exe [mode] [pars_path] [resample_para] [--thead_num]" << endl;// 输出帮助文档
std::cout << "[mode]: 调用模块 0,1,2 " << endl;
std::cout << " 0:默认路径 " << endl;
std::cout << " 1:计算正射模拟图 " << endl;
std::cout << " 2:计算正射校正插值算法与强度图生成 " << endl;
std::cout << "[para_path]:必选 正射模拟参数文件 " << endl;
std::cout << "[resample_para]:当mode==2时必选 计算正射校正插值算法与强度图生成参数文件 " << endl;
std::cout << "[--thead_num]:可选 线程数默认是8" << endl;
std::cout << "example:" << endl;
std::cout << "PSTM_simulation_windows.exe 2 C:\\sim_sar_paras.txt D:\\resample_para.txt --thead_num 8" << endl;
int mode = -1;
int thread_num = 6;
std::string pars_path = ""; //配置文件代码
std::string resample_para = "";
std::string thread_str = "--thead_num";
try {
if (argc < 3) {
std::cout << "缺少参数" << endl;
//return 0;
}
for (int i = 1; i < argc; i++) {
if (i == 1) {
mode = stoi(argv[1]);
if (mode == 0) {
pars_path = "D:\\otherSoftware\\Ortho\\Ortho\\ortho_indirect\\datafolder\\testworkspace4\\sim_sar_paras.txt";
resample_para = "D:\\otherSoftware\\Ortho\\Ortho\\ortho_indirect\\datafolder\\testworkspace4\\resample_para.txt";
mode = 2;
break;
}
}
if (i == 2) {
pars_path= argv[2];
}
if (i == 3) {
if (mode == 1) {
break;
}
else {
resample_para = argv[3];
}
}
}
for (int i = 1; i < argc; i++) {
std::string temp = argv[i];
if (temp== thread_str) {
i = i + 1;
if (i >= argc) { break; }
else {
thread_num = stoi(argv[i]);
}
}
}
}
catch(exception ex) {
std::cout << "参数解析错误" << endl;
// 开始test模式
return -1;
}
if (1) {
pars_path = "D:\\MicroWorkspace\\C-SAR\\Ortho\\Temporary\\sim_sar_paras.txt";
resample_para = "";// "D:\\otherSoftware\\Ortho\\Ortho\\ortho_indirect\\datafolder\\testworkspace\\resample_para.txt";
mode = 1;
}
std::cout << "线程数:" << thread_num << endl;
//Fmaintest();
cout << mode << "\n";
int d=round(3.13);
if (mode == 1) {
cout << "sim_sar program run....\n";
cout << pars_path << "\n";
ParameterInFile parmas(pars_path);
//testPTSN(parmas);
if (!check(parmas)) {
throw "不符合运行条件";
return 0;
}
//SimProcess(parmas, 32);
SimProcess_LVY(parmas, thread_num);
// ResamplingSim(parmas);
// 检查解析结果
cout << "programover" << "\n";
}
else if (mode == 2) {
try {
ConvertResampleParameter converPara(resample_para);
ParameterInFile parmas(pars_path);
testPTSN(pars_path);
SimProcess_Calsim2ori(parmas, converPara, thread_num);
SimProcess_ResamplingOri2Orth(parmas, converPara, thread_num);
SimProcess_Calspow(parmas, converPara, thread_num);
}
catch(exception& ex) {
std::cout << ex.what() << std::endl;
return -1;
}
//SimProcess_CalXYZ(parmas, converPara,16);
//ConverOri2Sim(parmas, converPara);
//CalCoondinaryXYZOfSAR(parmas, converPara);
}
// }
//catch (exception ex) {
// 防止内存泄露,保证内存能够被调用
// throw "error";
// }
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

View File

@ -0,0 +1,41 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32602.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PSTM_simulation_windows", "PSTM_simulation_windows.vcxproj", "{418EA1F3-8583-4728-ABC4-45B98FC053BF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication1", "..\ConsoleApplication1\ConsoleApplication1.vcxproj", "{DB6D05F9-271E-4954-98ED-591AB27BB05E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Debug|x64.ActiveCfg = Debug|x64
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Debug|x64.Build.0 = Debug|x64
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Debug|x86.ActiveCfg = Debug|Win32
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Debug|x86.Build.0 = Debug|Win32
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Release|x64.ActiveCfg = Release|x64
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Release|x64.Build.0 = Release|x64
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Release|x86.ActiveCfg = Release|Win32
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Release|x86.Build.0 = Release|Win32
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Debug|x64.ActiveCfg = Debug|x64
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Debug|x64.Build.0 = Debug|x64
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Debug|x86.ActiveCfg = Debug|Win32
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Debug|x86.Build.0 = Debug|Win32
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Release|x64.ActiveCfg = Release|x64
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Release|x64.Build.0 = Release|x64
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Release|x86.ActiveCfg = Release|Win32
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C2C843D5-F54A-4745-908B-8387B47D60A3}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{418ea1f3-8583-4728-abc4-45b98fc053bf}</ProjectGuid>
<RootNamespace>PSTMsimulationwindows</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>No</UseInteloneMKL>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>Parallel</UseInteloneMKL>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExternalIncludePath>$(ExternalIncludePath)</ExternalIncludePath>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExternalIncludePath>$(ExternalIncludePath)</ExternalIncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<OpenMPSupport>true</OpenMPSupport>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="common.cpp" />
<ClCompile Include="ParameterInFile.cpp" />
<ClCompile Include="PSTM_simulation_windows.cpp" />
<ClCompile Include="taskprocess.cpp" />
<ClCompile Include="threadpool.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="common.h" />
<ClInclude Include="ParameterInFile.h" />
<ClInclude Include="taskprocess.h" />
<ClInclude Include="threadpool.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,576 @@
#pragma once
#include <iostream>
#include <memory>
#include <vector>
#include <future>
#include <complex>
#include "gdalwarper.h"
#define PI_180 180/3.141592653589793238462643383279;
#define T180_PI 3.141592653589793238462643383279/180;
#define Radians2Degrees(Radians) Radians*PI_180
#define Degrees2Radians(Degrees) Degrees*T180_PI
const long double PI=3.141592653589793238462643383279;
const long double epsilon = 0.000000000000001;
const long double pi = 3.14159265358979323846;
const long double d2r = pi / 180;
const long double r2d = 180 / pi;
const long double a = 6378137.0; //椭球长半轴
const long double f_inverse = 298.257223563; //扁率倒数
const long double b = a - a / f_inverse;
const long double e = sqrt(a * a - b * b) / a;
const long double eSquare = e*e;
int testPP();
using namespace std;
///
/// 内敛函数
///
struct point // 点 SAR影像的像素坐标
{
long double x; // 纬度 lat pixel_row
long double y; // 经度 lon pixel_col
long double z; // 高程 ati pixel_time
};
struct VectorPoint {
long double x;
long double y;
long double z;
};
/// <summary>
/// 将经纬度转换为地固参心坐标系
/// </summary>
/// <param name="XYZP">经纬度点--degree</param>
/// <returns>投影坐标系点</returns>
inline point LLA2XYZ(point& LLA) {
long double L = LLA.x * d2r;
long double B = LLA.y * d2r;
long double H = LLA.z;
long double sinB = sin(B);
long double cosB = cos(B);
//long double N = a / sqrt(1 - e * e * sin(B) * sin(B));
long double N = a / sqrt(1 - eSquare * sinB * sinB);
point result = { 0,0,0 };
result.x = (N + H) * cosB * cos(L);
result.y = (N + H) * cosB * sin(L);
//result.z = (N * (1 - e * e) + H) * sin(B);
result.z = (N * (1 - eSquare) + H) * sinB;
return result;
}
/// <summary>
/// 将地固参心坐标系转换为经纬度
/// </summary>
/// <param name="XYZ">固参心坐标系</param>
/// <returns>经纬度--degree</returns>
point XYZ2LLA(point& XYZ);
/// <summary>
/// 计算两个点之间的XY平面欧式距离的平方
/// </summary>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <returns></returns>
inline long double caldistanceXY(point& p1, point& p2) {
//return pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2);
return (p1.x - p2.x)* (p1.x - p2.x) + (p1.y - p2.y)* (p1.y - p2.y);
}
/// <summary>
/// 使用两个点,生成向量 p1-->p2
/// </summary>
/// <param name="p1">p1</param>
/// <param name="p2">p2</param>
/// <returns>向量</returns>
inline VectorPoint getVector(point& p1, point& p2) {
VectorPoint result = { 0,0,0 };
result.x = p2.x - p1.x;
result.y = p2.y - p1.y;
result.z = p2.z - p1.z;
return result;
}
/// <summary>
/// 获取向量的模
/// </summary>
/// <param name="vector1">向量</param>
/// <returns>向量模</returns>
inline long double getModule(VectorPoint& vector1) {
//return sqrt(pow(vector1.x, 2) + pow(vector1.y, 2) + pow(vector1.z, 2));
return sqrt(vector1.x* vector1.x + vector1.y* vector1.y + vector1.z* vector1.z);
}
inline long double getModuleV1V2(VectorPoint& v1, VectorPoint& v2)
{
return sqrt((v1.x * v1.x + v1.y * v1.y + v1.z * v1.z) * (v2.x * v2.x + v2.y * v2.y + v2.z * v2.z));
}
/// <summary>
/// 向量夹角的角度( 角度)
/// </summary>
/// <param name="vector1">向量</param>
/// <returns>向量夹角的角度</returns>
inline long double getVectorAngle(VectorPoint& vector1,VectorPoint& vector2) {
//return Radians2Degrees( acos((vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z) / (getModule(vector1) * getModule(vector2))));
return Radians2Degrees(acos((vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z) / (getModuleV1V2(vector1, vector2))));
}
/// <summary>
/// 向量的夹角值
/// </summary>
/// <param name="vector1">向量</param>
/// <returns>向量夹角的角度</returns>
inline long double getVectorAngleValue(VectorPoint& vector1, VectorPoint& vector2) {
//return (vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z) / (getModule(vector1) * getModule(vector2));
return (vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z) / (getModuleV1V2(vector1, vector2));
}
/// <summary>
/// 向量点乘
/// </summary>
/// <param name="V1">向量1</param>
/// <param name="v2">向量2</param>
/// <returns>点乘值</returns>
inline long double Vectordot(VectorPoint& V1, VectorPoint& v2) {
return V1.x * v2.x + V1.y * v2.y + V1.z * v2.z;
}
/// <summary>
/// 向量点乘
/// </summary>
/// <param name="V1">向量1</param>
/// <param name="lamda">系数值</param>
/// <returns>向量与数之间的插值</returns>
inline VectorPoint VectordotNumber(VectorPoint& V1, long double lamda) {
V1.x = V1.x * lamda;
V1.y = V1.y * lamda;
V1.z = V1.z * lamda;
return V1;
}
/// <summary>
/// 向量叉乘
/// 旋转方向v1->v2
/// </summary>
/// <param name="v1">v1</param>
/// <param name="v2">v2</param>
/// <returns>叉乘的结果向量</returns>
inline VectorPoint VectorFork(VectorPoint &v1, VectorPoint& v2) {
VectorPoint result{ 0,0,0 };
result.x = v1.y * v2.z - v1.z * v2.y;
result.y =v1.z*v2.x -v1.x * v2.z;
result.z = v1.x * v2.y - v1.y * v2.x;
return result;
}
//
// 参数文件解析
//
//参数文件标准格式
// 文件值 类型 对应的代号
// DEM文件的路径 str dem_path
// 模拟影像输出路径 str sar_sim_path
// 模拟影像的宽 int
// 模拟影像的高 int
// 模拟影像的匹配坐标文件输出路径 str sar_sim_match_point_x_path
// 模拟影像的匹配坐标X输出路径 str sar_sim_match_point_x_path
// 模拟影像的匹配坐标Y输出路径 str sar_sim_match_point_y_path
// 模拟影像的匹配坐标Z输出路径 str sar_sim_match_point_z_path
// 采样率 long double sample_f
// 近斜距 long double R0
// 成像起始时间 long double starttime ---UTC 时间
// 光速 long double
// 波长 long double
// 多普勒参考时间 long double TO ---UTC 时间
// 脉冲重复频率 long double PRF
// 斜距采样间隔 long double delta_R
// 多普勒系数个数 int
// 多普勒系数1 long double
// 多普勒系数2 long double
// ....
// 卫星轨道模型是否为多项式模型 int 1 是。0 不是
// 卫星轨道模型多项式次数 int 4 5
// 卫星轨道模型起始时间 long double
// 卫星轨道模型X值系数1 long double
// ....
// 卫星轨道模型Y值系数1 long double
// ...
// 卫星轨道模型Z值系数1 long double
// ...
// 卫星轨道模型Vx值系数1 long double
// ...
// 卫星轨道模型Vy值系数1 long double
// ...
// 卫星轨道模型Vz值系数1 long double
// ...
//
//
class ParameterInFile
{
public:
ParameterInFile(std::string infile_path);
ParameterInFile(const ParameterInFile& paras);
~ParameterInFile();
public:
//参数组
std::string dem_path; //dem 路径
std::string out_sar_sim_path; // 输出模拟sar
std::string out_sar_sim_dem_path; // 输出模拟sar
std::string out_sar_sim_resampling_path; // 输出模拟sar
std::string out_sar_sim_resampling_rc;
int sim_height; // 模拟影像的高
int sim_width;
long double widthspace;// 距离向分辨率
std::string sar_sim_match_point_path; //输出模拟影像的地点x
std::string sar_sim_match_point_xyz_path; //输出模拟影像的地点x
int sample_f; //采样率
long double R0; //近斜距
long double LightSpeed;//光速
long double lamda;//波长
long double refrange;// 参考斜距
long double delta_R; // 斜距间隔
long double imgStartTime; //成像起始时间
long double PRF;// 脉冲重复率
long double delta_t;// 时间间隔
// 多普勒
int doppler_paramenter_number;// 多普勒系数个数
long double* doppler_para;//多普勒系数
//卫星轨道模型
int polySatelliteModel;// 是否为卫星多轨道模型
int polynum;// 多项数
long double SatelliteModelStartTime;
long double* polySatellitePara;
};
// 根据轨道模型计算卫星空间位置
struct SatelliteSpacePoint {
long double x=0;
long double y=0;
long double z=0;
long double vx=0;
long double vy=0;
long double vz=0;
};
/// <summary>
/// 根据卫星轨道模型计算卫星
/// </summary>
/// <param name="satelliteTime">卫星轨道点时间</param>
/// <param name="SatelliteModelStartTime">卫星轨道模型起始时间</param>
/// <param name="polySatellitePara">卫星轨道坐标模型参数</param>
/// <param name="polynum">多项式项数</param>
/// <returns></returns>
inline SatelliteSpacePoint getSatellitePostion(long double satelliteTime,long double SatelliteModelStartTime,long double* polySatellitePara,int polynum);
/// <summary>
/// 数值模拟法计算多普勒频移值
/// </summary>
/// <param name="R">斜距</param>
/// <param name="LightSpeed">光速</param>
/// <param name="T0">多普勒参考时间</param>
/// <param name="doppler_para">多普勒参数</param>
/// <returns>多普勒频移值</returns>
inline long double calNumericalDopplerValue(long double R,long double LightSpeed,long double T0, long double* doppler_para,int doppler_paramenter_number);
/// <summary>
/// 根据理论模型计算多普勒频移值
/// </summary>
/// <param name="R">斜距</param>
/// <param name="lamda">波长</param>
/// <param name="R_sl">地面->卫星的空间向量</param>
/// <param name="V_sl">地面->卫星之间的速度向量</param>
/// <returns>多普勒频移值</returns>
inline long double calTheoryDopplerValue(long double R, long double lamda, VectorPoint R_sl, VectorPoint V_sl);
/// <summary>
/// 根据地面点求解对应的sar影像坐标
/// </summary>
/// <param name="landpoint">地面点的坐标--地固坐标系</param>
/// <param name="Starttime">影片开始成像时间</param>
/// <param name="lamda">波长</param>
/// <param name="T0">多普勒参考时间</param>
/// <param name="LightSpeed">光速</param>
/// <param name="delta_t">时间间隔</param>
/// <param name="R0">近斜距</param>
/// <param name="delta_R">斜距间隔</param>
/// <param name="SatelliteModelStartTime">卫星轨道模型时间</param>
/// <param name="polySatellitePara">卫星轨道坐标模型参数</param>
/// <param name="polynum">卫星轨道模型项数</param>
/// <param name="doppler_paramenter_number">多普勒模型数</param>
/// <returns>影像坐标x:行号y:列号z成像时刻</returns>
inline point PSTN(point& landpoint, long double Starttime, long double lamda, long double T0, long double* doppler_para, long double LightSpeed, long double delta_t, long double R0, long double delta_R, long double SatelliteModelStartTime, long double* polySatellitePara, int polynum = 4, int doppler_paramenter_number = 5);
struct translateArray {
long double a0, a1, a2;
long double b0, b1, b2;
};
/// <summary>
/// 转换影像
/// </summary>
/// <param name="row_ids"></param>
/// <param name="col_ids"></param>
/// <param name="value"></param>
/// <param name="gt"></param>
/// <returns></returns>
inline point Translation(long double row_ids,long double col_ids,long double value,translateArray& gt) {
point result{ 0,0,0 };
result.x = gt.a0 + gt.a1 * col_ids + gt.a2 * row_ids;
result.y = gt.b0 + gt.b1 * col_ids + gt.b2 * row_ids;
result.z = value;
return result;
}
inline int Translation(long double& x, long double& y, long double& r, long double& c, translateArray& gt) {
c = gt.a0 + gt.a1 * x + gt.a2 * y;
r = gt.b0 + gt.b1 * x + gt.b2 * y;
return 0;
}
/// <summary>
/// dem块
/// </summary>
class dem_block {
public:
dem_block(int all_start_row,int all_start_col,int start_row, int end_row, int start_col, int end_col, int height, int width,int sample_f);
dem_block(const dem_block& demblocks);
~dem_block();
dem_block resample_dem();
//dem_block resample_dem_cudic();
int rowcol2blockids(int row_ids, int col_ids);
point getpointblock(int row_ids, int col_ids);
int setpointblock(int row_ids, int col_ids, point& value);
point getpointblock(int ids);
int setpointblock(int ids, point& value);
int UpdatePointCoodinarary();
VectorPoint getslopeVector(int row_ids, int col_ids);
public:
int all_start_row;
int all_start_col;
int start_row; // 目标区域的起始行号
int end_row; //
int start_col; // 目标区域的起始列号
int end_col;
int height;
int width;
int size;
int sample_f;
point* pointblock; // 原始块
};
inline point bilineadInterpolation(point& p,point& p11,point& p12,point& p21,point& p22);
inline point cubicInterpolation(point& p, point& p11, point& p12,point& p13,point& p14, point& p21, point& p22,point& p23,point& p24,point& p31,point& p32,point& p33,point& p34,point& p41,point& p42,point& p43,point& p44);
/// <summary>
/// 双线性插值方法
/// </summary>
/// <param name="p"></param>
/// <param name="p11"></param>
/// <param name="p12"></param>
/// <param name="p21"></param>
/// <param name="p22"></param>
/// <returns></returns>
inline point SARbilineadInterpolation(point& p, point& p11, point& p12, point& p21, point& p22) {
}
/// <summary>
/// 入射角 -- 弧度制
/// </summary>
struct IncidenceAngle
{
long double incidenceAngle; // 雷达入射角
long double localincidenceAngle; // 局地入射角
};
struct matchPoint {
long double r, c, ti;
long double land_x, land_y, land_z;
long double distance;
long double incidenceAngle, localincidenceAngle;
};
/// <summary>
/// 模拟sar 的矩阵块累加模块默认使用short 类型(累加上限:
/// </summary>
class sim_block {
public:
sim_block(int start_row,int end_row,int start_col,int end_col,int height,int width);
sim_block(const sim_block& sim_blocks);
~sim_block();
int rowcol2blockids(int row_ids, int col_ids);
short getsimblock(int row_ids, int col_ids);
int setsimblock(int row_ids,int col_ids, short value);
int addsimblock(int row_ids, int col_ids,short value);
matchPoint getpointblock(int row_ids,int col_ids);
int setpointblock(int row_ids, int col_ids, matchPoint value);
//
long double getdistanceblock(int row_ids, int col_ids);
int setdistanceblock(int row_ids, int col_ids, long double value);
public:
int start_row;
int end_row;
int start_col;
int end_col;
int height;
int width;
int size;
short* block;
long double* distanceblock;
matchPoint* pointblock;
};
/// <summary>
/// 根据卫星坐标,地面坐标,地面法向量,求解对应的雷达入射角和局地入射角
/// </summary>
/// <param name="satellitepoint">卫星空间坐标</param>
/// <param name="landpoint">地面坐标</param>
/// <param name="slopvector">地面坡度</param>
/// <returns>入射角文件</returns>
inline IncidenceAngle calIncidence(point satellitepoint,point landpoint,VectorPoint slopvector) {
IncidenceAngle result;
VectorPoint R_ls = getVector(landpoint, satellitepoint);
result.localincidenceAngle = getVectorAngleValue(R_ls, slopvector);
VectorPoint R_s{ satellitepoint.x,satellitepoint.y,satellitepoint.z };
result.incidenceAngle = getVectorAngleValue(R_s, R_ls);
return result;
}
int SimProcessBlock(dem_block demblock, ParameterInFile paras, matchPoint* result_shared, int* Pcount);
int ResamplingSim(ParameterInFile paras);
int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, float fResX, float fResY, GDALResampleAlg eResample);
/// <summary>
/// 模拟sar的处理算法模块。
/// 为了控制内存的取用
/// 线程数8 --以进程类的方式进行管理--使用队列的方法
/// 线程内存dem_block_size*sample_f*sample_f< 1 G
/// </summary>
/// <param name="paras">参数文件项</param>
/// <param name="thread_num">线程数默认为8</param>
/// <returns>执行情况</returns>
int SimProcess(ParameterInFile paras, int thread_num);
int SimProcess_LVY(ParameterInFile paras, int thread_num);
int WriteMatchPoint(string path, std::vector<matchPoint>* matchps);
// 测试函数接口
int testPTSN(ParameterInFile paras);
///
///
/// 考虑影像的插值方案
///
///
class ConvertResampleParameter {
public:
ConvertResampleParameter(string path);
ConvertResampleParameter(const ConvertResampleParameter& para);
~ConvertResampleParameter();
public:
string in_ori_dem_path;
string ori_sim;
string out_sar_xyz_path;
string out_sar_xyz_incidence_path;
string out_orth_sar_incidence_path;
string out_orth_sar_local_incidence_path;
string outFolder_path;
int file_count;
std::vector<string> inputFile_paths;
std::vector<string> outFile_paths;
std::vector<string> outFile_pow_paths;
int ori2sim_num;
long double* ori2sim_paras;
int sim2ori_num;
long double* sim2ori_paras;
};
inline int ori2sim(long double ori_x,long double ori_y,long double& sim_x,long double& sim_y,long double* conver_paras) {
long double xy = ori_x * ori_y;
long double x2 = ori_x * ori_x;
long double y2 = ori_y * ori_y;
sim_x = conver_paras[0] + ori_x * conver_paras[1] + ori_y * conver_paras[2] + x2 * conver_paras[3] + y2 * conver_paras[4] + xy * conver_paras[5];
sim_y = conver_paras[6] + ori_x * conver_paras[7] + ori_y * conver_paras[8] + x2 * conver_paras[9] + y2 * conver_paras[10] + xy * conver_paras[11];
return 1;
}
/// <summary>
/// 将模拟的行列号转换为目标行列号
/// </summary>
/// <param name="sim_r">模拟的行号</param>
/// <param name="sim_c">模拟的列号</param>
/// <param name="ori_r">待计算的目标行号</param>
/// <param name="ori_c">待计算的目标列号</param>
/// <param name="conver_paras">变换矩阵</param>
/// <returns>默认0 表示计算结束</returns>
inline int sim2ori(long double sim_r,long double sim_c,long double& ori_r,long double& ori_c, long double* conver_paras) {
long double xy = sim_r * sim_c;
long double x2 = sim_r * sim_r;
long double y2 = sim_c * sim_c;
ori_r = conver_paras[0] + sim_r * conver_paras[1] + sim_c * conver_paras[2] + x2 * conver_paras[3] + y2 * conver_paras[4] + xy * conver_paras[5];
ori_c = conver_paras[6] + sim_r * conver_paras[7] + sim_c * conver_paras[8] + x2 * conver_paras[9] + y2 * conver_paras[10] + xy * conver_paras[11];
return 0;
}
// 查询精确坐标
point GetOriRC(point& landp, ParameterInFile& paras, ConvertResampleParameter& convparas);
int SimProcessBlock_CalXYZ(dem_block demblock, ParameterInFile paras, ConvertResampleParameter converParas, matchPoint* result_shared, int* Pcount);
int SimProcess_CalXYZ(ParameterInFile paras, ConvertResampleParameter conveparas, int thread_num);
/*
dem->sim->ori(r,c) <--> ori
step1: dem ori -> ori_sim.tif (r,c,incidence,localincidence)
step2: a,b
*/
int SimProcess_Calsim2ori(ParameterInFile paras, ConvertResampleParameter conveparas, int thread_num); // 正射模块
/*
step1
step2:
*/
int SimProcess_ResamplingOri2Orth(ParameterInFile paras, ConvertResampleParameter conveparas, int thread_num);
/*
*/
int SimProcess_Calspow(ParameterInFile paras, ConvertResampleParameter conveparas, int thread_num); // 正射模块

View File

@ -0,0 +1,30 @@
#include "common.h"
#include <time.h>
#include <chrono>
#include <ctime>
/**
* @brief GetCurrentTime
* @return
*/
std::string getCurrentTimeString() {
std::time_t t = std::time(NULL);
char mbstr[100];
std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d %H:%M:%S",
std::localtime(&t));
std::string strTime = mbstr;
return strTime;
}
std::string getCurrentShortTimeString() {
std::time_t t = std::time(NULL);
char mbstr[100];
std::strftime(mbstr, sizeof(mbstr), "%H:%M:%S",
std::localtime(&t));
std::string strTime = mbstr;
return strTime;
}

View File

@ -0,0 +1,14 @@
#ifndef COMMON_H
#define COMMON_H
#include <iostream>
#include <string>
/**
* @brief GetCurrentTime
* @return
*/
std::string getCurrentTimeString();
std::string getCurrentShortTimeString();
#endif

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<ExecutablePath>C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\bin\intel64;$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
<IncludePath>C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\include;C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\include;$(oneMKLIncludeDir);$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\lib\intel64;C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\lib\release;C:\Program Files (x86)\Intel\oneAPI\compiler\2022.1.0\windows\compiler\lib\intel64_win;$(LibraryPath)</LibraryPath>
<_PropertySheetDisplayName>mkl_debug_x64</_PropertySheetDisplayName>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>mkl_intel_ilp64.lib;mkl_intel_thread.lib;mkl_core.lib;mkl_blacs_intelmpi_ilp64.lib;libiomp5md.lib;impi.lib;mkl_sequential.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<ExecutablePath>C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\bin\intel64;$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
<IncludePath>C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\include;C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\include;$(oneMKLIncludeDir);$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\lib\intel64;C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\lib\release;C:\Program Files (x86)\Intel\oneAPI\compiler\2022.1.0\windows\compiler\lib\intel64_win;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>mkl_intel_ilp64.lib;mkl_intel_thread.lib;mkl_core.lib;mkl_blacs_intelmpi_ilp64.lib;libiomp5md.lib;impi.lib;mkl_sequential.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@ -0,0 +1,11 @@
#include "taskprocess.h"
TaskProcess::TaskProcess()
{
}
TaskProcess::~TaskProcess()
{
}

View File

@ -0,0 +1,15 @@
#ifndef TASKPROCESS_H
#define TASKPROCESS_H
class TaskProcess
{
public:
TaskProcess();
~TaskProcess();
private:
};
#endif

View File

@ -0,0 +1,182 @@
#include "threadpool.hpp"
#include <sstream>
#include <string>
//#include <unistd.h>
#include <windows.h>
static const int MAX_THREADS = 10000; //最大线程数目
/**
* @brief ThreadPool
* @param number[in]线 *线
* @param
* emptyQuit[in]线退falsetruestartwaite
*/
ThreadPool::ThreadPool(int number, bool emptyQuit)
: m_StopFlag(false), m_EmptyQuit(emptyQuit), m_JoinFlag(false), m_QuitNum(0), m_EmptyQuitWaite(false) {
std::cout << "线程池中线程数:" << number << std::endl;
if (number <= 0 || number > MAX_THREADS) throw std::exception();
m_ThreadNum = number;
}
ThreadPool::~ThreadPool() {
// std::cout << "~ThreadPool()" << std::endl;
stop();
}
/**
* @brief stop
*/
void ThreadPool::stop() {
//保证多线程情况下只调用一次stopThreadGroup
std::call_once(m_CallStopSlag, [this] { stopThreadGroup(); });
}
/**
* @brief stopThreadGroup 线
*/
void ThreadPool::stopThreadGroup() {
m_StopFlag = true;
Sleep(500);
m_Condition.notify_all();
waiteFinish(); //等待线程退出
std::thread* thread = NULL;
for (int i = 0; i < m_WorkThreads.size(); i++)
{
thread = m_WorkThreads[i];
if (thread != NULL)
{
thread->join();
delete thread;
thread = NULL;
}
m_WorkThreads[i] = NULL;
}
m_WorkThreads.clear();
}
/**
* @brief startThread 线
*/
void ThreadPool::startThread() {
for (int i = 0; i < m_ThreadNum; i++) {
std::thread* thread = new std::thread(ThreadPool::worker, this);
m_WorkThreads.push_back(thread);
}
}
/**
* @brief waiteThreadFinish 线
*/
void ThreadPool::waiteThreadFinish() {
if (m_JoinFlag) return;
if (m_EmptyQuit)
{
m_EmptyQuitWaite = true;
do
{
if (m_ThreadNum == m_QuitNum)
break;
Sleep(400);
} while (true);
m_StopFlag = true;
m_Condition.notify_all();
}
/* for (int i = 0; i < work_threads.size(); i++) {
if (work_threads[i]) { work_threads[i]->join(); }
}*/
m_JoinFlag = true;
}
/**
* @brief start
*/
void ThreadPool::start() {
std::call_once(m_CallStartSlag, [this] { startThread(); });
}
/**
* @brief waiteFinish ,退
*/
void ThreadPool::waiteFinish() {
std::call_once(m_CallWaiteFinisFlag, [this] { waiteThreadFinish(); });
}
/**
* @brief
*/
int ThreadPool::taskNum()
{
return m_TasksQueue.size();
}
/**
* @brief append task_queue<T *>
* @param task
* @return
*/
bool ThreadPool::append(Task task) {
/*操作工作队列时一定要加锁,因为他被所有线程共享*/
m_DataMutex.lock();
m_TasksQueue.push(task);
m_DataMutex.unlock();
m_Condition.notify_one(); //线程池添加进去了任务,自然要通知等待的线程
return true;
}
/**
* @brief worker 线
* @param arg
* @return
*/
void* ThreadPool::worker(void* arg) {
ThreadPool* pool = (ThreadPool*)arg;
pool->run();
return pool;
}
/**
* @brief notEmpty
* @return
*/
bool ThreadPool::notEmpty() {
bool empty = m_TasksQueue.empty();
if (empty) {
// std::ostringstream oss;
// oss << std::this_thread::get_id();
// printf("queue empty thread id %s waite...!\n", oss.str().c_str());
}
return !empty;
}
/**
* @brief run 线,
*/
void ThreadPool::run() {
bool flag = false;
int remainder = 0;
while (!m_StopFlag) {
flag = false;
{
std::unique_lock<std::mutex> lk(this->m_QueueMutex);
/* unique_lock() 出作用域会自动解锁 */
m_Condition.wait(lk, [this] { return m_StopFlag || notEmpty(); });
}
if (m_StopFlag) break;
Task task;
m_DataMutex.lock();
//如果任务队列不为空,就停下来等待唤醒
if (!this->m_TasksQueue.empty()) {
task = m_TasksQueue.front();
m_TasksQueue.pop();
remainder = m_TasksQueue.size();
flag = true;
}
m_DataMutex.unlock();
if (flag) task();
//如果队列为空并且完成退出,已经开始等待退出就退出
if (m_TasksQueue.empty() && m_EmptyQuit && m_EmptyQuitWaite)
{
break;
}
}
m_QuitNum += 1;
std::ostringstream oss;
oss << std::this_thread::get_id();
printf("thread %s end\n", oss.str().c_str());
}

View File

@ -0,0 +1,102 @@
#ifndef THREADPOOL_HPP
#define THREADPOOL_HPP
#include <atomic>
#include <condition_variable>
#include <functional>
#include <iostream>
#include <memory> //unique_ptr
#include <queue>
#include <stdexcept>
#include <thread>
#include <vector>
typedef std::function<void(void)> Task;
class ThreadPool {
public:
/**
* @brief ThreadPool
* @param number[in]线 *线
* @param
* emptyQuit[in]线退falsetruestartwaite
*/
ThreadPool(int number = 1, bool emptyQuit = false);
~ThreadPool();
/**
* @brief append task_queue<T *>
* @param task
* @return
*/
bool append(Task task);
/**
* @brief start
*/
void start();
/**
* @brief stop
*/
void stop();
/**
* @brief waiteFinish ,退
*/
void waiteFinish();
/**
* @brief
*/
int taskNum();
private:
/**
* @brief worker 线
* @param arg
* @return
*/
static void *worker(void *arg);
/**
* @brief run 线,
*/
void run();
/**
* @brief stopThreadGroup 线
*/
void stopThreadGroup();
/**
* @brief startThread 线
*/
void startThread();
/**
* @brief waiteThreadFinish 线
*/
void waiteThreadFinish();
/**
* @brief notEmpty
* @return
*/
bool notEmpty();
private:
std::vector<std::thread *> m_WorkThreads; /*工作线程*/
std::queue<Task> m_TasksQueue; /*任务队列*/
std::mutex m_QueueMutex;
std::condition_variable m_Condition; /*必须与unique_lock配合使用*/
std::recursive_mutex m_DataMutex; //数据锁
std::atomic_bool m_StopFlag; //是否停止标志
std::once_flag m_CallStopSlag;
std::once_flag m_CallStartSlag;
std::once_flag m_CallWaiteFinisFlag;
int m_ThreadNum; //线程数
std::atomic_bool m_EmptyQuit; //无任务退出模式,改模式先添加任务,再启动
std::atomic_bool m_JoinFlag; //线程是否Join
std::atomic_bool m_EmptyQuitWaite;//开始退出等待
std::atomic_int m_QuitNum;//退出的线程计数
};
typedef std::shared_ptr<ThreadPool> ThreadPoolPtr;
#endif // THREADPOOL_HPP

View File

@ -0,0 +1,20 @@
// testengiewithmkl.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{c26dab80-43be-4542-a2a3-7b5acb6e35e6}</ProjectGuid>
<RootNamespace>testengiewithmkl</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="testengiewithmkl.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="testengiewithmkl.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@ -0,0 +1 @@
# SIMOrthoProgram

View File

@ -0,0 +1,23 @@
#pragma once
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <boost/filesystem.hpp>
#include <omp.h>
#include "baseTool.h"
#include "simptsn.h"
#include "SateOrbit.h"
#include "ImageMatch.h"
#include <gdal_utils.h>
#include <proj.h>
#include "gdal_priv.h"
#include "gdal_alg.h"
#include "RPC_Correct.h"
using namespace std;
using namespace Eigen;

View File

@ -0,0 +1,29 @@
#pragma once
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <boost/filesystem.hpp>
#include <omp.h>
#include <gdal_utils.h>
#include <proj.h>
#include "gdal_priv.h"
#include "gdal_alg.h"
//#include <mkl.h>
#include "baseTool.h"
#include "simptsn.h"
#include "SateOrbit.h"
#include "ImageMatch.h"
using namespace std;
using namespace Eigen;
// 专门用于解析RPC
class RPC_Correct
{
};

Binary file not shown.

View File

@ -0,0 +1,434 @@
// SIMOrthoProgram.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
#include <stdlib.h>
#include <direct.h>
// gdal
#include <proj.h>
#include <string>
#include "gdal_priv.h"
#include "ogr_geometry.h"
#include "gdalwarper.h"
#include "baseTool.h"
#include "simptsn.h"
#include "test_moudel.h"
#include <Windows.h>
using namespace std;
using namespace Eigen;
//mode 1
void PreProcess(int argc, char* argv[])
{
// .\baseTool\x64\Release\SIMOrthoProgram.exe 1 D:\MicroWorkspace\C-SAR\Ortho\Temporary\unpack\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_HH_L10003923848.tiff
//输入参数
std::cout << "==========================================================================" << endl;
std::cout << "预处理计算结果可以计算出DEM 范围 " << endl;
std::cout << "SIMOrthoProgram.exe 1 in_parameter_path in_dem_path in_ori_sar_path in_work_path in_taget_path ";
std::string parameter_path = argv[2]; // 参数文件
std::string dem_path = argv[3]; // dem 文件
std::string in_sar_path = argv[4]; // 输入SAR文件
std::string work_path = argv[5]; // 目标空间文件
std::string taget_path = argv[6]; // 输出坐标映射文件
//std::string parameter_path = "D:\\micro\\LWork\\Ortho\\Temporary\\package\\orth_para.txt"; // 参数文件
//std::string dem_path = "D:\\micro\\LWork\\Ortho\\Temporary\\TestDEM\\mergedDEM.tif"; // dem 文件
//std::string in_sar_path = "D:\\micro\\LWork\\Ortho\\Temporary\\unpack\\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966\\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_HH_L1A_0000086966.tiff"; // 输入SAR文件
//std::string work_path = "D:\\micro\\LWork\\Ortho\\Temporary"; // 目标空间文件
//std::string taget_path = "D:\\micro\\LWork\\Ortho\\Temporary\\package"; // 输出坐标映射文件
//std::string Incident_path = argv[7];// 输出入射角文件
std::cout << "==========================================================================" << endl;
std::cout << "in parameters:========================================================" << endl;
std::cout << "parameters file path:\t" << parameter_path << endl;
std::cout << "input dem image(WGS84)" << dem_path << endl;
std::cout << "the sar image:\n" << in_sar_path << endl;
std::cout << "the work path for outputing temp file :\t" << work_path << endl;
std::cout << "the out file for finnal file:\t" << taget_path << endl;
simProcess process;
std::cout << "==========================================================================" << endl;
process.InitSimulationSAR(parameter_path, work_path, taget_path, dem_path, in_sar_path);
std::cout << "==========================================================================" << endl;
}
//mode 2
void calIncident_localIncident_angle(int argc, char* argv[]) {
std::cout << "mode 2: get incident angle and local incident angle by rc_wgs84 and dem and statellite model:\n";
std::cout << "SIMOrthoProgram.exe 2 in_parameter_path in_dem_path in_rc_wgs84_path out_incident_angle_path out_local_incident_angle_path";
std::string parameter_path = argv[2];
std::string dem_path = argv[3];
std::string in_rc_wgs84_path = argv[4];
std::string out_incident_angle_path = argv[5];
std::string out_local_incident_angle_path = argv[6];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
process.pstn = pstn;
process.calcalIncident_localIncident_angle(dem_path, in_rc_wgs84_path, out_incident_angle_path, out_local_incident_angle_path, pstn);
}
// mode 3
void calInterpolation_cubic_Wgs84_rc_sar(int argc, char* argv[]) {
std::cout << "mode 3: interpolation(cubic convolution) orth sar value by rc_wgs84 and ori_sar image and model:\n ";
std::cout << "SIMOrthoProgram.exe 3 in_parameter_path in_rc_wgs84_path in_ori_sar_path out_orth_sar_path";
std::string parameter_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary\\package\\orth_para.txt"; argv[2];
std::string in_rc_wgs84_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary\\dem_rc.tiff"; argv[3];
std::string in_ori_sar_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary\\unpack\\GF3_MYN_QPSI_011437_E99.2_N28.6_20181012_L1A_AHV_L10003514912\\GF3_MYN_QPSI_011437_E99.2_N28.6_20181012_L1A_VV_L10003514912.tiff"; argv[4];
std::string out_orth_sar_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary\\package\\GF3_MYN_QPSI_011437_E99.2_N28.6_20181012_L1A_VV_L10003514912_GTC_rpc_geo.tif"; argv[5];
parameter_path = argv[2];
in_rc_wgs84_path = argv[3];
in_ori_sar_path = argv[4];
out_orth_sar_path = argv[5];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
process.pstn = pstn;
std::cout << "==========================================================================" << endl;
process.interpolation_GTC_sar(in_rc_wgs84_path, in_ori_sar_path, out_orth_sar_path, pstn);
}
// mode 4 处理 RPC的入射角
void getRPC_Incident_localIncident_angle(int argc, char* argv[]) {
std::cout << "mode 4: get RPC incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 4 in_parameter_path in_dem_path in_rpc_rc_path out_rpc_dem_path out_incident_angle_path out_local_incident_angle_path";
std::string parameter_path = argv[2];
std::string in_dem_path = argv[3];
std::string in_rpc_rc_path = argv[4];
std::string out_rpc_dem_path = argv[5];
std::string out_incident_angle_path = argv[6];
std::string out_local_incident_angle_path = argv[7];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
process.CreateRPC_DEM(in_rpc_rc_path, in_dem_path, out_rpc_dem_path);
process.calcalIncident_localIncident_angle(out_rpc_dem_path, in_rpc_rc_path, out_incident_angle_path, out_local_incident_angle_path, pstn);
}
//mode 5
void cal_ori_2_power_tiff(int argc, char* argv[]) {
std::cout << "mode 5: convert ori tiff to power tiff:";
std::cout << "SIMOrthoProgram.exe 5 in_ori_path out_power_path";
std::string in_ori_path = argv[2];
std::string out_power_path = argv[3];
simProcess process;
process.ori_sar_power(in_ori_path, out_power_path);
}
// mode 6
void cal_GEC_Incident_localIncident_angle(int argc, char* argv[]) {
std::cout << "mode 6: get gec incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 6 in_parameter_path in_dem_path in_gec_lon_lat_path out_incident_angle_path out_local_incident_angle_path";
std::string parameter_path = argv[2];
std::string dem_path = argv[3];
std::string in_gec_lon_lat_path = argv[4];
std::string out_incident_angle_path = argv[5];
std::string out_local_incident_angle_path = argv[6];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
process.calGEC_Incident_localIncident_angle(dem_path, in_gec_lon_lat_path, out_incident_angle_path, out_local_incident_angle_path, pstn);
}
// mode 7
void RPC_inangle(int argc, char* argv[]) {
std::cout << "mode 7: get rpc incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 7 in_parameter_path in_dem_path in_gec_lon_lat_path work_path taget_path out_incident_angle_path out_local_incident_angle_path";
std::string parameter_path = argv[2];
std::string dem_path = argv[3];
std::string in_gec_lon_lat_path = argv[4];
std::string work_path = argv[5];
std::string taget_path = argv[6];
std::string out_incident_angle_path = argv[7];
std::string out_local_incident_angle_path = argv[8];
std::string out_incident_angle_geo_path = argv[9];
std::string out_local_incident_angle_geo_path = argv[10];
simProcess process;
//InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path, std::string in_rpc_lon_lat_path)
std::cout << "==========================================================================" << endl;
process.InitRPCIncAngle(parameter_path, work_path, taget_path, dem_path, in_gec_lon_lat_path, out_incident_angle_path, out_local_incident_angle_path, out_incident_angle_geo_path, out_local_incident_angle_geo_path);
std::cout << "==========================================================================" << endl;
}
// mode 9
void calInterpolation_cubic_Wgs84_rc_sar_sigma(int argc, char* argv[]) {
std::cout << "mode 9: interpolation(cubic convolution) orth sar value by rc_wgs84 and ori_sar image and model:\n ";
std::cout << "SIMOrthoProgram.exe 9 in_parameter_path in_rc_wgs84_path in_ori_sar_path out_orth_sar_path";
std::string parameter_path = "D:\\micro\\LWork\\Ortho\\Temporary\\package\\orth_para.txt";
std::string in_rc_wgs84_path = "D:\\micro\\LWork\\Ortho\\Temporary\\package\\RD_sim_ori.tif";
std::string in_ori_sar_path = "D:\\micro\\LWork\\Ortho\\Temporary\\in_sar_power.tiff";
std::string out_orth_sar_path = "D:\\micro\\LWork\\Ortho\\Temporary\\in_sar_power_GTC.tiff";
parameter_path = argv[2];
in_rc_wgs84_path = argv[3];
in_ori_sar_path = argv[4];
out_orth_sar_path = argv[5];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
process.pstn = pstn;
std::cout << "==========================================================================" << endl;
process.interpolation_GTC_sar_sigma(in_rc_wgs84_path, in_ori_sar_path, out_orth_sar_path, pstn);
}
// mode 11
void interpolation_bil_GTC_sar_sigma(int argc, char* argv[]) {
std::cout << "mode 11: interpolation(cubic convolution) orth sar value by rc_wgs84 and ori_sar image and model:\n ";
std::cout << "SIMOrthoProgram.exe 11 in_parameter_path in_rc_wgs84_path in_ori_sar_path out_orth_sar_path";
std::string parameter_path = "D:\\micro\\WorkSpace\\SurfaceRoughness\\Temporary\\preprocessing\\GF3B_MYC_QPSI_008114_E121.6_N40.9_20230608_L1A_AHV_L10000196489-ortho\\orth_para.txt";
std::string in_rc_wgs84_path = "D:\\micro\\WorkSpace\\SurfaceRoughness\\Temporary\\preprocessing\\GF3B_MYC_QPSI_008114_E121.6_N40.9_20230608_L1A_AHV_L10000196489-ortho\\sim_ori-ortho.tif";
std::string in_ori_sar_path = "D:\\micro\\WorkSpace\\SurfaceRoughness\\Temporary\\SurfaceRoughnessProduct_temp.tif";
std::string out_orth_sar_path = "D:\\micro\\WorkSpace\\SurfaceRoughness\\Temporary\\SurfaceRoughnessProduct_geo1.tif";
parameter_path = argv[2];
in_rc_wgs84_path = argv[3];
in_ori_sar_path = argv[4];
out_orth_sar_path = argv[5];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
process.pstn = pstn;
std::cout << "==========================================================================" << endl;
process.interpolation_bil(in_rc_wgs84_path, in_ori_sar_path, out_orth_sar_path, pstn);
}
// mode 12
void lee_process_sar(int argc, char* argv[]) {
std::cout << "mode 12: lee process:\n ";
std::cout << "SIMOrthoProgram.exe 12 in_sar_path out_sar_path win_size noise_var\n";
std::string in_sar_path = "D:\\micro\\WorkSpace\\BackScattering\\Temporary\\preprocessing\\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_HH_L10003515422_DB.tif";
std::string out_sar_path = "D:\\micro\\WorkSpace\\BackScattering\\Temporary\\preprocessed_lee.tif";
int win_size = 5;
double noise_var = 0.25;
in_sar_path = argv[2];
out_sar_path = argv[3];
win_size = stoi(argv[4]);
noise_var = stod(argv[5]);
simProcess process;
std::cout << "==========================================================================\n" << endl;
//std::cout << in_sar_path << endl;
//std::cout << out_sar_path << endl;
//std::cout << win_size << endl;
//std::cout << noise_var << endl;
process.lee_process(in_sar_path, out_sar_path, win_size, noise_var);
}
void createRPC_lon_lat(int argc, char* argv[]) {
std::cout << "mode 8";
std::cout << "SIMOrthoProgram.exe 8 in_rpc_tiff out_lon_lat_path";
std::string in_rpc_tiff = argv[2];
std::string in_dem_tiff = argv[3];
std::string out_lon_lat_path = argv[4];
simProcess process;
//InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path, std::string in_rpc_lon_lat_path)
std::cout << "==========================================================================" << endl;
process.CreateRPC_refrenceTable(in_rpc_tiff, in_dem_tiff,out_lon_lat_path);
std::cout << "==========================================================================" << endl;
}
void Scatter2Grid_lon_lat(int argc, char* argv[]) {
std::cout << "mode 10";
std::cout << "SIMOrthoProgram.exe 10 lon_lat_path data_tiff grid_path space";
std::string lon_lat_path = "F:\\orthtest\\ori_sim_preprocessed.tif";
std::string data_tiff = "F:\\orthtest\\SoilMoistureProduct_geo.tif";
std::string grid_path = "F:\\orthtest\\SoilMoistureProduct_geo_test.tif";
double space = 5;
lon_lat_path = argv[2];
data_tiff = argv[3];
grid_path = argv[4];
space = stod(argv[5]);
simProcess process;
//InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path, std::string in_rpc_lon_lat_path)
std::cout << "==========================================================================" << endl;
process.Scatter2Grid(lon_lat_path, data_tiff, grid_path, space);
std::cout << "==========================================================================" << endl;
}
string GetExePath()
{
char szFilePath[MAX_PATH + 1] = { 0 };
GetModuleFileNameA(NULL, szFilePath, MAX_PATH);
/*
strrchr:cstrstrc
NULL
使cstr
*/
(strrchr(szFilePath, '\\'))[0] = 0; // 删除文件名,只获得路径字串//
string path = szFilePath;
return path;
}
/// <summary>
/// 初始化
/// </summary>
void initProjEnv() {
PJ_CONTEXT* C;
C = proj_context_create();
std::cout << "========================== init PROJ ================================================" << endl;
string exepath = GetExePath();
char buffer[10240];
int i;
for (i = 0; i < exepath.length(); i++) {
buffer[i] = exepath[i];
}
buffer[i] = '\0';
const char* proj_share_path = buffer;
proj_context_set_search_paths(C, 1, &proj_share_path);
char* buf = nullptr;
size_t sz = 0;
if (_dupenv_s(&buf, &sz, "PROJ_LIB") == 0 && buf != nullptr)
{
printf("PROJ_LIB = %s\n", buf);
std::string newEnv = "PROJ_LIB=" + std::string(buffer);
_putenv(newEnv.c_str());
}
else {
std::string newEnv = "PROJ_LIB=" + std::string(buffer);
_putenv(newEnv.c_str());
}
if (_dupenv_s(&buf, &sz, "PROJ_LIB") == 0 && buf != nullptr)
{
std::cout << "after PROJ_LIB = " << buf << endl;
}
free(buf);
std::cout << "========================================================================================" << endl;
}
int main(int argc, char* argv[])
{
initProjEnv();
//WGS84_J2000();
cout << "test\t" << acos(-1) << endl;
cout << getAngle(Landpoint{ -3421843,5089485,3630606 }, Landpoint{ -2609414,4763328,3332879 }) << endl;;
Landpoint p2 = { -3421843,5089485,3630606 }; Landpoint p1 = { -2609414,4763328,3332879 };
cout << getIncAngle(p2, p1) << endl;;
std::cout << "program start:\t" << getCurrentTimeString() << endl;;
int mode = 9;
GDALAllRegister();
if (argc == 0) { // 测试参数
// 算法说明
std::cout << "========================== description ================================================" << endl;
std::cout << "algorithm moudel:.exe [modeparamert] {otherParaments}" << endl;
std::cout << "mode 1: Preprocess\n ";
std::cout << "SIMOrthoProgram.exe 1 in_parameter_path in_dem_path in_ori_sar_path in_work_path in_taget_path out_GEC_dem_path out_GTC_rc_path out_GEC_lon_lat_path out_clip_dem_path" << endl;
std::cout << "mode 2: get incident angle and local incident angle by rc_wgs84 and dem and statellite model:\n";
std::cout << "SIMOrthoProgram.exe 2 in_parameter_path in_dem_path in_rc_wgs84_path out_incident_angle_path out_local_incident_angle_path";
std::cout << "mode 3: interpolation(cubic convolution) orth sar value by rc_wgs84 and ori_sar image and model:\n ";
std::cout << "SIMOrthoProgram.exe 3 in_parameter_path in_rc_wgs84_path in_ori_sar_path out_orth_sar_path";
std::cout << "mode 4: get RPC incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 4 in_parameter_path in_dem_path in_rpc_rc_path out_rpc_dem_path out_incident_angle_path out_local_incident_angle_path";
std::cout << "mode 5: interpolation(cubic convolution) orth sar value by gec_lon_lat and dem and ori_sar image and sar model:";
std::cout << "SIMOrthoProgram.exe 5 in_parameter_path in_gec_lon_lat_path in_dem_path in_sar_path out_orth_sar_path";
std::cout << "mode 6: get gec incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 6 in_parameter_path in_dem_path in_gec_lon_lat_path out_incident_angle_path out_local_incident_angle_path";
if (mode == 10) {
Scatter2Grid_lon_lat(argc, argv);
}
else {
test_main(mode, "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary");
}
//calInterpolation_cubic_Wgs84_rc_sar(argc, argv);
}
else if (argc > 1) { // 预处理模块
std::cout << "=============================description V2.0 =============================================" << endl;
std::cout << "algorithm moudel:.exe [modeparamert] {otherParaments}" << endl;
std::cout << "algorithm moudel:.exe [modeparamert] {otherParaments}" << endl;
mode = stoi(argv[1]);
if (mode == 0) {
test_main(mode, argv[2]);
}
else if (mode == 1) {
PreProcess(argc, argv); //
}
else if (mode == 2) { // RPC 计算模块
calIncident_localIncident_angle(argc, argv);
}
else if (mode == 3) {
calInterpolation_cubic_Wgs84_rc_sar(argc, argv);
}
else if (mode == 4) {
getRPC_Incident_localIncident_angle(argc, argv);
}
else if (mode == 5) {
cal_ori_2_power_tiff(argc, argv);
}
else if (mode == 6) {
cal_GEC_Incident_localIncident_angle(argc, argv);
}
else if (mode == 7) {
RPC_inangle(argc, argv);
}
else if (mode == 8) {
createRPC_lon_lat(argc, argv);
}
else if (mode == 9) {
calInterpolation_cubic_Wgs84_rc_sar_sigma(argc, argv);
}
else if (mode == 10) {
Scatter2Grid_lon_lat(argc, argv);
}
else if (mode == 11) {
interpolation_bil_GTC_sar_sigma(argc, argv);
}
else if (mode == 12){
lee_process_sar(argc, argv);
}
}
GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
std::cout << "program over\t" << getCurrentTimeString() << endl;
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

View File

@ -0,0 +1,64 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// 中文(简体,中国) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#endif // 中文(简体,中国) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32602.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SIMOrthoProgram", "SIMOrthoProgram.vcxproj", "{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Debug|x64.ActiveCfg = Debug|x64
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Debug|x64.Build.0 = Debug|x64
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Debug|x86.ActiveCfg = Debug|Win32
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Debug|x86.Build.0 = Debug|Win32
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Release|x64.ActiveCfg = Release|x64
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Release|x64.Build.0 = Release|x64
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Release|x86.ActiveCfg = Release|Win32
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CE6D0980-E92A-4188-91CE-EEE5749F908C}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,201 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{7722b0a9-572b-4e32-afbe-4dc88898f8ee}</ProjectGuid>
<RootNamespace>SIMOrthoProgram</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>SIMOrthoProgram-L-SAR</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>Sequential</UseInteloneMKL>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>Parallel</UseInteloneMKL>
<UseIntelMPI>false</UseIntelMPI>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>C:\ProgramData\Miniconda3\envs\orth\Library\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64;$(oneMKLOmpLibDir);$(LibraryPath)</LibraryPath>
<CopyLocalProjectReference>true</CopyLocalProjectReference>
<CopyCppRuntimeToOutputDir>false</CopyCppRuntimeToOutputDir>
<ExternalIncludePath>C:\ProgramData\Miniconda3\envs\orth\Library\include;$(ExternalIncludePath)</ExternalIncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<CopyLocalProjectReference>true</CopyLocalProjectReference>
<CopyLocalDebugSymbols>true</CopyLocalDebugSymbols>
<CopyCppRuntimeToOutputDir>true</CopyCppRuntimeToOutputDir>
<IncludePath>$(IncludePath)</IncludePath>
<ExecutablePath>$(ExecutablePath)</ExecutablePath>
<ExternalIncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);</ExternalIncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<ReferencePath>$(VC_ReferencesPath_x64);</ReferencePath>
<LibraryWPath>$(WindowsSDK_MetadataPath);</LibraryWPath>
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<OpenMPSupport>true</OpenMPSupport>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>
</FunctionLevelLinking>
<IntrinsicFunctions>false</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<OpenMPSupport>true</OpenMPSupport>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard_C>Default</LanguageStandard_C>
<Optimization>MaxSpeed</Optimization>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
<WholeProgramOptimization>false</WholeProgramOptimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<StackCommitSize>
</StackCommitSize>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="baseTool.cpp" />
<ClCompile Include="ImageMatch.cpp" />
<ClCompile Include="interpolation.cpp" />
<ClCompile Include="OctreeNode.cpp" />
<ClCompile Include="RPC_Correct.cpp" />
<ClCompile Include="simptsn.cpp" />
<ClCompile Include="SateOrbit.cpp" />
<ClCompile Include="SIMOrthoProgram.cpp" />
<ClCompile Include="test_moudel.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="baseTool.h" />
<ClInclude Include="ImageMatch.h" />
<ClInclude Include="interpolation.h" />
<ClInclude Include="linterp.h" />
<ClInclude Include="OctreeNode.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="RPC_Correct.h" />
<ClInclude Include="simptsn.h" />
<ClInclude Include="SateOrbit.h" />
<ClInclude Include="test_moudel.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SIMOrthoProgram.rc" />
</ItemGroup>
<ItemGroup>
<None Include="proj.db" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SIMOrthoProgram.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="baseTool.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="simptsn.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="SateOrbit.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ImageMatch.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="test_moudel.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="RPC_Correct.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="OctreeNode.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="interpolation.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="baseTool.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="simptsn.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="SateOrbit.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ImageMatch.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="test_moudel.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="RPC_Correct.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="OctreeNode.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="interpolation.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="linterp.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SIMOrthoProgram.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="proj.db">
<Filter>资源文件</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@ -0,0 +1,86 @@
#include "SateOrbit.h"
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
using namespace std;
using namespace Eigen;
OrbitPoly::OrbitPoly()
{
}
OrbitPoly::OrbitPoly(int polynum, Eigen::MatrixX<double> polySatellitePara, double SatelliteModelStartTime)
{
if (polySatellitePara.rows() != polynum||polySatellitePara.cols()!=6) {
throw exception("?????????????????");
}
this->polySatellitePara = polySatellitePara;
this->SatelliteModelStartTime = SatelliteModelStartTime;
this->polynum = polynum;
}
OrbitPoly::~OrbitPoly()
{
}
Eigen::MatrixX<double> OrbitPoly::SatelliteSpacePoint(Eigen::MatrixX<double> satellitetime)
{
Eigen::MatrixX<double> result= SatelliteSpacePoints(satellitetime, this->SatelliteModelStartTime, this->polySatellitePara, this->polynum);
return result;
}
Eigen::MatrixX<double> OrbitPoly::SatelliteSpacePoint(long double satellitetime) {
if (this->polySatellitePara.rows() != polynum || this->polySatellitePara.cols() != 6) {
throw exception("the size of satellitetime has error!! row: p1,p2,p3,p4 col: x,y,z,vx,vy,vz ");
}
// ?????????
double satellitetime2 =double( satellitetime - this->SatelliteModelStartTime);
Eigen::MatrixX<double> satetime(1, polynum);
for (int i = 0; i < polynum; i++) {
satetime(0, i) = pow(satellitetime2, i);
}
// ????
Eigen::MatrixX<double> satellitePoints(1, 6);
satellitePoints = satetime * polySatellitePara;
return satellitePoints;
}
/// <summary>
/// ????????????????????
/// </summary>
/// <param name="satellitetime">???????</param>
/// <param name="SatelliteModelStartTime">??????????</param>
/// <param name="polySatellitePara">??????[x1,y1,z1,vx1,vy1,vz1; x2,y2,z2,vx2,vy2,vz2; ..... ]</param>
/// <param name="polynum">??????????</param>
/// <returns>????????</returns>
Eigen::MatrixX<double> SatelliteSpacePoints(Eigen::MatrixX<double>& satellitetime, double SatelliteModelStartTime, Eigen::MatrixX<double>& polySatellitePara, int polynum)
{
if (satellitetime.cols() != 1) {
throw exception("the size of satellitetime has error!!");
}
if (polySatellitePara.rows() != polynum || polySatellitePara.cols() != 6) {
throw exception("the size of satellitetime has error!! row: p1,p2,p3,p4 col: x,y,z,vx,vy,vz ");
}
// ?????????
int satellitetime_num = satellitetime.rows();
satellitetime = satellitetime.array() - SatelliteModelStartTime;
Eigen::MatrixX<double> satelliteTime(satellitetime_num, polynum);
for (int i = 0; i < polynum; i++) {
satelliteTime.col(i) = satellitetime.array().pow(i);
}
// ????
Eigen::MatrixX<double> satellitePoints(satellitetime_num, 6);
satellitePoints = satelliteTime * polySatellitePara;
return satellitePoints;
}

View File

@ -0,0 +1,53 @@
#pragma once
///
/// 计算卫星轨道
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// 本地方法
#include "baseTool.h"
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
//#include <armadillo>
using namespace std;
using namespace Eigen;
//using namespace arma;
/// <summary>
/// 多项式轨道模型
/// </summary>
class OrbitPoly {
public:
//OrbitPoly(std::string orbitModelPath);
OrbitPoly();
OrbitPoly(int polynum, Eigen::MatrixX<double> polySatellitePara, double SatelliteModelStartTime);
~OrbitPoly();
Eigen::MatrixX<double> SatelliteSpacePoint(Eigen::MatrixX<double> satellitetime);
Eigen::MatrixX<double> SatelliteSpacePoint(long double satellitetime);
public:
int polynum;
Eigen::MatrixX<double> polySatellitePara;
double SatelliteModelStartTime;
};
/// <summary>
/// 获取指定时刻的卫星轨道坐标
/// </summary>
/// <param name="satellitetime">卫星时刻</param>
/// <param name="SatelliteModelStartTime">模型起算时间</param>
/// <param name="polySatellitePara">模型参数[x1,y1,z1,vx1,vy1,vz1; x2,y2,z2,vx2,vy2,vz2; ..... ]</param>
/// <param name="polynum">模型参数数量</param>
/// <returns>卫星坐标</returns>
Eigen::MatrixX<double> SatelliteSpacePoints(Eigen::MatrixX<double> &satellitetime, double SatelliteModelStartTime, Eigen::MatrixX<double>& polySatellitePara, int polynum = 4);

View File

@ -0,0 +1,19 @@
#pragma once
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <math.h>
#include <string>
#include <omp.h>
#include <complex>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <ogrsf_frmts.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
#include <opencv2/features2d.hpp>
#include <fstream>
#include "baseTool.h"
#include"WGS84_J2000.h"

View File

@ -0,0 +1,10 @@
#pragma once
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <omp.h>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include "baseTool.h"
#include <string>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,397 @@
#pragma once
///
/// 基本类、基本函数
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
//#include <mkl.h>
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <string>
#include <omp.h>
#include <complex>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <ogrsf_frmts.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
#include <opencv2/features2d.hpp>
#include <fstream>
using namespace std;
using namespace Eigen;
#define PI_180 180/3.141592653589793238462643383279
#define T180_PI 3.141592653589793238462643383279/180
#define LIGHTSPEED 299792458
#define Radians2Degrees(Radians) Radians*PI_180
#define Degrees2Radians(Degrees) Degrees*T180_PI
const double PI = 3.141592653589793238462643383279;
const double epsilon = 0.000000000000001;
const double pi = 3.14159265358979323846;
const double d2r = pi / 180;
const double r2d = 180 / pi;
const double a = 6378137.0; //椭球长半轴
const double ae = 6378137.0; //椭球长半轴
const double ee= 0.0818191910428;// 第一偏心率
const double f_inverse = 298.257223563; //扁率倒数
const double b = a - a / f_inverse;
const double eSquare = (a * a - b * b) / (a * a);
const double e = sqrt(eSquare);
const double earth_Re = 6378136.49;
const double earth_Rp = (1 - 1 / f_inverse) * earth_Re;
const double earth_We = 0.000072292115;
///////////////////////////////////// 运行时间打印 //////////////////////////////////////////////////////////
std::string getCurrentTimeString();
std::string getCurrentShortTimeString();
/////////////////////////////// 基本图像类 //////////////////////////////////////////////////////////
/// <summary>
/// 三维向量,坐标表达
/// </summary>
struct Landpoint // 点 SAR影像的像素坐标
{
/// <summary>
/// 经度x
/// </summary>
double lon; // 经度x lon pixel_col
/// <summary>
/// 纬度y
/// </summary>
double lat; // 纬度y lat pixel_row
/// <summary>
/// 高度z
/// </summary>
double ati; // 高程z ati pixel_time
};
struct Point_3d {
double x;
double y;
double z;
};
Landpoint operator +(const Landpoint& p1, const Landpoint& p2);
Landpoint operator -(const Landpoint& p1, const Landpoint& p2);
bool operator ==(const Landpoint& p1, const Landpoint& p2);
Landpoint operator *(const Landpoint& p, double scale);
/// <summary>
/// 向量A,B的夹角,角度
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns>角度制 0-360度逆时针</returns>
double getAngle(const Landpoint& a, const Landpoint& b);
/// <summary>
/// 点乘
/// </summary>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <returns></returns>
double dot(const Landpoint& p1, const Landpoint& p2);
double getlength(const Landpoint& p1);
Landpoint crossProduct(const Landpoint& a, const Landpoint& b);
struct DemBox {
double min_lat; //纬度
double min_lon;//经度
double max_lat;//纬度
double max_lon;//经度
};
/// <summary>
/// gdalImage图像操作类
/// </summary>
class gdalImage
{
public: // 方法
gdalImage(string raster_path);
~gdalImage();
void setHeight(int);
void setWidth(int);
void setTranslationMatrix(Eigen::MatrixXd gt);
void setData(Eigen::MatrixXd);
Eigen::MatrixXd getData(int start_row, int start_col, int rows_count, int cols_count, int band_ids);
void saveImage(Eigen::MatrixXd,int start_row,int start_col, int band_ids);
void saveImage();
void setNoDataValue(double nodatavalue,int band_ids);
int InitInv_gt();
Landpoint getRow_Col(double lon, double lat);
Landpoint getLandPoint(double i, double j, double ati);
double mean(int bandids=1);
double max(int bandids=1);
double min(int bandids=1);
GDALRPCInfo getRPC();
Eigen::MatrixXd getLandPoint(Eigen::MatrixXd points);
Eigen::MatrixXd getHist(int bandids);
public:
string img_path; // 图像文件
int height; // 高
int width; // 宽
int band_num;// 波段数
int start_row;//
int start_col;//
int data_band_ids;
Eigen::MatrixXd gt; // 变换矩阵
Eigen::MatrixXd inv_gt; // 逆变换矩阵
Eigen::MatrixXd data;
string projection;
};
gdalImage CreategdalImage(string img_path, int height, int width, int band_num, Eigen::MatrixXd gt, std::string projection, bool need_gt=true);
void clipGdalImage(string in_path, string out_path, DemBox box, double pixelinterval);
int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int new_width, int new_height, GDALResampleAlg eResample);
int ResampleGDALs(const char* pszSrcFile, int band_ids, GDALRIOResampleAlg eResample=GRIORA_Bilinear);
/////////////////////////////// 基本图像类 结束 //////////////////////////////////////////////////////////
string Convert(float Num);
std::string JoinPath(const std::string& path, const std::string& filename);
////////////////////////////// 坐标部分基本方法 //////////////////////////////////////////
/// <summary>
/// 将经纬度转换为地固参心坐标系
/// </summary>
/// <param name="XYZP">经纬度点--degree</param>
/// <returns>投影坐标系点</returns>
Landpoint LLA2XYZ(const Landpoint& LLA);
Eigen::MatrixXd LLA2XYZ(Eigen::MatrixXd landpoint);
/// <summary>
/// 将地固参心坐标系转换为经纬度
/// </summary>
/// <param name="XYZ">固参心坐标系</param>
/// <returns>经纬度--degree</returns>
Landpoint XYZ2LLA(const Landpoint& XYZ);
////////////////////////////// 坐标部分基本方法 //////////////////////////////////////////
/// <summary>
/// 计算地表坡度向量
/// </summary>
/// <param name="p0">固参心坐标系</param>
/// <param name="p1">固参心坐标系</param>
/// <param name="p2">固参心坐标系</param>
/// <param name="p3">固参心坐标系</param>
/// <param name="p4">固参心坐标系</param>
/// <returns>向量角度</returns>
//Landpoint getSlopeVector(Landpoint& p0, Landpoint& p1, Landpoint& p2, Landpoint& p3, Landpoint& p4, Eigen::MatrixXd UTC, double xp, double yp, double dut1, double dat);
Landpoint getSlopeVector(const Landpoint& p0, const Landpoint& p1, const Landpoint& p2, const Landpoint& p3, const Landpoint& p4);
////////////////////////////// 插值 ////////////////////////////////////////////
complex<double> Cubic_Convolution_interpolation(double u,double v,Eigen::MatrixX<complex<double>> img);
complex<double> Cubic_kernel_weight(double s);
double Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Landpoint p12, Landpoint p22);
inline float cross2d(Point_3d a, Point_3d b) { return a.x * b.y - a.y * b.x; }
inline Point_3d operator-(Point_3d a, Point_3d b) {
return Point_3d{ a.x - b.x, a.y - b.y, a.z - b.z };
};
inline Point_3d operator+(Point_3d a, Point_3d b) {
return Point_3d{ a.x + b.x, a.y +b.y, a.z + b.z };
};
inline double operator/(Point_3d a, Point_3d b) {
return sqrt(pow(a.x,2)+ pow(a.y, 2))/sqrt(pow(b.x, 2)+ pow(b.y, 2));
};
inline bool onSegment(Point_3d Pi, Point_3d Pj, Point_3d Q)
{
if ((Q.x - Pi.x) * (Pj.y - Pi.y) == (Pj.x - Pi.x) * (Q.y - Pi.y) //叉乘
//保证Q点坐标在pi,pj之间
&& min(Pi.x, Pj.x) <= Q.x && Q.x <= max(Pi.x, Pj.x)
&& min(Pi.y, Pj.y) <= Q.y && Q.y <= max(Pi.y, Pj.y))
return true;
else
return false;
}
inline Point_3d invBilinear(Point_3d p, Point_3d a, Point_3d b, Point_3d c, Point_3d d)
{
Point_3d res ;
Point_3d e = b - a;
Point_3d f = d - a;
Point_3d g = a - b + c - d;
Point_3d h = p - a;
double k2 = cross2d(g, f);
double k1 = cross2d(e, f) + cross2d(h, g);
double k0 = cross2d(h, e);
double u, v;
// if edges are parallel, this is a linear equation
if (abs(k2) < 0.001)
{
v = -k0 / k1;
u = (h.x - f.x *v) / (e.x + g.x *v);
p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
return p;
}
// otherwise, it's a quadratic
else
{
float w = k1 * k1 - 4.0 * k0 * k2;
if (w < 0.0){
// 可能在边界上
if (onSegment(a, b, p)) {
Point_3d tt = b - a;
Point_3d ttpa = p - a;
double scater=ttpa / tt;
if(scater<0||scater>1){ return { -9999,-9999,-9999 }; }
p.z = a.z + scater * tt.z;
return p;
}
else if (onSegment(b, c, p)) {
Point_3d tt = c-b;
Point_3d ttpa = p - b;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = b.z + scater * tt.z;
return p;
}
else if (onSegment(c, d, p)) {
Point_3d tt = d-c;
Point_3d ttpa = p - c;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = c.z + scater * tt.z;
return p;
}
else if (onSegment(d, a, p)) {
Point_3d tt = a-d;
Point_3d ttpa = p - d;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = d.z + scater * tt.z;
return p;
}
return { -9999,-9999,-9999 };
}
else {
w = sqrt(w);
float ik2 = 0.5 / k2;
float v = (-k1 - w) * ik2;
float u = (h.x - f.x * v) / (e.x + g.x * v);
if (u < 0.0 || u>1.0 || v < 0.0 || v>1.0)
{
v = (-k1 + w) * ik2;
u = (h.x - f.x * v) / (e.x + g.x * v);
}
p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
return p;
}
}
p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
return p;
}
//
// WGS84 到J2000 坐标系的变换
// 参考网址https://blog.csdn.net/hit5067/article/details/116894616
// 资料网址http://celestrak.org/spacedata/
// 参数文件:
// a. Earth Orientation Parameter 文件: http://celestrak.org/spacedata/EOP-Last5Years.csv
// b. Space Weather Data 文件: http://celestrak.org/spacedata/SW-Last5Years.csv
// 备注上述文件是自2017年-五年内
/**
wgs84 J2000 WGS t ,BLH
step 1: WGS 84
step 2:
step 3:
step 4:
step 5: J2000
**/
inline double sind(double degree) {
return sin(degree * d2r);
}
inline double cosd(double d) {
return cos(d * d2r);
}
/*
class WGS84_J2000
{
public:
WGS84_J2000();
~WGS84_J2000();
public:
// step1 WGS 84 转换到协议地球坐标系。
static Eigen::MatrixXd WGS84TECEF(Eigen::MatrixXd WGS84_Lon_lat_ait);
//step 2 协议地球坐标系 转换为瞬时地球坐标系
static Eigen::MatrixXd ordinateSingleRotate(int axis, double angle_deg);
// step 3 瞬时地球坐标系 转换为 瞬时真天球坐标系
// xyz= ordinateSingleRotate('z',-gst_deg)*earthFixedXYZ;
static int utc2gst(Eigen::MatrixXd UTC, double dUT1, double dAT, double& gst_deg, double& JDTDB);
// step 4 瞬时真天球坐标系 转到瞬时平天球 坐标系
static int nutationInLongitudeCaculate(double JD, double& epthilongA_deg, double& dertaPthi_deg, double& dertaEpthilong_deg, double& epthilong_deg);
// step5 瞬时平天球坐标系转换为协议天球坐标系J2000函数中 JDTDB 为给定时刻 的地球动力学时对应的儒略日,其计算方法由步骤三中的函数给出。
// xyz=ordinateSingleRotate('Z',zetaA)*ordinateSingleRotate('y',-thitaA)*ordinateSingleRotate('z',zA)*xyz;
static int precessionAngle(double JDTDB, double& zetaA, double& thitaA, double& zA);
// YMD2JD 同时 YMD2JD函数为 年月日转换为儒略日,具体说明 见公元纪年法(儒略历-格里高历转儒略日_${王小贱}的博客-CSDN博客_年积日计算公式
static double YMD2JD(double y, double m, double d);
static Eigen::MatrixXd WGS842J2000(Eigen::MatrixXd BLH_deg_m, Eigen::MatrixXd UTC, double xp, double yp, double dut1, double dat);
static Landpoint WGS842J2000(Landpoint LBH_deg_m, Eigen::MatrixXd UTC, double xp, double yp, double dut1, double dat);
public:
static std::string EOP_File_Path;
static std::string Space_Weather_Data;
// IAU2000模型有77项11列
static Eigen::Matrix<double, 77, 11> IAU2000ModelParams;
};
*/

View File

@ -0,0 +1 @@
#include "interpolation.h"

View File

@ -0,0 +1,10 @@
#pragma once
/**
*/
#include <stdio.h>
#include <stdlib.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_interp2d.h>
#include <gsl/gsl_spline2d.h>

View File

@ -0,0 +1,423 @@
//
// Copyright (c) 2012 Ronaldo Carpio
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appear in all copies and
// that both that copyright notice and this permission notice appear
// in supporting documentation. The authors make no representations
// about the suitability of this software for any purpose.
// It is provided "as is" without express or implied warranty.
//
/*
This is a C++ header-only library for N-dimensional linear interpolation on a rectangular grid. Implements two methods:
* Multilinear: Interpolate using the N-dimensional hypercube containing the point. Interpolation step is O(2^N)
* Simplicial: Interpolate using the N-dimensional simplex containing the point. Interpolation step is O(N log N), but less accurate.
Requires boost/multi_array library.
For a description of the algorithms, see:
* Weiser & Zarantonello (1988), "A Note on Piecewise Linear and Multilinear Table Interpolation in Many Dimensions", _Mathematics of Computation_ 50 (181), p. 189-196
* Davies (1996), "Multidimensional Triangulation and Interpolation for Reinforcement Learning", _Proceedings of Neural Information Processing Systems 1996_
*/
#ifndef _linterp_h
#define _linterp_h
#include <assert.h>
#include <math.h>
#include <stdarg.h>
#include <float.h>
#include <cstdarg>
#include <string>
#include <vector>
#include <array>
#include <functional>
#include <boost/multi_array.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/storage.hpp>
using std::vector;
using std::array;
typedef unsigned int uint;
typedef vector<int> iVec;
typedef vector<double> dVec;
// TODO:
// - specify behavior past grid boundaries.
// 1) clamp
// 2) return a pre-determined value (e.g. NaN)
// compile-time params:
// 1) number of dimensions
// 2) scalar type T
// 3) copy data or not (default: false). The grids will always be copied
// 4) ref count class (default: none)
// 5) continuous or not
// run-time constructor params:
// 1) f
// 2) grids
// 3) behavior outside grid: default=clamp
// 4) value to return outside grid, defaut=nan
struct EmptyClass {};
template <int N, class T, bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
class NDInterpolator {
public:
typedef T value_type;
typedef ArrayRefCountT array_ref_count_type;
typedef GridRefCountT grid_ref_count_type;
static const int m_N = N;
static const bool m_bCopyData = CopyData;
static const bool m_bContinuous = Continuous;
typedef boost::numeric::ublas::array_adaptor<T> grid_type;
typedef boost::const_multi_array_ref<T, N> array_type;
typedef std::unique_ptr<array_type> array_type_ptr;
array_type_ptr m_pF;
ArrayRefCountT m_ref_F; // reference count for m_pF
vector<T> m_F_copy; // if CopyData == true, this holds the copy of F
vector<grid_type> m_grid_list;
vector<GridRefCountT> m_grid_ref_list; // reference counts for grids
vector<vector<T> > m_grid_copy_list; // if CopyData == true, this holds the copies of the grids
// constructors assume that [f_begin, f_end) is a contiguous array in C-order
// non ref-counted constructor.
template <class IterT1, class IterT2, class IterT3>
NDInterpolator(IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end) {
init(grids_begin, grids_len_begin, f_begin, f_end);
}
// ref-counted constructor
template <class IterT1, class IterT2, class IterT3, class RefCountIterT>
NDInterpolator(IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end, ArrayRefCountT &refF, RefCountIterT grid_refs_begin) {
init_refcount(grids_begin, grids_len_begin, f_begin, f_end, refF, grid_refs_begin);
}
template <class IterT1, class IterT2, class IterT3>
void init(IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end) {
set_grids(grids_begin, grids_len_begin, m_bCopyData);
set_f_array(f_begin, f_end, m_bCopyData);
}
template <class IterT1, class IterT2, class IterT3, class RefCountIterT>
void init_refcount(IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end, ArrayRefCountT &refF, RefCountIterT grid_refs_begin) {
set_grids(grids_begin, grids_len_begin, m_bCopyData);
set_grids_refcount(grid_refs_begin, grid_refs_begin + N);
set_f_array(f_begin, f_end, m_bCopyData);
set_f_refcount(refF);
}
template <class IterT1, class IterT2>
void set_grids(IterT1 grids_begin, IterT2 grids_len_begin, bool bCopy) {
m_grid_list.clear();
m_grid_ref_list.clear();
m_grid_copy_list.clear();
for (int i=0; i<N; i++) {
int gridLength = grids_len_begin[i];
if (bCopy == false) {
T const *grid_ptr = &(*grids_begin[i]);
m_grid_list.push_back(grid_type(gridLength, (T*) grid_ptr )); // use the given pointer
} else {
m_grid_copy_list.push_back( vector<T>(grids_begin[i], grids_begin[i] + grids_len_begin[i]) ); // make our own copy of the grid
T *begin = &(m_grid_copy_list[i][0]);
m_grid_list.push_back(grid_type(gridLength, begin)); // use our copy
}
}
}
template <class IterT1, class RefCountIterT>
void set_grids_refcount(RefCountIterT refs_begin, RefCountIterT refs_end) {
assert(refs_end - refs_begin == N);
m_grid_ref_list.assign(refs_begin, refs_begin + N);
}
// assumes that [f_begin, f_end) is a contiguous array in C-order
template <class IterT>
void set_f_array(IterT f_begin, IterT f_end, bool bCopy) {
unsigned int nGridPoints = 1;
array<int,N> sizes;
for (unsigned int i=0; i<m_grid_list.size(); i++) {
sizes[i] = m_grid_list[i].size();
nGridPoints *= sizes[i];
}
int f_len = f_end - f_begin;
if ( (m_bContinuous && f_len != nGridPoints) || (!m_bContinuous && f_len != 2 * nGridPoints) ) {
throw std::invalid_argument("f has wrong size");
}
for (unsigned int i=0; i<m_grid_list.size(); i++) {
if (!m_bContinuous) { sizes[i] *= 2; }
}
m_F_copy.clear();
if (bCopy == false) {
m_pF.reset(new array_type(f_begin, sizes));
} else {
m_F_copy = vector<T>(f_begin, f_end);
m_pF.reset(new array_type(&m_F_copy[0], sizes));
}
}
void set_f_refcount(ArrayRefCountT &refF) {
m_ref_F = refF;
}
// -1 is before the first grid point
// N-1 (where grid.size() == N) is after the last grid point
int find_cell(int dim, T x) const {
grid_type const &grid(m_grid_list[dim]);
if (x < *(grid.begin())) return -1;
else if (x >= *(grid.end()-1)) return grid.size()-1;
else {
auto i_upper = std::upper_bound(grid.begin(), grid.end(), x);
return i_upper - grid.begin() - 1;
}
}
// return the value of f at the given cell and vertex
T get_f_val(array<int,N> const &cell_index, array<int,N> const &v_index) const {
array<int,N> f_index;
if (m_bContinuous) {
for (int i=0; i<N; i++) {
if (cell_index[i] < 0) {
f_index[i] = 0;
} else if (cell_index[i] >= m_grid_list[i].size()-1) {
f_index[i] = m_grid_list[i].size()-1;
} else {
f_index[i] = cell_index[i] + v_index[i];
}
}
} else {
for (int i=0; i<N; i++) {
if (cell_index[i] < 0) {
f_index[i] = 0;
} else if (cell_index[i] >= m_grid_list[i].size()-1) {
f_index[i] = (2*m_grid_list[i].size())-1;
} else {
f_index[i] = 1 + (2*cell_index[i]) + v_index[i];
}
}
}
return (*m_pF)(f_index);
}
T get_f_val(array<int,N> const &cell_index, int v) const {
array<int,N> v_index;
for (int dim=0; dim<N; dim++) {
v_index[dim] = (v >> (N-dim-1)) & 1; // test if the i-th bit is set
}
return get_f_val(cell_index, v_index);
}
};
template <int N, class T, bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
class InterpSimplex : public NDInterpolator<N,T,CopyData,Continuous,ArrayRefCountT,GridRefCountT> {
public:
typedef NDInterpolator<N,T,CopyData,Continuous,ArrayRefCountT,GridRefCountT> super;
template <class IterT1, class IterT2, class IterT3>
InterpSimplex(IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end)
: super(grids_begin, grids_len_begin, f_begin, f_end)
{}
template <class IterT1, class IterT2, class IterT3, class RefCountIterT>
InterpSimplex(IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end, ArrayRefCountT &refF, RefCountIterT ref_begins)
: super(grids_begin, grids_len_begin, f_begin, f_end, refF, ref_begins)
{}
template <class IterT>
T interp(IterT x_begin) const {
array<T,1> result;
array< array<T,1>, N > coord_iter;
for (int i=0; i<N; i++) {
coord_iter[i][0] = x_begin[i];
}
interp_vec(1, coord_iter.begin(), coord_iter.end(), result.begin());
return result[0];
}
template <class IterT1, class IterT2>
void interp_vec(int n, IterT1 coord_iter_begin, IterT1 coord_iter_end, IterT2 i_result) const {
assert(N == coord_iter_end - coord_iter_begin);
array<int,N> cell_index, v_index;
array<std::pair<T, int>,N> xipair;
int c;
T y, v0, v1;
//mexPrintf("%d\n", n);
for (int i=0; i<n; i++) { // for each point
for (int dim=0; dim<N; dim++) {
typename super::grid_type const &grid(super::m_grid_list[dim]);
c = this->find_cell(dim, coord_iter_begin[dim][i]);
//mexPrintf("%d\n", c);
if (c == -1) { // before first grid point
y = 1.0;
} else if (c == grid.size()-1) { // after last grid point
y = 0.0;
} else {
//mexPrintf("%f %f\n", grid[c], grid[c+1]);
y = (coord_iter_begin[dim][i] - grid[c]) / (grid[c + 1] - grid[c]);
if (y < 0.0) y=0.0;
else if (y > 1.0) y=1.0;
}
xipair[dim].first = y;
xipair[dim].second = dim;
cell_index[dim] = c;
}
// sort xi's and get the permutation
std::sort(xipair.begin(), xipair.end(), [](std::pair<T, int> const &a, std::pair<T, int> const &b) {
return (a.first < b.first);
});
// walk the vertices of the simplex determined by the permutation
for (int j=0; j<N; j++) {
v_index[j] = 1;
}
v0 = this->get_f_val(cell_index, v_index);
y = v0;
for (int j=0; j<N; j++) {
v_index[xipair[j].second]--;
v1 = this->get_f_val(cell_index, v_index);
y += (1.0 - xipair[j].first) * (v1-v0); // interpolate
v0 = v1;
}
*i_result++ = y;
}
}
};
template <int N, class T, bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
class InterpMultilinear : public NDInterpolator<N,T,CopyData,Continuous,ArrayRefCountT,GridRefCountT> {
public:
typedef NDInterpolator<N,T,CopyData,Continuous,ArrayRefCountT,GridRefCountT> super;
template <class IterT1, class IterT2, class IterT3>
InterpMultilinear(IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end)
: super(grids_begin, grids_len_begin, f_begin, f_end)
{}
template <class IterT1, class IterT2, class IterT3, class RefCountIterT>
InterpMultilinear(IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end, ArrayRefCountT &refF, RefCountIterT ref_begins)
: super(grids_begin, grids_len_begin, f_begin, f_end, refF, ref_begins)
{}
template <class IterT1, class IterT2>
static T linterp_nd_unitcube(IterT1 f_begin, IterT1 f_end, IterT2 xi_begin, IterT2 xi_end) {
int n = xi_end - xi_begin;
int f_len = f_end - f_begin;
assert(1 << n == f_len);
T sub_lower, sub_upper;
if (n == 1) {
sub_lower = f_begin[0];
sub_upper = f_begin[1];
} else {
sub_lower = linterp_nd_unitcube(f_begin, f_begin + (f_len/2), xi_begin + 1, xi_end);
sub_upper = linterp_nd_unitcube(f_begin + (f_len/2), f_end, xi_begin + 1, xi_end);
}
T result = sub_lower + (*xi_begin)*(sub_upper - sub_lower);
return result;
}
template <class IterT>
T interp(IterT x_begin) const {
array<T,1> result;
array< array<T,1>, N > coord_iter;
for (int i=0; i<N; i++) {
coord_iter[i][0] = x_begin[i];
}
interp_vec(1, coord_iter.begin(), coord_iter.end(), result.begin());
return result[0];
}
template <class IterT1, class IterT2>
void interp_vec(int n, IterT1 coord_iter_begin, IterT1 coord_iter_end, IterT2 i_result) const {
assert(N == coord_iter_end - coord_iter_begin);
array<int,N> index;
int c;
T y, xi;
vector<T> f(1 << N);
array<T,N> x;
for (int i=0; i<n; i++) { // loop over each point
for (int dim=0; dim<N; dim++) { // loop over each dimension
auto const &grid(super::m_grid_list[dim]);
xi = coord_iter_begin[dim][i];
c = this->find_cell(dim, coord_iter_begin[dim][i]);
if (c == -1) { // before first grid point
y = 1.0;
} else if (c == grid.size()-1) { // after last grid point
y = 0.0;
} else {
y = (coord_iter_begin[dim][i] - grid[c]) / (grid[c + 1] - grid[c]);
if (y < 0.0) y=0.0;
else if (y > 1.0) y=1.0;
}
index[dim] = c;
x[dim] = y;
}
// copy f values at vertices
for (int v=0; v < (1 << N); v++) { // loop over each vertex of hypercube
f[v] = this->get_f_val(index, v);
}
*i_result++ = linterp_nd_unitcube(f.begin(), f.end(), x.begin(), x.end());
}
}
};
typedef InterpSimplex<1,double> NDInterpolator_1_S;
typedef InterpSimplex<2,double> NDInterpolator_2_S;
typedef InterpSimplex<3,double> NDInterpolator_3_S;
typedef InterpSimplex<4,double> NDInterpolator_4_S;
typedef InterpSimplex<5,double> NDInterpolator_5_S;
typedef InterpMultilinear<1,double> NDInterpolator_1_ML;
typedef InterpMultilinear<2,double> NDInterpolator_2_ML;
typedef InterpMultilinear<3,double> NDInterpolator_3_ML;
typedef InterpMultilinear<4,double> NDInterpolator_4_ML;
typedef InterpMultilinear<5,double> NDInterpolator_5_ML;
// C interface
extern "C" {
void linterp_simplex_1(double **grids_begin, int *grid_len_begin, double *pF, int xi_len, double **xi_begin, double *pResult);
void linterp_simplex_2(double **grids_begin, int *grid_len_begin, double *pF, int xi_len, double **xi_begin, double *pResult);
void linterp_simplex_3(double **grids_begin, int *grid_len_begin, double *pF, int xi_len, double **xi_begin, double *pResult);
}
void inline linterp_simplex_1(double **grids_begin, int *grid_len_begin, double *pF, int xi_len, double **xi_begin, double *pResult) {
const int N=1;
size_t total_size = 1;
for (int i=0; i<N; i++) {
total_size *= grid_len_begin[i];
}
InterpSimplex<N, double, false> interp_obj(grids_begin, grid_len_begin, pF, pF + total_size);
interp_obj.interp_vec(xi_len, xi_begin, xi_begin + N, pResult);
}
void inline linterp_simplex_2(double **grids_begin, int *grid_len_begin, double *pF, int xi_len, double **xi_begin, double *pResult) {
const int N=2;
size_t total_size = 1;
for (int i=0; i<N; i++) {
total_size *= grid_len_begin[i];
}
InterpSimplex<N, double, false> interp_obj(grids_begin, grid_len_begin, pF, pF + total_size);
interp_obj.interp_vec(xi_len, xi_begin, xi_begin + N, pResult);
}
void inline linterp_simplex_3(double **grids_begin, int *grid_len_begin, double *pF, int xi_len, double **xi_begin, double *pResult) {
const int N=3;
size_t total_size = 1;
for (int i=0; i<N; i++) {
total_size *= grid_len_begin[i];
}
InterpSimplex<N, double, false> interp_obj(grids_begin, grid_len_begin, pF, pF + total_size);
interp_obj.interp_vec(xi_len, xi_begin, xi_begin + N, pResult);
}
#endif //_linterp_h

View File

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 SIMOrthoProgram.rc 使用
//
#define IDR_PROJ1 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,241 @@
#pragma once
///
/// 仿真成像算法
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// 本地方法
#include "baseTool.h"
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
#include <omp.h>
#include "SateOrbit.h"
#include "ImageMatch.h"
using namespace std;
using namespace Eigen;
////////////// 常用函数 ////////////////////////
double getRangeColumn(long double R, long double NearRange, long double Fs, long double lamda);
Eigen::MatrixXd getRangeColumn(Eigen::MatrixXd R, long double NearRange, long double Fs, long double lamda);
double getRangebyColumn(double j, long double NearRange, long double Fs, long double lamda);
Eigen::MatrixXd getRangebyColumn(Eigen::MatrixXd j, long double NearRange, long double Fs, long double lamda);
///////////// ptsn 算法 /////////////////////
class PSTNAlgorithm {
public:
// 初始化与析构函数
PSTNAlgorithm();
PSTNAlgorithm(string parameterPath);
~PSTNAlgorithm();
int dem2lat_lon(std::string dem_path, std::string lon_path, std::string lat_path);
int dem2SAR_RC(std::string dem_path, std::string sim_rc_path);
// 模拟算法函数
Eigen::MatrixX<double> calNumericalDopplerValue(Eigen::MatrixX<double> R);// 数值模拟法计算多普勒频移值
double calNumericalDopplerValue(double R);// 数值模拟法计算多普勒频移值
Eigen::MatrixX<double> calTheoryDopplerValue(Eigen::MatrixX<double> R, Eigen::MatrixX<double> R_s1, Eigen::MatrixX<double> V_s1);//根据理论模型计算多普勒频移值
double calTheoryDopplerValue(double R, Eigen::MatrixX<double> R_s1, Eigen::MatrixX<double> V_s1);
Eigen::MatrixX<double> PSTN(Eigen::MatrixX<double> TargetPostion, double ave_dem, double dt, bool isCol ); // 输入DEM
//Eigen::MatrixXd WGS842J2000(Eigen::MatrixXd blh);
//Landpoint WGS842J2000(Landpoint p);
public: // WGS84 到 J2000 之间的变换参数
Eigen::MatrixXd UTC;
double Xp = 0.204071;
double Yp = 0.318663;
double Dut1 = 0.0366742;
double Dat = 37;
public:
int height; // 影像的高
int width;
// 入射角
double near_in_angle;// 近入射角
double far_in_angle;// 远入射角
// SAR的成像参数
double fs;// 距离向采样率
double R0;//近斜距
double LightSpeed; // 光速
double lamda;// 波长
double refrange;// 参考斜距
double doppler_reference_time; //多普勒参考时间
double imgStartTime;// 成像起始时间
double PRF;// 脉冲重复率
int doppler_paramenter_number;//多普勒系数个数
MatrixX<double> doppler_paras;// 多普勒系数
OrbitPoly orbit; // 轨道模型
};
/// <summary>
/// 获取局地入射角,角度值
/// </summary>
/// <param name="satepoint"></param>
/// <param name="landpoint"></param>
/// <param name="slopeVector"></param>
/// <returns></returns>
double getlocalIncAngle(Landpoint& satepoint, Landpoint& landpoint, Landpoint& slopeVector);
/// <summary>
/// 侧视入射角,角度值
/// </summary>
/// <param name="satepoint"></param>
/// <param name="landpoint"></param>
/// <returns></returns>
double getIncAngle(Landpoint& satepoint, Landpoint& landpoint);
/// <summary>
/// ASF计算方法
/// </summary>
class ASFOrthClass {
public:
Eigen::MatrixXd Satellite2ECR(Eigen::Vector3d Rsc, Eigen::Vector3d Vsc); // 根据卫星坐标计算变换矩阵 M
Eigen::Vector3d UnitVectorOfSatelliteAndTarget(double alpha, double beta, Eigen::MatrixXd M);
double GetLookFromRangeYaw(double R, double alpha, double beta, Eigen::Vector3d SatellitePosition, Eigen::Vector3d SatelliteVelocity, double R_threshold, double H = 0);
Eigen::Vector3d GetXYZByBetaAlpha(double alpha,double beta, Eigen::Vector3d SatellitePosition,double R, Eigen::MatrixXd M);
double FD(double alpha, double beta, Eigen::Vector3d SatelliteVelocity, Eigen::Vector3d TargetVelocity,double R,double lamda, Eigen::MatrixXd M);
double FR(double alpha, double beta, Eigen::Vector3d SatellitePosition, Eigen::MatrixXd M, double R_threshold, double H = 0);
Eigen::Vector3d ASF(double R, Eigen::Vector3d SatellitePosition, Eigen::Vector3d SatelliteVelocity, Eigen::Vector3d TargetPosition, PSTNAlgorithm PSTN, double R_threshold, double H = 0, double alpha0 = 0, double beta0 = 0);
};
/// <summary>
/// 仿真处理流程
/// </summary>
class simProcess {
public:
simProcess();
~simProcess();
int parameters(int argc, char* argv[]);
int InitSimulationSAR(std::string paras_path,std::string workspace_path,std::string out_dir_path,std::string in_dem_path,std::string in_sar_path); // 间接定位法
int CreateSARDEM();
int dem2SAR(); // 切换行号
int SARIncidentAngle();
int SARSimulationWGS();
int SARSimulation();
int in_sar_power();
int ReflectTable_WGS2Range();
int InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path,std::string in_rpc_lon_lat_path,std::string out_inc_angle_path, std::string out_local_inc_angle_path, std::string out_inc_angle_geo_path, std::string out_local_inc_angle_geo_path);
int dem2SAR_row(); // 切换行号
int SARIncidentAngle_RPC();
int createRPCDEM();
// 格网离散插值
int Scatter2Grid(std::string lon_lat_path, std::string data_tiff, std::string grid_path, double space);
// ASF 模块计算
int InitASFSAR(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path);
int ASF(std::string in_dem_path, std::string out_latlon_path, ASFOrthClass asfclass, PSTNAlgorithm PSTN);
//int dem2simSAR(std::string dem_path, std::string out_sim_path, PSTNAlgorithm PSTN); // 根据DEM生成输出仿真图像
int sim_SAR(std::string dem_path, std::string sim_rc_path, std::string sim_sar_path, PSTNAlgorithm PSTN);
int dem2aspect_slope(std::string dem_path, std::string aspect_path, std::string slope_path);
int sim_sum_SAR(std::string sim_dem_path,std::string sim_rc_path, std::string sim_orth_path, std::string sim_sum_path,PSTNAlgorithm pstn);
void interpolation_GTC_sar_sigma(std::string in_rc_wgs84_path, std::string in_ori_sar_path, std::string out_orth_sar_path, PSTNAlgorithm pstn);
//双线性插值
void interpolation_bil(std::string in_rc_wgs84_path, std::string in_ori_sar_path, std::string out_orth_sar_path, PSTNAlgorithm pstn);
//lee滤波
void lee_process(std::string in_ori_sar_path, std::string out_orth_sar_path, int w_size, double noise_var);
// 原始影像强度图
int ori_sar_power(std::string ori_sar_path, std::string out_sar_power_path);
// 匹配偏移模型构建
int createImageMatchModel(std::string ori_sar_rsc_path, std::string ori_sar_rsc_jpg_path, std::string sim_sar_path, std::string sim_sar_jpg_path, std::string matchmodel_path);
// 纠正影像
int correctOrth_rc(std::string sim_rc_path,ImageMatch matchmodel);
int correct_ati(std::string orth_rc_path, std::string dem_path, std::string out_inclocal_path, std::string out_dem_path, std::string out_count_path, PSTNAlgorithm PSTN);
void calcalIncident_localIncident_angle(std::string in_dem_path, std::string in_rc_wgs84_path, std::string out_incident_angle_path, std::string out_local_incident_angle_path, PSTNAlgorithm PSTN);
void calGEC_Incident_localIncident_angle(std::string in_dem_path, std::string in_gec_lon_lat_path,std::string out_incident_angle_path, std::string out_local_incident_angle_path,PSTNAlgorithm PSTN);
void interpolation_GTC_sar(std::string in_rc_wgs84_path, std::string in_ori_sar_path, std::string out_orth_sar_path, PSTNAlgorithm pstn);
// RPC
void CreateRPC_DEM(std::string in_rpc_rc_path, std::string in_dem_path, std::string out_rpc_dem_path);
void CreateRPC_refrenceTable(string in_rpc_tiff_path, string in_merge_dem, string out_rpc_lon_lat_tiff_path);
void CorrectionFromSLC2Geo(string in_lon_lat_path, string in_radar_path, string out_radar_path, int in_band_ids);
// 内部参数
public:
ImageMatch matchmodel;
bool isMatchModel;
std::string workSpace_path;// 工作空间路径
std::string outSpace_path;// 输出工作空间路径
PSTNAlgorithm pstn; // 参数组件
///// RPC 局地入射角 ///////////////////////////////////
std::string in_rpc_lon_lat_path;
std::string out_dir_path;
std::string workspace_path;
// 临时文件
std::string rpc_wgs_path;
std::string ori_sim_count_tiff;// 映射角文件
// 输出文件
std::string out_inc_angle_rpc_path;
std::string out_local_inc_angle_rpc_path;
// 输出文件
std::string out_inc_angle_geo_path;
std::string out_local_inc_angle_geo_path;
///// 正向仿真方法 /////////
// 临时产品文件
std::string in_dem_path; // 输入DEM
std::string dem_path; // 重采样之后DEM
std::string dem_r_path;// 行号影像
std::string dem_rc_path; // 行列号
std::string sar_sim_wgs_path;
std::string sar_sim_path;
std::string in_sar_path;
std::string sar_jpg_path;
std::string sar_power_path;
// 最终产品
std::string out_dem_rc_path; // 经纬度与行列号变换文件
std::string out_dem_slantRange_path; // 斜距文件
std::string out_plant_slantRange_path;// 平面斜距文件
//// ASF 方法 /////////////
std::string out_lon_path;// 经度
std::string out_lat_path;// 纬度
std::string out_slantRange_path;// 斜距文件
/// 共同文件 ///
std::string out_localIncidenct_path;// 计算局地入射角
std::string out_incidence_path; // 入射角文件
std::string out_ori_sim_tiff;// 映射角文件'
std::string out_sim_ori_tiff;
};
bool PtInRect(Point_3d pCur, Point_3d pLeftTop, Point_3d pRightTop, Point_3d pRightBelow, Point_3d pLeftBelow);

View File

@ -0,0 +1,282 @@
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
#include <stdlib.h>
#include <direct.h>
// gdal
#include <proj.h>
#include <string>
#include "gdal_priv.h"
#include "ogr_geometry.h"
#include "gdalwarper.h"
#include "baseTool.h"
#include "simptsn.h"
using namespace std;
using namespace Eigen;
#include "test_moudel.h"
int test_main(int mode, string rootpath)
{
switch (mode)
{
case 0:
{
test_mode_0();
break;
};
case 1:
{
test_mode_1(rootpath);
break;
}
case 7: {
test_mode_7();
break;
}
case 8: {
std::string in_rpc_tiff = "D:\\MicroSAR\\C-SAR\\MicroWorkspace\\Ortho\\Temporary\\GF3_MYN_QPSI_011437_E99.2_N28.6_20181012_L1B_HH_L10003514912_db.tif";
std::string out_lon_lat_path = "D:\\MicroSAR\\C-SAR\\MicroWorkspace\\Ortho\\Temporary\\RPC_ori_sim.tif";
std::string dem_path = "D:\\MicroSAR\\C-SAR\\MicroWorkspace\\Ortho\\Temporary\\TestDEM\\mergedDEM.tif";
simProcess process;
//InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path, std::string in_rpc_lon_lat_path)
std::cout << "==========================================================================" << endl;
process.CreateRPC_refrenceTable(in_rpc_tiff, dem_path,out_lon_lat_path);
std::cout << "==========================================================================" << endl;
break;
}
default:
test_ASF(rootpath);
break;
}
return 0;
}
int test_mode_7() {
//
std::cout << "mode 7: get rpc incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 7 in_parameter_path in_dem_path in_gec_lon_lat_path work_path taget_path out_incident_angle_path out_local_incident_angle_path";
std::string parameter_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Temporary\\package\\orth_para.txt";
std::string dem_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Temporary\\TestDEM\\mergedDEM.tif";
std::string in_gec_lon_lat_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Temporary\\package\\RPC_ori_sim.tif";
std::string work_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Temporary";
std::string taget_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Temporary\\package";
std::string out_incident_angle_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Temporary\\package\\inc_angle.tiff";
std::string out_local_incident_angle_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Temporary\\package\\local_inc_angle.tiff";
std::string out_incident_angle_geo_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Temporary\\package\\inc_angle_geo.tiff";
std::string out_local_incident_angle_geo_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Temporary\\package\\local_inc_angle_geo.tiff";
simProcess process;
//InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path, std::string in_rpc_lon_lat_path)
std::cout << "==========================================================================" << endl;
process.InitRPCIncAngle(parameter_path, work_path, taget_path, dem_path, in_gec_lon_lat_path, out_incident_angle_path, out_local_incident_angle_path, out_incident_angle_geo_path, out_local_incident_angle_geo_path);
std::cout << "==========================================================================" << endl;
return 0;
}
int test_mode_0()
{
std::cout << "State:\tTEST MODE" << endl;
test_LLA2XYZ_XYZ2LLA();
return 0;
}
int test_mode_1(string rootpath)
{
// .\baseTool\x64\Release\SIMOrthoProgram.exe 1 D:\MicroWorkspace\C-SAR\Ortho\Temporary\unpack\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_HH_L10003923848.tiff
//???????
std::string root_path = rootpath;// "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary2";
std::string workspace = "D:\\MicroSAR\\C-SAR\\MicroWorkspace\\Ortho\\Temporary";
std::string parameter_path =workspace+ "\\package\\orth_para.txt"; //
std::string dem_path = workspace + "\\TestDEM\\pindem.tif"; //
std::string in_sar_path = workspace + "\\unpack\\GF3_KAS_FSI_020253_E110.8_N25.5_20200614_L1A_HHHV_L10004871459\\GF3_KAS_FSI_020253_E110.8_N25.5_20200614_L1A_HH_L10004871459.tiff"; //
std::string work_path = workspace ; //
std::string taget_path = workspace + "\\package"; //
std::cout << "==========================================================================" << endl;
std::cout << "in parameters:========================================================" << endl;
std::cout << "parameters file path:\t" << parameter_path << endl;
std::cout << "input dem image(WGS84)" << dem_path << endl;
std::cout << "the sar image:\n" << in_sar_path << endl;
std::cout << "the work path for outputing temp file :\t" << work_path << endl;
std::cout << "the out file for finnal file:\t" << taget_path << endl;
simProcess process;
std::cout << "==========================================================================" << endl;
process.InitSimulationSAR(parameter_path, work_path, taget_path, dem_path, in_sar_path);
std::cout << "==========================================================================" << endl;
return 0;
}
int test_ASF(string rootpath) {
std::string root_path = rootpath;// "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary2";
std::string parameter_path = root_path + "\\package\\orth_para.txt";
std::string dem_path = root_path + "\\TestDEM\\mergedDEM.tif";
std::string ori_sar_path = root_path + "\\unpack\\" + "GF3_KAS_FSI_020253_E110.8_N25.5_20200614_L1A_HHHV_L10004871459\\GF3_KAS_FSI_020253_E110.8_N25.5_20200614_L1A_HH_L10003923848.tiff";
std::string work_path = root_path + "\\TestSim";
std::string taget_path = root_path + "\\output";
std::string out_GEC_dem_path = root_path + "\\output\\GEC_dem.tif";
std::string out_GTC_rc_path = root_path + "\\output\\GTC_rc_wgs84.tif";
std::string out_GEC_lon_lat_path = root_path + "\\output\\GEC_lon_lat.tif";
std::string out_clip_DEM_path = root_path + "\\output\\Orth_dem.tif";
std::cout << "==========================================================================" << endl;
std::cout << "????????????????????DEM ??¦¶" << endl;
std::cout << "SIMOrthoProgram.exe 1 in_parameter_path in_dem_path in_ori_sar_path in_work_path in_taget_path ";
std::cout << "out_GEC_dem_path out_GTC_rc_path out_GEC_lon_lat_path out_clip_dem_path" << endl;
std::cout << "==========================================================================" << endl;
std::cout << "in parameters:========================================================" << endl;
std::cout << "parameters file path:\t" << parameter_path << endl;
std::cout << "input dem image(WGS84)" << dem_path << endl;
std::cout << "the reference sar image for match simulation sar image:\n" << ori_sar_path << endl;
std::cout << "the work path for outputing temp file :\t" << work_path << endl;
std::cout << "the out file for finnal file:\t" << taget_path << endl;
simProcess process;
ASFOrthClass ASFClass;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
//
dem_path = out_clip_DEM_path;// JoinPath(work_path, "clipDEM.tif");
std::string out_simrc_path = JoinPath(work_path, "dem_sar_rc.tif"); //r,c
std::string sim_sar_orth_path = JoinPath(work_path, "sim_sar_orth.tif"); // orth_sim,orth_inclocal
std::string dem_slope_path = JoinPath(work_path, "dem_slope.tif");
std::string dem_aspect_path = JoinPath(work_path, "dem_aspect.tif");
std::string sim_sar_path = JoinPath(work_path, "sim_sar_sum.tif"); // sim count dem
std::string ori_sar_rsc_path = JoinPath(work_path, "ori_sar_power.tif"); // ori_power
std::string ori_sar_rsc_jpg_path = JoinPath(work_path, "ori_sar_power.jpg");
std::string sim_sar_jpg_path = JoinPath(work_path, "sim_sar_sum.jpg");
std::string matchmodel_path = JoinPath(work_path, "matchmodel.txt"); // matchmodel
std::string out_dem_count_path = JoinPath(work_path, "dem_count.tif");
std::string out_dem_path = out_GEC_dem_path;
std::string out_inclocal_path = JoinPath(taget_path, "inclocal.tif");
std::string out_sar_rc_path = out_GTC_rc_path;
std::string out_lon_lat_path = out_GEC_lon_lat_path;
if (process.isMatchModel) {
process.correctOrth_rc(out_simrc_path, process.matchmodel);
}
if (boost::filesystem::exists(boost::filesystem::path(out_sar_rc_path))) {
boost::filesystem::remove(boost::filesystem::path(out_sar_rc_path));
}
boost::filesystem::copy_file(boost::filesystem::path(out_simrc_path), boost::filesystem::path(out_sar_rc_path));
process.correct_ati(out_sar_rc_path, dem_path, out_inclocal_path, out_dem_path, out_dem_count_path, pstn);
// ASF
process.ASF(out_dem_path, out_lon_lat_path, ASFClass, pstn);
return 0;
}
int test_mode_2()
{
std::string parameter_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\orth_para.txt";
std::string dem_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\RPC_Ortho\\RPC_DEM.tiff";
std::string in_rc_wgs84_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\RPC_Ortho\\RPC_sar_rc.tiff";
std::string out_incident_angle_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\RPC_Ortho\\RPC_incident_angle.tiff";
std::string out_local_incident_angle_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\RPC_Ortho\\RPC_local_incident_angle.tiff";
std::cout << "mode 2: get incident angle and local incident angle by rc_wgs84 and dem and statellite model:\n";
std::cout << "SIMOrthoProgram.exe 2 in_parameter_path in_dem_path in_rc_wgs84_path out_incident_angle_path out_local_incident_angle_path";
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
process.calcalIncident_localIncident_angle(dem_path, in_rc_wgs84_path, out_incident_angle_path, out_local_incident_angle_path, pstn);
return 0;
}
int test_mode_3()
{
std::string parameter_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\orth_para.txt";
std::string in_rc_wgs84_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\output\\GTC_rc_wgs84.tiff";
std::string in_ori_sar_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\unpack\\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848\\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_HH_L10003923848.tiff";
std::string out_orth_sar_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\output\\GTC\\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_HH_L10003923848.tiff";
std::cout << "mode 3: interpolation(cubic convolution) orth sar value by rc_wgs84 and ori_sar image and model:\n ";
std::cout << "SIMOrthoProgram.exe 3 in_parameter_path in_rc_wgs84_path in_ori_sar_path out_orth_sar_path";
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
process.interpolation_GTC_sar(in_rc_wgs84_path, in_ori_sar_path, out_orth_sar_path, pstn);
return 0;
}
int test_mode_4()
{
std::string parameter_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\orth_para.txt";
std::string in_dem_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\output\\Orth_dem.tiff";
std::string in_rpc_rc_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\output\\\RPC_Ortho\\RPC_sar_rc.tiff";
std::string out_rpc_dem_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\output\\RPC_Ortho\\RPC_DEM.tiff";
std::string out_incident_angle_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\output\\RPC_Ortho\\RPC_incident_angle.tiff";
std::string out_local_incident_angle_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\output\\RPC_Ortho\\RPC_local_incident_angle.tiff";
std::cout << "mode 4: get RPC incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 4 in_parameter_path in_dem_path in_rpc_rc_path out_rpc_dem_path out_incident_angle_path out_local_incident_angle_path";
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
process.CreateRPC_DEM(in_rpc_rc_path, in_dem_path, out_rpc_dem_path);
process.calcalIncident_localIncident_angle(out_rpc_dem_path, in_rpc_rc_path, out_incident_angle_path, out_local_incident_angle_path, pstn);
return 0;
}
int test_mode_5()
{
std::string in_ori_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\output\\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_HH_L10003923848_GTC_geo_wp.tif";
std::string out_power_path = "D:\\MicroSAR\\C-SAR\\SIMOrthoProgram\\Temporary\\package\\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_HH_L10003923848_GTC_geo_OrthoResult.tif";
std::cout << "mode 5: convert ori tiff to power tiff:";
std::cout << "SIMOrthoProgram.exe 5 in_ori_path out_power_path";
simProcess process;
process.ori_sar_power(in_ori_path, out_power_path);
return 0;
}
int test_mode_6()
{
return 0;
}
int test_LLA2XYZ_XYZ2LLA()
{
std::cout << "===========================================" << endl;
std::cout << "TEST LLA2XYZ and XYZ2LLA " << endl;
bool pass = false;
Landpoint lla_p{ 30,40,500 };
Landpoint xyz_p = LLA2XYZ(lla_p);
Landpoint lla_p2 = XYZ2LLA(xyz_p);
std::cout << "LLA:\t" << lla_p.lon << "," << lla_p.lat << "," << lla_p.ati << endl;
std::cout << "XYZ:\t" << xyz_p.lon << "," << xyz_p.lat << "," << xyz_p.ati << endl;
std::cout<<"LLA2:\t"<< lla_p2.lon << "," << lla_p2.lat << "," << lla_p2.ati << endl;
pass = (lla_p2.lon-lla_p.lon==0) && (lla_p2.lat- lla_p.lat==0) && (lla_p2.ati-lla_p.ati==0);
std::cout << "TEST LLA2XYZ and XYZ2LLA passed:" << pass << endl;
std::cout << "===========================================" << endl;
return pass?1:0;
}
int test_vector_operator()
{
// ????
return 0;
}

View File

@ -0,0 +1,41 @@
#pragma once
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
#include <stdlib.h>
#include <direct.h>
// gdal
#include <proj.h>
#include <string>
#include "gdal_priv.h"
#include "ogr_geometry.h"
#include "gdalwarper.h"
#include "baseTool.h"
#include "simptsn.h"
using namespace std;
using namespace Eigen;
class test_moudel
{
};
int test_main(int mode, string rootpath);
int test_mode_0();
int test_mode_1(string rootpath);
int test_ASF(string rootpath);
int test_mode_2();
int test_mode_3();
int test_mode_4();
int test_mode_5();
int test_mode_6();
int test_mode_7();
int test_LLA2XYZ_XYZ2LLA();
int test_vector_operator();

View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@ -0,0 +1,56 @@
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
*.dll
x64/
x64/*
.vs/
.vs/*
/x64/*
/.vs/*
./x64/*
./.vs/*
./x64/*
/x64/*
*.ipch
*.db
*.pdb
*.tlog
*.log
*.pdb
*.db
*.tiff
*.tif
*.jpg
Temporary*/

View File

@ -0,0 +1,510 @@
#pragma once
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// 本地方法
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <omp.h>
#include "baseTool.h"
#include "simptsn.h"
#include "SateOrbit.h"
#include <gdal_utils.h>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
#include "ImageMatch.h"
#include <opencv2/core/eigen.hpp>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace Eigen;
using namespace cv;
/// <summary>
/// cpnvert gdal to jpg
/// </summary>
/// <param name="gdal_path"></param>
/// <param name="jpg_path"></param>
/// <param name="band_ids"></param>
/// <returns></returns>
int ImageMatch::gdal2JPG(std::string gdal_path, std::string jpg_path, int band_ids)
{
std::cout << "convert gdal to jpg , beigining : \t" << getCurrentTimeString() << endl;
gdalImage gdalimg(gdal_path);
cv::Mat img(gdalimg.height, gdalimg.width, CV_8U);
{
int start_ids = 0;
int line_invert = int(80000000 / gdalimg.width);
Eigen::MatrixXd temp(line_invert, gdalimg.width);
double min_value = 0, temp_min = 0;
double max_value = 0, temp_max = 0;
// 线性拉伸2%
Eigen::MatrixXd hist = gdalimg.getHist(band_ids);
int count = 0;
int sum_count = gdalimg.height * gdalimg.width;
int rows = hist.rows();
for (int i = 0; i < rows; i++) {
if ((count+ hist(i, 1)) / sum_count > 0.01) {
min_value = hist(i, 0);
break;
}
count = count + hist(i, 1);
}
count = 0;
for (int i = rows - 1; i >= 0; i--) {
if ((count + hist(i, 1)) / sum_count > 0.01) {
max_value = hist(i, 0);
break;
}
count = count + hist(i, 1);
}
// 重新缩放最大值,最小值
std::cout << "min value \t" << min_value << "\n";
std::cout << "max value \t" << max_value << "\n";
start_ids = 0;
do {
line_invert = line_invert + start_ids < gdalimg.height ? line_invert : gdalimg.height - start_ids;
temp = gdalimg.getData(start_ids, 0, line_invert, gdalimg.width, band_ids);
temp = (temp.array() - min_value) * 250 / (max_value - min_value);
for (int i = 0; i < line_invert; i++) {
for (int j = 0; j < gdalimg.width; j++) {
if (temp(i, j) < 0) { temp(i, j) = 0; }
if (temp(i, j) > 250) { temp(i, j) = 250; }
uchar tempvalue = uchar(temp(i, j));;
img.at<uchar>(i + start_ids, j) = tempvalue;
}
}
start_ids = start_ids + line_invert;
} while (start_ids < gdalimg.height);
cv::Mat result1(gdalimg.height, gdalimg.width, CV_8U);
result1 = img;
//bilateralFilter(img, result1, 10, 80, 50);
vector<int> compression_params;
compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); //选择jpeg
compression_params.push_back(100); //在这个填入你要的图片质量
cv::Mat out = result1;
//cv::resize(img, out, cv::Size(img.cols, img.rows), cv::INTER_AREA);
cv::imwrite(jpg_path, out, compression_params);
}
std::cout << "convert gdal to jpg , overing : \t" << getCurrentTimeString() << endl;
std::cout << "=========================================\n";
std::cout << " convert gdal to jpg :\n";
std::cout << "input gdal img file path \t" << gdal_path << "\n";
std::cout << "input gdal img band \t" << band_ids << "\n";
std::cout << "out jpg file path \t" << jpg_path << "\n";
std::cout << "=========================================\n";
return 0;
}
/// <summary>
/// 获取模型匹配点
/// </summary>
/// <param name="ori_power_path"></param>
/// <param name="sim_sum_path"></param>
/// <returns></returns>
Eigen::MatrixXd ImageMatch::ImageMatch_ori_sim(std::string ori_power_path, std::string sim_sum_path, int roughSize, int PreciseSize, int scale, int searchSize, int roughStep,int preciseStep)
{
std::cout << "match point between ori and sim , overing : \t" << getCurrentTimeString() << endl;
std::cout << "match parameters : \n";
std::cout << "rough match templet size : \t" << roughSize << endl;
std::cout << "Precise match templet size : \t" << PreciseSize << endl;
std::cout << "Precise match wait search size : \t" << searchSize << endl;
std::cout << "Precise match scale : \t" << scale << endl;
std::cout << "Precise match step : \t" << preciseStep << endl;
std::cout << "input ori image path : \t" << ori_power_path << endl;
std::cout << "input sim image path : \t" << sim_sum_path << endl;
//读取影像
cv::Mat ori = openJPG(ori_power_path);
cv::Mat sim = openJPG(sim_sum_path);
int sim_rows = sim.rows;
int sim_cols = sim.cols;
int BlockCount = 0;
for (int i = 0; i < sim_rows; i=i+ roughSize) {
for (int j = 0; j < sim_cols; j=j+ roughSize) {
if (i + 2 * roughSize < sim_rows && j + 2 * roughSize < sim_cols) {
BlockCount++;
}
}
}
Eigen::MatrixXd sim_block(BlockCount,3);
BlockCount = 0;
for (int i = 0; i < sim_rows; i = i + roughSize) {
for (int j = 0; j < sim_cols; j = j + roughSize) {
if (i + 2 * roughSize < sim_rows && j + 2 * roughSize < sim_cols) {
sim_block(BlockCount, 0) = i;
sim_block(BlockCount, 1) = j;
BlockCount++;
}
}
}
Eigen::MatrixXd Tempmatchpoints(BlockCount, 6);
Tempmatchpoints = Tempmatchpoints.array() * 0;
int count = 0;
#pragma omp parallel for num_threads(8)
for (int ii = 0; ii < BlockCount; ii++) {
int i = sim_block(ii, 0);
int j = sim_block(ii, 1);
cv::Mat templet_mat = sim(Rect(j, i, 2 * roughSize, 2 * roughSize));
cv::Scalar mean1;
cv::Mat stddevMat;
cv::meanStdDev(templet_mat, mean1, stddevMat);
double minvalue = 0;
double maxvalue = 0;
cv::minMaxLoc(templet_mat, &minvalue, &maxvalue, NULL, NULL);//用于检测矩阵中最大值和最小值的位置
double sig = (stddevMat.at<double>(0, 0)) / (maxvalue - minvalue);
if (sig >1) {
//continue;
}
// 构建搜索域
int search_i = i - 2 * searchSize >= 0 ? i - 2 * searchSize >= 0 : 0;
int search_j = j - 2 * searchSize >= 0 ? j - 2 * searchSize >= 0 : 0;
int len_i = search_i + 4 * searchSize;
int len_j = search_j + 4 * searchSize;
len_i = search_i + len_i < ori.rows ? len_i : ori.rows - search_i - 1;
len_j = search_j + len_j < ori.cols ? len_j : ori.rows - search_j - 1;
cv::Mat serch = ori(Rect(search_j, search_i, len_j, len_i));
// 检索
cv::Mat result;
matchTemplate(serch, templet_mat, result, cv::TM_CCOEFF_NORMED);
Point minLoc;
Point maxLoc;
Point matchLoc;
double tempminVal = 100, tempmaxVal = 0;
cv::minMaxLoc(result, &tempminVal, &tempmaxVal, &minLoc, &maxLoc);//用于检测矩阵中最大值和最小值的位置
double offset_j = maxLoc.x + search_j;
double offset_i = maxLoc.y + search_i;
//cv::Scalar mean1;
//cv::Mat stddevMat;
//cv::meanStdDev(templet_mat, mean1, stddevMat);
Tempmatchpoints(ii, 0) = double(j); //sim_x
Tempmatchpoints(ii, 1) = double(i); //sim_y
Tempmatchpoints(ii, 2) = offset_j; // sim_x
Tempmatchpoints(ii, 3) = offset_i; // sim_y
Tempmatchpoints(ii, 4) = tempmaxVal; // maxVal
Tempmatchpoints(ii, 5) = sig; // maxVal
std::cout << 100.0*count/ BlockCount<<"\t:\t"<< count << " / " << BlockCount<<"\t" << Tempmatchpoints(ii, 0) << "\t" << Tempmatchpoints(ii, 1) << "\t" << Tempmatchpoints(ii, 2)
<< "\t" << Tempmatchpoints(ii, 3) << "\t" << Tempmatchpoints(ii, 4) << "\t" << Tempmatchpoints(ii, 5) << endl;
count++;
}
//BlockCount = 0;
count = 0;
for (int ii = 0; ii < BlockCount; ii++) {
if (Tempmatchpoints(ii, 4) > 0.7) {
std::cout << Tempmatchpoints(ii, 0) << "\t" << Tempmatchpoints(ii, 1) << "\t" << Tempmatchpoints(ii, 2)
<< "\t" << Tempmatchpoints(ii, 3) << "\t" << Tempmatchpoints(ii, 4) << "\t" << Tempmatchpoints(ii, 5) << endl;
//BlockCount++;
count++;
}
}
Eigen::MatrixXd matchpoints(count, 5);
count = 0;
for (int ii = 0; ii < BlockCount; ii++) {
if (Tempmatchpoints(ii, 4) > 0.7) {
matchpoints(count, 0)=Tempmatchpoints(ii, 0); //sim_x
matchpoints(count, 1) = Tempmatchpoints(ii, 1); //sim_y
matchpoints(count, 2) = Tempmatchpoints(ii, 2);// sim_x
matchpoints(count, 3) = Tempmatchpoints(ii, 3);// sim_y
matchpoints(count, 4) = Tempmatchpoints(ii, 4); // maxVal
count++;
}
}
/*
// step 1: 粗匹配,分块均匀匹配
std::cout << "rough match , begining : \t" << getCurrentTimeString() << endl;
double offset_x = 0, offset_y = 0;
cv::Mat mask = sim;
cv::Mat temp_ori = ori;
int offsetcount = 0;
Eigen::MatrixXd matchpoints;
{
int row_count = ori.rows;
int col_count = ori.cols;
int count = 0;
for (int i = roughSize; i < row_count; i = i + roughSize + 500) { // y
for (int j = roughSize; j < col_count; j = j + roughSize + 200) { //x
count = count + 1;
}
}
matchpoints= Eigen::MatrixXd::Zero(count, 5);//ori_x,ori_y,sim_x,sim_y,maxval
double minVal = 100, maxVal = 0.7;
omp_lock_t lock;
std::cout << "ori_x\tori_y\tsim_x\tsim_y\tmaxval \t" << endl;
omp_init_lock(&lock); // 初始化互斥锁
count = 0;
int search_count = 0;
#pragma omp parallel for num_threads(8)
for (int i = roughSize; i < row_count; i = i + roughSize+ 500) { // y
double tempminVal = 100, tempmaxVal = 0;
cv::Mat templet_mat;
cv::Mat result;
for (int j = roughSize; j < col_count; j = j + roughSize+ 200) { //x
templet_mat = ori(Rect(j - roughSize, i - roughSize, roughSize, roughSize));
matchTemplate(sim, templet_mat, result, cv::TM_CCOEFF_NORMED);
//normalize(result, result, 1, 0, cv::NORM_MINMAX);
// 通过函数 minMaxLoc 定位最匹配的位置;
omp_set_lock(&lock); //获得互斥器
Point minLoc;
Point maxLoc;
Point matchLoc;
cv::minMaxLoc(result, &tempminVal, &tempmaxVal, &minLoc, &maxLoc);//用于检测矩阵中最大值和最小值的位置
if (tempmaxVal >= maxVal) {
offset_x = maxLoc.x - (j - roughSize);
offset_y = maxLoc.y - (i - roughSize);
//maxVal = tempmaxVal;
matchpoints(count, 0) = (j - roughSize); //ori_x
matchpoints(count, 1) = (i - roughSize); //ori_y
double temp= maxLoc.x;
matchpoints(count, 2) = temp; // sim_x
temp = maxLoc.y;
matchpoints(count, 3) = temp; // sim_y
matchpoints(count, 4) = tempmaxVal; // maxVal
count = count + 1;
offsetcount += 1;
}
search_count = search_count + 1;
std::cout << j - roughSize << "\t" << i - roughSize << "\t" << maxLoc.x << "\t" << maxLoc.y << "\t" << tempmaxVal << "\t" << search_count << "\t" << matchpoints.rows() << endl;
omp_unset_lock(&lock); //释放互斥器
}
}
omp_destroy_lock(&lock); //销毁互斥器
offset_x = offset_x*1.0 / offsetcount;
offset_y = offset_y * 1.0 / offsetcount;
std::cout << "rough match point : "<< offsetcount <<"\n" << endl;
std::cout << "offset X : \t" << offset_x << endl;
std::cout << "offset Y : \t" << offset_y << endl;
std::cout << "maxVal : \t" << maxVal << endl;
}
std::cout << "rough match out : \t" << getCurrentTimeString() << endl;
// step1.1: 粗匹配绘制结果
std::string rough_math_path = sim_sum_path;
boost::algorithm::replace_last(rough_math_path, ".", "_ori_in_sim.");
std::cout << "ori in sim :\t" << rough_math_path << endl;
cv::Mat ori_in_sim = sim;
cv::rectangle(ori_in_sim, cv::Point(offset_x, offset_y), Point(offset_x + ori.cols, offset_y + ori.rows), Scalar(0, 255, 0), 2, 8, 0);
vector<int> compression_params;
compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); //选择jpeg
compression_params.push_back(100); //在这个填入你要的图片质量
cv::Mat out = ori_in_sim;
cv::imwrite(rough_math_path, out, compression_params);
if (offsetcount == 0) { // 表示全局粗匹配失败,无法进行精校准,考虑直接定位法
std::cout << "there are not effective point in rought match \t" << endl;
return Eigen::MatrixXd(0, 5);
}
Eigen::MatrixXd matchpointstemp(offsetcount,5);
for (int i = 0; i < matchpoints.rows(); i++) {
if (matchpoints(i, 4) > 0.7) {
for (int j = 0; j < matchpoints.cols(); j++) {
matchpointstemp(i, j) = matchpoints(i, j);
}
}
}
matchpoints = matchpointstemp;
*/
//std::cout << "rough match , overing : \t" << getCurrentTimeString() << endl;
//// step 2: 精匹配,
//std::cout << "Precise match , begining : \t" << getCurrentTimeString() << endl;
//Eigen::MatrixXd matchpoints;
//{
// int row_count = ori.rows;
// int col_count = ori.cols;
// int count = 0;
// for (int i = PreciseSize; i < row_count; i = i + preciseStep) { // y
// for (int j = PreciseSize; j < col_count; j = j + preciseStep) { //x
// count = count + 1;
// }
// }
// matchpoints(count, 5);//ori_x,ori_y,sim_x,sim_y,maxval
// double templeta_size = PreciseSize * scale;
// double search_size = searchSize * scale;
// count = 0;
// double ori_start_x, ori_start_y;
// double sim_start_x, sim_start_y;
// row_count = row_count - PreciseSize;
// col_count = col_count - PreciseSize;
// omp_lock_t lock;
// omp_init_lock(&lock); // 初始化互斥锁
// // 以搜索范围为核心计算
// #pragma omp parallel for num_threads(8)
// for (int i = searchSize + offset_y; i < row_count; i = i + preciseStep) { // y
// cv::Mat templet_mat;
// cv::Mat search_mat;
// cv::Mat resample_templet_mat;
// cv::Mat resample_search_mat;
// cv::Mat result;
// double minVal = 100, maxVal = 0;
// for (int j = searchSize + offset_x; j < col_count; j = j + preciseStep) { //x
// // 计算 起始点
// sim_start_x = j - searchSize;
// sim_start_y = i - searchSize;
// ori_start_x = (j - searchSize / 2) - PreciseSize / 2;
// ori_start_y = (i - searchSize / 2) - PreciseSize / 2;
// // 匹配模板,待匹配模板
// templet_mat = ori(Rect(ori_start_x, ori_start_y, PreciseSize, PreciseSize));
// search_mat = ori(Rect(sim_start_x, sim_start_y, searchSize, searchSize));
// resample_templet_mat = resampledMat(templet_mat, templeta_size);
// resample_search_mat = resampledMat(search_mat, search_size);
// matchTemplate(sim, templet_mat, result, cv::TM_CCORR_NORMED);
// // 通过函数 minMaxLoc 定位最匹配的位置;
// cv::Point minLoc; cv::Point maxLoc;
// cv::Point matchLoc;
// cv::minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc);//用于检测矩阵中最大值和最小值的位置
// if (maxVal > 0.7) {
// omp_set_lock(&lock); //获得互斥器
//
// matchpoints(count, 0) = ori_start_x; //ori_x
// matchpoints(count, 1) = ori_start_y; //ori_y
// matchpoints(count, 2) = sim_start_x + maxLoc.x * 1.0 / scale; // sim_x
// matchpoints(count, 3) = sim_start_y + maxLoc.y * 1.0 / scale; // sim_y
// matchpoints(count, 4) = maxVal; // maxVal
// count = count + 1;
//
// omp_unset_lock(&lock); //释放互斥器
// }
// }
// }
// omp_destroy_lock(&lock); //销毁互斥器
//}
//
std::cout << "Precise match , ending : \t" << getCurrentTimeString() << endl;
std::cout << "=======================================================================" << endl;
std::cout << "match point result: \t" << getCurrentTimeString() << endl;
std::cout << "=======================================================================" << endl;
{
std::cout << "ori_x\tori_y\tsim_x\tsim_y\tmaxval \t" << endl;
int count = matchpoints.rows();
for (int i = 0; i < count; i++) {
std::cout << matchpoints(i, 0) << "\t" << matchpoints(i, 1) << "\t" << matchpoints(i, 2) << "\t" << matchpoints(i, 3) << "\t" << matchpoints(i, 4) << endl;
}
}
std::cout << "=======================================================================" << endl;
return matchpoints;
}
Eigen::MatrixXd ImageMatch::CreateMatchModel(Eigen::MatrixXd offsetXY_matrix)
{
// ori_x,oir_y,to_x,to_y,maxval
// 0 1 2 3 4
Eigen::MatrixXd offset_x= offsetXY_matrix.col(2) - offsetXY_matrix.col(0);
Eigen::MatrixXd offset_y = offsetXY_matrix.col(3) - offsetXY_matrix.col(1);
// 计算最小二乘法模型
Eigen::MatrixXd temp(offset_x.rows(), 6);
temp.col(0) = temp.col(0).array()*0+1; //1
temp.col(1) = offsetXY_matrix.col(3).array(); // r
temp.col(2) = offsetXY_matrix.col(2).array(); // c
temp.col(3) = offsetXY_matrix.col(3).array().pow(2);//r2
temp.col(4) = offsetXY_matrix.col(2).array().pow(2);//c2
temp.col(5) = offsetXY_matrix.col(2).array()* offsetXY_matrix.col(3).array();//r*c
Eigen::MatrixXd matchmodel(2, 6);
Eigen::MatrixXd tempx= temp.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(offset_x);//x c
Eigen::MatrixXd tempy = temp.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(offset_y);//y r
matchmodel.row(1) = tempx;
matchmodel.row(0) = tempy;
return matchmodel;
}
Eigen::MatrixXd ImageMatch::correctMatchModel(Eigen::MatrixXd r, Eigen::MatrixXd c)
{
Eigen::MatrixXd a0 = Eigen::MatrixXd::Ones(1,r.cols());
Eigen::MatrixXd a1 = r.array();
Eigen::MatrixXd a2 = c.array();
Eigen::MatrixXd a3 = r.array().pow(2);
Eigen::MatrixXd a4 = c.array().pow(2);
Eigen::MatrixXd a5 = r.array() * c.array();
Eigen::MatrixXd offset(2, r.cols());//r,c
offset.row(0) = r.array() + this->match_model(0, 0) * a0.array() + this->match_model(0, 1) * a1.array() + this->match_model(0, 2) * a2.array() + this->match_model(0, 3) * a3.array() + this->match_model(0, 4) * a4.array() + this->match_model(0, 5) * a5.array();
offset.row(1) = c.array() + this->match_model(1, 0) * a0.array() + this->match_model(1, 1) * a1.array() + this->match_model(1, 2) * a2.array() + this->match_model(1, 3) * a3.array() + this->match_model(1, 4) * a4.array() + this->match_model(1, 5) * a5.array();
return offset;
}
int ImageMatch::outMatchModel(std::string matchmodel_path)
{
ofstream fout(matchmodel_path, ios::trunc);
fout << "model:" << endl;
fout << this->match_model(0, 0) << " " << this->match_model(0, 1) << " " << this->match_model(0, 2) << " " << this->match_model(0, 3) << " " << this->match_model(0, 4) << " " << this->match_model(0, 5) << endl;
fout << this->match_model(1, 0) << " " << this->match_model(1, 1) << " " << this->match_model(1, 2) << " " << this->match_model(1, 3) << " " << this->match_model(1, 4) << " " << this->match_model(1, 5) << endl;
fout << "model_points:" << endl;
std::cout << "ori_x\tori_y\tsim_x\tsim_y\tmaxval \t" << endl;
int count = this->offsetXY_matrix.rows();
for (int i = 0; i < count; i++) {
std::cout << this->offsetXY_matrix(i, 0) << "\t" << this->offsetXY_matrix(i, 1) << "\t" << this->offsetXY_matrix(i, 2) << "\t" << this->offsetXY_matrix(i, 3) << "\t" << this->offsetXY_matrix(i, 4) << endl;
}
fout.close();
return 0;
}
/// <summary>
/// 读取jpg 文件
/// </summary>
/// <param name="jpg_path"></param>
/// <returns></returns>
cv::Mat openJPG(std::string jpg_path)
{
cv::Mat image = cv::imread(jpg_path);
if (image.data == nullptr) //nullptr是c++11新出现的空指针常量
{
throw new exception("图片文件不存在");
}
return image;
}
cv::Mat resampledMat(cv::Mat& image, int targetSize, int interpolation)
{
cv::Mat out;
cv::resize(image, out, cv::Size(targetSize, targetSize), interpolation);
return out;
}

View File

@ -0,0 +1,39 @@
#pragma once
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// ±¾µØ·½·¨
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <boost/filesystem.hpp>
#include <omp.h>
#include "baseTool.h"
#include "simptsn.h"
#include "SateOrbit.h"
#include <gdal_utils.h>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
using namespace std;
using namespace Eigen;
class ImageMatch
{
public:
int gdal2JPG(std::string gdal_path,std::string jpg_path,int band_ids);
Eigen::MatrixXd ImageMatch_ori_sim(std::string ori_power_path, std::string sim_sum_path, int roughSize=500, int Precise=300,int scale=5, int searchSize=1000,int roughStep=400 ,int preciseStep=300);
Eigen::MatrixXd CreateMatchModel(Eigen::MatrixXd offsetXY_matrix);
Eigen::MatrixXd correctMatchModel(Eigen::MatrixXd r, Eigen::MatrixXd c);
int outMatchModel(std::string matchmodel_path);
//²ÎÊý
Eigen::MatrixXd offsetXY_matrix;
Eigen::MatrixXd match_model;
};
cv::Mat openJPG(std::string jpg_path);
cv::Mat resampledMat(cv::Mat& templet, int targetSize, int interpolation = cv::INTER_AREA);

View File

@ -0,0 +1 @@
#include "OctreeNode.h"

View File

@ -0,0 +1,264 @@
#pragma once
#include <iostream>
using namespace std;
//定义八叉树节点类
template<class T>
struct OctreeNode
{
T data; //节点数据
T xmin, xmax; //节点坐标,即六面体个顶点的坐标
T ymin, ymax;
T zmin, zmax;
OctreeNode <T>* top_left_front, * top_left_back; //该节点的个子结点
OctreeNode <T>* top_right_front, * top_right_back;
OctreeNode <T>* bottom_left_front, * bottom_left_back;
OctreeNode <T>* bottom_right_front, * bottom_right_back;
OctreeNode //节点类
(T nodeValue = T(),
T xminValue = T(), T xmaxValue = T(),
T yminValue = T(), T ymaxValue = T(),
T zminValue = T(), T zmaxValue = T(),
OctreeNode<T>* top_left_front_Node = NULL,
OctreeNode<T>* top_left_back_Node = NULL,
OctreeNode<T>* top_right_front_Node = NULL,
OctreeNode<T>* top_right_back_Node = NULL,
OctreeNode<T>* bottom_left_front_Node = NULL,
OctreeNode<T>* bottom_left_back_Node = NULL,
OctreeNode<T>* bottom_right_front_Node = NULL,
OctreeNode<T>* bottom_right_back_Node = NULL)
:data(nodeValue),
xmin(xminValue), xmax(xmaxValue),
ymin(yminValue), ymax(ymaxValue),
zmin(zminValue), zmax(zmaxValue),
top_left_front(top_left_front_Node),
top_left_back(top_left_back_Node),
top_right_front(top_right_front_Node),
top_right_back(top_right_back_Node),
bottom_left_front(bottom_left_front_Node),
bottom_left_back(bottom_left_back_Node),
bottom_right_front(bottom_right_front_Node),
bottom_right_back(bottom_right_back_Node) {}
};
//创建八叉树
template <class T>
void createOctree(OctreeNode<T>*& root, int maxdepth, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
{
//cout<<"处理中,请稍候……"<<endl;
maxdepth = maxdepth - 1; //每递归一次就将最大递归深度-1
if (maxdepth >= 0)
{
root = new OctreeNode<T>();
//cout << "请输入节点值:";
//root->data =9;//为节点赋值可以存储节点信息如物体可见性。由于是简单实现八叉树功能简单赋值为9。
cin >> root->data; //为节点赋值
root->xmin = xmin; //为节点坐标赋值
root->xmax = xmax;
root->ymin = ymin;
root->ymax = ymax;
root->zmin = zmin;
root->zmax = zmax;
double xm = (xmax - xmin) / 2;//计算节点个维度上的半边长
double ym = (ymax - ymin) / 2;
double zm = (ymax - ymin) / 2;
//递归创建子树,根据每一个节点所处(是几号节点)的位置决定其子结点的坐标。
createOctree(root->top_left_front, maxdepth, xmin, xmax - xm, ymax - ym, ymax, zmax - zm, zmax);
createOctree(root->top_left_back, maxdepth, xmin, xmax - xm, ymin, ymax - ym, zmax - zm, zmax);
createOctree(root->top_right_front, maxdepth, xmax - xm, xmax, ymax - ym, ymax, zmax - zm, zmax);
createOctree(root->top_right_back, maxdepth, xmax - xm, xmax, ymin, ymax - ym, zmax - zm, zmax);
createOctree(root->bottom_left_front, maxdepth, xmin, xmax - xm, ymax - ym, ymax, zmin, zmax - zm);
createOctree(root->bottom_left_back, maxdepth, xmin, xmax - xm, ymin, ymax - ym, zmin, zmax - zm);
createOctree(root->bottom_right_front, maxdepth, xmax - xm, xmax, ymax - ym, ymax, zmin, zmax - zm);
createOctree(root->bottom_right_back, maxdepth, xmax - xm, xmax, ymin, ymax - ym, zmin, zmax - zm);
}
}
int i = 1;
//先序遍历八叉树
template <class T>
void preOrder(OctreeNode<T>*& p)
{
if (p)
{
//cout << i << ".当前节点的值为:" << p->data << "\n坐标为";
//cout << "xmin: " << p->xmin << " xmax: " << p->xmax;
//cout << "ymin: " << p->ymin << " ymax: " << p->ymax;
//cout << "zmin: " << p->zmin << " zmax: " << p->zmax;
i += 1;
cout << endl;
preOrder(p->top_left_front);
preOrder(p->top_left_back);
preOrder(p->top_right_front);
preOrder(p->top_right_back);
preOrder(p->bottom_left_front);
preOrder(p->bottom_left_back);
preOrder(p->bottom_right_front);
preOrder(p->bottom_right_back);
cout << endl;
}
}
//求八叉树的深度
template<class T>
int depth(OctreeNode<T>*& p)
{
if (p == NULL)
return -1;
int h = depth(p->top_left_front);
return h + 1;
}
template<class T>
int num(OctreeNode<T>*& p)
{
if (p == NULL)
return 0;
return 1 + num(p->top_left_front) + num(p->top_left_back) + num(p->top_right_back) + num(p->top_right_front) + num(p->bottom_left_back) + num(p->bottom_left_front) + num(p->bottom_right_back) + num(p->bottom_right_front);
}
//计算单位长度,为查找点做准备
int cal(int num)
{
int result = 1;
if (1 == num)
result = 1;
else
{
for (int i = 1; i < num; i++)
result = 2 * result;
}
return result;
}
template<class T>
int find(OctreeNode<T>*& p, double x, double y, double z)
{
//查找点
int maxdepth = 0;
int times = 0;
static double xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0;
int tmaxdepth = 0;
double txm = 1, tym = 1, tzm = 1;
double xm = (p->xmax - p->xmin) / 2;
double ym = (p->ymax - p->ymin) / 2;
double zm = (p->ymax - p->ymin) / 2;
times++;
if (x > xmax || x<xmin || y>ymax || y<ymin || z>zmax || z < zmin)
{
//cout << "该点不在场景中!" << endl;
return 0;
}
if (x <= p->xmin + txm && x >= p->xmax - txm && y <= p->ymin + tym && y >= p->ymax - tym && z <= p->zmin + tzm && z >= p->zmax - tzm)
{
//cout << endl << "找到该点!" << "该点位于" << endl;
//cout << "xmin: " << p->xmin << " xmax: " << p->xmax;
//cout << "ymin: " << p->ymin << " ymax: " << p->ymax;
//cout << "zmin: " << p->zmin << " zmax: " << p->zmax;
//cout << "节点内!" << endl;
//cout << "共经过" << times << "次递归!" << endl;
return 1;
}
else if (x < (p->xmax - xm) && y < (p->ymax - ym) && z < (p->zmax - zm))
{
find(p->bottom_left_back, x, y, z);
}
else if (x < (p->xmax - xm) && y<(p->ymax - ym) && z>(p->zmax - zm))
{
find(p->top_left_back, x, y, z);
}
else if (x > (p->xmax - xm) && y < (p->ymax - ym) && z < (p->zmax - zm))
{
find(p->bottom_right_back, x, y, z);
}
else if (x > (p->xmax - xm) && y<(p->ymax - ym) && z>(p->zmax - zm))
{
find(p->top_right_back, x, y, z);
}
else if (x<(p->xmax - xm) && y>(p->ymax - ym) && z < (p->zmax - zm))
{
find(p->bottom_left_front, x, y, z);
}
else if (x<(p->xmax - xm) && y>(p->ymax - ym) && z > (p->zmax - zm))
{
find(p->top_left_front, x, y, z);
}
else if (x > (p->xmax - xm) && y > (p->ymax - ym) && z < (p->zmax - zm))
{
find(p->bottom_right_front, x, y, z);
}
else if (x > (p->xmax - xm) && y > (p->ymax - ym) && z > (p->zmax - zm))
{
find(p->top_right_front, x, y, z);
}
}
//main函数
/*
int main()
{
OctreeNode<double>* rootNode = NULL;
int choiced = 0;
cout << "系统开始前请先创建八叉树" << endl;
cout << "请输入最大递归深度:" << endl;
cin >> maxdepth;
cout << "请输入外包盒坐标顺序如下xmin,xmax,ymin,ymax,zmin,zmax" << endl;
cin >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax;
if (maxdepth >= 0 || xmax > xmin || ymax > ymin || zmax > zmin || xmin > 0 || ymin > 0 || zmin > 0)
{
tmaxdepth = cal(maxdepth);
txm = (xmax - xmin) / tmaxdepth;
tym = (ymax - ymin) / tmaxdepth;
tzm = (zmax - zmin) / tmaxdepth;
createOctree(rootNode, maxdepth, xmin, xmax, ymin, ymax, zmin, zmax);
}
while (true)
{
system("cls");
cout << "请选择操作:\n";
cout << "\t1.计算空间中区域的个数\n";
cout << "\t2.先序遍历八叉树\n";
cout << "\t3.查看树深度\n";
cout << "\t4.查找节点 \n";
cout << "\t0.退出\n";
cin >> choiced;
if (choiced == 0)
return 0;
if (choiced == 1)
{
system("cls");
cout << "空间区域个数" << endl;
cout << num(rootNode);
}
if (choiced == 2)
{
system("cls");
cout << "先序遍历八叉树结果:/n";
i = 1;
preOrder(rootNode);
cout << endl;
system("pause");
}
if (choiced == 3)
{
system("cls");
int dep = depth(rootNode);
cout << "此八叉树的深度为" << dep + 1 << endl;
system("pause");
}
if (choiced == 4)
{
system("cls");
cout << "请输入您希望查找的点的坐标顺序如下x,y,z\n";
double x, y, z;
cin >> x >> y >> z;
times = 0;
cout << endl << "开始搜寻该点……" << endl;
find(rootNode, x, y, z);
system("pause");
}
else
{
system("cls");
cout << "\n\n错误选择!\n";
system("pause");
}
}
*/

View File

@ -0,0 +1,49 @@
// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <armadillo>
//using namespace arma;
using namespace std;
using namespace Eigen;
int main(int argc, char* argv[])
{
cout << cos(30) << endl;
cout << cos(45) << endl;
cout << cos(60) << endl;
cout << pow(1, 3) << endl;
cout << pow(2, 3) << endl;
Eigen::MatrixXd a = Eigen::MatrixXd::Ones(6, 3); // 随机初始化矩阵
Eigen::MatrixXd b = Eigen::MatrixXd::Ones(6,3).array()*2;
Eigen::Vector3d p(3, 1, 2);
double start = clock();
Eigen::MatrixXd c = (a.array()/b.array());// .rowwise().sum();
double endd = clock();
double thisTime = (double)(endd - start) / CLOCKS_PER_SEC;
cout << thisTime << endl;
cout << c.rows() << "," << c.cols() << endl;
cout << c(Eigen::all, { 0,1}) << endl;
system("PAUSE");
return 0;
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{db6d05f9-271e-4954-98ed-591ab27bb05e}</ProjectGuid>
<RootNamespace>ConsoleApplication1</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>Parallel</UseInteloneMKL>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\lib\release;C:\Program Files %28x86%29\Intel\oneAPI\compiler\2022.1.0\windows\compiler\lib\intel64_win;C:\Program Files %28x86%29\Intel\oneAPI\mkl\2022.1.0\lib\intel64;$(oneMKLOmpLibDir);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>mkl_scalapack_ilp64.lib;mkl_cdft_core.lib;mkl_intel_ilp64.lib;mkl_sequential.lib;mkl_core.lib;mkl_blacs_intelmpi_ilp64.lib;impi.lib;mkl_intel_thread.lib;libiomp5md.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ConsoleApplication1.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ConsoleApplication1.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@ -0,0 +1,191 @@
// PSTM_simulation_windows.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include <vector>
#include <memory>
#include <medparam.h>
#include <malloc.h>
#include <string>
#include "ParameterInFile.h"
#include <time.h>  
#include <crtdbg.h>
//
// 引用变量的空间
//
using namespace std;
int test(ParameterInFile parmas) {
cout << parmas.doppler_para[0] << endl;
return 0;
}
/// <summary>
/// 检查环境,主要检查内存情况
/// </summary>
/// <param name="parmas"></param>
/// <returns></returns>
bool check(ParameterInFile& parmas) {
return true;
}
sim_block testsimblock(int a = 1) {
sim_block result(1, 2, 1, 2, 1, 1);
return result;
}
int Fmaintest() {
sim_block temp = testsimblock(1);
point lla = point{ 110,22,33 };
point xyz = point{ -2023567.6297546995,5559706.3694903487,2374425.2573203994 };
point ttxyz = LLA2XYZ(lla);
point ttlla = XYZ2LLA(xyz);
VectorPoint v1 = getVector(xyz, ttxyz);
VectorPoint v2 = getVector(lla, ttlla);
cout << getModule(v1) << std::endl;
cout << getModule(v2) << std::endl;
return 0;
}
int main(int argc, char* argv[])
{
// try {
testPP();
std::cout << "PSTM_simulation_windows.exe [mode] [pars_path] [resample_para] [--thead_num]" << endl;// 输出帮助文档
std::cout << "[mode]: 调用模块 0,1,2 " << endl;
std::cout << " 0:默认路径 " << endl;
std::cout << " 1:计算正射模拟图 " << endl;
std::cout << " 2:计算正射校正插值算法与强度图生成 " << endl;
std::cout << "[para_path]:必选 正射模拟参数文件 " << endl;
std::cout << "[resample_para]:当mode==2时必选 计算正射校正插值算法与强度图生成参数文件 " << endl;
std::cout << "[--thead_num]:可选 线程数默认是8" << endl;
std::cout << "example:" << endl;
std::cout << "PSTM_simulation_windows.exe 2 C:\\sim_sar_paras.txt D:\\resample_para.txt --thead_num 8" << endl;
int mode = -1;
int thread_num = 6;
std::string pars_path = ""; //配置文件代码
std::string resample_para = "";
std::string thread_str = "--thead_num";
try {
if (argc < 3) {
std::cout << "缺少参数" << endl;
//return 0;
}
for (int i = 1; i < argc; i++) {
if (i == 1) {
mode = stoi(argv[1]);
if (mode == 0) {
pars_path = "D:\\otherSoftware\\Ortho\\Ortho\\ortho_indirect\\datafolder\\testworkspace4\\sim_sar_paras.txt";
resample_para = "D:\\otherSoftware\\Ortho\\Ortho\\ortho_indirect\\datafolder\\testworkspace4\\resample_para.txt";
mode = 2;
break;
}
}
if (i == 2) {
pars_path= argv[2];
}
if (i == 3) {
if (mode == 1) {
break;
}
else {
resample_para = argv[3];
}
}
}
for (int i = 1; i < argc; i++) {
std::string temp = argv[i];
if (temp== thread_str) {
i = i + 1;
if (i >= argc) { break; }
else {
thread_num = stoi(argv[i]);
}
}
}
}
catch(exception ex) {
std::cout << "参数解析错误" << endl;
// 开始test模式
return -1;
}
if (1) {
pars_path = "D:\\MicroWorkspace\\C-SAR\\Ortho\\Temporary\\sim_sar_paras.txt";
resample_para = "";// "D:\\otherSoftware\\Ortho\\Ortho\\ortho_indirect\\datafolder\\testworkspace\\resample_para.txt";
mode = 1;
}
std::cout << "线程数:" << thread_num << endl;
//Fmaintest();
cout << mode << "\n";
int d=round(3.13);
if (mode == 1) {
cout << "sim_sar program run....\n";
cout << pars_path << "\n";
ParameterInFile parmas(pars_path);
//testPTSN(parmas);
if (!check(parmas)) {
throw "不符合运行条件";
return 0;
}
//SimProcess(parmas, 32);
SimProcess_LVY(parmas, thread_num);
// ResamplingSim(parmas);
// 检查解析结果
cout << "programover" << "\n";
}
else if (mode == 2) {
try {
ConvertResampleParameter converPara(resample_para);
ParameterInFile parmas(pars_path);
testPTSN(pars_path);
SimProcess_Calsim2ori(parmas, converPara, thread_num);
SimProcess_ResamplingOri2Orth(parmas, converPara, thread_num);
SimProcess_Calspow(parmas, converPara, thread_num);
}
catch(exception& ex) {
std::cout << ex.what() << std::endl;
return -1;
}
//SimProcess_CalXYZ(parmas, converPara,16);
//ConverOri2Sim(parmas, converPara);
//CalCoondinaryXYZOfSAR(parmas, converPara);
}
// }
//catch (exception ex) {
// 防止内存泄露,保证内存能够被调用
// throw "error";
// }
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

View File

@ -0,0 +1,41 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32602.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PSTM_simulation_windows", "PSTM_simulation_windows.vcxproj", "{418EA1F3-8583-4728-ABC4-45B98FC053BF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication1", "..\ConsoleApplication1\ConsoleApplication1.vcxproj", "{DB6D05F9-271E-4954-98ED-591AB27BB05E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Debug|x64.ActiveCfg = Debug|x64
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Debug|x64.Build.0 = Debug|x64
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Debug|x86.ActiveCfg = Debug|Win32
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Debug|x86.Build.0 = Debug|Win32
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Release|x64.ActiveCfg = Release|x64
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Release|x64.Build.0 = Release|x64
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Release|x86.ActiveCfg = Release|Win32
{418EA1F3-8583-4728-ABC4-45B98FC053BF}.Release|x86.Build.0 = Release|Win32
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Debug|x64.ActiveCfg = Debug|x64
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Debug|x64.Build.0 = Debug|x64
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Debug|x86.ActiveCfg = Debug|Win32
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Debug|x86.Build.0 = Debug|Win32
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Release|x64.ActiveCfg = Release|x64
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Release|x64.Build.0 = Release|x64
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Release|x86.ActiveCfg = Release|Win32
{DB6D05F9-271E-4954-98ED-591AB27BB05E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C2C843D5-F54A-4745-908B-8387B47D60A3}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{418ea1f3-8583-4728-abc4-45b98fc053bf}</ProjectGuid>
<RootNamespace>PSTMsimulationwindows</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>No</UseInteloneMKL>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>Parallel</UseInteloneMKL>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExternalIncludePath>$(ExternalIncludePath)</ExternalIncludePath>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExternalIncludePath>$(ExternalIncludePath)</ExternalIncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<OpenMPSupport>true</OpenMPSupport>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="common.cpp" />
<ClCompile Include="ParameterInFile.cpp" />
<ClCompile Include="PSTM_simulation_windows.cpp" />
<ClCompile Include="taskprocess.cpp" />
<ClCompile Include="threadpool.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="common.h" />
<ClInclude Include="ParameterInFile.h" />
<ClInclude Include="taskprocess.h" />
<ClInclude Include="threadpool.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,576 @@
#pragma once
#include <iostream>
#include <memory>
#include <vector>
#include <future>
#include <complex>
#include "gdalwarper.h"
#define PI_180 180/3.141592653589793238462643383279;
#define T180_PI 3.141592653589793238462643383279/180;
#define Radians2Degrees(Radians) Radians*PI_180
#define Degrees2Radians(Degrees) Degrees*T180_PI
const long double PI=3.141592653589793238462643383279;
const long double epsilon = 0.000000000000001;
const long double pi = 3.14159265358979323846;
const long double d2r = pi / 180;
const long double r2d = 180 / pi;
const long double a = 6378137.0; //椭球长半轴
const long double f_inverse = 298.257223563; //扁率倒数
const long double b = a - a / f_inverse;
const long double e = sqrt(a * a - b * b) / a;
const long double eSquare = e*e;
int testPP();
using namespace std;
///
/// 内敛函数
///
struct point // 点 SAR影像的像素坐标
{
long double x; // 纬度 lat pixel_row
long double y; // 经度 lon pixel_col
long double z; // 高程 ati pixel_time
};
struct VectorPoint {
long double x;
long double y;
long double z;
};
/// <summary>
/// 将经纬度转换为地固参心坐标系
/// </summary>
/// <param name="XYZP">经纬度点--degree</param>
/// <returns>投影坐标系点</returns>
inline point LLA2XYZ(point& LLA) {
long double L = LLA.x * d2r;
long double B = LLA.y * d2r;
long double H = LLA.z;
long double sinB = sin(B);
long double cosB = cos(B);
//long double N = a / sqrt(1 - e * e * sin(B) * sin(B));
long double N = a / sqrt(1 - eSquare * sinB * sinB);
point result = { 0,0,0 };
result.x = (N + H) * cosB * cos(L);
result.y = (N + H) * cosB * sin(L);
//result.z = (N * (1 - e * e) + H) * sin(B);
result.z = (N * (1 - eSquare) + H) * sinB;
return result;
}
/// <summary>
/// 将地固参心坐标系转换为经纬度
/// </summary>
/// <param name="XYZ">固参心坐标系</param>
/// <returns>经纬度--degree</returns>
point XYZ2LLA(point& XYZ);
/// <summary>
/// 计算两个点之间的XY平面欧式距离的平方
/// </summary>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <returns></returns>
inline long double caldistanceXY(point& p1, point& p2) {
//return pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2);
return (p1.x - p2.x)* (p1.x - p2.x) + (p1.y - p2.y)* (p1.y - p2.y);
}
/// <summary>
/// 使用两个点,生成向量 p1-->p2
/// </summary>
/// <param name="p1">p1</param>
/// <param name="p2">p2</param>
/// <returns>向量</returns>
inline VectorPoint getVector(point& p1, point& p2) {
VectorPoint result = { 0,0,0 };
result.x = p2.x - p1.x;
result.y = p2.y - p1.y;
result.z = p2.z - p1.z;
return result;
}
/// <summary>
/// 获取向量的模
/// </summary>
/// <param name="vector1">向量</param>
/// <returns>向量模</returns>
inline long double getModule(VectorPoint& vector1) {
//return sqrt(pow(vector1.x, 2) + pow(vector1.y, 2) + pow(vector1.z, 2));
return sqrt(vector1.x* vector1.x + vector1.y* vector1.y + vector1.z* vector1.z);
}
inline long double getModuleV1V2(VectorPoint& v1, VectorPoint& v2)
{
return sqrt((v1.x * v1.x + v1.y * v1.y + v1.z * v1.z) * (v2.x * v2.x + v2.y * v2.y + v2.z * v2.z));
}
/// <summary>
/// 向量夹角的角度( 角度)
/// </summary>
/// <param name="vector1">向量</param>
/// <returns>向量夹角的角度</returns>
inline long double getVectorAngle(VectorPoint& vector1,VectorPoint& vector2) {
//return Radians2Degrees( acos((vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z) / (getModule(vector1) * getModule(vector2))));
return Radians2Degrees(acos((vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z) / (getModuleV1V2(vector1, vector2))));
}
/// <summary>
/// 向量的夹角值
/// </summary>
/// <param name="vector1">向量</param>
/// <returns>向量夹角的角度</returns>
inline long double getVectorAngleValue(VectorPoint& vector1, VectorPoint& vector2) {
//return (vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z) / (getModule(vector1) * getModule(vector2));
return (vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z) / (getModuleV1V2(vector1, vector2));
}
/// <summary>
/// 向量点乘
/// </summary>
/// <param name="V1">向量1</param>
/// <param name="v2">向量2</param>
/// <returns>点乘值</returns>
inline long double Vectordot(VectorPoint& V1, VectorPoint& v2) {
return V1.x * v2.x + V1.y * v2.y + V1.z * v2.z;
}
/// <summary>
/// 向量点乘
/// </summary>
/// <param name="V1">向量1</param>
/// <param name="lamda">系数值</param>
/// <returns>向量与数之间的插值</returns>
inline VectorPoint VectordotNumber(VectorPoint& V1, long double lamda) {
V1.x = V1.x * lamda;
V1.y = V1.y * lamda;
V1.z = V1.z * lamda;
return V1;
}
/// <summary>
/// 向量叉乘
/// 旋转方向v1->v2
/// </summary>
/// <param name="v1">v1</param>
/// <param name="v2">v2</param>
/// <returns>叉乘的结果向量</returns>
inline VectorPoint VectorFork(VectorPoint &v1, VectorPoint& v2) {
VectorPoint result{ 0,0,0 };
result.x = v1.y * v2.z - v1.z * v2.y;
result.y =v1.z*v2.x -v1.x * v2.z;
result.z = v1.x * v2.y - v1.y * v2.x;
return result;
}
//
// 参数文件解析
//
//参数文件标准格式
// 文件值 类型 对应的代号
// DEM文件的路径 str dem_path
// 模拟影像输出路径 str sar_sim_path
// 模拟影像的宽 int
// 模拟影像的高 int
// 模拟影像的匹配坐标文件输出路径 str sar_sim_match_point_x_path
// 模拟影像的匹配坐标X输出路径 str sar_sim_match_point_x_path
// 模拟影像的匹配坐标Y输出路径 str sar_sim_match_point_y_path
// 模拟影像的匹配坐标Z输出路径 str sar_sim_match_point_z_path
// 采样率 long double sample_f
// 近斜距 long double R0
// 成像起始时间 long double starttime ---UTC 时间
// 光速 long double
// 波长 long double
// 多普勒参考时间 long double TO ---UTC 时间
// 脉冲重复频率 long double PRF
// 斜距采样间隔 long double delta_R
// 多普勒系数个数 int
// 多普勒系数1 long double
// 多普勒系数2 long double
// ....
// 卫星轨道模型是否为多项式模型 int 1 是。0 不是
// 卫星轨道模型多项式次数 int 4 5
// 卫星轨道模型起始时间 long double
// 卫星轨道模型X值系数1 long double
// ....
// 卫星轨道模型Y值系数1 long double
// ...
// 卫星轨道模型Z值系数1 long double
// ...
// 卫星轨道模型Vx值系数1 long double
// ...
// 卫星轨道模型Vy值系数1 long double
// ...
// 卫星轨道模型Vz值系数1 long double
// ...
//
//
class ParameterInFile
{
public:
ParameterInFile(std::string infile_path);
ParameterInFile(const ParameterInFile& paras);
~ParameterInFile();
public:
//参数组
std::string dem_path; //dem 路径
std::string out_sar_sim_path; // 输出模拟sar
std::string out_sar_sim_dem_path; // 输出模拟sar
std::string out_sar_sim_resampling_path; // 输出模拟sar
std::string out_sar_sim_resampling_rc;
int sim_height; // 模拟影像的高
int sim_width;
long double widthspace;// 距离向分辨率
std::string sar_sim_match_point_path; //输出模拟影像的地点x
std::string sar_sim_match_point_xyz_path; //输出模拟影像的地点x
int sample_f; //采样率
long double R0; //近斜距
long double LightSpeed;//光速
long double lamda;//波长
long double refrange;// 参考斜距
long double delta_R; // 斜距间隔
long double imgStartTime; //成像起始时间
long double PRF;// 脉冲重复率
long double delta_t;// 时间间隔
// 多普勒
int doppler_paramenter_number;// 多普勒系数个数
long double* doppler_para;//多普勒系数
//卫星轨道模型
int polySatelliteModel;// 是否为卫星多轨道模型
int polynum;// 多项数
long double SatelliteModelStartTime;
long double* polySatellitePara;
};
// 根据轨道模型计算卫星空间位置
struct SatelliteSpacePoint {
long double x=0;
long double y=0;
long double z=0;
long double vx=0;
long double vy=0;
long double vz=0;
};
/// <summary>
/// 根据卫星轨道模型计算卫星
/// </summary>
/// <param name="satelliteTime">卫星轨道点时间</param>
/// <param name="SatelliteModelStartTime">卫星轨道模型起始时间</param>
/// <param name="polySatellitePara">卫星轨道坐标模型参数</param>
/// <param name="polynum">多项式项数</param>
/// <returns></returns>
inline SatelliteSpacePoint getSatellitePostion(long double satelliteTime,long double SatelliteModelStartTime,long double* polySatellitePara,int polynum);
/// <summary>
/// 数值模拟法计算多普勒频移值
/// </summary>
/// <param name="R">斜距</param>
/// <param name="LightSpeed">光速</param>
/// <param name="T0">多普勒参考时间</param>
/// <param name="doppler_para">多普勒参数</param>
/// <returns>多普勒频移值</returns>
inline long double calNumericalDopplerValue(long double R,long double LightSpeed,long double T0, long double* doppler_para,int doppler_paramenter_number);
/// <summary>
/// 根据理论模型计算多普勒频移值
/// </summary>
/// <param name="R">斜距</param>
/// <param name="lamda">波长</param>
/// <param name="R_sl">地面->卫星的空间向量</param>
/// <param name="V_sl">地面->卫星之间的速度向量</param>
/// <returns>多普勒频移值</returns>
inline long double calTheoryDopplerValue(long double R, long double lamda, VectorPoint R_sl, VectorPoint V_sl);
/// <summary>
/// 根据地面点求解对应的sar影像坐标
/// </summary>
/// <param name="landpoint">地面点的坐标--地固坐标系</param>
/// <param name="Starttime">影片开始成像时间</param>
/// <param name="lamda">波长</param>
/// <param name="T0">多普勒参考时间</param>
/// <param name="LightSpeed">光速</param>
/// <param name="delta_t">时间间隔</param>
/// <param name="R0">近斜距</param>
/// <param name="delta_R">斜距间隔</param>
/// <param name="SatelliteModelStartTime">卫星轨道模型时间</param>
/// <param name="polySatellitePara">卫星轨道坐标模型参数</param>
/// <param name="polynum">卫星轨道模型项数</param>
/// <param name="doppler_paramenter_number">多普勒模型数</param>
/// <returns>影像坐标x:行号y:列号z成像时刻</returns>
inline point PSTN(point& landpoint, long double Starttime, long double lamda, long double T0, long double* doppler_para, long double LightSpeed, long double delta_t, long double R0, long double delta_R, long double SatelliteModelStartTime, long double* polySatellitePara, int polynum = 4, int doppler_paramenter_number = 5);
struct translateArray {
long double a0, a1, a2;
long double b0, b1, b2;
};
/// <summary>
/// 转换影像
/// </summary>
/// <param name="row_ids"></param>
/// <param name="col_ids"></param>
/// <param name="value"></param>
/// <param name="gt"></param>
/// <returns></returns>
inline point Translation(long double row_ids,long double col_ids,long double value,translateArray& gt) {
point result{ 0,0,0 };
result.x = gt.a0 + gt.a1 * col_ids + gt.a2 * row_ids;
result.y = gt.b0 + gt.b1 * col_ids + gt.b2 * row_ids;
result.z = value;
return result;
}
inline int Translation(long double& x, long double& y, long double& r, long double& c, translateArray& gt) {
c = gt.a0 + gt.a1 * x + gt.a2 * y;
r = gt.b0 + gt.b1 * x + gt.b2 * y;
return 0;
}
/// <summary>
/// dem块
/// </summary>
class dem_block {
public:
dem_block(int all_start_row,int all_start_col,int start_row, int end_row, int start_col, int end_col, int height, int width,int sample_f);
dem_block(const dem_block& demblocks);
~dem_block();
dem_block resample_dem();
//dem_block resample_dem_cudic();
int rowcol2blockids(int row_ids, int col_ids);
point getpointblock(int row_ids, int col_ids);
int setpointblock(int row_ids, int col_ids, point& value);
point getpointblock(int ids);
int setpointblock(int ids, point& value);
int UpdatePointCoodinarary();
VectorPoint getslopeVector(int row_ids, int col_ids);
public:
int all_start_row;
int all_start_col;
int start_row; // 目标区域的起始行号
int end_row; //
int start_col; // 目标区域的起始列号
int end_col;
int height;
int width;
int size;
int sample_f;
point* pointblock; // 原始块
};
inline point bilineadInterpolation(point& p,point& p11,point& p12,point& p21,point& p22);
inline point cubicInterpolation(point& p, point& p11, point& p12,point& p13,point& p14, point& p21, point& p22,point& p23,point& p24,point& p31,point& p32,point& p33,point& p34,point& p41,point& p42,point& p43,point& p44);
/// <summary>
/// 双线性插值方法
/// </summary>
/// <param name="p"></param>
/// <param name="p11"></param>
/// <param name="p12"></param>
/// <param name="p21"></param>
/// <param name="p22"></param>
/// <returns></returns>
inline point SARbilineadInterpolation(point& p, point& p11, point& p12, point& p21, point& p22) {
}
/// <summary>
/// 入射角 -- 弧度制
/// </summary>
struct IncidenceAngle
{
long double incidenceAngle; // 雷达入射角
long double localincidenceAngle; // 局地入射角
};
struct matchPoint {
long double r, c, ti;
long double land_x, land_y, land_z;
long double distance;
long double incidenceAngle, localincidenceAngle;
};
/// <summary>
/// 模拟sar 的矩阵块累加模块默认使用short 类型(累加上限:
/// </summary>
class sim_block {
public:
sim_block(int start_row,int end_row,int start_col,int end_col,int height,int width);
sim_block(const sim_block& sim_blocks);
~sim_block();
int rowcol2blockids(int row_ids, int col_ids);
short getsimblock(int row_ids, int col_ids);
int setsimblock(int row_ids,int col_ids, short value);
int addsimblock(int row_ids, int col_ids,short value);
matchPoint getpointblock(int row_ids,int col_ids);
int setpointblock(int row_ids, int col_ids, matchPoint value);
//
long double getdistanceblock(int row_ids, int col_ids);
int setdistanceblock(int row_ids, int col_ids, long double value);
public:
int start_row;
int end_row;
int start_col;
int end_col;
int height;
int width;
int size;
short* block;
long double* distanceblock;
matchPoint* pointblock;
};
/// <summary>
/// 根据卫星坐标,地面坐标,地面法向量,求解对应的雷达入射角和局地入射角
/// </summary>
/// <param name="satellitepoint">卫星空间坐标</param>
/// <param name="landpoint">地面坐标</param>
/// <param name="slopvector">地面坡度</param>
/// <returns>入射角文件</returns>
inline IncidenceAngle calIncidence(point satellitepoint,point landpoint,VectorPoint slopvector) {
IncidenceAngle result;
VectorPoint R_ls = getVector(landpoint, satellitepoint);
result.localincidenceAngle = getVectorAngleValue(R_ls, slopvector);
VectorPoint R_s{ satellitepoint.x,satellitepoint.y,satellitepoint.z };
result.incidenceAngle = getVectorAngleValue(R_s, R_ls);
return result;
}
int SimProcessBlock(dem_block demblock, ParameterInFile paras, matchPoint* result_shared, int* Pcount);
int ResamplingSim(ParameterInFile paras);
int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, float fResX, float fResY, GDALResampleAlg eResample);
/// <summary>
/// 模拟sar的处理算法模块。
/// 为了控制内存的取用
/// 线程数8 --以进程类的方式进行管理--使用队列的方法
/// 线程内存dem_block_size*sample_f*sample_f< 1 G
/// </summary>
/// <param name="paras">参数文件项</param>
/// <param name="thread_num">线程数默认为8</param>
/// <returns>执行情况</returns>
int SimProcess(ParameterInFile paras, int thread_num);
int SimProcess_LVY(ParameterInFile paras, int thread_num);
int WriteMatchPoint(string path, std::vector<matchPoint>* matchps);
// 测试函数接口
int testPTSN(ParameterInFile paras);
///
///
/// 考虑影像的插值方案
///
///
class ConvertResampleParameter {
public:
ConvertResampleParameter(string path);
ConvertResampleParameter(const ConvertResampleParameter& para);
~ConvertResampleParameter();
public:
string in_ori_dem_path;
string ori_sim;
string out_sar_xyz_path;
string out_sar_xyz_incidence_path;
string out_orth_sar_incidence_path;
string out_orth_sar_local_incidence_path;
string outFolder_path;
int file_count;
std::vector<string> inputFile_paths;
std::vector<string> outFile_paths;
std::vector<string> outFile_pow_paths;
int ori2sim_num;
long double* ori2sim_paras;
int sim2ori_num;
long double* sim2ori_paras;
};
inline int ori2sim(long double ori_x,long double ori_y,long double& sim_x,long double& sim_y,long double* conver_paras) {
long double xy = ori_x * ori_y;
long double x2 = ori_x * ori_x;
long double y2 = ori_y * ori_y;
sim_x = conver_paras[0] + ori_x * conver_paras[1] + ori_y * conver_paras[2] + x2 * conver_paras[3] + y2 * conver_paras[4] + xy * conver_paras[5];
sim_y = conver_paras[6] + ori_x * conver_paras[7] + ori_y * conver_paras[8] + x2 * conver_paras[9] + y2 * conver_paras[10] + xy * conver_paras[11];
return 1;
}
/// <summary>
/// 将模拟的行列号转换为目标行列号
/// </summary>
/// <param name="sim_r">模拟的行号</param>
/// <param name="sim_c">模拟的列号</param>
/// <param name="ori_r">待计算的目标行号</param>
/// <param name="ori_c">待计算的目标列号</param>
/// <param name="conver_paras">变换矩阵</param>
/// <returns>默认0 表示计算结束</returns>
inline int sim2ori(long double sim_r,long double sim_c,long double& ori_r,long double& ori_c, long double* conver_paras) {
long double xy = sim_r * sim_c;
long double x2 = sim_r * sim_r;
long double y2 = sim_c * sim_c;
ori_r = conver_paras[0] + sim_r * conver_paras[1] + sim_c * conver_paras[2] + x2 * conver_paras[3] + y2 * conver_paras[4] + xy * conver_paras[5];
ori_c = conver_paras[6] + sim_r * conver_paras[7] + sim_c * conver_paras[8] + x2 * conver_paras[9] + y2 * conver_paras[10] + xy * conver_paras[11];
return 0;
}
// 查询精确坐标
point GetOriRC(point& landp, ParameterInFile& paras, ConvertResampleParameter& convparas);
int SimProcessBlock_CalXYZ(dem_block demblock, ParameterInFile paras, ConvertResampleParameter converParas, matchPoint* result_shared, int* Pcount);
int SimProcess_CalXYZ(ParameterInFile paras, ConvertResampleParameter conveparas, int thread_num);
/*
dem->sim->ori(r,c) <--> ori
step1: dem ori -> ori_sim.tif (r,c,incidence,localincidence)
step2: a,b
*/
int SimProcess_Calsim2ori(ParameterInFile paras, ConvertResampleParameter conveparas, int thread_num); // 正射模块
/*
step1
step2:
*/
int SimProcess_ResamplingOri2Orth(ParameterInFile paras, ConvertResampleParameter conveparas, int thread_num);
/*
*/
int SimProcess_Calspow(ParameterInFile paras, ConvertResampleParameter conveparas, int thread_num); // 正射模块

View File

@ -0,0 +1,30 @@
#include "common.h"
#include <time.h>
#include <chrono>
#include <ctime>
/**
* @brief GetCurrentTime
* @return
*/
std::string getCurrentTimeString() {
std::time_t t = std::time(NULL);
char mbstr[100];
std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d %H:%M:%S",
std::localtime(&t));
std::string strTime = mbstr;
return strTime;
}
std::string getCurrentShortTimeString() {
std::time_t t = std::time(NULL);
char mbstr[100];
std::strftime(mbstr, sizeof(mbstr), "%H:%M:%S",
std::localtime(&t));
std::string strTime = mbstr;
return strTime;
}

View File

@ -0,0 +1,14 @@
#ifndef COMMON_H
#define COMMON_H
#include <iostream>
#include <string>
/**
* @brief GetCurrentTime
* @return
*/
std::string getCurrentTimeString();
std::string getCurrentShortTimeString();
#endif

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<ExecutablePath>C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\bin\intel64;$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
<IncludePath>C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\include;C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\include;$(oneMKLIncludeDir);$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\lib\intel64;C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\lib\release;C:\Program Files (x86)\Intel\oneAPI\compiler\2022.1.0\windows\compiler\lib\intel64_win;$(LibraryPath)</LibraryPath>
<_PropertySheetDisplayName>mkl_debug_x64</_PropertySheetDisplayName>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>mkl_intel_ilp64.lib;mkl_intel_thread.lib;mkl_core.lib;mkl_blacs_intelmpi_ilp64.lib;libiomp5md.lib;impi.lib;mkl_sequential.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<ExecutablePath>C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\bin\intel64;$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
<IncludePath>C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\include;C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\include;$(oneMKLIncludeDir);$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\lib\intel64;C:\Program Files (x86)\Intel\oneAPI\mpi\2021.6.0\lib\release;C:\Program Files (x86)\Intel\oneAPI\compiler\2022.1.0\windows\compiler\lib\intel64_win;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>mkl_intel_ilp64.lib;mkl_intel_thread.lib;mkl_core.lib;mkl_blacs_intelmpi_ilp64.lib;libiomp5md.lib;impi.lib;mkl_sequential.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@ -0,0 +1,11 @@
#include "taskprocess.h"
TaskProcess::TaskProcess()
{
}
TaskProcess::~TaskProcess()
{
}

View File

@ -0,0 +1,15 @@
#ifndef TASKPROCESS_H
#define TASKPROCESS_H
class TaskProcess
{
public:
TaskProcess();
~TaskProcess();
private:
};
#endif

View File

@ -0,0 +1,182 @@
#include "threadpool.hpp"
#include <sstream>
#include <string>
//#include <unistd.h>
#include <windows.h>
static const int MAX_THREADS = 10000; //最大线程数目
/**
* @brief ThreadPool
* @param number[in]线 *线
* @param
* emptyQuit[in]线退falsetruestartwaite
*/
ThreadPool::ThreadPool(int number, bool emptyQuit)
: m_StopFlag(false), m_EmptyQuit(emptyQuit), m_JoinFlag(false), m_QuitNum(0), m_EmptyQuitWaite(false) {
std::cout << "线程池中线程数:" << number << std::endl;
if (number <= 0 || number > MAX_THREADS) throw std::exception();
m_ThreadNum = number;
}
ThreadPool::~ThreadPool() {
// std::cout << "~ThreadPool()" << std::endl;
stop();
}
/**
* @brief stop
*/
void ThreadPool::stop() {
//保证多线程情况下只调用一次stopThreadGroup
std::call_once(m_CallStopSlag, [this] { stopThreadGroup(); });
}
/**
* @brief stopThreadGroup 线
*/
void ThreadPool::stopThreadGroup() {
m_StopFlag = true;
Sleep(500);
m_Condition.notify_all();
waiteFinish(); //等待线程退出
std::thread* thread = NULL;
for (int i = 0; i < m_WorkThreads.size(); i++)
{
thread = m_WorkThreads[i];
if (thread != NULL)
{
thread->join();
delete thread;
thread = NULL;
}
m_WorkThreads[i] = NULL;
}
m_WorkThreads.clear();
}
/**
* @brief startThread 线
*/
void ThreadPool::startThread() {
for (int i = 0; i < m_ThreadNum; i++) {
std::thread* thread = new std::thread(ThreadPool::worker, this);
m_WorkThreads.push_back(thread);
}
}
/**
* @brief waiteThreadFinish 线
*/
void ThreadPool::waiteThreadFinish() {
if (m_JoinFlag) return;
if (m_EmptyQuit)
{
m_EmptyQuitWaite = true;
do
{
if (m_ThreadNum == m_QuitNum)
break;
Sleep(400);
} while (true);
m_StopFlag = true;
m_Condition.notify_all();
}
/* for (int i = 0; i < work_threads.size(); i++) {
if (work_threads[i]) { work_threads[i]->join(); }
}*/
m_JoinFlag = true;
}
/**
* @brief start
*/
void ThreadPool::start() {
std::call_once(m_CallStartSlag, [this] { startThread(); });
}
/**
* @brief waiteFinish ,退
*/
void ThreadPool::waiteFinish() {
std::call_once(m_CallWaiteFinisFlag, [this] { waiteThreadFinish(); });
}
/**
* @brief
*/
int ThreadPool::taskNum()
{
return m_TasksQueue.size();
}
/**
* @brief append task_queue<T *>
* @param task
* @return
*/
bool ThreadPool::append(Task task) {
/*操作工作队列时一定要加锁,因为他被所有线程共享*/
m_DataMutex.lock();
m_TasksQueue.push(task);
m_DataMutex.unlock();
m_Condition.notify_one(); //线程池添加进去了任务,自然要通知等待的线程
return true;
}
/**
* @brief worker 线
* @param arg
* @return
*/
void* ThreadPool::worker(void* arg) {
ThreadPool* pool = (ThreadPool*)arg;
pool->run();
return pool;
}
/**
* @brief notEmpty
* @return
*/
bool ThreadPool::notEmpty() {
bool empty = m_TasksQueue.empty();
if (empty) {
// std::ostringstream oss;
// oss << std::this_thread::get_id();
// printf("queue empty thread id %s waite...!\n", oss.str().c_str());
}
return !empty;
}
/**
* @brief run 线,
*/
void ThreadPool::run() {
bool flag = false;
int remainder = 0;
while (!m_StopFlag) {
flag = false;
{
std::unique_lock<std::mutex> lk(this->m_QueueMutex);
/* unique_lock() 出作用域会自动解锁 */
m_Condition.wait(lk, [this] { return m_StopFlag || notEmpty(); });
}
if (m_StopFlag) break;
Task task;
m_DataMutex.lock();
//如果任务队列不为空,就停下来等待唤醒
if (!this->m_TasksQueue.empty()) {
task = m_TasksQueue.front();
m_TasksQueue.pop();
remainder = m_TasksQueue.size();
flag = true;
}
m_DataMutex.unlock();
if (flag) task();
//如果队列为空并且完成退出,已经开始等待退出就退出
if (m_TasksQueue.empty() && m_EmptyQuit && m_EmptyQuitWaite)
{
break;
}
}
m_QuitNum += 1;
std::ostringstream oss;
oss << std::this_thread::get_id();
printf("thread %s end\n", oss.str().c_str());
}

View File

@ -0,0 +1,102 @@
#ifndef THREADPOOL_HPP
#define THREADPOOL_HPP
#include <atomic>
#include <condition_variable>
#include <functional>
#include <iostream>
#include <memory> //unique_ptr
#include <queue>
#include <stdexcept>
#include <thread>
#include <vector>
typedef std::function<void(void)> Task;
class ThreadPool {
public:
/**
* @brief ThreadPool
* @param number[in]线 *线
* @param
* emptyQuit[in]线退falsetruestartwaite
*/
ThreadPool(int number = 1, bool emptyQuit = false);
~ThreadPool();
/**
* @brief append task_queue<T *>
* @param task
* @return
*/
bool append(Task task);
/**
* @brief start
*/
void start();
/**
* @brief stop
*/
void stop();
/**
* @brief waiteFinish ,退
*/
void waiteFinish();
/**
* @brief
*/
int taskNum();
private:
/**
* @brief worker 线
* @param arg
* @return
*/
static void *worker(void *arg);
/**
* @brief run 线,
*/
void run();
/**
* @brief stopThreadGroup 线
*/
void stopThreadGroup();
/**
* @brief startThread 线
*/
void startThread();
/**
* @brief waiteThreadFinish 线
*/
void waiteThreadFinish();
/**
* @brief notEmpty
* @return
*/
bool notEmpty();
private:
std::vector<std::thread *> m_WorkThreads; /*工作线程*/
std::queue<Task> m_TasksQueue; /*任务队列*/
std::mutex m_QueueMutex;
std::condition_variable m_Condition; /*必须与unique_lock配合使用*/
std::recursive_mutex m_DataMutex; //数据锁
std::atomic_bool m_StopFlag; //是否停止标志
std::once_flag m_CallStopSlag;
std::once_flag m_CallStartSlag;
std::once_flag m_CallWaiteFinisFlag;
int m_ThreadNum; //线程数
std::atomic_bool m_EmptyQuit; //无任务退出模式,改模式先添加任务,再启动
std::atomic_bool m_JoinFlag; //线程是否Join
std::atomic_bool m_EmptyQuitWaite;//开始退出等待
std::atomic_int m_QuitNum;//退出的线程计数
};
typedef std::shared_ptr<ThreadPool> ThreadPoolPtr;
#endif // THREADPOOL_HPP

View File

@ -0,0 +1,20 @@
// testengiewithmkl.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{c26dab80-43be-4542-a2a3-7b5acb6e35e6}</ProjectGuid>
<RootNamespace>testengiewithmkl</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="testengiewithmkl.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="testengiewithmkl.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@ -0,0 +1 @@
# SIMOrthoProgram

View File

@ -0,0 +1,23 @@
#pragma once
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <boost/filesystem.hpp>
#include <omp.h>
#include "baseTool.h"
#include "simptsn.h"
#include "SateOrbit.h"
#include "ImageMatch.h"
#include <gdal_utils.h>
#include <proj.h>
#include "gdal_priv.h"
#include "gdal_alg.h"
#include "RPC_Correct.h"
using namespace std;
using namespace Eigen;

View File

@ -0,0 +1,29 @@
#pragma once
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <boost/filesystem.hpp>
#include <omp.h>
#include <gdal_utils.h>
#include <proj.h>
#include "gdal_priv.h"
#include "gdal_alg.h"
//#include <mkl.h>
#include "baseTool.h"
#include "simptsn.h"
#include "SateOrbit.h"
#include "ImageMatch.h"
using namespace std;
using namespace Eigen;
// 专门用于解析RPC
class RPC_Correct
{
};

Binary file not shown.

View File

@ -0,0 +1,440 @@
// SIMOrthoProgram.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
#include <stdlib.h>
#include <direct.h>
// gdal
#include <proj.h>
#include <string>
#include "gdal_priv.h"
#include "ogr_geometry.h"
#include "gdalwarper.h"
#include "baseTool.h"
#include "simptsn.h"
#include "test_moudel.h"
#include <Windows.h>
using namespace std;
using namespace Eigen;
//mode 1
void PreProcess(int argc, char* argv[])
{
// .\baseTool\x64\Release\SIMOrthoProgram.exe 1 D:\MicroWorkspace\C-SAR\Ortho\Temporary\unpack\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848\GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_HH_L10003923848.tiff
//输入参数
std::cout << "==========================================================================" << endl;
std::cout << "预处理计算结果可以计算出DEM 范围 " << endl;
std::cout << "SIMOrthoProgram.exe 1 in_parameter_path in_dem_path in_ori_sar_path in_work_path in_taget_path ";
std::string parameter_path = argv[2]; // 参数文件
std::string dem_path = argv[3]; // dem 文件
std::string in_sar_path = argv[4]; // 输入SAR文件
std::string work_path = argv[5]; // 目标空间文件
std::string taget_path = argv[6]; // 输出坐标映射文件
//std::string parameter_path = "D:\\micro\\WorkSpace\\Ortho\\Temporary\\package\\orth_para.txt"; // 参数文件
//std::string dem_path = "D:\\micro\\WorkSpace\\Ortho\\Temporary\\TestDEM\\mergedDEM.tif"; // dem 文件
//std::string in_sar_path = "D:\\micro\\WorkSpace\\Ortho\\Temporary\\unpack\\HJ2E_KSC_STRIP_003375_E100.3_N26.8_20230522_SLC_HHHV_L10000057058\\HJ2E_KSC_STRIP_003375_E100.3_N26.8_20230522_SLC_HHHV_L10000057058\\HJ2E_KSC_STRIP_003375_E100.3_N26.8_20230522_SLC_HH_L10000057058.tiff"; // 输入SAR文件
//std::string work_path = "D:\\micro\\WorkSpace\\Ortho\\Temporary"; // 目标空间文件
//std::string taget_path = "D:\\micro\\WorkSpace\\Ortho\\Temporary\\package"; // 输出坐标映射文件
//std::string parameter_path = "D:\\micro\\WorkSpace\\Ortho1\\Temporary\\package\\orth_para.txt"; // 参数文件
//std::string dem_path = "D:\\micro\\WorkSpace\\Ortho1\\Temporary\\TestDEM\\mergedDEM.tif"; // dem 文件
//std::string in_sar_path = "D:\\micro\\WorkSpace\\Ortho1\\Temporary\\unpack\\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422\\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_HH_L10003515422.tiff"; // 输入SAR文件
//std::string work_path = "D:\\micro\\WorkSpace\\Ortho1\\Temporary"; // 目标空间文件
//std::string taget_path = "D:\\micro\\WorkSpace\\Ortho1\\Temporary\\package"; // 输出坐标映射文件
//std::string Incident_path = argv[7];// 输出入射角文件
std::cout << "==========================================================================" << endl;
std::cout << "in parameters:========================================================" << endl;
std::cout << "parameters file path:\t" << parameter_path << endl;
std::cout << "input dem image(WGS84)" << dem_path << endl;
std::cout << "the sar image:\n" << in_sar_path << endl;
std::cout << "the work path for outputing temp file :\t" << work_path << endl;
std::cout << "the out file for finnal file:\t" << taget_path << endl;
simProcess process;
std::cout << "==========================================================================" << endl;
process.InitSimulationSAR(parameter_path, work_path, taget_path, dem_path, in_sar_path);
std::cout << "==========================================================================" << endl;
}
//mode 2
void calIncident_localIncident_angle(int argc, char* argv[]) {
std::cout << "mode 2: get incident angle and local incident angle by rc_wgs84 and dem and statellite model:\n";
std::cout << "SIMOrthoProgram.exe 2 in_parameter_path in_dem_path in_rc_wgs84_path out_incident_angle_path out_local_incident_angle_path";
std::string parameter_path = argv[2];
std::string dem_path = argv[3];
std::string in_rc_wgs84_path = argv[4];
std::string out_incident_angle_path = argv[5];
std::string out_local_incident_angle_path = argv[6];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
process.pstn = pstn;
process.calcalIncident_localIncident_angle(dem_path, in_rc_wgs84_path, out_incident_angle_path, out_local_incident_angle_path, pstn);
}
// mode 3
void calInterpolation_cubic_Wgs84_rc_sar(int argc, char* argv[]) {
std::cout << "mode 3: interpolation(cubic convolution) orth sar value by rc_wgs84 and ori_sar image and model:\n ";
std::cout << "SIMOrthoProgram.exe 3 in_parameter_path in_rc_wgs84_path in_ori_sar_path out_orth_sar_path";
std::string parameter_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary\\package\\orth_para.txt"; argv[2];
std::string in_rc_wgs84_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary\\dem_rc.tiff"; argv[3];
std::string in_ori_sar_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary\\unpack\\GF3_MYN_QPSI_011437_E99.2_N28.6_20181012_L1A_AHV_L10003514912\\GF3_MYN_QPSI_011437_E99.2_N28.6_20181012_L1A_VV_L10003514912.tiff"; argv[4];
std::string out_orth_sar_path = "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary\\package\\GF3_MYN_QPSI_011437_E99.2_N28.6_20181012_L1A_VV_L10003514912_GTC_rpc_geo.tif"; argv[5];
parameter_path = argv[2];
in_rc_wgs84_path = argv[3];
in_ori_sar_path = argv[4];
out_orth_sar_path = argv[5];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
process.pstn = pstn;
std::cout << "==========================================================================" << endl;
process.interpolation_GTC_sar(in_rc_wgs84_path, in_ori_sar_path, out_orth_sar_path, pstn);
}
// mode 4 处理 RPC的入射角
void getRPC_Incident_localIncident_angle(int argc, char* argv[]) {
std::cout << "mode 4: get RPC incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 4 in_parameter_path in_dem_path in_rpc_rc_path out_rpc_dem_path out_incident_angle_path out_local_incident_angle_path";
std::string parameter_path = argv[2];
std::string in_dem_path = argv[3];
std::string in_rpc_rc_path = argv[4];
std::string out_rpc_dem_path = argv[5];
std::string out_incident_angle_path = argv[6];
std::string out_local_incident_angle_path = argv[7];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
process.CreateRPC_DEM(in_rpc_rc_path, in_dem_path, out_rpc_dem_path);
process.calcalIncident_localIncident_angle(out_rpc_dem_path, in_rpc_rc_path, out_incident_angle_path, out_local_incident_angle_path, pstn);
}
//mode 5
void cal_ori_2_power_tiff(int argc, char* argv[]) {
std::cout << "mode 5: convert ori tiff to power tiff:";
std::cout << "SIMOrthoProgram.exe 5 in_ori_path out_power_path";
std::string in_ori_path = argv[2];
std::string out_power_path = argv[3];
simProcess process;
process.ori_sar_power(in_ori_path, out_power_path);
}
// mode 6
void cal_GEC_Incident_localIncident_angle(int argc, char* argv[]) {
std::cout << "mode 6: get gec incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 6 in_parameter_path in_dem_path in_gec_lon_lat_path out_incident_angle_path out_local_incident_angle_path";
std::string parameter_path = argv[2];
std::string dem_path = argv[3];
std::string in_gec_lon_lat_path = argv[4];
std::string out_incident_angle_path = argv[5];
std::string out_local_incident_angle_path = argv[6];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
std::cout << "==========================================================================" << endl;
process.calGEC_Incident_localIncident_angle(dem_path, in_gec_lon_lat_path, out_incident_angle_path, out_local_incident_angle_path, pstn);
}
// mode 7
void RPC_inangle(int argc, char* argv[]) {
std::cout << "mode 7: get rpc incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 7 in_parameter_path in_dem_path in_gec_lon_lat_path work_path taget_path out_incident_angle_path out_local_incident_angle_path";
std::string parameter_path = argv[2];
std::string dem_path = argv[3];
std::string in_gec_lon_lat_path = argv[4];
std::string work_path = argv[5];
std::string taget_path = argv[6];
std::string out_incident_angle_path = argv[7];
std::string out_local_incident_angle_path = argv[8];
std::string out_incident_angle_geo_path = argv[9];
std::string out_local_incident_angle_geo_path = argv[10];
simProcess process;
//InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path, std::string in_rpc_lon_lat_path)
std::cout << "==========================================================================" << endl;
process.InitRPCIncAngle(parameter_path, work_path, taget_path, dem_path, in_gec_lon_lat_path, out_incident_angle_path, out_local_incident_angle_path, out_incident_angle_geo_path, out_local_incident_angle_geo_path);
std::cout << "==========================================================================" << endl;
}
// mode 9
void calInterpolation_cubic_Wgs84_rc_sar_sigma(int argc, char* argv[]) {
std::cout << "mode 9: interpolation(cubic convolution) orth sar value by rc_wgs84 and ori_sar image and model:\n ";
std::cout << "SIMOrthoProgram.exe 9 in_parameter_path in_rc_wgs84_path in_ori_sar_path out_orth_sar_path";
std::string parameter_path = "D:\\micro\\WorkSpace\\Ortho\\Temporary\\package\\orth_para.txt";
std::string in_rc_wgs84_path = "D:\\micro\\WorkSpace\\Ortho\\Temporary\\package\\RD_sim_ori.tif";
std::string in_ori_sar_path = "D:\\micro\\WorkSpace\\Ortho\\Temporary\\in_sar_power.tiff";
std::string out_orth_sar_path = "D:\\micro\\WorkSpace\\Ortho\\Temporary\\in_sar_power_GTC.tiff";
parameter_path = argv[2];
in_rc_wgs84_path = argv[3];
in_ori_sar_path = argv[4];
out_orth_sar_path = argv[5];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
process.pstn = pstn;
std::cout << "==========================================================================" << endl;
process.interpolation_GTC_sar_sigma(in_rc_wgs84_path, in_ori_sar_path, out_orth_sar_path, pstn);
}
// mode 11
void interpolation_bil_GTC_sar_sigma(int argc, char* argv[]) {
std::cout << "mode 11: interpolation(cubic convolution) orth sar value by rc_wgs84 and ori_sar image and model:\n ";
std::cout << "SIMOrthoProgram.exe 11 in_parameter_path in_rc_wgs84_path in_ori_sar_path out_orth_sar_path";
std::string parameter_path = "D:\\micro\\WorkSpace\\SoilSalinity\\Temporary\\preprocessing\\GF3B_SYC_QPSI_008316_E116.1_N43.3_20230622_L1A_AHV_L10000202892-ortho\\orth_para.txt";
std::string in_rc_wgs84_path = "D:\\micro\\WorkSpace\\SoilSalinity\\Temporary\\preprocessing\\sim_ori_cut.tif";
std::string in_ori_sar_path = "D:\\micro\\WorkSpace\\SoilSalinity\\Temporary\\processing\\salinity.tif";
std::string out_orth_sar_path = "D:\\micro\\WorkSpace\\SoilSalinity\\Temporary\\processing\\salinity_geo.tif";
parameter_path = argv[2];
in_rc_wgs84_path = argv[3];
in_ori_sar_path = argv[4];
out_orth_sar_path = argv[5];
simProcess process;
std::cout << "==========================================================================" << endl;
PSTNAlgorithm pstn(parameter_path);
process.pstn = pstn;
std::cout << "==========================================================================" << endl;
process.interpolation_bil(in_rc_wgs84_path, in_ori_sar_path, out_orth_sar_path, pstn);
}
// mode 12
void lee_process_sar(int argc, char* argv[]) {
std::cout << "mode 12: lee process:\n ";
std::cout << "SIMOrthoProgram.exe 12 in_sar_path out_sar_path win_size noise_var\n";
std::string in_sar_path = "D:\\micro\\WorkSpace\\BackScattering\\Temporary\\preprocessing\\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_HH_L10003515422_DB.tif";
std::string out_sar_path = "D:\\micro\\WorkSpace\\BackScattering\\Temporary\\preprocessed_lee.tif";
int win_size = 5;
double noise_var = 0.25;
in_sar_path = argv[2];
out_sar_path = argv[3];
win_size = stoi(argv[4]);
noise_var = stod(argv[5]);
simProcess process;
std::cout << "==========================================================================\n" << endl;
//std::cout << in_sar_path << endl;
//std::cout << out_sar_path << endl;
//std::cout << win_size << endl;
//std::cout << noise_var << endl;
process.lee_process(in_sar_path, out_sar_path, win_size, noise_var);
}
void createRPC_lon_lat(int argc, char* argv[]) {
std::cout << "mode 8";
std::cout << "SIMOrthoProgram.exe 8 in_rpc_tiff out_lon_lat_path";
std::string in_rpc_tiff = argv[2];
std::string in_dem_tiff = argv[3];
std::string out_lon_lat_path = argv[4];
simProcess process;
//InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path, std::string in_rpc_lon_lat_path)
std::cout << "==========================================================================" << endl;
process.CreateRPC_refrenceTable(in_rpc_tiff, in_dem_tiff,out_lon_lat_path);
std::cout << "==========================================================================" << endl;
}
void Scatter2Grid_lon_lat(int argc, char* argv[]) {
std::cout << "mode 10";
std::cout << "SIMOrthoProgram.exe 10 lon_lat_path data_tiff grid_path space";
std::string lon_lat_path = "F:\\orthtest\\ori_sim_preprocessed.tif";
std::string data_tiff = "F:\\orthtest\\SoilMoistureProduct_geo.tif";
std::string grid_path = "F:\\orthtest\\SoilMoistureProduct_geo_test.tif";
double space = 5;
lon_lat_path = argv[2];
data_tiff = argv[3];
grid_path = argv[4];
space = stod(argv[5]);
simProcess process;
//InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path, std::string in_rpc_lon_lat_path)
std::cout << "==========================================================================" << endl;
process.Scatter2Grid(lon_lat_path, data_tiff, grid_path, space);
std::cout << "==========================================================================" << endl;
}
string GetExePath()
{
char szFilePath[MAX_PATH + 1] = { 0 };
GetModuleFileNameA(NULL, szFilePath, MAX_PATH);
/*
strrchr:cstrstrc
NULL
使cstr
*/
(strrchr(szFilePath, '\\'))[0] = 0; // 删除文件名,只获得路径字串//
string path = szFilePath;
return path;
}
/// <summary>
/// 初始化
/// </summary>
void initProjEnv() {
PJ_CONTEXT* C;
C = proj_context_create();
std::cout << "========================== init PROJ ================================================" << endl;
string exepath = GetExePath();
char buffer[10240];
int i;
for (i = 0; i < exepath.length(); i++) {
buffer[i] = exepath[i];
}
buffer[i] = '\0';
const char* proj_share_path = buffer;
proj_context_set_search_paths(C, 1, &proj_share_path);
char* buf = nullptr;
size_t sz = 0;
if (_dupenv_s(&buf, &sz, "PROJ_LIB") == 0 && buf != nullptr)
{
printf("PROJ_LIB = %s\n", buf);
std::string newEnv = "PROJ_LIB=" + std::string(buffer);
_putenv(newEnv.c_str());
}
else {
std::string newEnv = "PROJ_LIB=" + std::string(buffer);
_putenv(newEnv.c_str());
}
if (_dupenv_s(&buf, &sz, "PROJ_LIB") == 0 && buf != nullptr)
{
std::cout << "after PROJ_LIB = " << buf << endl;
}
free(buf);
std::cout << "========================================================================================" << endl;
}
int main(int argc, char* argv[])
{
initProjEnv();
//WGS84_J2000();
cout << "test\t" << acos(-1) << endl;
cout << getAngle(Landpoint{ -3421843,5089485,3630606 }, Landpoint{ -2609414,4763328,3332879 }) << endl;;
Landpoint p2 = { -3421843,5089485,3630606 }; Landpoint p1 = { -2609414,4763328,3332879 };
cout << getIncAngle(p2, p1) << endl;;
std::cout << "program start:\t" << getCurrentTimeString() << endl;;
int mode = 11;
GDALAllRegister();
if (argc == 0) { // 测试参数
// 算法说明
std::cout << "========================== description ================================================" << endl;
std::cout << "algorithm moudel:.exe [modeparamert] {otherParaments}" << endl;
std::cout << "mode 1: Preprocess\n ";
std::cout << "SIMOrthoProgram.exe 1 in_parameter_path in_dem_path in_ori_sar_path in_work_path in_taget_path out_GEC_dem_path out_GTC_rc_path out_GEC_lon_lat_path out_clip_dem_path" << endl;
std::cout << "mode 2: get incident angle and local incident angle by rc_wgs84 and dem and statellite model:\n";
std::cout << "SIMOrthoProgram.exe 2 in_parameter_path in_dem_path in_rc_wgs84_path out_incident_angle_path out_local_incident_angle_path";
std::cout << "mode 3: interpolation(cubic convolution) orth sar value by rc_wgs84 and ori_sar image and model:\n ";
std::cout << "SIMOrthoProgram.exe 3 in_parameter_path in_rc_wgs84_path in_ori_sar_path out_orth_sar_path";
std::cout << "mode 4: get RPC incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 4 in_parameter_path in_dem_path in_rpc_rc_path out_rpc_dem_path out_incident_angle_path out_local_incident_angle_path";
std::cout << "mode 5: interpolation(cubic convolution) orth sar value by gec_lon_lat and dem and ori_sar image and sar model:";
std::cout << "SIMOrthoProgram.exe 5 in_parameter_path in_gec_lon_lat_path in_dem_path in_sar_path out_orth_sar_path";
std::cout << "mode 6: get gec incident and local incident angle sar model:";
std::cout << "SIMOrthoProgram.exe 6 in_parameter_path in_dem_path in_gec_lon_lat_path out_incident_angle_path out_local_incident_angle_path";
if (mode == 10) {
Scatter2Grid_lon_lat(argc, argv);
}
else {
test_main(mode, "D:\\MicroSAR\\C-SAR\\Ortho\\Ortho\\Temporary");
}
//calInterpolation_cubic_Wgs84_rc_sar(argc, argv);
}
else if (argc > 1) { // 预处理模块
std::cout << "=============================description V2.0 =============================================" << endl;
std::cout << "algorithm moudel:.exe [modeparamert] {otherParaments}" << endl;
std::cout << "algorithm moudel:.exe [modeparamert] {otherParaments}" << endl;
mode = stoi(argv[1]);
if (mode == 0) {
test_main(mode, argv[2]);
}
else if (mode == 1) {
PreProcess(argc, argv); //
}
else if (mode == 2) { // RPC 计算模块
calIncident_localIncident_angle(argc, argv);
}
else if (mode == 3) {
calInterpolation_cubic_Wgs84_rc_sar(argc, argv);
}
else if (mode == 4) {
getRPC_Incident_localIncident_angle(argc, argv);
}
else if (mode == 5) {
cal_ori_2_power_tiff(argc, argv);
}
else if (mode == 6) {
cal_GEC_Incident_localIncident_angle(argc, argv);
}
else if (mode == 7) {
RPC_inangle(argc, argv);
}
else if (mode == 8) {
createRPC_lon_lat(argc, argv);
}
else if (mode == 9) {
calInterpolation_cubic_Wgs84_rc_sar_sigma(argc, argv);
}
else if (mode == 10) {
Scatter2Grid_lon_lat(argc, argv);
}
else if (mode == 11) {
interpolation_bil_GTC_sar_sigma(argc, argv);
}
else if (mode == 12){
lee_process_sar(argc, argv);
}
}
GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
std::cout << "program over\t" << getCurrentTimeString() << endl;
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

View File

@ -0,0 +1,64 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// 中文(简体,中国) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#endif // 中文(简体,中国) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32602.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SIMOrthoProgram", "SIMOrthoProgram.vcxproj", "{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Debug|x64.ActiveCfg = Debug|x64
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Debug|x64.Build.0 = Debug|x64
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Debug|x86.ActiveCfg = Debug|Win32
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Debug|x86.Build.0 = Debug|Win32
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Release|x64.ActiveCfg = Release|x64
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Release|x64.Build.0 = Release|x64
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Release|x86.ActiveCfg = Release|Win32
{7722B0A9-572B-4E32-AFBE-4DC88898F8EE}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CE6D0980-E92A-4188-91CE-EEE5749F908C}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,200 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{7722b0a9-572b-4e32-afbe-4dc88898f8ee}</ProjectGuid>
<RootNamespace>SIMOrthoProgram</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>Sequential</UseInteloneMKL>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>Parallel</UseInteloneMKL>
<UseIntelMPI>false</UseIntelMPI>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>C:\ProgramData\Miniconda3\envs\orth\Library\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64;$(oneMKLOmpLibDir);$(LibraryPath)</LibraryPath>
<CopyLocalProjectReference>true</CopyLocalProjectReference>
<CopyCppRuntimeToOutputDir>false</CopyCppRuntimeToOutputDir>
<ExternalIncludePath>C:\ProgramData\Miniconda3\envs\orth\Library\include;$(ExternalIncludePath)</ExternalIncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<CopyLocalProjectReference>true</CopyLocalProjectReference>
<CopyLocalDebugSymbols>true</CopyLocalDebugSymbols>
<CopyCppRuntimeToOutputDir>true</CopyCppRuntimeToOutputDir>
<IncludePath>$(IncludePath)</IncludePath>
<ExecutablePath>$(ExecutablePath)</ExecutablePath>
<ExternalIncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);</ExternalIncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<ReferencePath>$(VC_ReferencesPath_x64);</ReferencePath>
<LibraryWPath>$(WindowsSDK_MetadataPath);</LibraryWPath>
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<OpenMPSupport>true</OpenMPSupport>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>
</FunctionLevelLinking>
<IntrinsicFunctions>false</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<OpenMPSupport>true</OpenMPSupport>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard_C>Default</LanguageStandard_C>
<Optimization>MaxSpeed</Optimization>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
<WholeProgramOptimization>false</WholeProgramOptimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<StackCommitSize>
</StackCommitSize>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="baseTool.cpp" />
<ClCompile Include="ImageMatch.cpp" />
<ClCompile Include="interpolation.cpp" />
<ClCompile Include="OctreeNode.cpp" />
<ClCompile Include="RPC_Correct.cpp" />
<ClCompile Include="simptsn.cpp" />
<ClCompile Include="SateOrbit.cpp" />
<ClCompile Include="SIMOrthoProgram.cpp" />
<ClCompile Include="test_moudel.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="baseTool.h" />
<ClInclude Include="ImageMatch.h" />
<ClInclude Include="interpolation.h" />
<ClInclude Include="linterp.h" />
<ClInclude Include="OctreeNode.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="RPC_Correct.h" />
<ClInclude Include="simptsn.h" />
<ClInclude Include="SateOrbit.h" />
<ClInclude Include="test_moudel.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SIMOrthoProgram.rc" />
</ItemGroup>
<ItemGroup>
<None Include="proj.db" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SIMOrthoProgram.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="baseTool.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="simptsn.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="SateOrbit.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ImageMatch.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="test_moudel.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="RPC_Correct.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="OctreeNode.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="interpolation.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="baseTool.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="simptsn.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="SateOrbit.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ImageMatch.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="test_moudel.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="RPC_Correct.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="OctreeNode.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="interpolation.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="linterp.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SIMOrthoProgram.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="proj.db">
<Filter>资源文件</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@ -0,0 +1,86 @@
#include "SateOrbit.h"
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
using namespace std;
using namespace Eigen;
OrbitPoly::OrbitPoly()
{
}
OrbitPoly::OrbitPoly(int polynum, Eigen::MatrixX<double> polySatellitePara, double SatelliteModelStartTime)
{
if (polySatellitePara.rows() != polynum||polySatellitePara.cols()!=6) {
throw exception("?????????????????");
}
this->polySatellitePara = polySatellitePara;
this->SatelliteModelStartTime = SatelliteModelStartTime;
this->polynum = polynum;
}
OrbitPoly::~OrbitPoly()
{
}
Eigen::MatrixX<double> OrbitPoly::SatelliteSpacePoint(Eigen::MatrixX<double> satellitetime)
{
Eigen::MatrixX<double> result= SatelliteSpacePoints(satellitetime, this->SatelliteModelStartTime, this->polySatellitePara, this->polynum);
return result;
}
Eigen::MatrixX<double> OrbitPoly::SatelliteSpacePoint(long double satellitetime) {
if (this->polySatellitePara.rows() != polynum || this->polySatellitePara.cols() != 6) {
throw exception("the size of satellitetime has error!! row: p1,p2,p3,p4 col: x,y,z,vx,vy,vz ");
}
// ?????????
double satellitetime2 =double( satellitetime - this->SatelliteModelStartTime);
Eigen::MatrixX<double> satetime(1, polynum);
for (int i = 0; i < polynum; i++) {
satetime(0, i) = pow(satellitetime2, i);
}
// ????
Eigen::MatrixX<double> satellitePoints(1, 6);
satellitePoints = satetime * polySatellitePara;
return satellitePoints;
}
/// <summary>
/// ????????????????????
/// </summary>
/// <param name="satellitetime">???????</param>
/// <param name="SatelliteModelStartTime">??????????</param>
/// <param name="polySatellitePara">??????[x1,y1,z1,vx1,vy1,vz1; x2,y2,z2,vx2,vy2,vz2; ..... ]</param>
/// <param name="polynum">??????????</param>
/// <returns>????????</returns>
Eigen::MatrixX<double> SatelliteSpacePoints(Eigen::MatrixX<double>& satellitetime, double SatelliteModelStartTime, Eigen::MatrixX<double>& polySatellitePara, int polynum)
{
if (satellitetime.cols() != 1) {
throw exception("the size of satellitetime has error!!");
}
if (polySatellitePara.rows() != polynum || polySatellitePara.cols() != 6) {
throw exception("the size of satellitetime has error!! row: p1,p2,p3,p4 col: x,y,z,vx,vy,vz ");
}
// ?????????
int satellitetime_num = satellitetime.rows();
satellitetime = satellitetime.array() - SatelliteModelStartTime;
Eigen::MatrixX<double> satelliteTime(satellitetime_num, polynum);
for (int i = 0; i < polynum; i++) {
satelliteTime.col(i) = satellitetime.array().pow(i);
}
// ????
Eigen::MatrixX<double> satellitePoints(satellitetime_num, 6);
satellitePoints = satelliteTime * polySatellitePara;
return satellitePoints;
}

View File

@ -0,0 +1,53 @@
#pragma once
///
/// 计算卫星轨道
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// 本地方法
#include "baseTool.h"
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
//#include <armadillo>
using namespace std;
using namespace Eigen;
//using namespace arma;
/// <summary>
/// 多项式轨道模型
/// </summary>
class OrbitPoly {
public:
//OrbitPoly(std::string orbitModelPath);
OrbitPoly();
OrbitPoly(int polynum, Eigen::MatrixX<double> polySatellitePara, double SatelliteModelStartTime);
~OrbitPoly();
Eigen::MatrixX<double> SatelliteSpacePoint(Eigen::MatrixX<double> satellitetime);
Eigen::MatrixX<double> SatelliteSpacePoint(long double satellitetime);
public:
int polynum;
Eigen::MatrixX<double> polySatellitePara;
double SatelliteModelStartTime;
};
/// <summary>
/// 获取指定时刻的卫星轨道坐标
/// </summary>
/// <param name="satellitetime">卫星时刻</param>
/// <param name="SatelliteModelStartTime">模型起算时间</param>
/// <param name="polySatellitePara">模型参数[x1,y1,z1,vx1,vy1,vz1; x2,y2,z2,vx2,vy2,vz2; ..... ]</param>
/// <param name="polynum">模型参数数量</param>
/// <returns>卫星坐标</returns>
Eigen::MatrixX<double> SatelliteSpacePoints(Eigen::MatrixX<double> &satellitetime, double SatelliteModelStartTime, Eigen::MatrixX<double>& polySatellitePara, int polynum = 4);

View File

@ -0,0 +1,19 @@
#pragma once
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <math.h>
#include <string>
#include <omp.h>
#include <complex>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <ogrsf_frmts.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
#include <opencv2/features2d.hpp>
#include <fstream>
#include "baseTool.h"
#include"WGS84_J2000.h"

View File

@ -0,0 +1,10 @@
#pragma once
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <omp.h>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include "baseTool.h"
#include <string>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,433 @@
#pragma once
///
/// 基本类、基本函数
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
//#include <mkl.h>
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <string>
#include <omp.h>
#include <complex>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <ogrsf_frmts.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
#include <opencv2/features2d.hpp>
#include <fstream>
using namespace std;
using namespace Eigen;
#define PI_180 180/3.141592653589793238462643383279
#define T180_PI 3.141592653589793238462643383279/180
#define LIGHTSPEED 299792458
#define Radians2Degrees(Radians) Radians*PI_180
#define Degrees2Radians(Degrees) Degrees*T180_PI
const double PI = 3.141592653589793238462643383279;
const double epsilon = 0.000000000000001;
const double pi = 3.14159265358979323846;
const double d2r = pi / 180;
const double r2d = 180 / pi;
const double a = 6378137.0; //椭球长半轴
const double ae = 6378137.0; //椭球长半轴
const double ee= 0.0818191910428;// 第一偏心率
const double f_inverse = 298.257223563; //扁率倒数
const double b = a - a / f_inverse;
const double eSquare = (a * a - b * b) / (a * a);
const double e = sqrt(eSquare);
const double earth_Re = 6378136.49;
const double earth_Rp = (1 - 1 / f_inverse) * earth_Re;
const double earth_We = 0.000072292115;
///////////////////////////////////// 运行时间打印 //////////////////////////////////////////////////////////
std::string getCurrentTimeString();
std::string getCurrentShortTimeString();
/////////////////////////////// 基本图像类 //////////////////////////////////////////////////////////
/// <summary>
/// 三维向量,坐标表达
/// </summary>
struct Landpoint // 点 SAR影像的像素坐标
{
/// <summary>
/// 经度x
/// </summary>
double lon; // 经度x lon pixel_col
/// <summary>
/// 纬度y
/// </summary>
double lat; // 纬度y lat pixel_row
/// <summary>
/// 高度z
/// </summary>
double ati; // 高程z ati pixel_time
};
struct Point_3d {
double x;
double y;
double z;
};
Landpoint operator +(const Landpoint& p1, const Landpoint& p2);
Landpoint operator -(const Landpoint& p1, const Landpoint& p2);
bool operator ==(const Landpoint& p1, const Landpoint& p2);
Landpoint operator *(const Landpoint& p, double scale);
/// <summary>
/// 向量A,B的夹角,角度
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns>角度制 0-360度逆时针</returns>
double getAngle(const Landpoint& a, const Landpoint& b);
/// <summary>
/// 点乘
/// </summary>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <returns></returns>
double dot(const Landpoint& p1, const Landpoint& p2);
double getlength(const Landpoint& p1);
Landpoint crossProduct(const Landpoint& a, const Landpoint& b);
struct DemBox {
double min_lat; //纬度
double min_lon;//经度
double max_lat;//纬度
double max_lon;//经度
};
/// <summary>
/// gdalImage图像操作类
/// </summary>
class gdalImage
{
public: // 方法
gdalImage(string raster_path);
~gdalImage();
void setHeight(int);
void setWidth(int);
void setTranslationMatrix(Eigen::MatrixXd gt);
void setData(Eigen::MatrixXd);
Eigen::MatrixXd getData(int start_row, int start_col, int rows_count, int cols_count, int band_ids);
void saveImage(Eigen::MatrixXd,int start_row,int start_col, int band_ids);
void saveImage();
void setNoDataValue(double nodatavalue,int band_ids);
int InitInv_gt();
Landpoint getRow_Col(double lon, double lat);
Landpoint getLandPoint(double i, double j, double ati);
double mean(int bandids=1);
double max(int bandids=1);
double min(int bandids=1);
GDALRPCInfo getRPC();
Eigen::MatrixXd getLandPoint(Eigen::MatrixXd points);
Eigen::MatrixXd getHist(int bandids);
public:
string img_path; // 图像文件
int height; // 高
int width; // 宽
int band_num;// 波段数
int start_row;//
int start_col;//
int data_band_ids;
Eigen::MatrixXd gt; // 变换矩阵
Eigen::MatrixXd inv_gt; // 逆变换矩阵
Eigen::MatrixXd data;
string projection;
};
gdalImage CreategdalImage(string img_path, int height, int width, int band_num, Eigen::MatrixXd gt, std::string projection, bool need_gt=true);
void clipGdalImage(string in_path, string out_path, DemBox box, double pixelinterval);
int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int new_width, int new_height, GDALResampleAlg eResample);
int ResampleGDALs(const char* pszSrcFile, int band_ids, GDALRIOResampleAlg eResample=GRIORA_Bilinear);
/////////////////////////////// 基本图像类 结束 //////////////////////////////////////////////////////////
string Convert(float Num);
std::string JoinPath(const std::string& path, const std::string& filename);
////////////////////////////// 坐标部分基本方法 //////////////////////////////////////////
/// <summary>
/// 将经纬度转换为地固参心坐标系
/// </summary>
/// <param name="XYZP">经纬度点--degree</param>
/// <returns>投影坐标系点</returns>
Landpoint LLA2XYZ(const Landpoint& LLA);
Eigen::MatrixXd LLA2XYZ(Eigen::MatrixXd landpoint);
/// <summary>
/// 将地固参心坐标系转换为经纬度
/// </summary>
/// <param name="XYZ">固参心坐标系</param>
/// <returns>经纬度--degree</returns>
Landpoint XYZ2LLA(const Landpoint& XYZ);
////////////////////////////// 坐标部分基本方法 //////////////////////////////////////////
/// <summary>
/// 计算地表坡度向量
/// </summary>
/// <param name="p0">固参心坐标系</param>
/// <param name="p1">固参心坐标系</param>
/// <param name="p2">固参心坐标系</param>
/// <param name="p3">固参心坐标系</param>
/// <param name="p4">固参心坐标系</param>
/// <returns>向量角度</returns>
//Landpoint getSlopeVector(Landpoint& p0, Landpoint& p1, Landpoint& p2, Landpoint& p3, Landpoint& p4, Eigen::MatrixXd UTC, double xp, double yp, double dut1, double dat);
Landpoint getSlopeVector(const Landpoint& p0, const Landpoint& p1, const Landpoint& p2, const Landpoint& p3, const Landpoint& p4);
////////////////////////////// 插值 ////////////////////////////////////////////
complex<double> Cubic_Convolution_interpolation(double u,double v,Eigen::MatrixX<complex<double>> img);
complex<double> Cubic_kernel_weight(double s);
double Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Landpoint p12, Landpoint p22);
inline float cross2d(Point_3d a, Point_3d b) { return a.x * b.y - a.y * b.x; }
inline Point_3d operator-(Point_3d a, Point_3d b) {
return Point_3d{ a.x - b.x, a.y - b.y, a.z - b.z };
};
inline Point_3d operator+(Point_3d a, Point_3d b) {
return Point_3d{ a.x + b.x, a.y +b.y, a.z + b.z };
};
inline double operator/(Point_3d a, Point_3d b) {
return sqrt(pow(a.x,2)+ pow(a.y, 2))/sqrt(pow(b.x, 2)+ pow(b.y, 2));
};
inline bool onSegment(Point_3d Pi, Point_3d Pj, Point_3d Q)
{
if ((Q.x - Pi.x) * (Pj.y - Pi.y) == (Pj.x - Pi.x) * (Q.y - Pi.y) //叉乘
//保证Q点坐标在pi,pj之间
&& min(Pi.x, Pj.x) <= Q.x && Q.x <= max(Pi.x, Pj.x)
&& min(Pi.y, Pj.y) <= Q.y && Q.y <= max(Pi.y, Pj.y))
return true;
else
return false;
}
inline Point_3d invBilinear(Point_3d p, Point_3d a, Point_3d b, Point_3d c, Point_3d d)
{
Point_3d res ;
Point_3d e = b - a;
Point_3d f = d - a;
Point_3d g = a - b + c - d;
Point_3d h = p - a;
double k2 = cross2d(g, f);
double k1 = cross2d(e, f) + cross2d(h, g);
double k0 = cross2d(h, e);
double u, v;
// if edges are parallel, this is a linear equation
if (abs(k2) < 0.001)
{
v = -k0 / k1;
u = (h.x - f.x *v) / (e.x + g.x *v);
p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
return p;
}
// otherwise, it's a quadratic
else
{
float w = k1 * k1 - 4.0 * k0 * k2;
if (w < 0.0){
// 可能在边界上
if (onSegment(a, b, p)) {
Point_3d tt = b - a;
Point_3d ttpa = p - a;
double scater=ttpa / tt;
if(scater<0||scater>1){ return { -9999,-9999,-9999 }; }
p.z = a.z + scater * tt.z;
return p;
}
else if (onSegment(b, c, p)) {
Point_3d tt = c-b;
Point_3d ttpa = p - b;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = b.z + scater * tt.z;
return p;
}
else if (onSegment(c, d, p)) {
Point_3d tt = d-c;
Point_3d ttpa = p - c;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = c.z + scater * tt.z;
return p;
}
else if (onSegment(d, a, p)) {
Point_3d tt = a-d;
Point_3d ttpa = p - d;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = d.z + scater * tt.z;
return p;
}
return { -9999,-9999,-9999 };
}
else {
w = sqrt(w);
float ik2 = 0.5 / k2;
float v = (-k1 - w) * ik2;
float u = (h.x - f.x * v) / (e.x + g.x * v);
if (u < 0.0 || u>1.0 || v < 0.0 || v>1.0)
{
v = (-k1 + w) * ik2;
u = (h.x - f.x * v) / (e.x + g.x * v);
}
p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
return p;
}
}
p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
return p;
}
//
// WGS84 到J2000 坐标系的变换
// 参考网址https://blog.csdn.net/hit5067/article/details/116894616
// 资料网址http://celestrak.org/spacedata/
// 参数文件:
// a. Earth Orientation Parameter 文件: http://celestrak.org/spacedata/EOP-Last5Years.csv
// b. Space Weather Data 文件: http://celestrak.org/spacedata/SW-Last5Years.csv
// 备注上述文件是自2017年-五年内
/**
wgs84 J2000 WGS t ,BLH
step 1: WGS 84
step 2:
step 3:
step 4:
step 5: J2000
**/
inline double sind(double degree) {
return sin(degree * d2r);
}
inline double cosd(double d) {
return cos(d * d2r);
}
/*
class WGS84_J2000
{
public:
WGS84_J2000();
~WGS84_J2000();
public:
// step1 WGS 84 转换到协议地球坐标系。
static Eigen::MatrixXd WGS84TECEF(Eigen::MatrixXd WGS84_Lon_lat_ait);
//step 2 协议地球坐标系 转换为瞬时地球坐标系
static Eigen::MatrixXd ordinateSingleRotate(int axis, double angle_deg);
// step 3 瞬时地球坐标系 转换为 瞬时真天球坐标系
// xyz= ordinateSingleRotate('z',-gst_deg)*earthFixedXYZ;
static int utc2gst(Eigen::MatrixXd UTC, double dUT1, double dAT, double& gst_deg, double& JDTDB);
// step 4 瞬时真天球坐标系 转到瞬时平天球 坐标系
static int nutationInLongitudeCaculate(double JD, double& epthilongA_deg, double& dertaPthi_deg, double& dertaEpthilong_deg, double& epthilong_deg);
// step5 瞬时平天球坐标系转换为协议天球坐标系J2000函数中 JDTDB 为给定时刻 的地球动力学时对应的儒略日,其计算方法由步骤三中的函数给出。
// xyz=ordinateSingleRotate('Z',zetaA)*ordinateSingleRotate('y',-thitaA)*ordinateSingleRotate('z',zA)*xyz;
static int precessionAngle(double JDTDB, double& zetaA, double& thitaA, double& zA);
// YMD2JD 同时 YMD2JD函数为 年月日转换为儒略日,具体说明 见公元纪年法(儒略历-格里高历转儒略日_${王小贱}的博客-CSDN博客_年积日计算公式
static double YMD2JD(double y, double m, double d);
static Eigen::MatrixXd WGS842J2000(Eigen::MatrixXd BLH_deg_m, Eigen::MatrixXd UTC, double xp, double yp, double dut1, double dat);
static Landpoint WGS842J2000(Landpoint LBH_deg_m, Eigen::MatrixXd UTC, double xp, double yp, double dut1, double dat);
public:
static std::string EOP_File_Path;
static std::string Space_Weather_Data;
// IAU2000模型有77项11列
static Eigen::Matrix<double, 77, 11> IAU2000ModelParams;
};
*/
/*
XYZENUENURAH https://blog.csdn.net/why1472587/article/details/128178417
*/
//经纬度BLH
typedef struct BLH {
double B;
double L;
double H;
};
//站心坐标系也称NEU坐标系或东北高坐标系
typedef struct ENU {
double E;
double N;
double U;
};
//r为卫星向径A为卫星方位角h为卫星的高度角。
typedef struct RAH {
double R;
double A;
double H;
};
//xyz转blh
BLH xyz2blh(double X, double Y, double Z);
//xyz转enu Xr 已知测站坐标
ENU xyz2enu(double Xr, double Yr, double Zr, double Xs, double Ys, double Zs);
//求卫星方位角、高度角
RAH Satrah(double Xr, double Yr, double Zr, double Xs, double Ys, double Zs);
//将值写入到txt中
void creatTxt(const std::string& txtPath, const std::string& data);

View File

@ -0,0 +1 @@
#include "interpolation.h"

View File

@ -0,0 +1,10 @@
#pragma once
/**
*/
#include <stdio.h>
#include <stdlib.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_interp2d.h>
#include <gsl/gsl_spline2d.h>

Some files were not shown because too many files have changed in this diff Show More