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
941ecd52
Commit
941ecd52
authored
Aug 27, 2015
by
Vladimir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge Fixes #1
parent
bc08607d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
164 additions
and
43 deletions
+164
-43
tracker.hpp
modules/tracking/include/opencv2/tracking/tracker.hpp
+162
-41
multiTracker.cpp
modules/tracking/src/multiTracker.cpp
+2
-2
No files found.
modules/tracking/include/opencv2/tracking/tracker.hpp
View file @
941ecd52
...
...
@@ -1204,53 +1204,173 @@ class CV_EXPORTS_W TrackerTLD : public Tracker
*/
class
CV_EXPORTS_W
TrackerKCF
:
public
Tracker
{
public
:
/**
* \brief Feature type to be used in the tracking grayscale, colornames, compressed color-names
* The modes available now:
- "GRAY" -- Use grayscale values as the feature
- "CN" -- Color-names feature
*/
enum
MODE
{
GRAY
,
CN
,
CN2
};
public
:
/**
* \brief Feature type to be used in the tracking grayscale, colornames, compressed color-names
* The modes available now:
- "GRAY" -- Use grayscale values as the feature
- "CN" -- Color-names feature
*/
enum
MODE
{
GRAY
=
(
1u
<<
0
),
CN
=
(
1u
<<
1
),
CUSTOM
=
(
1u
<<
2
)
};
struct
CV_EXPORTS
Params
{
/**
* \brief Constructor
*/
Params
();
struct
CV_EXPORTS
Params
{
/**
* \brief Constructor
*/
Params
();
/**
* \brief Read parameters from file, currently unused
*/
void
read
(
const
FileNode
&
/*fn*/
);
/**
* \brief Read parameters from file, currently unused
*/
void
write
(
FileStorage
&
/*fs*/
)
const
;
double
sigma
;
//!< gaussian kernel bandwidth
double
lambda
;
//!< regularization
double
interp_factor
;
//!< linear interpolation factor for adaptation
double
output_sigma_factor
;
//!< spatial bandwidth (proportional to target)
double
pca_learning_rate
;
//!< compression learning rate
bool
resize
;
//!< activate the resize feature to improve the processing speed
bool
split_coeff
;
//!< split the training coefficients into two matrices
bool
wrap_kernel
;
//!< wrap around the kernel values
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
};
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
);
};
/**
* \brief Read parameters from file, currently unused
*/
void
read
(
const
FileNode
&
/*fn*/
);
/************************************ MultiTracker Class ---By Laksono Kurnianggoro---) ************************************/
/** @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 Read parameters from file, currently unused
*/
void
write
(
FileStorage
&
/*fs*/
)
const
;
/**
* \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
=
""
);
double
sigma
;
//!< gaussian kernel bandwidth
double
lambda
;
//!< regularization
double
interp_factor
;
//!< linear interpolation factor for adaptation
double
output_sigma_factor
;
//!< spatial bandwidth (proportional to target)
double
pca_learning_rate
;
//!< compression learning rate
bool
resize
;
//!< activate the resize feature to improve the processing speed
bool
split_coeff
;
//!< split the training coefficients into two matrices
bool
wrap_kernel
;
//!< wrap around the kernel values
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
MODE
descriptor
;
//!< descriptor type
};
/**
* \brief Destructor
*/
~
MultiTracker
();
/** @brief Constructor
@param parameters KCF parameters TrackerKCF::Params
*/
BOILERPLATE_CODE
(
"KCF"
,
TrackerKCF
);
/**
* \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
;
//!< default algorithm for the tracking method.
String
defaultAlgorithm
;
};
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
;
};
/************************************ Multi-Tracker Classes ************************************/
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
);
/************************************ Multi-Tracker Classes ---By Tyan Vladimir---************************************/
/** @brief Base abstract class for the long-term Multi Object Trackers:
...
...
@@ -1261,7 +1381,7 @@ class CV_EXPORTS_W MultiTracker_Alt
public
:
/** @brief Constructor for Multitracker
*/
MultiTracker
()
MultiTracker
_Alt
()
{
targetNum
=
0
;
}
...
...
@@ -1277,6 +1397,7 @@ public:
/** @brief Update all trackers from the tracking-list, find a new most likely bounding boxes for the targets
@param image The current frame
@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)
...
...
modules/tracking/src/multiTracker.cpp
View file @
941ecd52
...
...
@@ -44,7 +44,7 @@
namespace
cv
{
//Multitracker
bool
MultiTracker
::
addTarget
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
,
String
tracker_algorithm_name
)
bool
MultiTracker
_Alt
::
addTarget
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
,
String
tracker_algorithm_name
)
{
Ptr
<
Tracker
>
tracker
=
Tracker
::
create
(
tracker_algorithm_name
);
if
(
tracker
==
NULL
)
...
...
@@ -73,7 +73,7 @@ namespace cv
return
true
;
}
bool
MultiTracker
::
update
(
const
Mat
&
image
)
bool
MultiTracker
_Alt
::
update
(
const
Mat
&
image
)
{
for
(
int
i
=
0
;
i
<
(
int
)
trackers
.
size
();
i
++
)
if
(
!
trackers
[
i
]
->
update
(
image
,
boundingBoxes
[
i
]))
...
...
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