Package pycv :: Package cs :: Module cs
[hide private]
[frames] | no frames]

Source Code for Module pycv.cs.cs

 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  __all__ = ['arrayd','approx'] 
25   
26  from scipy import alterdot 
27  from numpy import ascontiguousarray, asarray, all, abs 
28   
29  #------------------------------------------------------------------------------------------ 
30   
31  # Some initializations 
32   
33  alterdot() 
34   
35 -def arrayd(A):
36 """Convert A into a contiguous numpy.array of dtype('float64'), if necessary""" 37 return ascontiguousarray(A,'d')
38
39 -def approx(a,b,epsilon = 10**-6):
40 """Returns true if a and b are of the same shape, and their elements are approximately equal. 41 42 :Parameters: 43 a : array 44 the left operand 45 b : array 46 the right operand 47 epsilon: double 48 the maximum deviance 49 50 :Returns: 51 out: boolean 52 True if a and b are of the same shape, and their elements are approximately equal. 53 """ 54 try: 55 return all(abs(a-b) < epsilon) 56 except: 57 return False
58