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
1f04ea47
Commit
1f04ea47
authored
Aug 19, 2010
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added DisparityBilateralFilter to gpu module
parent
48090fd3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
185 additions
and
0 deletions
+185
-0
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+40
-0
bilateral_filter.cpp
modules/gpu/src/bilateral_filter.cpp
+145
-0
bilateral_filter.cu
modules/gpu/src/cuda/bilateral_filter.cu
+0
-0
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
1f04ea47
...
...
@@ -391,6 +391,7 @@ namespace cv
////////////////////////// StereoBeliefPropagation ///////////////////////////
// "Efficient Belief Propagation for Early Vision"
// P.Felzenszwalb
class
CV_EXPORTS
StereoBeliefPropagation
{
public
:
...
...
@@ -504,6 +505,45 @@ namespace cv
GpuMat
out
;
};
/////////////////////////// DisparityBilateralFilter ///////////////////////////
// Disparity map refinement using joint bilateral filtering given a single color image.
// Qingxiong Yang, Liang Wang, Narendra Ahuja
// http://vision.ai.uiuc.edu/~qyang6/
class
CV_EXPORTS
DisparityBilateralFilter
{
public
:
enum
{
DEFAULT_NDISP
=
64
};
enum
{
DEFAULT_RADIUS
=
3
};
enum
{
DEFAULT_ITERS
=
1
};
//! the default constructor
explicit
DisparityBilateralFilter
(
int
ndisp
=
DEFAULT_NDISP
,
int
radius
=
DEFAULT_RADIUS
,
int
iters
=
DEFAULT_ITERS
);
//! the full constructor taking the number of disparities, filter radius,
//! number of iterations, truncation of data continuity, truncation of disparity continuity
//! and filter range sigma
DisparityBilateralFilter
(
int
ndisp
,
int
radius
,
int
iters
,
float
edge_threshold
,
float
max_disc_threshold
,
float
sigma_range
);
//! the disparity map refinement operator. Refine disparity map using joint bilateral filtering given a single color image.
//! disparity must have CV_8U or CV_16S type, image must have CV_8UC1 or CV_8UC3 type.
void
operator
()(
const
GpuMat
&
disparity
,
const
GpuMat
&
image
,
GpuMat
&
dst
);
//! Acync version
void
operator
()(
const
GpuMat
&
disparity
,
const
GpuMat
&
image
,
GpuMat
&
dst
,
Stream
&
stream
);
int
ndisp
;
int
radius
;
int
iters
;
float
edge_threshold
;
float
max_disc_threshold
;
float
sigma_range
;
private
:
std
::
vector
<
float
>
table_color
;
GpuMat
table_space
;
};
}
//! Speckle filtering - filters small connected components on diparity image.
...
...
modules/gpu/src/bilateral_filter.cpp
0 → 100644
View file @
1f04ea47
/*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) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., 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 GpuMaterials 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"
using
namespace
cv
;
using
namespace
cv
::
gpu
;
using
namespace
std
;
#if !defined (HAVE_CUDA)
cv
::
gpu
::
DisparityBilateralFilter
::
DisparityBilateralFilter
(
int
,
int
,
int
)
{
throw_nogpu
();
}
cv
::
gpu
::
DisparityBilateralFilter
::
DisparityBilateralFilter
(
int
,
int
,
int
,
float
,
float
,
float
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
DisparityBilateralFilter
::
operator
()(
const
GpuMat
&
,
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
DisparityBilateralFilter
::
operator
()(
const
GpuMat
&
,
const
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_nogpu
();
}
#else
/* !defined (HAVE_CUDA) */
namespace
cv
{
namespace
gpu
{
namespace
bf
{
void
calc_space_weighted_filter_gpu
(
const
DevMem2Df
&
table_space
,
int
half
,
float
dist_space
,
cudaStream_t
stream
);
void
load_constants
(
float
*
table_color
,
const
DevMem2Df
&
table_space
,
int
ndisp
,
int
radius
,
short
edge_disc
,
short
max_disc
);
void
bilateral_filter_gpu
(
const
DevMem2D
&
disp
,
const
DevMem2D
&
img
,
int
channels
,
int
iters
,
cudaStream_t
stream
);
void
bilateral_filter_gpu
(
const
DevMem2D_
<
short
>&
disp
,
const
DevMem2D
&
img
,
int
channels
,
int
iters
,
cudaStream_t
stream
);
}}}
namespace
{
const
float
DEFAULT_EDGE_THRESHOLD
=
0.1
f
;
const
float
DEFAULT_MAX_DISC_THRESHOLD
=
0.2
f
;
const
float
DEFAULT_SIGMA_RANGE
=
10.0
f
;
inline
void
calc_color_weighted_table
(
vector
<
float
>&
table_color
,
float
sigma_range
,
int
len
)
{
float
*
color_table_x
;
table_color
.
resize
(
len
);
color_table_x
=
&
table_color
[
0
];
for
(
int
y
=
0
;
y
<
len
;
y
++
)
table_color
[
y
]
=
static_cast
<
float
>
(
std
::
exp
(
-
double
(
y
*
y
)
/
(
2
*
sigma_range
*
sigma_range
)));
}
inline
void
calc_space_weighted_filter
(
GpuMat
&
table_space
,
int
win_size
,
float
dist_space
,
cudaStream_t
stream
)
{
int
half
=
(
win_size
>>
1
);
table_space
.
create
(
half
+
1
,
half
+
1
,
CV_32F
);
bf
::
calc_space_weighted_filter_gpu
(
table_space
,
half
,
dist_space
,
stream
);
}
template
<
typename
T
>
void
bilateral_filter_operator
(
DisparityBilateralFilter
&
rthis
,
vector
<
float
>&
table_color
,
GpuMat
&
table_space
,
const
GpuMat
&
disp
,
const
GpuMat
&
img
,
GpuMat
&
dst
,
cudaStream_t
stream
)
{
calc_color_weighted_table
(
table_color
,
rthis
.
sigma_range
,
255
);
calc_space_weighted_filter
(
table_space
,
rthis
.
radius
*
2
+
1
,
rthis
.
radius
+
1.0
f
,
stream
);
short
edge_disc
=
max
<
short
>
(
short
(
1
),
short
(
rthis
.
ndisp
*
rthis
.
edge_threshold
+
0.5
));
short
max_disc
=
short
(
rthis
.
ndisp
*
rthis
.
max_disc_threshold
+
0.5
);
bf
::
load_constants
(
&
table_color
[
0
],
table_space
,
rthis
.
ndisp
,
rthis
.
radius
,
edge_disc
,
max_disc
);
if
(
&
dst
!=
&
disp
)
disp
.
copyTo
(
dst
);
bf
::
bilateral_filter_gpu
((
DevMem2D_
<
T
>
)
dst
,
img
,
img
.
channels
(),
rthis
.
iters
,
stream
);
}
typedef
void
(
*
bilateral_filter_operator_t
)(
DisparityBilateralFilter
&
rthis
,
vector
<
float
>&
table_color
,
GpuMat
&
table_space
,
const
GpuMat
&
disp
,
const
GpuMat
&
img
,
GpuMat
&
dst
,
cudaStream_t
stream
);
const
bilateral_filter_operator_t
operators
[]
=
{
bilateral_filter_operator
<
unsigned
char
>
,
0
,
0
,
bilateral_filter_operator
<
short
>
,
0
,
0
,
0
,
0
};
}
cv
::
gpu
::
DisparityBilateralFilter
::
DisparityBilateralFilter
(
int
ndisp_
,
int
radius_
,
int
iters_
)
:
ndisp
(
ndisp_
),
radius
(
radius_
),
iters
(
iters_
),
edge_threshold
(
DEFAULT_EDGE_THRESHOLD
),
max_disc_threshold
(
DEFAULT_MAX_DISC_THRESHOLD
),
sigma_range
(
DEFAULT_SIGMA_RANGE
)
{
}
cv
::
gpu
::
DisparityBilateralFilter
::
DisparityBilateralFilter
(
int
ndisp_
,
int
radius_
,
int
iters_
,
float
edge_threshold_
,
float
max_disc_threshold_
,
float
sigma_range_
)
:
ndisp
(
ndisp_
),
radius
(
radius_
),
iters
(
iters_
),
edge_threshold
(
edge_threshold_
),
max_disc_threshold
(
max_disc_threshold_
),
sigma_range
(
sigma_range_
)
{
}
void
cv
::
gpu
::
DisparityBilateralFilter
::
operator
()(
const
GpuMat
&
disp
,
const
GpuMat
&
img
,
GpuMat
&
dst
)
{
CV_DbgAssert
(
0
<
ndisp
&&
0
<
radius
&&
0
<
iters
);
CV_Assert
(
disp
.
rows
==
img
.
rows
&&
disp
.
cols
==
img
.
cols
&&
(
disp
.
type
()
==
CV_8U
||
disp
.
type
()
==
CV_16S
)
&&
(
img
.
type
()
==
CV_8UC1
||
img
.
type
()
==
CV_8UC3
));
operators
[
disp
.
type
()](
*
this
,
table_color
,
table_space
,
disp
,
img
,
dst
,
0
);
}
void
cv
::
gpu
::
DisparityBilateralFilter
::
operator
()(
const
GpuMat
&
disp
,
const
GpuMat
&
img
,
GpuMat
&
dst
,
Stream
&
stream
)
{
CV_DbgAssert
(
0
<
ndisp
&&
0
<
radius
&&
0
<
iters
);
CV_Assert
(
disp
.
rows
==
img
.
rows
&&
disp
.
cols
==
img
.
cols
&&
(
disp
.
type
()
==
CV_8U
||
disp
.
type
()
==
CV_16S
)
&&
(
img
.
type
()
==
CV_8UC1
||
img
.
type
()
==
CV_8UC3
));
operators
[
disp
.
type
()](
*
this
,
table_color
,
table_space
,
disp
,
img
,
dst
,
StreamAccessor
::
getStream
(
stream
));
}
#endif
/* !defined (HAVE_CUDA) */
modules/gpu/src/cuda/bilateral_filter.cu
0 → 100644
View file @
1f04ea47
This diff is collapsed.
Click to expand it.
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