Go to file
陈增辉 a62daae92c 修改:
1.所有的RTPC代码全部修改为GPU代码;
2. 增加重值地表覆盖类型
3. 方向图插值修改为GPU代码
4. 后向散射系数函数修改为GPU代码
2024-11-30 21:05:44 +08:00
BaseLibraryCPP@ef94aa388a 代码更新: 2024-11-29 23:32:50 +08:00
GF3ProcessToolbox 为工具增加界面 2024-11-26 01:51:20 +08:00
Imageshow 补充了完整的流程 2024-11-25 14:26:46 +08:00
SimulationSAR 修改: 2024-11-30 21:05:44 +08:00
script 代码更新: 2024-11-29 23:32:50 +08:00
.gitattributes 添加 .gitattributes、.gitignore 和 README.md。 2024-11-15 09:49:01 +08:00
.gitignore 添加 .gitattributes、.gitignore 和 README.md。 2024-11-15 09:49:01 +08:00
.gitmodules 更新 .gitmodules 2024-11-15 18:21:34 +08:00
BackScattering_C_SAR_V3_NOMAP.rar 合并仿真、成像、影像合并的代码 2024-11-25 09:30:14 +08:00
GF3PSTNClass.cpp 合并仿真、成像、影像合并的代码 2024-11-25 09:30:14 +08:00
QMergeRasterProcessDialog.cpp 补充了完整的流程 2024-11-25 14:26:46 +08:00
QMergeRasterProcessDialog.h 增加界面 2024-11-15 17:23:00 +08:00
QMergeRasterProcessDialog.ui 合并仿真、成像、影像合并的代码 2024-11-25 09:30:14 +08:00
QSimulationRTPCGUI.cpp 补充了完整的流程 2024-11-25 14:26:46 +08:00
QSimulationRTPCGUI.h 补充了完整的流程 2024-11-25 14:26:46 +08:00
QSimulationRTPCGUI.ui 将工具以菜单项的方式集成进处理软件界面中 2024-11-25 16:24:38 +08:00
README.md 代码更新: 2024-11-29 23:32:50 +08:00
RasterProcessTool.cpp 为工具增加界面 2024-11-26 01:51:20 +08:00
RasterProcessTool.h 为工具增加界面 2024-11-26 01:51:20 +08:00
RasterProcessTool.qrc 添加项目文件。 2024-11-15 09:49:05 +08:00
RasterProcessTool.sln 添加项目文件。 2024-11-15 09:49:05 +08:00
RasterProcessTool.ui 修改: 2024-11-30 21:05:44 +08:00
RasterProcessTool.vcxproj 修改: 2024-11-30 21:05:44 +08:00
RasterProcessTool.vcxproj.filters 代码更新: 2024-11-29 23:32:50 +08:00
RegisterToolbox.cpp 迁移代码 2024-11-27 13:10:40 +08:00
RegisterToolbox.h 为工具增加界面 2024-11-26 01:51:20 +08:00
main.cpp 为工具增加界面 2024-11-26 01:51:20 +08:00
proj.db 增加界面 2024-11-15 17:23:00 +08:00

README.md

RasterProcessTool

extern "C" void AddCUDA(void* aPtr, void* bptr, void* cptr, long member, LAMPGPUDATETYPE datetype) { int blockSize = 256; // 每个块的线程数 int numBlocks = (member + blockSize - 1) / blockSize; // 根据 pixelcount 计算网格大小

}

// CUDA 核函数 global void computeDistanceAndEchoID(float* antPx, float* antPy, float* antPz, float* img_x, float* img_y, float* img_z, complexfloat* echopluse, complexfloat* imgarr, long rowcount, long colcount, long prfid, float Rnear, float fs, float factorj) {

