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
caa33b22
Commit
caa33b22
authored
Oct 24, 2013
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added first very simple test for UMat<=>Mat conversion
parent
b1aa4a49
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
3 deletions
+136
-3
umatrix.cpp
modules/core/src/umatrix.cpp
+4
-3
test_umat.cpp
modules/core/test/test_umat.cpp
+132
-0
No files found.
modules/core/src/umatrix.cpp
View file @
caa33b22
...
...
@@ -602,13 +602,14 @@ void UMat::copyTo(OutputArray _dst) const
return
;
}
size_t
i
,
sz
[
CV_MAX_DIM
],
srcofs
[
CV_MAX_DIM
],
dstofs
[
CV_MAX_DIM
];
size_t
i
,
sz
[
CV_MAX_DIM
],
srcofs
[
CV_MAX_DIM
],
dstofs
[
CV_MAX_DIM
]
,
esz
=
elemSize
()
;
for
(
i
=
0
;
i
<
(
size_t
)
dims
;
i
++
)
sz
[
i
]
=
size
.
p
[
i
];
sz
[
dims
-
1
]
*=
e
lemSize
()
;
sz
[
dims
-
1
]
*=
e
sz
;
ndoffset
(
srcofs
);
srcofs
[
dims
-
1
]
*=
esz
;
_dst
.
create
(
dims
,
size
,
type
()
);
_dst
.
create
(
dims
,
size
.
p
,
type
()
);
if
(
_dst
.
kind
()
==
_InputArray
::
UMAT
)
{
UMat
dst
=
_dst
.
getUMat
();
...
...
modules/core/test/test_umat.cpp
0 → 100644
View file @
caa33b22
/*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) 2013, OpenCV Foundation, 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 OpenCV Foundation 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 "test_precomp.hpp"
#include <string>
#include <iostream>
#include <fstream>
#include <iterator>
#include <limits>
#include <numeric>
using
namespace
cv
;
using
namespace
std
;
class
CV_UMatTest
:
public
cvtest
::
BaseTest
{
public
:
CV_UMatTest
()
{}
~
CV_UMatTest
()
{}
protected
:
void
run
(
int
);
struct
test_excep
{
test_excep
(
const
string
&
_s
=
string
(
""
))
:
s
(
_s
)
{};
string
s
;
};
bool
TestUMat
();
void
checkDiff
(
const
Mat
&
m1
,
const
Mat
&
m2
,
const
string
&
s
)
{
if
(
norm
(
m1
,
m2
,
NORM_INF
)
!=
0
)
throw
test_excep
(
s
);
}
void
checkDiffF
(
const
Mat
&
m1
,
const
Mat
&
m2
,
const
string
&
s
)
{
if
(
norm
(
m1
,
m2
,
NORM_INF
)
>
1e-5
)
throw
test_excep
(
s
);
}
};
#define STR(a) STR2(a)
#define STR2(a) #a
#define CHECK_DIFF(a, b) checkDiff(a, b, "(" #a ") != (" #b ") at l." STR(__LINE__))
#define CHECK_DIFF_FLT(a, b) checkDiffF(a, b, "(" #a ") !=(eps) (" #b ") at l." STR(__LINE__))
bool
CV_UMatTest
::
TestUMat
()
{
try
{
Mat
a
(
100
,
100
,
CV_16S
),
b
;
randu
(
a
,
Scalar
::
all
(
-
100
),
Scalar
::
all
(
100
));
Rect
roi
(
1
,
3
,
10
,
20
);
Mat
ra
(
a
,
roi
),
rb
;
UMat
ua
,
ura
;
a
.
copyTo
(
ua
);
ua
.
copyTo
(
b
);
CHECK_DIFF
(
a
,
b
);
ura
=
ua
(
roi
);
ura
.
copyTo
(
rb
);
CHECK_DIFF
(
ra
,
rb
);
ra
+=
Scalar
::
all
(
1.
f
);
{
Mat
temp
=
ura
.
getMat
(
ACCESS_RW
);
temp
+=
Scalar
::
all
(
1.
f
);
}
ra
.
copyTo
(
rb
);
CHECK_DIFF
(
ra
,
rb
);
}
catch
(
const
test_excep
&
e
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"%s
\n
"
,
e
.
s
.
c_str
());
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISMATCH
);
return
false
;
}
return
true
;
}
void
CV_UMatTest
::
run
(
int
/* start_from */
)
{
if
(
!
TestUMat
())
return
;
ts
->
set_failed_test_info
(
cvtest
::
TS
::
OK
);
}
TEST
(
Core_UMat
,
base
)
{
CV_UMatTest
test
;
test
.
safe_run
();
}
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