GpuSurfOctave.cppGo to the documentation of this file.00001 /* 00002 Copyright (c) 2010, Paul Furgale and Chi Hay Tong 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are 00007 met: 00008 00009 * Redistributions of source code must retain the above copyright notice, 00010 this list of conditions and the following disclaimer. 00011 * Redistributions in binary form must reproduce the above copyright 00012 notice, this list of conditions and the following disclaimer in the 00013 documentation and/or other materials provided with the distribution. 00014 * The names of its contributors may not be used to endorse or promote 00015 products derived from this software without specific prior written 00016 permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00020 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00021 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 00022 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00026 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00027 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 */ 00030 00031 #include "GpuSurfOctave.hpp" 00032 #include <cmath> 00033 00034 namespace asrl { 00035 GpuSurfOctave::GpuSurfOctave(){ 00036 init(0,0,1.f,1.f,1.f,1.f,1.f,1.f,0,1,1); 00037 } 00038 00039 GpuSurfOctave::GpuSurfOctave(int img_width, int img_height, float l1, float l2, float l3, float l4, float edge_scale, float base_scale, int octave, int baseStep, int nIntervals) 00040 { 00041 init(img_width, img_height, l1, l2, l3, l4, edge_scale, base_scale, octave, baseStep, nIntervals); 00042 } 00043 00044 void GpuSurfOctave::init(int img_width, int img_height, float l1, float l2, float l3, float l4, float edge_scale, float base_scale, int octave, int baseStep, int nIntervals) 00045 { 00046 // Compute Dxx and Dyy filter half-widths 00047 m_mask_width = l2*0.5f; 00048 m_mask_height = 1.f + l1; 00049 00050 // Compute step size 00051 m_step = baseStep * (1<<octave); 00052 00053 // Compute scales 00054 00055 float d = (base_scale * (1<<octave))/(nIntervals-2); 00056 for(int i = 0; i < nIntervals; i++) 00057 { 00058 m_scales[i] = base_scale * (1<<octave) + d * (i - 1.f) + 0.5f; // scales with SURF-style overlap 00059 } 00060 00061 // Compute border required such that the filters don't overstep the image boundaries 00062 float smax = m_scales[nIntervals-1]; 00063 m_border = (int) ceil(smax * std::max(std::max(m_mask_width, m_mask_height), l3+l4*0.5f)); 00064 00065 // Hessian buffer size 00066 m_width = (img_width - 2*m_border)/m_step; 00067 m_height = (img_height - 2*m_border)/m_step; 00068 m_valid = m_width > 0 && m_height > 0; // Ensure we have a valid Hessian before creating it 00069 //if(m_valid) 00070 //{ 00071 // m_hessian.init(m_width*m_height*nIntervals); 00072 //} 00073 m_intervals = nIntervals; 00074 00075 // Store the filter parameters for weight computation 00076 m_l1 = l1; 00077 m_l2 = l2; 00078 m_l3 = l3; 00079 m_l4 = l4; 00080 m_edge_scale = edge_scale; 00081 } 00082 00083 GpuSurfOctave::operator SurfOctaveParameters(){ 00084 SurfOctaveParameters s; 00085 s.x_size = m_width; 00086 s.y_size = m_height; 00087 s.nIntervals = m_intervals; 00088 s.border = m_border; 00089 s.step = m_step; 00090 s.mask_width = m_mask_width; 00091 s.mask_height = m_mask_height; 00092 s.dxy_center_offset = 0.5f*(m_l4 + m_l3); // Dxy gap half-width 00093 s.dxy_half_width = 0.5f*m_l3; // Dxy squares half-width 00094 s.dxy_scale = m_edge_scale * pow((2.f + 2.f*m_l1) * m_l2 / (4.f*m_l3*m_l3), 2.f); // rescale edge_scale to fit with the filter dimensions 00095 00096 return s; 00097 } 00098 00099 // Lookup to m_hessian 00100 // float & GpuSurfOctave::operator()(int row, int col, int interval) 00101 // { 00102 // ASRL_ASSERT_GE_LT(row,0,height(),"row out of bounds"); 00103 // ASRL_ASSERT_GE_LT(col,0,width(),"col out of bounds"); 00104 // ASRL_ASSERT_GE_LT(interval,0,intervals(),"interval out of bounds"); 00105 00106 // return m_hessian[col + row * width() + interval * width() * height()]; 00107 // } 00108 00109 } // namespace asrl Generated on Fri Apr 30 20:06:20 2010 for gpusurf by 1.6.2 |