Python SourceCode Object-Erkennung
import os, sys
03
04 from faces import detectFaces
05 from skin import detectSkin
06 from ocr import extractText
07
08 def main():
09
10 if len(sys.argv)
!= 3:
11
print("Wrong number of arguments. Usage: python %s
" % sys.argv[0])
12 sys.exit(-1)
13
14 if (sys.argv[1]
== "faces"):
15 processFunc =
detectFaces
16 elif (sys.argv[1]
== "skin"):
17 processFunc =
detectSkin
18 elif (sys.argv[1]
== "text"):
19 processFunc =
extractText
20 else:
21
print('Wrong parameter! Usage: python %s
' % sys.argv[0])
22
sys.exit(-2)
23
24 for lRoot, lDirs,
lFiles in os.walk(sys.argv[2]):
25 for lName in
lFiles:
26 try:
27 pPath =
lRoot + os.sep + lName
28 lResult =
processFunc(pPath)
29 if
lResult[0] == 0:
30
print("""Negative result for: %s
31 -------------------------------------------"""
% pPath)
32 else:
33
print("""Positive result for: %s
34
-------------------------------------------""" % pPath)
35 except
KeyboardInterrupt:
36
print("Cleaning up ...")
37
sys.exit(-1)
38 except
IOError:
39
print("File \'"+ pPath + """\' is not supported
or not a picture!
40
-------------------------------------------""")
41
42 if __name__ == "__main__":
43 main()
Keine Kommentare:
Kommentar veröffentlichen
Hinweis: Nur ein Mitglied dieses Blogs kann Kommentare posten.