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
cdae0743
Commit
cdae0743
authored
Jan 18, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix OpenGL render functions
fix createOpticalFlowNeedleMap
parent
70820224
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
9 deletions
+15
-9
opengl_interop.cpp
modules/core/src/opengl_interop.cpp
+3
-2
optical_flow.cu
modules/gpu/src/cuda/optical_flow.cu
+4
-5
optical_flow.cpp
modules/gpu/src/optical_flow.cpp
+8
-2
No files found.
modules/core/src/opengl_interop.cpp
View file @
cdae0743
...
...
@@ -1330,7 +1330,7 @@ void cv::render(const GlArrays& arr, int mode, Scalar color)
#ifndef HAVE_OPENGL
throw_nogl
;
#else
glColor3d
(
color
[
0
]
/
255.0
,
color
[
1
]
/
255.0
,
color
[
3
]
/
255.0
);
glColor3d
(
color
[
0
]
/
255.0
,
color
[
1
]
/
255.0
,
color
[
2
]
/
255.0
);
arr
.
bind
();
...
...
@@ -1358,9 +1358,10 @@ void cv::render(const string& str, const Ptr<GlFont>& font, Scalar color, Point2
glMatrixMode
(
GL_MODELVIEW
);
glLoadIdentity
();
glColor3d
(
color
[
0
]
/
255.0
,
color
[
1
]
/
255.0
,
color
[
2
]
/
255.0
);
glRasterPos2d
(
2.0
*
(
viewport
[
0
]
+
pos
.
x
)
/
viewport
[
2
]
-
1.0
,
1.0
-
2.0
*
(
viewport
[
1
]
+
pos
.
y
+
font
->
height
())
/
viewport
[
3
]);
glColor4dv
(
color
.
val
);
font
->
draw
(
str
.
c_str
(),
str
.
length
());
glPopAttrib
();
...
...
modules/gpu/src/cuda/optical_flow.cu
View file @
cdae0743
...
...
@@ -47,7 +47,6 @@ namespace cv { namespace gpu { namespace device
namespace optical_flow
{
#define NEEDLE_MAP_SCALE 16
#define MAX_FLOW 30.0f
#define NUM_VERTS_PER_ARROW 6
__global__ void NeedleMapAverageKernel(const DevMem2Df u, const PtrStepf v, PtrStepf u_avg, PtrStepf v_avg)
...
...
@@ -123,7 +122,7 @@ namespace cv { namespace gpu { namespace device
cudaSafeCall( cudaDeviceSynchronize() );
}
__global__ void NeedleMapVertexKernel(const DevMem2Df u_avg, const PtrStepf v_avg, float* vertex_data, float* color_data, float xscale, float yscale)
__global__ void NeedleMapVertexKernel(const DevMem2Df u_avg, const PtrStepf v_avg, float* vertex_data, float* color_data, float
max_flow, float
xscale, float yscale)
{
// test - just draw a triangle at each pixel
const int x = blockIdx.x * blockDim.x + threadIdx.x;
...
...
@@ -142,7 +141,7 @@ namespace cv { namespace gpu { namespace device
const float theta = ::atan2f(v_avg_val, u_avg_val) + CV_PI;
float r = ::sqrtf(v_avg_val * v_avg_val + u_avg_val * u_avg_val);
r = fmin(14.0f * (r /
MAX_FLOW
), 14.0f);
r = fmin(14.0f * (r /
max_flow
), 14.0f);
v[0].z = 1.0f;
v[1].z = 0.7f;
...
...
@@ -203,12 +202,12 @@ namespace cv { namespace gpu { namespace device
}
}
void CreateOpticalFlowNeedleMap_gpu(DevMem2Df u_avg, DevMem2Df v_avg, float* vertex_buffer, float* color_data, float xscale, float yscale)
void CreateOpticalFlowNeedleMap_gpu(DevMem2Df u_avg, DevMem2Df v_avg, float* vertex_buffer, float* color_data, float
max_flow, float
xscale, float yscale)
{
const dim3 block(16);
const dim3 grid(divUp(u_avg.cols, block.x), divUp(u_avg.rows, block.y));
NeedleMapVertexKernel<<<grid, block>>>(u_avg, v_avg, vertex_buffer, color_data, xscale, yscale);
NeedleMapVertexKernel<<<grid, block>>>(u_avg, v_avg, vertex_buffer, color_data,
max_flow,
xscale, yscale);
cudaSafeCall( cudaGetLastError() );
cudaSafeCall( cudaDeviceSynchronize() );
...
...
modules/gpu/src/optical_flow.cpp
View file @
cdae0743
...
...
@@ -194,7 +194,7 @@ namespace cv { namespace gpu { namespace device
namespace
optical_flow
{
void
NeedleMapAverage_gpu
(
DevMem2Df
u
,
DevMem2Df
v
,
DevMem2Df
u_avg
,
DevMem2Df
v_avg
);
void
CreateOpticalFlowNeedleMap_gpu
(
DevMem2Df
u_avg
,
DevMem2Df
v_avg
,
float
*
vertex_buffer
,
float
*
color_data
,
float
xscale
,
float
yscale
);
void
CreateOpticalFlowNeedleMap_gpu
(
DevMem2Df
u_avg
,
DevMem2Df
v_avg
,
float
*
vertex_buffer
,
float
*
color_data
,
float
max_flow
,
float
xscale
,
float
yscale
);
}
}}}
...
...
@@ -224,7 +224,13 @@ void cv::gpu::createOpticalFlowNeedleMap(const GpuMat& u, const GpuMat& v, GpuMa
colors
.
setTo
(
Scalar
::
all
(
1.0
));
CreateOpticalFlowNeedleMap_gpu
(
u_avg
,
v_avg
,
vertex
.
ptr
<
float
>
(),
colors
.
ptr
<
float
>
(),
1.0
f
/
u
.
cols
,
1.0
f
/
u
.
rows
);
double
uMax
,
vMax
;
minMax
(
u_avg
,
0
,
&
uMax
);
minMax
(
v_avg
,
0
,
&
vMax
);
float
max_flow
=
static_cast
<
float
>
(
sqrt
(
uMax
*
uMax
+
vMax
*
vMax
));
CreateOpticalFlowNeedleMap_gpu
(
u_avg
,
v_avg
,
vertex
.
ptr
<
float
>
(),
colors
.
ptr
<
float
>
(),
max_flow
,
1.0
f
/
u
.
cols
,
1.0
f
/
u
.
rows
);
cvtColor
(
colors
,
colors
,
COLOR_HSV2RGB
);
}
...
...
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