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
a9b7ff41
Commit
a9b7ff41
authored
May 29, 2013
by
yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust test cases
parent
14bd6402
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
116 additions
and
247 deletions
+116
-247
perf_brute_force_matcher.cpp
modules/ocl/perf/perf_brute_force_matcher.cpp
+1
-1
perf_opticalflow.cpp
modules/ocl/perf/perf_opticalflow.cpp
+71
-0
perf_pyramid.cpp
modules/ocl/perf/perf_pyramid.cpp
+44
-0
perf_pyrup.cpp
modules/ocl/perf/perf_pyrup.cpp
+0
-90
precomp.cpp
modules/ocl/perf/precomp.cpp
+0
-156
No files found.
modules/ocl/perf/perf_brute_force_matcher.cpp
View file @
a9b7ff41
...
...
@@ -95,7 +95,7 @@ PERFTEST(BruteForceMatcher)
GPU_FULL_ON
;
d_query
.
upload
(
query
);
d_train
.
upload
(
train
);
d_matcher
.
match
(
d_query
,
d_train
,
matches
[
0
]);
d_matcher
.
match
(
d_query
,
d_train
,
d_
matches
[
0
]);
GPU_FULL_OFF
;
int
diff
=
abs
((
int
)
d_matches
[
0
].
size
()
-
(
int
)
matches
[
0
].
size
());
...
...
modules/ocl/perf/perf_
pyrlk
.cpp
→
modules/ocl/perf/perf_
opticalflow
.cpp
View file @
a9b7ff41
...
...
@@ -156,3 +156,73 @@ PERFTEST(PyrLKOpticalFlow)
}
}
PERFTEST
(
tvl1flow
)
{
cv
::
Mat
frame0
=
imread
(
"rubberwhale1.png"
,
cv
::
IMREAD_GRAYSCALE
);
assert
(
!
frame0
.
empty
());
cv
::
Mat
frame1
=
imread
(
"rubberwhale2.png"
,
cv
::
IMREAD_GRAYSCALE
);
assert
(
!
frame1
.
empty
());
cv
::
ocl
::
OpticalFlowDual_TVL1_OCL
d_alg
;
cv
::
ocl
::
oclMat
d_flowx
(
frame0
.
size
(),
CV_32FC1
);
cv
::
ocl
::
oclMat
d_flowy
(
frame1
.
size
(),
CV_32FC1
);
cv
::
Ptr
<
cv
::
DenseOpticalFlow
>
alg
=
cv
::
createOptFlow_DualTVL1
();
cv
::
Mat
flow
;
SUBTEST
<<
frame0
.
cols
<<
'x'
<<
frame0
.
rows
<<
"; rubberwhale1.png; "
<<
frame1
.
cols
<<
'x'
<<
frame1
.
rows
<<
"; rubberwhale2.png"
;
alg
->
calc
(
frame0
,
frame1
,
flow
);
CPU_ON
;
alg
->
calc
(
frame0
,
frame1
,
flow
);
CPU_OFF
;
cv
::
Mat
gold
[
2
];
cv
::
split
(
flow
,
gold
);
cv
::
ocl
::
oclMat
d0
(
frame0
.
size
(),
CV_32FC1
);
d0
.
upload
(
frame0
);
cv
::
ocl
::
oclMat
d1
(
frame1
.
size
(),
CV_32FC1
);
d1
.
upload
(
frame1
);
WARMUP_ON
;
d_alg
(
d0
,
d1
,
d_flowx
,
d_flowy
);
WARMUP_OFF
;
/*
double diff1 = 0.0, diff2 = 0.0;
if(ExceptedMatSimilar(gold[0], cv::Mat(d_flowx), 3e-3, diff1) == 1
&&ExceptedMatSimilar(gold[1], cv::Mat(d_flowy), 3e-3, diff2) == 1)
TestSystem::instance().setAccurate(1);
else
TestSystem::instance().setAccurate(0);
TestSystem::instance().setDiff(diff1);
TestSystem::instance().setDiff(diff2);
*/
GPU_ON
;
d_alg
(
d0
,
d1
,
d_flowx
,
d_flowy
);
d_alg
.
collectGarbage
();
GPU_OFF
;
cv
::
Mat
flowx
,
flowy
;
GPU_FULL_ON
;
d0
.
upload
(
frame0
);
d1
.
upload
(
frame1
);
d_alg
(
d0
,
d1
,
d_flowx
,
d_flowy
);
d_alg
.
collectGarbage
();
d_flowx
.
download
(
flowx
);
d_flowy
.
download
(
flowy
);
GPU_FULL_OFF
;
TestSystem
::
instance
().
ExceptedMatSimilar
(
gold
[
0
],
flowx
,
3e-3
);
TestSystem
::
instance
().
ExceptedMatSimilar
(
gold
[
1
],
flowy
,
3e-3
);
}
\ No newline at end of file
modules/ocl/perf/perf_pyr
down
.cpp
→
modules/ocl/perf/perf_pyr
amid
.cpp
View file @
a9b7ff41
...
...
@@ -86,4 +86,47 @@ PERFTEST(pyrDown)
TestSystem
::
instance
().
ExpectedMatNear
(
dst
,
ocl_dst
,
dst
.
depth
()
==
CV_32F
?
1e-4
f
:
1.0
f
);
}
}
}
///////////// pyrUp ////////////////////////
PERFTEST
(
pyrUp
)
{
Mat
src
,
dst
,
ocl_dst
;
int
all_type
[]
=
{
CV_8UC1
,
CV_8UC4
};
std
::
string
type_name
[]
=
{
"CV_8UC1"
,
"CV_8UC4"
};
for
(
int
size
=
500
;
size
<=
2000
;
size
*=
2
)
{
for
(
size_t
j
=
0
;
j
<
sizeof
(
all_type
)
/
sizeof
(
int
);
j
++
)
{
SUBTEST
<<
size
<<
'x'
<<
size
<<
"; "
<<
type_name
[
j
]
;
gen
(
src
,
size
,
size
,
all_type
[
j
],
0
,
256
);
pyrUp
(
src
,
dst
);
CPU_ON
;
pyrUp
(
src
,
dst
);
CPU_OFF
;
ocl
::
oclMat
d_src
(
src
);
ocl
::
oclMat
d_dst
;
WARMUP_ON
;
ocl
::
pyrUp
(
d_src
,
d_dst
);
WARMUP_OFF
;
GPU_ON
;
ocl
::
pyrUp
(
d_src
,
d_dst
);
GPU_OFF
;
GPU_FULL_ON
;
d_src
.
upload
(
src
);
ocl
::
pyrUp
(
d_src
,
d_dst
);
d_dst
.
download
(
ocl_dst
);
GPU_FULL_OFF
;
TestSystem
::
instance
().
ExpectedMatNear
(
dst
,
ocl_dst
,
(
src
.
depth
()
==
CV_32F
?
1e-4
f
:
1.0
));
}
}
}
\ No newline at end of file
modules/ocl/perf/perf_pyrup.cpp
deleted
100644 → 0
View file @
14bd6402
/*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) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
//
// 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 oclMaterials 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 Intel Corporation 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 "precomp.hpp"
///////////// pyrUp ////////////////////////
PERFTEST
(
pyrUp
)
{
Mat
src
,
dst
,
ocl_dst
;
int
all_type
[]
=
{
CV_8UC1
,
CV_8UC4
};
std
::
string
type_name
[]
=
{
"CV_8UC1"
,
"CV_8UC4"
};
for
(
int
size
=
500
;
size
<=
2000
;
size
*=
2
)
{
for
(
size_t
j
=
0
;
j
<
sizeof
(
all_type
)
/
sizeof
(
int
);
j
++
)
{
SUBTEST
<<
size
<<
'x'
<<
size
<<
"; "
<<
type_name
[
j
]
;
gen
(
src
,
size
,
size
,
all_type
[
j
],
0
,
256
);
pyrUp
(
src
,
dst
);
CPU_ON
;
pyrUp
(
src
,
dst
);
CPU_OFF
;
ocl
::
oclMat
d_src
(
src
);
ocl
::
oclMat
d_dst
;
WARMUP_ON
;
ocl
::
pyrUp
(
d_src
,
d_dst
);
WARMUP_OFF
;
GPU_ON
;
ocl
::
pyrUp
(
d_src
,
d_dst
);
GPU_OFF
;
GPU_FULL_ON
;
d_src
.
upload
(
src
);
ocl
::
pyrUp
(
d_src
,
d_dst
);
d_dst
.
download
(
ocl_dst
);
GPU_FULL_OFF
;
TestSystem
::
instance
().
ExpectedMatNear
(
dst
,
ocl_dst
,
(
src
.
depth
()
==
CV_32F
?
1e-4
f
:
1.0
));
}
}
}
\ No newline at end of file
modules/ocl/perf/precomp.cpp
View file @
a9b7ff41
...
...
@@ -471,134 +471,6 @@ void gen(Mat &mat, int rows, int cols, int type, Scalar low, Scalar high)
RNG
rng
(
0
);
rng
.
fill
(
mat
,
RNG
::
UNIFORM
,
low
,
high
);
}
#if 0
void gen(Mat &mat, int rows, int cols, int type, int low, int high, int n)
{
assert(n > 0&&n <= cols * rows);
assert(type == CV_8UC1||type == CV_8UC3||type == CV_8UC4
||type == CV_32FC1||type == CV_32FC3||type == CV_32FC4);
RNG rng;
//generate random position without duplication
std::vector<int> pos;
for(int i = 0; i < cols * rows; i++)
{
pos.push_back(i);
}
for(int i = 0; i < cols * rows; i++)
{
int temp = i + rng.uniform(0, cols * rows - 1 - i);
int temp1 = pos[temp];
pos[temp]= pos[i];
pos[i] = temp1;
}
std::vector<int> selected_pos;
for(int i = 0; i < n; i++)
{
selected_pos.push_back(pos[i]);
}
pos.clear();
//end of generating random y without duplication
if(type == CV_8UC1)
{
typedef struct coorStruct_
{
int x;
int y;
uchar xy;
}coorStruct;
coorStruct coor_struct;
std::vector<coorStruct> coor;
for(int i = 0; i < n; i++)
{
coor_struct.x = -1;
coor_struct.y = -1;
coor_struct.xy = (uchar)rng.uniform(low, high);
coor.push_back(coor_struct);
}
for(int i = 0; i < n; i++)
{
coor[i].y = selected_pos[i]/cols;
coor[i].x = selected_pos[i]%cols;
}
selected_pos.clear();
mat.create(rows, cols, type);
mat.setTo(0);
for(int i = 0; i < n; i++)
{
mat.at<unsigned char>(coor[i].y, coor[i].x) = coor[i].xy;
}
}
if(type == CV_8UC4 || type == CV_8UC3)
{
mat.create(rows, cols, type);
mat.setTo(0);
typedef struct Coor
{
int x;
int y;
uchar r;
uchar g;
uchar b;
uchar alpha;
}coor;
std::vector<coor> coor_vect;
coor xy_coor;
for(int i = 0; i < n; i++)
{
xy_coor.r = (uchar)rng.uniform(low, high);
xy_coor.g = (uchar)rng.uniform(low, high);
xy_coor.b = (uchar)rng.uniform(low, high);
if(type == CV_8UC4)
xy_coor.alpha = (uchar)rng.uniform(low, high);
coor_vect.push_back(xy_coor);
}
for(int i = 0; i < n; i++)
{
coor_vect[i].y = selected_pos[i]/((int)mat.step1()/mat.elemSize());
coor_vect[i].x = selected_pos[i]%((int)mat.step1()/mat.elemSize());
//printf("coor_vect[%d] = (%d, %d)\n", i, coor_vect[i].y, coor_vect[i].x);
}
if(type == CV_8UC4)
{
for(int i = 0; i < n; i++)
{
mat.at<unsigned char>(coor_vect[i].y, 4 * coor_vect[i].x) = coor_vect[i].r;
mat.at<unsigned char>(coor_vect[i].y, 4 * coor_vect[i].x + 1) = coor_vect[i].g;
mat.at<unsigned char>(coor_vect[i].y, 4 * coor_vect[i].x + 2) = coor_vect[i].b;
mat.at<unsigned char>(coor_vect[i].y, 4 * coor_vect[i].x + 3) = coor_vect[i].alpha;
}
}else if(type == CV_8UC3)
{
for(int i = 0; i < n; i++)
{
mat.at<unsigned char>(coor_vect[i].y, 3 * coor_vect[i].x) = coor_vect[i].r;
mat.at<unsigned char>(coor_vect[i].y, 3 * coor_vect[i].x + 1) = coor_vect[i].g;
mat.at<unsigned char>(coor_vect[i].y, 3 * coor_vect[i].x + 2) = coor_vect[i].b;
}
}
}
}
#endif
string
abspath
(
const
string
&
relpath
)
{
...
...
@@ -631,34 +503,6 @@ double checkSimilarity(const Mat &m1, const Mat &m2)
return
std
::
abs
(
diff
.
at
<
float
>
(
0
,
0
)
-
1.
f
);
}
/*
int ExpectedMatNear(cv::Mat dst, cv::Mat cpu_dst, double eps)
{
assert(dst.type() == cpu_dst.type());
assert(dst.size() == cpu_dst.size());
if(checkNorm(cv::Mat(dst), cv::Mat(cpu_dst)) < eps ||checkNorm(cv::Mat(dst), cv::Mat(cpu_dst)) == eps)
return 1;
return 0;
}
int ExceptDoubleNear(double val1, double val2, double abs_error)
{
const double diff = fabs(val1 - val2);
if (diff <= abs_error)
return 1;
return 0;
}
/*
int ExceptedMatSimilar(cv::Mat dst, cv::Mat cpu_dst, double eps)
{
assert(dst.type() == cpu_dst.type());
assert(dst.size() == cpu_dst.size());
if(checkSimilarity(cv::Mat(cpu_dst), cv::Mat(dst)) <= eps)
return 1;
return 0;
}
*/
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