Commit 203b398c authored by Tim King's avatar Tim King

Fixed bug #7482. Updated dense flow routine to reference bound textures.

parent 474e5f4c
...@@ -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_Ib, x, y); I_patch[i * patchWidth + j] = tex2D(tex_If, x, y);
// Sharr Deriv // Sharr Deriv
dIdx_patch[i * patchWidth + j] = 3 * tex2D(tex_Ib, 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_If, x+1, y-1) + 10 * tex2D(tex_If, x+1, y) + 3 * tex2D(tex_If, x+1, y+1) -
(3 * tex2D(tex_Ib, x-1, y-1) + 10 * tex2D(tex_Ib, x-1, y) + 3 * tex2D(tex_Ib, x-1, y+1)); (3 * tex2D(tex_If, 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_Ib, 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_If, x-1, y+1) + 10 * tex2D(tex_If, x, y+1) + 3 * tex2D(tex_If, x+1, y+1) -
(3 * tex2D(tex_Ib, x-1, y-1) + 10 * tex2D(tex_Ib, x, y-1) + 3 * tex2D(tex_Ib, x+1, y-1)); (3 * tex2D(tex_If, 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(PtrStepSzb 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);
......
...@@ -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(PtrStepSzb I, PtrStepSzf J, PtrStepSzf u, PtrStepSzf v, PtrStepSzf prevU, PtrStepSzf prevV, static void dense(PtrStepSzf 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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment