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
878ec080
Commit
878ec080
authored
Dec 08, 2015
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3540 from AlexanderUsentsov:good_feature
parents
7172c164
9abdf39c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
275 additions
and
1 deletion
+275
-1
featureselect.cpp
modules/imgproc/src/featureselect.cpp
+10
-1
test_goodfeaturetotrack.cpp
modules/imgproc/test/test_goodfeaturetotrack.cpp
+0
-0
ts.hpp
modules/ts/include/opencv2/ts.hpp
+3
-0
ts_func.cpp
modules/ts/src/ts_func.cpp
+262
-0
No files found.
modules/imgproc/src/featureselect.cpp
View file @
878ec080
...
...
@@ -309,11 +309,18 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
tmpCorners
.
push_back
(
eig_data
+
x
);
}
}
std
::
sort
(
tmpCorners
.
begin
(),
tmpCorners
.
end
(),
greaterThanPtr
()
);
std
::
vector
<
Point2f
>
corners
;
size_t
i
,
j
,
total
=
tmpCorners
.
size
(),
ncorners
=
0
;
if
(
total
==
0
)
{
_corners
.
release
();
return
;
}
std
::
sort
(
tmpCorners
.
begin
(),
tmpCorners
.
end
(),
greaterThanPtr
()
);
if
(
minDistance
>=
1
)
{
// Partition the image into larger grids
...
...
@@ -351,6 +358,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
y2
=
std
::
min
(
grid_height
-
1
,
y2
);
for
(
int
yy
=
y1
;
yy
<=
y2
;
yy
++
)
{
for
(
int
xx
=
x1
;
xx
<=
x2
;
xx
++
)
{
std
::
vector
<
Point2f
>
&
m
=
grid
[
yy
*
grid_width
+
xx
];
...
...
@@ -370,6 +378,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
}
}
}
}
break_out
:
...
...
modules/imgproc/test/test_goodfeaturetotrack.cpp
0 → 100644
View file @
878ec080
This diff is collapsed.
Click to expand it.
modules/ts/include/opencv2/ts.hpp
View file @
878ec080
...
...
@@ -163,6 +163,9 @@ CV_EXPORTS void gemm(const Mat& src1, const Mat& src2, double alpha,
const
Mat
&
src3
,
double
beta
,
Mat
&
dst
,
int
flags
);
CV_EXPORTS
void
transform
(
const
Mat
&
src
,
Mat
&
dst
,
const
Mat
&
transmat
,
const
Mat
&
shift
);
CV_EXPORTS
double
crossCorr
(
const
Mat
&
src1
,
const
Mat
&
src2
);
CV_EXPORTS
void
threshold
(
const
Mat
&
src
,
Mat
&
dst
,
double
thresh
,
double
maxval
,
int
thresh_type
);
CV_EXPORTS
void
minMaxIdx
(
InputArray
_img
,
double
*
minVal
,
double
*
maxVal
,
Point
*
minLoc
,
Point
*
maxLoc
,
InputArray
_mask
);
struct
CV_EXPORTS
MatInfo
{
...
...
modules/ts/src/ts_func.cpp
View file @
878ec080
#include "precomp.hpp"
#include <float.h>
#include <limits.h>
#include "opencv2/imgproc/types_c.h"
#ifdef HAVE_TEGRA_OPTIMIZATION
#include "tegra.hpp"
...
...
@@ -3074,4 +3075,265 @@ void printVersionInfo(bool useStdOut)
#endif
}
void
threshold
(
const
Mat
&
_src
,
Mat
&
_dst
,
double
thresh
,
double
maxval
,
int
thresh_type
)
{
int
i
,
j
;
int
depth
=
_src
.
depth
(),
cn
=
_src
.
channels
();
int
width_n
=
_src
.
cols
*
cn
,
height
=
_src
.
rows
;
int
ithresh
=
cvFloor
(
thresh
);
int
imaxval
,
ithresh2
;
if
(
depth
==
CV_8U
)
{
ithresh2
=
saturate_cast
<
uchar
>
(
ithresh
);
imaxval
=
saturate_cast
<
uchar
>
(
maxval
);
}
else
if
(
depth
==
CV_16S
)
{
ithresh2
=
saturate_cast
<
short
>
(
ithresh
);
imaxval
=
saturate_cast
<
short
>
(
maxval
);
}
else
{
ithresh2
=
cvRound
(
ithresh
);
imaxval
=
cvRound
(
maxval
);
}
assert
(
depth
==
CV_8U
||
depth
==
CV_16S
||
depth
==
CV_32F
);
switch
(
thresh_type
)
{
case
CV_THRESH_BINARY
:
for
(
i
=
0
;
i
<
height
;
i
++
)
{
if
(
depth
==
CV_8U
)
{
const
uchar
*
src
=
_src
.
ptr
<
uchar
>
(
i
);
uchar
*
dst
=
_dst
.
ptr
<
uchar
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
uchar
)(
src
[
j
]
>
ithresh
?
imaxval
:
0
);
}
else
if
(
depth
==
CV_16S
)
{
const
short
*
src
=
_src
.
ptr
<
short
>
(
i
);
short
*
dst
=
_dst
.
ptr
<
short
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
short
)(
src
[
j
]
>
ithresh
?
imaxval
:
0
);
}
else
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
float
)((
double
)
src
[
j
]
>
thresh
?
maxval
:
0.
f
);
}
}
break
;
case
CV_THRESH_BINARY_INV
:
for
(
i
=
0
;
i
<
height
;
i
++
)
{
if
(
depth
==
CV_8U
)
{
const
uchar
*
src
=
_src
.
ptr
<
uchar
>
(
i
);
uchar
*
dst
=
_dst
.
ptr
<
uchar
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
uchar
)(
src
[
j
]
>
ithresh
?
0
:
imaxval
);
}
else
if
(
depth
==
CV_16S
)
{
const
short
*
src
=
_src
.
ptr
<
short
>
(
i
);
short
*
dst
=
_dst
.
ptr
<
short
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
short
)(
src
[
j
]
>
ithresh
?
0
:
imaxval
);
}
else
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
float
)((
double
)
src
[
j
]
>
thresh
?
0.
f
:
maxval
);
}
}
break
;
case
CV_THRESH_TRUNC
:
for
(
i
=
0
;
i
<
height
;
i
++
)
{
if
(
depth
==
CV_8U
)
{
const
uchar
*
src
=
_src
.
ptr
<
uchar
>
(
i
);
uchar
*
dst
=
_dst
.
ptr
<
uchar
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
int
s
=
src
[
j
];
dst
[
j
]
=
(
uchar
)(
s
>
ithresh
?
ithresh2
:
s
);
}
}
else
if
(
depth
==
CV_16S
)
{
const
short
*
src
=
_src
.
ptr
<
short
>
(
i
);
short
*
dst
=
_dst
.
ptr
<
short
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
int
s
=
src
[
j
];
dst
[
j
]
=
(
short
)(
s
>
ithresh
?
ithresh2
:
s
);
}
}
else
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
double
s
=
src
[
j
];
dst
[
j
]
=
(
float
)(
s
>
thresh
?
thresh
:
s
);
}
}
}
break
;
case
CV_THRESH_TOZERO
:
for
(
i
=
0
;
i
<
height
;
i
++
)
{
if
(
depth
==
CV_8U
)
{
const
uchar
*
src
=
_src
.
ptr
<
uchar
>
(
i
);
uchar
*
dst
=
_dst
.
ptr
<
uchar
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
int
s
=
src
[
j
];
dst
[
j
]
=
(
uchar
)(
s
>
ithresh
?
s
:
0
);
}
}
else
if
(
depth
==
CV_16S
)
{
const
short
*
src
=
_src
.
ptr
<
short
>
(
i
);
short
*
dst
=
_dst
.
ptr
<
short
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
int
s
=
src
[
j
];
dst
[
j
]
=
(
short
)(
s
>
ithresh
?
s
:
0
);
}
}
else
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
float
s
=
src
[
j
];
dst
[
j
]
=
s
>
thresh
?
s
:
0.
f
;
}
}
}
break
;
case
CV_THRESH_TOZERO_INV
:
for
(
i
=
0
;
i
<
height
;
i
++
)
{
if
(
depth
==
CV_8U
)
{
const
uchar
*
src
=
_src
.
ptr
<
uchar
>
(
i
);
uchar
*
dst
=
_dst
.
ptr
<
uchar
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
int
s
=
src
[
j
];
dst
[
j
]
=
(
uchar
)(
s
>
ithresh
?
0
:
s
);
}
}
else
if
(
depth
==
CV_16S
)
{
const
short
*
src
=
_src
.
ptr
<
short
>
(
i
);
short
*
dst
=
_dst
.
ptr
<
short
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
int
s
=
src
[
j
];
dst
[
j
]
=
(
short
)(
s
>
ithresh
?
0
:
s
);
}
}
else
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
float
s
=
src
[
j
];
dst
[
j
]
=
s
>
thresh
?
0.
f
:
s
;
}
}
}
break
;
default
:
assert
(
0
);
}
}
static
void
_minMaxIdx
(
const
float
*
src
,
const
uchar
*
mask
,
double
*
_minVal
,
double
*
_maxVal
,
size_t
*
_minIdx
,
size_t
*
_maxIdx
,
int
len
,
size_t
startIdx
)
{
double
minVal
=
FLT_MAX
,
maxVal
=
-
FLT_MAX
;
size_t
minIdx
=
0
,
maxIdx
=
0
;
if
(
!
mask
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
float
val
=
src
[
i
];
if
(
val
<
minVal
)
{
minVal
=
val
;
minIdx
=
startIdx
+
i
;
}
if
(
val
>
maxVal
)
{
maxVal
=
val
;
maxIdx
=
startIdx
+
i
;
}
}
}
else
{
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
float
val
=
src
[
i
];
if
(
mask
[
i
]
&&
val
<
minVal
)
{
minVal
=
val
;
minIdx
=
startIdx
+
i
;
}
if
(
mask
[
i
]
&&
val
>
maxVal
)
{
maxVal
=
val
;
maxIdx
=
startIdx
+
i
;
}
}
}
if
(
_minIdx
)
*
_minIdx
=
minIdx
;
if
(
_maxIdx
)
*
_maxIdx
=
maxIdx
;
if
(
_minVal
)
*
_minVal
=
minVal
;
if
(
_maxVal
)
*
_maxVal
=
maxVal
;
}
void
minMaxIdx
(
InputArray
_img
,
double
*
minVal
,
double
*
maxVal
,
Point
*
minLoc
,
Point
*
maxLoc
,
InputArray
_mask
)
{
Mat
img
=
_img
.
getMat
();
Mat
mask
=
_mask
.
getMat
();
CV_Assert
(
img
.
dims
<=
2
);
_minMaxIdx
((
const
float
*
)
img
.
data
,
mask
.
data
,
minVal
,
maxVal
,
(
size_t
*
)
minLoc
,
(
size_t
*
)
maxLoc
,
(
int
)
img
.
total
(),
1
);
if
(
minLoc
)
std
::
swap
(
minLoc
->
x
,
minLoc
->
y
);
if
(
maxLoc
)
std
::
swap
(
maxLoc
->
x
,
maxLoc
->
y
);
}
}
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