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
27fb7e18
Commit
27fb7e18
authored
Jan 23, 2014
by
vbystricky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change type of result vector of ocl version from row to column
parent
094bc923
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
13 deletions
+26
-13
lkpyramid.cpp
modules/video/src/lkpyramid.cpp
+16
-6
test_optflowpyrlk.cpp
modules/video/test/ocl/test_optflowpyrlk.cpp
+10
-7
No files found.
modules/video/src/lkpyramid.cpp
View file @
27fb7e18
...
...
@@ -806,14 +806,25 @@ namespace cv
if
((
0
!=
CV_MAT_DEPTH
(
typePrev
))
||
(
0
!=
CV_MAT_DEPTH
(
typeNext
)))
return
false
;
if
(
_prevPts
.
empty
()
||
_prevPts
.
size
().
height
!=
1
||
_prevPts
.
type
()
!=
CV_32FC2
)
if
(
_prevPts
.
empty
()
||
_prevPts
.
type
()
!=
CV_32FC2
||
(
!
_prevPts
.
isContinuous
())
)
return
false
;
if
((
1
!=
_prevPts
.
size
().
height
)
&&
(
1
!=
_prevPts
.
size
().
width
))
return
false
;
size_t
npoints
=
_prevPts
.
total
();
bool
useInitialFlow
=
(
0
!=
(
flags
&
OPTFLOW_USE_INITIAL_FLOW
));
if
(
useInitialFlow
)
{
if
(
_nextPts
.
size
()
!=
_prevPts
.
size
()
||
_nextPts
.
type
()
!=
CV_32FC2
)
if
(
_nextPts
.
empty
()
||
_nextPts
.
type
()
!=
CV_32FC2
||
(
!
_prevPts
.
isContinuous
()))
return
false
;
if
((
1
!=
_nextPts
.
size
().
height
)
&&
(
1
!=
_nextPts
.
size
().
width
))
return
false
;
if
(
_nextPts
.
total
()
!=
npoints
)
return
false
;
}
else
{
_nextPts
.
create
(
_prevPts
.
size
(),
_prevPts
.
type
());
}
PyrLKOpticalFlow
opticalFlow
;
opticalFlow
.
winSize
=
winSize
;
...
...
@@ -828,14 +839,13 @@ namespace cv
UMat
umatErr
;
if
(
_err
.
needed
())
{
_err
.
create
(
_prevPts
.
size
()
,
CV_32FC1
);
_err
.
create
(
(
int
)
npoints
,
1
,
CV_32FC1
);
umatErr
=
_err
.
getUMat
();
}
else
umatErr
.
create
(
_prevPts
.
size
()
,
CV_32FC1
);
umatErr
.
create
(
(
int
)
npoints
,
1
,
CV_32FC1
);
_nextPts
.
create
(
_prevPts
.
size
(),
_prevPts
.
type
());
_status
.
create
(
_prevPts
.
size
(),
CV_8UC1
);
_status
.
create
((
int
)
npoints
,
1
,
CV_8UC1
);
UMat
umatNextPts
=
_nextPts
.
getUMat
();
UMat
umatStatus
=
_status
.
getUMat
();
return
opticalFlow
.
sparse
(
_prevImg
.
getUMat
(),
_nextImg
.
getUMat
(),
_prevPts
.
getUMat
(),
umatNextPts
,
umatStatus
,
umatErr
);
...
...
modules/video/test/ocl/test_optflowpyrlk.cpp
View file @
27fb7e18
...
...
@@ -75,16 +75,19 @@ PARAM_TEST_CASE(PyrLKOpticalFlow, int, int)
OCL_TEST_P
(
PyrLKOpticalFlow
,
Mat
)
{
cv
::
Mat
frame0
=
readImage
(
"optflow/rubberwhale1.png"
,
cv
::
IMREAD_GRAYSCALE
);
static
const
int
npoints
=
1000
;
static
const
float
eps
=
0.03
f
;
cv
::
Mat
frame0
=
readImage
(
"optflow/RubberWhale1.png"
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame0
.
empty
());
UMat
umatFrame0
;
frame0
.
copyTo
(
umatFrame0
);
cv
::
Mat
frame1
=
readImage
(
"optflow/
rubberwhale1
.png"
,
cv
::
IMREAD_GRAYSCALE
);
cv
::
Mat
frame1
=
readImage
(
"optflow/
RubberWhale2
.png"
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame1
.
empty
());
UMat
umatFrame1
;
frame1
.
copyTo
(
umatFrame1
);
std
::
vector
<
cv
::
Point2f
>
pts
;
cv
::
goodFeaturesToTrack
(
frame0
,
pts
,
1000
,
0.01
,
0.0
);
cv
::
goodFeaturesToTrack
(
frame0
,
pts
,
npoints
,
0.01
,
0.0
);
std
::
vector
<
cv
::
Point2f
>
cpuNextPts
;
std
::
vector
<
unsigned
char
>
cpuStatusCPU
;
...
...
@@ -93,9 +96,9 @@ OCL_TEST_P(PyrLKOpticalFlow, Mat)
UMat
umatNextPts
,
umatStatus
,
umatErr
;
OCL_ON
(
cv
::
calcOpticalFlowPyrLK
(
umatFrame0
,
umatFrame1
,
pts
,
umatNextPts
,
umatStatus
,
umatErr
,
winSize
,
maxLevel
,
criteria
,
flags
,
minEigThreshold
));
std
::
vector
<
cv
::
Point2f
>
nextPts
(
umatNextPts
.
cols
);
umatNextPts
.
copyTo
(
nextPts
);
std
::
vector
<
unsigned
char
>
status
;
umatStatus
.
copyTo
(
status
);
std
::
vector
<
float
>
err
;
umatErr
.
copyTo
(
err
);
std
::
vector
<
cv
::
Point2f
>
nextPts
;
umatNextPts
.
reshape
(
2
,
1
)
.
copyTo
(
nextPts
);
std
::
vector
<
unsigned
char
>
status
;
umatStatus
.
reshape
(
1
,
1
).
copyTo
(
status
);
std
::
vector
<
float
>
err
;
umatErr
.
reshape
(
1
,
1
).
copyTo
(
err
);
ASSERT_EQ
(
cpuNextPts
.
size
(),
nextPts
.
size
());
ASSERT_EQ
(
cpuStatusCPU
.
size
(),
status
.
size
());
...
...
@@ -124,7 +127,7 @@ OCL_TEST_P(PyrLKOpticalFlow, Mat)
double
bad_ratio
=
static_cast
<
double
>
(
mistmatch
)
/
(
nextPts
.
size
());
ASSERT_LE
(
bad_ratio
,
0.02
f
);
ASSERT_LE
(
bad_ratio
,
eps
);
}
OCL_INSTANTIATE_TEST_CASE_P
(
Video
,
PyrLKOpticalFlow
,
...
...
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