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
3f5dd5f1
Commit
3f5dd5f1
authored
Jul 22, 2010
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added implementation GpuMat::convertTo and merged this with matrix_operations.cpp
parent
7bf29e14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
2 deletions
+117
-2
cuda_shared.hpp
modules/gpu/src/cuda/cuda_shared.hpp
+3
-0
matrix_operations.cu
modules/gpu/src/cuda/matrix_operations.cu
+0
-0
matrix_operations.cpp
modules/gpu/src/matrix_operations.cpp
+24
-2
precomp.hpp
modules/gpu/src/precomp.hpp
+1
-0
convert_to.cpp
tests/gpu/src/convert_to.cpp
+89
-0
No files found.
modules/gpu/src/cuda/cuda_shared.hpp
View file @
3f5dd5f1
...
...
@@ -51,6 +51,7 @@ namespace cv
namespace
gpu
{
typedef
unsigned
char
uchar
;
typedef
signed
char
schar
;
typedef
unsigned
short
ushort
;
typedef
unsigned
int
uint
;
...
...
@@ -62,6 +63,8 @@ namespace cv
extern
"C"
void
set_to_without_mask
(
const
DevMem2D
&
mat
,
const
double
*
scalar
,
int
depth
,
int
channels
);
extern
"C"
void
set_to_with_mask
(
const
DevMem2D
&
mat
,
const
double
*
scalar
,
const
DevMem2D
&
mask
,
int
depth
,
int
channels
);
extern
"C"
void
convert_to
(
const
DevMem2D
&
src
,
int
sdepth
,
DevMem2D
dst
,
int
ddepth
,
size_t
width
,
size_t
height
,
double
alpha
,
double
beta
);
}
}
}
...
...
modules/gpu/src/cuda/matrix_operations.cu
View file @
3f5dd5f1
This diff is collapsed.
Click to expand it.
modules/gpu/src/matrix_operations.cpp
View file @
3f5dd5f1
...
...
@@ -104,9 +104,31 @@ void cv::gpu::GpuMat::copyTo( GpuMat& /*m*/, const GpuMat&/* mask */) const
CV_Assert
(
!
"Not implemented"
);
}
void
cv
::
gpu
::
GpuMat
::
convertTo
(
GpuMat
&
/*m*/
,
int
/*rtype*/
,
double
/*alpha*/
,
double
/*beta*/
)
const
void
cv
::
gpu
::
GpuMat
::
convertTo
(
GpuMat
&
dst
,
int
rtype
,
double
alpha
,
double
beta
)
const
{
CV_Assert
(
!
"Not implemented"
);
//CV_Assert(!"Not implemented");
bool
noScale
=
fabs
(
alpha
-
1
)
<
std
::
numeric_limits
<
double
>::
epsilon
()
&&
fabs
(
beta
)
<
std
::
numeric_limits
<
double
>::
epsilon
();
if
(
rtype
<
0
)
rtype
=
type
();
else
rtype
=
CV_MAKETYPE
(
CV_MAT_DEPTH
(
rtype
),
channels
());
int
sdepth
=
depth
(),
ddepth
=
CV_MAT_DEPTH
(
rtype
);
/*if( sdepth == ddepth && noScale )
{
copyTo(dst);
return;
}*/
GpuMat
temp
;
const
GpuMat
*
psrc
=
this
;
if
(
sdepth
!=
ddepth
&&
psrc
==
&
dst
)
psrc
=
&
(
temp
=
*
this
);
dst
.
create
(
size
(),
rtype
);
impl
::
convert_to
(
*
psrc
,
sdepth
,
dst
,
ddepth
,
psrc
->
cols
*
psrc
->
channels
(),
psrc
->
rows
,
alpha
,
beta
);
}
GpuMat
&
GpuMat
::
operator
=
(
const
Scalar
&
s
)
...
...
modules/gpu/src/precomp.hpp
View file @
3f5dd5f1
...
...
@@ -51,6 +51,7 @@
#endif
#include <iostream>
#include <limits>
#include "opencv2/gpu/gpu.hpp"
...
...
tests/gpu/src/convert_to.cpp
0 → 100644
View file @
3f5dd5f1
#include "gputest.hpp"
#include <string>
#include <iostream>
#include <fstream>
#include <iterator>
#include <limits>
#include <numeric>
using
namespace
cv
;
using
namespace
std
;
using
namespace
gpu
;
class
CV_GpuMatOpConvertTo
:
public
CvTest
{
public
:
CV_GpuMatOpConvertTo
();
~
CV_GpuMatOpConvertTo
();
protected
:
void
run
(
int
);
};
CV_GpuMatOpConvertTo
::
CV_GpuMatOpConvertTo
()
:
CvTest
(
"GpuMatOperatorConvertTo"
,
"convertTo"
)
{}
CV_GpuMatOpConvertTo
::~
CV_GpuMatOpConvertTo
()
{}
void
CV_GpuMatOpConvertTo
::
run
(
int
/* start_from */
)
{
const
Size
img_size
(
67
,
35
);
const
int
types
[]
=
{
CV_8U
,
CV_8S
,
CV_16U
,
CV_16S
,
CV_32S
,
CV_32F
,
CV_64F
/**/
};
const
int
types_num
=
sizeof
(
types
)
/
sizeof
(
int
);
const
char
*
types_str
[]
=
{
"CV_8U"
,
"CV_8S"
,
"CV_16U"
,
"CV_16S"
,
"CV_32S"
,
"CV_32F"
,
"CV_64F"
};
bool
passed
=
true
;
for
(
int
i
=
0
;
i
<
types_num
&&
passed
;
++
i
)
{
for
(
int
j
=
0
;
j
<
types_num
&&
passed
;
++
j
)
{
for
(
int
c
=
1
;
c
<
2
&&
passed
;
++
c
)
{
//if (i == j)
// continue;
const
int
src_type
=
CV_MAKETYPE
(
types
[
i
],
c
);
const
int
dst_type
=
types
[
j
];
const
double
alpha
=
(
double
)
rand
()
/
RAND_MAX
*
10.0
;
const
double
beta
=
(
double
)
rand
()
/
RAND_MAX
*
10.0
;
Mat
cpumatsrc
(
img_size
,
src_type
);
randu
(
cpumatsrc
,
Scalar
::
all
(
0
),
Scalar
::
all
(
10
));
GpuMat
gpumatsrc
(
cpumatsrc
);
Mat
cpumatdst
;
GpuMat
gpumatdst
;
//double cput = (double)getTickCount();
cpumatsrc
.
convertTo
(
cpumatdst
,
dst_type
,
alpha
,
beta
);
//cput = ((double)getTickCount() - cput) / getTickFrequency();
//double gput = (double)getTickCount();
gpumatsrc
.
convertTo
(
gpumatdst
,
dst_type
,
alpha
,
beta
);
//gput = ((double)getTickCount() - gput) / getTickFrequency();
/*cout << "convertTo time: " << endl;
cout << "CPU time: " << cput << endl;
cout << "GPU time: " << gput << endl;/**/
double
r
=
norm
(
cpumatdst
,
gpumatdst
,
NORM_L1
);
if
(
r
>
1
)
{
/*namedWindow("CPU");
imshow("CPU", cpumatdst);
namedWindow("GPU");
imshow("GPU", gpumatdst);
waitKey();/**/
cout
<<
"Failed:"
<<
endl
;
cout
<<
"
\t
r = "
<<
r
<<
endl
;
cout
<<
"
\t
SRC_TYPE="
<<
types_str
[
i
]
<<
"C"
<<
c
<<
" DST_TYPE="
<<
types_str
[
j
]
<<
endl
;
/**/
passed
=
false
;
}
}
}
}
ts
->
set_failed_test_info
(
passed
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
);
}
CV_GpuMatOpConvertTo
CV_GpuMatOpConvertTo_test
;
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