24 jevois::Component(instance), itsKF(6, 4, 0), itsProcessNoise(6, 1, CV_32F),
25 itsMeasurement(4, 1, CV_32F), itsLatest(4, 1, CV_32F), itsFresh(false)
27 cv::setIdentity(
itsKF.measurementMatrix);
37 itsKF.statePost.at<
float>(0) = 0.0F;
38 itsKF.statePost.at<
float>(1) = 0.0F;
39 itsKF.statePost.at<
float>(2) = 1.0F;
40 itsKF.statePost.at<
float>(3) = 1.0F;
41 itsKF.statePost.at<
float>(4) = 0.0F;
42 itsKF.statePost.at<
float>(5) = 0.0F;
52 itsKF.transitionMatrix = (cv::Mat_<float>(6, 6) <<
61 itsKF.transitionMatrix = (cv::Mat_<float>(6, 6) <<
74 float constexpr e = 0.01F;
75 float const n = newval * newval;
76 itsKF.processNoiseCov = (cv::Mat_<float>(6, 6) <<
88 cv::setIdentity(
itsKF.measurementNoiseCov, cv::Scalar::all(newval * newval));
94 cv::setIdentity(
itsKF.errorCovPost, cv::Scalar::all(newval * newval));
107void Kalman4D::set(
float x,
float y,
float w,
float h,
unsigned int imgwidth,
unsigned int imgheight)
111 this->
set(x, y, w,
h);
115void Kalman4D::get(
float & x,
float & y,
float & w,
float & h,
float const eps)
142 x = std::round(x / eps) * eps;
143 y = std::round(y / eps) * eps;
144 w = std::round(w / eps) * eps;
145 h = std::round(
h / eps) * eps;
150void Kalman4D::get(
float & x,
float & y,
float & w,
float & h,
unsigned int imgwidth,
151 unsigned int imgheight,
float const eps)
153 this->
get(x, y, w,
h, 0.0F);
159void Kalman4D::get(
float & rawx,
float & rawy,
float & raww,
float & rawh,
float & imgx,
float & imgy,
160 float & imgw,
float & imgh,
unsigned int imgwidth,
unsigned int imgheight,
161 float const raweps,
float const imgeps)
164 this->
get(rawx, rawy, raww, rawh, 0.0F);
173 rawx = std::round(rawx / raweps) * raweps;
174 rawy = std::round(rawy / raweps) * raweps;
175 raww = std::round(raww / raweps) * raweps;
176 rawh = std::round(rawh / raweps) * raweps;
186{
return itsKF.errorCovPost; }
#define JEVOIS_UNUSED_PARAM(x)
virtual ~Kalman4D()
Destructor.
Kalman4D(std::string const &instance)
Constructor.
void get(float &x, float &y, float &w, float &h, float const eps=0.01F)
Function to call each time you want to get the Kalman-filtered coordinates.
void onParamChange(kalman4d::usevel const ¶m, bool const &newval) override
void set(float x, float y, float w, float h)
Function to call each time you have a new measurement (output from a vision algorithm)
cv::Mat const & getErrorCov() const
Get the latest error covariance matrix (errorCovPost). It is updated after each get() or set()
void stdToImg(float &x, float &y, RawImage const &camimg, float const eps=0.1F)
void imgToStd(float &x, float &y, RawImage const &camimg, float const eps=0.1F)
void imgToStdSize(float &w, float &h, unsigned int const width, unsigned int const height, float const eps=0.1F)
void stdToImgSize(float &x, float &y, unsigned int const width, unsigned int const height, float const eps=0.1F)