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
a6c261be
Commit
a6c261be
authored
Apr 25, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merged bug fix from r8188 (PyrLKOpticalFlow patch size calculation)
parent
e467ece1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
16 deletions
+44
-16
pyrlk.cpp
modules/gpu/src/pyrlk.cpp
+25
-13
pyrlk_optical_flow.cpp
samples/gpu/pyrlk_optical_flow.cpp
+19
-3
No files found.
modules/gpu/src/pyrlk.cpp
View file @
a6c261be
...
...
@@ -124,6 +124,29 @@ void cv::gpu::PyrLKOpticalFlow::buildImagePyramid(const GpuMat& img0, vector<Gpu
}
}
namespace
{
void
calcPatchSize
(
cv
::
Size
winSize
,
int
cn
,
dim3
&
block
,
dim3
&
patch
)
{
winSize
.
width
*=
cn
;
if
(
winSize
.
width
>
32
&&
winSize
.
width
>
2
*
winSize
.
height
)
{
block
.
x
=
32
;
block
.
y
=
8
;
}
else
{
block
.
x
=
block
.
y
=
16
;
}
patch
.
x
=
(
winSize
.
width
+
block
.
x
-
1
)
/
block
.
x
;
patch
.
y
=
(
winSize
.
height
+
block
.
y
-
1
)
/
block
.
y
;
block
.
z
=
patch
.
z
=
1
;
}
}
void
cv
::
gpu
::
PyrLKOpticalFlow
::
sparse
(
const
GpuMat
&
prevImg
,
const
GpuMat
&
nextImg
,
const
GpuMat
&
prevPts
,
GpuMat
&
nextPts
,
GpuMat
&
status
,
GpuMat
*
err
)
{
using
namespace
cv
::
gpu
::
device
::
pyrlk
;
...
...
@@ -142,19 +165,8 @@ void cv::gpu::PyrLKOpticalFlow::sparse(const GpuMat& prevImg, const GpuMat& next
const
int
cn
=
prevImg
.
channels
();
dim3
block
;
if
(
winSize
.
width
*
cn
>
32
)
{
block
.
x
=
32
;
block
.
y
=
8
;
}
else
{
block
.
x
=
block
.
y
=
16
;
}
dim3
patch
((
winSize
.
width
*
cn
+
block
.
x
-
1
)
/
block
.
x
,
(
winSize
.
height
+
block
.
y
-
1
)
/
block
.
y
);
dim3
block
,
patch
;
calcPatchSize
(
winSize
,
cn
,
block
,
patch
);
CV_Assert
(
derivLambda
>=
0
);
CV_Assert
(
maxLevel
>=
0
&&
winSize
.
width
>
2
&&
winSize
.
height
>
2
);
...
...
samples/gpu/pyrlk_optical_flow.cpp
View file @
a6c261be
...
...
@@ -155,8 +155,13 @@ int main(int argc, const char* argv[])
"{ h | help | false | print help message }"
"{ l | left | | specify left image }"
"{ r | right | | specify right image }"
"{ g | gray | false | use grayscale sources [PyrLK Sparse] }"
"{ p | points | 4000 | specify points count [GoodFeatureToTrack] }"
;
"{ gray | gray | false | use grayscale sources [PyrLK Sparse] }"
"{ win_size | win_size | 21 | specify windows size [PyrLK] }"
"{ max_level | max_level | 3 | specify max level [PyrLK] }"
"{ iters | iters | 30 | specify iterations count [PyrLK] }"
"{ deriv_lambda | deriv_lambda | 0.5 | specify deriv lambda [PyrLK] }"
"{ points | points | 4000 | specify points count [GoodFeatureToTrack] }"
"{ min_dist | min_dist | 0 | specify minimal distance between points [GoodFeatureToTrack] }"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
...
...
@@ -178,7 +183,12 @@ int main(int argc, const char* argv[])
}
bool
useGray
=
cmd
.
get
<
bool
>
(
"gray"
);
int
winSize
=
cmd
.
get
<
int
>
(
"win_size"
);
int
maxLevel
=
cmd
.
get
<
int
>
(
"max_level"
);
int
iters
=
cmd
.
get
<
int
>
(
"iters"
);
double
derivLambda
=
cmd
.
get
<
double
>
(
"deriv_lambda"
);
int
points
=
cmd
.
get
<
int
>
(
"points"
);
double
minDist
=
cmd
.
get
<
double
>
(
"min_dist"
);
Mat
frame0
=
imread
(
fname0
);
Mat
frame1
=
imread
(
fname1
);
...
...
@@ -210,7 +220,7 @@ int main(int argc, const char* argv[])
// goodFeaturesToTrack
GoodFeaturesToTrackDetector_GPU
detector
(
points
,
0.01
,
0.0
);
GoodFeaturesToTrackDetector_GPU
detector
(
points
,
0.01
,
minDist
);
GpuMat
d_frame0Gray
(
frame0Gray
);
GpuMat
d_prevPts
;
...
...
@@ -221,6 +231,12 @@ int main(int argc, const char* argv[])
PyrLKOpticalFlow
d_pyrLK
;
d_pyrLK
.
winSize
.
width
=
winSize
;
d_pyrLK
.
winSize
.
height
=
winSize
;
d_pyrLK
.
maxLevel
=
maxLevel
;
d_pyrLK
.
iters
=
iters
;
d_pyrLK
.
derivLambda
=
derivLambda
;
GpuMat
d_frame0
(
frame0
);
GpuMat
d_frame1
(
frame1
);
GpuMat
d_frame1Gray
(
frame1Gray
);
...
...
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