|
|
@ -20,7 +20,7 @@ ScanConversion::ScanConversion(const Context context, |
|
|
|
_queryX = Q_NULLPTR; |
|
|
|
_queryZ = Q_NULLPTR; |
|
|
|
|
|
|
|
_gridPixelR = Q_NULLPTR; |
|
|
|
_gridPixelR = Q_NULLPTR; |
|
|
|
_gridPixelTheta = Q_NULLPTR; |
|
|
|
} |
|
|
|
|
|
|
@ -30,8 +30,364 @@ void ScanConversion::cpuProcess(ScenGenOutput_t params) |
|
|
|
|
|
|
|
auto context = _openCLHelper.getContext(); |
|
|
|
auto queue = BIP::getInstance()->CLQueue; |
|
|
|
//virtual convex
|
|
|
|
if(params.virtualConvex.value) |
|
|
|
//convex
|
|
|
|
if (!params.linear.value) |
|
|
|
{ |
|
|
|
if(params.outputWidth.isUpdated || params.outputHeight.isUpdated) |
|
|
|
{ |
|
|
|
if(_gridPixelXPos) |
|
|
|
delete[] _gridPixelXPos; |
|
|
|
if(_gridPixelZPos) |
|
|
|
delete[] _gridPixelZPos; |
|
|
|
|
|
|
|
_gridPixelXPos = new myflt[params.outputWidth.value * params.outputHeight.value]; |
|
|
|
_gridPixelZPos = new myflt[params.outputWidth.value * params.outputHeight.value]; |
|
|
|
|
|
|
|
_width = params.outputWidth.value; |
|
|
|
_height = params.outputHeight.value; |
|
|
|
|
|
|
|
_kernelParameters.width = _width; |
|
|
|
} |
|
|
|
|
|
|
|
if(params.depth.isUpdated || params.probeRadius.isUpdated || |
|
|
|
params.fieldOfView.isUpdated || params.angle.isUpdated || |
|
|
|
params.startDepth.isUpdated || params.startDepth.isUpdated || |
|
|
|
params.outputWidth.isUpdated || params.outputHeight.isUpdated|| |
|
|
|
params.steering.isUpdated) |
|
|
|
{ |
|
|
|
auto maxX = params.probeRadius.value*sinf(params.fieldOfView.value/2)+params.depth.value*sinf(params.angle.value/2); |
|
|
|
auto minX = -1 * maxX; |
|
|
|
auto maxZ = params.depth.value + params.probeRadius.value; |
|
|
|
auto minZ = params.probeRadius.value*cosf(params.fieldOfView.value/2)+params.startDepth.value*cosf(params.angle.value/2); |
|
|
|
|
|
|
|
// auto baseZ = (maxZ - minZ) / (params.outputHeight.value - 1);
|
|
|
|
// auto baseX = (maxX - minX) / (params.outputWidth.value - 1);
|
|
|
|
|
|
|
|
// for (auto i = 0; i < params.outputHeight.value; ++i)
|
|
|
|
// {
|
|
|
|
// auto temp = i * baseZ;
|
|
|
|
// auto baseIndex = i * params.outputHeight.value;
|
|
|
|
// for (auto j = 0; j < params.outputWidth.value; ++j)
|
|
|
|
// {
|
|
|
|
// auto b = minX + baseX * j;
|
|
|
|
// _gridPixelXPos[baseIndex+j] = b;
|
|
|
|
// auto a = minZ + temp;
|
|
|
|
// _gridPixelZPos[baseIndex+j] = a;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
auto baseZ = (maxZ - minZ) / (params.outputHeight.value - 1); |
|
|
|
auto baseX = (maxX - minX) / (params.outputWidth.value - 1); |
|
|
|
|
|
|
|
for (auto i = 0; i < params.outputHeight.value; ++i) |
|
|
|
{ |
|
|
|
auto temp = i * baseZ; |
|
|
|
auto baseIndex = i * params.outputHeight.value; |
|
|
|
for (auto j = 0; j < params.outputWidth.value; ++j) |
|
|
|
{ |
|
|
|
|
|
|
|
auto a = minZ + i * (maxZ - minZ) / (params.outputHeight.value - 1); |
|
|
|
_gridPixelZPos[baseIndex+j] = a; |
|
|
|
|
|
|
|
|
|
|
|
auto b = minX + baseX * j; |
|
|
|
_gridPixelXPos[baseIndex+j] = b; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(_gridPixelR) |
|
|
|
delete[] _gridPixelR; |
|
|
|
_gridPixelR = new myflt[params.outputWidth.value * params.outputHeight.value]; |
|
|
|
|
|
|
|
if(_gridPixelTheta) |
|
|
|
delete[] _gridPixelTheta; |
|
|
|
_gridPixelTheta = new myflt[params.outputWidth.value * params.outputHeight.value]; |
|
|
|
|
|
|
|
auto virtualOriginalZ = params.probeRadius.value * (cosf(params.fieldOfView.value/2) - |
|
|
|
sinf(params.fieldOfView.value/2) / |
|
|
|
tanf(params.angle.value/2)); |
|
|
|
auto virtualOriginalZ2 = powf(virtualOriginalZ, 2); |
|
|
|
|
|
|
|
auto minR = params.probeRadius.value - virtualOriginalZ + params.startDepth.value; |
|
|
|
auto maxR = params.probeRadius.value + params.depth.value; |
|
|
|
|
|
|
|
auto minTheta = (-1 * params.angle.value) / 2 - abs(params.steering.value); |
|
|
|
auto maxTheta = params.angle.value / 2 + abs(params.steering.value); |
|
|
|
|
|
|
|
auto strSin = 2 * sinf(params.steering.value); |
|
|
|
auto maxInterceptTheta = params.fieldOfView.value / 2; |
|
|
|
auto radius2 = powf(params.probeRadius.value, 2); |
|
|
|
|
|
|
|
if(params.steering.value == 0.0f) |
|
|
|
{ |
|
|
|
for (auto i = 0; i < params.outputWidth.value * params.outputHeight.value; ++i) |
|
|
|
{ |
|
|
|
auto x = _gridPixelXPos[i]; |
|
|
|
auto z = _gridPixelZPos[i]; |
|
|
|
auto pixelTheta = atan2f(x, z - virtualOriginalZ); |
|
|
|
auto pixelR = sqrtf(powf(x, 2) + powf((z - virtualOriginalZ), 2)); |
|
|
|
|
|
|
|
if(pixelR >= minR && pixelR <= maxR && pixelTheta >= minTheta && pixelTheta <= maxTheta) |
|
|
|
{ |
|
|
|
auto interceptTheta = 0.0f; |
|
|
|
auto interceptX = 0.0f; |
|
|
|
auto interceptZ = 0.0f; |
|
|
|
auto alpha = virtualOriginalZ; |
|
|
|
auto beta = (virtualOriginalZ - z) / x; |
|
|
|
|
|
|
|
if (x == 0.0f) |
|
|
|
interceptTheta = 0; |
|
|
|
else |
|
|
|
{ |
|
|
|
interceptX = (alpha * beta + sqrtf(-1 * powf(alpha, 2) + (powf(beta, 2) + 1)* radius2)) / (powf(beta, 2) + 1); |
|
|
|
interceptZ = alpha - beta * interceptX; |
|
|
|
interceptTheta = atan2f(interceptX, interceptZ); |
|
|
|
} |
|
|
|
|
|
|
|
if(interceptTheta > maxInterceptTheta || interceptTheta < (-1 * maxInterceptTheta)) |
|
|
|
{ |
|
|
|
interceptX = (alpha * beta - sqrtf(-1 * powf(alpha, 2) + (powf(beta, 2) + 1)* radius2)) / (powf(beta, 2) + 1); |
|
|
|
interceptZ = alpha - beta * interceptX; |
|
|
|
interceptTheta = atan2f(interceptX, interceptZ); |
|
|
|
|
|
|
|
if(interceptTheta > maxInterceptTheta || interceptTheta < (-1 * maxInterceptTheta)) |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
auto gridPixelAx = sqrtf(powf((x - params.probeRadius.value * sinf(interceptTheta)), 2) + |
|
|
|
powf((z - params.probeRadius.value * cosf(interceptTheta)), 2)); |
|
|
|
if(gridPixelAx >= params.startDepth.value && gridPixelAx <= params.depth.value) |
|
|
|
{ |
|
|
|
_gridPixelR[i] = params.probeRadius.value + gridPixelAx; |
|
|
|
_gridPixelTheta[i] = interceptTheta; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
auto gridPixelAx = sqrtf(powf((x - params.probeRadius.value * sinf(interceptTheta)), 2) + |
|
|
|
powf((z - params.probeRadius.value * cosf(interceptTheta)), 2)); |
|
|
|
if(gridPixelAx >= params.startDepth.value && gridPixelAx <= params.depth.value) |
|
|
|
{ |
|
|
|
_gridPixelR[i] = params.probeRadius.value + gridPixelAx; |
|
|
|
_gridPixelTheta[i] = interceptTheta; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
for (auto i = 0; i < params.outputWidth.value * params.outputHeight.value; ++i) |
|
|
|
{ |
|
|
|
auto x = _gridPixelXPos[i]; |
|
|
|
auto z = _gridPixelZPos[i]; |
|
|
|
auto pixelTheta = atan2f(x, z - virtualOriginalZ); |
|
|
|
auto pixelR = sqrtf(powf(x, 2) + powf((z - virtualOriginalZ), 2)); |
|
|
|
|
|
|
|
if(pixelR >= minR && pixelR <= maxR && pixelTheta >= minTheta && pixelTheta <=maxTheta) |
|
|
|
{ |
|
|
|
auto ro = pixelR / strSin; |
|
|
|
auto xo = ro * cosf(params.steering.value - pixelTheta); |
|
|
|
auto zo = ro * sinf(params.steering.value - pixelTheta) + virtualOriginalZ; |
|
|
|
if(zo == 0.0f) |
|
|
|
{ |
|
|
|
auto interceptX = (radius2 - virtualOriginalZ2) / 2 / xo; |
|
|
|
auto interceptZ = sqrtf(radius2 - powf(interceptX , 2)); |
|
|
|
auto interceptTheta = atan2f(interceptX, interceptZ); |
|
|
|
if (interceptTheta > maxInterceptTheta || interceptTheta < (-1 * maxInterceptTheta)) |
|
|
|
{ |
|
|
|
interceptZ = -1 * sqrtf(radius2 - powf(interceptX , 2)); |
|
|
|
interceptTheta = atan2(interceptX, interceptZ); |
|
|
|
if(interceptTheta > maxInterceptTheta || interceptTheta < (-1 * maxInterceptTheta)) |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
auto gridPixelAx = sqrtf(powf(x - params.probeRadius.value * sinf(interceptTheta), 2) + |
|
|
|
powf(z - params.probeRadius.value * cosf(interceptTheta), 2)); |
|
|
|
if(gridPixelAx >= params.startDepth.value && gridPixelAx <= params.depth.value) |
|
|
|
{ |
|
|
|
_gridPixelR[i] = params.probeRadius.value + gridPixelAx; |
|
|
|
_gridPixelTheta[i] = interceptTheta; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
auto gridPixelAx = sqrtf(powf(x - params.probeRadius.value * sinf(interceptTheta), 2) + |
|
|
|
powf(z - params.probeRadius.value * cosf(interceptTheta), 2)); |
|
|
|
if(gridPixelAx >= params.startDepth.value && gridPixelAx <= params.depth.value) |
|
|
|
{ |
|
|
|
_gridPixelR[i] = params.probeRadius.value + gridPixelAx; |
|
|
|
_gridPixelTheta[i] = interceptTheta; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
auto alpha = (radius2 - virtualOriginalZ2 + 2 * zo * virtualOriginalZ) / 2 / zo; |
|
|
|
auto beta = xo / zo; |
|
|
|
|
|
|
|
auto interceptX = (alpha * beta + sqrtf(-1 * powf(alpha, 2) + (powf(beta,2) + 1) * radius2)) / (powf(beta, 2) + 1); |
|
|
|
auto interceptZ = alpha - beta * interceptX; |
|
|
|
auto interceptTheta = atan2f(interceptX, interceptZ); |
|
|
|
|
|
|
|
if(interceptTheta > maxInterceptTheta || interceptTheta < (-1 * maxInterceptTheta)) |
|
|
|
{ |
|
|
|
interceptX = (alpha * beta - sqrtf(-1 * powf(alpha, 2) + (powf(beta,2) + 1) * radius2)) / (powf(beta, 2) + 1); |
|
|
|
interceptZ = alpha - beta * interceptX; |
|
|
|
interceptTheta = atan2f(interceptX, interceptZ); |
|
|
|
if(interceptTheta > maxInterceptTheta || interceptTheta < (-1 * maxInterceptTheta)) |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
auto gridPixelAx = sqrtf(powf(x - params.probeRadius.value * sinf(interceptTheta), 2) + |
|
|
|
powf(z - params.probeRadius.value * cosf(interceptTheta), 2)); |
|
|
|
if(gridPixelAx >= params.startDepth.value && gridPixelAx <= params.depth.value) |
|
|
|
{ |
|
|
|
_gridPixelR[i] = params.probeRadius.value + gridPixelAx; |
|
|
|
_gridPixelTheta[i] = interceptTheta; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
auto gridPixelAx = sqrtf(powf(x - params.probeRadius.value * sinf(interceptTheta), 2) + |
|
|
|
powf(z - params.probeRadius.value * cosf(interceptTheta), 2)); |
|
|
|
if(gridPixelAx >= params.startDepth.value && gridPixelAx <= params.depth.value) |
|
|
|
{ |
|
|
|
_gridPixelR[i] = params.probeRadius.value + gridPixelAx; |
|
|
|
_gridPixelTheta[i] = interceptTheta; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_gridPixelR[i] = 0; |
|
|
|
_gridPixelTheta[i] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(_queryX) |
|
|
|
delete _queryX; |
|
|
|
|
|
|
|
if(_queryZ) |
|
|
|
delete _queryZ; |
|
|
|
_queryX = _openCLHelper.array2CLBuffer(context, |
|
|
|
params.outputWidth.value * |
|
|
|
params.outputHeight.value * |
|
|
|
sizeof (myflt)); |
|
|
|
_queryZ = _openCLHelper.array2CLBuffer(context, |
|
|
|
params.outputWidth.value * |
|
|
|
params.outputHeight.value * |
|
|
|
sizeof (myflt)); |
|
|
|
|
|
|
|
BIP::getInstance()->CLQueue.enqueueWriteBuffer(*_queryZ, CL_TRUE, 0, |
|
|
|
params.outputWidth.value * |
|
|
|
params.outputHeight.value * |
|
|
|
sizeof (myflt), |
|
|
|
_gridPixelR); |
|
|
|
queue.enqueueWriteBuffer(*_queryX, CL_TRUE, 0, |
|
|
|
params.outputWidth.value * |
|
|
|
params.outputHeight.value * |
|
|
|
sizeof (myflt), |
|
|
|
_gridPixelTheta); |
|
|
|
} |
|
|
|
|
|
|
|
//TODO:: write after convex
|
|
|
|
//scanTheta
|
|
|
|
if(params.rxLineNo.isUpdated || params.minScanAz.isUpdated || |
|
|
|
params.rxLineDaz.isUpdated) |
|
|
|
{ |
|
|
|
if(_scanXPos) |
|
|
|
delete [] _scanXPos; |
|
|
|
|
|
|
|
if(_gridX) |
|
|
|
delete _gridX; |
|
|
|
|
|
|
|
_scanXPos = new myflt[params.rxLineNo.value]; |
|
|
|
for (auto i = 0; i < params.rxLineNo.value ; ++i) |
|
|
|
{ |
|
|
|
_scanXPos[i] = params.minScanAz.value + i * params.rxLineDaz.value; |
|
|
|
} |
|
|
|
|
|
|
|
_gridX = _openCLHelper.array2CLBuffer(context, static_cast<qint64>(params.rxLineNo.value * sizeof (myflt))); |
|
|
|
auto er = queue.enqueueWriteBuffer(*_gridX,CL_TRUE, 0, static_cast<unsigned long>(params.rxLineNo.value * sizeof (myflt)), _scanXPos); |
|
|
|
|
|
|
|
_kernelParameters.gridXSize = params.rxLineNo.value; |
|
|
|
} |
|
|
|
//scanR
|
|
|
|
if(params.rxFocusPointNo.isUpdated || params.minScanAx.isUpdated || |
|
|
|
params.rxPointDax.isUpdated) |
|
|
|
{ |
|
|
|
if(_scanZPos) |
|
|
|
delete [] _scanZPos; |
|
|
|
|
|
|
|
if(_gridZ) |
|
|
|
delete _gridZ; |
|
|
|
|
|
|
|
_scanZPos = new myflt[params.rxFocusPointNo.value]; |
|
|
|
for (auto i = 0; i < params.rxFocusPointNo.value; ++i) |
|
|
|
{ |
|
|
|
_scanZPos[i] = (params.minScanAx.value + i * params.rxPointDax.value ) +params.probeRadius.value; |
|
|
|
} |
|
|
|
|
|
|
|
_gridZ = _openCLHelper.array2CLBuffer(context, static_cast<qint64>(params.rxFocusPointNo.value * sizeof (myflt))); |
|
|
|
auto er = queue.enqueueWriteBuffer(*_gridZ, CL_TRUE, 0, static_cast<unsigned long>(params.rxFocusPointNo.value * sizeof (myflt)),_scanZPos); |
|
|
|
|
|
|
|
_kernelParameters.gridZSize = params.rxFocusPointNo.value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//virtual convex
|
|
|
|
else if(params.virtualConvex.value) |
|
|
|
{ |
|
|
|
if(params.outputWidth.isUpdated|| params.outputHeight.isUpdated) |
|
|
|
{ |
|
|
@ -190,7 +546,7 @@ void ScanConversion::cpuProcess(ScenGenOutput_t params) |
|
|
|
params.outputHeight.value * |
|
|
|
sizeof (myflt), |
|
|
|
_gridPixelR); |
|
|
|
queue.enqueueWriteBuffer(*_queryX, CL_TRUE, 0, |
|
|
|
queue.enqueueWriteBuffer(*_queryX, CL_TRUE, 0, |
|
|
|
params.outputWidth.value * |
|
|
|
params.outputHeight.value * |
|
|
|
sizeof (myflt), |
|
|
@ -249,7 +605,8 @@ void ScanConversion::cpuProcess(ScenGenOutput_t params) |
|
|
|
_kernelParameters.gridZSize = params.rxFocusPointNo.value; |
|
|
|
} |
|
|
|
} |
|
|
|
//linear non convex
|
|
|
|
|
|
|
|
//linear non convex
|
|
|
|
else |
|
|
|
{ |
|
|
|
if(params.outputWidth.isUpdated || params.outputHeight.isUpdated) |
|
|
|