Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
3ad82f9d
Commit
3ad82f9d
authored
Aug 05, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
parents
821b7fb6
4c2ef476
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
53 deletions
+52
-53
FindGflags.cmake
modules/sfm/cmake/FindGflags.cmake
+1
-1
FindGlog.cmake
modules/sfm/cmake/FindGlog.cmake
+1
-1
sparse_match_interpolators.cpp
modules/ximgproc/src/sparse_match_interpolators.cpp
+49
-50
inpainting.cpp
modules/xphoto/src/inpainting.cpp
+1
-1
No files found.
modules/sfm/cmake/FindGflags.cmake
View file @
3ad82f9d
...
...
@@ -482,7 +482,7 @@ if (NOT GFLAGS_FOUND)
endif
(
NOT GFLAGS_INCLUDE_DIR OR
NOT EXISTS
${
GFLAGS_INCLUDE_DIR
}
)
find_library
(
GFLAGS_LIBRARY NAMES gflags
find_library
(
GFLAGS_LIBRARY NAMES gflags
gflags_debug gflags_nothreads gflags_nothreads_debug
PATHS
${
GFLAGS_LIBRARY_DIR_HINTS
}
${
GFLAGS_CHECK_LIBRARY_DIRS
}
PATH_SUFFIXES
${
GFLAGS_CHECK_LIBRARY_SUFFIXES
}
)
...
...
modules/sfm/cmake/FindGlog.cmake
View file @
3ad82f9d
...
...
@@ -148,7 +148,7 @@ if (NOT GLOG_INCLUDE_DIR OR
endif
(
NOT GLOG_INCLUDE_DIR OR
NOT EXISTS
${
GLOG_INCLUDE_DIR
}
)
find_library
(
GLOG_LIBRARY NAMES glog
find_library
(
GLOG_LIBRARY NAMES glog
glogd
PATHS
${
GLOG_LIBRARY_DIR_HINTS
}
${
GLOG_CHECK_LIBRARY_DIRS
}
PATH_SUFFIXES
${
GLOG_CHECK_LIBRARY_SUFFIXES
}
)
...
...
modules/ximgproc/src/sparse_match_interpolators.cpp
View file @
3ad82f9d
...
...
@@ -57,16 +57,16 @@ struct SparseMatch
bool
operator
<
(
const
SparseMatch
&
lhs
,
const
SparseMatch
&
rhs
);
void
weightedLeastSquaresAffineFit
(
shor
t
*
labels
,
float
*
weights
,
int
count
,
float
lambda
,
SparseMatch
*
matches
,
Mat
&
dst
);
void
generateHypothesis
(
shor
t
*
labels
,
int
count
,
RNG
&
rng
,
unsigned
char
*
is_used
,
SparseMatch
*
matches
,
Mat
&
dst
);
void
verifyHypothesis
(
shor
t
*
labels
,
float
*
weights
,
int
count
,
SparseMatch
*
matches
,
float
eps
,
float
lambda
,
Mat
&
hypothesis_transform
,
Mat
&
old_transform
,
float
&
old_weighted_num_inliers
);
void
weightedLeastSquaresAffineFit
(
in
t
*
labels
,
float
*
weights
,
int
count
,
float
lambda
,
SparseMatch
*
matches
,
Mat
&
dst
);
void
generateHypothesis
(
in
t
*
labels
,
int
count
,
RNG
&
rng
,
unsigned
char
*
is_used
,
SparseMatch
*
matches
,
Mat
&
dst
);
void
verifyHypothesis
(
in
t
*
labels
,
float
*
weights
,
int
count
,
SparseMatch
*
matches
,
float
eps
,
float
lambda
,
Mat
&
hypothesis_transform
,
Mat
&
old_transform
,
float
&
old_weighted_num_inliers
);
struct
node
{
float
dist
;
shor
t
label
;
in
t
label
;
node
()
{}
node
(
shor
t
l
,
float
d
)
:
dist
(
d
),
label
(
l
)
{}
node
(
in
t
l
,
float
d
)
:
dist
(
d
),
label
(
l
)
{}
};
class
EdgeAwareInterpolatorImpl
CV_FINAL
:
public
EdgeAwareInterpolator
...
...
@@ -78,7 +78,6 @@ public:
protected
:
int
w
,
h
;
int
match_num
;
//internal buffers:
vector
<
node
>*
g
;
Mat
labels
;
...
...
@@ -186,9 +185,9 @@ void EdgeAwareInterpolatorImpl::interpolate(InputArray from_image, InputArray fr
CV_Assert
(
match_num
<
SHRT_MAX
);
Mat
src
=
from_image
.
getMat
();
labels
=
Mat
(
h
,
w
,
CV_
16
S
);
labels
=
Mat
(
h
,
w
,
CV_
32
S
);
labels
=
Scalar
(
-
1
);
NNlabels
=
Mat
(
match_num
,
k
,
CV_
16
S
);
NNlabels
=
Mat
(
match_num
,
k
,
CV_
32
S
);
NNlabels
=
Scalar
(
-
1
);
NNdistances
=
Mat
(
match_num
,
k
,
CV_32F
);
NNdistances
=
Scalar
(
0.0
f
);
...
...
@@ -218,7 +217,7 @@ void EdgeAwareInterpolatorImpl::preprocessData(Mat& src, vector<SparseMatch>& ma
y
=
min
((
int
)(
matches
[
i
].
reference_image_pos
.
y
+
0.5
f
),
h
-
1
);
distances
.
at
<
float
>
(
y
,
x
)
=
0.0
f
;
labels
.
at
<
short
>
(
y
,
x
)
=
(
shor
t
)
i
;
labels
.
at
<
int
>
(
y
,
x
)
=
(
in
t
)
i
;
}
computeGradientMagnitude
(
src
,
cost_map
);
...
...
@@ -234,7 +233,7 @@ void EdgeAwareInterpolatorImpl::computeGradientMagnitude(Mat& src, Mat& dst)
Mat
dx
,
dy
;
Sobel
(
src
,
dx
,
CV_16S
,
1
,
0
);
Sobel
(
src
,
dy
,
CV_16S
,
0
,
1
);
float
norm_coef
=
src
.
channels
()
*
4
.0
f
*
255.0
f
;
float
norm_coef
=
src
.
channels
()
*
4
*
255.0
f
;
if
(
src
.
channels
()
==
1
)
{
...
...
@@ -272,8 +271,8 @@ void EdgeAwareInterpolatorImpl::geodesicDistanceTransform(Mat& distances, Mat& c
int
i
,
j
;
float
*
dist_row
,
*
cost_row
;
float
*
dist_row_prev
,
*
cost_row_prev
;
shor
t
*
label_row
;
shor
t
*
label_row_prev
;
in
t
*
label_row
;
in
t
*
label_row_prev
;
#define CHECK(cur_dist,cur_label,cur_cost,prev_dist,prev_label,prev_cost,coef)\
{\
...
...
@@ -287,7 +286,7 @@ void EdgeAwareInterpolatorImpl::geodesicDistanceTransform(Mat& distances, Mat& c
{
//first pass (left-to-right, top-to-bottom):
dist_row
=
distances
.
ptr
<
float
>
(
0
);
label_row
=
labels
.
ptr
<
shor
t
>
(
0
);
label_row
=
labels
.
ptr
<
in
t
>
(
0
);
cost_row
=
cost_map
.
ptr
<
float
>
(
0
);
for
(
j
=
1
;
j
<
w
;
j
++
)
CHECK
(
dist_row
[
j
],
label_row
[
j
],
cost_row
[
j
],
dist_row
[
j
-
1
],
label_row
[
j
-
1
],
cost_row
[
j
-
1
],
c1
);
...
...
@@ -297,8 +296,8 @@ void EdgeAwareInterpolatorImpl::geodesicDistanceTransform(Mat& distances, Mat& c
dist_row
=
distances
.
ptr
<
float
>
(
i
);
dist_row_prev
=
distances
.
ptr
<
float
>
(
i
-
1
);
label_row
=
labels
.
ptr
<
shor
t
>
(
i
);
label_row_prev
=
labels
.
ptr
<
shor
t
>
(
i
-
1
);
label_row
=
labels
.
ptr
<
in
t
>
(
i
);
label_row_prev
=
labels
.
ptr
<
in
t
>
(
i
-
1
);
cost_row
=
cost_map
.
ptr
<
float
>
(
i
);
cost_row_prev
=
cost_map
.
ptr
<
float
>
(
i
-
1
);
...
...
@@ -321,7 +320,7 @@ void EdgeAwareInterpolatorImpl::geodesicDistanceTransform(Mat& distances, Mat& c
//second pass (right-to-left, bottom-to-top):
dist_row
=
distances
.
ptr
<
float
>
(
h
-
1
);
label_row
=
labels
.
ptr
<
shor
t
>
(
h
-
1
);
label_row
=
labels
.
ptr
<
in
t
>
(
h
-
1
);
cost_row
=
cost_map
.
ptr
<
float
>
(
h
-
1
);
for
(
j
=
w
-
2
;
j
>=
0
;
j
--
)
CHECK
(
dist_row
[
j
],
label_row
[
j
],
cost_row
[
j
],
dist_row
[
j
+
1
],
label_row
[
j
+
1
],
cost_row
[
j
+
1
],
c1
);
...
...
@@ -331,8 +330,8 @@ void EdgeAwareInterpolatorImpl::geodesicDistanceTransform(Mat& distances, Mat& c
dist_row
=
distances
.
ptr
<
float
>
(
i
);
dist_row_prev
=
distances
.
ptr
<
float
>
(
i
+
1
);
label_row
=
labels
.
ptr
<
shor
t
>
(
i
);
label_row_prev
=
labels
.
ptr
<
shor
t
>
(
i
+
1
);
label_row
=
labels
.
ptr
<
in
t
>
(
i
);
label_row_prev
=
labels
.
ptr
<
in
t
>
(
i
+
1
);
cost_row
=
cost_map
.
ptr
<
float
>
(
i
);
cost_row_prev
=
cost_map
.
ptr
<
float
>
(
i
+
1
);
...
...
@@ -360,8 +359,8 @@ void EdgeAwareInterpolatorImpl::buildGraph(Mat& distances, Mat& cost_map)
{
float
*
dist_row
,
*
cost_row
;
float
*
dist_row_prev
,
*
cost_row_prev
;
shor
t
*
label_row
;
shor
t
*
label_row_prev
;
in
t
*
label_row
;
in
t
*
label_row_prev
;
int
i
,
j
;
const
float
c1
=
1.0
f
/
2.0
f
;
const
float
c2
=
sqrt
(
2.0
f
)
/
2.0
f
;
...
...
@@ -387,7 +386,7 @@ void EdgeAwareInterpolatorImpl::buildGraph(Mat& distances, Mat& cost_map)
}
dist_row
=
distances
.
ptr
<
float
>
(
0
);
label_row
=
labels
.
ptr
<
shor
t
>
(
0
);
label_row
=
labels
.
ptr
<
in
t
>
(
0
);
cost_row
=
cost_map
.
ptr
<
float
>
(
0
);
for
(
j
=
1
;
j
<
w
;
j
++
)
CHECK
(
dist_row
[
j
],
label_row
[
j
],
cost_row
[
j
],
dist_row
[
j
-
1
],
label_row
[
j
-
1
],
cost_row
[
j
-
1
],
c1
);
...
...
@@ -397,8 +396,8 @@ void EdgeAwareInterpolatorImpl::buildGraph(Mat& distances, Mat& cost_map)
dist_row
=
distances
.
ptr
<
float
>
(
i
);
dist_row_prev
=
distances
.
ptr
<
float
>
(
i
-
1
);
label_row
=
labels
.
ptr
<
shor
t
>
(
i
);
label_row_prev
=
labels
.
ptr
<
shor
t
>
(
i
-
1
);
label_row
=
labels
.
ptr
<
in
t
>
(
i
);
label_row_prev
=
labels
.
ptr
<
in
t
>
(
i
-
1
);
cost_row
=
cost_map
.
ptr
<
float
>
(
i
);
cost_row_prev
=
cost_map
.
ptr
<
float
>
(
i
-
1
);
...
...
@@ -442,7 +441,7 @@ void EdgeAwareInterpolatorImpl::buildGraph(Mat& distances, Mat& cost_map)
}
if
(
!
found
)
g
[
neighbors
[
j
].
label
].
push_back
(
node
((
shor
t
)
i
,
neighbors
[
j
].
dist
));
g
[
neighbors
[
j
].
label
].
push_back
(
node
((
in
t
)
i
,
neighbors
[
j
].
dist
));
}
}
}
...
...
@@ -453,18 +452,18 @@ struct nodeHeap
// children: 2*i, 2*i+1
// parent: i>>1
node
*
heap
;
shor
t
*
heap_pos
;
in
t
*
heap_pos
;
node
tmp_node
;
shor
t
size
;
shor
t
num_labels
;
in
t
size
;
in
t
num_labels
;
nodeHeap
(
shor
t
_num_labels
)
nodeHeap
(
in
t
_num_labels
)
{
num_labels
=
_num_labels
;
heap
=
new
node
[
num_labels
+
1
];
heap
[
0
]
=
node
(
-
1
,
-
1.0
f
);
heap_pos
=
new
shor
t
[
num_labels
];
memset
(
heap_pos
,
0
,
sizeof
(
shor
t
)
*
num_labels
);
heap_pos
=
new
in
t
[
num_labels
];
memset
(
heap_pos
,
0
,
sizeof
(
in
t
)
*
num_labels
);
size
=
0
;
}
...
...
@@ -477,7 +476,7 @@ struct nodeHeap
void
clear
()
{
size
=
0
;
memset
(
heap_pos
,
0
,
sizeof
(
shor
t
)
*
num_labels
);
memset
(
heap_pos
,
0
,
sizeof
(
in
t
)
*
num_labels
);
}
inline
bool
empty
()
...
...
@@ -485,7 +484,7 @@ struct nodeHeap
return
(
size
==
0
);
}
inline
void
nodeSwap
(
short
idx1
,
shor
t
idx2
)
inline
void
nodeSwap
(
int
idx1
,
in
t
idx2
)
{
heap_pos
[
heap
[
idx1
].
label
]
=
idx2
;
heap_pos
[
heap
[
idx2
].
label
]
=
idx1
;
...
...
@@ -500,8 +499,8 @@ struct nodeHeap
size
++
;
heap
[
size
]
=
n
;
heap_pos
[
n
.
label
]
=
size
;
shor
t
i
=
size
;
shor
t
parent_i
=
i
>>
1
;
in
t
i
=
size
;
in
t
parent_i
=
i
>>
1
;
while
(
heap
[
i
].
dist
<
heap
[
parent_i
].
dist
)
{
nodeSwap
(
i
,
parent_i
);
...
...
@@ -515,8 +514,8 @@ struct nodeHeap
node
res
=
heap
[
1
];
heap_pos
[
res
.
label
]
=
0
;
shor
t
i
=
1
;
shor
t
left
,
right
;
in
t
i
=
1
;
in
t
left
,
right
;
while
(
(
left
=
i
<<
1
)
<
size
)
{
right
=
left
+
1
;
...
...
@@ -543,7 +542,7 @@ struct nodeHeap
heap
[
i
]
=
heap
[
size
];
heap_pos
[
heap
[
i
].
label
]
=
i
;
shor
t
parent_i
=
i
>>
1
;
in
t
parent_i
=
i
>>
1
;
while
(
heap
[
i
].
dist
<
heap
[
parent_i
].
dist
)
{
nodeSwap
(
i
,
parent_i
);
...
...
@@ -562,9 +561,9 @@ struct nodeHeap
{
if
(
heap_pos
[
n
.
label
])
{
shor
t
i
=
heap_pos
[
n
.
label
];
in
t
i
=
heap_pos
[
n
.
label
];
heap
[
i
].
dist
=
min
(
heap
[
i
].
dist
,
n
.
dist
);
shor
t
parent_i
=
i
>>
1
;
in
t
parent_i
=
i
>>
1
;
while
(
heap
[
i
].
dist
<
heap
[
parent_i
].
dist
)
{
nodeSwap
(
i
,
parent_i
);
...
...
@@ -587,7 +586,7 @@ void EdgeAwareInterpolatorImpl::GetKNNMatches_ParBody::operator() (const Range&
{
int
start
=
std
::
min
(
range
.
start
*
stripe_sz
,
inst
->
match_num
);
int
end
=
std
::
min
(
range
.
end
*
stripe_sz
,
inst
->
match_num
);
nodeHeap
q
((
shor
t
)
inst
->
match_num
);
nodeHeap
q
((
in
t
)
inst
->
match_num
);
int
num_expanded_vertices
;
unsigned
char
*
expanded_flag
=
new
unsigned
char
[
inst
->
match_num
];
node
*
neighbors
;
...
...
@@ -600,8 +599,8 @@ void EdgeAwareInterpolatorImpl::GetKNNMatches_ParBody::operator() (const Range&
num_expanded_vertices
=
0
;
memset
(
expanded_flag
,
0
,
inst
->
match_num
);
q
.
clear
();
q
.
add
(
node
((
shor
t
)
i
,
0.0
f
));
short
*
NNlabels_row
=
inst
->
NNlabels
.
ptr
<
shor
t
>
(
i
);
q
.
add
(
node
((
in
t
)
i
,
0.0
f
));
int
*
NNlabels_row
=
inst
->
NNlabels
.
ptr
<
in
t
>
(
i
);
float
*
NNdistances_row
=
inst
->
NNdistances
.
ptr
<
float
>
(
i
);
while
(
num_expanded_vertices
<
inst
->
k
&&
!
q
.
empty
())
{
...
...
@@ -625,7 +624,7 @@ void EdgeAwareInterpolatorImpl::GetKNNMatches_ParBody::operator() (const Range&
delete
[]
expanded_flag
;
}
void
weightedLeastSquaresAffineFit
(
shor
t
*
labels
,
float
*
weights
,
int
count
,
float
lambda
,
SparseMatch
*
matches
,
Mat
&
dst
)
void
weightedLeastSquaresAffineFit
(
in
t
*
labels
,
float
*
weights
,
int
count
,
float
lambda
,
SparseMatch
*
matches
,
Mat
&
dst
)
{
double
sa
[
6
][
6
]
=
{{
0.
}},
sb
[
6
]
=
{
0.
};
Mat
A
(
6
,
6
,
CV_64F
,
&
sa
[
0
][
0
]),
...
...
@@ -672,7 +671,7 @@ void weightedLeastSquaresAffineFit(short* labels, float* weights, int count, flo
MM
.
reshape
(
2
,
3
).
convertTo
(
dst
,
CV_32F
);
}
void
generateHypothesis
(
shor
t
*
labels
,
int
count
,
RNG
&
rng
,
unsigned
char
*
is_used
,
SparseMatch
*
matches
,
Mat
&
dst
)
void
generateHypothesis
(
in
t
*
labels
,
int
count
,
RNG
&
rng
,
unsigned
char
*
is_used
,
SparseMatch
*
matches
,
Mat
&
dst
)
{
int
idx
;
Point2f
src_points
[
3
];
...
...
@@ -703,7 +702,7 @@ void generateHypothesis(short* labels, int count, RNG& rng, unsigned char* is_us
getAffineTransform
(
src_points
,
dst_points
).
convertTo
(
dst
,
CV_32F
);
}
void
verifyHypothesis
(
shor
t
*
labels
,
float
*
weights
,
int
count
,
SparseMatch
*
matches
,
float
eps
,
float
lambda
,
Mat
&
hypothesis_transform
,
Mat
&
old_transform
,
float
&
old_weighted_num_inliers
)
void
verifyHypothesis
(
in
t
*
labels
,
float
*
weights
,
int
count
,
SparseMatch
*
matches
,
float
eps
,
float
lambda
,
Mat
&
hypothesis_transform
,
Mat
&
old_transform
,
float
&
old_weighted_num_inliers
)
{
float
*
tr
=
hypothesis_transform
.
ptr
<
float
>
(
0
);
Point2f
a
,
b
;
...
...
@@ -749,12 +748,12 @@ void EdgeAwareInterpolatorImpl::RansacInterpolation_ParBody::operator() (const R
start
=
tmp
-
1
;
}
shor
t
*
KNNlabels
;
in
t
*
KNNlabels
;
float
*
KNNdistances
;
unsigned
char
*
is_used
=
new
unsigned
char
[
inst
->
k
];
Mat
hypothesis_transform
;
short
*
inlier_labels
=
new
shor
t
[
inst
->
k
];
int
*
inlier_labels
=
new
in
t
[
inst
->
k
];
float
*
inlier_distances
=
new
float
[
inst
->
k
];
float
*
tr
;
int
num_inliers
;
...
...
@@ -765,7 +764,7 @@ void EdgeAwareInterpolatorImpl::RansacInterpolation_ParBody::operator() (const R
if
(
inst
->
g
[
i
].
empty
())
continue
;
KNNlabels
=
inst
->
NNlabels
.
ptr
<
shor
t
>
(
i
);
KNNlabels
=
inst
->
NNlabels
.
ptr
<
in
t
>
(
i
);
KNNdistances
=
inst
->
NNdistances
.
ptr
<
float
>
(
i
);
if
(
inc
>
0
)
//forward pass
{
...
...
@@ -846,11 +845,11 @@ void EdgeAwareInterpolatorImpl::ransacInterpolation(vector<SparseMatch>& matches
parallel_for_
(
Range
(
0
,
ransac_num_stripes
),
RansacInterpolation_ParBody
(
*
this
,
transforms
,
weighted_inlier_nums
,
eps
,
&
matches
.
front
(),
ransac_num_stripes
,
-
1
));
//construct the final piecewise-affine interpolation:
shor
t
*
label_row
;
in
t
*
label_row
;
float
*
tr
;
for
(
int
i
=
0
;
i
<
h
;
i
++
)
{
label_row
=
labels
.
ptr
<
shor
t
>
(
i
);
label_row
=
labels
.
ptr
<
in
t
>
(
i
);
Point2f
*
dst_row
=
dst_dense_flow
.
ptr
<
Point2f
>
(
i
);
for
(
int
j
=
0
;
j
<
w
;
j
++
)
{
...
...
modules/xphoto/src/inpainting.cpp
View file @
3ad82f9d
...
...
@@ -83,7 +83,7 @@ namespace xphoto
cv
::
resize
(
_src
,
src
,
_src
.
size
()
/
ls
,
0
,
0
,
cv
::
INTER_AREA
);
src
.
convertTo
(
img
,
CV_32F
);
img
.
setTo
(
0
,
255
-
mask
);
img
.
setTo
(
0
,
~
(
mask
>
0
)
);
cv
::
erode
(
mask
,
dmask
,
cv
::
Mat
(),
cv
::
Point
(
-
1
,
-
1
),
2
);
cv
::
erode
(
dmask
,
ddmask
,
cv
::
Mat
(),
cv
::
Point
(
-
1
,
-
1
),
2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment