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
70a2c8f5
Commit
70a2c8f5
authored
Jul 29, 2010
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added conversion operators Mat->vector<T>, Mat->Vec<T,n>, Mat->Matx<T,m,n>
parent
8f33e89d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
5 deletions
+56
-5
core.hpp
modules/core/include/opencv2/core/core.hpp
+8
-0
mat.hpp
modules/core/include/opencv2/core/mat.hpp
+48
-5
No files found.
modules/core/include/opencv2/core/core.hpp
View file @
70a2c8f5
...
@@ -1599,6 +1599,10 @@ public:
...
@@ -1599,6 +1599,10 @@ public:
//! converts header to IplImage; no data is copied
//! converts header to IplImage; no data is copied
operator
IplImage
()
const
;
operator
IplImage
()
const
;
template
<
typename
_Tp
>
operator
vector
<
_Tp
>
()
const
;
template
<
typename
_Tp
,
int
n
>
operator
Vec
<
_Tp
,
n
>
()
const
;
template
<
typename
_Tp
,
int
m
,
int
n
>
operator
Matx
<
_Tp
,
m
,
n
>
()
const
;
//! returns true iff the matrix data is continuous
//! returns true iff the matrix data is continuous
// (i.e. when there are no gaps between successive rows).
// (i.e. when there are no gaps between successive rows).
// similar to CV_IS_MAT_CONT(cvmat->type)
// similar to CV_IS_MAT_CONT(cvmat->type)
...
@@ -2372,6 +2376,10 @@ public:
...
@@ -2372,6 +2376,10 @@ public:
//! conversion to vector.
//! conversion to vector.
operator
vector
<
_Tp
>
()
const
;
operator
vector
<
_Tp
>
()
const
;
//! conversion to Vec
template
<
int
n
>
operator
Vec
<
_Tp
,
n
>
()
const
;
//! conversion to Matx
template
<
int
m
,
int
n
>
operator
Matx
<
_Tp
,
m
,
n
>
()
const
;
};
};
typedef
Mat_
<
uchar
>
Mat1b
;
typedef
Mat_
<
uchar
>
Mat1b
;
...
...
modules/core/include/opencv2/core/mat.hpp
View file @
70a2c8f5
...
@@ -595,7 +595,6 @@ template<typename _Tp> inline MatIterator_<_Tp> Mat::end()
...
@@ -595,7 +595,6 @@ template<typename _Tp> inline MatIterator_<_Tp> Mat::end()
return
it
;
return
it
;
}
}
static
inline
void
swap
(
Mat
&
a
,
Mat
&
b
)
static
inline
void
swap
(
Mat
&
a
,
Mat
&
b
)
{
{
std
::
swap
(
a
.
flags
,
b
.
flags
);
std
::
swap
(
a
.
flags
,
b
.
flags
);
...
@@ -606,6 +605,42 @@ static inline void swap( Mat& a, Mat& b )
...
@@ -606,6 +605,42 @@ static inline void swap( Mat& a, Mat& b )
std
::
swap
(
a
.
refcount
,
b
.
refcount
);
std
::
swap
(
a
.
refcount
,
b
.
refcount
);
}
}
template
<
typename
_Tp
>
inline
Mat
::
operator
vector
<
_Tp
>
()
const
{
CV_Assert
(
(
rows
==
1
||
cols
==
1
)
&&
channels
()
==
DataType
<
_Tp
>::
channels
);
int
n
=
rows
+
cols
-
1
;
if
(
isContinuous
()
&&
type
()
==
DataType
<
_Tp
>::
type
)
return
vector
<
_Tp
>
((
_Tp
*
)
data
,(
_Tp
*
)
data
+
n
);
vector
<
_Tp
>
v
(
n
);
Mat
tmp
(
rows
,
cols
,
DataType
<
_Tp
>::
type
,
&
v
[
0
]);
convertTo
(
tmp
,
tmp
.
type
());
return
v
;
}
template
<
typename
_Tp
,
int
n
>
inline
Mat
::
operator
Vec
<
_Tp
,
n
>
()
const
{
CV_Assert
(
(
rows
==
1
||
cols
==
1
)
&&
rows
+
cols
-
1
==
n
&&
channels
()
==
DataType
<
_Tp
>::
channels
);
if
(
isContinuous
()
&&
type
()
==
DataType
<
_Tp
>::
type
)
return
Vec
<
_Tp
,
n
>
((
_Tp
*
)
data
);
Vec
<
_Tp
,
n
>
v
;
Mat
tmp
(
rows
,
cols
,
DataType
<
_Tp
>::
type
,
v
.
val
);
convertTo
(
tmp
,
tmp
.
type
());
return
v
;
}
template
<
typename
_Tp
,
int
m
,
int
n
>
inline
Mat
::
operator
Matx
<
_Tp
,
m
,
n
>
()
const
{
CV_Assert
(
rows
==
m
&&
cols
==
n
&&
channels
()
==
DataType
<
_Tp
>::
channels
);
if
(
isContinuous
()
&&
type
()
==
DataType
<
_Tp
>::
type
)
return
Matx
<
_Tp
,
m
,
n
>
((
_Tp
*
)
data
);
Matx
<
_Tp
,
m
,
n
>
mtx
;
Mat
tmp
(
rows
,
cols
,
DataType
<
_Tp
>::
type
,
mtx
.
val
);
convertTo
(
tmp
,
tmp
.
type
());
return
mtx
;
}
inline
SVD
::
SVD
()
{}
inline
SVD
::
SVD
()
{}
inline
SVD
::
SVD
(
const
Mat
&
m
,
int
flags
)
{
operator
()(
m
,
flags
);
}
inline
SVD
::
SVD
(
const
Mat
&
m
,
int
flags
)
{
operator
()(
m
,
flags
);
}
inline
void
SVD
::
solveZ
(
const
Mat
&
m
,
Mat
&
dst
)
inline
void
SVD
::
solveZ
(
const
Mat
&
m
,
Mat
&
dst
)
...
@@ -829,12 +864,20 @@ template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(Point pt) const
...
@@ -829,12 +864,20 @@ template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(Point pt) const
template
<
typename
_Tp
>
inline
Mat_
<
_Tp
>::
operator
vector
<
_Tp
>
()
const
template
<
typename
_Tp
>
inline
Mat_
<
_Tp
>::
operator
vector
<
_Tp
>
()
const
{
{
CV_Assert
(
rows
==
1
||
cols
==
1
);
return
this
->
Mat
::
operator
vector
<
_Tp
>
();
return
isContinuous
()
?
}
vector
<
_Tp
>
((
_Tp
*
)
data
,(
_Tp
*
)
data
+
(
rows
+
cols
-
1
))
:
(
vector
<
_Tp
>
)((
Mat_
<
_Tp
>
)
this
->
t
());
template
<
typename
_Tp
>
template
<
int
n
>
inline
Mat_
<
_Tp
>::
operator
Vec
<
_Tp
,
n
>
()
const
{
return
this
->
Mat
::
operator
Vec
<
_Tp
,
n
>
();
}
}
template
<
typename
_Tp
>
template
<
int
m
,
int
n
>
inline
Mat_
<
_Tp
>::
operator
Matx
<
_Tp
,
m
,
n
>
()
const
{
return
this
->
Mat
::
operator
Matx
<
_Tp
,
m
,
n
>
();
}
template
<
typename
T1
,
typename
T2
,
typename
Op
>
inline
void
template
<
typename
T1
,
typename
T2
,
typename
Op
>
inline
void
process
(
const
Mat_
<
T1
>&
m1
,
Mat_
<
T2
>&
m2
,
Op
op
)
process
(
const
Mat_
<
T1
>&
m1
,
Mat_
<
T2
>&
m2
,
Op
op
)
{
{
...
...
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