Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
multimedia-retrieval
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bakhtali,T.I. (Tariq)
multimedia-retrieval
Commits
bac6f42a
Commit
bac6f42a
authored
2 years ago
by
D1oStar
Browse files
Options
Downloads
Patches
Plain Diff
distance update
parent
ef1c27c5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mmr/include/features.h
+4
-1
4 additions, 1 deletion
src/mmr/include/features.h
src/mmr/src/features.cpp
+24
-12
24 additions, 12 deletions
src/mmr/src/features.cpp
with
28 additions
and
13 deletions
src/mmr/include/features.h
+
4
−
1
View file @
bac6f42a
...
...
@@ -34,7 +34,10 @@ public:
return
std
::
visit
(
AnyGet
{},
input
);
}
static
float
e_dist
(
feature_t
*
F1
,
feature_t
*
F2
)
{
return
*
F1
-
*
F2
;
}
static
float
e_dist
(
feature_t
*
F1
,
feature_t
*
F2
)
{
return
fabs
(
*
F1
-
*
F2
);
}
};
class
FeatureVector
:
public
Feature
...
...
This diff is collapsed.
Click to expand it.
src/mmr/src/features.cpp
+
24
−
12
View file @
bac6f42a
#include
"features.h"
using
namespace
pmp
;
using
pmp
::
Scalar
;
namespace
mmr
{
Scalar
FeatureVector
::
distance
(
Histogram
&
h1
,
Histogram
&
h2
)
{
Scalar
w1
[
10
],
w2
[
10
];
std
::
copy
(
h1
.
histogram
.
begin
(),
h1
.
histogram
.
end
(),
w1
);
std
::
copy
(
h2
.
histogram
.
begin
(),
h2
.
histogram
.
end
(),
w2
);
feature_t
f1
[
10
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
},
f2
[
10
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
};
signature_t
s1
=
{
10
,
f1
,
w1
},
s2
=
{
10
,
f2
,
w2
};
std
::
vector
<
float
>::
size_type
N1
=
h1
.
histogram
.
size
();
std
::
vector
<
float
>::
size_type
N2
=
h2
.
histogram
.
size
();
feature_t
*
f1
=
new
feature_t
[
N1
],
*
f2
=
new
feature_t
[
N2
];
Scalar
*
w1
=
new
Scalar
[
N1
],
*
w2
=
new
Scalar
[
N2
];
int
i
=
0
;
for
(
std
::
vector
<
float
>::
iterator
iter
=
h1
.
histogram
.
begin
();
iter
!=
h1
.
histogram
.
end
();
++
iter
,
++
i
)
{
f1
[
i
]
=
i
;
w1
[
i
]
=
h1
.
histogram
[
*
iter
];
}
i
=
0
;
for
(
std
::
vector
<
float
>::
iterator
iter
=
h1
.
histogram
.
begin
();
iter
!=
h2
.
histogram
.
end
();
++
iter
,
++
i
)
{
f2
[
i
]
=
i
;
w2
[
i
]
=
h2
.
histogram
[
*
iter
];
}
signature_t
s1
=
{
N1
,
f1
,
w1
},
s2
=
{
N2
,
f2
,
w2
};
Scalar
d
=
emd
(
&
s1
,
&
s2
,
Feature
::
e_dist
,
0
,
0
);
return
d
;
}
...
...
@@ -21,15 +33,15 @@ Scalar FeatureVector::distance(std::map<std::string, Scalar>& data1,
std
::
map
<
std
::
string
,
Scalar
>&
data2
,
std
::
vector
<
std
::
string
>&
index
)
{
Scalar
d
(
0.
f
)
;
Eigen
::
VectorXf
f1
,
f2
;
for
(
auto
&
i
:
index
)
{
auto
iter
=
data1
.
find
(
i
);
if
(
iter
==
data1
.
end
()
||
iter
==
data2
.
end
())
continue
;
Scalar
delta
=
data1
[
i
]
-
data2
[
i
]
;
d
+=
delta
*
delta
;
f1
<<
f1
,
Scalar
(
data1
[
i
])
;
f2
<<
f2
,
Scalar
(
data2
[
i
])
;
}
return
sqrtf
(
d
);
return
(
f1
-
f2
).
norm
(
);
}
}
// namespace mmr
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