Commit 941ecd52 authored by Vladimir's avatar Vladimir

Merge Fixes #1

parent bc08607d
......@@ -1204,14 +1204,18 @@ class CV_EXPORTS_W TrackerTLD : public Tracker
*/
class CV_EXPORTS_W TrackerKCF : public Tracker
{
public:
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};
enum MODE {
GRAY = (1u << 0),
CN = (1u << 1),
CUSTOM = (1u << 2)
};
struct CV_EXPORTS Params
{
......@@ -1223,12 +1227,12 @@ class CV_EXPORTS_W TrackerKCF : public Tracker
/**
* \brief Read parameters from file, currently unused
*/
void read( const FileNode& /*fn*/ );
void read(const FileNode& /*fn*/);
/**
* \brief Read parameters from file, currently unused
*/
void write( FileStorage& /*fs*/ ) const;
void write(FileStorage& /*fs*/) const;
double sigma; //!< gaussian kernel bandwidth
double lambda; //!< regularization
......@@ -1241,16 +1245,132 @@ 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
MODE descriptor; //!< descriptor type
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);
BOILERPLATE_CODE("KCF", TrackerKCF);
};
/************************************ 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 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;
//!< default algorithm for the tracking method.
String defaultAlgorithm;
};
/************************************ Multi-Tracker Classes ************************************/
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;
};
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)
......
......@@ -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]))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment