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
ff071d2c
Commit
ff071d2c
authored
Apr 02, 2012
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Algorithm::get/set/addParam(vector<Mat>) (to be used by EM)
parent
6fdf7b4d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
4 deletions
+92
-4
core.hpp
modules/core/include/opencv2/core/core.hpp
+16
-1
operations.hpp
modules/core/include/opencv2/core/operations.hpp
+4
-2
algorithm.cpp
modules/core/src/algorithm.cpp
+47
-0
persistence.cpp
modules/core/src/persistence.cpp
+25
-1
No files found.
modules/core/include/opencv2/core/core.hpp
View file @
ff071d2c
...
...
@@ -4273,6 +4273,7 @@ public:
void
set
(
const
string
&
name
,
bool
value
);
void
set
(
const
string
&
name
,
const
string
&
value
);
void
set
(
const
string
&
name
,
const
Mat
&
value
);
void
set
(
const
string
&
name
,
const
vector
<
Mat
>&
value
);
void
set
(
const
string
&
name
,
const
Ptr
<
Algorithm
>&
value
);
void
set
(
const
char
*
name
,
int
value
);
...
...
@@ -4280,6 +4281,7 @@ public:
void
set
(
const
char
*
name
,
bool
value
);
void
set
(
const
char
*
name
,
const
string
&
value
);
void
set
(
const
char
*
name
,
const
Mat
&
value
);
void
set
(
const
char
*
name
,
const
vector
<
Mat
>&
value
);
void
set
(
const
char
*
name
,
const
Ptr
<
Algorithm
>&
value
);
string
paramHelp
(
const
string
&
name
)
const
;
...
...
@@ -4347,6 +4349,11 @@ public:
Mat
(
Algorithm
::*
getter
)()
=
0
,
void
(
Algorithm
::*
setter
)(
const
Mat
&
)
=
0
,
const
string
&
help
=
string
());
void
addParam
(
Algorithm
&
algo
,
const
char
*
name
,
vector
<
Mat
>&
value
,
bool
readOnly
=
false
,
vector
<
Mat
>
(
Algorithm
::*
getter
)()
=
0
,
void
(
Algorithm
::*
setter
)(
const
vector
<
Mat
>&
)
=
0
,
const
string
&
help
=
string
());
void
addParam
(
Algorithm
&
algo
,
const
char
*
name
,
Ptr
<
Algorithm
>&
value
,
bool
readOnly
=
false
,
Ptr
<
Algorithm
>
(
Algorithm
::*
getter
)()
=
0
,
...
...
@@ -4359,7 +4366,7 @@ protected:
struct
CV_EXPORTS
Param
{
enum
{
INT
=
0
,
BOOLEAN
=
1
,
REAL
=
2
,
STRING
=
3
,
MAT
=
4
,
ALGORITHM
=
5
};
enum
{
INT
=
0
,
BOOLEAN
=
1
,
REAL
=
2
,
STRING
=
3
,
MAT
=
4
,
MAT_VECTOR
=
5
,
ALGORITHM
=
6
};
Param
();
Param
(
int
_type
,
bool
_readonly
,
int
_offset
,
...
...
@@ -4414,6 +4421,14 @@ template<> struct ParamType<Mat>
enum
{
type
=
Param
::
MAT
};
};
template
<>
struct
ParamType
<
vector
<
Mat
>
>
{
typedef
const
vector
<
Mat
>&
const_param_type
;
typedef
vector
<
Mat
>
member_type
;
enum
{
type
=
Param
::
MAT_VECTOR
};
};
template
<>
struct
ParamType
<
Algorithm
>
{
typedef
const
Ptr
<
Algorithm
>&
const_param_type
;
...
...
modules/core/include/opencv2/core/operations.hpp
View file @
ff071d2c
...
...
@@ -2856,7 +2856,8 @@ operator << ( FileStorage& fs, const vector<_Tp>& vec )
CV_EXPORTS_W
void
write
(
FileStorage
&
fs
,
const
string
&
name
,
const
Mat
&
value
);
CV_EXPORTS
void
write
(
FileStorage
&
fs
,
const
string
&
name
,
const
SparseMat
&
value
);
CV_EXPORTS
void
write
(
FileStorage
&
fs
,
const
string
&
name
,
const
vector
<
Mat
>&
value
);
template
<
typename
_Tp
>
static
inline
FileStorage
&
operator
<<
(
FileStorage
&
fs
,
const
_Tp
&
value
)
{
if
(
!
fs
.
isOpened
()
)
...
...
@@ -2956,7 +2957,8 @@ static inline void read(const FileNode& node, string& value, const string& defau
}
CV_EXPORTS_W
void
read
(
const
FileNode
&
node
,
Mat
&
mat
,
const
Mat
&
default_mat
=
Mat
()
);
CV_EXPORTS
void
read
(
const
FileNode
&
node
,
SparseMat
&
mat
,
const
SparseMat
&
default_mat
=
SparseMat
()
);
CV_EXPORTS
void
read
(
const
FileNode
&
node
,
SparseMat
&
mat
,
const
SparseMat
&
default_mat
=
SparseMat
()
);
CV_EXPORTS
void
read
(
const
FileNode
&
node
,
vector
<
Mat
>&
mat
,
const
vector
<
Mat
>&
default_mat_vector
=
vector
<
Mat
>
()
);
inline
FileNode
::
operator
int
()
const
{
...
...
modules/core/src/algorithm.cpp
View file @
ff071d2c
...
...
@@ -202,6 +202,11 @@ void Algorithm::set(const string& name, const Mat& value)
info
()
->
set
(
this
,
name
.
c_str
(),
ParamType
<
Mat
>::
type
,
&
value
);
}
void
Algorithm
::
set
(
const
string
&
name
,
const
vector
<
Mat
>&
value
)
{
info
()
->
set
(
this
,
name
.
c_str
(),
ParamType
<
vector
<
Mat
>
>::
type
,
&
value
);
}
void
Algorithm
::
set
(
const
string
&
name
,
const
Ptr
<
Algorithm
>&
value
)
{
info
()
->
set
(
this
,
name
.
c_str
(),
ParamType
<
Algorithm
>::
type
,
&
value
);
...
...
@@ -232,6 +237,11 @@ void Algorithm::set(const char* name, const Mat& value)
info
()
->
set
(
this
,
name
,
ParamType
<
Mat
>::
type
,
&
value
);
}
void
Algorithm
::
set
(
const
char
*
name
,
const
vector
<
Mat
>&
value
)
{
info
()
->
set
(
this
,
name
,
ParamType
<
vector
<
Mat
>
>::
type
,
&
value
);
}
void
Algorithm
::
set
(
const
char
*
name
,
const
Ptr
<
Algorithm
>&
value
)
{
info
()
->
set
(
this
,
name
,
ParamType
<
Algorithm
>::
type
,
&
value
);
...
...
@@ -298,6 +308,8 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
cv
::
write
(
fs
,
pname
,
algo
->
get
<
string
>
(
pname
));
else
if
(
p
.
type
==
Param
::
MAT
)
cv
::
write
(
fs
,
pname
,
algo
->
get
<
Mat
>
(
pname
));
else
if
(
p
.
type
==
Param
::
MAT_VECTOR
)
cv
::
write
(
fs
,
pname
,
algo
->
get
<
vector
<
Mat
>
>
(
pname
));
else
if
(
p
.
type
==
Param
::
ALGORITHM
)
{
WriteStructContext
ws
(
fs
,
pname
,
CV_NODE_MAP
);
...
...
@@ -334,6 +346,12 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
cv
::
read
(
fn
,
m
);
algo
->
set
(
pname
,
m
);
}
else
if
(
p
.
type
==
Param
::
MAT_VECTOR
)
{
vector
<
Mat
>
mv
;
cv
::
read
(
fn
,
mv
);
algo
->
set
(
pname
,
mv
);
}
else
if
(
p
.
type
==
Param
::
ALGORITHM
)
{
Ptr
<
Algorithm
>
nestedAlgo
=
Algorithm
::
_create
((
string
)
n
[
"name"
]);
...
...
@@ -358,6 +376,7 @@ union GetSetParam
double
(
Algorithm
::*
get_double
)()
const
;
string
(
Algorithm
::*
get_string
)()
const
;
Mat
(
Algorithm
::*
get_mat
)()
const
;
vector
<
Mat
>
(
Algorithm
::*
get_mat_vector
)()
const
;
Ptr
<
Algorithm
>
(
Algorithm
::*
get_algo
)()
const
;
void
(
Algorithm
::*
set_int
)(
int
);
...
...
@@ -365,6 +384,7 @@ union GetSetParam
void
(
Algorithm
::*
set_double
)(
double
);
void
(
Algorithm
::*
set_string
)(
const
string
&
);
void
(
Algorithm
::*
set_mat
)(
const
Mat
&
);
void
(
Algorithm
::*
set_mat_vector
)(
const
vector
<
Mat
>&
);
void
(
Algorithm
::*
set_algo
)(
const
Ptr
<
Algorithm
>&
);
};
...
...
@@ -436,6 +456,16 @@ void AlgorithmInfo::set(Algorithm* algo, const char* name, int argType, const vo
else
*
(
Mat
*
)((
uchar
*
)
algo
+
p
->
offset
)
=
val
;
}
else
if
(
argType
==
Param
::
MAT_VECTOR
)
{
CV_Assert
(
p
->
type
==
Param
::
MAT_VECTOR
);
const
vector
<
Mat
>&
val
=
*
(
const
vector
<
Mat
>*
)
value
;
if
(
p
->
setter
)
(
algo
->*
f
.
set_mat_vector
)(
val
);
else
*
(
vector
<
Mat
>*
)((
uchar
*
)
algo
+
p
->
offset
)
=
val
;
}
else
if
(
argType
==
Param
::
ALGORITHM
)
{
CV_Assert
(
p
->
type
==
Param
::
ALGORITHM
);
...
...
@@ -505,6 +535,13 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* name, int argType, vo
*
(
Mat
*
)
value
=
p
->
getter
?
(
algo
->*
f
.
get_mat
)()
:
*
(
Mat
*
)((
uchar
*
)
algo
+
p
->
offset
);
}
else
if
(
argType
==
Param
::
MAT_VECTOR
)
{
CV_Assert
(
p
->
type
==
Param
::
MAT
);
*
(
vector
<
Mat
>*
)
value
=
p
->
getter
?
(
algo
->*
f
.
get_mat_vector
)()
:
*
(
vector
<
Mat
>*
)((
uchar
*
)
algo
+
p
->
offset
);
}
else
if
(
argType
==
Param
::
ALGORITHM
)
{
CV_Assert
(
p
->
type
==
Param
::
ALGORITHM
);
...
...
@@ -604,6 +641,16 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
addParam_
(
algo
,
name
,
ParamType
<
Mat
>::
type
,
&
value
,
readOnly
,
(
Algorithm
::
Getter
)
getter
,
(
Algorithm
::
Setter
)
setter
,
help
);
}
void
AlgorithmInfo
::
addParam
(
Algorithm
&
algo
,
const
char
*
name
,
vector
<
Mat
>&
value
,
bool
readOnly
,
vector
<
Mat
>
(
Algorithm
::*
getter
)(),
void
(
Algorithm
::*
setter
)(
const
vector
<
Mat
>&
),
const
string
&
help
)
{
addParam_
(
algo
,
name
,
ParamType
<
vector
<
Mat
>
>::
type
,
&
value
,
readOnly
,
(
Algorithm
::
Getter
)
getter
,
(
Algorithm
::
Setter
)
setter
,
help
);
}
void
AlgorithmInfo
::
addParam
(
Algorithm
&
algo
,
const
char
*
name
,
Ptr
<
Algorithm
>&
value
,
bool
readOnly
,
...
...
modules/core/src/persistence.cpp
View file @
ff071d2c
...
...
@@ -5358,7 +5358,13 @@ void write( FileStorage& fs, const string& name, const SparseMat& value )
Ptr
<
CvSparseMat
>
mat
=
(
CvSparseMat
*
)
value
;
cvWrite
(
*
fs
,
name
.
size
()
?
name
.
c_str
()
:
0
,
mat
);
}
void
write
(
FileStorage
&
fs
,
const
string
&
name
,
const
vector
<
Mat
>&
value
)
{
WriteStructContext
ws
(
fs
,
name
,
CV_NODE_SEQ
);
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
write
(
fs
,
string
(),
value
[
i
]);
}
WriteStructContext
::
WriteStructContext
(
FileStorage
&
_fs
,
const
string
&
name
,
int
flags
,
const
string
&
typeName
)
:
fs
(
&
_fs
)
...
...
@@ -5406,6 +5412,24 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat )
CV_Assert
(
CV_IS_SPARSE_MAT
(
m
));
SparseMat
(
m
).
copyTo
(
mat
);
}
void
read
(
const
FileNode
&
node
,
vector
<
Mat
>&
mat_vector
,
const
vector
<
Mat
>&
default_mat_vector
)
{
if
(
node
.
empty
()
)
{
mat_vector
=
default_mat_vector
;
return
;
}
FileNodeIterator
it
=
node
.
begin
(),
it_end
=
node
.
end
();
mat_vector
.
clear
();
for
(
;
it
!=
it_end
;
++
it
)
{
Mat
m
;
*
it
>>
m
;
mat_vector
.
push_back
(
m
);
}
}
}
...
...
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