OpenCV_4.2.0/opencv_contrib-4.2.0/modules/tracking/samples/samples_utility.hpp

33 lines
921 B
C++
Raw Normal View History

2024-07-25 16:47:56 +08:00
#ifndef _SAMPLES_UTILITY_HPP_
#define _SAMPLES_UTILITY_HPP_
#include <opencv2/tracking.hpp>
inline cv::Ptr<cv::Tracker> createTrackerByName(cv::String name)
{
cv::Ptr<cv::Tracker> tracker;
if (name == "KCF")
tracker = cv::TrackerKCF::create();
else if (name == "TLD")
tracker = cv::TrackerTLD::create();
else if (name == "BOOSTING")
tracker = cv::TrackerBoosting::create();
else if (name == "MEDIAN_FLOW")
tracker = cv::TrackerMedianFlow::create();
else if (name == "MIL")
tracker = cv::TrackerMIL::create();
else if (name == "GOTURN")
tracker = cv::TrackerGOTURN::create();
else if (name == "MOSSE")
tracker = cv::TrackerMOSSE::create();
else if (name == "CSRT")
tracker = cv::TrackerCSRT::create();
else
CV_Error(cv::Error::StsBadArg, "Invalid tracking algorithm name\n");
return tracker;
}
#endif