Kalman filter of opencv doesnt work in ROS
Hi, im trying to adapt a Kalman filter cpp code to a node cpp in ROS, but in the very beginning, the initialization goes wrong, more precisly, when i try to set the matrices, this is the relevant part of the code.
int stateSize = 4;
int measSize = 2;
int contrSize = 0;
unsigned int type = CV_32F;
cv::KalmanFilter kf(stateSize, measSize, contrSize, type);
cv::Mat state(stateSize, 1, type); // [x,y,v_x,v_y,w,h]
cv::Mat meas(measSize, 1, type);
setIdentity(kf.measurementMatrix);
The compiler shows me the next error:
error: expected constructor, destructor, or type conversion before ‘(’ token
setIdentity(kf.measurementMatrix);
I really have no idea what is happening, because those lines show no problem in the "pure" cpp code. Hope someone can help me, thanks.
EDIT 1:
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <cv_bridge/cv_bridge.h>
#include <geometry_msgs/Twist.h>
#include <std_msgs/Empty.h>
#include <std_msgs/String.h>
#include <sstream>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <stdio.h>
#include <iostream>
#include <cmath>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include <ros/package.h>
#include "opencv2/calib3d/calib3d.hpp"
#include <geometry_msgs/Point.h>
#include <fstream>
#include <opencv2/video/video.hpp>
#include "opencv2/video/tracking.hpp"