From 6be62e224e94ae3922e9f19f5ceeb449f2dcad4a Mon Sep 17 00:00:00 2001 From: mmtalaie Date: Tue, 28 Jul 2020 16:09:44 +0430 Subject: [PATCH] add some change --- MainWindow.cpp | 104 ++- MainWindow.h | 2 +- header/ELogId.h | 4 +- header/ESeverityLevel.h | 2 +- header/ScenarioParams.h | 90 +-- header/Utils.h | 2 +- header/model/algorithms/ScanConversionAlg.h | 35 + header/model/processor/IProcessStrategy.h | 2 +- header/model/processor/strategies/Cri.h | 2 +- header/model/processor/strategies/DynCont.h | 2 +- header/model/processor/strategies/Enhance.h | 2 +- header/model/processor/strategies/GrayMap.h | 2 +- header/model/processor/strategies/Persist.h | 2 +- header/model/processor/strategies/Rejection.h | 2 +- .../processor/strategies/ScanConversion.h | 14 +- header/model/processor/strategies/Sri.h | 2 +- header/model/processor/strategies/TintMap.h | 2 +- kernels/ScanConversion.cl | 18 +- source/FileHelper.cpp | 2 +- source/model/algorithms/ScanConversionAlg.cpp | 518 ++++++++++++ source/model/processor/strategies/Cri.cpp | 11 +- source/model/processor/strategies/DynCont.cpp | 20 +- source/model/processor/strategies/Enhance.cpp | 153 ++-- source/model/processor/strategies/GrayMap.cpp | 7 +- source/model/processor/strategies/Persist.cpp | 9 +- .../model/processor/strategies/Rejection.cpp | 4 +- .../processor/strategies/ScanConversion.cpp | 755 ++---------------- source/model/processor/strategies/Sri.cpp | 7 +- source/model/processor/strategies/TintMap.cpp | 7 +- 29 files changed, 824 insertions(+), 958 deletions(-) create mode 100644 header/model/algorithms/ScanConversionAlg.h create mode 100644 source/model/algorithms/ScanConversionAlg.cpp diff --git a/MainWindow.cpp b/MainWindow.cpp index b9c2265..c451647 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -132,93 +132,111 @@ void MainWindow::readParam(QString path, int mode) //sc case 0: temp = sl[index++].PARSE; - update_field(&_scenGenOutput.linear, INP2MYFLT(temp) == 0); + _scenGenOutput.probe.linear = INP2MYFLT(temp) == 0; temp = sl[index++].PARSE; - update_field(&_scenGenOutput.depth, INP2MYFLT(temp)); + OUT_WIDTH = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.probeRadius, INP2MYFLT(temp)); + OUT_HEIGHT = INP2MYFLT(temp); + if(!_scenGenOutput.probe.linear) + { + temp = sl[index++].PARSE; + _scenGenOutput.probe.radius = INP2MYFLT(temp); + + temp = sl[index++].PARSE; + _scenGenOutput.angle = INP2MYFLT(temp); + + temp = sl[index++].PARSE; + _scenGenOutput.maxScanAx = INP2MYFLT(temp); + } temp = sl[index++].PARSE; - update_field(&_scenGenOutput.fieldOfView, INP2MYFLT(temp)); + _scenGenOutput.depth = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.probeFieldOfView, INP2MYFLT(temp)); + _scenGenOutput.fieldOfView = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.virtualOriginalZ, INP2MYFLT(temp)); + _scenGenOutput.bMinScanAx = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.minScanAx, INP2MYFLT(temp)); + _scenGenOutput.bMinScanAz = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.minScanAz, INP2MYFLT(temp)); + _scenGenOutput.bMaxScanAx = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.maxScanAx, INP2MYFLT(temp)); + _scenGenOutput.bMaxScanAz = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.startDepth, INP2MYFLT(temp)); + _scenGenOutput.minScanAx = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.steering, INP2MYFLT(temp)); + _scenGenOutput.minScanAz = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.rxLineNo, INP2MYFLT(temp)); + _scenGenOutput.startDepth = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.rxFocusPointNo, INP2MYFLT(temp)); + _scenGenOutput.steering = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.rxLineDaz, INP2MYFLT(temp)); + _scenGenOutput.rxLineNo = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.rxPointDax, INP2MYFLT(temp)); + _scenGenOutput.rxFocusPointNo= INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.virtualConvex, INP2MYFLT(temp) != 0); + _scenGenOutput.rxLineDaz = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.vcMaxTheta, INP2MYFLT(temp)); + _scenGenOutput.rxPointDax = INP2MYFLT(temp); + + if(_scenGenOutput.probe.linear) + { + temp = sl[index++].PARSE; + _scenGenOutput.virtualConvex = INP2MYFLT(temp) != 0; + } temp = sl[index++].PARSE; - update_field(&_scenGenOutput.angle, INP2MYFLT(temp)); + _scenGenOutput.hdZoom= INP2MYFLT(temp) != 0; + break; case 1: temp = sl[index++].PARSE; - update_field(&_scenGenOutput.rejectThreshold, INP2MYFLT(temp)); + _scenGenOutput.rejectThreshold = INP2MYFLT(temp); break; case 2: temp = sl[index++].PARSE; - update_field(&_scenGenOutput.sri, INP2MYFLT(temp)); + _scenGenOutput.sri = INP2MYFLT(temp); break; case 3: temp = sl[index++].PARSE; - update_field(&_scenGenOutput.tintMapSelector, INP2MYFLT(temp)); + _scenGenOutput.tintMapSelector = INP2MYFLT(temp); break; case 4: temp = sl[index++].PARSE; - update_field(&_scenGenOutput.grayMapSelector, INP2MYFLT(temp)); + _scenGenOutput.grayMapSelector = INP2MYFLT(temp); break; case 5: temp = sl[index++].PARSE; - update_field(&_scenGenOutput.dynContSelector, INP2MYFLT(temp)); + _scenGenOutput.dynContSelector = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.dynContGain, INP2MYFLT(temp)); + _scenGenOutput.dynContGain = INP2MYFLT(temp); temp = sl[index++].PARSE; - update_field(&_scenGenOutput.compressionType, INP2MYFLT(temp)); + _scenGenOutput.compressionType = INP2MYFLT(temp); break; case 6: temp = sl[index++].PARSE; - update_field(&_scenGenOutput.enhance, INP2MYFLT(temp)); + _scenGenOutput.enhance = INP2MYFLT(temp); - update_field(&_scenGenOutput.enhanceAlgorithm, 0); + _scenGenOutput.enhanceAlgorithm = 0; break; case 7: - update_field(&_scenGenOutput.persist, 1); + _scenGenOutput.persist = 1; break; } } @@ -290,8 +308,8 @@ void MainWindow::on_btn_test_clicked() return; } - OUT_WIDTH = ui->cb_kernelName->currentIndex() ? width : 1000; - OUT_HEIGHT = ui->cb_kernelName->currentIndex() ? height : 1000; +// OUT_WIDTH = ui->cb_kernelName->currentIndex() ? width : 1000; +// OUT_HEIGHT = ui->cb_kernelName->currentIndex() ? height : 1000; ImageFormat format; format.image_channel_order = CL_RGBA; @@ -309,19 +327,19 @@ void MainWindow::on_btn_test_clicked() width * sizeof (myflt), 0, arr.data()); - if(ui->cb_kernelName->currentText() == "Cri") - { - Image2D* criBuffer[16]; - auto bufferPath = inputDir.path() + "/buffer"; - for (int i = 1; i <= 16; ++i) - { - auto bfname = QString("%1\%2\") - - } - - } - update_field(&_scenGenOutput.outputWidth, (uint)OUT_WIDTH); - update_field(&_scenGenOutput.outputHeight, (uint)OUT_HEIGHT); +// if(ui->cb_kernelName->currentText() == "Cri") +// { +// Image2D* criBuffer[16]; +// auto bufferPath = inputDir.path() + "/buffer"; +// for (int i = 1; i <= 16; ++i) +// { +// auto bfname = QString("%1\%2\") + +// } + +// } + _scenGenOutput.outputWidth = (uint)OUT_WIDTH; + _scenGenOutput.outputHeight = (uint)OUT_HEIGHT; _strategy->cpuProcess(_scenGenOutput); auto outFrame = _strategy->processKernel(inFrame, _scratchPad); diff --git a/MainWindow.h b/MainWindow.h index c301ce8..1537f75 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -63,7 +63,7 @@ private: void registerStrategies(); void pushBackStrategy(const QString strategyName, const QString kernelFolder); IProcessStrategy* _strategy; - ScenGenOutput_t _scenGenOutput; + Input_t _scenGenOutput; void readParam(QString path, int mode); diff --git a/header/ELogId.h b/header/ELogId.h index 9d71093..cba8944 100644 --- a/header/ELogId.h +++ b/header/ELogId.h @@ -145,9 +145,9 @@ public: * Converts the eLogId enumerator to the relevant identification number */ - static int qtEnumToInt(const eLogId qtEnum) + static int qtEnumToInt(const QString key) { - return QMetaEnum::fromType().value(qtEnum); + return static_cast (QMetaEnum::fromType().keyToValue(key.toStdString().c_str())); } }; diff --git a/header/ESeverityLevel.h b/header/ESeverityLevel.h index 03991e8..f8c881f 100755 --- a/header/ESeverityLevel.h +++ b/header/ESeverityLevel.h @@ -79,7 +79,7 @@ public: */ static QString qtEnumToQString(const eSeverityLevel qtEnum) { - return QString(QMetaEnum::fromType().valueToKey(qtEnum)); + return QString(QMetaEnum::fromType().valueToKey(qtEnum)); } /** diff --git a/header/ScenarioParams.h b/header/ScenarioParams.h index 0d8836b..0d5167a 100644 --- a/header/ScenarioParams.h +++ b/header/ScenarioParams.h @@ -3,56 +3,52 @@ #include -template -struct field_t +typedef struct ProbeProperties_t { - T value; - bool isUpdated; -}; + bool linear; + float radius; + float fieldOfView; +}ProbeProperties_t; -typedef struct ScenGenOutput_t +typedef struct Input_t { - field_t linear; - field_t virtualConvex; - field_t depth; - field_t probeRadius; - field_t fieldOfView; - field_t probeFieldOfView; - field_t startDepth; - field_t rxLineNo; - field_t rxFocusPointNo; - field_t rxLineDaz; - field_t rxPointDax; - field_t vcMaxTheta; - field_t angle; - field_t steering; - field_t minScanAx; - field_t minScanAz; - field_t maxScanAx; - field_t virtualOriginalZ; - field_t outputWidth; - field_t outputHeight; - field_t compressionType; - field_t dynContSelector; - field_t dynContGain; - field_t grayMapSelector; - field_t tintMapSelector; - field_t sri; - field_t rejectThreshold; - field_t enhance; - field_t enhanceAlgorithm; - field_t persist; - field_t criFilterMode;//cri - field_t frameCntr;//cri - field_t scenarioFrameNo;//cri -}ScenGenOutput_t; - -template -void update_field(field_t *t, T value) -{ - t->value = value; - t->isUpdated = true; -} + ProbeProperties_t probe; + bool virtualConvex; + bool hdZoom; + float depth; + float fieldOfView; + float startDepth; + int rxLineNo; + int rxFocusPointNo; + float rxLineDaz; + float rxPointDax; + float vcMaxTheta; + float angle; + float steering; + float minScanAx; + float maxScanAx; + float minScanAz; + float bMinScanAx; + float bMinScanAz; + float bMaxScanAx; + float bMaxScanAz; + float virtualOriginalZ; + uint outputWidth; + uint outputHeight; + int compressionType; + int dynContSelector; + int dynContGain; + int grayMapSelector; + int tintMapSelector; + int sri; + int rejectThreshold; + int enhance; + int enhanceAlgorithm; + int persist; + int criFilterMode;//cri + int frameCntr;//cri + int scenarioFrameNo;//cri +}Input_t; #endif // SCENARIOPARAMS_H diff --git a/header/Utils.h b/header/Utils.h index 6ebbb8f..cf85d51 100644 --- a/header/Utils.h +++ b/header/Utils.h @@ -13,7 +13,7 @@ typedef float myflt; typedef int myint; #endif -#define INP2MYFLT(x) *((myflt*)(&x)) +#define INP2MYFLT(x) *(reinterpret_cast(&x)) #ifdef USE_DBL #define PARSE toULong(Q_NULLPTR, 16) diff --git a/header/model/algorithms/ScanConversionAlg.h b/header/model/algorithms/ScanConversionAlg.h new file mode 100644 index 0000000..dcdd56a --- /dev/null +++ b/header/model/algorithms/ScanConversionAlg.h @@ -0,0 +1,35 @@ +#ifndef SCANCONVERSIONALG_H +#define SCANCONVERSIONALG_H + +#include "./ScenarioParams.h" + +class ScanConversionAlg +{ +private: + static void linear(Input_t params, QVector& scanXPos, QVector& scanZPos, + QVector& gridPixelXPos, QVector& gridPixelZPos); + + static void virtualConvex(Input_t params, QVector& scanXPos, QVector& scanZPos, + QVector& gridPixelXPos, QVector& gridPixelZPos); + + static void convex(Input_t params, QVector& scanXPos, QVector& scanZPos, + QVector& gridPixelXPos, QVector& gridPixelZPos); + +public: + static void scanConversion(Input_t params, QVector& scanXPos, QVector& scanZPos, + QVector& gridPixelXPos, QVector& gridPixelZPos); + + static void virtualScanConversion(QVector pixelXPos, QVector pixelZPos, + uint width, uint height, + float steering, float virtualOriginalZ, + float startDepth, float depth, float vcMaxTheta, + QVector& gridPixelR, QVector& gridPixelTheta); + + static void convexScanConversion(QVector pixelXPos, QVector pixelZPos, + uint width, uint height, + float steering, float angle, float fieldOfView, + float probeRadius, float startDepth, float depth, + QVector& gridPixelR, QVector& gridPixelTheta); +}; + +#endif // SCANCONVERSIONALG_H diff --git a/header/model/processor/IProcessStrategy.h b/header/model/processor/IProcessStrategy.h index ab63e9f..403e956 100644 --- a/header/model/processor/IProcessStrategy.h +++ b/header/model/processor/IProcessStrategy.h @@ -22,7 +22,7 @@ class IProcessStrategy : public QObject Q_OBJECT public: - virtual void cpuProcess(ScenGenOutput_t parameters) = 0; + virtual void cpuProcess(Input_t parameters) = 0; virtual void finalize() = 0; virtual Image* processKernel(Image* inputFrame, Buffer* scrathPad) = 0; diff --git a/header/model/processor/strategies/Cri.h b/header/model/processor/strategies/Cri.h index ea8a5ae..72451e5 100644 --- a/header/model/processor/strategies/Cri.h +++ b/header/model/processor/strategies/Cri.h @@ -23,7 +23,7 @@ class Cri : public IProcessStrategy Q_OBJECT public: Q_INVOKABLE Cri(const Context context, const QString kernelPath, const QObject *parent); - virtual void cpuProcess(ScenGenOutput_t parameters) override; + virtual void cpuProcess(Input_t parameters) override; virtual void finalize() override; private: diff --git a/header/model/processor/strategies/DynCont.h b/header/model/processor/strategies/DynCont.h index 953f3ec..a186214 100644 --- a/header/model/processor/strategies/DynCont.h +++ b/header/model/processor/strategies/DynCont.h @@ -20,7 +20,7 @@ class DynCont : public IProcessStrategy Q_OBJECT public: Q_INVOKABLE DynCont(const Context context, const QString kernelPath, const QObject *parent); - virtual void cpuProcess(ScenGenOutput_t parameters) override; + virtual void cpuProcess(Input_t parameters) override; virtual void finalize() override; private: diff --git a/header/model/processor/strategies/Enhance.h b/header/model/processor/strategies/Enhance.h index 4a29ad1..f060b67 100644 --- a/header/model/processor/strategies/Enhance.h +++ b/header/model/processor/strategies/Enhance.h @@ -20,7 +20,7 @@ class Enhance : public IProcessStrategy Q_OBJECT public: Q_INVOKABLE Enhance(const Context context, const QString kernelPath, const QObject *parent); - virtual void cpuProcess(ScenGenOutput_t parameters) override; + virtual void cpuProcess(Input_t parameters) override; virtual void finalize() override; private: diff --git a/header/model/processor/strategies/GrayMap.h b/header/model/processor/strategies/GrayMap.h index de394e2..196a9a3 100644 --- a/header/model/processor/strategies/GrayMap.h +++ b/header/model/processor/strategies/GrayMap.h @@ -17,7 +17,7 @@ class GrayMap : public IProcessStrategy Q_OBJECT public: Q_INVOKABLE GrayMap(const Context context, const QString kernelPath, const QObject *parent); - virtual void cpuProcess(ScenGenOutput_t parameters) override; + virtual void cpuProcess(Input_t parameters) override; virtual void finalize() override; private: diff --git a/header/model/processor/strategies/Persist.h b/header/model/processor/strategies/Persist.h index 2febf62..d5dad3d 100644 --- a/header/model/processor/strategies/Persist.h +++ b/header/model/processor/strategies/Persist.h @@ -20,7 +20,7 @@ class Persist : public IProcessStrategy Q_OBJECT public: Q_INVOKABLE Persist(const Context context, const QString kernelPath, const QObject *parent); - virtual void cpuProcess(ScenGenOutput_t parameters) override; + virtual void cpuProcess(Input_t parameters) override; virtual void finalize() override; private: diff --git a/header/model/processor/strategies/Rejection.h b/header/model/processor/strategies/Rejection.h index 59657cd..72444fe 100644 --- a/header/model/processor/strategies/Rejection.h +++ b/header/model/processor/strategies/Rejection.h @@ -16,7 +16,7 @@ class Rejection : public IProcessStrategy Q_OBJECT public: Q_INVOKABLE Rejection(const Context context, const QString kernelPath); - virtual void cpuProcess(ScenGenOutput_t parameters) override; + virtual void cpuProcess(Input_t parameters) override; virtual void finalize() override; diff --git a/header/model/processor/strategies/ScanConversion.h b/header/model/processor/strategies/ScanConversion.h index 3ef1c13..ba9fa28 100644 --- a/header/model/processor/strategies/ScanConversion.h +++ b/header/model/processor/strategies/ScanConversion.h @@ -15,11 +15,11 @@ typedef struct ScanConversion_t class ScanConversion : public IProcessStrategy { - Q_OBJECT + Q_OBJECT public: Q_INVOKABLE ScanConversion(const Context context, const QString kernelPath, const QObject* parent); - virtual void cpuProcess(ScenGenOutput_t parameters) override; + virtual void cpuProcess(Input_t parameters) override; virtual void finalize() override; @@ -30,12 +30,10 @@ private: quint64 _width; quint64 _height; - myflt* _gridPixelXPos; - myflt* _gridPixelZPos; - myflt* _gridPixelR; - myflt* _gridPixelTheta; - myflt* _scanXPos; - myflt* _scanZPos; + QVector _gridPixelXPos; + QVector _gridPixelZPos; + QVector _scanXPos; + QVector _scanZPos; Buffer* _gridX; Buffer* _gridZ; diff --git a/header/model/processor/strategies/Sri.h b/header/model/processor/strategies/Sri.h index 0c06aa6..a93f80f 100644 --- a/header/model/processor/strategies/Sri.h +++ b/header/model/processor/strategies/Sri.h @@ -20,7 +20,7 @@ class Sri : public IProcessStrategy Q_OBJECT public: Q_INVOKABLE Sri(const Context context, const QString kernelPath, const QObject *parent); - virtual void cpuProcess(ScenGenOutput_t parameters) override; + virtual void cpuProcess(Input_t parameters) override; virtual void finalize() override; private: diff --git a/header/model/processor/strategies/TintMap.h b/header/model/processor/strategies/TintMap.h index f2f999f..02d7ee9 100644 --- a/header/model/processor/strategies/TintMap.h +++ b/header/model/processor/strategies/TintMap.h @@ -17,7 +17,7 @@ class TintMap : public IProcessStrategy Q_OBJECT public: Q_INVOKABLE TintMap(const Context context, const QString kernelPath, const QObject *parent); - virtual void cpuProcess(ScenGenOutput_t parameters) override; + virtual void cpuProcess(Input_t parameters) override; virtual void finalize() override; private: diff --git a/kernels/ScanConversion.cl b/kernels/ScanConversion.cl index ee61881..004f2b2 100644 --- a/kernels/ScanConversion.cl +++ b/kernels/ScanConversion.cl @@ -1,6 +1,6 @@ #define TEST -#define X 500 -#define Y 186 +#define X 379 +#define Y 142 //#define USE_DBL #ifdef USE_DBL @@ -70,28 +70,14 @@ kernel void ScanConversion(read_only image2d_t input_frame, read_write image2d_t if(mabs(z - grid_z[params.grid_z_size - 1]) < EPSILSON) { - if(gid.x == X && gid.y == Y) - printf("here 1 "); grid_z_index = params.grid_z_size - 2; } else { - if(gid.x == X && gid.y == Y) - printf("here 2 %0.9f",grid_z[0]); grid_z_index = floor((z - grid_z[0]) / dz); } TYPE_FLT output_data = 0; - if(gid.x == X && gid.y == Y) - { - printf("dx: %.9f | ", dx); - printf("dz: %.9f | ", dz); - printf("x: %.9f | ", x); - printf("z: %.9f | ", z); - printf("grid_x_index: %d | ", grid_x_index); - printf("grid_z_index: %d | ", grid_z_index); - } - if(grid_x_index >= 0 && grid_x_index < params.grid_x_size - 1 && grid_z_index >= 0 && grid_z_index < params.grid_z_size - 1) { diff --git a/source/FileHelper.cpp b/source/FileHelper.cpp index 434a988..631fe88 100644 --- a/source/FileHelper.cpp +++ b/source/FileHelper.cpp @@ -64,7 +64,7 @@ bool FileHelper::ReadInputFile(myint *arr, QString path, quint64 *width, quint64 if(str.length() == 0) break; (*height)++; - str = str.remove(str.length() - 1, 1); +// str = str.remove(str.length() - 1, 1); auto sl = str.split(","); if(first) { diff --git a/source/model/algorithms/ScanConversionAlg.cpp b/source/model/algorithms/ScanConversionAlg.cpp new file mode 100644 index 0000000..3b30dc8 --- /dev/null +++ b/source/model/algorithms/ScanConversionAlg.cpp @@ -0,0 +1,518 @@ +#include "model/algorithms/ScanConversionAlg.h" + +#include + +void ScanConversionAlg::linear(Input_t params, QVector &scanXPos, QVector &scanZPos, + QVector &gridPixelXPos, QVector &gridPixelZPos) +{ + //just to map to X Z convention + auto frameMaxXScan = params.bMaxScanAz; + auto frameMinXScan = params.bMinScanAz; + auto frameMaxZScan = params.bMaxScanAx; + auto frameMinZScan = params.bMinScanAx; + + auto finalPixelXNo = params.outputWidth; + auto finalPixelZNo = params.outputHeight; + + auto pixelXStep = (frameMaxXScan - frameMinXScan) / (finalPixelXNo - 1); + auto pixelZStep = (frameMaxZScan - frameMinZScan) / (finalPixelZNo - 1); + + gridPixelXPos.reserve(finalPixelXNo * finalPixelZNo); + gridPixelZPos.reserve(finalPixelXNo * finalPixelZNo); + + auto cap = gridPixelXPos.capacity(); + + for(auto i = 0UL; i < finalPixelZNo; i++) + { + auto temp = frameMinZScan + i * pixelZStep; + for(auto j = 0UL; j < finalPixelXNo; j++) + { + gridPixelZPos.push_back(temp / cosf(params.steering)); + gridPixelXPos.push_back((frameMinXScan + j * pixelXStep) - + (temp * tanf(params.steering))); + } + } + + for(auto i = 0; i < params.rxLineNo; i++) + { + scanXPos.push_back(params.minScanAz + i * params.rxLineDaz); + } + + for(auto i = 0; i < params.rxFocusPointNo; i++) + { + scanZPos.push_back(params.minScanAx + i * params.rxPointDax); + } +} + +/*************************************************************************************************/ +void ScanConversionAlg::virtualConvex(Input_t params, QVector& scanXPos, + QVector& scanZPos, QVector& gridPixelXPos, + QVector& gridPixelZPos) +{ + auto finalPixelXNo = params.outputWidth; + auto finalPixelZNo = params.outputHeight; + + auto minAbsScanAz = 0.0f; + if (params.bMaxScanAz > 0 && params.bMinScanAz < 0) + { + minAbsScanAz = 0; + } + else + { + minAbsScanAz = qMin(abs(params.bMinScanAz), abs(params.bMaxScanAz)); + } + + auto maxAbsScanAz = qMax(abs(params.bMinScanAz), abs(params.bMaxScanAz)); + auto frameMaxZScan = params.bMaxScanAx * + cosf(minAbsScanAz / params.fieldOfView * 2 * params.vcMaxTheta); + auto frameMinZScan = params.bMinScanAx * + cosf(maxAbsScanAz / params.fieldOfView * 2 * params.vcMaxTheta); + auto frameMaxXScan = params.bMaxScanAz + params.bMaxScanAx * + sinf(params.bMaxScanAz / params.fieldOfView * 2 * params.vcMaxTheta); + auto frameMinXScan = params.bMinScanAz + params.bMaxScanAx * + sinf(params.bMinScanAz / params.fieldOfView * 2 * params.vcMaxTheta); + + + auto pixelXStep = (frameMaxXScan - frameMinXScan) / (finalPixelXNo - 1); + auto pixelZStep = (frameMaxZScan - frameMinZScan) / (finalPixelZNo - 1); + + auto pixelXPos = QVector(); + auto pixelZPos = QVector(); + + pixelXPos.reserve(finalPixelXNo * finalPixelZNo); + pixelZPos.reserve(finalPixelXNo * finalPixelZNo); + + for(auto i = 0UL; i < finalPixelZNo; i++) + { + for(auto j = 0UL; j < finalPixelXNo; j++) + { + pixelZPos.push_back(frameMinZScan + i * pixelZStep); + pixelXPos.push_back(frameMinXScan + j * pixelXStep); + } + } + + virtualScanConversion(pixelXPos, pixelZPos, finalPixelXNo, finalPixelZNo, params.steering, + params.virtualOriginalZ, params.startDepth, params.depth, + params.vcMaxTheta, gridPixelZPos, gridPixelXPos); + + //scanTheta + for(auto i = 0; i < params.rxLineNo; i++) + { + scanXPos.push_back(params.minScanAz + i * params.rxLineDaz); + } + + //scanR + for(auto i = 0; i < params.rxFocusPointNo; i++) + { + scanZPos.push_back(params.minScanAx + i * params.rxPointDax); + } +} + +/*************************************************************************************************/ +void ScanConversionAlg::convex(Input_t params, QVector& scanXPos, QVector& scanZPos, + QVector& gridPixelXPos, QVector& gridPixelZPos) +{ + auto finalPixelXNo = params.outputWidth; + auto finalPixelZNo = params.outputHeight; + + auto frameMaxXScan = params.probe.radius * sinf(params.bMaxScanAz) + + params.bMaxScanAx * sinf(params.bMaxScanAz / params.fieldOfView * params.angle); + auto frameMinXScan = params.probe.radius * sinf(params.bMinScanAz) + + params.bMaxScanAx * sinf(params.bMinScanAz / params.fieldOfView * params.angle); + + auto minAbsScanAz = 0.0f; + if (params.bMaxScanAz > 0 && params.bMinScanAz < 0) + { + minAbsScanAz = 0; + } + else + { + minAbsScanAz = qMin(abs(params.bMinScanAz), abs(params.bMaxScanAz)); + } + auto maxAbsScanAz = qMax(abs(params.bMinScanAz), abs(params.bMaxScanAz)); + + auto frameMaxZScan = params.probe.radius * cosf(minAbsScanAz) + + params.bMaxScanAx * cosf(minAbsScanAz / params.fieldOfView * params.angle); + auto frameMinZScan = params.probe.radius * cosf(maxAbsScanAz) + + params.bMinScanAx * cosf(maxAbsScanAz / params.fieldOfView * params.angle); + + auto pixelXStep = (frameMaxXScan - frameMinXScan) / (finalPixelXNo - 1); + auto pixelZStep = (frameMaxZScan - frameMinZScan) / (finalPixelZNo - 1); + + auto pixelXPos = QVector(); + auto pixelZPos = QVector(); + + pixelXPos.reserve(finalPixelXNo * finalPixelZNo); + pixelZPos.reserve(finalPixelXNo * finalPixelZNo); + + for(auto i = 0UL; i < finalPixelZNo; i++) + { + for(auto j = 0UL; j < finalPixelXNo; j++) + { + pixelZPos.push_back(frameMinZScan + i * pixelZStep); + pixelXPos.push_back(frameMinXScan + j * pixelXStep); + } + } + + convexScanConversion(pixelXPos, pixelZPos, finalPixelXNo, finalPixelZNo, params.steering, + params.angle, params.fieldOfView, params.probe.radius, params.startDepth, + params.depth, gridPixelZPos, gridPixelXPos); + + + //scanTheta + for(auto i = 0; i < params.rxLineNo; i++) + { + scanXPos.push_back(params.minScanAz + i * params.rxLineDaz + params.probe.radius); + } + + //scanR + for(auto i = 0; i < params.rxFocusPointNo; i++) + { + scanZPos.push_back(params.minScanAx + i * params.rxPointDax); + } +} + +/*************************************************************************************************/ +void ScanConversionAlg::scanConversion(Input_t params, QVector& scanXPos, + QVector& scanZPos, QVector& gridPixelXPos, + QVector& gridPixelZPos) +{ + //convex + if(!params.probe.linear) + { + convex(params, scanXPos, scanZPos, gridPixelXPos, gridPixelZPos); + } + //virtual convex + else if(params.virtualConvex) + { + virtualConvex(params, scanXPos, scanZPos, gridPixelXPos, gridPixelZPos); + } + //linear + else + { + linear(params, scanXPos, scanZPos, gridPixelXPos, gridPixelZPos); + } +} + +/*************************************************************************************************/ +void ScanConversionAlg::virtualScanConversion(QVector pixelXPos, QVector pixelZPos, + uint width, uint height, float steering, + float virtualOriginalZ, float startDepth, float depth, + float vcMaxTheta, QVector& gridPixelR, + QVector& gridPixelTheta) +{ + for(auto i = 0U; i < width * height; i++) + { + auto x = pixelXPos[i]; + auto z = pixelZPos[i]; + + auto pixelTheta = atanf(x / (z + virtualOriginalZ)); + + if(pixelTheta >= -vcMaxTheta - abs(steering) && + pixelTheta <= vcMaxTheta + abs(steering)) + { + if(steering == 0.0f) + { + auto gridPixelAx = sqrtf(powf(x - virtualOriginalZ * tanf(pixelTheta), 2) + + powf(z, 2)); + + if(gridPixelAx >= startDepth && gridPixelAx <= depth) + { + gridPixelR.push_back(gridPixelAx); + gridPixelTheta.push_back(pixelTheta); + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + else + { + auto strTan = tanf(steering); + auto a = virtualOriginalZ * strTan; + auto b = x * strTan + virtualOriginalZ + z; + auto c = x - z * strTan; + auto interceptTheta = atanf((b + sqrtf(powf(b, 2) - 4 * a * c)) / (2 * a)); + if(interceptTheta > vcMaxTheta || interceptTheta < -vcMaxTheta) + { + interceptTheta = atanf((b - sqrtf(powf(b, 2) - 4 * a * c)) / (2 * a)); + if(interceptTheta > vcMaxTheta || interceptTheta < -vcMaxTheta) + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + else + { + auto gridPixelAx = + sqrtf(powf(x - virtualOriginalZ * tanf(interceptTheta), 2) + + powf(z, 2)); + if(gridPixelAx >= startDepth && gridPixelAx <= depth) + { + gridPixelR.push_back(gridPixelAx); + gridPixelTheta.push_back(interceptTheta); + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + } + else + { + auto gridPixelAx = + sqrtf(powf(x - virtualOriginalZ * tanf(interceptTheta), 2) + + powf(z, 2)); + if(gridPixelAx >= startDepth && gridPixelAx <= depth) + { + gridPixelR.push_back(gridPixelAx); + gridPixelTheta.push_back(interceptTheta); + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + }//steering = 0 + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } +} + +/*************************************************************************************************/ +void ScanConversionAlg::convexScanConversion(QVector pixelXPos, QVector pixelZPos, + uint width, uint height, float steering, float angle, + float fieldOfView, float probeRadius, float startDepth, + float depth, QVector& gridPixelR, + QVector& gridPixelTheta) +{ + auto virtualOriginalZ = probeRadius * + (cosf(fieldOfView / 2) - sinf(fieldOfView / 2) / tanf(angle / 2)); + auto virtualOriginalZ2 = powf(virtualOriginalZ, 2); + + auto maxR = probeRadius + depth; + auto minR = probeRadius - virtualOriginalZ + startDepth; + + auto minTheta = -angle / 2 - abs(steering); + auto maxTheta = angle / 2 + abs(steering); + + auto maxInterceptTheta = fieldOfView / 2; + auto radius2 = powf(probeRadius, 2); + + if(steering == 0.0f) + { + for (auto i = 0U; i < width * height; i++) + { + auto x = pixelXPos[i]; + auto z = pixelZPos[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 = 0.0f; + auto beta = 0.0f; + + if(x == 0.0f) + interceptTheta = 0; + else + { + alpha = virtualOriginalZ; + beta = (virtualOriginalZ - z) / x; + 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 < -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 < -maxInterceptTheta) + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + else + { + auto gridPixelAx = sqrtf(powf(x - probeRadius * sinf(interceptTheta), 2) + + powf(z - probeRadius * cosf(interceptTheta), 2)); + if(gridPixelAx >= startDepth && gridPixelAx <= depth) + { + gridPixelR.push_back(probeRadius + gridPixelAx); + gridPixelTheta.push_back(interceptTheta); + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + } + else + { + auto gridPixelAx = sqrtf(powf(x - probeRadius * sinf(interceptTheta), 2) + + powf(z - probeRadius * cosf(interceptTheta), 2)); + if(gridPixelAx >= startDepth && gridPixelAx <= depth) + { + gridPixelR.push_back(probeRadius + gridPixelAx); + gridPixelTheta.push_back(interceptTheta); + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + } + else + { + for (auto i = 0U; i < width * height; i++) + { + auto x = pixelXPos[i]; + auto z = pixelZPos[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 strSin = 2 * sinf(steering); + auto ro = pixelR / strSin; + auto xo = ro * cosf(steering - pixelTheta); + auto zo = ro * sinf(steering - 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 < -maxInterceptTheta) + { + interceptZ = -sqrtf(radius2 - powf(interceptX , 2)); + interceptTheta = atan2f(interceptX, interceptZ); + if(interceptTheta > maxInterceptTheta || + interceptTheta < -maxInterceptTheta) + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + else + { + auto gridPixelAx = + sqrtf(powf(x - probeRadius * sinf(interceptTheta), 2) + + powf(z - probeRadius * cosf(interceptTheta), 2)); + if(gridPixelAx >= startDepth && gridPixelAx <= depth) + { + gridPixelR.push_back(probeRadius + gridPixelAx); + gridPixelTheta.push_back(interceptTheta); + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + } + else + { + auto gridPixelAx = sqrtf(powf(x - probeRadius * sinf(interceptTheta), 2) + + powf(z - probeRadius * cosf(interceptTheta), 2)); + if(gridPixelAx >= startDepth && gridPixelAx <= depth) + { + gridPixelR.push_back(probeRadius + gridPixelAx); + gridPixelTheta.push_back(interceptTheta); + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(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 < -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 < -maxInterceptTheta) + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + else + { + auto gridPixelAx = sqrtf(powf(x - probeRadius * sinf(interceptTheta), 2) + + powf(z - probeRadius * cosf(interceptTheta), 2)); + if(gridPixelAx >= startDepth && gridPixelAx <= depth) + { + gridPixelR.push_back(probeRadius + gridPixelAx); + gridPixelTheta.push_back(interceptTheta); + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + } + else + { + auto gridPixelAx = sqrtf(powf(x - probeRadius * sinf(interceptTheta), 2) + + powf(z - probeRadius * cosf(interceptTheta), 2)); + if(gridPixelAx >= startDepth && gridPixelAx <= depth) + { + gridPixelR.push_back(probeRadius + gridPixelAx); + gridPixelTheta.push_back(interceptTheta); + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + } + } + else + { + gridPixelR.push_back(0); + gridPixelTheta.push_back(0); + } + } + } +} diff --git a/source/model/processor/strategies/Cri.cpp b/source/model/processor/strategies/Cri.cpp index fabaf50..131599b 100644 --- a/source/model/processor/strategies/Cri.cpp +++ b/source/model/processor/strategies/Cri.cpp @@ -11,14 +11,11 @@ Cri::Cri(const Context context,const QString kernelPath,const QObject *parent = // _criBuffer = new Image2D()[CRI_MAX_BUFFER_SIZE]; } -void Cri::cpuProcess(ScenGenOutput_t params) +void Cri::cpuProcess(Input_t params) { - if(params.criFilterMode.isUpdated) - _kernelParameters.criFilterMode = params.criFilterMode.value; - if(params.scenarioFrameNo.isUpdated) - _kernelParameters.scenariFrameNo = params.scenarioFrameNo.value; - if(params.frameCntr.isUpdated) - _kernelParameters.frameCntr = params.frameCntr.value; + _kernelParameters.criFilterMode = params.criFilterMode; + _kernelParameters.scenariFrameNo = params.scenarioFrameNo; + _kernelParameters.frameCntr = params.frameCntr; } void Cri::finalize() diff --git a/source/model/processor/strategies/DynCont.cpp b/source/model/processor/strategies/DynCont.cpp index 5642d1a..7dcf6f0 100644 --- a/source/model/processor/strategies/DynCont.cpp +++ b/source/model/processor/strategies/DynCont.cpp @@ -13,23 +13,11 @@ DynCont::DynCont(const Context context, memset(&_kernelParameters, 0, sizeof (DynCont_t)); } -void DynCont::cpuProcess(ScenGenOutput_t parameters) +void DynCont::cpuProcess(Input_t parameters) { - if(parameters.dynContGain.isUpdated) - { - _kernelParameters.gain = parameters.dynContGain.value; - } - - if(parameters.dynContSelector.isUpdated) - { - _kernelParameters.dynContSelector = parameters.dynContSelector.value; - } - - - if(parameters.compressionType.isUpdated) - { - _kernelParameters.compressionType = parameters.compressionType.value; - } + _kernelParameters.gain = parameters.dynContGain; + _kernelParameters.dynContSelector = parameters.dynContSelector; + _kernelParameters.compressionType = parameters.compressionType; } void DynCont::finalize() diff --git a/source/model/processor/strategies/Enhance.cpp b/source/model/processor/strategies/Enhance.cpp index 4ba1b14..5ad366d 100644 --- a/source/model/processor/strategies/Enhance.cpp +++ b/source/model/processor/strategies/Enhance.cpp @@ -14,110 +14,107 @@ Enhance::Enhance(const Context context, _filter = Q_NULLPTR; } -void Enhance::cpuProcess(ScenGenOutput_t parameters) +void Enhance::cpuProcess(Input_t parameters) { - if(parameters.enhance.isUpdated || parameters.enhanceAlgorithm.isUpdated) + _run = false; + if(parameters.enhance == 0) { - _run = false; - if(parameters.enhance.value == 0) - { - return; - } + return; + } - float *hpf; - int *backgroundRecovery; + float *hpf; + int *backgroundRecovery; - //sharpen - if(parameters.enhanceAlgorithm.value == 0) - { - auto alpha = 0.25f * (parameters.enhance.value - 1); + //sharpen + if(parameters.enhanceAlgorithm == 0) + { + auto alpha = 0.25f * (parameters.enhance - 1); - _kernelParameters.filterWidth = 3; - _kernelParameters.filterHeight = 3; + _kernelParameters.filterWidth = 3; + _kernelParameters.filterHeight = 3; - hpf = new float[9]; - backgroundRecovery = new int[9]; + hpf = new float[9]; + backgroundRecovery = new int[9]; - auto factor = 4 / (alpha + 1); - int index = 0; + auto factor = 4 / (alpha + 1); + int index = 0; - hpf[index++] = factor * (alpha / 4); - hpf[index++] = factor * ((1 - alpha) / 4); - hpf[index++] = factor * (alpha / 4); + hpf[index++] = factor * (alpha / 4); + hpf[index++] = factor * ((1 - alpha) / 4); + hpf[index++] = factor * (alpha / 4); - hpf[index++] = factor * ((1 - alpha) / 4); - hpf[index++] = factor * -1; - hpf[index++] = factor * ((1 - alpha) / 4); + hpf[index++] = factor * ((1 - alpha) / 4); + hpf[index++] = factor * -1; + hpf[index++] = factor * ((1 - alpha) / 4); - hpf[index++] = factor * (alpha / 4); - hpf[index++] = factor * ((1 - alpha) / 4); - hpf[index++] = factor * (alpha / 4); + hpf[index++] = factor * (alpha / 4); + hpf[index++] = factor * ((1 - alpha) / 4); + hpf[index++] = factor * (alpha / 4); - index = 0; + index = 0; - memset(backgroundRecovery, 0, 9 * sizeof (int)); - backgroundRecovery[4] = 1; + memset(backgroundRecovery, 0, 9 * sizeof (int)); + backgroundRecovery[4] = 1; - _run = true; - } - //log - else if(parameters.enhanceAlgorithm.value == 1) - { - _kernelParameters.filterWidth = 5; - _kernelParameters.filterHeight = 5; + _run = true; + } + //log + else if(parameters.enhanceAlgorithm == 1) + { + _kernelParameters.filterWidth = 5; + _kernelParameters.filterHeight = 5; - hpf = new float[25]; - backgroundRecovery = new int[25]; + hpf = new float[25]; + backgroundRecovery = new int[25]; - auto sigma = 0.5f + 0.25f * (parameters.enhance.value - 1); - float sumHg = 0; - float h[25]; + auto sigma = 0.5f + 0.25f * (parameters.enhance - 1); + float sumHg = 0; + float h[25]; - for(int i = -2; i <= 2; i++) + for(int i = -2; i <= 2; i++) + { + for(int j = -2; j <= 2; j++) { - for(int j = -2; j <= 2; j++) - { - float temp = expf(-(powf(i, 2) + powf(j, 2)) - / 2 / powf(sigma, 2)); - h[(i + 2) * 5 + (j + 2)] = (powf(i, 2) + powf(j, 2) - 2 * powf(sigma, 2)) * - temp; - - sumHg += temp; - } - } + float temp = expf(-(powf(i, 2) + powf(j, 2)) + / 2 / powf(sigma, 2)); + h[(i + 2) * 5 + (j + 2)] = (powf(i, 2) + powf(j, 2) - 2 * powf(sigma, 2)) * + temp; - for(int i = 0; i < 25 ; i++) - { - hpf[i] = h[i] / powf(sigma, 4) / sumHg; + sumHg += temp; } - - memset(backgroundRecovery, 0, 25 * sizeof (int)); - backgroundRecovery[12] = 1; - - _run = true; } - if(_run) + for(int i = 0; i < 25 ; i++) { - auto filterSize = _kernelParameters.filterWidth * _kernelParameters.filterHeight; - auto filter = new float[filterSize]; - for(int i = 0; i < filterSize ; i++) - { - filter[i] = backgroundRecovery[i] - hpf[i]; - } + hpf[i] = h[i] / powf(sigma, 4) / sumHg; + } - delete [] hpf; - delete [] backgroundRecovery; + memset(backgroundRecovery, 0, 25 * sizeof (int)); + backgroundRecovery[12] = 1; - if(_filter) - delete _filter; + _run = true; + } - _filter = _openCLHelper.array2CLBuffer(_CLContext, filterSize * sizeof (float)); - BIP::getInstance()->CLQueue.enqueueWriteBuffer(*_filter, CL_TRUE, - 0, filterSize * sizeof (float), - filter); - delete[] filter; + if(_run) + { + auto filterSize = _kernelParameters.filterWidth * _kernelParameters.filterHeight; + auto filter = new float[filterSize]; + for(int i = 0; i < filterSize ; i++) + { + filter[i] = backgroundRecovery[i] - hpf[i]; } + + delete [] hpf; + delete [] backgroundRecovery; + + if(_filter) + delete _filter; + + _filter = _openCLHelper.array2CLBuffer(_CLContext, filterSize * sizeof (float)); + BIP::getInstance()->CLQueue.enqueueWriteBuffer(*_filter, CL_TRUE, + 0, filterSize * sizeof (float), + filter); + delete[] filter; } } diff --git a/source/model/processor/strategies/GrayMap.cpp b/source/model/processor/strategies/GrayMap.cpp index 9de4f31..609613e 100644 --- a/source/model/processor/strategies/GrayMap.cpp +++ b/source/model/processor/strategies/GrayMap.cpp @@ -13,12 +13,9 @@ GrayMap::GrayMap(const Context context, memset(&_kernelParameters, 0, sizeof (GrayMap_t)); } -void GrayMap::cpuProcess(ScenGenOutput_t parameters) +void GrayMap::cpuProcess(Input_t parameters) { - if(parameters.grayMapSelector.isUpdated) - { - _kernelParameters.grayMapSelector = parameters.grayMapSelector.value; - } + _kernelParameters.grayMapSelector = parameters.grayMapSelector; } void GrayMap::finalize() diff --git a/source/model/processor/strategies/Persist.cpp b/source/model/processor/strategies/Persist.cpp index 2c97f30..2446adf 100644 --- a/source/model/processor/strategies/Persist.cpp +++ b/source/model/processor/strategies/Persist.cpp @@ -15,13 +15,10 @@ Persist::Persist(const Context context, _reCalc = true; } -void Persist::cpuProcess(ScenGenOutput_t parameters) +void Persist::cpuProcess(Input_t parameters) { - if(parameters.persist.isUpdated) - { - _kernelParameters.persist = parameters.persist.value; - _reCalc = true; - } + _kernelParameters.persist = parameters.persist; + _reCalc = true; } void Persist::finalize() diff --git a/source/model/processor/strategies/Rejection.cpp b/source/model/processor/strategies/Rejection.cpp index 5a4be4f..de50e1d 100644 --- a/source/model/processor/strategies/Rejection.cpp +++ b/source/model/processor/strategies/Rejection.cpp @@ -12,9 +12,9 @@ Rejection::Rejection(const Context context, } -void Rejection::cpuProcess(ScenGenOutput_t parameters) +void Rejection::cpuProcess(Input_t parameters) { - //_rejectionThr = parameters.rejectThreshold.value; + //_rejectionThr = parameters.rejectThreshold; } void Rejection::finalize() diff --git a/source/model/processor/strategies/ScanConversion.cpp b/source/model/processor/strategies/ScanConversion.cpp index d1a72d7..44650b7 100644 --- a/source/model/processor/strategies/ScanConversion.cpp +++ b/source/model/processor/strategies/ScanConversion.cpp @@ -2,6 +2,9 @@ #include #include #include "model/processor/BIP.h" +#include "model/algorithms/ScanConversionAlg.h" + +#include ScanConversion::ScanConversion(const Context context, const QString kernelPath, @@ -10,744 +13,86 @@ ScanConversion::ScanConversion(const Context context, _kernelFunctor(KernelFunctor(_kernel)) { - _gridPixelXPos = Q_NULLPTR; - _gridPixelZPos = Q_NULLPTR; - _scanXPos = Q_NULLPTR; - _scanZPos = Q_NULLPTR; - _gridX = Q_NULLPTR; _gridZ = Q_NULLPTR; _queryX = Q_NULLPTR; _queryZ = Q_NULLPTR; - - _gridPixelR = Q_NULLPTR; - _gridPixelTheta = Q_NULLPTR; } -void ScanConversion::cpuProcess(ScenGenOutput_t params) +void ScanConversion::cpuProcess(Input_t params) { - - auto context = _openCLHelper.getContext(); auto queue = BIP::getInstance()->CLQueue; - //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(params.rxLineNo.value * sizeof (myflt))); - auto er = queue.enqueueWriteBuffer(*_gridX,CL_TRUE, 0, static_cast(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(params.rxFocusPointNo.value * sizeof (myflt))); - auto er = queue.enqueueWriteBuffer(*_gridZ, CL_TRUE, 0, static_cast(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) - { - if(_gridPixelXPos) - delete[] _gridPixelXPos; + if(_queryX) + delete _queryX; - if(_gridPixelZPos) - delete[] _gridPixelZPos; + if(_queryZ) + delete _queryZ; - _gridPixelXPos = new myflt[params.outputWidth.value * - params.outputHeight.value]; - _gridPixelZPos = new myflt[params.outputWidth.value * - params.outputHeight.value]; + if(_gridX) + delete _gridX; - _width = params.outputWidth.value; - _height = params.outputHeight.value; + if(_gridZ) + delete _gridZ; - _kernelParameters.width = _width; - } + _gridPixelXPos.clear(); + _gridPixelZPos.clear(); + _scanXPos.clear(); + _scanZPos.clear(); - if(params.depth.isUpdated || params.startDepth.isUpdated || - params.fieldOfView.isUpdated || params.vcMaxTheta.isUpdated || - params.outputWidth.isUpdated || params.outputHeight.isUpdated) - { - auto maxZ = params.depth.value; - auto minZ = params.startDepth.value * cosf(params.vcMaxTheta.value); - auto maxX = params.fieldOfView.value / 2 + maxZ * sinf(params.vcMaxTheta.value); - auto minX = -1 * maxX; + _queryX = _openCLHelper.array2CLBuffer(context, + params.outputWidth * + params.outputHeight * + sizeof (myflt)); + _queryZ = _openCLHelper.array2CLBuffer(context, + params.outputWidth * + params.outputHeight * + sizeof (myflt)); - auto baseZ = (maxZ - minZ) / (params.outputHeight.value - 1); - auto baseX = (maxX - minX) / (params.outputWidth.value - 1); + _gridX = _openCLHelper.array2CLBuffer + (context, static_cast(params.rxLineNo * sizeof (float))); - for(auto i = 0; i < params.outputHeight.value; i++) - { - auto temp = i * baseZ; - for(auto j = 0; j < params.outputWidth.value; j++) - { - _gridPixelZPos[i * params.outputHeight.value + j] = minZ + temp; - _gridPixelXPos[i * params.outputHeight.value + j] = minX + (baseX * j); - } - } + _gridZ = _openCLHelper.array2CLBuffer + (context, static_cast(params.rxFocusPointNo * sizeof (float))); - auto virtualOriginZ = params.fieldOfView.value / 2 / tanf(params.vcMaxTheta.value); + ScanConversionAlg::scanConversion(params, _scanXPos, _scanZPos, _gridPixelXPos, _gridPixelZPos); - if(_gridPixelR) - delete[] _gridPixelR; + queue.enqueueWriteBuffer(*_queryZ, CL_TRUE, 0, + params.outputWidth * + params.outputHeight * + sizeof (myflt), + _gridPixelZPos.data()); - if(_gridPixelTheta) - delete[] _gridPixelTheta; + queue.enqueueWriteBuffer(*_queryX, CL_TRUE, 0, + params.outputWidth * + params.outputHeight * + sizeof (myflt), + _gridPixelXPos.data()); - _gridPixelR = new myflt[params.outputWidth.value * - params.outputHeight.value]; - _gridPixelTheta = new myflt[params.outputWidth.value * - params.outputHeight.value]; + queue.enqueueWriteBuffer(*_gridX, CL_TRUE, 0, + static_cast(params.rxLineNo * sizeof (float)), + _scanXPos.data()); - auto strTan = tanf(params.steering.value); + queue.enqueueWriteBuffer(*_gridZ, CL_TRUE, 0, + static_cast(params.rxFocusPointNo * sizeof (float)), + _scanZPos.data()); - for(auto i = 0; i < params.outputWidth.value * - params.outputHeight.value; i++) - { - auto x = _gridPixelXPos[i]; - auto z = _gridPixelZPos[i]; + _kernelParameters.gridXSize = params.rxLineNo; + _kernelParameters.gridZSize = params.rxFocusPointNo; + _kernelParameters.width = params.outputWidth; - auto pixelTheta = atanf(x / (z + virtualOriginZ)); - - if(pixelTheta >= -params.vcMaxTheta.value - abs(params.steering.value) && - pixelTheta <= params.vcMaxTheta.value + abs(params.steering.value)) - { - if(params.steering.value == 0) - { - auto gridPixelAx = sqrtf(powf(x - virtualOriginZ * tanf(pixelTheta), 2) + powf(z, 2)); - if(gridPixelAx >= params.startDepth.value && - gridPixelAx <= params.depth.value) - { - _gridPixelR[i] = gridPixelAx; - _gridPixelTheta[i] = pixelTheta; - } - else - { - _gridPixelR[i] = 0; - _gridPixelTheta[i] = 0; - } - } - else - { - auto a = virtualOriginZ * strTan; - auto b = x * strTan + virtualOriginZ + z; - auto c = x - z * strTan; - auto interceptTheta = atanf((b + sqrtf(powf(b, 2) - 4 * a * c)) / (2 * a)); - if(interceptTheta > params.vcMaxTheta.value || - interceptTheta < -params.vcMaxTheta.value) - { - interceptTheta = atanf((b - sqrtf(powf(b, 2) - 4 * a * c)) / (2 * a)); - if(interceptTheta > params.vcMaxTheta.value || - interceptTheta < -params.vcMaxTheta.value) - { - _gridPixelR[i] = 0; - _gridPixelTheta[i] = 0; - } - else - { - auto gridPixelAx = sqrtf(powf(x - virtualOriginZ * tanf(interceptTheta), 2) + powf(z, 2)); - if(gridPixelAx >= params.startDepth.value && - gridPixelAx <= params.depth.value) - { - _gridPixelR[i] = gridPixelAx; - _gridPixelTheta[i] = interceptTheta; - } - else - { - _gridPixelR[i] = 0; - _gridPixelTheta[i] = 0; - } - } - } - else - { - auto gridPixelAx = sqrtf(powf(x - virtualOriginZ * tanf(interceptTheta), 2) + powf(z, 2)); - if(gridPixelAx >= params.startDepth.value && - gridPixelAx <= params.depth.value) - { - _gridPixelR[i] = 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); - } - - if(params.minScanAz.isUpdated || params.rxLineNo.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(params.rxLineNo.value) - * sizeof (myflt)); - - queue.enqueueWriteBuffer(*_gridX, CL_TRUE, 0, - static_cast(params.rxLineNo.value) * sizeof (myflt), - _scanXPos); - - _kernelParameters.gridXSize = params.rxLineNo.value; - } - - 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; - } - - _gridZ = _openCLHelper.array2CLBuffer(context, - static_cast(params.rxFocusPointNo.value) - * sizeof (myflt)); - - queue.enqueueWriteBuffer(*_gridZ, CL_TRUE, 0, - static_cast(params.rxFocusPointNo.value) * sizeof (myflt), - _scanZPos); - - _kernelParameters.gridZSize = params.rxFocusPointNo.value; - } - } - - //linear non convex - else - { - 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]; - - 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)); - - _width = params.outputWidth.value; - _height = params.outputHeight.value; - - _kernelParameters.width = _width; - } - - if(params.depth.isUpdated || params.startDepth.isUpdated || - params.fieldOfView.isUpdated || params.steering.isUpdated || - params.outputWidth.isUpdated || params.outputHeight.isUpdated) - { - auto maxZ = params.depth.value; - auto minZ = params.startDepth.value; - auto maxX = params.fieldOfView.value / 2; - auto minX = -1 * maxX; - - 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 tan_result = temp * tanf(params.steering.value); - for(auto j = 0; j < params.outputWidth.value; j++) - { - _gridPixelZPos[i * params.outputHeight.value + j] = minZ + temp; - _gridPixelXPos[i * params.outputHeight.value + j] = minX + (baseX * j) - tan_result; - } - } - - BIP::getInstance()->CLQueue.enqueueWriteBuffer(*_queryX, CL_TRUE, 0, - params.outputWidth.value * - params.outputHeight.value * - sizeof (myflt), - _gridPixelXPos); - queue.enqueueWriteBuffer(*_queryZ, CL_TRUE, 0, - params.outputWidth.value * - params.outputHeight.value * - sizeof (myflt), - _gridPixelZPos); - } - - if(params.fieldOfView.isUpdated || params.rxLineNo.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.fieldOfView.value / 2 + i * params.rxLineDaz.value; - } - - _gridX = _openCLHelper.array2CLBuffer(context, - static_cast(params.rxLineNo.value) - * sizeof (myflt)); - - queue.enqueueWriteBuffer(*_gridX, CL_TRUE, 0, - static_cast(params.rxLineNo.value) * sizeof (myflt), - _scanXPos); - - _kernelParameters.gridXSize = params.rxLineNo.value; - } - - if(params.rxFocusPointNo.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.startDepth.value + i * params.rxPointDax.value; - } - - _gridZ = _openCLHelper.array2CLBuffer(context, - static_cast(params.rxFocusPointNo.value) - * sizeof (myflt)); - - queue.enqueueWriteBuffer(*_gridZ, CL_TRUE, 0, - static_cast(params.rxFocusPointNo.value) * sizeof (myflt), - _scanZPos); - - _kernelParameters.gridZSize = params.rxFocusPointNo.value; - } - } + _width = params.outputWidth; + _height = params.outputHeight; } void ScanConversion::finalize() { - delete _gridPixelXPos; - delete _gridPixelZPos; - delete _scanXPos; - delete _scanZPos; - delete _gridX; delete _gridZ; delete _queryX; delete _queryZ; - _gridPixelXPos = Q_NULLPTR; - _gridPixelZPos = Q_NULLPTR; - _scanXPos = Q_NULLPTR; - _scanZPos = Q_NULLPTR; - _gridX = Q_NULLPTR; _gridZ = Q_NULLPTR; _queryX = Q_NULLPTR; diff --git a/source/model/processor/strategies/Sri.cpp b/source/model/processor/strategies/Sri.cpp index d1090bf..03c691c 100644 --- a/source/model/processor/strategies/Sri.cpp +++ b/source/model/processor/strategies/Sri.cpp @@ -13,12 +13,9 @@ Sri::Sri(const Context context, memset(&_kernelParameters, 0, sizeof (Sri_t)); } -void Sri::cpuProcess(ScenGenOutput_t parameters) +void Sri::cpuProcess(Input_t parameters) { - if(parameters.sri.isUpdated) - { - _kernelParameters.sri = parameters.sri.value; - } + _kernelParameters.sri = parameters.sri; } void Sri::finalize() diff --git a/source/model/processor/strategies/TintMap.cpp b/source/model/processor/strategies/TintMap.cpp index 8492676..3a08baf 100644 --- a/source/model/processor/strategies/TintMap.cpp +++ b/source/model/processor/strategies/TintMap.cpp @@ -13,12 +13,9 @@ TintMap::TintMap(const Context context, memset(&_kernelParameters, 0, sizeof (TintMap_t)); } -void TintMap::cpuProcess(ScenGenOutput_t parameters) +void TintMap::cpuProcess(Input_t parameters) { - if(parameters.tintMapSelector.isUpdated) - { - _kernelParameters.tintMapSelector = parameters.tintMapSelector.value; - } + _kernelParameters.tintMapSelector = parameters.tintMapSelector; } void TintMap::finalize()