-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (52 loc) · 1.8 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!bin/python
from convolution import convolveImage
from contorni import riconoscimentoContorni
from tesseract import returnTextFromImage
import os
from foldermanager import createDir, copiaFoto
import cv2
import numpy as np
cartellaFoto ='todo/'
cartellaTemp='temp/'
folderClassified='done/'
#cartellaClassificateSenzaBollino='done/senzaBollino/'
#cartellaClassificateConBollino='done/conBollino/'
limitPixelOverExposed=2000
def istogram(immagine):
img = cv2.imread(immagine) #reads image data
color = ('b')
histr = cv2.calcHist([img],[0],None,[256],[0,256])
overexposed=histr[200:255]
total = np.sum(overexposed)
return total
def avviaRecuperoTesto(filename):
convolvedImage= convolveImage(filename)
immagineDaRiconoscere= riconoscimentoContorni(convolvedImage)
print (immagineDaRiconoscere)
matricola = returnTextFromImage(immagineDaRiconoscere)
return matricola
def classifica():
for subdir, dirs, files in os.walk(cartellaFoto):
if files:
files.sort()
tempFolder=''
for file in files:
print (file)
src = os.path.join(subdir,file)
pixelOverexposed = istogram(src)
print (pixelOverexposed)
if (pixelOverexposed<=limitPixelOverExposed):
print ("immagine stop")
print ("cropping")
src = os.path.join(subdir,file)
matricola= avviaRecuperoTesto(src)
print (matricola)
tempFolder=matricola
createDir(matricola,folderClassified)
else:
print ("")
copiaFoto(tempFolder,src,folderClassified)
def main():
classifica()
if __name__ == "__main__":
main()