GCVL
Multi-platform (Windows, Unix and Mac OS) C++/OpenCL/CUDA library with several Computer Vision algorithms.
src/gcvl/opencl/oclblockmatching.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * GPGPU Computer Vision Library (GCVL)
00004  *
00005  * Copyright (c) Luis Omar Alvarez Mures 2015 <omar.alvarez@udc.es>
00006  * Copyright (c) Emilio Padron Gonzalez 2015 <emilioj@gmail.com>
00007  *
00008  * All rights reserved.
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 3 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public
00021  * License along with this library.
00022  *
00023  */
00024 
00025 #pragma once
00026 
00027 #include "../export.h"
00028 #include "../gcvlconfig.h"
00029 #include "oclalgorithm.h"
00030 
00031 #include <memory>
00032 #include <string>
00033 #include <vector>
00034 #include <opencv2/opencv.hpp>
00035 
00036 namespace gcvl { namespace opencl {
00037 
00038     class GCVL_EXPORT BlockMatching : public Algorithm {
00039 
00040     public:
00041         BlockMatching(Core & core, std::string inputLeft, std::string inputRight, std::unique_ptr<unsigned char[]> &output);
00042         ~BlockMatching();
00044 
00047         inline void setAggDim(const int val) { val % 2 == 0 ? _dim = val + 1 : _dim = val; _radius = _dim / 2; _clDim.Initialize(_dim); _clRadius.Initialize(_radius); }
00049 
00052         inline void setMaxDisp(const int val) { val > 255 ? _maxDisp = 255 : _maxDisp = val; _clMaxDisp.Initialize(_maxDisp); }
00054 
00057         inline void setNormalize(const bool val) { _normalize = val; }
00059 
00062         inline unsigned int getWidth() { return _width; }
00064 
00067         inline unsigned int getHeight() { return _height; }
00068         void prepare();
00069         void setArgs();
00070         void launch();
00071         void postpare();
00072 
00073     private:
00074         //Aggregation dimension (odd value)
00075         int _dim;
00076         OpenCL_Data<unsigned int> _clDim;
00077         //Aggregation dimension / 2
00078         int _radius;
00079         OpenCL_Data<unsigned int> _clRadius;
00080         //Maximum disparity
00081         int _maxDisp;
00082         bool _normalize;
00083         OpenCL_Data<unsigned int> _clMaxDisp;
00084         unsigned int _width;
00085         OpenCL_Data<unsigned int> _clWidth;
00086         unsigned int _height;
00087         OpenCL_Data<unsigned int> _clHeight;
00088         cv::Mat _inputLeft;
00089         OpenCL_Array<unsigned char> _clInputLeft;
00090         cv::Mat _inputRight;
00091         OpenCL_Array<unsigned char> _clInputRight;
00092         unsigned char * _output;
00093         OpenCL_Array<unsigned char> _clOutput;
00094         OpenCL_Kernel _normalization;
00095 
00096     };
00097 
00098 } }
 All Classes Namespaces Files Functions Variables Defines