Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
fbe2e6fb
Commit
fbe2e6fb
authored
Sep 05, 2011
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored stitching module
parent
9be4701f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
198 additions
and
226 deletions
+198
-226
autocalib.cpp
modules/stitching/src/autocalib.cpp
+18
-22
blenders.cpp
modules/stitching/src/blenders.cpp
+18
-22
camera.cpp
modules/stitching/src/camera.cpp
+4
-8
exposure_compensate.cpp
modules/stitching/src/exposure_compensate.cpp
+11
-15
matchers.cpp
modules/stitching/src/matchers.cpp
+59
-66
motion_estimators.cpp
modules/stitching/src/motion_estimators.cpp
+54
-48
seam_finders.cpp
modules/stitching/src/seam_finders.cpp
+14
-18
util.cpp
modules/stitching/src/util.cpp
+10
-14
warpers.cpp
modules/stitching/src/warpers.cpp
+10
-13
No files found.
modules/stitching/src/autocalib.cpp
View file @
fbe2e6fb
...
...
@@ -42,11 +42,24 @@
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
namespace
cv
namespace
{
template
<
typename
_Tp
>
static
inline
bool
decomposeCholesky
(
_Tp
*
A
,
size_t
astep
,
int
m
)
{
if
(
!
Cholesky
(
A
,
astep
,
m
,
0
,
0
,
0
))
return
false
;
astep
/=
sizeof
(
A
[
0
]);
for
(
int
i
=
0
;
i
<
m
;
++
i
)
A
[
i
*
astep
+
i
]
=
(
_Tp
)(
1.
/
A
[
i
*
astep
+
i
]);
return
true
;
}
}
// namespace
void
focalsFromHomography
(
const
Mat
&
H
,
double
&
f0
,
double
&
f1
,
bool
&
f0_ok
,
bool
&
f1_ok
)
void
cv
::
focalsFromHomography
(
const
Mat
&
H
,
double
&
f0
,
double
&
f1
,
bool
&
f0_ok
,
bool
&
f1_ok
)
{
CV_Assert
(
H
.
type
()
==
CV_64F
&&
H
.
size
()
==
Size
(
3
,
3
));
...
...
@@ -77,8 +90,8 @@ void focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, boo
}
void
estimateFocal
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
double
>
&
focals
)
void
cv
::
estimateFocal
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
double
>
&
focals
)
{
const
int
num_images
=
static_cast
<
int
>
(
features
.
size
());
focals
.
resize
(
num_images
);
...
...
@@ -118,22 +131,7 @@ void estimateFocal(const vector<ImageFeatures> &features, const vector<MatchesIn
}
namespace
{
template
<
typename
_Tp
>
static
inline
bool
decomposeCholesky
(
_Tp
*
A
,
size_t
astep
,
int
m
)
{
if
(
!
Cholesky
(
A
,
astep
,
m
,
0
,
0
,
0
))
return
false
;
astep
/=
sizeof
(
A
[
0
]);
for
(
int
i
=
0
;
i
<
m
;
++
i
)
A
[
i
*
astep
+
i
]
=
(
_Tp
)(
1.
/
A
[
i
*
astep
+
i
]);
return
true
;
}
}
// namespace
bool
calibrateRotatingCamera
(
const
vector
<
Mat
>
&
Hs
,
Mat
&
K
)
bool
cv
::
calibrateRotatingCamera
(
const
vector
<
Mat
>
&
Hs
,
Mat
&
K
)
{
int
m
=
static_cast
<
int
>
(
Hs
.
size
());
CV_Assert
(
m
>=
1
);
...
...
@@ -183,5 +181,3 @@ bool calibrateRotatingCamera(const vector<Mat> &Hs, Mat &K)
K
=
W
.
t
();
return
true
;
}
}
// namespace cv
modules/stitching/src/blenders.cpp
View file @
fbe2e6fb
...
...
@@ -42,13 +42,11 @@
#include "precomp.hpp"
using
namespace
std
;
namespace
cv
{
using
namespace
cv
;
static
const
float
WEIGHT_EPS
=
1e-5
f
;
Ptr
<
Blender
>
Blender
::
createDefault
(
int
type
,
bool
try_gpu
)
Ptr
<
Blender
>
cv
::
Blender
::
createDefault
(
int
type
,
bool
try_gpu
)
{
if
(
type
==
NO
)
return
new
Blender
();
...
...
@@ -61,13 +59,13 @@ Ptr<Blender> Blender::createDefault(int type, bool try_gpu)
}
void
Blender
::
prepare
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Size
>
&
sizes
)
void
cv
::
Blender
::
prepare
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Size
>
&
sizes
)
{
prepare
(
resultRoi
(
corners
,
sizes
));
}
void
Blender
::
prepare
(
Rect
dst_roi
)
void
cv
::
Blender
::
prepare
(
Rect
dst_roi
)
{
dst_
.
create
(
dst_roi
.
size
(),
CV_16SC3
);
dst_
.
setTo
(
Scalar
::
all
(
0
));
...
...
@@ -77,7 +75,7 @@ void Blender::prepare(Rect dst_roi)
}
void
Blender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
void
cv
::
Blender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
{
CV_Assert
(
img
.
type
()
==
CV_16SC3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
...
...
@@ -101,7 +99,7 @@ void Blender::feed(const Mat &img, const Mat &mask, Point tl)
}
void
Blender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
void
cv
::
Blender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
{
dst_
.
setTo
(
Scalar
::
all
(
0
),
dst_mask_
==
0
);
dst
=
dst_
;
...
...
@@ -111,7 +109,7 @@ void Blender::blend(Mat &dst, Mat &dst_mask)
}
void
FeatherBlender
::
prepare
(
Rect
dst_roi
)
void
cv
::
FeatherBlender
::
prepare
(
Rect
dst_roi
)
{
Blender
::
prepare
(
dst_roi
);
dst_weight_map_
.
create
(
dst_roi
.
size
(),
CV_32F
);
...
...
@@ -119,7 +117,7 @@ void FeatherBlender::prepare(Rect dst_roi)
}
void
FeatherBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
void
cv
::
FeatherBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
{
CV_Assert
(
img
.
type
()
==
CV_16SC3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
...
...
@@ -146,7 +144,7 @@ void FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl)
}
void
FeatherBlender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
void
cv
::
FeatherBlender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
{
normalizeUsingWeightMap
(
dst_weight_map_
,
dst_
);
dst_mask_
=
dst_weight_map_
>
WEIGHT_EPS
;
...
...
@@ -154,14 +152,14 @@ void FeatherBlender::blend(Mat &dst, Mat &dst_mask)
}
MultiBandBlender
::
MultiBandBlender
(
int
try_gpu
,
int
num_bands
)
cv
::
MultiBandBlender
::
MultiBandBlender
(
int
try_gpu
,
int
num_bands
)
{
setNumBands
(
num_bands
);
can_use_gpu_
=
try_gpu
&&
gpu
::
getCudaEnabledDeviceCount
();
}
void
MultiBandBlender
::
prepare
(
Rect
dst_roi
)
void
cv
::
MultiBandBlender
::
prepare
(
Rect
dst_roi
)
{
dst_roi_final_
=
dst_roi
;
...
...
@@ -194,7 +192,7 @@ void MultiBandBlender::prepare(Rect dst_roi)
}
void
MultiBandBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
void
cv
::
MultiBandBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
{
CV_Assert
(
img
.
type
()
==
CV_16SC3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
...
...
@@ -279,7 +277,7 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)
}
void
MultiBandBlender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
void
cv
::
MultiBandBlender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
{
for
(
int
i
=
0
;
i
<=
num_bands_
;
++
i
)
normalizeUsingWeightMap
(
dst_band_weights_
[
i
],
dst_pyr_laplace_
[
i
]);
...
...
@@ -300,7 +298,7 @@ void MultiBandBlender::blend(Mat &dst, Mat &dst_mask)
//////////////////////////////////////////////////////////////////////////////
// Auxiliary functions
void
normalizeUsingWeightMap
(
const
Mat
&
weight
,
Mat
&
src
)
void
cv
::
normalizeUsingWeightMap
(
const
Mat
&
weight
,
Mat
&
src
)
{
CV_Assert
(
weight
.
type
()
==
CV_32F
);
CV_Assert
(
src
.
type
()
==
CV_16SC3
);
...
...
@@ -319,7 +317,7 @@ void normalizeUsingWeightMap(const Mat& weight, Mat& src)
}
void
createWeightMap
(
const
Mat
&
mask
,
float
sharpness
,
Mat
&
weight
)
void
c
v
::
c
reateWeightMap
(
const
Mat
&
mask
,
float
sharpness
,
Mat
&
weight
)
{
CV_Assert
(
mask
.
type
()
==
CV_8U
);
distanceTransform
(
mask
,
weight
,
CV_DIST_L1
,
3
);
...
...
@@ -327,7 +325,7 @@ void createWeightMap(const Mat &mask, float sharpness, Mat &weight)
}
void
createLaplacePyr
(
const
Mat
&
img
,
int
num_levels
,
vector
<
Mat
>
&
pyr
)
void
c
v
::
c
reateLaplacePyr
(
const
Mat
&
img
,
int
num_levels
,
vector
<
Mat
>
&
pyr
)
{
pyr
.
resize
(
num_levels
+
1
);
pyr
[
0
]
=
img
;
...
...
@@ -342,7 +340,7 @@ void createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)
}
void
createLaplacePyrGpu
(
const
Mat
&
img
,
int
num_levels
,
vector
<
Mat
>
&
pyr
)
void
c
v
::
c
reateLaplacePyrGpu
(
const
Mat
&
img
,
int
num_levels
,
vector
<
Mat
>
&
pyr
)
{
pyr
.
resize
(
num_levels
+
1
);
...
...
@@ -363,7 +361,7 @@ void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
}
void
restoreImageFromLaplacePyr
(
vector
<
Mat
>
&
pyr
)
void
cv
::
restoreImageFromLaplacePyr
(
vector
<
Mat
>
&
pyr
)
{
if
(
pyr
.
size
()
==
0
)
return
;
...
...
@@ -374,5 +372,3 @@ void restoreImageFromLaplacePyr(vector<Mat> &pyr)
add
(
tmp
,
pyr
[
i
-
1
],
pyr
[
i
-
1
]);
}
}
}
// namespace cv
modules/stitching/src/camera.cpp
View file @
fbe2e6fb
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
namespace
cv
{
CameraParams
::
CameraParams
()
:
focal
(
1
),
R
(
Mat
::
eye
(
3
,
3
,
CV_64F
)),
t
(
Mat
::
zeros
(
3
,
1
,
CV_64F
))
{}
cv
::
CameraParams
::
CameraParams
()
:
focal
(
1
),
R
(
Mat
::
eye
(
3
,
3
,
CV_64F
)),
t
(
Mat
::
zeros
(
3
,
1
,
CV_64F
))
{}
CameraParams
::
CameraParams
(
const
CameraParams
&
other
)
{
*
this
=
other
;
}
cv
::
CameraParams
::
CameraParams
(
const
CameraParams
&
other
)
{
*
this
=
other
;
}
const
CameraParams
&
CameraParams
::
operator
=
(
const
CameraParams
&
other
)
const
cv
::
CameraParams
&
CameraParams
::
operator
=
(
const
CameraParams
&
other
)
{
focal
=
other
.
focal
;
R
=
other
.
R
.
clone
();
t
=
other
.
t
.
clone
();
return
*
this
;
}
}
// namespace cv
modules/stitching/src/exposure_compensate.cpp
View file @
fbe2e6fb
...
...
@@ -42,12 +42,10 @@
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
gpu
;
namespace
cv
{
Ptr
<
ExposureCompensator
>
ExposureCompensator
::
createDefault
(
int
type
)
Ptr
<
ExposureCompensator
>
cv
::
ExposureCompensator
::
createDefault
(
int
type
)
{
if
(
type
==
NO
)
return
new
NoExposureCompensator
();
...
...
@@ -60,8 +58,8 @@ Ptr<ExposureCompensator> ExposureCompensator::createDefault(int type)
}
void
ExposureCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
const
vector
<
Mat
>
&
masks
)
void
cv
::
ExposureCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
const
vector
<
Mat
>
&
masks
)
{
vector
<
pair
<
Mat
,
uchar
>
>
level_masks
;
for
(
size_t
i
=
0
;
i
<
masks
.
size
();
++
i
)
...
...
@@ -70,8 +68,8 @@ void ExposureCompensator::feed(const vector<Point> &corners, const vector<Mat> &
}
void
GainCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
const
vector
<
pair
<
Mat
,
uchar
>
>
&
masks
)
void
cv
::
GainCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
const
vector
<
pair
<
Mat
,
uchar
>
>
&
masks
)
{
LOGLN
(
"Exposure compensation..."
);
int64
t
=
getTickCount
();
...
...
@@ -145,13 +143,13 @@ void GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &imag
}
void
GainCompensator
::
apply
(
int
index
,
Point
/*corner*/
,
Mat
&
image
,
const
Mat
&
/*mask*/
)
void
cv
::
GainCompensator
::
apply
(
int
index
,
Point
/*corner*/
,
Mat
&
image
,
const
Mat
&
/*mask*/
)
{
image
*=
gains_
(
index
,
0
);
}
vector
<
double
>
GainCompensator
::
gains
()
const
vector
<
double
>
cv
::
GainCompensator
::
gains
()
const
{
vector
<
double
>
gains_vec
(
gains_
.
rows
);
for
(
int
i
=
0
;
i
<
gains_
.
rows
;
++
i
)
...
...
@@ -160,8 +158,8 @@ vector<double> GainCompensator::gains() const
}
void
BlocksGainCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
const
vector
<
pair
<
Mat
,
uchar
>
>
&
masks
)
void
cv
::
BlocksGainCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
const
vector
<
pair
<
Mat
,
uchar
>
>
&
masks
)
{
CV_Assert
(
corners
.
size
()
==
images
.
size
()
&&
images
.
size
()
==
masks
.
size
());
...
...
@@ -220,7 +218,7 @@ void BlocksGainCompensator::feed(const vector<Point> &corners, const vector<Mat>
}
void
BlocksGainCompensator
::
apply
(
int
index
,
Point
/*corner*/
,
Mat
&
image
,
const
Mat
&
/*mask*/
)
void
cv
::
BlocksGainCompensator
::
apply
(
int
index
,
Point
/*corner*/
,
Mat
&
image
,
const
Mat
&
/*mask*/
)
{
CV_Assert
(
image
.
type
()
==
CV_8UC3
);
...
...
@@ -242,5 +240,3 @@ void BlocksGainCompensator::apply(int index, Point /*corner*/, Mat &image, const
}
}
}
}
// namespace cv
modules/stitching/src/matchers.cpp
View file @
fbe2e6fb
...
...
@@ -42,25 +42,19 @@
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
gpu
;
namespace
cv
{
void
FeaturesFinder
::
operator
()(
const
Mat
&
image
,
ImageFeatures
&
features
)
void
cv
::
FeaturesFinder
::
operator
()(
const
Mat
&
image
,
ImageFeatures
&
features
)
{
find
(
image
,
features
);
features
.
img_size
=
image
.
size
();
//features.img = image.clone();
}
}
// namespace cv
namespace
{
using
namespace
cv
;
class
CpuSurfFeaturesFinder
:
public
FeaturesFinder
{
public
:
...
...
@@ -155,10 +149,7 @@ namespace
}
// namespace
namespace
cv
{
SurfFeaturesFinder
::
SurfFeaturesFinder
(
bool
try_use_gpu
,
double
hess_thresh
,
int
num_octaves
,
int
num_layers
,
cv
::
SurfFeaturesFinder
::
SurfFeaturesFinder
(
bool
try_use_gpu
,
double
hess_thresh
,
int
num_octaves
,
int
num_layers
,
int
num_octaves_descr
,
int
num_layers_descr
)
{
if
(
try_use_gpu
&&
getCudaEnabledDeviceCount
()
>
0
)
...
...
@@ -168,12 +159,12 @@ SurfFeaturesFinder::SurfFeaturesFinder(bool try_use_gpu, double hess_thresh, int
}
void
SurfFeaturesFinder
::
find
(
const
Mat
&
image
,
ImageFeatures
&
features
)
void
cv
::
SurfFeaturesFinder
::
find
(
const
Mat
&
image
,
ImageFeatures
&
features
)
{
(
*
impl_
)(
image
,
features
);
}
void
SurfFeaturesFinder
::
releaseMemory
()
void
cv
::
SurfFeaturesFinder
::
releaseMemory
()
{
impl_
->
releaseMemory
();
}
...
...
@@ -181,11 +172,11 @@ void SurfFeaturesFinder::releaseMemory()
//////////////////////////////////////////////////////////////////////////////
MatchesInfo
::
MatchesInfo
()
:
src_img_idx
(
-
1
),
dst_img_idx
(
-
1
),
num_inliers
(
0
),
confidence
(
0
)
{}
cv
::
MatchesInfo
::
MatchesInfo
()
:
src_img_idx
(
-
1
),
dst_img_idx
(
-
1
),
num_inliers
(
0
),
confidence
(
0
)
{}
MatchesInfo
::
MatchesInfo
(
const
MatchesInfo
&
other
)
{
*
this
=
other
;
}
cv
::
MatchesInfo
::
MatchesInfo
(
const
MatchesInfo
&
other
)
{
*
this
=
other
;
}
const
MatchesInfo
&
MatchesInfo
::
operator
=
(
const
MatchesInfo
&
other
)
const
cv
::
MatchesInfo
&
MatchesInfo
::
operator
=
(
const
MatchesInfo
&
other
)
{
src_img_idx
=
other
.
src_img_idx
;
dst_img_idx
=
other
.
dst_img_idx
;
...
...
@@ -200,65 +191,69 @@ const MatchesInfo& MatchesInfo::operator =(const MatchesInfo &other)
//////////////////////////////////////////////////////////////////////////////
struct
DistIdxPair
namespace
{
bool
operator
<
(
const
DistIdxPair
&
other
)
const
{
return
dist
<
other
.
dist
;
}
double
dist
;
int
idx
;
};
struct
MatchPairsBody
{
MatchPairsBody
(
const
MatchPairsBody
&
other
)
:
matcher
(
other
.
matcher
),
features
(
other
.
features
),
pairwise_matches
(
other
.
pairwise_matches
),
near_pairs
(
other
.
near_pairs
)
{}
struct
DistIdxPair
{
bool
operator
<
(
const
DistIdxPair
&
other
)
const
{
return
dist
<
other
.
dist
;
}
double
dist
;
int
idx
;
};
MatchPairsBody
(
FeaturesMatcher
&
matcher
,
const
vector
<
ImageFeatures
>
&
features
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
pair
<
int
,
int
>
>
&
near_pairs
)
:
matcher
(
matcher
),
features
(
features
),
pairwise_matches
(
pairwise_matches
),
near_pairs
(
near_pairs
)
{}
void
operator
()(
const
BlockedRange
&
r
)
const
struct
MatchPairsBody
{
const
int
num_images
=
static_cast
<
int
>
(
features
.
size
());
for
(
int
i
=
r
.
begin
();
i
<
r
.
end
();
++
i
)
MatchPairsBody
(
const
MatchPairsBody
&
other
)
:
matcher
(
other
.
matcher
),
features
(
other
.
features
),
pairwise_matches
(
other
.
pairwise_matches
),
near_pairs
(
other
.
near_pairs
)
{}
MatchPairsBody
(
FeaturesMatcher
&
matcher
,
const
vector
<
ImageFeatures
>
&
features
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
pair
<
int
,
int
>
>
&
near_pairs
)
:
matcher
(
matcher
),
features
(
features
),
pairwise_matches
(
pairwise_matches
),
near_pairs
(
near_pairs
)
{}
void
operator
()(
const
BlockedRange
&
r
)
const
{
int
from
=
near_pairs
[
i
].
first
;
int
to
=
near_pairs
[
i
].
second
;
int
pair_idx
=
from
*
num_images
+
to
;
const
int
num_images
=
static_cast
<
int
>
(
features
.
size
());
for
(
int
i
=
r
.
begin
();
i
<
r
.
end
();
++
i
)
{
int
from
=
near_pairs
[
i
].
first
;
int
to
=
near_pairs
[
i
].
second
;
int
pair_idx
=
from
*
num_images
+
to
;
matcher
(
features
[
from
],
features
[
to
],
pairwise_matches
[
pair_idx
]);
pairwise_matches
[
pair_idx
].
src_img_idx
=
from
;
pairwise_matches
[
pair_idx
].
dst_img_idx
=
to
;
matcher
(
features
[
from
],
features
[
to
],
pairwise_matches
[
pair_idx
]);
pairwise_matches
[
pair_idx
].
src_img_idx
=
from
;
pairwise_matches
[
pair_idx
].
dst_img_idx
=
to
;
size_t
dual_pair_idx
=
to
*
num_images
+
from
;
size_t
dual_pair_idx
=
to
*
num_images
+
from
;
pairwise_matches
[
dual_pair_idx
]
=
pairwise_matches
[
pair_idx
];
pairwise_matches
[
dual_pair_idx
].
src_img_idx
=
to
;
pairwise_matches
[
dual_pair_idx
].
dst_img_idx
=
from
;
pairwise_matches
[
dual_pair_idx
]
=
pairwise_matches
[
pair_idx
];
pairwise_matches
[
dual_pair_idx
].
src_img_idx
=
to
;
pairwise_matches
[
dual_pair_idx
].
dst_img_idx
=
from
;
if
(
!
pairwise_matches
[
pair_idx
].
H
.
empty
())
pairwise_matches
[
dual_pair_idx
].
H
=
pairwise_matches
[
pair_idx
].
H
.
inv
();
if
(
!
pairwise_matches
[
pair_idx
].
H
.
empty
())
pairwise_matches
[
dual_pair_idx
].
H
=
pairwise_matches
[
pair_idx
].
H
.
inv
();
for
(
size_t
j
=
0
;
j
<
pairwise_matches
[
dual_pair_idx
].
matches
.
size
();
++
j
)
std
::
swap
(
pairwise_matches
[
dual_pair_idx
].
matches
[
j
].
queryIdx
,
pairwise_matches
[
dual_pair_idx
].
matches
[
j
].
trainIdx
);
LOG
(
"."
);
for
(
size_t
j
=
0
;
j
<
pairwise_matches
[
dual_pair_idx
].
matches
.
size
();
++
j
)
std
::
swap
(
pairwise_matches
[
dual_pair_idx
].
matches
[
j
].
queryIdx
,
pairwise_matches
[
dual_pair_idx
].
matches
[
j
].
trainIdx
);
LOG
(
"."
);
}
}
}
FeaturesMatcher
&
matcher
;
const
vector
<
ImageFeatures
>
&
features
;
vector
<
MatchesInfo
>
&
pairwise_matches
;
vector
<
pair
<
int
,
int
>
>
&
near_pairs
;
FeaturesMatcher
&
matcher
;
const
vector
<
ImageFeatures
>
&
features
;
vector
<
MatchesInfo
>
&
pairwise_matches
;
vector
<
pair
<
int
,
int
>
>
&
near_pairs
;
private
:
void
operator
=
(
const
MatchPairsBody
&
);
};
private
:
void
operator
=
(
const
MatchPairsBody
&
);
};
}
// namespace
void
FeaturesMatcher
::
operator
()(
const
vector
<
ImageFeatures
>
&
features
,
vector
<
MatchesInfo
>
&
pairwise_matches
)
void
cv
::
FeaturesMatcher
::
operator
()(
const
vector
<
ImageFeatures
>
&
features
,
vector
<
MatchesInfo
>
&
pairwise_matches
)
{
const
int
num_images
=
static_cast
<
int
>
(
features
.
size
());
...
...
@@ -408,10 +403,10 @@ namespace
vector
<
vector
<
DMatch
>
>
().
swap
(
pair_matches
);
}
}
//
anonymous
namespace
}
// namespace
BestOf2NearestMatcher
::
BestOf2NearestMatcher
(
bool
try_use_gpu
,
float
match_conf
,
int
num_matches_thresh1
,
int
num_matches_thresh2
)
cv
::
BestOf2NearestMatcher
::
BestOf2NearestMatcher
(
bool
try_use_gpu
,
float
match_conf
,
int
num_matches_thresh1
,
int
num_matches_thresh2
)
{
if
(
try_use_gpu
&&
getCudaEnabledDeviceCount
()
>
0
)
impl_
=
new
GpuMatcher
(
match_conf
);
...
...
@@ -424,7 +419,7 @@ BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf,
}
void
BestOf2NearestMatcher
::
match
(
const
ImageFeatures
&
features1
,
const
ImageFeatures
&
features2
,
void
cv
::
BestOf2NearestMatcher
::
match
(
const
ImageFeatures
&
features1
,
const
ImageFeatures
&
features2
,
MatchesInfo
&
matches_info
)
{
(
*
impl_
)(
features1
,
features2
,
matches_info
);
...
...
@@ -502,9 +497,7 @@ void BestOf2NearestMatcher::match(const ImageFeatures &features1, const ImageFea
matches_info
.
H
=
findHomography
(
src_points
,
dst_points
,
CV_RANSAC
);
}
void
BestOf2NearestMatcher
::
releaseMemory
()
void
cv
::
BestOf2NearestMatcher
::
releaseMemory
()
{
impl_
->
releaseMemory
();
}
}
// namespace cv
modules/stitching/src/motion_estimators.cpp
View file @
fbe2e6fb
...
...
@@ -42,50 +42,53 @@
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
namespace
cv
namespace
{
struct
IncDistance
{
IncDistance
(
vector
<
int
>
&
dists
)
:
dists
(
&
dists
[
0
])
{}
void
operator
()(
const
GraphEdge
&
edge
)
{
dists
[
edge
.
to
]
=
dists
[
edge
.
from
]
+
1
;
}
int
*
dists
;
};
struct
IncDistance
{
IncDistance
(
vector
<
int
>
&
dists
)
:
dists
(
&
dists
[
0
])
{}
void
operator
()(
const
GraphEdge
&
edge
)
{
dists
[
edge
.
to
]
=
dists
[
edge
.
from
]
+
1
;
}
int
*
dists
;
};
struct
CalcRotation
{
CalcRotation
(
int
num_images
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
:
num_images
(
num_images
),
pairwise_matches
(
&
pairwise_matches
[
0
]),
cameras
(
&
cameras
[
0
])
{}
void
operator
()(
const
GraphEdge
&
edge
)
struct
CalcRotation
{
int
pair_idx
=
edge
.
from
*
num_images
+
edge
.
to
;
CalcRotation
(
int
num_images
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
:
num_images
(
num_images
),
pairwise_matches
(
&
pairwise_matches
[
0
]),
cameras
(
&
cameras
[
0
])
{}
double
f_from
=
cameras
[
edge
.
from
].
focal
;
double
f_to
=
cameras
[
edge
.
to
].
focal
;
void
operator
()(
const
GraphEdge
&
edge
)
{
int
pair_idx
=
edge
.
from
*
num_images
+
edge
.
to
;
Mat
K_from
=
Mat
::
eye
(
3
,
3
,
CV_64F
);
K_from
.
at
<
double
>
(
0
,
0
)
=
f_from
;
K_from
.
at
<
double
>
(
1
,
1
)
=
f_from
;
double
f_from
=
cameras
[
edge
.
from
].
focal
;
double
f_to
=
cameras
[
edge
.
to
].
focal
;
Mat
K_to
=
Mat
::
eye
(
3
,
3
,
CV_64F
);
K_to
.
at
<
double
>
(
0
,
0
)
=
f_to
;
K_to
.
at
<
double
>
(
1
,
1
)
=
f_to
;
Mat
K_from
=
Mat
::
eye
(
3
,
3
,
CV_64F
);
K_from
.
at
<
double
>
(
0
,
0
)
=
f_from
;
K_from
.
at
<
double
>
(
1
,
1
)
=
f_from
;
Mat
R
=
K_from
.
inv
()
*
pairwise_matches
[
pair_idx
].
H
.
inv
()
*
K_to
;
cameras
[
edge
.
to
].
R
=
cameras
[
edge
.
from
].
R
*
R
;
}
Mat
K_to
=
Mat
::
eye
(
3
,
3
,
CV_64F
);
K_to
.
at
<
double
>
(
0
,
0
)
=
f_to
;
K_to
.
at
<
double
>
(
1
,
1
)
=
f_to
;
Mat
R
=
K_from
.
inv
()
*
pairwise_matches
[
pair_idx
].
H
.
inv
()
*
K_to
;
cameras
[
edge
.
to
].
R
=
cameras
[
edge
.
from
].
R
*
R
;
}
int
num_images
;
const
MatchesInfo
*
pairwise_matches
;
CameraParams
*
cameras
;
};
int
num_images
;
const
MatchesInfo
*
pairwise_matches
;
CameraParams
*
cameras
;
};
}
// namespace
void
HomographyBasedEstimator
::
estimate
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
void
cv
::
HomographyBasedEstimator
::
estimate
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
{
LOGLN
(
"Estimating rotations..."
);
int64
t
=
getTickCount
();
...
...
@@ -132,8 +135,8 @@ void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, c
//////////////////////////////////////////////////////////////////////////////
void
BundleAdjuster
::
estimate
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
void
cv
::
BundleAdjuster
::
estimate
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
{
if
(
cost_space_
==
NO
)
return
;
...
...
@@ -247,7 +250,7 @@ void BundleAdjuster::estimate(const vector<ImageFeatures> &features, const vecto
}
void
BundleAdjuster
::
calcError
(
Mat
&
err
)
void
cv
::
BundleAdjuster
::
calcError
(
Mat
&
err
)
{
err
.
create
(
total_num_matches_
*
3
,
1
,
CV_64F
);
...
...
@@ -311,14 +314,19 @@ void BundleAdjuster::calcError(Mat &err)
}
void
calcDeriv
(
const
Mat
&
err1
,
const
Mat
&
err2
,
double
h
,
Mat
res
)
namespace
{
for
(
int
i
=
0
;
i
<
err1
.
rows
;
++
i
)
res
.
at
<
double
>
(
i
,
0
)
=
(
err2
.
at
<
double
>
(
i
,
0
)
-
err1
.
at
<
double
>
(
i
,
0
))
/
h
;
}
void
calcDeriv
(
const
Mat
&
err1
,
const
Mat
&
err2
,
double
h
,
Mat
res
)
{
for
(
int
i
=
0
;
i
<
err1
.
rows
;
++
i
)
res
.
at
<
double
>
(
i
,
0
)
=
(
err2
.
at
<
double
>
(
i
,
0
)
-
err1
.
at
<
double
>
(
i
,
0
))
/
h
;
}
void
BundleAdjuster
::
calcJacobian
()
}
// namespace
void
cv
::
BundleAdjuster
::
calcJacobian
()
{
J_
.
create
(
total_num_matches_
*
3
,
num_images_
*
4
,
CV_64F
);
...
...
@@ -366,7 +374,7 @@ void BundleAdjuster::calcJacobian()
//////////////////////////////////////////////////////////////////////////////
// TODO replace SVD with eigen
void
waveCorrect
(
vector
<
Mat
>
&
rmats
)
void
cv
::
waveCorrect
(
vector
<
Mat
>
&
rmats
)
{
LOGLN
(
"Wave correcting..."
);
int64
t
=
getTickCount
();
...
...
@@ -407,8 +415,8 @@ void waveCorrect(vector<Mat> &rmats)
//////////////////////////////////////////////////////////////////////////////
string
matchesGraphAsString
(
vector
<
string
>
&
pathes
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
)
string
cv
::
matchesGraphAsString
(
vector
<
string
>
&
pathes
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
)
{
stringstream
str
;
str
<<
"graph matches_graph{
\n
"
;
...
...
@@ -473,8 +481,8 @@ string matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pairwis
return
str
.
str
();
}
vector
<
int
>
leaveBiggestComponent
(
vector
<
ImageFeatures
>
&
features
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
)
vector
<
int
>
cv
::
leaveBiggestComponent
(
vector
<
ImageFeatures
>
&
features
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
)
{
const
int
num_images
=
static_cast
<
int
>
(
features
.
size
());
...
...
@@ -531,8 +539,8 @@ vector<int> leaveBiggestComponent(vector<ImageFeatures> &features, vector<Match
}
void
findMaxSpanningTree
(
int
num_images
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
Graph
&
span_tree
,
vector
<
int
>
&
centers
)
void
cv
::
findMaxSpanningTree
(
int
num_images
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
Graph
&
span_tree
,
vector
<
int
>
&
centers
)
{
Graph
graph
(
num_images
);
vector
<
GraphEdge
>
edges
;
...
...
@@ -600,5 +608,3 @@ void findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_mat
centers
.
push_back
(
i
);
CV_Assert
(
centers
.
size
()
>
0
&&
centers
.
size
()
<=
2
);
}
}
// namespace cv
modules/stitching/src/seam_finders.cpp
View file @
fbe2e6fb
...
...
@@ -42,11 +42,9 @@
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
namespace
cv
{
Ptr
<
SeamFinder
>
SeamFinder
::
createDefault
(
int
type
)
Ptr
<
SeamFinder
>
cv
::
SeamFinder
::
createDefault
(
int
type
)
{
if
(
type
==
NO
)
return
new
NoSeamFinder
();
...
...
@@ -61,8 +59,8 @@ Ptr<SeamFinder> SeamFinder::createDefault(int type)
}
void
PairwiseSeamFinder
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
vector
<
Mat
>
&
masks
)
void
cv
::
PairwiseSeamFinder
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
vector
<
Mat
>
&
masks
)
{
LOGLN
(
"Finding seams..."
);
int64
t
=
getTickCount
();
...
...
@@ -88,7 +86,7 @@ void PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corne
}
void
VoronoiSeamFinder
::
findInPair
(
size_t
first
,
size_t
second
,
Rect
roi
)
void
cv
::
VoronoiSeamFinder
::
findInPair
(
size_t
first
,
size_t
second
,
Rect
roi
)
{
const
int
gap
=
10
;
Mat
submask1
(
roi
.
height
+
2
*
gap
,
roi
.
width
+
2
*
gap
,
CV_8U
);
...
...
@@ -142,7 +140,7 @@ void VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi)
}
class
GraphCutSeamFinder
::
Impl
:
public
PairwiseSeamFinder
class
cv
::
GraphCutSeamFinder
::
Impl
:
public
PairwiseSeamFinder
{
public
:
Impl
(
int
cost_type
,
float
terminal_cost
,
float
bad_region_penalty
)
...
...
@@ -165,8 +163,8 @@ private:
};
void
GraphCutSeamFinder
::
Impl
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
vector
<
Mat
>
&
masks
)
void
cv
::
GraphCutSeamFinder
::
Impl
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
vector
<
Mat
>
&
masks
)
{
// Compute gradients
dx_
.
resize
(
src
.
size
());
...
...
@@ -196,8 +194,8 @@ void GraphCutSeamFinder::Impl::find(const vector<Mat> &src, const vector<Point>
}
void
GraphCutSeamFinder
::
Impl
::
setGraphWeightsColor
(
const
Mat
&
img1
,
const
Mat
&
img2
,
const
Mat
&
mask1
,
const
Mat
&
mask2
,
GCGraph
<
float
>
&
graph
)
void
cv
::
GraphCutSeamFinder
::
Impl
::
setGraphWeightsColor
(
const
Mat
&
img1
,
const
Mat
&
img2
,
const
Mat
&
mask1
,
const
Mat
&
mask2
,
GCGraph
<
float
>
&
graph
)
{
const
Size
img_size
=
img1
.
size
();
...
...
@@ -244,7 +242,7 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat &
}
void
GraphCutSeamFinder
::
Impl
::
setGraphWeightsColorGrad
(
void
cv
::
GraphCutSeamFinder
::
Impl
::
setGraphWeightsColorGrad
(
const
Mat
&
img1
,
const
Mat
&
img2
,
const
Mat
&
dx1
,
const
Mat
&
dx2
,
const
Mat
&
dy1
,
const
Mat
&
dy2
,
const
Mat
&
mask1
,
const
Mat
&
mask2
,
GCGraph
<
float
>
&
graph
)
...
...
@@ -298,7 +296,7 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
}
void
GraphCutSeamFinder
::
Impl
::
findInPair
(
size_t
first
,
size_t
second
,
Rect
roi
)
void
cv
::
GraphCutSeamFinder
::
Impl
::
findInPair
(
size_t
first
,
size_t
second
,
Rect
roi
)
{
Mat
img1
=
images_
[
first
],
img2
=
images_
[
second
];
Mat
dx1
=
dx_
[
first
],
dx2
=
dx_
[
second
];
...
...
@@ -396,14 +394,12 @@ void GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi)
}
GraphCutSeamFinder
::
GraphCutSeamFinder
(
int
cost_type
,
float
terminal_cost
,
float
bad_region_penalty
)
cv
::
GraphCutSeamFinder
::
GraphCutSeamFinder
(
int
cost_type
,
float
terminal_cost
,
float
bad_region_penalty
)
:
impl_
(
new
Impl
(
cost_type
,
terminal_cost
,
bad_region_penalty
))
{}
void
GraphCutSeamFinder
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
void
cv
::
GraphCutSeamFinder
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
vector
<
Mat
>
&
masks
)
{
impl_
->
find
(
src
,
corners
,
masks
);
}
}
// namespace cv
modules/stitching/src/util.cpp
View file @
fbe2e6fb
...
...
@@ -42,11 +42,9 @@
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
namespace
cv
{
void
DisjointSets
::
createOneElemSets
(
int
n
)
void
cv
::
DisjointSets
::
createOneElemSets
(
int
n
)
{
rank_
.
assign
(
n
,
0
);
size
.
assign
(
n
,
1
);
...
...
@@ -56,7 +54,7 @@ void DisjointSets::createOneElemSets(int n)
}
int
DisjointSets
::
findSetByElem
(
int
elem
)
int
cv
::
DisjointSets
::
findSetByElem
(
int
elem
)
{
int
set
=
elem
;
while
(
set
!=
parent
[
set
])
...
...
@@ -72,7 +70,7 @@ int DisjointSets::findSetByElem(int elem)
}
int
DisjointSets
::
mergeSets
(
int
set1
,
int
set2
)
int
cv
::
DisjointSets
::
mergeSets
(
int
set1
,
int
set2
)
{
if
(
rank_
[
set1
]
<
rank_
[
set2
])
{
...
...
@@ -93,13 +91,13 @@ int DisjointSets::mergeSets(int set1, int set2)
}
void
Graph
::
addEdge
(
int
from
,
int
to
,
float
weight
)
void
cv
::
Graph
::
addEdge
(
int
from
,
int
to
,
float
weight
)
{
edges_
[
from
].
push_back
(
GraphEdge
(
from
,
to
,
weight
));
}
bool
overlapRoi
(
Point
tl1
,
Point
tl2
,
Size
sz1
,
Size
sz2
,
Rect
&
roi
)
bool
cv
::
overlapRoi
(
Point
tl1
,
Point
tl2
,
Size
sz1
,
Size
sz2
,
Rect
&
roi
)
{
int
x_tl
=
max
(
tl1
.
x
,
tl2
.
x
);
int
y_tl
=
max
(
tl1
.
y
,
tl2
.
y
);
...
...
@@ -114,7 +112,7 @@ bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi)
}
Rect
resultRoi
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
)
Rect
cv
::
resultRoi
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
)
{
vector
<
Size
>
sizes
(
images
.
size
());
for
(
size_t
i
=
0
;
i
<
images
.
size
();
++
i
)
...
...
@@ -123,7 +121,7 @@ Rect resultRoi(const vector<Point> &corners, const vector<Mat> &images)
}
Rect
resultRoi
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Size
>
&
sizes
)
Rect
cv
::
resultRoi
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Size
>
&
sizes
)
{
CV_Assert
(
sizes
.
size
()
==
corners
.
size
());
Point
tl
(
numeric_limits
<
int
>::
max
(),
numeric_limits
<
int
>::
max
());
...
...
@@ -139,7 +137,7 @@ Rect resultRoi(const vector<Point> &corners, const vector<Size> &sizes)
}
Point
resultTl
(
const
vector
<
Point
>
&
corners
)
Point
cv
::
resultTl
(
const
vector
<
Point
>
&
corners
)
{
Point
tl
(
numeric_limits
<
int
>::
max
(),
numeric_limits
<
int
>::
max
());
for
(
size_t
i
=
0
;
i
<
corners
.
size
();
++
i
)
...
...
@@ -151,7 +149,7 @@ Point resultTl(const vector<Point> &corners)
}
void
selectRandomSubset
(
int
count
,
int
size
,
vector
<
int
>
&
subset
)
void
cv
::
selectRandomSubset
(
int
count
,
int
size
,
vector
<
int
>
&
subset
)
{
subset
.
clear
();
for
(
int
i
=
0
;
i
<
size
;
++
i
)
...
...
@@ -163,5 +161,3 @@ void selectRandomSubset(int count, int size, vector<int> &subset)
}
}
}
}
// namespace cv
modules/stitching/src/warpers.cpp
View file @
fbe2e6fb
...
...
@@ -42,11 +42,9 @@
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
namespace
cv
{
Ptr
<
Warper
>
Warper
::
createByCameraFocal
(
float
focal
,
int
type
,
bool
try_gpu
)
Ptr
<
Warper
>
cv
::
Warper
::
createByCameraFocal
(
float
focal
,
int
type
,
bool
try_gpu
)
{
bool
can_use_gpu
=
try_gpu
&&
gpu
::
getCudaEnabledDeviceCount
();
if
(
type
==
PLANE
)
...
...
@@ -60,7 +58,7 @@ Ptr<Warper> Warper::createByCameraFocal(float focal, int type, bool try_gpu)
}
void
ProjectorBase
::
setTransformation
(
const
Mat
&
R
)
void
cv
::
ProjectorBase
::
setTransformation
(
const
Mat
&
R
)
{
CV_Assert
(
R
.
size
()
==
Size
(
3
,
3
));
CV_Assert
(
R
.
type
()
==
CV_32F
);
...
...
@@ -75,7 +73,7 @@ void ProjectorBase::setTransformation(const Mat &R)
}
void
PlaneWarper
::
detectResultRoi
(
Point
&
dst_tl
,
Point
&
dst_br
)
void
cv
::
PlaneWarper
::
detectResultRoi
(
Point
&
dst_tl
,
Point
&
dst_br
)
{
float
tl_uf
=
numeric_limits
<
float
>::
max
();
float
tl_vf
=
numeric_limits
<
float
>::
max
();
...
...
@@ -107,7 +105,7 @@ void PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
}
Point
PlaneWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
cv
::
Mat
&
R
,
cv
::
Mat
&
dst
,
int
interp_mode
,
int
border_mode
)
Point
cv
::
PlaneWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
cv
::
Mat
&
R
,
cv
::
Mat
&
dst
,
int
interp_mode
,
int
border_mode
)
{
src_size_
=
src
.
size
();
projector_
.
size
=
src
.
size
();
...
...
@@ -133,7 +131,7 @@ Point PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv::Ma
}
void
SphericalWarper
::
detectResultRoi
(
Point
&
dst_tl
,
Point
&
dst_br
)
void
cv
::
SphericalWarper
::
detectResultRoi
(
Point
&
dst_tl
,
Point
&
dst_br
)
{
detectResultRoiByBorder
(
dst_tl
,
dst_br
);
...
...
@@ -177,8 +175,8 @@ void SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
}
Point
SphericalWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
Mat
&
R
,
Mat
&
dst
,
int
interp_mode
,
int
border_mode
)
Point
cv
::
SphericalWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
Mat
&
R
,
Mat
&
dst
,
int
interp_mode
,
int
border_mode
)
{
src_size_
=
src
.
size
();
projector_
.
size
=
src
.
size
();
...
...
@@ -204,8 +202,8 @@ Point SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &d
}
Point
CylindricalWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
Mat
&
R
,
Mat
&
dst
,
int
interp_mode
,
int
border_mode
)
Point
cv
::
CylindricalWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
Mat
&
R
,
Mat
&
dst
,
int
interp_mode
,
int
border_mode
)
{
src_size_
=
src
.
size
();
projector_
.
size
=
src
.
size
();
...
...
@@ -230,4 +228,3 @@ Point CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat
return
dst_tl
;
}
}
// namespace cv
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