-
Notifications
You must be signed in to change notification settings - Fork 3
/
readdata.py
42 lines (35 loc) · 1.41 KB
/
readdata.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
import cv2
import os
def read_data(folder_path, count,start, font, data, labels):
for i in range(count):
filename = f"{start+i}.jpeg"
image_path = os.path.join(folder_path, filename)
image = cv2.imread(image_path)
if image is not None:
data.append(image)
labels.append(font)
def read_all_data(folder_path,count,font, data,labels):
for filename in os.listdir(folder_path):
if count==0:
break
count-=1
if filename.endswith((".jpeg")):
image_path = os.path.join(folder_path, filename)
image = cv2.imread(image_path)
if image is not None:
data.append(image)
labels.append(font)
# folder_path = r"F:\LockD\CMP2025\Third_Year\Second_Term\Neural_Networks\Project\testing\3"
# image_list = read_data(folder_path)
# clf = joblib.load('Haar_LPQ.pkl')
# for image in image_list:
# image=preprocess_image(image)
# image=cv2.resize(image,(32,32))
# feature_lpq=lpq(image)
# feature_2d = feature_lpq.reshape(1, -1)
# coeffs = pywt.dwt2(image, 'haar') # Using Haar wavelet as an example
# cA, (cH, cV, cD) = coeffs
# feature_haar = np.concatenate((cA.flatten(), cH.flatten(), cV.flatten(), cD.flatten()))
# features = np.concatenate((feature_haar, feature_lpq))
# result = clf.predict(np.array(features).reshape(1, -1))
# print (result)