Skip to content
Snippets Groups Projects
Commit 3b1b87a4 authored by Herman Andersen Dyrkorn's avatar Herman Andersen Dyrkorn
Browse files

Merge branch '14-brute-force-mock-file-structure' into 'master'

Resolve "Brute force mock file structure"

Closes #14

See merge request !17
parents 3bacfd6d fead3d42
No related branches found
No related tags found
1 merge request!17Resolve "Brute force mock file structure"
...@@ -5,3 +5,4 @@ __pycache__ ...@@ -5,3 +5,4 @@ __pycache__
algorithm/train_src/dlc_model algorithm/train_src/dlc_model
img_analyze/*.png img_analyze/*.png
env env
male
\ No newline at end of file
import os
from cv2 import cv2 from cv2 import cv2
from Salamander import Salamander from Salamander import Salamander
from SalamanderImage import SalamanderImage from SalamanderImage import SalamanderImage
...@@ -49,10 +51,24 @@ def match_single_image(input_image, match_image) -> bool: ...@@ -49,10 +51,24 @@ def match_single_image(input_image, match_image) -> bool:
goodmatch = [] goodmatch = []
for m, n in match: for m, n in match:
if m.distance < match_dist * n.distance: if m.distance < match_dist * n.distance:
print("Match!")
goodmatch.append([m]) goodmatch.append([m])
else: # print(len(goodmatch))
print("Not match!") if len(goodmatch) > min_good_match:
print(len(goodmatch)) return True
return False
def match_file_structure(input_image, match_directory) -> int:
for folder in os.listdir(match_directory):
current_dir = match_directory + "\\" + folder
for filename in os.listdir(current_dir):
if filename.endswith("_str.png"):
match_image = current_dir + "\\" + filename
res = match_single_image(input_image, match_image)
if res:
return int(folder)
return -1
res = match_single_image("..\\..\\img_analyze\\img40Edit_str.png", "..\\..\\img_analyze\\img43_str.png") print(match_file_structure("..\\..\\img_analyze\\img81_str.png", "..\\..\\Male"))
# res = match_single_image("..\\..\\img_analyze\\img40Edit_str.png", "..\\..\\img_analyze\\img43_str.png")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment