0
$\begingroup$

Rosanswers logo

I'm trying to use kalman filter in ROS with OpenCV library, but I'm getting error.

below is the error that I'm getting while compilation.

error: ‘KalmanFilter’ is not a member of ‘cv’ cv::KalmanFilter kf(stateSize, measSize, contrSize, type); ^ /home/pkumars/catkin_ws/src/cv_bridge_tutorial_pkg/src/kalman_code1.cpp:59:19: error: expected ‘;’ before ‘kf’ cv::KalmanFilter kf(stateSize, measSize, contrSize, type); ^

and here is my code that I'm trying to compile.

// ROS synchronization headers
#include <message_filters/subscriber.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <message_filters/time_synchronizer.h>
// ROS headers
#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <sensor_msgs/PointCloud2.h>
#include <image_transport/image_transport.h>
#include <sensor_msgs/image_encodings.h>
// OpenCV headers
#include <cv_bridge/cv_bridge.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
// c++ headers
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <math.h>  
// pcl headers
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>
#include <boost/foreach.hpp>
#include <pcl/io/pcd_io.h>
// visualization header
#include <visualization_msgs/Marker.h>

// point cloud definition
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;

// standard namespace for c++, ROS messages transport, ROS message filters, OpenCV 
using namespace std;
using namespace sensor_msgs;
using namespace message_filters;
using namespace cv;


// Kalman filter parameters 
int stateSize = 6;          // 6 no of states 
int measSize = 3;           // 3 parameters to be measured 
int contrSize = 0;          // 
unsigned int type = CV_32F; // type 

int main( int argc, char *argv[] )

{

ros::init(argc, argv, "prediction_node");
ros::NodeHandle nh;
ROS_INFO("Starting ");
    
cv::KalmanFilter kf(stateSize, measSize, contrSize, type);

ros::spin();
return 0;

}


Originally posted by PKumars on ROS Answers with karma: 92 on 2016-02-26

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You are already using namespace cv, so you don't have to write cv:: infront of your methods. That won't cause an error, but just nice to know.

The KalmanFilter is in the #include "tracking.hpp", and i can't see that you have included that, so try to do that and see if it still gives an error.

Here is a sample code of how to use it:

https://github.com/Itseez/opencv/blob/master/samples/cpp/kalman.cpp


Originally posted by ros_geller with karma: 92 on 2016-02-26

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by PKumars on 2016-02-26:
it worked. Thanks a lot..

Comment by ros_geller on 2016-02-26:
Please flag it as solved and upvote if the problem is solved ;)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.