long  idx = blockIdx.x * blockDim.x + threadIdx.x;
// 确保线程索引有效
if (idx < rowcount * colcount) {

	// 计算距离
	float dx = antPx[prfid] - img_x[idx];
	float dy = antPy[prfid] - img_y[idx];
	float dz = antPz[prfid] - img_z[idx];
	float imgR = sqrt(dx * dx + dy * dy + dz * dz);

	// 计算 EchoID
	long echoID = floor(((imgR - Rnear) * 2 / LIGHTSPEED) * fs);//回波坐标
	float Rftj = imgR * factorj; // 校正
	//printf("%d:(%f,%f),%f,%f  |||||, %f, %f, %f, %f, %f, %f, %f\n", idx, echopluse[echoID].real,  Rftj, imgR, fs,
	//	antPx[prfid], antPy[prfid], antPz[prfid], img_x[idx], img_y[idx], img_z[idx], imgR);
	if (echoID < 0 || echoID >= colcount) {

	}
	else {
		complexfloat Rphi{ 0,Rftj };
		Rphi = expComplex(Rphi);
		imgarr[idx] = addComplex(imgarr[idx], mulComplex(echopluse[echoID], Rphi));
	}
}

}

void TBPImageGPUBlock(float* antPx, float* antPy, float* antPz, float* img_x, float* img_y, float* img_z, std::shared_ptr<std::complex> echoArr, long prfcount, long plusecount, std::shared_ptr<std::complex> imageArr, float freq, float fs, float Rnear, float Rfar, float factorj, long startline, long stepline, long rowcount, long colcount) {

long pixelcount = rowcount * colcount;
complexfloat* h_echopluse;
complexfloat* h_imgarr;

cudaMallocHost(&h_echopluse, sizeof(float) * 2 * plusecount);  // 单个传感器的位置
cudaMallocHost(&h_imgarr, sizeof(float) * 2 * stepline * colcount);

for (long i = 0; i < stepline; i++) {
	long rid = startline + i;
	for (long j = 0; j < colcount; j++) {
		h_imgarr[i * colcount + j].real = imageArr.get()[rid * colcount + j].real();
		h_imgarr[i * colcount + j].imag = imageArr.get()[rid * colcount + j].imag();
	}
}
std::cout << "h_imgarr init finished!!" << std::endl;


float* h_antPx, * h_antPy, * h_antPz;
cudaMallocHost(&h_antPx, sizeof(float) * prfcount);  // 单个传感器的位置
cudaMallocHost(&h_antPy, sizeof(float) * prfcount);
cudaMallocHost(&h_antPz, sizeof(float) * prfcount);

// 初始化
for (long i = 0; i < prfcount; i++) {
	h_antPx[i] = antPx[i];
	h_antPy[i] = antPy[i];
	h_antPz[i] = antPz[i];
}



float* h_img_x, * h_img_y, * h_img_z;
cudaMallocHost(&h_img_x, sizeof(float) * stepline * colcount);
cudaMallocHost(&h_img_y, sizeof(float) * stepline * colcount);
cudaMallocHost(&h_img_z, sizeof(float) * stepline * colcount);



// 初始化
long rid = 0;
for (long i = 0; i < stepline; i++) {
	rid = startline + i;
	for (long j = 0; j < colcount; j++) {
		h_img_x[i * colcount + j] = img_x[rid * colcount + j];
		h_img_y[i * colcount + j] = img_y[rid * colcount + j];
		h_img_z[i * colcount + j] = img_z[rid * colcount + j];
	}
}
std::cout << "h_img_x init finished!!" << std::endl;

// 分配设备内存
float* d_antPx, * d_antPy, * d_antPz, * d_img_x, * d_img_y, * d_img_z;

complexfloat* d_echopluse;
complexfloat* d_imgarr;

cudaMalloc(&d_echopluse, sizeof(float) * 2 * plusecount);
cudaMalloc(&d_imgarr, sizeof(float) * 2 * stepline * colcount);
cudaMalloc(&d_antPx, sizeof(float) * prfcount);
cudaMalloc(&d_antPy, sizeof(float) * prfcount);
cudaMalloc(&d_antPz, sizeof(float) * prfcount);
cudaMalloc(&d_img_x, sizeof(float) * rowcount * colcount);
cudaMalloc(&d_img_y, sizeof(float) * rowcount * colcount);
cudaMalloc(&d_img_z, sizeof(float) * rowcount * colcount);


// 将数据从主机拷贝到设备
cudaMemcpy(d_antPx, h_antPx, sizeof(float) * prfcount, cudaMemcpyHostToDevice);
cudaMemcpy(d_antPx, h_antPx, sizeof(float) * prfcount, cudaMemcpyHostToDevice);
cudaMemcpy(d_antPy, h_antPy, sizeof(float) * prfcount, cudaMemcpyHostToDevice);
cudaMemcpy(d_antPz, h_antPz, sizeof(float) * prfcount, cudaMemcpyHostToDevice);
cudaMemcpy(d_img_x, h_img_x, sizeof(float) * rowcount * colcount, cudaMemcpyHostToDevice);
cudaMemcpy(d_img_y, h_img_y, sizeof(float) * rowcount * colcount, cudaMemcpyHostToDevice);
cudaMemcpy(d_img_z, h_img_z, sizeof(float) * rowcount * colcount, cudaMemcpyHostToDevice);
cudaMemcpy(d_imgarr, h_imgarr, sizeof(float) * 2 * stepline * colcount, cudaMemcpyHostToDevice);




int blockSize = 256; // 每个块的线程数
int numBlocks = (pixelcount + blockSize - 1) / blockSize; // 根据 pixelcount 计算网格大小
long eid = 0;
std::complex<double> Rphi;
for (long prfid = 0; prfid < prfcount; prfid++) {

	for (long i = 0; i < plusecount; i++) {
		h_echopluse[i].real = echoArr.get()[prfid * plusecount + i].real();
		h_echopluse[i].imag = echoArr.get()[prfid * plusecount + i].imag();
	}

	cudaMemcpy(d_echopluse, h_echopluse, sizeof(float) * 2 * plusecount, cudaMemcpyHostToDevice);

	computeDistanceAndEchoID << < numBlocks, blockSize >> > (d_antPx, d_antPy, d_antPz,
		d_img_x, d_img_y, d_img_z,
		d_echopluse, d_imgarr,
		rowcount, colcount, prfid,
		Rnear, fs, factorj);
	cudaDeviceSynchronize();// 等待所有设备任务完成
	if (prfid % 100 == 0) {
		//std::cout << "\rprf " << prfid <<"/"<< prfcount << "\t\t\t";
	}
	//cudaMemcpy(h_echopluse, d_echopluse, sizeof(float) * 2 * stepline * colcount, cudaMemcpyDeviceToHost);

}
std::cout << std::endl;
// GPU -> CPU
cudaMemcpy(h_imgarr, d_imgarr, sizeof(float) * 2 * stepline * colcount, cudaMemcpyDeviceToHost);

for (long i = 0; i < stepline; i++) {
	long rid = startline + i;
	for (long j = 0; j < colcount; j++) {
		imageArr.get()[rid * colcount + j] = std::complex<double>(h_imgarr[i * colcount + j].real, h_imgarr[i * colcount + j].imag);
	}
}



// 清理资源
cudaFree(d_antPx);
cudaFree(d_antPy);
cudaFree(d_antPz);
cudaFree(d_img_x);
cudaFree(d_img_y);
cudaFree(d_img_z);

cudaFree(d_echopluse);
cudaFree(d_imgarr);

cudaFreeHost(h_antPx);
cudaFreeHost(h_antPy);
cudaFreeHost(h_antPz);
cudaFreeHost(h_img_x);
cudaFreeHost(h_img_y);
cudaFreeHost(h_img_z);
cudaFreeHost(h_echopluse);
cudaFreeHost(h_imgarr);
std::cout << "end GPU" << std::endl;

}

void RTPC(float* antx, float* anty, float* antz, float* demx, float* demy, float* demz, float* demslopex, float* demslopey, float* demslopez ) {}