Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
bcbbb63b
Commit
bcbbb63b
authored
Nov 10, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #425 from berak:python_tracking
parents
c8053da4
59e9a9ae
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
109 additions
and
43 deletions
+109
-43
CMakeLists.txt
modules/tracking/CMakeLists.txt
+1
-1
onlineMIL.hpp
modules/tracking/include/opencv2/tracking/onlineMIL.hpp
+1
-1
tracker.hpp
modules/tracking/include/opencv2/tracking/tracker.hpp
+37
-37
multitracker.py
modules/tracking/samples/multitracker.py
+35
-0
tracker.py
modules/tracking/samples/tracker.py
+31
-0
roiSelector.cpp
modules/tracking/src/roiSelector.cpp
+4
-4
No files found.
modules/tracking/CMakeLists.txt
View file @
bcbbb63b
set
(
the_description
"Tracking API"
)
ocv_define_module
(
tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_datasets
)
ocv_define_module
(
tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_datasets
WRAP python
)
modules/tracking/include/opencv2/tracking/onlineMIL.hpp
View file @
bcbbb63b
...
...
@@ -58,7 +58,7 @@ namespace cv
class
ClfOnlineStump
;
class
ClfMilBoost
class
C
V_EXPORTS
C
lfMilBoost
{
public
:
struct
CV_EXPORTS
Params
...
...
modules/tracking/include/opencv2/tracking/tracker.hpp
View file @
bcbbb63b
...
...
@@ -74,7 +74,7 @@ namespace cv
/** @brief Abstract base class for TrackerFeature that represents the feature.
*/
class
CV_EXPORTS
_W
TrackerFeature
class
CV_EXPORTS
TrackerFeature
{
public
:
virtual
~
TrackerFeature
();
...
...
@@ -131,7 +131,7 @@ TrackerFeatureSet is an aggregation of TrackerFeature
TrackerFeature
*/
class
CV_EXPORTS
_W
TrackerFeatureSet
class
CV_EXPORTS
TrackerFeatureSet
{
public
:
...
...
@@ -209,7 +209,7 @@ class CV_EXPORTS_W TrackerFeatureSet
/** @brief Abstract base class for TrackerSamplerAlgorithm that represents the algorithm for the specific
sampler.
*/
class
CV_EXPORTS
_W
TrackerSamplerAlgorithm
class
CV_EXPORTS
TrackerSamplerAlgorithm
{
public
:
/**
...
...
@@ -261,7 +261,7 @@ TrackerSampler is an aggregation of TrackerSamplerAlgorithm
@sa
TrackerSamplerAlgorithm
*/
class
CV_EXPORTS
_W
TrackerSampler
class
CV_EXPORTS
TrackerSampler
{
public
:
...
...
@@ -334,7 +334,7 @@ See @cite AAM \f$\hat{x}^{i}_{k}\f$ all the states candidates.
Inherits this class with your Target state, In own implementation you can add scale variation,
width, height, orientation, etc.
*/
class
CV_EXPORTS
_W
TrackerTargetState
class
CV_EXPORTS
TrackerTargetState
{
public
:
virtual
~
TrackerTargetState
()
...
...
@@ -403,7 +403,7 @@ See @cite AAM State estimator
See @cite AMVOT Statistical modeling (Fig. 3), Table III (generative) - IV (discriminative) - V (hybrid)
*/
class
CV_EXPORTS
_W
TrackerStateEstimator
class
CV_EXPORTS
TrackerStateEstimator
{
public
:
virtual
~
TrackerStateEstimator
();
...
...
@@ -449,7 +449,7 @@ See @cite AAM Ak
Inherits this with your TrackerModel
*/
class
CV_EXPORTS
_W
TrackerModel
class
CV_EXPORTS
TrackerModel
{
public
:
...
...
@@ -539,7 +539,7 @@ class CV_EXPORTS_W Tracker : public virtual Algorithm
@return True if initialization went succesfully, false otherwise
*/
bool
init
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
);
CV_WRAP
bool
init
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
);
/** @brief Update the tracker, find the new most likely bounding box for the target
@param image The current frame
...
...
@@ -550,7 +550,7 @@ class CV_EXPORTS_W Tracker : public virtual Algorithm
current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed
missing from the frame (say, out of sight)
*/
bool
update
(
const
Mat
&
image
,
Rect2d
&
boundingBox
);
CV_WRAP
bool
update
(
const
Mat
&
image
,
CV_OUT
Rect2d
&
boundingBox
);
/** @brief Creates a tracker by its name.
@param trackerType Tracker type
...
...
@@ -560,7 +560,7 @@ class CV_EXPORTS_W Tracker : public virtual Algorithm
- "MIL" -- TrackerMIL
- "BOOSTING" -- TrackerBoosting
*/
static
Ptr
<
Tracker
>
create
(
const
String
&
trackerType
);
CV_WRAP
static
Ptr
<
Tracker
>
create
(
const
String
&
trackerType
);
virtual
void
read
(
const
FileNode
&
fn
)
=
0
;
virtual
void
write
(
FileStorage
&
fs
)
const
=
0
;
...
...
@@ -587,7 +587,7 @@ class CV_EXPORTS_W Tracker : public virtual Algorithm
/** @brief TrackerStateEstimator based on Boosting
*/
class
CV_EXPORTS
_W
TrackerStateEstimatorMILBoosting
:
public
TrackerStateEstimator
class
CV_EXPORTS
TrackerStateEstimatorMILBoosting
:
public
TrackerStateEstimator
{
public
:
...
...
@@ -664,7 +664,7 @@ class CV_EXPORTS_W TrackerStateEstimatorMILBoosting : public TrackerStateEstimat
/** @brief TrackerStateEstimatorAdaBoosting based on ADA-Boosting
*/
class
CV_EXPORTS
_W
TrackerStateEstimatorAdaBoosting
:
public
TrackerStateEstimator
class
CV_EXPORTS
TrackerStateEstimatorAdaBoosting
:
public
TrackerStateEstimator
{
public
:
/** @brief Implementation of the target state for TrackerAdaBoostingTargetState
...
...
@@ -774,7 +774,7 @@ class CV_EXPORTS_W TrackerStateEstimatorAdaBoosting : public TrackerStateEstimat
/**
* \brief TrackerStateEstimator based on SVM
*/
class
CV_EXPORTS
_W
TrackerStateEstimatorSVM
:
public
TrackerStateEstimator
class
CV_EXPORTS
TrackerStateEstimatorSVM
:
public
TrackerStateEstimator
{
public
:
TrackerStateEstimatorSVM
();
...
...
@@ -789,7 +789,7 @@ class CV_EXPORTS_W TrackerStateEstimatorSVM : public TrackerStateEstimator
/** @brief TrackerSampler based on CSC (current state centered), used by MIL algorithm TrackerMIL
*/
class
CV_EXPORTS
_W
TrackerSamplerCSC
:
public
TrackerSamplerAlgorithm
class
CV_EXPORTS
TrackerSamplerCSC
:
public
TrackerSamplerAlgorithm
{
public
:
enum
...
...
@@ -847,7 +847,7 @@ class CV_EXPORTS_W TrackerSamplerCSC : public TrackerSamplerAlgorithm
/** @brief TrackerSampler based on CS (current state), used by algorithm TrackerBoosting
*/
class
CV_EXPORTS
_W
TrackerSamplerCS
:
public
TrackerSamplerAlgorithm
class
CV_EXPORTS
TrackerSamplerCS
:
public
TrackerSamplerAlgorithm
{
public
:
enum
...
...
@@ -914,7 +914,7 @@ It should be noted, that the definition of "similarity" between two rectangles i
their histograms. As experiments show, tracker is *not* very succesfull if target is assumed to
strongly change its dimensions.
*/
class
CV_EXPORTS
_W
TrackerSamplerPF
:
public
TrackerSamplerAlgorithm
class
CV_EXPORTS
TrackerSamplerPF
:
public
TrackerSamplerAlgorithm
{
public
:
/** @brief This structure contains all the parameters that can be varied during the course of sampling
...
...
@@ -949,7 +949,7 @@ private:
/**
* \brief TrackerFeature based on Feature2D
*/
class
CV_EXPORTS
_W
TrackerFeatureFeature2d
:
public
TrackerFeature
class
CV_EXPORTS
TrackerFeatureFeature2d
:
public
TrackerFeature
{
public
:
...
...
@@ -976,7 +976,7 @@ class CV_EXPORTS_W TrackerFeatureFeature2d : public TrackerFeature
/**
* \brief TrackerFeature based on HOG
*/
class
CV_EXPORTS
_W
TrackerFeatureHOG
:
public
TrackerFeature
class
CV_EXPORTS
TrackerFeatureHOG
:
public
TrackerFeature
{
public
:
...
...
@@ -995,7 +995,7 @@ class CV_EXPORTS_W TrackerFeatureHOG : public TrackerFeature
/** @brief TrackerFeature based on HAAR features, used by TrackerMIL and many others algorithms
@note HAAR features implementation is copied from apps/traincascade and modified according to MIL
*/
class
CV_EXPORTS
_W
TrackerFeatureHAAR
:
public
TrackerFeature
class
CV_EXPORTS
TrackerFeatureHAAR
:
public
TrackerFeature
{
public
:
struct
CV_EXPORTS
Params
...
...
@@ -1057,7 +1057,7 @@ class CV_EXPORTS_W TrackerFeatureHAAR : public TrackerFeature
/**
* \brief TrackerFeature based on LBP
*/
class
CV_EXPORTS
_W
TrackerFeatureLBP
:
public
TrackerFeature
class
CV_EXPORTS
TrackerFeatureLBP
:
public
TrackerFeature
{
public
:
...
...
@@ -1083,7 +1083,7 @@ based on @cite MIL .
Original code can be found here <http://vision.ucsd.edu/~bbabenko/project_miltrack.shtml>
*/
class
CV_EXPORTS
_W
TrackerMIL
:
public
Tracker
class
CV_EXPORTS
TrackerMIL
:
public
Tracker
{
public
:
struct
CV_EXPORTS
Params
...
...
@@ -1113,7 +1113,7 @@ class CV_EXPORTS_W TrackerMIL : public Tracker
The classifier uses the surrounding background as negative examples in update step to avoid the
drifting problem. The implementation is based on @cite OLB .
*/
class
CV_EXPORTS
_W
TrackerBoosting
:
public
Tracker
class
CV_EXPORTS
TrackerBoosting
:
public
Tracker
{
public
:
struct
CV_EXPORTS
Params
...
...
@@ -1151,7 +1151,7 @@ by authors to outperform MIL). During the implementation period the code at
<http://www.aonsquared.co.uk/node/5>, the courtesy of the author Arthur Amarra, was used for the
reference purpose.
*/
class
CV_EXPORTS
_W
TrackerMedianFlow
:
public
Tracker
class
CV_EXPORTS
TrackerMedianFlow
:
public
Tracker
{
public
:
struct
CV_EXPORTS
Params
...
...
@@ -1180,7 +1180,7 @@ The Median Flow algorithm (see cv::TrackerMedianFlow) was chosen as a tracking c
implementation, following authors. Tracker is supposed to be able to handle rapid motions, partial
occlusions, object absence etc.
*/
class
CV_EXPORTS
_W
TrackerTLD
:
public
Tracker
class
CV_EXPORTS
TrackerTLD
:
public
Tracker
{
public
:
struct
CV_EXPORTS
Params
...
...
@@ -1202,7 +1202,7 @@ class CV_EXPORTS_W TrackerTLD : public Tracker
* as well as the matlab implementation. For more information about KCF with color-names features, please refer to
* <http://www.cvl.isy.liu.se/research/objrec/visualtracking/colvistrack/index.html>.
*/
class
CV_EXPORTS
_W
TrackerKCF
:
public
Tracker
class
CV_EXPORTS
TrackerKCF
:
public
Tracker
{
public
:
/**
...
...
@@ -1271,7 +1271,7 @@ public:
* In the case of trackerType is given, it will be set as the default algorithm for all trackers.
* @param trackerType the name of the tracker algorithm to be used
*/
MultiTracker
(
const
String
&
trackerType
=
""
);
CV_WRAP
MultiTracker
(
const
String
&
trackerType
=
""
);
/**
* \brief Destructor
...
...
@@ -1284,7 +1284,7 @@ public:
* @param image input image
* @param boundingBox a rectangle represents ROI of the tracked object
*/
bool
add
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
);
CV_WRAP
bool
add
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
);
/**
* \brief Add a new object to be tracked.
...
...
@@ -1292,7 +1292,7 @@ public:
* @param image input image
* @param boundingBox a rectangle represents ROI of the tracked object
*/
bool
add
(
const
String
&
trackerType
,
const
Mat
&
image
,
const
Rect2d
&
boundingBox
);
CV_WRAP
bool
add
(
const
String
&
trackerType
,
const
Mat
&
image
,
const
Rect2d
&
boundingBox
);
/**
* \brief Add a set of objects to be tracked.
...
...
@@ -1300,14 +1300,14 @@ public:
* @param image input image
* @param boundingBox list of the tracked objects
*/
bool
add
(
const
String
&
trackerType
,
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
);
CV_WRAP
bool
add
(
const
String
&
trackerType
,
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
);
/**
* \brief Add a set of objects to be tracked using the defaultAlgorithm tracker.
* @param image input image
* @param boundingBox list of the tracked objects
*/
bool
add
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
);
CV_WRAP
bool
add
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
);
/**
* \brief Update the current tracking status.
...
...
@@ -1324,7 +1324,7 @@ public:
* @param image input image
* @param boundingBox the tracking result, represent a list of ROIs of the tracked objects.
*/
bool
update
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
&
boundingBox
);
CV_WRAP
bool
update
(
const
Mat
&
image
,
CV_OUT
std
::
vector
<
Rect2d
>
&
boundingBox
);
protected
:
//!< storage for the tracker algorithms.
...
...
@@ -1337,8 +1337,8 @@ protected:
class
ROISelector
{
public
:
Rect2d
select
(
Mat
img
,
bool
fromCenter
=
true
);
Rect2d
select
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
bool
showCrossair
=
true
,
bool
fromCenter
=
true
);
void
select
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
=
true
);
Rect2d
select
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
bool
showCrossair
=
true
,
bool
fromCenter
=
true
);
void
select
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
=
true
);
struct
handlerT
{
// basic parameters
...
...
@@ -1366,8 +1366,8 @@ private:
};
Rect2d
CV_EXPORTS_W
selectROI
(
Mat
img
,
bool
fromCenter
=
true
);
Rect2d
CV_EXPORTS_W
selectROI
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
bool
showCrossair
=
true
,
bool
fromCenter
=
true
);
void
CV_EXPORTS_W
selectROI
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
=
true
);
Rect2d
CV_EXPORTS_W
selectROI
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
bool
showCrossair
=
true
,
bool
fromCenter
=
true
);
void
CV_EXPORTS_W
selectROI
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
=
true
);
/************************************ Multi-Tracker Classes ---By Tyan Vladimir---************************************/
...
...
@@ -1376,7 +1376,7 @@ void CV_EXPORTS_W selectROI(const std::string& windowName, Mat img, std::vector<
@sa Tracker, MultiTrackerTLD
*/
class
CV_EXPORTS
_W
MultiTracker_Alt
class
CV_EXPORTS
MultiTracker_Alt
{
public
:
/** @brief Constructor for Multitracker
...
...
@@ -1433,7 +1433,7 @@ occlusions, object absence etc.
@sa Tracker, MultiTracker, TrackerTLD
*/
class
CV_EXPORTS
_W
MultiTrackerTLD
:
public
MultiTracker_Alt
class
CV_EXPORTS
MultiTrackerTLD
:
public
MultiTracker_Alt
{
public
:
/** @brief Update all trackers from the tracking-list, find a new most likely bounding boxes for the targets by
...
...
modules/tracking/samples/multitracker.py
0 → 100644
View file @
bcbbb63b
import
numpy
as
np
import
cv2
cv2
.
namedWindow
(
"tracking"
)
camera
=
cv2
.
VideoCapture
(
"E:/code/opencv/samples/data/768x576.avi"
)
tracker
=
cv2
.
MultiTracker
(
"MIL"
)
bbox1
=
(
638.0
,
230.0
,
56.0
,
101.0
)
bbox2
=
(
240.0
,
210.0
,
60.0
,
104.0
)
bbox3
=
(
486.0
,
149.0
,
54.0
,
83.0
)
init_once
=
False
while
camera
.
isOpened
():
ok
,
image
=
camera
.
read
()
if
not
ok
:
print
'no image read'
break
if
not
init_once
:
# add a list of boxes:
ok
=
tracker
.
add
(
image
,
(
bbox1
,
bbox2
))
# or add single box:
ok
=
tracker
.
add
(
image
,
bbox3
)
init_once
=
True
ok
,
boxes
=
tracker
.
update
(
image
)
print
ok
,
boxes
for
newbox
in
boxes
:
p1
=
(
int
(
newbox
[
0
]),
int
(
newbox
[
1
]))
p2
=
(
int
(
newbox
[
0
]
+
newbox
[
2
]),
int
(
newbox
[
1
]
+
newbox
[
3
]))
cv2
.
rectangle
(
image
,
p1
,
p2
,
(
200
,
0
,
0
))
cv2
.
imshow
(
"tracking"
,
image
)
k
=
cv2
.
waitKey
(
1
)
&
0xff
if
k
==
27
:
break
# esc pressed
modules/tracking/samples/tracker.py
0 → 100644
View file @
bcbbb63b
import
numpy
as
np
import
cv2
cv2
.
namedWindow
(
"tracking"
)
camera
=
cv2
.
VideoCapture
(
"E:/code/opencv/samples/data/768x576.avi"
)
bbox
=
(
638.0
,
230.0
,
56.0
,
101.0
)
tracker
=
cv2
.
Tracker_create
(
"MIL"
)
init_once
=
False
while
camera
.
isOpened
():
ok
,
image
=
camera
.
read
()
if
not
ok
:
print
'no image read'
break
if
not
init_once
:
ok
=
tracker
.
init
(
image
,
bbox
)
init_once
=
True
ok
,
newbox
=
tracker
.
update
(
image
)
print
ok
,
newbox
if
ok
:
p1
=
(
int
(
newbox
[
0
]),
int
(
newbox
[
1
]))
p2
=
(
int
(
newbox
[
0
]
+
newbox
[
2
]),
int
(
newbox
[
1
]
+
newbox
[
3
]))
cv2
.
rectangle
(
image
,
p1
,
p2
,
(
200
,
0
,
0
))
cv2
.
imshow
(
"tracking"
,
image
)
k
=
cv2
.
waitKey
(
1
)
&
0xff
if
k
==
27
:
break
# esc pressed
\ No newline at end of file
modules/tracking/src/roiSelector.cpp
View file @
bcbbb63b
...
...
@@ -91,7 +91,7 @@ namespace cv {
return
select
(
"ROI selector"
,
img
,
fromCenter
);
}
Rect2d
ROISelector
::
select
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
bool
showCrossair
,
bool
fromCenter
){
Rect2d
ROISelector
::
select
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
bool
showCrossair
,
bool
fromCenter
){
key
=
0
;
...
...
@@ -149,7 +149,7 @@ namespace cv {
return
selectorParams
.
box
;
}
void
ROISelector
::
select
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
){
void
ROISelector
::
select
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
){
std
::
vector
<
Rect2d
>
box
;
Rect2d
temp
;
key
=
0
;
...
...
@@ -172,12 +172,12 @@ namespace cv {
return
_selector
.
select
(
"ROI selector"
,
img
,
true
,
fromCenter
);
};
Rect2d
selectROI
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
bool
showCrossair
,
bool
fromCenter
){
Rect2d
selectROI
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
bool
showCrossair
,
bool
fromCenter
){
printf
(
"Select an object to track and then press SPACE or ENTER button!
\n
"
);
return
_selector
.
select
(
windowName
,
img
,
showCrossair
,
fromCenter
);
};
void
selectROI
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
){
void
selectROI
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
){
return
_selector
.
select
(
windowName
,
img
,
boundingBox
,
fromCenter
);
}
...
...
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