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
bf5e9304
Commit
bf5e9304
authored
Mar 24, 2015
by
Rok Mandeljc
Committed by
Rok Mandeljc
Nov 19, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cudastereo: drawColorDisp: enabled CV_32S and CV_32F disparity formats
parent
9f82ac18
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
+55
-2
util.cu
modules/cudastereo/src/cuda/util.cu
+51
-0
util.cpp
modules/cudastereo/src/util.cpp
+4
-2
No files found.
modules/cudastereo/src/cuda/util.cu
View file @
bf5e9304
...
...
@@ -205,6 +205,29 @@ namespace cv { namespace cuda { namespace device
}
}
__global__ void drawColorDisp(int* disp, size_t disp_step, uchar* out_image, size_t out_step, int width, int height, int ndisp)
{
const int x = blockIdx.x * blockDim.x + threadIdx.x;
const int y = blockIdx.y * blockDim.y + threadIdx.y;
if(x < width && y < height)
{
uint *line = (uint*)(out_image + y * out_step);
line[x] = cvtPixel(disp[y*disp_step + x], ndisp);
}
}
__global__ void drawColorDisp(float* disp, size_t disp_step, uchar* out_image, size_t out_step, int width, int height, int ndisp)
{
const int x = blockIdx.x * blockDim.x + threadIdx.x;
const int y = blockIdx.y * blockDim.y + threadIdx.y;
if(x < width && y < height)
{
uint *line = (uint*)(out_image + y * out_step);
line[x] = cvtPixel(disp[y*disp_step + x], ndisp);
}
}
void drawColorDisp_gpu(const PtrStepSzb& src, const PtrStepSzb& dst, int ndisp, const cudaStream_t& stream)
{
...
...
@@ -233,6 +256,34 @@ namespace cv { namespace cuda { namespace device
if (stream == 0)
cudaSafeCall( cudaDeviceSynchronize() );
}
void drawColorDisp_gpu(const PtrStepSz<int>& src, const PtrStepSzb& dst, int ndisp, const cudaStream_t& stream)
{
dim3 threads(32, 8, 1);
dim3 grid(1, 1, 1);
grid.x = divUp(src.cols, threads.x);
grid.y = divUp(src.rows, threads.y);
drawColorDisp<<<grid, threads, 0, stream>>>(src.data, src.step / sizeof(int), dst.data, dst.step, src.cols, src.rows, ndisp);
cudaSafeCall( cudaGetLastError() );
if (stream == 0)
cudaSafeCall( cudaDeviceSynchronize() );
}
void drawColorDisp_gpu(const PtrStepSz<float>& src, const PtrStepSzb& dst, int ndisp, const cudaStream_t& stream)
{
dim3 threads(32, 8, 1);
dim3 grid(1, 1, 1);
grid.x = divUp(src.cols, threads.x);
grid.y = divUp(src.rows, threads.y);
drawColorDisp<<<grid, threads, 0, stream>>>(src.data, src.step / sizeof(float), dst.data, dst.step, src.cols, src.rows, ndisp);
cudaSafeCall( cudaGetLastError() );
if (stream == 0)
cudaSafeCall( cudaDeviceSynchronize() );
}
}}} // namespace cv { namespace cuda { namespace cudev
...
...
modules/cudastereo/src/util.cpp
View file @
bf5e9304
...
...
@@ -92,6 +92,8 @@ namespace cv { namespace cuda { namespace device
{
void
drawColorDisp_gpu
(
const
PtrStepSzb
&
src
,
const
PtrStepSzb
&
dst
,
int
ndisp
,
const
cudaStream_t
&
stream
);
void
drawColorDisp_gpu
(
const
PtrStepSz
<
short
>&
src
,
const
PtrStepSzb
&
dst
,
int
ndisp
,
const
cudaStream_t
&
stream
);
void
drawColorDisp_gpu
(
const
PtrStepSz
<
int
>&
src
,
const
PtrStepSzb
&
dst
,
int
ndisp
,
const
cudaStream_t
&
stream
);
void
drawColorDisp_gpu
(
const
PtrStepSz
<
float
>&
src
,
const
PtrStepSzb
&
dst
,
int
ndisp
,
const
cudaStream_t
&
stream
);
}}}
namespace
...
...
@@ -111,11 +113,11 @@ namespace
void
cv
::
cuda
::
drawColorDisp
(
InputArray
_src
,
OutputArray
dst
,
int
ndisp
,
Stream
&
stream
)
{
typedef
void
(
*
drawColorDisp_caller_t
)(
const
GpuMat
&
src
,
OutputArray
dst
,
int
ndisp
,
const
cudaStream_t
&
stream
);
const
drawColorDisp_caller_t
drawColorDisp_callers
[]
=
{
drawColorDisp_caller
<
unsigned
char
>
,
0
,
0
,
drawColorDisp_caller
<
short
>
,
0
,
0
,
0
,
0
};
const
drawColorDisp_caller_t
drawColorDisp_callers
[]
=
{
drawColorDisp_caller
<
unsigned
char
>
,
0
,
0
,
drawColorDisp_caller
<
short
>
,
drawColorDisp_caller
<
int
>
,
drawColorDisp_caller
<
float
>
,
0
,
0
};
GpuMat
src
=
_src
.
getGpuMat
();
CV_Assert
(
src
.
type
()
==
CV_8U
||
src
.
type
()
==
CV_16S
);
CV_Assert
(
src
.
type
()
==
CV_8U
||
src
.
type
()
==
CV_16S
||
src
.
type
()
==
CV_32S
||
src
.
type
()
==
CV_32F
);
drawColorDisp_callers
[
src
.
type
()](
src
,
dst
,
ndisp
,
StreamAccessor
::
getStream
(
stream
));
}
...
...
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