2024-11-25 10:09:24 +00:00
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "TBPImageAlgCls.h"
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <cmath>
|
2024-11-27 05:10:40 +00:00
|
|
|
|
#include <QProgressDialog>
|
2024-12-20 15:38:34 +00:00
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include "GPUTool.cuh"
|
2024-11-25 10:09:24 +00:00
|
|
|
|
|
2024-12-20 15:38:34 +00:00
|
|
|
|
void CreatePixelXYZ(std::shared_ptr<EchoL0Dataset> echoL0ds, QString outPixelXYZPath)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ
|
|
|
|
|
long prfcount = echoL0ds->getPluseCount();
|
|
|
|
|
long freqcount = echoL0ds->getPlusePoints();
|
|
|
|
|
Eigen::MatrixXd gt = Eigen::MatrixXd::Zero(2, 3);
|
|
|
|
|
gt(0, 0) = 0;
|
|
|
|
|
gt(0, 1) = 1;
|
|
|
|
|
gt(0, 2) = 0;
|
|
|
|
|
gt(1, 0) = 0;
|
|
|
|
|
gt(1, 1) = 0;
|
|
|
|
|
gt(1, 2) = 1;
|
|
|
|
|
gdalImage xyzRaster = CreategdalImage(outPixelXYZPath, prfcount, freqcount, 3, gt, QString(""), false, 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;
|
|
|
|
|
std::cout << "echocol:\t " << echocol << std::endl;
|
|
|
|
|
echocol = echocol < 3000 ? 3000 : echocol;
|
|
|
|
|
long startcolidx = 0;
|
|
|
|
|
for (startcolidx = 0; startcolidx < freqcount; startcolidx = startcolidx + echocol) {
|
|
|
|
|
|
|
|
|
|
long tempechocol = echocol;
|
|
|
|
|
if (startcolidx + tempechocol >= freqcount) {
|
|
|
|
|
tempechocol = freqcount - startcolidx;
|
|
|
|
|
}
|
|
|
|
|
std::cout << "\r[" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString() << "] imgxyz :\t" << startcolidx << "\t-\t" << startcolidx + tempechocol << " / " << freqcount << std::endl;
|
|
|
|
|
|
|
|
|
|
Eigen::MatrixXd demx = xyzRaster.getData(0, startcolidx, prfcount, tempechocol, 1);
|
|
|
|
|
Eigen::MatrixXd demy = xyzRaster.getData(0, startcolidx, prfcount, tempechocol, 2);
|
|
|
|
|
Eigen::MatrixXd demz = xyzRaster.getData(0, startcolidx, prfcount, tempechocol, 3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (long i = 0; i < prfcount; i++) {
|
|
|
|
|
|
|
|
|
|
double Px = 0;
|
|
|
|
|
double Py = 0;
|
|
|
|
|
double Pz = 0;
|
|
|
|
|
|
|
|
|
|
double AntDirectX = 0;
|
|
|
|
|
double AntDirectY = 0;
|
|
|
|
|
double AntDirectZ = 0;
|
|
|
|
|
double R = 0;
|
|
|
|
|
double NormAnt = 0;
|
|
|
|
|
|
|
|
|
|
Px = antpos.get()[i * 19 + 1];
|
|
|
|
|
Py = antpos.get()[i * 19 + 2];
|
|
|
|
|
Pz = antpos.get()[i * 19 + 3];
|
|
|
|
|
AntDirectX = antpos.get()[i * 19 + 13];// zero doppler
|
|
|
|
|
AntDirectY = antpos.get()[i * 19 + 14];
|
|
|
|
|
AntDirectZ = antpos.get()[i * 19 + 15];
|
|
|
|
|
|
|
|
|
|
NormAnt = std::sqrt(AntDirectX * AntDirectX + AntDirectY * AntDirectY + AntDirectZ * AntDirectZ);
|
|
|
|
|
AntDirectX = AntDirectX / NormAnt;
|
|
|
|
|
AntDirectY = AntDirectY / NormAnt;
|
|
|
|
|
AntDirectZ = AntDirectZ / NormAnt;// <20><>һ<EFBFBD><D2BB>
|
|
|
|
|
for (long j = 0; j < tempechocol; j++) {
|
|
|
|
|
R = (j + startcolidx)*dx + Rnear;
|
|
|
|
|
demx(i,j) = Px + AntDirectX * R;
|
|
|
|
|
demy(i,j) = Py + AntDirectY * R;
|
|
|
|
|
demz(i,j) = Pz + AntDirectZ * R;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xyzRaster.saveImage(demx, 0, startcolidx, 1);
|
|
|
|
|
xyzRaster.saveImage(demy, 0, startcolidx, 2);
|
|
|
|
|
xyzRaster.saveImage(demz, 0, startcolidx, 3);
|
|
|
|
|
}
|
2024-11-29 15:32:50 +00:00
|
|
|
|
|
2024-12-20 15:38:34 +00:00
|
|
|
|
}
|
2024-11-29 15:32:50 +00:00
|
|
|
|
|
2024-11-25 10:09:24 +00:00
|
|
|
|
void TBPImageProcess(QString echofile, QString outImageFolder, QString imagePlanePath,long num_thread)
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<EchoL0Dataset> echoL0ds(new EchoL0Dataset);
|
|
|
|
|
echoL0ds->Open(echofile);
|
|
|
|
|
|
|
|
|
|
std::shared_ptr< SARSimulationImageL1Dataset> imagL1(new SARSimulationImageL1Dataset);
|
|
|
|
|
imagL1->setCenterAngle(echoL0ds->getCenterAngle());
|
|
|
|
|
imagL1->setCenterFreq(echoL0ds->getCenterFreq());
|
|
|
|
|
imagL1->setNearRange(echoL0ds->getNearRange());
|
|
|
|
|
imagL1->setRefRange((echoL0ds->getNearRange() + echoL0ds->getFarRange()) / 2);
|
|
|
|
|
imagL1->setFarRange(echoL0ds->getFarRange());
|
|
|
|
|
imagL1->setFs(echoL0ds->getFs());
|
|
|
|
|
imagL1->setLookSide(echoL0ds->getLookSide());
|
|
|
|
|
imagL1->OpenOrNew(outImageFolder, echoL0ds->getSimulationTaskName(), echoL0ds->getPluseCount(), echoL0ds->getPlusePoints());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TBPImageAlgCls TBPimag;
|
|
|
|
|
TBPimag.setEchoL0(echoL0ds);
|
|
|
|
|
TBPimag.setImageL1(imagL1);
|
|
|
|
|
TBPimag.setImagePlanePath(imagePlanePath);
|
|
|
|
|
|
|
|
|
|
TBPimag.Process(num_thread);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-20 15:38:34 +00:00
|
|
|
|
|
|
|
|
|
|
2024-11-25 10:09:24 +00:00
|
|
|
|
void TBPImageAlgCls::setImagePlanePath(QString INimagePlanePath)
|
|
|
|
|
{
|
|
|
|
|
this->imagePlanePath = INimagePlanePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString TBPImageAlgCls::getImagePlanePath()
|
|
|
|
|
{
|
|
|
|
|
return this->imagePlanePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TBPImageAlgCls::setEchoL0(std::shared_ptr<EchoL0Dataset> inL0ds)
|
|
|
|
|
{
|
|
|
|
|
this->L0ds = inL0ds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TBPImageAlgCls::setImageL1(std::shared_ptr<SARSimulationImageL1Dataset> inL1ds)
|
|
|
|
|
{
|
|
|
|
|
this->L1ds = inL1ds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<EchoL0Dataset> TBPImageAlgCls::getEchoL1()
|
|
|
|
|
{
|
|
|
|
|
return this->L0ds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<SARSimulationImageL1Dataset> TBPImageAlgCls::getImageL0()
|
|
|
|
|
{
|
|
|
|
|
return this->L1ds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ErrorCode TBPImageAlgCls::Process(long num_thread)
|
|
|
|
|
{
|
2024-12-20 15:38:34 +00:00
|
|
|
|
qDebug() << u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>XYZ";
|
|
|
|
|
QString outRasterXYZ = JoinPath(this->L1ds->getoutFolderPath(), this->L0ds->getSimulationTaskName() + "_xyz.tif");
|
|
|
|
|
CreatePixelXYZ(this->L0ds, outRasterXYZ);
|
|
|
|
|
this->outRasterXYZPath = outRasterXYZ;
|
|
|
|
|
|
|
|
|
|
// <20><>ʼ<EFBFBD><CABC>Raster
|
|
|
|
|
qDebug() << u8"<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD>";
|
|
|
|
|
long imageheight = this->L1ds->getrowCount();
|
|
|
|
|
long imagewidth = this->L1ds->getcolCount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long blokline = Memory1GB / 8 / 4 / imageheight * 8;
|
|
|
|
|
blokline = blokline < 1000 ? 1000 : blokline;
|
|
|
|
|
|
|
|
|
|
long startline = 0;
|
|
|
|
|
for (startline = 0; startline < imageheight; startline = startline + blokline) {
|
|
|
|
|
long templine = blokline;
|
|
|
|
|
if (startline + templine >= imageheight) {
|
|
|
|
|
templine = imageheight - startline;
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
for (long i = 0; i < templine; i++) {
|
|
|
|
|
for (long j = 0; j < imagewidth; j++) {
|
|
|
|
|
imageRaster.get()[i * imagewidth + j] = std::complex<double>(0,0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this->L1ds->saveImageRaster(imageRaster, startline,templine);
|
|
|
|
|
}
|
|
|
|
|
qDebug() << u8"<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
2024-11-25 17:51:20 +00:00
|
|
|
|
if (GPURUN) {
|
2024-11-29 15:32:50 +00:00
|
|
|
|
return this->ProcessGPU();
|
2024-11-25 17:51:20 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2024-12-20 15:38:34 +00:00
|
|
|
|
QMessageBox::information(nullptr,u8"<EFBFBD><EFBFBD>ʾ",u8"Ŀǰֻ֧<EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD>");
|
|
|
|
|
return ErrorCode::FAIL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ErrorCode TBPImageAlgCls::ProcessGPU()
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
|
|
|
|
|
long rowCount = this->L1ds->getrowCount();
|
|
|
|
|
long colCount = this->L1ds->getcolCount();
|
|
|
|
|
long pixelCount = rowCount * colCount;
|
|
|
|
|
long PRFCount = this->L0ds->getPluseCount();
|
|
|
|
|
long PlusePoints = this->L0ds->getPlusePoints();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float Rnear = this->L1ds->getNearRange();
|
|
|
|
|
float Rfar = this->L1ds->getFarRange();
|
|
|
|
|
float fs = this->L1ds->getFs();
|
|
|
|
|
double dx = LIGHTSPEED / 2 / fs;
|
|
|
|
|
float freq = this->L1ds->getCenterFreq()*1.0*1e9;
|
|
|
|
|
double factorj = freq * 4 * M_PI / LIGHTSPEED ;
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<float> Pxs (new float[this->L0ds->getPluseCount()]);
|
|
|
|
|
std::shared_ptr<float> Pys (new float[this->L0ds->getPluseCount()]);
|
|
|
|
|
std::shared_ptr<float> Pzs (new float[this->L0ds->getPluseCount()]);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<double> antpos = this->L0ds->getAntPos();
|
|
|
|
|
double time = 0;
|
|
|
|
|
double Px = 0;
|
|
|
|
|
double Py = 0;
|
|
|
|
|
double Pz = 0;
|
|
|
|
|
for (long i = 0; i < rowCount; i++) {
|
|
|
|
|
time = antpos.get()[i *19 + 0];
|
|
|
|
|
Px = antpos.get()[i *19 + 1];
|
|
|
|
|
Py = antpos.get()[i *19 + 2];
|
|
|
|
|
Pz = antpos.get()[i *19 + 3];
|
|
|
|
|
Pxs.get()[i] = Px;
|
|
|
|
|
Pys.get()[i] = Py;
|
|
|
|
|
Pzs.get()[i] = Pz;
|
|
|
|
|
}
|
|
|
|
|
antpos.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ջز<D5BB><D8B2>ֿ飬ͼ<E9A3AC><CDBC><EFBFBD>ֿ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
long echoBlockline = Memory1GB / 8 / 2 / PlusePoints * 6;
|
|
|
|
|
echoBlockline = echoBlockline < 1 ? 1 : echoBlockline;
|
|
|
|
|
|
|
|
|
|
long imageBlockline = Memory1GB / 8 / 2 / colCount * 2;
|
|
|
|
|
imageBlockline = imageBlockline < 1 ? 1 : imageBlockline;
|
|
|
|
|
|
|
|
|
|
gdalImage imageXYZ(this->outRasterXYZPath);
|
|
|
|
|
|
|
|
|
|
long startimgrowid = 0;
|
|
|
|
|
for (startimgrowid = 0; startimgrowid < rowCount; startimgrowid = startimgrowid + imageBlockline) {
|
|
|
|
|
long tempimgBlockline = imageBlockline;
|
|
|
|
|
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;
|
|
|
|
|
// <20><>ȡ<EFBFBD>ֲ<EFBFBD>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);
|
|
|
|
|
// <20><>ȡ<EFBFBD>ز<EFBFBD>
|
|
|
|
|
long startechoid = 0;
|
|
|
|
|
for (long startechoid = 0; startechoid < PRFCount; startechoid = startechoid + echoBlockline) {
|
|
|
|
|
long tempechoBlockline = echoBlockline;
|
|
|
|
|
if (startechoid + tempechoBlockline >= PRFCount) {
|
|
|
|
|
tempechoBlockline = PRFCount - startechoid;
|
|
|
|
|
}
|
|
|
|
|
std::shared_ptr<std::complex<double>> echoArr = this->L0ds->getEchoArr(startechoid, tempechoBlockline);
|
|
|
|
|
std::shared_ptr<float> antpx(new float[tempechoBlockline*PlusePoints]);
|
|
|
|
|
std::shared_ptr<float> antpy(new float[tempechoBlockline* PlusePoints]);
|
|
|
|
|
std::shared_ptr<float> antpz(new float[tempechoBlockline* PlusePoints]);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
for (long anti = 0; anti < tempechoBlockline; anti++) {
|
|
|
|
|
antpx.get()[anti] = Pxs.get()[anti + startechoid];
|
|
|
|
|
antpy.get()[anti] = Pys.get()[anti + startechoid];
|
|
|
|
|
antpz.get()[anti] = Pzs.get()[anti + startechoid];
|
|
|
|
|
}
|
|
|
|
|
TBPImageGPUAlg(antpx, antpy, antpz,
|
|
|
|
|
img_x, img_y, img_z,
|
|
|
|
|
echoArr, imgArr,
|
|
|
|
|
freq, fs, Rnear, Rfar,
|
|
|
|
|
tempimgBlockline, colCount,
|
|
|
|
|
tempechoBlockline, PlusePoints );
|
|
|
|
|
}
|
|
|
|
|
this->L1ds->saveImageRaster(imgArr, startimgrowid, tempimgBlockline);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qDebug() << "\r[" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") << "] image writing:\t" << this->L1ds->getxmlFilePath();
|
|
|
|
|
|
|
|
|
|
return ErrorCode::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
float freq, float fs, float Rnear, float Rfar,
|
|
|
|
|
long rowcount, long colcount,
|
|
|
|
|
long prfcount, long freqcount
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>GPU<50><55><EFBFBD><EFBFBD>
|
|
|
|
|
float* h_antPx = (float*)mallocCUDAHost(sizeof(float) * prfcount);
|
|
|
|
|
float* h_antPy = (float*)mallocCUDAHost(sizeof(float) * prfcount);
|
|
|
|
|
float* h_antPz = (float*)mallocCUDAHost(sizeof(float) * prfcount);
|
|
|
|
|
float* d_antPx = (float*)mallocCUDADevice(sizeof(float) * prfcount);
|
|
|
|
|
float* d_antPy = (float*)mallocCUDADevice(sizeof(float) * prfcount);
|
|
|
|
|
float* d_antPz = (float*)mallocCUDADevice(sizeof(float) * prfcount);
|
|
|
|
|
|
|
|
|
|
float* h_imgx = (float*)mallocCUDAHost(sizeof(float) * rowcount * colcount);
|
|
|
|
|
float* h_imgy = (float*)mallocCUDAHost(sizeof(float) * rowcount * colcount);
|
|
|
|
|
float* h_imgz = (float*)mallocCUDAHost(sizeof(float) * rowcount * colcount);
|
|
|
|
|
float* d_imgx = (float*)mallocCUDADevice(sizeof(float) * rowcount * colcount);
|
|
|
|
|
float* d_imgy = (float*)mallocCUDADevice(sizeof(float) * rowcount * colcount);
|
|
|
|
|
float* d_imgz = (float*)mallocCUDADevice(sizeof(float) * rowcount * colcount);
|
|
|
|
|
|
|
|
|
|
cuComplex* h_echoArr = (cuComplex*)mallocCUDAHost(sizeof(cuComplex) * prfcount * freqcount);
|
|
|
|
|
cuComplex* h_imgArr = (cuComplex*)mallocCUDAHost(sizeof(cuComplex) * rowcount * colcount);
|
|
|
|
|
cuComplex* d_echoArr = (cuComplex*)mallocCUDADevice(sizeof(cuComplex) * prfcount * freqcount);
|
|
|
|
|
cuComplex* d_imgArr = (cuComplex*)mallocCUDADevice( sizeof(cuComplex) * rowcount * colcount);
|
|
|
|
|
|
|
|
|
|
// <20><>ʼ<EFBFBD><CABC>
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
for (long i = 0; i < prfcount; i++) {
|
|
|
|
|
h_antPx[i] = antPx.get()[i];
|
|
|
|
|
h_antPy[i] = antPy.get()[i];
|
|
|
|
|
h_antPz[i] = antPz.get()[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>
|
|
|
|
|
for (long i = 0; i < rowcount; i++) {
|
|
|
|
|
for (long j = 0; j < colcount; j++) {
|
|
|
|
|
h_imgx[i * colcount + j]=imgx.get()[i * colcount + j];
|
|
|
|
|
h_imgy[i * colcount + j]=imgy.get()[i * colcount + j];
|
|
|
|
|
h_imgz[i * colcount + j]=imgz.get()[i * colcount + j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20>ز<EFBFBD>
|
|
|
|
|
for (long i = 0; i < prfcount; i++) {
|
|
|
|
|
for (long j = 0; j < freqcount; j++) {
|
|
|
|
|
h_echoArr[i * freqcount + j] = make_cuComplex(echoArr.get()[i * freqcount + j].real(),
|
|
|
|
|
echoArr.get()[i * freqcount + j].imag());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ͼ<><CDBC>
|
|
|
|
|
for (long i = 0; i < rowcount; i++) {
|
|
|
|
|
for (long j = 0; j < colcount; j++) {
|
|
|
|
|
h_imgArr[i * colcount + j].x = imgArr.get()[i * colcount + j].real();
|
|
|
|
|
h_imgArr[i * colcount + j].y = imgArr.get()[i * colcount + j].imag();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Host -> GPU
|
|
|
|
|
HostToDevice(h_antPx, d_antPx, sizeof(float) * prfcount);
|
|
|
|
|
HostToDevice(h_antPy, d_antPy, sizeof(float) * prfcount);
|
|
|
|
|
HostToDevice(h_antPz, d_antPz, sizeof(float) * prfcount);
|
|
|
|
|
HostToDevice(h_imgx, d_imgx, sizeof(float) * rowcount * colcount);
|
|
|
|
|
HostToDevice(h_imgy, d_imgy, sizeof(float) * rowcount * colcount);
|
|
|
|
|
HostToDevice(h_imgz, d_imgz, sizeof(float) * rowcount * colcount);
|
|
|
|
|
HostToDevice(h_echoArr, d_echoArr, sizeof(cuComplex) * prfcount * freqcount);
|
|
|
|
|
HostToDevice(h_imgArr, d_imgArr, sizeof(cuComplex) * rowcount * colcount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (long prfid = 0; prfid < prfcount; prfid++) {
|
|
|
|
|
CUDATBPImage(
|
|
|
|
|
d_antPx,
|
|
|
|
|
d_antPy,
|
|
|
|
|
d_antPz,
|
|
|
|
|
d_imgx,
|
|
|
|
|
d_imgy,
|
|
|
|
|
d_imgz,
|
|
|
|
|
d_echoArr,
|
|
|
|
|
d_imgArr,
|
|
|
|
|
freq, fs, Rnear, Rfar,
|
|
|
|
|
rowcount, colcount,
|
|
|
|
|
prfid, freqcount
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Device -> Host
|
|
|
|
|
DeviceToHost(h_imgArr, d_imgArr, sizeof(cuComplex) * rowcount * colcount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (long i = 0; i < rowcount; i++) {
|
|
|
|
|
for (long j = 0; j < colcount; j++) {
|
|
|
|
|
imgArr.get()[i * colcount + j] = std::complex<double>(h_imgArr[i * colcount + j].x,
|
|
|
|
|
h_imgArr[i * colcount + j].y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FreeCUDAHost(h_antPx);
|
|
|
|
|
FreeCUDAHost(h_antPy);
|
|
|
|
|
FreeCUDAHost(h_antPz);
|
|
|
|
|
FreeCUDADevice(d_antPx);
|
|
|
|
|
FreeCUDADevice(d_antPy);
|
|
|
|
|
FreeCUDADevice(d_antPz);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FreeCUDAHost(h_imgx);
|
|
|
|
|
FreeCUDAHost(h_imgy);
|
|
|
|
|
FreeCUDAHost(h_imgz);
|
|
|
|
|
FreeCUDADevice(d_imgx);
|
|
|
|
|
FreeCUDADevice(d_imgy);
|
|
|
|
|
FreeCUDADevice(d_imgz);
|
|
|
|
|
|
|
|
|
|
FreeCUDAHost(h_echoArr);
|
|
|
|
|
FreeCUDAHost(h_imgArr);
|
|
|
|
|
FreeCUDADevice(d_echoArr);
|
|
|
|
|
FreeCUDADevice(d_imgArr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20>ͷ<EFBFBD>GPU<50><55><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TBPImageAlgCls::setGPU(bool flag)
|
|
|
|
|
{
|
|
|
|
|
this->GPURUN = flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TBPImageAlgCls::getGPU( )
|
|
|
|
|
{
|
|
|
|
|
return this->GPURUN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// TBP GPU<50><55><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="antpos_ptr"><3E><><EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="echoArr"><3E>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="img_arr">ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
void TBPImageGPUAlg(std::shared_ptr<float> antPx, std::shared_ptr<float> antPy, std::shared_ptr<float> antPz, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
std::shared_ptr<float> antVx, std::shared_ptr<float> antVy, std::shared_ptr<float> antVz,
|
|
|
|
|
std::shared_ptr<float> img_x, std::shared_ptr<float> img_y, std::shared_ptr<float> img_z, // ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
std::shared_ptr<std::complex<double>> echoArr, std::shared_ptr<std::complex<double>> img_arr,
|
|
|
|
|
float freq, float fs, float Rnear, float Rfar,
|
|
|
|
|
long rowcount, long colcount, std::shared_ptr<SARSimulationImageL1Dataset> L1ds) {
|
|
|
|
|
|
|
|
|
|
float factorj = freq * 4 * PI / LIGHTSPEED;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "factorj:\t" << factorj;
|
|
|
|
|
qDebug() << "freq:\t" << freq;
|
|
|
|
|
qDebug() << "fs:\t" << fs;
|
|
|
|
|
qDebug() << "Rnear:\t" << Rnear;
|
|
|
|
|
qDebug() << "Rfar:\t" << Rfar;
|
|
|
|
|
|
|
|
|
|
qDebug() << "img_x:\t" << img_x.get()[0];
|
|
|
|
|
qDebug() << "img_y:\t" << img_y.get()[0];
|
|
|
|
|
qDebug() << "img_z:\t" << img_z.get()[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long blockline = Memory1MB * 1000 / sizeof(float) / colcount;
|
|
|
|
|
blockline = blockline < 10 ? 10 : blockline;
|
|
|
|
|
for (long startline = 0; startline < rowcount; startline = startline + blockline) {
|
|
|
|
|
long stepline = startline + blockline < rowcount ? blockline : rowcount - startline;
|
|
|
|
|
std::cout << startline << " \ " << rowcount << " "<< stepline << " start " << std::endl;
|
|
|
|
|
//TBPImageGPUBlock(antPx.get(), antPy.get(), antPz.get(), img_x.get(), img_y.get(), img_z.get(),
|
|
|
|
|
// echoArr, rowcount, colcount,
|
|
|
|
|
// img_arr,
|
|
|
|
|
// freq, fs, Rnear, Rfar, factorj, startline, stepline,
|
|
|
|
|
// stepline, colcount);
|
|
|
|
|
//std::cout << startline << " \ " << rowcount << " " << stepline << " end " << std::endl;
|
|
|
|
|
//L1ds->saveImageRaster(img_arr, 0, rowcount);
|
2024-11-25 17:51:20 +00:00
|
|
|
|
}
|
2024-12-20 15:38:34 +00:00
|
|
|
|
L1ds->saveImageRaster(img_arr, 0, rowcount);
|
|
|
|
|
|
|
|
|
|
L1ds->saveToXml();
|
2024-11-25 10:09:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-12-20 15:38:34 +00:00
|
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
|
2024-11-25 17:51:20 +00:00
|
|
|
|
ErrorCode TBPImageAlgCls::ProcessCPU(long num_thread)
|
2024-11-25 10:09:24 +00:00
|
|
|
|
{
|
|
|
|
|
omp_set_num_threads(num_thread);
|
|
|
|
|
// <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
|
|
|
|
|
long rowCount = this->L1ds->getrowCount();
|
|
|
|
|
long colCount = this->L1ds->getcolCount();
|
|
|
|
|
long pixelCount = rowCount * colCount;
|
|
|
|
|
long PRFCount = this->L0ds->getPluseCount();
|
|
|
|
|
long PlusePoints = this->L0ds->getPlusePoints();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double Rnear = this->L1ds->getNearRange();
|
|
|
|
|
double Rfar = this->L1ds->getFarRange();
|
|
|
|
|
double fs = this->L1ds->getFs();
|
|
|
|
|
double dx = LIGHTSPEED / 2 / fs;
|
|
|
|
|
double factorj = this->L1ds->getCenterFreq() * 4 * M_PI / LIGHTSPEED * 1e9;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Eigen::MatrixXcd echo = Eigen::MatrixXcd::Zero(PRFCount, PlusePoints);
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<std::complex<double>> echodata = this->L0ds->getEchoArr();
|
|
|
|
|
for (long i = 0; i < PRFCount; i++) {
|
|
|
|
|
for (long j = 0; j < PlusePoints; j++) {
|
|
|
|
|
echo(i, j) = echodata.get()[i * PlusePoints + j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echodata.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Eigen::MatrixXd pixelX = Eigen::MatrixXd::Zero(rowCount, colCount);
|
|
|
|
|
Eigen::MatrixXd pixelY = Eigen::MatrixXd::Zero(rowCount, colCount);
|
|
|
|
|
Eigen::MatrixXd pixelZ = Eigen::MatrixXd::Zero(rowCount, colCount);
|
|
|
|
|
|
|
|
|
|
Eigen::MatrixXd Pxs = Eigen::MatrixXd::Zero(this->L0ds->getPluseCount(), 1);
|
|
|
|
|
Eigen::MatrixXd Pys = Eigen::MatrixXd::Zero(this->L0ds->getPluseCount(), 1);
|
|
|
|
|
Eigen::MatrixXd Pzs = Eigen::MatrixXd::Zero(this->L0ds->getPluseCount(), 1);
|
|
|
|
|
|
|
|
|
|
// ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<double> antpos = this->L0ds->getAntPos();
|
|
|
|
|
double time = 0;
|
|
|
|
|
double Px = 0;
|
|
|
|
|
double Py = 0;
|
|
|
|
|
double Pz = 0;
|
|
|
|
|
double Vx = 0;
|
|
|
|
|
double Vy = 0;
|
|
|
|
|
double Vz = 0;
|
|
|
|
|
double AntDirectX = 0;
|
|
|
|
|
double AntDirectY = 0;
|
|
|
|
|
double AntDirectZ = 0;
|
|
|
|
|
double AVx = 0;
|
|
|
|
|
double AVy = 0;
|
|
|
|
|
double AVz = 0;
|
|
|
|
|
|
|
|
|
|
double R = 0;
|
|
|
|
|
double NormAnt = 0;
|
|
|
|
|
|
|
|
|
|
for (long i = 0; i < rowCount; i++) {
|
2024-12-20 15:38:34 +00:00
|
|
|
|
time = antpos.get()[i * 19 + 0];
|
|
|
|
|
Px = antpos.get()[i * 19 + 1];
|
|
|
|
|
Py = antpos.get()[i * 19 + 2];
|
|
|
|
|
Pz = antpos.get()[i * 19 + 3];
|
|
|
|
|
Vx = antpos.get()[i * 19 + 4];
|
|
|
|
|
Vy = antpos.get()[i * 19 + 5];
|
|
|
|
|
Vz = antpos.get()[i * 19 + 6];
|
|
|
|
|
AntDirectX = antpos.get()[i * 19 + 13]; // Zero doppler
|
|
|
|
|
AntDirectY = antpos.get()[i * 19 + 14];
|
|
|
|
|
AntDirectZ = antpos.get()[i * 19 + 15];
|
|
|
|
|
AVx = antpos.get()[i * 19 + 10];
|
|
|
|
|
AVy = antpos.get()[i * 19 + 11];
|
|
|
|
|
AVz = antpos.get()[i * 19 + 12];
|
2024-11-25 10:09:24 +00:00
|
|
|
|
|
|
|
|
|
NormAnt = std::sqrt(AntDirectX * AntDirectX + AntDirectY * AntDirectY + AntDirectZ * AntDirectZ);
|
|
|
|
|
AntDirectX = AntDirectX / NormAnt;
|
|
|
|
|
AntDirectY = AntDirectY / NormAnt;
|
|
|
|
|
AntDirectZ = AntDirectZ / NormAnt;// <20><>һ<EFBFBD><D2BB>
|
|
|
|
|
|
2024-12-20 15:38:34 +00:00
|
|
|
|
antpos.get()[i * 19 + 13] = AntDirectX;
|
|
|
|
|
antpos.get()[i * 19 + 14] = AntDirectY;
|
|
|
|
|
antpos.get()[i * 19 + 15] = AntDirectZ;
|
2024-11-25 10:09:24 +00:00
|
|
|
|
Pxs(i, 0) = Px;
|
|
|
|
|
Pys(i, 0) = Py;
|
|
|
|
|
Pzs(i, 0) = Pz;
|
|
|
|
|
|
|
|
|
|
for (long j = 0; j < colCount; j++) {
|
|
|
|
|
R = j * dx + Rnear;
|
|
|
|
|
pixelX(i, j) = Px + AntDirectX * R;
|
|
|
|
|
pixelY(i, j) = Py + AntDirectY * R;
|
|
|
|
|
pixelZ(i, j) = Pz + AntDirectZ * R;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->L1ds->saveAntPos(antpos);
|
|
|
|
|
antpos.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BP<42><50><EFBFBD><EFBFBD>
|
|
|
|
|
long BlockLine = Memory1MB * 10 / 16 / rowCount;
|
|
|
|
|
if (rowCount / BlockLine / num_thread < 3) {
|
|
|
|
|
BlockLine = rowCount / num_thread / 3;
|
|
|
|
|
}
|
|
|
|
|
BlockLine = BlockLine > 10 ? BlockLine : 10;
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<std::complex<double>> imagarr = this->L1ds->getImageRaster();
|
|
|
|
|
{
|
|
|
|
|
for (long i = 0; i < pixelCount; i++) {
|
|
|
|
|
imagarr.get()[i] = imagarr.get()[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
omp_lock_t lock; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
omp_init_lock(&lock); // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
long writeImageCount = 0;
|
|
|
|
|
qDebug() << "block line:\t" << BlockLine;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long startLine = 0;
|
|
|
|
|
long processValue = 0;
|
2024-11-27 05:10:40 +00:00
|
|
|
|
long processNumber = 0;
|
|
|
|
|
QProgressDialog progressDialog(u8"RTPC<EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD>ֹ", 0, rowCount);
|
|
|
|
|
progressDialog.setWindowTitle(u8"RTPC<EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
progressDialog.setWindowModality(Qt::WindowModal);
|
|
|
|
|
progressDialog.setAutoClose(true);
|
|
|
|
|
progressDialog.setValue(0);
|
|
|
|
|
progressDialog.setMaximum(rowCount);
|
|
|
|
|
progressDialog.setMinimum(0);
|
|
|
|
|
progressDialog.show();
|
2024-11-25 10:09:24 +00:00
|
|
|
|
|
|
|
|
|
#pragma omp parallel for
|
|
|
|
|
for (startLine = 0; startLine < rowCount; startLine = startLine + BlockLine) { // ͼ<><CDBC><EFBFBD><EFBFBD>С
|
|
|
|
|
long stepLine = startLine + BlockLine < rowCount ? BlockLine : rowCount - startLine;
|
|
|
|
|
long imageRowID = startLine; //
|
|
|
|
|
|
|
|
|
|
//Eigen::MatrixXd R = Eigen::MatrixXd::Zero(rowCount, 1);
|
|
|
|
|
long pluseId = 0;
|
|
|
|
|
std::complex<double> factPhas(0, 0);
|
|
|
|
|
std::complex < double> sign(0, 0);
|
|
|
|
|
Eigen::MatrixXd R = Eigen::MatrixXd::Zero(rowCount, 1);
|
|
|
|
|
Eigen::MatrixXcd Rphi = Eigen::MatrixXd::Zero(rowCount, 1);
|
|
|
|
|
|
|
|
|
|
long PluseIDs = 0;
|
|
|
|
|
double mask = 0;
|
|
|
|
|
|
|
|
|
|
for (long i = 0; i < stepLine; i++) { // ͼ<><CDBC><EFBFBD><EFBFBD>
|
|
|
|
|
imageRowID = startLine + i;
|
|
|
|
|
for (long j = 0; j < colCount; j++) { //ͼ<><CDBC><EFBFBD><EFBFBD>
|
|
|
|
|
R = ((pixelX(i, j) - Pxs.array()).array().pow(2) + (pixelY(i, j) - Pys.array()).array().pow(2) + (pixelZ(i, j) - Pzs.array()).array().pow(2)).array().sqrt();
|
|
|
|
|
Rphi = Rphi.array() * 0;
|
|
|
|
|
Rphi.imag() = R.array() * factorj;
|
|
|
|
|
Rphi = Rphi.array().exp();
|
|
|
|
|
|
|
|
|
|
for (long prfid = 0; prfid < rowCount; prfid++) { // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
PluseIDs = std::floor((R(prfid, 0) - Rnear) / dx);
|
|
|
|
|
mask = (PluseIDs < 0 || PluseIDs >= PlusePoints) ? 0 : 1;
|
|
|
|
|
PluseIDs = (PluseIDs < 0 || PluseIDs >= PlusePoints) ? 0 : PluseIDs;
|
|
|
|
|
imagarr.get()[imageRowID * colCount + j] =
|
|
|
|
|
imagarr.get()[imageRowID * colCount + j] +
|
|
|
|
|
mask * echo(prfid, PluseIDs) * Rphi(prfid, 0);// <20>ź<EFBFBD>* <20><>λУ<CEBB><D0A3>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
omp_set_lock(&lock); // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
processValue = processValue + BlockLine;
|
|
|
|
|
this->L1ds->saveImageRaster(imagarr, 0, rowCount);
|
|
|
|
|
qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz").toUtf8().constData() << "\t" << processValue * 100.0 / rowCount << "%\t" << startLine << "\t-\t" << startLine + BlockLine << "\tend\t\t";
|
2024-11-27 05:10:40 +00:00
|
|
|
|
processNumber = processNumber + BlockLine;
|
|
|
|
|
processNumber = processNumber < progressDialog.maximum() ? processNumber : progressDialog.maximum();
|
|
|
|
|
progressDialog.setValue(processNumber);
|
2024-11-25 10:09:24 +00:00
|
|
|
|
omp_unset_lock(&lock); // <20><><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
omp_destroy_lock(&lock); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
this->L1ds->saveImageRaster(imagarr, 0, rowCount);
|
|
|
|
|
this->L1ds->saveToXml();
|
2024-11-27 05:10:40 +00:00
|
|
|
|
progressDialog.close();
|
2024-11-25 17:51:20 +00:00
|
|
|
|
return ErrorCode::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-29 15:32:50 +00:00
|
|
|
|
|
2024-12-20 15:38:34 +00:00
|
|
|
|
*/
|