1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #26875 from asmorkalov:as/in_memory_models

Added trackers factory with pre-loaded dnn models #26875

Replaces https://github.com/opencv/opencv/pull/26295

Allows to substitute custom models or initialize tracker from in-memory model.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Alexander Smorkalov
2025-02-14 15:35:38 +03:00
committed by GitHub
parent a8df0a06ac
commit ae25c3194f
9 changed files with 223 additions and 41 deletions
@@ -46,6 +46,9 @@
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#ifdef HAVE_OPENCV_DNN
# include "opencv2/dnn.hpp"
#endif
namespace cv
{
@@ -826,6 +829,13 @@ public:
static CV_WRAP
Ptr<TrackerGOTURN> create(const TrackerGOTURN::Params& parameters = TrackerGOTURN::Params());
#ifdef HAVE_OPENCV_DNN
/** @brief Constructor
@param model pre-loaded GOTURN model
*/
static CV_WRAP Ptr<TrackerGOTURN> create(const dnn::Net& model);
#endif
//void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE;
//bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE;
};
@@ -853,6 +863,16 @@ public:
static CV_WRAP
Ptr<TrackerDaSiamRPN> create(const TrackerDaSiamRPN::Params& parameters = TrackerDaSiamRPN::Params());
#ifdef HAVE_OPENCV_DNN
/** @brief Constructor
* @param siam_rpn pre-loaded SiamRPN model
* @param kernel_cls1 pre-loaded CLS model
* @param kernel_r1 pre-loaded R1 model
*/
static CV_WRAP
Ptr<TrackerDaSiamRPN> create(const dnn::Net& siam_rpn, const dnn::Net& kernel_cls1, const dnn::Net& kernel_r1);
#endif
/** @brief Return tracking score
*/
CV_WRAP virtual float getTrackingScore() = 0;
@@ -891,6 +911,15 @@ public:
static CV_WRAP
Ptr<TrackerNano> create(const TrackerNano::Params& parameters = TrackerNano::Params());
#ifdef HAVE_OPENCV_DNN
/** @brief Constructor
* @param backbone pre-loaded backbone model
* @param neckhead pre-loaded neckhead model
*/
static CV_WRAP
Ptr<TrackerNano> create(const dnn::Net& backbone, const dnn::Net& neckhead);
#endif
/** @brief Return tracking score
*/
CV_WRAP virtual float getTrackingScore() = 0;
@@ -929,6 +958,18 @@ public:
static CV_WRAP
Ptr<TrackerVit> create(const TrackerVit::Params& parameters = TrackerVit::Params());
#ifdef HAVE_OPENCV_DNN
/** @brief Constructor
* @param model pre-loaded DNN model
* @param meanvalue mean value for image preprocessing
* @param stdvalue std value for image preprocessing
* @param tracking_score_threshold threshold for tracking score
*/
static CV_WRAP
Ptr<TrackerVit> create(const dnn::Net& model, Scalar meanvalue = Scalar(0.485, 0.456, 0.406),
Scalar stdvalue = Scalar(0.229, 0.224, 0.225), float tracking_score_threshold = 0.20f);
#endif
/** @brief Return tracking score
*/
CV_WRAP virtual float getTrackingScore() = 0;