mirror of
https://github.com/3x4byte/StreetsignRecognition.git
synced 2025-12-21 01:15:52 +00:00
created feature vector of all images
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import csv
|
||||
import cv2 as cv
|
||||
import re
|
||||
|
||||
from util.featue_extraction import get_color_percentage, get_raster_color_percentage, get_edges, get_corners, get_contours
|
||||
from classes.feature_vector import FeatureVector
|
||||
@@ -9,7 +10,7 @@ from classes.feature import Feature
|
||||
|
||||
img_path = os.path.abspath(os.path.join(__file__, "..", "..", "data", "processed"))
|
||||
vector_path = os.path.abspath(os.path.join(__file__, "..", "..", "data", "vectors"))
|
||||
csv_path = os.path.abspath(os.path.join(__file__, "..", "feature_vectors.csv"))
|
||||
csv_path = os.path.abspath(os.path.join(__file__, "..", "all_feature_vectors.csv"))
|
||||
|
||||
def get_concept(path) -> Concept:
|
||||
if "fahrtrichtung_links" in path:
|
||||
@@ -31,7 +32,7 @@ if __name__ == "__main__":
|
||||
# create csv file and insert headers
|
||||
with open(csv_path, "w") as csv_file:
|
||||
csv_writer = csv.writer(csv_file, delimiter=";")
|
||||
csv_writer.writerow(["filename", "concept", "vector"])
|
||||
csv_writer.writerow(["brightness","filename", "concept", "vector"])
|
||||
|
||||
# go to every file in img_path
|
||||
for dirpath, dnames, fnames in os.walk(img_path):
|
||||
@@ -45,8 +46,8 @@ if __name__ == "__main__":
|
||||
image_path = os.path.join(dirpath, fname)
|
||||
|
||||
# only create vectors of images in directory 0 (normal brightness)
|
||||
if not "0\\3500" in image_path:
|
||||
continue
|
||||
# if not "0\\3500" in image_path:
|
||||
# continue
|
||||
|
||||
try:
|
||||
# prepare image
|
||||
@@ -76,9 +77,11 @@ if __name__ == "__main__":
|
||||
vec.add_feature(Feature.OVERALL_COLOR_PERCENTAGE, color_percentage_overall)
|
||||
vec.add_feature(Feature.RASTER_COLOR_PERCENTAGE, color_percentage_rasters)
|
||||
|
||||
brightness = re.search(r'(-2|-1|0|\+1|\+2)', image_path)[1]
|
||||
|
||||
with open(csv_path, "a") as csv_file:
|
||||
csv_writer = csv.writer(csv_file, delimiter=";", lineterminator="\n")
|
||||
csv_writer.writerow([fname, concept, vec.get_vector()])
|
||||
csv_writer.writerow([brightness, fname, concept, vec.get_vector()])
|
||||
|
||||
vec_path = os.path.join(save_path, fname.replace(".jpg", ".pkl"))
|
||||
vec.save(vec_path)
|
||||
Reference in New Issue
Block a user