| Home | Trees | Indices | Help |
|---|
|
|
1 # PyCV - A Computer Vision Package for Python Incorporating Fast Training of Face Detection 2 3 # Copyright 2007 Nanyang Technological University, Singapore. 4 # Authors: Minh-Tri Pham, Viet-Dung D. Hoang, and Tat-Jen Cham. 5 6 # This file is part of PyCV. 7 8 # PyCV is free software: you can redistribute it and/or modify 9 # it under the terms of the GNU General Public 10 # License as published by the Free Software Foundation, either version 11 # 3 of the License, or (at your option) any later version. 12 13 # PyCV is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 18 # You should have received a copy of the GNU General Public License 19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 20 21 # --------------------------------------------------------------------- 22 #!/usr/bin/env python 23 24 25 from os.path import join, dirname 26 from scipy.weave import ext_tools 27 from numpy.distutils.misc_util import Configuration, dot_join 28 from numpy import array, zeros 29 30 from extension import get_ext 31 32 # ============================================================================== 33 # Adding new routines to the C++ extension module 34 # ==============================================================================36 mod = get_ext() 37 38 39 #---------------------------------------------------------- 40 # stats_Stats2e_learn(x, d, w, A) 41 #---------------------------------------------------------- 42 # Add d-dimensional vector x, with weight w, into A statistics 43 #---------------------------------------------------------- 44 45 # this is effectively a type declaration for function arguments 46 x = zeros(1,'d') 47 d = 1 48 w = 1.0 49 A = zeros((1,1), 'd') 50 51 # code 52 code = """ 53 int i; 54 double tw0, tw1, tw2; 55 56 tw0 = A[0]; 57 A[0] = tw0+w; 58 59 for( i = 0; i < d; ++i ) 60 { 61 tw1 = A[i+1]; 62 tw2 = A[i+1+d]; 63 A[i+1] = (tw1*tw0+x[i]*w)/A[0]; 64 A[i+1+d] = sqrt(((tw2*tw2+tw1*tw1)*tw0+x[i]*x[i]*w)/A[0] - A[i+1]*A[i+1]); 65 } 66 67 return_val = 1; 68 """ 69 func = ext_tools.ext_function('stats_Stats2e_learn',code, 70 ['x', 'd', 'w', 'A']) 71 mod.add_function(func)72 73 74 75 # ============================================================================== 76 # Configuration 77 # ==============================================================================79 from numpy.distutils.misc_util import Configuration, dot_join 80 config = Configuration('stats',parent_package,top_path) 81 82 config.add_subpackage('gaussian') 83 84 add_routines() 85 86 config.add_data_dir('tests') 87 return config88 89 if __name__ == '__main__': 90 print 'This is the wrong setup.py file to run' 91
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Mon Feb 25 10:24:23 2008 | http://epydoc.sourceforge.net |