-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (43 loc) · 1.36 KB
/
main.py
File metadata and controls
56 lines (43 loc) · 1.36 KB
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
import csv
import cv2
import dataset_creator as DC
import feature_extractor as FE
import glob
import numpy as np
import os
import read_files as RF
import time
import platform
from scipy import stats
from commonfunctions import *
start_time = time.time()
###################################################################
#WIP
def ReadAndSegment(ii):
if os.path.exists("image_label_pair.csv"):
os.remove("image_label_pair.csv")
Path = './Pattern Data Set/scanned/'
textPath = './Pattern Data Set/text/'
Number_Of_Files = 4000
#Number_Of_Files = 1
gen = glob.iglob(Path+ "*.png")
for i in range(Number_Of_Files):
py = next(gen)
input_image = cv2.imread(py)
splitted = None
if platform.system() == "Windows":
splitted = py.split("\\")
splitted = splitted[1].split(".")
else:
splitted = py.split("/")
splitted = splitted[3].split(".")
splitted = splitted[0]
splitted += ".txt"
list_of_letters = RF.read_text_file(textPath,splitted)
all_words = FE.extractSeparateLettersWholeImage(input_image)
DC.createDataSet(all_words,list_of_letters)
ii += 1
print("Ended Images Index: ",str(ii))
j = 0
ReadAndSegment(j)
print("Running Time In Seconds: {0:.3f}".format(time.time() - start_time))