Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Salamander - API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Herman Andersen Dyrkorn
Salamander - API
Commits
3c43a2a6
Commit
3c43a2a6
authored
4 years ago
by
Anders Langlie
Browse files
Options
Downloads
Plain Diff
Merge branch '42-add-better-brute-force-matching' into 'master'
Resolve "Add better brute force matching" Closes
#42
See merge request
!45
parents
c6f352a7
7c9d8a62
No related branches found
No related tags found
1 merge request
!45
Resolve "Add better brute force matching"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
algorithm/brute_force_matching.py
+13
-10
13 additions, 10 deletions
algorithm/brute_force_matching.py
with
13 additions
and
10 deletions
algorithm/brute_force_matching.py
+
13
−
10
View file @
3c43a2a6
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment