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
eb0c6706
Commit
eb0c6706
authored
Jul 05, 2015
by
Kurnianggoro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
naive implementation of the multi tracker
parent
7aa3e6b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
128 additions
and
2 deletions
+128
-2
tracker.hpp
modules/tracking/include/opencv2/tracking/tracker.hpp
+68
-1
multiTracker.cpp
modules/tracking/src/multiTracker.cpp
+60
-1
No files found.
modules/tracking/include/opencv2/tracking/tracker.hpp
View file @
eb0c6706
...
...
@@ -1245,14 +1245,81 @@ class CV_EXPORTS_W TrackerKCF : public Tracker
//! @}
/************************************ MultiTracker Class ************************************/
/** @brief This class is used to track multiple objects using the specified tracker algorithm.
* The MultiTracker is naive implementation of multiple object tracking.
* It process the tracked objects independently without any optimization accross the tracked objects.
*/
class
CV_EXPORTS_W
MultiTracker
{
public
:
/**
* \brief Constructor.
* 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
=
""
);
/**
* \brief Destructor
*/
~
MultiTracker
();
/**
* \brief Add a new object to be tracked.
* The defaultAlgorithm will be used the newly added tracker.
* @param image input image
* @param boundingBox a rectangle represents ROI of the tracked object
*/
bool
add
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
);
/**
* \brief Add a new object to be tracked.
* @param trackerType the name of the tracker algorithm to be used
* @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
);
/**
* \brief Add a set of objects to be tracked.
* @param trackerType the name of the tracker algorithm to be used
* @param image input image
* @param boundingBox list of the tracked objects
*/
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
);
/**
* \brief Update the current tracking status.
* The result will be saved in the internal storage.
* @param image input image
*/
bool
update
(
const
Mat
&
image
);
//!< storage for the tracked objects, each object corresponds to one tracker algorithm.
std
::
vector
<
Rect2d
>
objects
;
/**
* \brief Update the current tracking status.
* @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
);
protected
:
//!< storage for the tracker algorithms.
std
::
vector
<
Ptr
<
Tracker
>
>
trackerList
;
std
::
vector
<
Rect2d
>
objects
;
//!< default algorithm for the tracking method.
String
defaultAlgorithm
;
};
}
/* namespace cv */
...
...
modules/tracking/src/multiTracker.cpp
View file @
eb0c6706
...
...
@@ -41,21 +41,80 @@
namespace
cv
{
// constructor
MultiTracker
::
MultiTracker
(
const
String
&
trackerType
)
:
defaultAlgorithm
(
trackerType
){};
// destructor
MultiTracker
::~
MultiTracker
(){};
// add an object to be tracked, defaultAlgorithm is used
bool
MultiTracker
::
add
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
){
// quit if defaultAlgorithm has not been configured
if
(
defaultAlgorithm
==
""
){
printf
(
"Default algorithm was not defined!
\n
"
);
return
false
;
}
// add a new tracked object
return
add
(
defaultAlgorithm
.
c_str
(),
image
,
boundingBox
);
};
// add a new tracked object
bool
MultiTracker
::
add
(
const
String
&
trackerType
,
const
Mat
&
image
,
const
Rect2d
&
boundingBox
){
// declare a new tracker
Ptr
<
Tracker
>
newTracker
=
Tracker
::
create
(
trackerType
);
// add the created tracker algorithm to the trackers list
trackerList
.
push_back
(
newTracker
);
// add the ROI to the bounding box list
objects
.
push_back
(
boundingBox
);
// initialize the created tracker
return
trackerList
.
back
()
->
init
(
image
,
boundingBox
);
};
bool
MultiTracker
::
update
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
&
boundingBox
){
// add a set of objects to be tracked
bool
MultiTracker
::
add
(
const
String
&
trackerType
,
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
){
// status of the tracker addition
bool
stat
;
// add tracker for all input objects
for
(
unsigned
i
=
0
;
i
<
boundingBox
.
size
();
i
++
){
stat
=
add
(
trackerType
,
image
,
boundingBox
[
i
]);
if
(
!
stat
)
break
;
}
// return the status
return
stat
;
};
// add a set of object to be tracked, defaultAlgorithm is used.
bool
MultiTracker
::
add
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
){
// quit if defaultAlgorithm has not been configured
if
(
defaultAlgorithm
==
""
){
printf
(
"Default algorithm was not defined!
\n
"
);
return
false
;
}
return
add
(
defaultAlgorithm
.
c_str
(),
image
,
boundingBox
);
};
// update position of the tracked objects, the result is stored in internal storage
bool
MultiTracker
::
update
(
const
Mat
&
image
){
for
(
unsigned
i
=
0
;
i
<
trackerList
.
size
();
i
++
){
trackerList
[
i
]
->
update
(
image
,
objects
[
i
]);
}
return
true
;
};
// update position of the tracked objects, the result is copied to external variable
bool
MultiTracker
::
update
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
&
boundingBox
){
update
(
image
);
boundingBox
=
objects
;
return
true
;
};
}
/* namespace cv */
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