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
7ee60401
Commit
7ee60401
authored
Oct 11, 2012
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable Matx as Mat elements (bug #1705).
parent
e435674a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
core.hpp
modules/core/include/opencv2/core/core.hpp
+12
-0
test_operations.cpp
modules/core/test/test_operations.cpp
+24
-0
No files found.
modules/core/include/opencv2/core/core.hpp
View file @
7ee60401
...
...
@@ -1107,6 +1107,18 @@ public:
type
=
CV_MAKETYPE
(
depth
,
channels
)
};
};
template
<
typename
_Tp
,
int
m
,
int
n
>
class
DataType
<
Matx
<
_Tp
,
m
,
n
>
>
{
public
:
typedef
Matx
<
_Tp
,
m
,
n
>
value_type
;
typedef
Matx
<
typename
DataType
<
_Tp
>::
work_type
,
m
,
n
>
work_type
;
typedef
_Tp
channel_type
;
typedef
value_type
vec_type
;
enum
{
generic_type
=
0
,
depth
=
DataDepth
<
channel_type
>::
value
,
channels
=
m
*
n
,
fmt
=
((
channels
-
1
)
<<
8
)
+
DataDepth
<
channel_type
>::
fmt
,
type
=
CV_MAKETYPE
(
depth
,
channels
)
};
};
template
<
typename
_Tp
,
int
cn
>
class
DataType
<
Vec
<
_Tp
,
cn
>
>
{
public
:
...
...
modules/core/test/test_operations.cpp
View file @
7ee60401
...
...
@@ -69,6 +69,7 @@ protected:
bool
SomeMatFunctions
();
bool
TestMat
();
template
<
typename
_Tp
>
void
TestType
(
Size
sz
,
_Tp
value
=
_Tp
(
1.
f
));
bool
TestTemplateMat
();
bool
TestMatND
();
bool
TestSparseMat
();
...
...
@@ -106,6 +107,19 @@ CV_OperationsTest::~CV_OperationsTest() {}
#define MSVC_OLD 0
#endif
template
<
typename
_Tp
>
void
CV_OperationsTest
::
TestType
(
Size
sz
,
_Tp
value
)
{
cv
::
Mat_
<
_Tp
>
m
(
sz
);
CV_Assert
(
m
.
cols
==
sz
.
width
&&
m
.
rows
==
sz
.
height
&&
m
.
depth
()
==
DataType
<
_Tp
>::
depth
&&
m
.
channels
()
==
DataType
<
_Tp
>::
channels
&&
m
.
elemSize
()
==
sizeof
(
_Tp
)
&&
m
.
step
==
m
.
elemSize
()
*
m
.
cols
);
for
(
int
y
=
0
;
y
<
sz
.
height
;
y
++
)
for
(
int
x
=
0
;
x
<
sz
.
width
;
x
++
)
m
(
y
,
x
)
=
value
;
CV_Assert
(
sum
(
m
.
reshape
(
1
,
1
))[
0
]
==
(
double
)
sz
.
width
*
sz
.
height
);
}
bool
CV_OperationsTest
::
TestMat
()
{
try
...
...
@@ -779,6 +793,16 @@ bool CV_OperationsTest::TestTemplateMat()
badarg_catched
=
true
;
}
CV_Assert
(
badarg_catched
);
#include <iostream>
#include <opencv2/core/core.hpp>
Size
size
(
2
,
5
);
TestType
<
float
>
(
size
);
TestType
<
cv
::
Vec3f
>
(
size
);
TestType
<
cv
::
Matx31f
>
(
size
);
TestType
<
cv
::
Matx41f
>
(
size
);
TestType
<
cv
::
Matx32f
>
(
size
);
}
catch
(
const
test_excep
&
e
)
{
...
...
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