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
203b398c
Commit
203b398c
authored
Jan 18, 2017
by
Tim King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug #7482. Updated dense flow routine to reference bound textures.
parent
474e5f4c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
pyrlk.cu
modules/cudaoptflow/src/cuda/pyrlk.cu
+11
-8
pyrlk.cpp
modules/cudaoptflow/src/pyrlk.cpp
+4
-2
No files found.
modules/cudaoptflow/src/cuda/pyrlk.cu
View file @
203b398c
...
@@ -51,6 +51,8 @@
...
@@ -51,6 +51,8 @@
#include "opencv2/core/cuda/filters.hpp"
#include "opencv2/core/cuda/filters.hpp"
#include "opencv2/core/cuda/border_interpolate.hpp"
#include "opencv2/core/cuda/border_interpolate.hpp"
#include <iostream>
using namespace cv::cuda;
using namespace cv::cuda;
using namespace cv::cuda::device;
using namespace cv::cuda::device;
...
@@ -923,15 +925,15 @@ namespace pyrlk
...
@@ -923,15 +925,15 @@ namespace pyrlk
float x = xBase - c_halfWin_x + j + 0.5f;
float x = xBase - c_halfWin_x + j + 0.5f;
float y = yBase - c_halfWin_y + i + 0.5f;
float y = yBase - c_halfWin_y + i + 0.5f;
I_patch[i * patchWidth + j] = tex2D(tex_I
b
, x, y);
I_patch[i * patchWidth + j] = tex2D(tex_I
f
, x, y);
// Sharr Deriv
// Sharr Deriv
dIdx_patch[i * patchWidth + j] = 3 * tex2D(tex_I
b, x+1, y-1) + 10 * tex2D(tex_Ib, x+1, y) + 3 * tex2D(tex_Ib
, x+1, y+1) -
dIdx_patch[i * patchWidth + j] = 3 * tex2D(tex_I
f, x+1, y-1) + 10 * tex2D(tex_If, x+1, y) + 3 * tex2D(tex_If
, x+1, y+1) -
(3 * tex2D(tex_I
b, x-1, y-1) + 10 * tex2D(tex_Ib, x-1, y) + 3 * tex2D(tex_Ib
, x-1, y+1));
(3 * tex2D(tex_I
f, x-1, y-1) + 10 * tex2D(tex_If, x-1, y) + 3 * tex2D(tex_If
, x-1, y+1));
dIdy_patch[i * patchWidth + j] = 3 * tex2D(tex_I
b, x-1, y+1) + 10 * tex2D(tex_Ib, x, y+1) + 3 * tex2D(tex_Ib
, x+1, y+1) -
dIdy_patch[i * patchWidth + j] = 3 * tex2D(tex_I
f, x-1, y+1) + 10 * tex2D(tex_If, x, y+1) + 3 * tex2D(tex_If
, x+1, y+1) -
(3 * tex2D(tex_I
b, x-1, y-1) + 10 * tex2D(tex_Ib, x, y-1) + 3 * tex2D(tex_Ib
, x+1, y-1));
(3 * tex2D(tex_I
f, x-1, y-1) + 10 * tex2D(tex_If, x, y-1) + 3 * tex2D(tex_If
, x+1, y-1));
}
}
}
}
...
@@ -943,6 +945,7 @@ namespace pyrlk
...
@@ -943,6 +945,7 @@ namespace pyrlk
if (x >= cols || y >= rows)
if (x >= cols || y >= rows)
return;
return;
int A11i = 0;
int A11i = 0;
int A12i = 0;
int A12i = 0;
int A22i = 0;
int A22i = 0;
...
@@ -970,7 +973,6 @@ namespace pyrlk
...
@@ -970,7 +973,6 @@ namespace pyrlk
{
{
if (calcErr)
if (calcErr)
err(y, x) = numeric_limits<float>::max();
err(y, x) = numeric_limits<float>::max();
return;
return;
}
}
...
@@ -1014,6 +1016,7 @@ namespace pyrlk
...
@@ -1014,6 +1016,7 @@ namespace pyrlk
}
}
}
}
float2 delta;
float2 delta;
delta.x = A12 * b2 - A22 * b1;
delta.x = A12 * b2 - A22 * b1;
delta.y = A12 * b1 - A11 * b2;
delta.y = A12 * b1 - A11 * b2;
...
@@ -1083,11 +1086,11 @@ namespace pyrlk
...
@@ -1083,11 +1086,11 @@ namespace pyrlk
funcs[patch.y - 1][patch.x - 1](I, J, I.rows, I.cols, prevPts, nextPts, status, err, ptcount,
funcs[patch.y - 1][patch.x - 1](I, J, I.rows, I.cols, prevPts, nextPts, status, err, ptcount,
level, block, stream);
level, block, stream);
}
}
static void dense(PtrStepSz
b
I, PtrStepSz<T> J, PtrStepSzf u, PtrStepSzf v, PtrStepSzf prevU, PtrStepSzf prevV, PtrStepSzf err, int2 winSize, cudaStream_t stream)
static void dense(PtrStepSz
<T>
I, PtrStepSz<T> J, PtrStepSzf u, PtrStepSzf v, PtrStepSzf prevU, PtrStepSzf prevV, PtrStepSzf err, int2 winSize, cudaStream_t stream)
{
{
dim3 block(16, 16);
dim3 block(16, 16);
dim3 grid(divUp(I.cols, block.x), divUp(I.rows, block.y));
dim3 grid(divUp(I.cols, block.x), divUp(I.rows, block.y));
Tex_I<1,
uchar
>::bindTexture_(I);
Tex_I<1,
T
>::bindTexture_(I);
Tex_J<1, T>::bindTexture_(J);
Tex_J<1, T>::bindTexture_(J);
int2 halfWin = make_int2((winSize.x - 1) / 2, (winSize.y - 1) / 2);
int2 halfWin = make_int2((winSize.x - 1) / 2, (winSize.y - 1) / 2);
...
...
modules/cudaoptflow/src/pyrlk.cpp
View file @
203b398c
...
@@ -61,7 +61,7 @@ namespace pyrlk
...
@@ -61,7 +61,7 @@ namespace pyrlk
static
void
sparse
(
PtrStepSz
<
typename
device
::
TypeVec
<
T
,
cn
>::
vec_type
>
I
,
PtrStepSz
<
typename
device
::
TypeVec
<
T
,
cn
>::
vec_type
>
J
,
const
float2
*
prevPts
,
float2
*
nextPts
,
uchar
*
status
,
float
*
err
,
int
ptcount
,
static
void
sparse
(
PtrStepSz
<
typename
device
::
TypeVec
<
T
,
cn
>::
vec_type
>
I
,
PtrStepSz
<
typename
device
::
TypeVec
<
T
,
cn
>::
vec_type
>
J
,
const
float2
*
prevPts
,
float2
*
nextPts
,
uchar
*
status
,
float
*
err
,
int
ptcount
,
int
level
,
dim3
block
,
dim3
patch
,
cudaStream_t
stream
);
int
level
,
dim3
block
,
dim3
patch
,
cudaStream_t
stream
);
static
void
dense
(
PtrStepSz
b
I
,
PtrStepSzf
J
,
PtrStepSzf
u
,
PtrStepSzf
v
,
PtrStepSzf
prevU
,
PtrStepSzf
prevV
,
static
void
dense
(
PtrStepSz
f
I
,
PtrStepSzf
J
,
PtrStepSzf
u
,
PtrStepSzf
v
,
PtrStepSzf
prevU
,
PtrStepSzf
prevV
,
PtrStepSzf
err
,
int2
winSize
,
cudaStream_t
stream
);
PtrStepSzf
err
,
int2
winSize
,
cudaStream_t
stream
);
};
};
...
@@ -236,7 +236,9 @@ namespace
...
@@ -236,7 +236,9 @@ namespace
prevPyr_
.
resize
(
maxLevel_
+
1
);
prevPyr_
.
resize
(
maxLevel_
+
1
);
nextPyr_
.
resize
(
maxLevel_
+
1
);
nextPyr_
.
resize
(
maxLevel_
+
1
);
prevPyr_
[
0
]
=
prevImg
;
//prevPyr_[0] = prevImg;
prevImg
.
convertTo
(
prevPyr_
[
0
],
CV_32F
,
stream
);
nextImg
.
convertTo
(
nextPyr_
[
0
],
CV_32F
,
stream
);
nextImg
.
convertTo
(
nextPyr_
[
0
],
CV_32F
,
stream
);
for
(
int
level
=
1
;
level
<=
maxLevel_
;
++
level
)
for
(
int
level
=
1
;
level
<=
maxLevel_
;
++
level
)
...
...
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