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
78bb3920
Commit
78bb3920
authored
Aug 16, 2011
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored opencv_stitching
parent
f1e8b43c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
75 deletions
+37
-75
camera.cpp
modules/stitching/camera.cpp
+7
-20
camera.hpp
modules/stitching/camera.hpp
+7
-6
motion_estimators.cpp
modules/stitching/motion_estimators.cpp
+14
-29
motion_estimators.hpp
modules/stitching/motion_estimators.hpp
+1
-12
util.cpp
modules/stitching/util.cpp
+3
-3
util.hpp
modules/stitching/util.hpp
+5
-5
No files found.
modules/stitching/camera.cpp
View file @
78bb3920
...
...
@@ -5,27 +5,14 @@ using namespace std;
using
namespace
cv
;
CameraInfo
CameraInfo
::
load
(
const
string
&
path
)
{
FileStorage
fs
(
path
,
FileStorage
::
READ
);
CV_Assert
(
fs
.
isOpened
());
CameraInfo
cam
;
if
(
!
fs
[
"R"
].
isNone
())
fs
[
"R"
]
>>
cam
.
R
;
if
(
!
fs
[
"K"
].
isNone
())
fs
[
"K"
]
>>
cam
.
K
;
return
cam
;
}
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
;
}
void
CameraInfo
::
save
(
const
string
&
path
)
const
CameraParams
&
CameraParams
::
operator
=
(
const
CameraParams
&
other
)
{
FileStorage
fs
(
path
,
FileStorage
::
WRITE
);
CV_Assert
(
fs
.
isOpened
());
if
(
!
R
.
empty
())
fs
<<
"R"
<<
R
;
if
(
!
K
.
empty
())
fs
<<
"K"
<<
K
;
focal
=
other
.
focal
;
R
=
other
.
R
.
clone
();
t
=
other
.
t
.
clone
();
return
*
this
;
}
modules/stitching/camera.hpp
View file @
78bb3920
...
...
@@ -45,14 +45,15 @@
#include "precomp.hpp"
class
CameraInfo
struct
CameraParams
{
public
:
static
CameraInfo
load
(
const
std
::
string
&
path
);
void
save
(
const
std
::
string
&
path
);
CameraParams
();
CameraParams
(
const
CameraParams
&
other
);
const
CameraParams
&
operator
=
(
const
CameraParams
&
other
);
cv
::
Mat
R
;
cv
::
Mat
K
;
double
focal
;
// Focal length
cv
::
Mat
R
;
// Rotation
cv
::
Mat
t
;
// Translation
};
#endif // #ifndef __OPENCV_CAMERA_HPP__
modules/stitching/motion_estimators.cpp
View file @
78bb3920
...
...
@@ -49,21 +49,6 @@ using namespace std;
using
namespace
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
;
}
const
CameraParams
&
CameraParams
::
operator
=
(
const
CameraParams
&
other
)
{
focal
=
other
.
focal
;
R
=
other
.
R
.
clone
();
t
=
other
.
t
.
clone
();
return
*
this
;
}
//////////////////////////////////////////////////////////////////////////////
struct
IncDistance
...
...
@@ -434,7 +419,7 @@ string matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pairwis
const
int
num_images
=
static_cast
<
int
>
(
pathes
.
size
());
set
<
pair
<
int
,
int
>
>
span_tree_edges
;
D
j
Sets
comps
(
num_images
);
D
isjoint
Sets
comps
(
num_images
);
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
{
...
...
@@ -442,11 +427,11 @@ string matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pairwis
{
if
(
pairwise_matches
[
i
*
num_images
+
j
].
confidence
<
conf_threshold
)
continue
;
int
comp1
=
comps
.
find
(
i
);
int
comp2
=
comps
.
find
(
j
);
int
comp1
=
comps
.
find
SetByElem
(
i
);
int
comp2
=
comps
.
find
SetByElem
(
j
);
if
(
comp1
!=
comp2
)
{
comps
.
merge
(
comp1
,
comp2
);
comps
.
merge
Sets
(
comp1
,
comp2
);
span_tree_edges
.
insert
(
make_pair
(
i
,
j
));
}
}
...
...
@@ -478,7 +463,7 @@ string matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pairwis
for
(
size_t
i
=
0
;
i
<
comps
.
size
.
size
();
++
i
)
{
if
(
comps
.
size
[
comps
.
find
(
i
)]
==
1
)
if
(
comps
.
size
[
comps
.
find
SetByElem
(
i
)]
==
1
)
{
string
name
=
pathes
[
i
];
size_t
prefix_len
=
name
.
find_last_of
(
"/
\\
"
);
...
...
@@ -497,17 +482,17 @@ vector<int> leaveBiggestComponent(vector<ImageFeatures> &features, vector<Match
{
const
int
num_images
=
static_cast
<
int
>
(
features
.
size
());
D
j
Sets
comps
(
num_images
);
D
isjoint
Sets
comps
(
num_images
);
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
{
for
(
int
j
=
0
;
j
<
num_images
;
++
j
)
{
if
(
pairwise_matches
[
i
*
num_images
+
j
].
confidence
<
conf_threshold
)
continue
;
int
comp1
=
comps
.
find
(
i
);
int
comp2
=
comps
.
find
(
j
);
int
comp1
=
comps
.
find
SetByElem
(
i
);
int
comp2
=
comps
.
find
SetByElem
(
j
);
if
(
comp1
!=
comp2
)
comps
.
merge
(
comp1
,
comp2
);
comps
.
merge
Sets
(
comp1
,
comp2
);
}
}
...
...
@@ -516,7 +501,7 @@ vector<int> leaveBiggestComponent(vector<ImageFeatures> &features, vector<Match
vector
<
int
>
indices
;
vector
<
int
>
indices_removed
;
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
if
(
comps
.
find
(
i
)
==
max_comp
)
if
(
comps
.
find
SetByElem
(
i
)
==
max_comp
)
indices
.
push_back
(
i
);
else
indices_removed
.
push_back
(
i
);
...
...
@@ -569,7 +554,7 @@ void findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_mat
}
}
D
j
Sets
comps
(
num_images
);
D
isjoint
Sets
comps
(
num_images
);
span_tree
.
create
(
num_images
);
vector
<
int
>
span_tree_powers
(
num_images
,
0
);
...
...
@@ -577,11 +562,11 @@ void findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_mat
sort
(
edges
.
begin
(),
edges
.
end
(),
greater
<
GraphEdge
>
());
for
(
size_t
i
=
0
;
i
<
edges
.
size
();
++
i
)
{
int
comp1
=
comps
.
find
(
edges
[
i
].
from
);
int
comp2
=
comps
.
find
(
edges
[
i
].
to
);
int
comp1
=
comps
.
find
SetByElem
(
edges
[
i
].
from
);
int
comp2
=
comps
.
find
SetByElem
(
edges
[
i
].
to
);
if
(
comp1
!=
comp2
)
{
comps
.
merge
(
comp1
,
comp2
);
comps
.
merge
Sets
(
comp1
,
comp2
);
span_tree
.
addEdge
(
edges
[
i
].
from
,
edges
[
i
].
to
,
edges
[
i
].
weight
);
span_tree
.
addEdge
(
edges
[
i
].
to
,
edges
[
i
].
from
,
edges
[
i
].
weight
);
span_tree_powers
[
edges
[
i
].
from
]
++
;
...
...
modules/stitching/motion_estimators.hpp
View file @
78bb3920
...
...
@@ -45,18 +45,7 @@
#include "precomp.hpp"
#include "matchers.hpp"
#include "util.hpp"
struct
CameraParams
{
CameraParams
();
CameraParams
(
const
CameraParams
&
other
);
const
CameraParams
&
operator
=
(
const
CameraParams
&
other
);
double
focal
;
// Focal length
cv
::
Mat
R
;
// Rotation
cv
::
Mat
t
;
// Translation
};
#include "camera.hpp"
class
Estimator
{
...
...
modules/stitching/util.cpp
View file @
78bb3920
...
...
@@ -44,7 +44,7 @@
using
namespace
std
;
using
namespace
cv
;
void
D
jSets
::
create
(
int
n
)
void
D
isjointSets
::
createOneElemSets
(
int
n
)
{
rank_
.
assign
(
n
,
0
);
size
.
assign
(
n
,
1
);
...
...
@@ -54,7 +54,7 @@ void DjSets::create(int n)
}
int
D
jSets
::
find
(
int
elem
)
int
D
isjointSets
::
findSetByElem
(
int
elem
)
{
int
set
=
elem
;
while
(
set
!=
parent
[
set
])
...
...
@@ -70,7 +70,7 @@ int DjSets::find(int elem)
}
int
D
jSets
::
merge
(
int
set1
,
int
set2
)
int
D
isjointSets
::
mergeSets
(
int
set1
,
int
set2
)
{
if
(
rank_
[
set1
]
<
rank_
[
set2
])
{
...
...
modules/stitching/util.hpp
View file @
78bb3920
...
...
@@ -57,14 +57,14 @@
#define LOGLN(msg) LOG(msg << std::endl)
class
D
j
Sets
class
D
isjoint
Sets
{
public
:
D
jSets
(
int
n
=
0
)
{
create
(
n
);
}
D
isjointSets
(
int
elem_count
=
0
)
{
createOneElemSets
(
elem_count
);
}
void
create
(
int
n
);
int
find
(
int
elem
);
int
merge
(
int
set1
,
int
set2
);
void
create
OneElemSets
(
int
elem_count
);
int
find
SetByElem
(
int
elem
);
int
merge
Sets
(
int
set1
,
int
set2
);
std
::
vector
<
int
>
parent
;
std
::
vector
<
int
>
size
;
...
...
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