Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLCV/src/ICLCV/CLSurfLib.h ** 00010 ** Module : ICLCV ** 00011 ** Authors: Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 /****************************************************************************\ 00032 * Copyright (c) 2011, Advanced Micro Devices, Inc. * 00033 * All rights reserved. * 00034 * * 00035 * Redistribution and use in source and binary forms, with or without * 00036 * modification, are permitted provided that the following conditions * 00037 * are met: * 00038 * * 00039 * Redistributions of source code must retain the above copyright notice, * 00040 * this list of conditions and the following disclaimer. * 00041 * * 00042 * Redistributions in binary form must reproduce the above copyright notice, * 00043 * this list of conditions and the following disclaimer in the documentation * 00044 * and/or other materials provided with the distribution. * 00045 * * 00046 * Neither the name of the copyright holder nor the names of its contributors * 00047 * may be used to endorse or promote products derived from this software * 00048 * without specific prior written permission. * 00049 * * 00050 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 00051 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * 00052 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * 00053 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * 00054 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * 00055 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * 00056 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 00057 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 00058 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 00059 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 00060 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 00061 * * 00062 * If you use the software (in whole or in part), you shall adhere to all * 00063 * applicable U.S., European, and other export laws, including but not * 00064 * limited to the U.S. Export Administration Regulations ('EAR'), (15 C.F.R. * 00065 * Sections 730 through 774), and E.U. Council Regulation (EC) No 1334/2000 * 00066 * of 22 June 2000. Further, pursuant to Section 740.6 of the EAR, you * 00067 * hereby certify that, except pursuant to a license granted by the United * 00068 * States Department of Commerce Bureau of Industry and Security or as * 00069 * otherwise permitted pursuant to a License Exception under the U.S. Export * 00070 * Administration Regulations ("EAR"), you will not (1) export, re-export or * 00071 * release to a national of a country in Country Groups D:1, E:1 or E:2 any * 00072 * restricted technology, software, or source code you receive hereunder, * 00073 * or (2) export to Country Groups D:1, E:1 or E:2 the direct product of such * 00074 * technology or software, if such foreign produced direct product is subject * 00075 * to national security controls as identified on the Commerce Control List * 00076 * (currently found in Supplement 1 to Part 774 of EAR). For the most current* 00077 * Country Group listings, or for additional information about the EAR or * 00078 * your obligations under those regulations, please refer to the U.S. Bureau * 00079 * of Industry and Security's website at http://www.bis.doc.gov/. * 00080 \****************************************************************************/ 00081 00082 00083 #pragma once 00084 00085 #include <ICLUtils/CompatMacros.h> 00086 #include <ICLCore/Img.h> 00087 #include <ICLCV/SurfFeature.h> 00088 #include <vector> 00089 #ifdef ICL_HAVE_OPENCL 00090 #include <ICLUtils/CLProgram.h> 00091 #include <ICLUtils/CLKernel.h> 00092 #include <ICLUtils/CLBuffer.h> 00093 #endif 00094 using namespace icl::utils; 00095 00096 namespace icl{ 00097 00098 namespace cv{ 00099 namespace clsurf{ 00100 00102 typedef SurfFeature Ipoint; 00103 00105 typedef std::vector<Ipoint> IpVec; 00106 00107 00109 00112 class Surf { 00113 struct Data; 00114 Data *m_data; 00115 void createKernels(); 00116 00117 public: 00118 00120 ICLCV_API Surf(int initialPoints, int i_height, int i_width, int octaves, 00121 int intervals, int sample_step, float threshold); 00122 00123 ICLCV_API ~Surf(); 00124 00126 ICLCV_API const IpVec &detect(const core::ImgBase *image); 00127 00128 private: 00129 00130 CLProgram program; 00131 CLKernel createDescrtptorsKernel; 00132 CLKernel getOrientationStep1Kernel; 00133 CLKernel getOrientationStep2Kernel; 00134 CLKernel hessian_detKernel; 00135 CLKernel scanKernel; 00136 CLKernel scan4Kernel; 00137 CLKernel scanImageKernel; 00138 CLKernel transposeKernel; 00139 CLKernel transposeImageKernel; 00140 CLKernel nearestNeighborKernel; 00141 CLKernel non_max_supressionKernel; 00142 CLKernel normalizeDescriptorsKernel; 00144 void computeIntegralImage(const icl::core::Img32f &source); 00145 00147 void createDescriptors(int i_width, int i_height); 00148 00150 void getOrientations(int i_width, int i_height); 00151 00153 void reallocateIptBuffers(); 00154 00156 void reset(); 00157 00159 const IpVec &retrieveDescriptors(); 00160 00162 void run(const icl::core::Img32f &image, bool upright); 00163 00164 }; 00165 00166 } 00167 } 00168 }