示例#1
0
        void pyrUp(const cv::ocl::oclMat &src, cv::ocl::oclMat &dst)
        {
            dst.create(src.rows * 2, src.cols * 2, src.type());

            Context *clCxt = src.clCxt;

            const String kernelName = "pyrUp";

            std::vector< std::pair<size_t, const void *> > args;
            args.push_back( std::make_pair( sizeof(cl_mem), (void *)&src.data));
            args.push_back( std::make_pair( sizeof(cl_mem), (void *)&dst.data));
            args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.rows));
            args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.rows));
            args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.cols));
            args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.cols));
            args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.offset));
            args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.offset));
            args.push_back( std::make_pair( sizeof(cl_int), (void *)&src.step));
            args.push_back( std::make_pair( sizeof(cl_int), (void *)&dst.step));

            size_t globalThreads[3] = {dst.cols, dst.rows, 1};
            size_t localThreads[3]  = {16, 16, 1};


            openCLExecuteKernel(clCxt, &pyr_up, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth());
        }
示例#2
0
void cv::ocl::MOG::operator()(const cv::ocl::oclMat& frame, cv::ocl::oclMat& fgmask, float learningRate)
{
    using namespace cv::ocl::device::mog;

    CV_Assert(frame.depth() == CV_8U);

    int ch = frame.oclchannels();
    int work_ch = ch;

    if (nframes_ == 0 || learningRate >= 1.0 || frame.size() != frameSize_ || work_ch != mean_.oclchannels())
        initialize(frame.size(), frame.type());

    fgmask.create(frameSize_, CV_8UC1);

    ++nframes_;
    learningRate = learningRate >= 0.0f && nframes_ > 1 ? learningRate : 1.0f / std::min(nframes_, history);
    CV_Assert(learningRate >= 0.0f);

    mog_ocl(frame, ch, fgmask, weight_, sortKey_, mean_, var_, nmixtures_,
        varThreshold, learningRate, backgroundRatio, noiseSigma);
}