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
ced60b74
Commit
ced60b74
authored
Oct 12, 2010
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added histograms calculation to gpu module
parent
525da9ef
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
2 deletions
+102
-2
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+25
-0
imgproc_gpu.cpp
modules/gpu/src/imgproc_gpu.cpp
+0
-0
imgproc_gpu.cpp
tests/gpu/src/imgproc_gpu.cpp
+77
-2
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
ced60b74
...
...
@@ -700,6 +700,31 @@ namespace cv
//!performs labeling via graph cuts
CV_EXPORTS
void
graphcut
(
GpuMat
&
terminals
,
GpuMat
&
leftTransp
,
GpuMat
&
rightTransp
,
GpuMat
&
top
,
GpuMat
&
bottom
,
GpuMat
&
labels
,
GpuMat
&
buf
);
////////////////////////////////// Histograms //////////////////////////////////
//! Compute levels with even distribution. levels will have 1 row and nLevels cols and CV_32SC1 type.
CV_EXPORTS
void
evenLevels
(
GpuMat
&
levels
,
int
nLevels
,
int
lowerLevel
,
int
upperLevel
);
//! Calculates histogram with evenly distributed bins for signle channel source.
//! Supports CV_8UC1, CV_16UC1 and CV_16SC1 source types.
//! Output hist will have one row and histSize cols and CV_32SC1 type.
CV_EXPORTS
void
histEven
(
const
GpuMat
&
src
,
GpuMat
&
hist
,
int
histSize
,
int
lowerLevel
,
int
upperLevel
);
//! Calculates histogram with evenly distributed bins for four-channel source.
//! All channels of source are processed separately.
//! Supports CV_8UC4, CV_16UC4 and CV_16SC4 source types.
//! Output hist[i] will have one row and histSize[i] cols and CV_32SC1 type.
CV_EXPORTS
void
histEven
(
const
GpuMat
&
src
,
GpuMat
hist
[
4
],
int
histSize
[
4
],
int
lowerLevel
[
4
],
int
upperLevel
[
4
]);
//! Calculates histogram with bins determined by levels array.
//! levels must have one row and CV_32SC1 type.
//! Supports CV_8UC1, CV_16UC1 and CV_16SC1 source types.
//! Output hist will have one row and (levels.cols-1) cols and CV_32SC1 type.
CV_EXPORTS
void
histRange
(
const
GpuMat
&
src
,
GpuMat
&
hist
,
const
GpuMat
&
levels
);
//! Calculates histogram with bins determined by levels array.
//! All levels must have one row and CV_32SC1 type.
//! All channels of source are processed separately.
//! Supports CV_8UC4, CV_16UC4 and CV_16SC4 source types.
//! Output hist[i] will have one row and (levels[i].cols-1) cols and CV_32SC1 type.
CV_EXPORTS
void
histRange
(
const
GpuMat
&
src
,
GpuMat
hist
[
4
],
const
GpuMat
levels
[
4
]);
//////////////////////////////// StereoBM_GPU ////////////////////////////////
class
CV_EXPORTS
StereoBM_GPU
...
...
modules/gpu/src/imgproc_gpu.cpp
View file @
ced60b74
This diff is collapsed.
Click to expand it.
tests/gpu/src/imgproc_gpu.cpp
View file @
ced60b74
...
...
@@ -530,6 +530,80 @@ void CV_GpuCvtColorTest::run( int )
ts
->
set_failed_test_info
(
testResult
);
}
////////////////////////////////////////////////////////////////////////////////
// Histograms
class
CV_GpuHistogramsTest
:
public
CvTest
{
public
:
CV_GpuHistogramsTest
()
:
CvTest
(
"GPU-Histograms"
,
"histEven"
)
{}
~
CV_GpuHistogramsTest
()
{};
protected
:
void
run
(
int
);
int
CheckNorm
(
const
Mat
&
m1
,
const
Mat
&
m2
)
{
double
ret
=
norm
(
m1
,
m2
,
NORM_INF
);
if
(
ret
<
std
::
numeric_limits
<
double
>::
epsilon
())
{
return
CvTS
::
OK
;
}
else
{
ts
->
printf
(
CvTS
::
LOG
,
"
\n
Norm: %f
\n
"
,
ret
);
return
CvTS
::
FAIL_GENERIC
;
}
}
};
void
CV_GpuHistogramsTest
::
run
(
int
)
{
//load image
cv
::
Mat
img
=
cv
::
imread
(
std
::
string
(
ts
->
get_data_path
())
+
"stereobp/aloe-L.png"
);
if
(
img
.
empty
())
{
ts
->
set_failed_test_info
(
CvTS
::
FAIL_MISSING_TEST_DATA
);
return
;
}
try
{
Mat
hsv
;
cv
::
cvtColor
(
img
,
hsv
,
CV_BGR2HSV
);
int
hbins
=
30
;
int
histSize
[]
=
{
hbins
};
float
hranges
[]
=
{
0
,
180
};
const
float
*
ranges
[]
=
{
hranges
};
MatND
hist
;
int
channels
[]
=
{
0
};
calcHist
(
&
hsv
,
1
,
channels
,
Mat
(),
hist
,
1
,
histSize
,
ranges
);
GpuMat
gpuHsv
(
hsv
);
std
::
vector
<
GpuMat
>
srcs
;
cv
::
gpu
::
split
(
gpuHsv
,
srcs
);
GpuMat
gpuHist
;
histEven
(
srcs
[
0
],
gpuHist
,
hbins
,
(
int
)
hranges
[
0
],
(
int
)
hranges
[
1
]);
Mat
cpuHist
=
hist
;
cpuHist
=
cpuHist
.
t
();
cpuHist
.
convertTo
(
cpuHist
,
CV_32S
);
ts
->
set_failed_test_info
(
CheckNorm
(
cpuHist
,
gpuHist
));
}
catch
(
const
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////// tests registration /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
...
...
@@ -545,4 +619,5 @@ CV_GpuNppImageWarpAffineTest CV_GpuNppImageWarpAffine_test;
CV_GpuNppImageWarpPerspectiveTest
CV_GpuNppImageWarpPerspective_test
;
CV_GpuNppImageIntegralTest
CV_GpuNppImageIntegral_test
;
CV_GpuNppImageCannyTest
CV_GpuNppImageCanny_test
;
CV_GpuCvtColorTest
CV_GpuCvtColor_test
;
\ No newline at end of file
CV_GpuCvtColorTest
CV_GpuCvtColor_test
;
CV_GpuHistogramsTest
CV_GpuHistograms_test
;
\ No newline at end of file
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