142 lines
6.2 KiB
C++
142 lines
6.2 KiB
C++
|
/*
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
*
|
|||
|
*/
|
|||
|
#include <stdio.h>
|
|||
|
#include <QString>
|
|||
|
|
|||
|
#include "EchoDataFormat.h"
|
|||
|
#include "ImageShowDialogClass.h"
|
|||
|
#include "GPUBaseLibAPI.h"
|
|||
|
#include "BaseConstVariable.h"
|
|||
|
#include "GPUTool.cuh"
|
|||
|
#include "GPUBPTool.cuh"
|
|||
|
#include "BPBasic0_CUDA.cuh"
|
|||
|
#include "ImageOperatorBase.h"
|
|||
|
#include "GPUBpSimulation.cuh"
|
|||
|
|
|||
|
int main(int argc, char* argv[]) {
|
|||
|
|
|||
|
/** 1. <20><><EFBFBD><EFBFBD> **************************************************************************************************/
|
|||
|
qDebug() << u8"1.<2E><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ȡ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
QString inGPSPath = u8"C:\\Users\\30453\\Desktop\\script\\data\\GF3_Simulation.gpspos.data";
|
|||
|
long gpspoints = gdalImage(inGPSPath).height;
|
|||
|
std::shared_ptr<SatelliteAntPos> antpos = SatelliteAntPosOperator::readAntPosFile(inGPSPath, gpspoints);
|
|||
|
std::shared_ptr<double> antX((double*)mallocCUDAHost(sizeof(double) * gpspoints), FreeCUDAHost);
|
|||
|
std::shared_ptr<double> antY((double*)mallocCUDAHost(sizeof(double) * gpspoints), FreeCUDAHost);
|
|||
|
std::shared_ptr<double> antZ((double*)mallocCUDAHost(sizeof(double) * gpspoints), FreeCUDAHost);
|
|||
|
for (long i = 0; i < gpspoints; i++) {
|
|||
|
antX.get()[i] = antpos.get()[i].Px;
|
|||
|
antY.get()[i] = antpos.get()[i].Py;
|
|||
|
antZ.get()[i] = antpos.get()[i].Pz;
|
|||
|
}
|
|||
|
/** 2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> **************************************************************************************************/
|
|||
|
qDebug() << u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n2.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
QString demxyzPath = u8"C:\\Users\\30453\\Desktop\\script\\data\\demxyz.bin";
|
|||
|
gdalImage demgridimg(demxyzPath);
|
|||
|
long dem_rowCount = demgridimg.height;
|
|||
|
long dem_ColCount = demgridimg.width;
|
|||
|
std::shared_ptr<double> demX = readDataArr<double>(demgridimg, 0, 0, dem_rowCount, dem_ColCount, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
|||
|
std::shared_ptr<double> demY = readDataArr<double>(demgridimg, 0, 0, dem_rowCount, dem_ColCount, 2, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
|||
|
std::shared_ptr<double> demZ = readDataArr<double>(demgridimg, 0, 0, dem_rowCount, dem_ColCount, 3, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
|||
|
|
|||
|
std::shared_ptr<double> imgX((double*)mallocCUDAHost(sizeof(double) * dem_rowCount * dem_ColCount), FreeCUDAHost);
|
|||
|
std::shared_ptr<double> imgY((double*)mallocCUDAHost(sizeof(double) * dem_rowCount * dem_ColCount), FreeCUDAHost);
|
|||
|
std::shared_ptr<double> imgZ((double*)mallocCUDAHost(sizeof(double) * dem_rowCount * dem_ColCount), FreeCUDAHost);
|
|||
|
for (long i = 0; i < dem_rowCount; i++) {
|
|||
|
for (long j = 0; j < dem_ColCount; j++) {
|
|||
|
imgX.get()[i * dem_ColCount + j] = demX.get()[i * dem_ColCount + j];
|
|||
|
imgY.get()[i * dem_ColCount + j] = demY.get()[i * dem_ColCount + j];
|
|||
|
imgZ.get()[i * dem_ColCount + j] = demZ.get()[i * dem_ColCount + j];
|
|||
|
}
|
|||
|
}
|
|||
|
qDebug() << u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
/** 3. Ƶ<><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> **************************************************************************************************/
|
|||
|
qDebug() << u8"3.<2E><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>";
|
|||
|
double centerFreq = 5.3e9;
|
|||
|
double bandwidth = 40e6;
|
|||
|
long freqpoints = 8096;
|
|||
|
std::shared_ptr<double> freqlist(getFreqPoints_mallocHost(centerFreq - bandwidth / 2, centerFreq + bandwidth / 2, freqpoints), FreeCUDAHost);
|
|||
|
qDebug() << "start Freq:\t" << centerFreq - bandwidth / 2;
|
|||
|
qDebug() << "end Freq:\t" << centerFreq + bandwidth / 2;
|
|||
|
qDebug() << "freq points:\t" << freqpoints;
|
|||
|
qDebug() << "delta freq:\t" << freqlist.get()[0] - freqlist.get()[1];
|
|||
|
qDebug() << u8"Ƶ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
/** 4. <20><>ʼ<EFBFBD><CABC><EFBFBD>ز<EFBFBD> **************************************************************************************************/
|
|||
|
qDebug() << u8"4.<2E><>ʼ<EFBFBD><CABC><EFBFBD>ز<EFBFBD>";
|
|||
|
std::shared_ptr<cuComplex> phdata (createEchoPhase_mallocHost(gpspoints, freqpoints),FreeCUDAHost);
|
|||
|
qDebug() << "Azimuth Points:\t"<<gpspoints;
|
|||
|
qDebug() << "Range Points:\t"<< freqpoints;
|
|||
|
qDebug() << u8"<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
/** 5. <20><>ʼ<EFBFBD><CABC>ͼ<EFBFBD><CDBC> **************************************************************************************************/
|
|||
|
qDebug() << u8"5.<2E><>ʼ<EFBFBD><CABC>ͼ<EFBFBD><CDBC>";
|
|||
|
std::shared_ptr<cuComplex> im_final(createEchoPhase_mallocHost(dem_rowCount, dem_ColCount), FreeCUDAHost);
|
|||
|
qDebug() << "Azimuth Points:\t" << gpspoints;
|
|||
|
qDebug() << "Range Points:\t" << freqpoints;
|
|||
|
qDebug() << u8"<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
|
|||
|
/** 6. ģ<>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC> **************************************************************************************************/
|
|||
|
qDebug() << u8"6.ģ<>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>";
|
|||
|
GPUDATA h_data;
|
|||
|
h_data.AntX = antX.get();
|
|||
|
h_data.AntX = antY.get();
|
|||
|
h_data.AntX = antZ.get();
|
|||
|
|
|||
|
h_data.x_mat = imgX.get();
|
|||
|
h_data.y_mat = imgY.get();
|
|||
|
h_data.z_mat = imgZ.get();
|
|||
|
|
|||
|
h_data.Freq = freqlist.get();
|
|||
|
h_data.Nfft = freqpoints;
|
|||
|
h_data.K = h_data.Nfft;
|
|||
|
h_data.phdata = phdata.get();
|
|||
|
h_data.im_final = im_final.get();
|
|||
|
qDebug() << u8"ģ<EFBFBD>Ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
|
|||
|
|
|||
|
/** 7. Ŀ<><C4BF> **************************************************************************************************/
|
|||
|
double Tx = -2028380.625000, Ty = 4139373.250000, Tz = 4393382.500000;
|
|||
|
double Tslx = -2028380.625000, Tsly = 4139373.250000, Tslz = 4393382.500000;
|
|||
|
|
|||
|
double p1 = 1, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0;
|
|||
|
|
|||
|
/** 7. <20><><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD> **************************************************************************************************/
|
|||
|
GPUDATA d_data;
|
|||
|
initGPUData(h_data, d_data);
|
|||
|
|
|||
|
RFPCProcess(Tx, Ty, Tz,
|
|||
|
Tslx, Tsly, Tslz, // Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
p1, p2, p3, p4, p5, p6,
|
|||
|
d_data);
|
|||
|
|
|||
|
HostToDevice(h_data.phdata, d_data.phdata, sizeof(cuComplex) * d_data.Np * d_data.Nfft);
|
|||
|
/** 8. չʾ<D5B9>ز<EFBFBD> **************************************************************************************************/
|
|||
|
ImageShowDialogClass* dialog = new ImageShowDialogClass;
|
|||
|
std::shared_ptr<cuComplex> h_ifftphdata((cuComplex*)mallocCUDAHost(sizeof(cuComplex) * d_data.Np * d_data.Nfft), FreeCUDAHost);
|
|||
|
std::shared_ptr<cuComplex> d_ifftphdata((cuComplex*)mallocCUDADevice(sizeof(cuComplex) * d_data.Np * d_data.Nfft), FreeCUDADevice);
|
|||
|
CUDAIFFT(d_data.phdata, d_ifftphdata.get(), d_data.Np, d_data.Nfft, d_data.Nfft);
|
|||
|
FFTShift1D(d_ifftphdata.get(), d_data.Np, d_data.Nfft);
|
|||
|
DeviceToHost(h_ifftphdata.get(), d_ifftphdata.get(), sizeof(cuComplex) * d_data.Np * d_data.Nfft);
|
|||
|
std::shared_ptr<double> echoAmpArr(new double[d_data.Np * d_data.Nfft], delArrPtr);
|
|||
|
{
|
|||
|
for (long i = 0; i < d_data.Np * d_data.Nfft; i++) {
|
|||
|
echoAmpArr.get()[i] =
|
|||
|
20 * std::log10(std::sqrt(std::pow(h_ifftphdata.get()[i].x, 2) + std::pow(h_ifftphdata.get()[i].y, 2)));
|
|||
|
}
|
|||
|
}
|
|||
|
dialog->load_double_data(echoAmpArr.get(), d_data.Np, d_data.Nfft, QString("ifft"));
|
|||
|
dialog->exec();
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|