7 changed files with 111 additions and 6 deletions
@ -0,0 +1,32 @@ |
|||
#ifndef REJECTION_H |
|||
#define REJECTION_H |
|||
|
|||
#include <QObject> |
|||
#include <QMetaType> |
|||
#include "header/IProcessStrategy.h" |
|||
#include "header/OpenCLHelper.h" |
|||
|
|||
typedef struct Rejection_t |
|||
{ |
|||
cl_int rejectThr; |
|||
}Rejection_t; |
|||
|
|||
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 finalize() override; |
|||
virtual void ReadParams(QString path, ScenGenOutput_t *params) override; |
|||
|
|||
|
|||
private: |
|||
KernelFunctor<Image2D, Image2D, Rejection_t> _kernelFunctor; |
|||
virtual Image* processKernel(Image *frames) override; |
|||
Rejection_t _kernelParameters; |
|||
|
|||
double _rejectionThr; |
|||
}; |
|||
|
|||
#endif // REJECTION_H
|
@ -0,0 +1,69 @@ |
|||
#include "header/strategies/Rejection.h" |
|||
#include "MainWindow.h" |
|||
#include <QPixmap> |
|||
#include <QImage> |
|||
|
|||
Rejection::Rejection(const Context context, |
|||
const QString kernelPath) : |
|||
IProcessStrategy(context, kernelPath, "Rejection"), |
|||
_kernelFunctor(KernelFunctor<Image2D, Image2D, |
|||
Rejection_t>(_kernel)) |
|||
{ |
|||
|
|||
} |
|||
|
|||
void Rejection::cpuProcess(ScenGenOutput_t parameters) |
|||
{ |
|||
_rejectionThr = parameters.rejectThreshold.value; |
|||
} |
|||
|
|||
void Rejection::finalize() |
|||
{ |
|||
} |
|||
|
|||
void Rejection::ReadParams(QString path, ScenGenOutput_t *params) |
|||
{ |
|||
QFile file(path); |
|||
file.open(QIODevice::ReadOnly); |
|||
|
|||
char data[8192]; |
|||
//first line is extra
|
|||
file.readLine(data, 8192); |
|||
QString str(data); |
|||
str = str.remove(str.length() - 1, 1); |
|||
auto sl = str.split(","); |
|||
|
|||
//decode here
|
|||
/***scenario specific code***/ |
|||
int index = 0; |
|||
|
|||
auto temp = sl[index++].PARSE; |
|||
update_field(¶ms->rejectThreshold, INP2MYFLT(temp)); |
|||
/***End of scenario specific code***/ |
|||
} |
|||
|
|||
|
|||
Image* Rejection::processKernel(Image *frames) |
|||
{ |
|||
Context context = _openCLHelper.getContext(); |
|||
auto format = frames->getImageInfo<CL_IMAGE_FORMAT>(); |
|||
auto width = frames->getImageInfo<CL_IMAGE_WIDTH>(); |
|||
auto height = frames->getImageInfo<CL_IMAGE_HEIGHT>(); |
|||
auto imageOutput = new Image2D(context, |
|||
CL_MEM_READ_WRITE, |
|||
ImageFormat(format.image_channel_order, format.image_channel_data_type), |
|||
width, |
|||
height); |
|||
cl::EnqueueArgs eargs(MainWindow::getInstance()->CLQueue, cl::NDRange(width, height)); |
|||
|
|||
_openCLHelper.runKernelFunctor<Image2D, Image2D, Rejection_t>(_kernelFunctor, |
|||
eargs, |
|||
*static_cast<Image2D*>(frames), |
|||
*imageOutput, |
|||
_kernelParameters); |
|||
delete frames; |
|||
|
|||
return imageOutput; |
|||
} |
|||
|
|||
|
Loading…
Reference in new issue