#ifndef OCSORT_H
#define OCSORT_H
#define OCSORT_API __declspec(dllexport)

#include "KalmanBoxTracker.h"
#include "Association.h"
#include "OCSortlapjv.h"
#include <functional>
#include <unordered_map>
#include <chrono>
#include "OCSortObject.h"

namespace ANSOCSort {
    class OCSORT_API OCSort {
    public:
        OCSort();
        void update_parameters(float det_thresh_, int max_age_ = 30, int min_hits_ = 3, float iou_threshold_ = 0.3,
            int delta_t_ = 3, std::string asso_func_ = "iou", float inertia_ = 0.2, bool use_byte_ = false,
            bool autoFrameRate = true);
        float getEstimatedFps() const;
        std::vector<Eigen::RowVectorXf> update(Eigen::MatrixXf dets);
    public:
        float det_thresh;
        int max_age;
        int min_hits;
        float iou_threshold;
        int delta_t;
        std::function<Eigen::MatrixXf(const Eigen::MatrixXf&, const Eigen::MatrixXf&)> asso_func;
        float inertia;
        bool use_byte;
        std::vector<KalmanBoxTracker> trackers;
        int frame_count;

    private:
        // Frame rate auto-estimation
        bool auto_frame_rate_;
        float estimated_fps_;
        float time_scale_factor_;
        size_t fps_sample_count_;
        std::chrono::steady_clock::time_point last_update_time_;
        bool has_last_update_time_;

        void estimateFrameRate();
    };

}
#endif