Commit 7c9d8a62 authored by AndersLan's avatar AndersLan
Browse files

added improved matching

parent c6f352a7
......@@ -5,7 +5,7 @@ import glob
min_good_match = 15
match_dist = 0.75
def match_single_image(input_image, match_image) -> bool:
def match_single_image(input_image, match_image):
bf = cv2.BFMatcher()
input_salamander = create_salamander_image(input_image)
match_salamander = create_salamander_image(match_image)
......@@ -17,18 +17,21 @@ def match_single_image(input_image, match_image) -> bool:
if m.distance < match_dist * n.distance:
goodmatch.append([m])
if len(goodmatch) > min_good_match:
return True
return False
return True, len(goodmatch)
return False, 0
def match_file_structure(input_image: str, match_directory: str):
best_match = -1
match_count = 0
def match_file_structure(input_image: str, match_directory: str) -> int:
# check if input path is valid:
if os.path.isfile(input_image):
for folder in os.listdir(match_directory):
name_list = glob.glob(os.path.join(match_directory, folder, "*_str.*"))
for filename in name_list:
res = match_single_image(input_image, filename)
if res:
return int(folder)
return -1
res, num_matches = match_single_image(input_image, filename)
if res and num_matches > match_count:
match_count = num_matches
best_match = int(folder)
return best_match
else:
return None
\ No newline at end of file
return None
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment