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
95a3ffd0
Commit
95a3ffd0
authored
Sep 07, 2011
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
put all old stitching API into detail namespace
parent
bf0081a8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
270 additions
and
215 deletions
+270
-215
OpenCVModule.cmake
OpenCVModule.cmake
+1
-1
autocalib.hpp
.../stitching/include/opencv2/stitching/detail/autocalib.hpp
+3
-2
blenders.hpp
...s/stitching/include/opencv2/stitching/detail/blenders.hpp
+3
-2
camera.hpp
...les/stitching/include/opencv2/stitching/detail/camera.hpp
+3
-2
exposure_compensate.hpp
.../include/opencv2/stitching/detail/exposure_compensate.hpp
+3
-2
matchers.hpp
...s/stitching/include/opencv2/stitching/detail/matchers.hpp
+3
-2
motion_estimators.hpp
...ng/include/opencv2/stitching/detail/motion_estimators.hpp
+3
-2
seam_finders.hpp
...itching/include/opencv2/stitching/detail/seam_finders.hpp
+3
-2
util.hpp
modules/stitching/include/opencv2/stitching/detail/util.hpp
+3
-2
util_inl.hpp
...s/stitching/include/opencv2/stitching/detail/util_inl.hpp
+3
-2
warpers.hpp
...es/stitching/include/opencv2/stitching/detail/warpers.hpp
+3
-2
warpers_inl.hpp
...titching/include/opencv2/stitching/detail/warpers_inl.hpp
+3
-2
stitching.hpp
modules/stitching/include/opencv2/stitching/stitching.hpp
+0
-54
autocalib.cpp
modules/stitching/src/autocalib.cpp
+22
-14
blenders.cpp
modules/stitching/src/blenders.cpp
+24
-18
camera.cpp
modules/stitching/src/camera.cpp
+51
-4
exposure_compensate.cpp
modules/stitching/src/exposure_compensate.cpp
+16
-10
matchers.cpp
modules/stitching/src/matchers.cpp
+0
-0
motion_estimators.cpp
modules/stitching/src/motion_estimators.cpp
+55
-50
precomp.hpp
modules/stitching/src/precomp.hpp
+9
-9
seam_finders.cpp
modules/stitching/src/seam_finders.cpp
+18
-11
util.cpp
modules/stitching/src/util.cpp
+15
-10
warpers.cpp
modules/stitching/src/warpers.cpp
+16
-11
stitching.cpp
samples/cpp/stitching.cpp
+10
-1
No files found.
OpenCVModule.cmake
View file @
95a3ffd0
...
...
@@ -144,7 +144,7 @@ macro(define_opencv_module name)
file
(
GLOB lib_srcs
"src/*.cpp"
)
file
(
GLOB lib_int_hdrs
"src/*.h*"
)
file
(
GLOB lib_hdrs
"include/opencv2/
${
name
}
/*.h*"
)
file
(
GLOB lib_hdrs
"include/opencv2/
${
name
}
/*.h*"
"include/opencv2/
${
name
}
/detail/*.h*"
)
if
(
COMMAND get_module_external_sources
)
get_module_external_sources
(
${
name
}
)
...
...
modules/stitching/include/opencv2/stitching/autocalib.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
autocalib.hpp
View file @
95a3ffd0
...
...
@@ -45,8 +45,8 @@
#include "opencv2/core/core.hpp"
#include "matchers.hpp"
namespace
cv
{
namespace
cv
{
namespace
detail
{
// See "Construction of Panoramic Image Mosaics with Global and Local Alignment"
// by Heung-Yeung Shum and Richard Szeliski.
...
...
@@ -58,6 +58,7 @@ void CV_EXPORTS estimateFocal(const std::vector<ImageFeatures> &features,
bool
CV_EXPORTS
calibrateRotatingCamera
(
const
std
::
vector
<
Mat
>
&
Hs
,
Mat
&
K
);
}
// namespace detail
}
// namespace cv
#endif // __OPENCV_STITCHING_AUTOCALIB_HPP__
modules/stitching/include/opencv2/stitching/blenders.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
blenders.hpp
View file @
95a3ffd0
...
...
@@ -44,8 +44,8 @@
#include "opencv2/core/core.hpp"
namespace
cv
{
namespace
cv
{
namespace
detail
{
// Simple blender which puts one image over another
class
CV_EXPORTS
Blender
...
...
@@ -119,6 +119,7 @@ void CV_EXPORTS createLaplacePyrGpu(const Mat &img, int num_levels, std::vector<
// Restores source image
void
CV_EXPORTS
restoreImageFromLaplacePyr
(
std
::
vector
<
Mat
>&
pyr
);
}
// namespace detail
}
// namespace cv
#endif // __OPENCV_STITCHING_BLENDERS_HPP__
modules/stitching/include/opencv2/stitching/camera.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
camera.hpp
View file @
95a3ffd0
...
...
@@ -44,8 +44,8 @@
#include "opencv2/core/core.hpp"
namespace
cv
{
namespace
cv
{
namespace
detail
{
struct
CV_EXPORTS
CameraParams
{
...
...
@@ -58,6 +58,7 @@ struct CV_EXPORTS CameraParams
Mat
t
;
// Translation
};
}
// namespace detail
}
// namespace cv
#endif // #ifndef __OPENCV_STITCHING_CAMERA_HPP__
modules/stitching/include/opencv2/stitching/exposure_compensate.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
exposure_compensate.hpp
View file @
95a3ffd0
...
...
@@ -44,8 +44,8 @@
#include "opencv2/core/core.hpp"
namespace
cv
{
namespace
cv
{
namespace
detail
{
class
CV_EXPORTS
ExposureCompensator
{
...
...
@@ -99,6 +99,7 @@ private:
std
::
vector
<
Mat_
<
float
>
>
gain_maps_
;
};
}
// namespace detail
}
// namespace cv
#endif // __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
modules/stitching/include/opencv2/stitching/matchers.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
matchers.hpp
View file @
95a3ffd0
...
...
@@ -45,8 +45,8 @@
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
namespace
cv
{
namespace
cv
{
namespace
detail
{
struct
CV_EXPORTS
ImageFeatures
{
...
...
@@ -140,6 +140,7 @@ protected:
cv
::
Ptr
<
FeaturesMatcher
>
impl_
;
};
}
// namespace detail
}
// namespace cv
#endif // __OPENCV_STITCHING_MATCHERS_HPP__
modules/stitching/include/opencv2/stitching/motion_estimators.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
motion_estimators.hpp
View file @
95a3ffd0
...
...
@@ -47,8 +47,8 @@
#include "util.hpp"
#include "camera.hpp"
namespace
cv
{
namespace
cv
{
namespace
detail
{
class
CV_EXPORTS
Estimator
{
...
...
@@ -126,6 +126,7 @@ std::vector<int> CV_EXPORTS leaveBiggestComponent(std::vector<ImageFeatures> &fe
void
CV_EXPORTS
findMaxSpanningTree
(
int
num_images
,
const
std
::
vector
<
MatchesInfo
>
&
pairwise_matches
,
Graph
&
span_tree
,
std
::
vector
<
int
>
&
centers
);
}
// namespace detail
}
// namespace cv
#endif // __OPENCV_STITCHING_MOTION_ESTIMATORS_HPP__
modules/stitching/include/opencv2/stitching/seam_finders.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
seam_finders.hpp
View file @
95a3ffd0
...
...
@@ -44,8 +44,8 @@
#include "opencv2/core/core.hpp"
namespace
cv
{
namespace
cv
{
namespace
detail
{
class
CV_EXPORTS
SeamFinder
{
...
...
@@ -103,6 +103,7 @@ private:
Ptr
<
Impl
>
impl_
;
};
}
// namespace detail
}
// namespace cv
#endif // __OPENCV_STITCHING_SEAM_FINDERS_HPP__
modules/stitching/include/opencv2/stitching/util.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
util.hpp
View file @
95a3ffd0
...
...
@@ -56,8 +56,8 @@
#define LOGLN(msg) LOG(msg << std::endl)
namespace
cv
{
namespace
cv
{
namespace
detail
{
class
CV_EXPORTS
DisjointSets
{
...
...
@@ -114,6 +114,7 @@ Point CV_EXPORTS resultTl(const std::vector<Point> &corners);
// Returns random 'count' element subset of the {0,1,...,size-1} set
void
CV_EXPORTS
selectRandomSubset
(
int
count
,
int
size
,
std
::
vector
<
int
>
&
subset
);
}
// namespace detail
}
// namespace cv
#include "util_inl.hpp"
...
...
modules/stitching/include/opencv2/stitching/util_inl.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
util_inl.hpp
View file @
95a3ffd0
...
...
@@ -46,8 +46,8 @@
#include "opencv2/core/core.hpp"
#include "util.hpp" // Make your IDE see declarations
namespace
cv
{
namespace
cv
{
namespace
detail
{
template
<
typename
B
>
B
Graph
::
forEach
(
B
body
)
const
...
...
@@ -120,6 +120,7 @@ static inline int sqr(int x) { return x * x; }
static
inline
float
sqr
(
float
x
)
{
return
x
*
x
;
}
static
inline
double
sqr
(
double
x
)
{
return
x
*
x
;
}
}
// namespace detail
}
// namespace cv
#endif // __OPENCV_STITCHING_UTIL_INL_HPP__
modules/stitching/include/opencv2/stitching/warpers.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
warpers.hpp
View file @
95a3ffd0
...
...
@@ -46,8 +46,8 @@
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/gpu/gpu.hpp"
namespace
cv
{
namespace
cv
{
namespace
detail
{
class
CV_EXPORTS
Warper
{
...
...
@@ -194,6 +194,7 @@ private:
gpu
::
GpuMat
d_xmap_
,
d_ymap_
,
d_dst_
,
d_src_
;
};
}
// namespace detail
}
// namespace cv
#include "warpers_inl.hpp"
...
...
modules/stitching/include/opencv2/stitching/warpers_inl.hpp
→
modules/stitching/include/opencv2/stitching/
detail/
warpers_inl.hpp
View file @
95a3ffd0
...
...
@@ -45,8 +45,8 @@
#include "opencv2/core/core.hpp"
#include "warpers.hpp" // Make your IDE see declarations
namespace
cv
{
namespace
cv
{
namespace
detail
{
template
<
class
P
>
Point
WarperBase
<
P
>::
warp
(
const
Mat
&
src
,
float
focal
,
const
Mat
&
R
,
Mat
&
dst
,
...
...
@@ -256,6 +256,7 @@ void CylindricalProjector::mapBackward(float u, float v, float &x, float &y)
y
=
focal
*
y
/
z
+
size
.
height
*
0.5
f
;
}
}
// namespace detail
}
// namespace cv
#endif // __OPENCV_STITCHING_WARPERS_INL_HPP__
modules/stitching/include/opencv2/stitching/stitching.hpp
deleted
100644 → 0
View file @
bf0081a8
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_STITCHING_HPP__
#define __OPENCV_STITCHING_HPP__
#include "opencv2/stitching/autocalib.hpp"
#include "opencv2/stitching/blenders.hpp"
#include "opencv2/stitching/camera.hpp"
#include "opencv2/stitching/exposure_compensate.hpp"
#include "opencv2/stitching/matchers.hpp"
#include "opencv2/stitching/motion_estimators.hpp"
#include "opencv2/stitching/seam_finders.hpp"
#include "opencv2/stitching/util.hpp"
#include "opencv2/stitching/warpers.hpp"
#endif // __OPENCV_STITCHING_HPP__
modules/stitching/src/autocalib.cpp
View file @
95a3ffd0
...
...
@@ -39,27 +39,32 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
namespace
namespace
{
template
<
typename
_Tp
>
static
inline
bool
decomposeCholesky
(
_Tp
*
A
,
size_t
astep
,
int
m
)
{
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
;
}
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
cv
::
focalsFromHomography
(
const
Mat
&
H
,
double
&
f0
,
double
&
f1
,
bool
&
f0_ok
,
bool
&
f1_ok
)
namespace
cv
{
namespace
detail
{
void
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
));
...
...
@@ -90,7 +95,7 @@ void cv::focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok,
}
void
cv
::
estimateFocal
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
void
estimateFocal
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
double
>
&
focals
)
{
const
int
num_images
=
static_cast
<
int
>
(
features
.
size
());
...
...
@@ -131,7 +136,7 @@ void cv::estimateFocal(const vector<ImageFeatures> &features, const vector<Match
}
bool
c
v
::
c
alibrateRotatingCamera
(
const
vector
<
Mat
>
&
Hs
,
Mat
&
K
)
bool
calibrateRotatingCamera
(
const
vector
<
Mat
>
&
Hs
,
Mat
&
K
)
{
int
m
=
static_cast
<
int
>
(
Hs
.
size
());
CV_Assert
(
m
>=
1
);
...
...
@@ -181,3 +186,6 @@ bool cv::calibrateRotatingCamera(const vector<Mat> &Hs, Mat &K)
K
=
W
.
t
();
return
true
;
}
}
// namespace detail
}
// namespace cv
modules/stitching/src/blenders.cpp
View file @
95a3ffd0
...
...
@@ -39,14 +39,17 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
namespace
cv
{
namespace
detail
{
static
const
float
WEIGHT_EPS
=
1e-5
f
;
Ptr
<
Blender
>
cv
::
Blender
::
createDefault
(
int
type
,
bool
try_gpu
)
Ptr
<
Blender
>
Blender
::
createDefault
(
int
type
,
bool
try_gpu
)
{
if
(
type
==
NO
)
return
new
Blender
();
...
...
@@ -59,13 +62,13 @@ Ptr<Blender> cv::Blender::createDefault(int type, bool try_gpu)
}
void
cv
::
Blender
::
prepare
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Size
>
&
sizes
)
void
Blender
::
prepare
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Size
>
&
sizes
)
{
prepare
(
resultRoi
(
corners
,
sizes
));
}
void
cv
::
Blender
::
prepare
(
Rect
dst_roi
)
void
Blender
::
prepare
(
Rect
dst_roi
)
{
dst_
.
create
(
dst_roi
.
size
(),
CV_16SC3
);
dst_
.
setTo
(
Scalar
::
all
(
0
));
...
...
@@ -75,7 +78,7 @@ void cv::Blender::prepare(Rect dst_roi)
}
void
cv
::
Blender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
void
Blender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
{
CV_Assert
(
img
.
type
()
==
CV_16SC3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
...
...
@@ -99,7 +102,7 @@ void cv::Blender::feed(const Mat &img, const Mat &mask, Point tl)
}
void
cv
::
Blender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
void
Blender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
{
dst_
.
setTo
(
Scalar
::
all
(
0
),
dst_mask_
==
0
);
dst
=
dst_
;
...
...
@@ -109,7 +112,7 @@ void cv::Blender::blend(Mat &dst, Mat &dst_mask)
}
void
cv
::
FeatherBlender
::
prepare
(
Rect
dst_roi
)
void
FeatherBlender
::
prepare
(
Rect
dst_roi
)
{
Blender
::
prepare
(
dst_roi
);
dst_weight_map_
.
create
(
dst_roi
.
size
(),
CV_32F
);
...
...
@@ -117,7 +120,7 @@ void cv::FeatherBlender::prepare(Rect dst_roi)
}
void
cv
::
FeatherBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
void
FeatherBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
{
CV_Assert
(
img
.
type
()
==
CV_16SC3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
...
...
@@ -144,7 +147,7 @@ void cv::FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl)
}
void
cv
::
FeatherBlender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
void
FeatherBlender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
{
normalizeUsingWeightMap
(
dst_weight_map_
,
dst_
);
dst_mask_
=
dst_weight_map_
>
WEIGHT_EPS
;
...
...
@@ -152,14 +155,14 @@ void cv::FeatherBlender::blend(Mat &dst, Mat &dst_mask)
}
cv
::
MultiBandBlender
::
MultiBandBlender
(
int
try_gpu
,
int
num_bands
)
MultiBandBlender
::
MultiBandBlender
(
int
try_gpu
,
int
num_bands
)
{
setNumBands
(
num_bands
);
can_use_gpu_
=
try_gpu
&&
gpu
::
getCudaEnabledDeviceCount
();
}
void
cv
::
MultiBandBlender
::
prepare
(
Rect
dst_roi
)
void
MultiBandBlender
::
prepare
(
Rect
dst_roi
)
{
dst_roi_final_
=
dst_roi
;
...
...
@@ -192,7 +195,7 @@ void cv::MultiBandBlender::prepare(Rect dst_roi)
}
void
cv
::
MultiBandBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
void
MultiBandBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
{
CV_Assert
(
img
.
type
()
==
CV_16SC3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
...
...
@@ -277,7 +280,7 @@ void cv::MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)
}
void
cv
::
MultiBandBlender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
void
MultiBandBlender
::
blend
(
Mat
&
dst
,
Mat
&
dst_mask
)
{
for
(
int
i
=
0
;
i
<=
num_bands_
;
++
i
)
normalizeUsingWeightMap
(
dst_band_weights_
[
i
],
dst_pyr_laplace_
[
i
]);
...
...
@@ -298,7 +301,7 @@ void cv::MultiBandBlender::blend(Mat &dst, Mat &dst_mask)
//////////////////////////////////////////////////////////////////////////////
// Auxiliary functions
void
cv
::
normalizeUsingWeightMap
(
const
Mat
&
weight
,
Mat
&
src
)
void
normalizeUsingWeightMap
(
const
Mat
&
weight
,
Mat
&
src
)
{
CV_Assert
(
weight
.
type
()
==
CV_32F
);
CV_Assert
(
src
.
type
()
==
CV_16SC3
);
...
...
@@ -317,7 +320,7 @@ void cv::normalizeUsingWeightMap(const Mat& weight, Mat& src)
}
void
c
v
::
c
reateWeightMap
(
const
Mat
&
mask
,
float
sharpness
,
Mat
&
weight
)
void
createWeightMap
(
const
Mat
&
mask
,
float
sharpness
,
Mat
&
weight
)
{
CV_Assert
(
mask
.
type
()
==
CV_8U
);
distanceTransform
(
mask
,
weight
,
CV_DIST_L1
,
3
);
...
...
@@ -325,7 +328,7 @@ void cv::createWeightMap(const Mat &mask, float sharpness, Mat &weight)
}
void
c
v
::
c
reateLaplacePyr
(
const
Mat
&
img
,
int
num_levels
,
vector
<
Mat
>
&
pyr
)
void
createLaplacePyr
(
const
Mat
&
img
,
int
num_levels
,
vector
<
Mat
>
&
pyr
)
{
pyr
.
resize
(
num_levels
+
1
);
pyr
[
0
]
=
img
;
...
...
@@ -340,7 +343,7 @@ void cv::createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)
}
void
c
v
::
c
reateLaplacePyrGpu
(
const
Mat
&
img
,
int
num_levels
,
vector
<
Mat
>
&
pyr
)
void
createLaplacePyrGpu
(
const
Mat
&
img
,
int
num_levels
,
vector
<
Mat
>
&
pyr
)
{
pyr
.
resize
(
num_levels
+
1
);
...
...
@@ -361,7 +364,7 @@ void cv::createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
}
void
cv
::
restoreImageFromLaplacePyr
(
vector
<
Mat
>
&
pyr
)
void
restoreImageFromLaplacePyr
(
vector
<
Mat
>
&
pyr
)
{
if
(
pyr
.
size
()
==
0
)
return
;
...
...
@@ -372,3 +375,6 @@ void cv::restoreImageFromLaplacePyr(vector<Mat> &pyr)
add
(
tmp
,
pyr
[
i
-
1
],
pyr
[
i
-
1
]);
}
}
}
// namespace detail
}
// namespace cv
modules/stitching/src/camera.cpp
View file @
95a3ffd0
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
cv
::
CameraParams
::
CameraParams
()
:
focal
(
1
),
R
(
Mat
::
eye
(
3
,
3
,
CV_64F
)),
t
(
Mat
::
zeros
(
3
,
1
,
CV_64F
))
{}
namespace
cv
{
namespace
detail
{
CameraParams
::
CameraParams
()
:
focal
(
1
),
R
(
Mat
::
eye
(
3
,
3
,
CV_64F
)),
t
(
Mat
::
zeros
(
3
,
1
,
CV_64F
))
{}
cv
::
CameraParams
::
CameraParams
(
const
CameraParams
&
other
)
{
*
this
=
other
;
}
CameraParams
::
CameraParams
(
const
CameraParams
&
other
)
{
*
this
=
other
;
}
const
cv
::
CameraParams
&
CameraParams
::
operator
=
(
const
CameraParams
&
other
)
const
CameraParams
&
CameraParams
::
operator
=
(
const
CameraParams
&
other
)
{
focal
=
other
.
focal
;
R
=
other
.
R
.
clone
();
t
=
other
.
t
.
clone
();
return
*
this
;
}
}
// namespace detail
}
// namespace cv
modules/stitching/src/exposure_compensate.cpp
View file @
95a3ffd0
...
...
@@ -39,13 +39,16 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
gpu
;
Ptr
<
ExposureCompensator
>
cv
::
ExposureCompensator
::
createDefault
(
int
type
)
namespace
cv
{
namespace
detail
{
Ptr
<
ExposureCompensator
>
ExposureCompensator
::
createDefault
(
int
type
)
{
if
(
type
==
NO
)
return
new
NoExposureCompensator
();
...
...
@@ -58,8 +61,8 @@ Ptr<ExposureCompensator> cv::ExposureCompensator::createDefault(int type)
}
void
cv
::
ExposureCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
const
vector
<
Mat
>
&
masks
)
void
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
)
...
...
@@ -68,8 +71,8 @@ void cv::ExposureCompensator::feed(const vector<Point> &corners, const vector<Ma
}
void
cv
::
GainCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
const
vector
<
pair
<
Mat
,
uchar
>
>
&
masks
)
void
GainCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
const
vector
<
pair
<
Mat
,
uchar
>
>
&
masks
)
{
LOGLN
(
"Exposure compensation..."
);
int64
t
=
getTickCount
();
...
...
@@ -143,13 +146,13 @@ void cv::GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &
}
void
cv
::
GainCompensator
::
apply
(
int
index
,
Point
/*corner*/
,
Mat
&
image
,
const
Mat
&
/*mask*/
)
void
GainCompensator
::
apply
(
int
index
,
Point
/*corner*/
,
Mat
&
image
,
const
Mat
&
/*mask*/
)
{
image
*=
gains_
(
index
,
0
);
}
vector
<
double
>
cv
::
GainCompensator
::
gains
()
const
vector
<
double
>
GainCompensator
::
gains
()
const
{
vector
<
double
>
gains_vec
(
gains_
.
rows
);
for
(
int
i
=
0
;
i
<
gains_
.
rows
;
++
i
)
...
...
@@ -158,7 +161,7 @@ vector<double> cv::GainCompensator::gains() const
}
void
cv
::
BlocksGainCompensator
::
feed
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
,
void
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
());
...
...
@@ -218,7 +221,7 @@ void cv::BlocksGainCompensator::feed(const vector<Point> &corners, const vector<
}
void
cv
::
BlocksGainCompensator
::
apply
(
int
index
,
Point
/*corner*/
,
Mat
&
image
,
const
Mat
&
/*mask*/
)
void
BlocksGainCompensator
::
apply
(
int
index
,
Point
/*corner*/
,
Mat
&
image
,
const
Mat
&
/*mask*/
)
{
CV_Assert
(
image
.
type
()
==
CV_8UC3
);
...
...
@@ -240,3 +243,6 @@ void cv::BlocksGainCompensator::apply(int index, Point /*corner*/, Mat &image, c
}
}
}
}
// namespace detail
}
// namespace cv
modules/stitching/src/matchers.cpp
View file @
95a3ffd0
This diff is collapsed.
Click to expand it.
modules/stitching/src/motion_estimators.cpp
View file @
95a3ffd0
...
...
@@ -39,56 +39,69 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
detail
;
namespace
{
namespa
ce
struct
IncDistan
ce
{
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
])
{}
struct
CalcRotation
void
operator
()(
const
GraphEdge
&
edge
)
{
CalcRotation
(
int
num_images
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
:
num_images
(
num_images
),
pairwise_matches
(
&
pairwise_matches
[
0
]),
cameras
(
&
cameras
[
0
])
{}
int
pair_idx
=
edge
.
from
*
num_images
+
edge
.
to
;
void
operator
()(
const
GraphEdge
&
edge
)
{
int
pair_idx
=
edge
.
from
*
num_images
+
edge
.
to
;
double
f_from
=
cameras
[
edge
.
from
].
focal
;
double
f_to
=
cameras
[
edge
.
to
].
focal
;
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
;
int
num_images
;
const
MatchesInfo
*
pairwise_matches
;
CameraParams
*
cameras
;
};
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
;
};
//////////////////////////////////////////////////////////////////////////////
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
;
}
}
// namespace
void
cv
::
HomographyBasedEstimator
::
estimate
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
namespace
cv
{
namespace
detail
{
void
HomographyBasedEstimator
::
estimate
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
{
LOGLN
(
"Estimating rotations..."
);
int64
t
=
getTickCount
();
...
...
@@ -135,8 +148,8 @@ void cv::HomographyBasedEstimator::estimate(const vector<ImageFeatures> &feature
//////////////////////////////////////////////////////////////////////////////
void
cv
::
BundleAdjuster
::
estimate
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
void
BundleAdjuster
::
estimate
(
const
vector
<
ImageFeatures
>
&
features
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
CameraParams
>
&
cameras
)
{
if
(
cost_space_
==
NO
)
return
;
...
...
@@ -250,7 +263,7 @@ void cv::BundleAdjuster::estimate(const vector<ImageFeatures> &features, const v
}
void
cv
::
BundleAdjuster
::
calcError
(
Mat
&
err
)
void
BundleAdjuster
::
calcError
(
Mat
&
err
)
{
err
.
create
(
total_num_matches_
*
3
,
1
,
CV_64F
);
...
...
@@ -314,19 +327,7 @@ void cv::BundleAdjuster::calcError(Mat &err)
}
namespace
{
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
;
}
}
// namespace
void
cv
::
BundleAdjuster
::
calcJacobian
()
void
BundleAdjuster
::
calcJacobian
()
{
J_
.
create
(
total_num_matches_
*
3
,
num_images_
*
4
,
CV_64F
);
...
...
@@ -374,7 +375,7 @@ void cv::BundleAdjuster::calcJacobian()
//////////////////////////////////////////////////////////////////////////////
// TODO replace SVD with eigen
void
cv
::
waveCorrect
(
vector
<
Mat
>
&
rmats
)
void
waveCorrect
(
vector
<
Mat
>
&
rmats
)
{
LOGLN
(
"Wave correcting..."
);
int64
t
=
getTickCount
();
...
...
@@ -415,7 +416,7 @@ void cv::waveCorrect(vector<Mat> &rmats)
//////////////////////////////////////////////////////////////////////////////
string
cv
::
matchesGraphAsString
(
vector
<
string
>
&
pathes
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
string
matchesGraphAsString
(
vector
<
string
>
&
pathes
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
)
{
stringstream
str
;
...
...
@@ -481,7 +482,7 @@ string cv::matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pai
return
str
.
str
();
}
vector
<
int
>
cv
::
leaveBiggestComponent
(
vector
<
ImageFeatures
>
&
features
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
vector
<
int
>
leaveBiggestComponent
(
vector
<
ImageFeatures
>
&
features
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
)
{
const
int
num_images
=
static_cast
<
int
>
(
features
.
size
());
...
...
@@ -539,7 +540,7 @@ vector<int> cv::leaveBiggestComponent(vector<ImageFeatures> &features, vector<M
}
void
cv
::
findMaxSpanningTree
(
int
num_images
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
void
findMaxSpanningTree
(
int
num_images
,
const
vector
<
MatchesInfo
>
&
pairwise_matches
,
Graph
&
span_tree
,
vector
<
int
>
&
centers
)
{
Graph
graph
(
num_images
);
...
...
@@ -608,3 +609,7 @@ void cv::findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise
centers
.
push_back
(
i
);
CV_Assert
(
centers
.
size
()
>
0
&&
centers
.
size
()
<=
2
);
}
}
// namespace detail
}
// namespace cv
modules/stitching/src/precomp.hpp
View file @
95a3ffd0
...
...
@@ -52,15 +52,15 @@
#include <set>
#include <functional>
#include <sstream>
#include "opencv2/stitching/autocalib.hpp"
#include "opencv2/stitching/blenders.hpp"
#include "opencv2/stitching/camera.hpp"
#include "opencv2/stitching/exposure_compensate.hpp"
#include "opencv2/stitching/matchers.hpp"
#include "opencv2/stitching/motion_estimators.hpp"
#include "opencv2/stitching/seam_finders.hpp"
#include "opencv2/stitching/util.hpp"
#include "opencv2/stitching/warpers.hpp"
#include "opencv2/stitching/
detail/
autocalib.hpp"
#include "opencv2/stitching/
detail/
blenders.hpp"
#include "opencv2/stitching/
detail/
camera.hpp"
#include "opencv2/stitching/
detail/
exposure_compensate.hpp"
#include "opencv2/stitching/
detail/
matchers.hpp"
#include "opencv2/stitching/
detail/
motion_estimators.hpp"
#include "opencv2/stitching/
detail/
seam_finders.hpp"
#include "opencv2/stitching/
detail/
util.hpp"
#include "opencv2/stitching/
detail/
warpers.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/core/internal.hpp"
#include "opencv2/imgproc/imgproc.hpp"
...
...
modules/stitching/src/seam_finders.cpp
View file @
95a3ffd0
...
...
@@ -39,12 +39,15 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
Ptr
<
SeamFinder
>
cv
::
SeamFinder
::
createDefault
(
int
type
)
namespace
cv
{
namespace
detail
{
Ptr
<
SeamFinder
>
SeamFinder
::
createDefault
(
int
type
)
{
if
(
type
==
NO
)
return
new
NoSeamFinder
();
...
...
@@ -59,7 +62,7 @@ Ptr<SeamFinder> cv::SeamFinder::createDefault(int type)
}
void
cv
::
PairwiseSeamFinder
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
void
PairwiseSeamFinder
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
vector
<
Mat
>
&
masks
)
{
LOGLN
(
"Finding seams..."
);
...
...
@@ -86,7 +89,7 @@ void cv::PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &c
}
void
cv
::
VoronoiSeamFinder
::
findInPair
(
size_t
first
,
size_t
second
,
Rect
roi
)
void
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
);
...
...
@@ -140,7 +143,7 @@ void cv::VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi)
}
class
cv
::
GraphCutSeamFinder
::
Impl
:
public
PairwiseSeamFinder
class
GraphCutSeamFinder
::
Impl
:
public
PairwiseSeamFinder
{
public
:
Impl
(
int
cost_type
,
float
terminal_cost
,
float
bad_region_penalty
)
...
...
@@ -163,7 +166,7 @@ private:
};
void
cv
::
GraphCutSeamFinder
::
Impl
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
void
GraphCutSeamFinder
::
Impl
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
vector
<
Mat
>
&
masks
)
{
// Compute gradients
...
...
@@ -194,7 +197,7 @@ void cv::GraphCutSeamFinder::Impl::find(const vector<Mat> &src, const vector<Poi
}
void
cv
::
GraphCutSeamFinder
::
Impl
::
setGraphWeightsColor
(
const
Mat
&
img1
,
const
Mat
&
img2
,
void
GraphCutSeamFinder
::
Impl
::
setGraphWeightsColor
(
const
Mat
&
img1
,
const
Mat
&
img2
,
const
Mat
&
mask1
,
const
Mat
&
mask2
,
GCGraph
<
float
>
&
graph
)
{
const
Size
img_size
=
img1
.
size
();
...
...
@@ -242,7 +245,7 @@ void cv::GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const M
}
void
cv
::
GraphCutSeamFinder
::
Impl
::
setGraphWeightsColorGrad
(
void
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
)
...
...
@@ -296,7 +299,7 @@ void cv::GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
}
void
cv
::
GraphCutSeamFinder
::
Impl
::
findInPair
(
size_t
first
,
size_t
second
,
Rect
roi
)
void
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
];
...
...
@@ -394,12 +397,16 @@ void cv::GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect
}
cv
::
GraphCutSeamFinder
::
GraphCutSeamFinder
(
int
cost_type
,
float
terminal_cost
,
float
bad_region_penalty
)
GraphCutSeamFinder
::
GraphCutSeamFinder
(
int
cost_type
,
float
terminal_cost
,
float
bad_region_penalty
)
:
impl_
(
new
Impl
(
cost_type
,
terminal_cost
,
bad_region_penalty
))
{}
void
cv
::
GraphCutSeamFinder
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
void
GraphCutSeamFinder
::
find
(
const
vector
<
Mat
>
&
src
,
const
vector
<
Point
>
&
corners
,
vector
<
Mat
>
&
masks
)
{
impl_
->
find
(
src
,
corners
,
masks
);
}
}
// namespace detail
}
// namespace cv
modules/stitching/src/util.cpp
View file @
95a3ffd0
...
...
@@ -42,9 +42,11 @@
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
void
cv
::
DisjointSets
::
createOneElemSets
(
int
n
)
namespace
cv
{
namespace
detail
{
void
DisjointSets
::
createOneElemSets
(
int
n
)
{
rank_
.
assign
(
n
,
0
);
size
.
assign
(
n
,
1
);
...
...
@@ -54,7 +56,7 @@ void cv::DisjointSets::createOneElemSets(int n)
}
int
cv
::
DisjointSets
::
findSetByElem
(
int
elem
)
int
DisjointSets
::
findSetByElem
(
int
elem
)
{
int
set
=
elem
;
while
(
set
!=
parent
[
set
])
...
...
@@ -70,7 +72,7 @@ int cv::DisjointSets::findSetByElem(int elem)
}
int
cv
::
DisjointSets
::
mergeSets
(
int
set1
,
int
set2
)
int
DisjointSets
::
mergeSets
(
int
set1
,
int
set2
)
{
if
(
rank_
[
set1
]
<
rank_
[
set2
])
{
...
...
@@ -91,13 +93,13 @@ int cv::DisjointSets::mergeSets(int set1, int set2)
}
void
cv
::
Graph
::
addEdge
(
int
from
,
int
to
,
float
weight
)
void
Graph
::
addEdge
(
int
from
,
int
to
,
float
weight
)
{
edges_
[
from
].
push_back
(
GraphEdge
(
from
,
to
,
weight
));
}
bool
cv
::
overlapRoi
(
Point
tl1
,
Point
tl2
,
Size
sz1
,
Size
sz2
,
Rect
&
roi
)
bool
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
);
...
...
@@ -112,7 +114,7 @@ bool cv::overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi)
}
Rect
cv
::
resultRoi
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
)
Rect
resultRoi
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Mat
>
&
images
)
{
vector
<
Size
>
sizes
(
images
.
size
());
for
(
size_t
i
=
0
;
i
<
images
.
size
();
++
i
)
...
...
@@ -121,7 +123,7 @@ Rect cv::resultRoi(const vector<Point> &corners, const vector<Mat> &images)
}
Rect
cv
::
resultRoi
(
const
vector
<
Point
>
&
corners
,
const
vector
<
Size
>
&
sizes
)
Rect
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
());
...
...
@@ -137,7 +139,7 @@ Rect cv::resultRoi(const vector<Point> &corners, const vector<Size> &sizes)
}
Point
cv
::
resultTl
(
const
vector
<
Point
>
&
corners
)
Point
resultTl
(
const
vector
<
Point
>
&
corners
)
{
Point
tl
(
numeric_limits
<
int
>::
max
(),
numeric_limits
<
int
>::
max
());
for
(
size_t
i
=
0
;
i
<
corners
.
size
();
++
i
)
...
...
@@ -149,7 +151,7 @@ Point cv::resultTl(const vector<Point> &corners)
}
void
cv
::
selectRandomSubset
(
int
count
,
int
size
,
vector
<
int
>
&
subset
)
void
selectRandomSubset
(
int
count
,
int
size
,
vector
<
int
>
&
subset
)
{
subset
.
clear
();
for
(
int
i
=
0
;
i
<
size
;
++
i
)
...
...
@@ -161,3 +163,6 @@ void cv::selectRandomSubset(int count, int size, vector<int> &subset)
}
}
}
}
// namespace detail
}
// namespace cv
modules/stitching/src/warpers.cpp
View file @
95a3ffd0
...
...
@@ -39,12 +39,15 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
Ptr
<
Warper
>
cv
::
Warper
::
createByCameraFocal
(
float
focal
,
int
type
,
bool
try_gpu
)
namespace
cv
{
namespace
detail
{
Ptr
<
Warper
>
Warper
::
createByCameraFocal
(
float
focal
,
int
type
,
bool
try_gpu
)
{
bool
can_use_gpu
=
try_gpu
&&
gpu
::
getCudaEnabledDeviceCount
();
if
(
type
==
PLANE
)
...
...
@@ -58,7 +61,7 @@ Ptr<Warper> cv::Warper::createByCameraFocal(float focal, int type, bool try_gpu)
}
void
cv
::
ProjectorBase
::
setTransformation
(
const
Mat
&
R
)
void
ProjectorBase
::
setTransformation
(
const
Mat
&
R
)
{
CV_Assert
(
R
.
size
()
==
Size
(
3
,
3
));
CV_Assert
(
R
.
type
()
==
CV_32F
);
...
...
@@ -73,7 +76,7 @@ void cv::ProjectorBase::setTransformation(const Mat &R)
}
void
cv
::
PlaneWarper
::
detectResultRoi
(
Point
&
dst_tl
,
Point
&
dst_br
)
void
PlaneWarper
::
detectResultRoi
(
Point
&
dst_tl
,
Point
&
dst_br
)
{
float
tl_uf
=
numeric_limits
<
float
>::
max
();
float
tl_vf
=
numeric_limits
<
float
>::
max
();
...
...
@@ -105,14 +108,14 @@ void cv::PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
}
Point
cv
::
PlaneWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
cv
::
Mat
&
R
,
cv
::
Mat
&
dst
,
int
interp_mode
,
int
border_mode
)
Point
PlaneWarperGpu
::
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
();
projector_
.
focal
=
focal
;
projector_
.
setTransformation
(
R
);
cv
::
Point
dst_tl
,
dst_br
;
Point
dst_tl
,
dst_br
;
detectResultRoi
(
dst_tl
,
dst_br
);
gpu
::
buildWarpPlaneMaps
(
src
.
size
(),
Rect
(
dst_tl
,
Point
(
dst_br
.
x
+
1
,
dst_br
.
y
+
1
)),
...
...
@@ -131,7 +134,7 @@ Point cv::PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv
}
void
cv
::
SphericalWarper
::
detectResultRoi
(
Point
&
dst_tl
,
Point
&
dst_br
)
void
SphericalWarper
::
detectResultRoi
(
Point
&
dst_tl
,
Point
&
dst_br
)
{
detectResultRoiByBorder
(
dst_tl
,
dst_br
);
...
...
@@ -175,7 +178,7 @@ void cv::SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
}
Point
cv
::
SphericalWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
Mat
&
R
,
Mat
&
dst
,
Point
SphericalWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
Mat
&
R
,
Mat
&
dst
,
int
interp_mode
,
int
border_mode
)
{
src_size_
=
src
.
size
();
...
...
@@ -183,7 +186,7 @@ Point cv::SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Ma
projector_
.
focal
=
focal
;
projector_
.
setTransformation
(
R
);
cv
::
Point
dst_tl
,
dst_br
;
Point
dst_tl
,
dst_br
;
detectResultRoi
(
dst_tl
,
dst_br
);
gpu
::
buildWarpSphericalMaps
(
src
.
size
(),
Rect
(
dst_tl
,
Point
(
dst_br
.
x
+
1
,
dst_br
.
y
+
1
)),
...
...
@@ -202,7 +205,7 @@ Point cv::SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Ma
}
Point
cv
::
CylindricalWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
Mat
&
R
,
Mat
&
dst
,
Point
CylindricalWarperGpu
::
warp
(
const
Mat
&
src
,
float
focal
,
const
Mat
&
R
,
Mat
&
dst
,
int
interp_mode
,
int
border_mode
)
{
src_size_
=
src
.
size
();
...
...
@@ -210,7 +213,7 @@ Point cv::CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R,
projector_
.
focal
=
focal
;
projector_
.
setTransformation
(
R
);
cv
::
Point
dst_tl
,
dst_br
;
Point
dst_tl
,
dst_br
;
detectResultRoi
(
dst_tl
,
dst_br
);
gpu
::
buildWarpCylindricalMaps
(
src
.
size
(),
Rect
(
dst_tl
,
Point
(
dst_br
.
x
+
1
,
dst_br
.
y
+
1
)),
...
...
@@ -228,3 +231,5 @@ Point cv::CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R,
return
dst_tl
;
}
}
// namespace detail
}
// namespace cv
samples/cpp/stitching.cpp
View file @
95a3ffd0
...
...
@@ -49,11 +49,20 @@
// Matthew Brown and David G. Lowe. 2007.
#include <fstream>
#include "opencv2/stitching/stitching.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/detail/autocalib.hpp"
#include "opencv2/stitching/detail/blenders.hpp"
#include "opencv2/stitching/detail/camera.hpp"
#include "opencv2/stitching/detail/exposure_compensate.hpp"
#include "opencv2/stitching/detail/matchers.hpp"
#include "opencv2/stitching/detail/motion_estimators.hpp"
#include "opencv2/stitching/detail/seam_finders.hpp"
#include "opencv2/stitching/detail/util.hpp"
#include "opencv2/stitching/detail/warpers.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
detail
;
void
printUsage
()
{
...
...
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