#ifndef RUNE_FIT_HPP_ #define RUNE_FIT_HPP_ // OpenCV #include #include #include // STD #include #include namespace rm_power_rune { struct SpeedfitResidual { SpeedfitResidual(double x, double y) : t_(x), speed_(y) {} template bool operator()(const T *const param, T *residual) const { //param[0]->a 0.78-1.045 //param[1]->w 1.884-2 //b= 2.090-a residual[0] = T(speed_) - (param[0] * ceres::sin(param[1] * T(t_)+param[2]) + (2.090 - param[0])); return true; } private: // Observations for a sample. const double t_; const double speed_; }; class rune_fitter { private: std::vector t_data_,speed_data_; double curve_param_[3]={0.78,1.884,0}; int fitdataCount_; //拟合数据个数 bool fit_flag; public: rune_fitter(int data_count); ~rune_fitter(); bool add_data(double t,double speed); bool fit_speed(); bool is_data_enough(); bool is_fitted(); void draw_result(); void draw_result_matplot(); }; } // namespace rm_power_rune #endif