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

Source Code for Module pycv.pycv

 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__ = ['sdpath','datapath','tprint','speak','ordinal', 'get_version'] 
25   
26  from time import ctime 
27  from os.path import join, dirname 
28   
29  sdpath = dirname(__file__) 
30  datapath = join( sdpath, 'data' ) 
31   
32  # _logfile = open(join( sdpath, 'mylog.txt' ), 'w') -- disable this for now 
33   
34 -def tprint(x):
35 """Print a message to stdout but also fprint it to the global log file.""" 36 s2 = ctime()+": "+str(x) 37 print s2
38 # _logfile.write(s2+'\n') -- disable this for now 39 40 try: 41 from win32com.client import Dispatch 42 _speaker = Dispatch("SAPI.SpVoice")
43 - def speak(s):
44 """Speak a message using text-to-speech (windows-dependent).""" 45 _speaker.Speak(str(s))
46 except:
47 - def speak(s):
48 """Speak a message using text-to-speech (windows-dependent).""" 49 tprint(str(s))
50
51 -def ordinal(n):
52 """Return the string representing the n-th position of a series, e.g. 0th, 1st, 2nd, 3rd, etc.""" 53 b = (n/10)%10 54 if b == 1: 55 suffix = 'th' 56 else: 57 a = n%10 58 if a == 1: 59 suffix = 'st' 60 elif a == 2: 61 suffix = 'nd' 62 elif a == 3: 63 suffix = 'rd' 64 else: 65 suffix = 'th' 66 return str(n)+suffix
67
68 -def get_version():
69 """Return the current version of the package.""" 70 from version import version 71 return version
72