You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

57 lines
1.4 KiB

#include "model/processor/strategies/GrayMap.h"
#include "model/processor/BIP.h"
#include <QPixmap>
#include <QImage>
GrayMap::GrayMap(const Context context,
const QString kernelPath,
const QObject *parent = Q_NULLPTR) :
IProcessStrategy(context, kernelPath, "GrayMap", parent),
_kernelFunctor(KernelFunctor<Image2D, Image2D,
GrayMap_t>(_kernel))
{
memset(&_kernelParameters, 0, sizeof (GrayMap_t));
}
void GrayMap::cpuProcess(ScenGenOutput_t parameters)
{
if(parameters.grayMapSelector.isUpdated)
{
_kernelParameters.grayMapSelector = parameters.grayMapSelector.value;
}
}
void GrayMap::finalize()
{
}
Image* GrayMap::processKernel(Image *frames, Buffer* scratchPad)
{
auto width = frames->getImageInfo<CL_IMAGE_WIDTH>();
auto height = frames->getImageInfo<CL_IMAGE_HEIGHT>();
ImageFormat format;
format.image_channel_order = CL_RGBA;
format.image_channel_data_type = CL_UNSIGNED_INT8;
auto imageOutput = new Image2D(_CLContext,
CL_MEM_READ_WRITE,
format,
width,
height);
//width should be lass than CL_DEVICE_MAX_WORK_GROUP_SIZE(1024 for current machine) or this will break
cl::EnqueueArgs eargs(BIP::getInstance()->CLQueue, cl::NDRange(width, height));
_openCLHelper.runKernelFunctor<Image2D, Image2D, GrayMap_t>(_kernelFunctor,
eargs,
*static_cast<Image2D*>(frames),
*imageOutput,
_kernelParameters);
delete frames;
return imageOutput;
}