同步修改代码

pull/3/head
陈增辉 2024-12-25 18:47:02 +08:00
parent ed617674fa
commit 60568818d6
6 changed files with 53 additions and 38 deletions

View File

@ -132,7 +132,7 @@ ErrorCode SARSimulationImageL1Dataset::OpenOrNew(QString folder, QString filenam
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("ENVI");
std::shared_ptr<GDALDataset> poDstDS(poDriver->Create(this->ImageRasterPath.toUtf8().constData(), colCount, rowCount, 1, GDT_CFloat64, NULL));
std::shared_ptr<GDALDataset> poDstDS(poDriver->Create(this->ImageRasterPath.toUtf8().constData(), colCount, rowCount, 1, GDT_CFloat32, NULL));
GDALFlushCache((GDALDatasetH)poDstDS.get());
poDstDS.reset();
omp_unset_lock(&lock); //
@ -605,7 +605,7 @@ ErrorCode SARSimulationImageL1Dataset::saveAntPos(std::shared_ptr<double> ptr)
return ErrorCode::SUCCESS;
}
std::shared_ptr<std::complex<double>> SARSimulationImageL1Dataset::getImageRaster()
std::shared_ptr<std::complex<float>> SARSimulationImageL1Dataset::getImageRaster()
{
if (this->Rasterlevel != RasterLevel::RasterSLC) {
return nullptr;
@ -614,7 +614,7 @@ std::shared_ptr<std::complex<double>> SARSimulationImageL1Dataset::getImageRaste
return this->getImageRaster(0, this->rowCount);
}
ErrorCode SARSimulationImageL1Dataset::saveImageRaster(std::shared_ptr<std::complex<double>> echoPtr, long startPRF, long PRFLen)
ErrorCode SARSimulationImageL1Dataset::saveImageRaster(std::shared_ptr<std::complex<float>> echoPtr, long startPRF, long PRFLen)
{
if (!(startPRF < this->rowCount)) {
qDebug() << QString::fromStdString(errorCode2errInfo(ErrorCode::ECHO_L0DATA_PRFIDXOUTRANGE));
@ -649,8 +649,8 @@ ErrorCode SARSimulationImageL1Dataset::saveImageRaster(std::shared_ptr<std::comp
return ErrorCode::ECHO_L0DATA_ECHOFILEFORMATERROR;
}
else {
if (gdal_datatype == GDT_CFloat64) {
poBand->RasterIO(GF_Write, 0, startPRF, width, PRFLen, echoPtr.get(), width, PRFLen, GDT_CFloat64, 0, 0);
if (gdal_datatype == GDT_CFloat32) {
poBand->RasterIO(GF_Write, 0, startPRF, width, PRFLen, echoPtr.get(), width, PRFLen, GDT_CFloat32, 0, 0);
GDALFlushCache((GDALDatasetH)rasterDataset.get());
}
else {
@ -663,7 +663,7 @@ ErrorCode SARSimulationImageL1Dataset::saveImageRaster(std::shared_ptr<std::comp
return ErrorCode::SUCCESS;
}
std::shared_ptr<std::complex<double>> SARSimulationImageL1Dataset::getImageRaster(long startPRF, long PRFLen)
std::shared_ptr<std::complex<float>> SARSimulationImageL1Dataset::getImageRaster(long startPRF, long PRFLen)
{
if (this->Rasterlevel != RasterLevel::RasterSLC) {
return nullptr;
@ -695,14 +695,14 @@ std::shared_ptr<std::complex<double>> SARSimulationImageL1Dataset::getImageRaste
long width = rasterDataset->GetRasterXSize();
long height = rasterDataset->GetRasterYSize();
long band_num = rasterDataset->GetRasterCount();
std::shared_ptr<std::complex<double>> temp = nullptr;
std::shared_ptr<std::complex<float>> temp = nullptr;
if (height != this->rowCount || width != this->colCount) {
qDebug() << QString::fromStdString(errorCode2errInfo(ErrorCode::ECHO_L0DATA_ECHOFILEFORMATERROR));
}
else {
if (gdal_datatype == GDT_CFloat64) {
temp = std::shared_ptr<std::complex<double>>(new std::complex<double>[PRFLen * width], delArrPtr);
poBand->RasterIO(GF_Read, 0, startPRF, width, PRFLen, temp.get(), width, PRFLen, GDT_CFloat64, 0, 0);
if (gdal_datatype == GDT_CFloat32) {
temp = std::shared_ptr<std::complex<float>>(new std::complex<float>[PRFLen * width], delArrPtr);
poBand->RasterIO(GF_Read, 0, startPRF, width, PRFLen, temp.get(), width, PRFLen, GDT_CFloat32, 0, 0);
GDALFlushCache((GDALDatasetH)rasterDataset.get());
}
else {
@ -723,7 +723,7 @@ Eigen::MatrixXcd SARSimulationImageL1Dataset::getImageRasterMatrix()
}
std::shared_ptr<std::complex<double>> data = this->getImageRaster();
std::shared_ptr<std::complex<float>> data = this->getImageRaster();
Eigen::MatrixXcd dataimg = Eigen::MatrixXcd::Zero(this->rowCount, this->colCount);
for (long i = 0; i < this->rowCount; i++) {
for (long j = 0; j < this->colCount; j++) {
@ -735,7 +735,7 @@ Eigen::MatrixXcd SARSimulationImageL1Dataset::getImageRasterMatrix()
ErrorCode SARSimulationImageL1Dataset::saveImageRaster(Eigen::MatrixXcd& dataimg, long startPRF)
{
std::shared_ptr<std::complex<double>> data(new std::complex<double>[dataimg.rows()* dataimg.cols()]);
std::shared_ptr<std::complex<float>> data(new std::complex<float>[dataimg.rows()* dataimg.cols()]);
long dataimgrows = dataimg.rows();
long dataimgcols = dataimg.cols();
for (long i = 0; i < dataimgrows; i++) {

View File

@ -57,9 +57,9 @@ public:
std::shared_ptr<double> getAntPos();
ErrorCode saveAntPos(std::shared_ptr<double> ptr); // 注意这个方法很危险,请写入前检查数据是否正确
std::shared_ptr<std::complex<double>> getImageRaster();
ErrorCode saveImageRaster(std::shared_ptr<std::complex<double>> echoPtr, long startPRF, long PRFLen);
std::shared_ptr<std::complex<double>> getImageRaster(long startPRF, long PRFLen);
std::shared_ptr<std::complex<float>> getImageRaster();
ErrorCode saveImageRaster(std::shared_ptr<std::complex<float>> echoPtr, long startPRF, long PRFLen);
std::shared_ptr<std::complex<float>> getImageRaster(long startPRF, long PRFLen);
Eigen::MatrixXcd getImageRasterMatrix();
ErrorCode saveImageRaster(Eigen::MatrixXcd& data, long startPRF);

View File

@ -33,6 +33,9 @@
<Filter Include="BaseTool">
<UniqueIdentifier>{101c627b-537e-4c7f-862c-380d3f7f226f}</UniqueIdentifier>
</Filter>
<Filter Include="GPUTool">
<UniqueIdentifier>{c39dcd9f-dfd6-4d94-8912-7a3f5f719385}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<QtRcc Include="RasterProcessTool.qrc">
@ -210,18 +213,12 @@
<ClInclude Include="BaseTool\GeoOperator.h">
<Filter>BaseTool</Filter>
</ClInclude>
<ClInclude Include="BaseTool\GPUTool.cuh">
<Filter>BaseTool</Filter>
</ClInclude>
<ClInclude Include="BaseTool\ImageOperatorBase.h">
<Filter>BaseTool</Filter>
</ClInclude>
<ClInclude Include="BaseTool\LogInfoCls.h">
<Filter>BaseTool</Filter>
</ClInclude>
<ClInclude Include="BaseTool\QToolProcessBarDialog.h">
<Filter>BaseTool</Filter>
</ClInclude>
<ClInclude Include="BaseTool\RasterToolBase.h">
<Filter>BaseTool</Filter>
</ClInclude>
@ -231,6 +228,15 @@
<ClInclude Include="BaseTool\stdafx.h">
<Filter>BaseTool</Filter>
</ClInclude>
<ClInclude Include="GPUTool\GPUTool.cuh">
<Filter>GPUTool</Filter>
</ClInclude>
<ClInclude Include="GPUTool\GPURTPC.cuh">
<Filter>GPUTool</Filter>
</ClInclude>
<ClInclude Include="GPUTool\GPUTBPImage.cuh">
<Filter>GPUTool</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<QtMoc Include="QMergeRasterProcessDialog.h">
@ -309,8 +315,17 @@
</QtUic>
</ItemGroup>
<ItemGroup>
<CudaCompile Include="BaseTool\GPUTool.cu">
<Filter>BaseTool</Filter>
<CudaCompile Include="GPUTool\GPURTPC.cu">
<Filter>GPUTool</Filter>
</CudaCompile>
<CudaCompile Include="GPUTool\GPUTBPImage.cu">
<Filter>GPUTool</Filter>
</CudaCompile>
<CudaCompile Include="GPUTool\GPUTool.cu">
<Filter>GPUTool</Filter>
</CudaCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
</ItemGroup>
</Project>

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<width>995</width>
<height>400</height>
</rect>
</property>
@ -45,7 +45,7 @@
</size>
</property>
<property name="text">
<string>D:\Programme\vs2022\RasterMergeTest\TestData\outData\GF3_Simulation.xml</string>
<string>D:\Programme\vs2022\RasterMergeTest\LAMPCAE_SCANE\GF3_Simulation.xml</string>
</property>
</widget>
</item>
@ -96,7 +96,7 @@
</size>
</property>
<property name="text">
<string>D:\Programme\vs2022\RasterMergeTest\TestData\outBPImage2\GF3_Simulation</string>
<string>D:\Programme\vs2022\RasterMergeTest\LAMPCAE_SCANE_TBPImage\GF3BPImage</string>
</property>
</widget>
</item>

View File

@ -21,12 +21,12 @@ void CreatePixelXYZ(std::shared_ptr<EchoL0Dataset> echoL0ds, QString outPixelXYZ
gt(1, 0) = 0;
gt(1, 1) = 0;
gt(1, 2) = 1;
gdalImage xyzRaster = CreategdalImage(outPixelXYZPath, prfcount, freqcount, 3, gt, QString(""), false, true);
gdalImage xyzRaster = CreategdalImage(outPixelXYZPath, prfcount, freqcount, 3, gt, QString(""), false, true,true);
std::shared_ptr<double> antpos = echoL0ds->getAntPos();
double dx = LIGHTSPEED / 2 / echoL0ds->getFs();
double Rnear = echoL0ds->getNearRange();
long echocol = 1073741824 / 8 / 4 / prfcount*4;
long echocol = 1073741824 / 8 / 4 / prfcount*32;
std::cout << "echocol:\t " << echocol << std::endl;
echocol = echocol < 3000 ? 3000 : echocol;
long startcolidx = 0;
@ -140,7 +140,7 @@ std::shared_ptr<SARSimulationImageL1Dataset> TBPImageAlgCls::getImageL0()
ErrorCode TBPImageAlgCls::Process(long num_thread)
{
qDebug() << u8"创建成像平面的XYZ";
QString outRasterXYZ = JoinPath(this->L1ds->getoutFolderPath(), this->L0ds->getSimulationTaskName() + "_xyz.tif");
QString outRasterXYZ = JoinPath(this->L1ds->getoutFolderPath(), this->L0ds->getSimulationTaskName() + "_xyz.bin");
CreatePixelXYZ(this->L0ds, outRasterXYZ);
this->outRasterXYZPath = outRasterXYZ;
@ -150,7 +150,7 @@ ErrorCode TBPImageAlgCls::Process(long num_thread)
long imagewidth = this->L1ds->getcolCount();
long blokline = Memory1GB / 8 / 4 / imageheight * 8;
long blokline = Memory1GB / 8 / 4 / imageheight * 32;
blokline = blokline < 1000 ? 1000 : blokline;
long startline = 0;
@ -161,11 +161,11 @@ ErrorCode TBPImageAlgCls::Process(long num_thread)
}
std::cout << "\r[" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString() << "] imgxyz :\t" << startline << "\t-\t" << startline + templine << " / " << imageheight << std::endl;
std::shared_ptr<std::complex<double>> imageRaster = this->L1ds->getImageRaster(startline, templine);
std::shared_ptr<std::complex<float>> imageRaster = this->L1ds->getImageRaster(startline, templine);
for (long i = 0; i < templine; i++) {
for (long j = 0; j < imagewidth; j++) {
imageRaster.get()[i * imagewidth + j] = std::complex<double>(0,0);
imageRaster.get()[i * imagewidth + j] = std::complex<float>(0,0);
}
}
this->L1ds->saveImageRaster(imageRaster, startline,templine);
@ -221,10 +221,10 @@ ErrorCode TBPImageAlgCls::ProcessGPU()
// 按照回波分块,图像分块
long echoBlockline = Memory1GB / 8 / 2 / PlusePoints * 6;
long echoBlockline = Memory1GB / 8 / 2 / PlusePoints * 4;
echoBlockline = echoBlockline < 1 ? 1 : echoBlockline;
long imageBlockline = Memory1GB / 8 / 2 / colCount * 2;
long imageBlockline = Memory1GB / 8 / 2 / colCount * 4;
imageBlockline = imageBlockline < 1 ? 1 : imageBlockline;
gdalImage imageXYZ(this->outRasterXYZPath);
@ -235,13 +235,13 @@ ErrorCode TBPImageAlgCls::ProcessGPU()
if (startimgrowid + imageBlockline >= rowCount) {
tempimgBlockline = rowCount - startimgrowid;
}
std::cout << "\r[" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString() << "] dem:\t" << startimgrowid << "\t-\t" << startimgrowid + tempimgBlockline << std::endl;
std::cout << "\r[" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString() << "] image create :\t" << startimgrowid << "\t-\t" << startimgrowid + tempimgBlockline<<"\t/\t"<< rowCount << std::endl;
// 提取局部pixel x,y,z
std::shared_ptr<float> img_x = readDataArr<float>(imageXYZ,startimgrowid,0,tempimgBlockline,colCount,1,GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
std::shared_ptr<float> img_y = readDataArr<float>(imageXYZ,startimgrowid,0,tempimgBlockline,colCount,2,GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
std::shared_ptr<float> img_z = readDataArr<float>(imageXYZ,startimgrowid,0,tempimgBlockline,colCount,3,GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
std::shared_ptr<std::complex<double>> imgArr = this->L1ds->getImageRaster(startimgrowid, tempimgBlockline);
std::shared_ptr<std::complex<float>> imgArr = this->L1ds->getImageRaster(startimgrowid, tempimgBlockline);
// 获取回波
long startechoid = 0;
for (long startechoid = 0; startechoid < PRFCount; startechoid = startechoid + echoBlockline) {
@ -276,7 +276,7 @@ ErrorCode TBPImageAlgCls::ProcessGPU()
void TBPImageGPUAlg(std::shared_ptr<float> antPx, std::shared_ptr<float> antPy, std::shared_ptr<float> antPz,
std::shared_ptr<float> imgx, std::shared_ptr<float> imgy, std::shared_ptr<float> imgz,
std::shared_ptr<std::complex<double>> echoArr, std::shared_ptr<std::complex<double>> imgArr,
std::shared_ptr<std::complex<double>> echoArr, std::shared_ptr<std::complex<float>> imgArr,
float freq, float fs, float Rnear, float Rfar,
long rowcount, long colcount,
long prfcount, long freqcount

View File

@ -67,7 +67,7 @@ void CreatePixelXYZ(std::shared_ptr<EchoL0Dataset> echoL0ds,QString outPixelXYZP
void TBPImageProcess(QString echofile,QString outImageFolder,QString imagePlanePath,long num_thread);
void TBPImageGPUAlg(std::shared_ptr<float> antPx, std::shared_ptr<float> antPy, std::shared_ptr<float> antPz,
std::shared_ptr<float> img_x, std::shared_ptr<float> img_y, std::shared_ptr<float> img_z,
std::shared_ptr<std::complex<double>> echoArr, std::shared_ptr<std::complex<double>> img_arr,
std::shared_ptr<std::complex<double>> echoArr, std::shared_ptr<std::complex<float>> img_arr,
float freq, float fs, float Rnear, float Rfar,
long rowcount, long colcount,
long prfcount,long freqcount );