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
26c48596
Commit
26c48596
authored
Jul 22, 2010
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduced code convert_to by using templates, merged with copyTo
parent
a0b1107b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
28 deletions
+27
-28
matrix_operations.cu
modules/gpu/src/cuda/matrix_operations.cu
+0
-0
matrix_operations.cpp
modules/gpu/src/matrix_operations.cpp
+2
-4
convert_to.cpp
tests/gpu/src/convert_to.cpp
+25
-24
No files found.
modules/gpu/src/cuda/matrix_operations.cu
View file @
26c48596
This diff is collapsed.
Click to expand it.
modules/gpu/src/matrix_operations.cpp
View file @
26c48596
...
...
@@ -114,8 +114,6 @@ void cv::gpu::GpuMat::copyTo( GpuMat& mat, const GpuMat& mask ) const
void
cv
::
gpu
::
GpuMat
::
convertTo
(
GpuMat
&
dst
,
int
rtype
,
double
alpha
,
double
beta
)
const
{
//CV_Assert(!"Not implemented");
bool
noScale
=
fabs
(
alpha
-
1
)
<
std
::
numeric_limits
<
double
>::
epsilon
()
&&
fabs
(
beta
)
<
std
::
numeric_limits
<
double
>::
epsilon
();
if
(
rtype
<
0
)
...
...
@@ -124,11 +122,11 @@ void cv::gpu::GpuMat::convertTo( GpuMat& dst, int rtype, double alpha, double be
rtype
=
CV_MAKETYPE
(
CV_MAT_DEPTH
(
rtype
),
channels
());
int
sdepth
=
depth
(),
ddepth
=
CV_MAT_DEPTH
(
rtype
);
/*
if( sdepth == ddepth && noScale )
if
(
sdepth
==
ddepth
&&
noScale
)
{
copyTo
(
dst
);
return
;
}
*/
}
GpuMat
temp
;
const
GpuMat
*
psrc
=
this
;
...
...
tests/gpu/src/convert_to.cpp
View file @
26c48596
...
...
@@ -26,7 +26,7 @@ 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
[]
=
{
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"
};
...
...
@@ -39,9 +39,6 @@ void CV_GpuMatOpConvertTo::run( int /* start_from */)
{
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
;
...
...
@@ -53,30 +50,34 @@ void CV_GpuMatOpConvertTo::run( int /* start_from */)
Mat
cpumatdst
;
GpuMat
gpumatdst
;
//double cput = (double)getTickCount();
cpumatsrc
.
convertTo
(
cpumatdst
,
dst_type
,
alpha
,
beta
);
//cput = ((double)getTickCount() - cput) / getTickFrequency();
//TickMeter tm;
//tm.start();
//for(int i = 0; i < 50; ++i)
cpumatsrc
.
convertTo
(
cpumatdst
,
dst_type
,
alpha
,
beta
);
//tm.stop();
//cout << "SRC_TYPE=" << types_str[i] << "C" << c << " DST_TYPE=" << types_str[j] << endl << "\tCPU FPS = " << 50.0/tm.getTimeSec() << endl;
//double gput = (double)getTickCount();
gpumatsrc
.
convertTo
(
gpumatdst
,
dst_type
,
alpha
,
beta
);
//gput = ((double)getTickCount() - gput) / getTickFrequency();
//tm.reset();
/*cout << "convertTo time: " << endl;
cout << "CPU time: " << cput << endl;
cout << "GPU time: " << gput << endl;/**/
try
{
//tm.start();
//for(int i = 0; i < 50; ++i)
gpumatsrc
.
convertTo
(
gpumatdst
,
dst_type
,
alpha
,
beta
);
//tm.stop();
//cout << "\tGPU FPS = " << 50.0/tm.getTimeSec() << endl;
}
catch
(
cv
::
Exception
&
e
)
{
cout
<<
"ERROR: "
<<
e
.
err
<<
endl
;
passed
=
false
;
break
;
}
double
r
=
norm
(
cpumatdst
,
gpumatdst
,
NORM_
L1
);
double
r
=
norm
(
cpumatdst
,
gpumatdst
,
NORM_
INF
);
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
;
/**/
{
cout
<<
"FAILED: "
<<
"SRC_TYPE="
<<
types_str
[
i
]
<<
"C"
<<
c
<<
" DST_TYPE="
<<
types_str
[
j
]
<<
" NORM = "
<<
r
<<
endl
;
passed
=
false
;
}
...
...
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