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
8d3470b5
Commit
8d3470b5
authored
Jul 27, 2015
by
Vladimir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added optimization to Multi-target TLD update
parent
7dc95a3a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
120 deletions
+61
-120
tracker.hpp
modules/tracking/include/opencv2/tracking/tracker.hpp
+61
-120
multiTracker.cpp
modules/tracking/src/multiTracker.cpp
+0
-0
No files found.
modules/tracking/include/opencv2/tracking/tracker.hpp
View file @
8d3470b5
...
...
@@ -565,7 +565,12 @@ class CV_EXPORTS_W Tracker : public virtual Algorithm
virtual
void
read
(
const
FileNode
&
fn
)
=
0
;
virtual
void
write
(
FileStorage
&
fs
)
const
=
0
;
public
:
Ptr
<
TrackerModel
>
getModel
()
{
return
model
;
}
protected
:
virtual
bool
initImpl
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
)
=
0
;
virtual
bool
updateImpl
(
const
Mat
&
image
,
Rect2d
&
boundingBox
)
=
0
;
...
...
@@ -1206,11 +1211,7 @@ class CV_EXPORTS_W TrackerKCF : public Tracker
- "GRAY" -- Use grayscale values as the feature
- "CN" -- Color-names feature
*/
enum
MODE
{
GRAY
=
(
1u
<<
0
),
CN
=
(
1u
<<
1
),
CUSTOM
=
(
1u
<<
2
)
};
enum
MODE
{
GRAY
,
CN
,
CN2
};
struct
CV_EXPORTS
Params
{
...
...
@@ -1240,156 +1241,96 @@ class CV_EXPORTS_W TrackerKCF : public Tracker
bool
compress_feature
;
//!< activate the pca method to compress the features
int
max_patch_size
;
//!< threshold for the ROI size
int
compressed_size
;
//!< feature size after compression
unsigned
int
desc_pca
;
//!< compressed descriptors of TrackerKCF::MODE
unsigned
int
desc_npca
;
//!< non-compressed descriptors of TrackerKCF::MODE
MODE
descriptor
;
//!< descriptor type
};
virtual
void
setFeatureExtractor
(
void
(
*
)(
const
Mat
,
const
Rect
,
Mat
&
),
bool
pca_func
=
false
);
/** @brief Constructor
@param parameters KCF parameters TrackerKCF::Params
*/
BOILERPLATE_CODE
(
"KCF"
,
TrackerKCF
);
};
/************************************ 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.
*/
/************************************ Multi-Tracker Classes ************************************/
/** @brief Base abstract class for the long-term Multi Object Trackers:
@sa Tracker, MultiTrackerTLD
*/
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
public
:
/** @brief Constructor for Multitracker
*/
MultiTracker
(
const
String
&
trackerType
=
""
);
MultiTracker
()
{
targetNum
=
0
;
}
/**
* \brief Destructor
*/
~
MultiTracker
();
/** @brief Add a new target to a tracking-list and initialize the tracker with a know bounding box that surrounding the target
@param image The initial frame
@param boundingBox The initial boundig box of target
@param tracker_algorithm_name Multi-tracker algorithm name
/**
* \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
@return True if new target initialization went succesfully, false otherwise
*/
bool
add
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
);
bool
addTarget
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
,
String
tracker_algorithm_name
);
/**
* \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 Update all trackers from the tracking-list, find a new most likely bounding boxes for the targets
@param image The current frame
/**
* \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
@return True means that all targets were located and false means that tracker couldn't locate one of the targets in
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
add
(
const
String
&
trackerType
,
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
);
bool
update
(
const
Mat
&
image
);
/**
* \brief Add a set of objects to be tracked using the defaultAlgorithm tracker.
* @param image input image
* @param boundingBox list of the tracked objects
/** @brief Current number of targets in tracking-list
*/
bool
add
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
)
;
int
targetNum
;
/**
* \brief Update the current tracking status.
* The result will be saved in the internal storage.
* @param image input image
/** @brief Trackers list for Multi-Object-Tracker
*/
bool
update
(
const
Mat
&
image
);
//!< storage for the tracked objects, each object corresponds to one tracker algorithm.
std
::
vector
<
Rect2d
>
objects
;
std
::
vector
<
Ptr
<
Tracker
>
>
trackers
;
/**
* \brief Update the current tracking status.
* @param image input image
* @param boundingBox the tracking result, represent a list of ROIs of the tracked objects.
/** @brief Bounding Boxes list for Multi-Object-Tracker
*/
bool
update
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
&
boundingBox
);
protected
:
//!< storage for the tracker algorithms.
std
::
vector
<
Ptr
<
Tracker
>
>
trackerList
;
//!< default algorithm for the tracking method.
String
defaultAlgorithm
;
std
::
vector
<
Rect2d
>
boundingBoxes
;
/** @brief List of randomly generated colors for bounding boxes display
*/
std
::
vector
<
Scalar
>
colors
;
};
class
ROISelector
{
public
:
Rect2d
select
(
Mat
img
,
bool
fromCenter
=
true
);
Rect2d
select
(
const
std
::
string
&
windowName
,
Mat
img
,
bool
showCrossair
=
true
,
bool
fromCenter
=
true
);
void
select
(
const
std
::
string
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
=
true
);
struct
handlerT
{
// basic parameters
bool
isDrawing
;
Rect2d
box
;
Mat
image
;
// parameters for drawing from the center
bool
drawFromCenter
;
Point2f
center
;
// initializer list
handlerT
()
:
isDrawing
(
false
),
drawFromCenter
(
true
)
{};
}
selectorParams
;
// to store the tracked objects
std
::
vector
<
handlerT
>
objects
;
private
:
static
void
mouseHandler
(
int
event
,
int
x
,
int
y
,
int
flags
,
void
*
param
);
void
opencv_mouse_callback
(
int
event
,
int
x
,
int
y
,
int
,
void
*
param
);
// save the keypressed characted
int
key
;
};
/** @brief Multi Object Tracker for TLD. TLD is a novel tracking framework that explicitly decomposes
the long-term tracking task into tracking, learning and detection.
Rect2d
CV_EXPORTS_W
selectROI
(
Mat
img
,
bool
fromCenter
=
true
);
Rect2d
CV_EXPORTS_W
selectROI
(
const
std
::
string
&
windowName
,
Mat
img
,
bool
showCrossair
=
true
,
bool
fromCenter
=
true
);
void
CV_EXPORTS_W
selectROI
(
const
std
::
string
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
=
true
);
The tracker follows the object from frame to frame. The detector localizes all appearances that
have been observed so far and corrects the tracker if necessary. The learning estimates detector’s
errors and updates it to avoid these errors in the future. The implementation is based on @cite TLD .
The Median Flow algorithm (see cv::TrackerMedianFlow) was chosen as a tracking component in this
implementation, following authors. Tracker is supposed to be able to handle rapid motions, partial
occlusions, object absence etc.
/************************************ Multi-Tracker Classes ************************************/
class
CV_EXPORTS_W
MultiTracker_Alt
@sa Tracker, MultiTracker, TrackerTLD
*/
class
CV_EXPORTS_W
MultiTrackerTLD
:
public
MultiTracker
{
public
:
/** @brief Update all trackers from the tracking-list, find a new most likely bounding boxes for the targets by
optimized update method using some techniques to speedup calculations specifically for MO TLD. The only limitation
is that all target bounding boxes should have approximately same aspect ratios. Speed boost is around 20%
bool
addTarget
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
,
char
*
tracker_algorithm_name
);
@param image The current frame.
bool
update
(
const
Mat
&
image
);
int
targetNum
=
0
;
std
::
vector
<
Ptr
<
Tracker
>>
trackers
;
std
::
vector
<
Rect2d
>
boundingBoxes
;
std
::
vector
<
Scalar
>
colors
;
};
class
CV_EXPORTS_W
MultiTrackerTLD
:
public
MultiTracker
{
public
:
bool
update
(
const
Mat
&
image
);
@return True means that all targets were located and false means that tracker couldn't locate one of the targets in
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_opt
(
const
Mat
&
image
);
};
//! @}
}
/* namespace cv */
//! @}
#endif
modules/tracking/src/multiTracker.cpp
View file @
8d3470b5
This diff is collapsed.
Click to expand it.
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