VINS-mono中图像数据的数据结构

在大概阅读了vins_estimator部分的代码后,被图像数据的各种数据搞的有点懵,所以稍微做一个总结。
1. feature_popints
在feature_tracker_node 的 img_callback()中创建,包含一帧图像中的特征点信息。

sensor_msgs::PointCloudPtr feature_points(new sensor_msgs::PointCloud);
//头信息
feature_points->header = img_msg->header;
feature_points->header.frame_id = "world";
//所有track_cn t> 1 的点
feature_points->points.push_back(p);	
//特征点的id, u, v, 速度 各建一个channel保存
sensor_msgs::ChannelFloat32 id_of_point;
sensor_msgs::ChannelFloat32 u_of_point;
sensor_msgs::ChannelFloat32 v_of_point;
sensor_msgs::ChannelFloat32 velocity_x_of_point;
sensor_msgs::ChannelFloat32 velocity_y_of_point;

2. measuremens
estimator_node.cpp中 process() 线程调用getMeasurements()对IMU和图像数据进行时间对齐后的数据结构。

std::vector<std::pair<std::vector<sensor_msgs::ImuConstPtr>, sensor_msgs::PointCloudConstPtr>> measurements;

3. img_msg
在process()线程中定义的一个变量

 auto img_msg = measurement.second;

4. image
在estimator.cpp中的process()中被建立,在Estimator::processImage()中被调用

作用是建立每个特征点(camera_id,[x,y,z,u,v,vx,vy])构成的map,索引为feature_id

map<int, vector<pair<int, Eigen::Matrix<double, 7, 1>>>> image;

            for (unsigned int i = 0; i < img_msg->points.size(); i++)
            {
                int v = img_msg->channels[0].values[i] + 0.5;
                int feature_id = v / NUM_OF_CAM;
                int camera_id = v % NUM_OF_CAM;
                double x = img_msg->points[i].x;
                double y = img_msg->points[i].y;
                double z = img_msg->points[i].z;
                double p_u = img_msg->channels[1].values[i];
                double p_v = img_msg->channels[2].values[i];
                double velocity_x = img_msg->channels[3].values[i];
                double velocity_y = img_msg->channels[4].values[i];
                ROS_ASSERT(z == 1);
                Eigen::Matrix<double, 7, 1> xyz_uv_velocity;
                xyz_uv_velocity << x, y, z, p_u, p_v, velocity_x, velocity_y;
                image[feature_id].emplace_back(camera_id,  xyz_uv_velocity);
            }
            estimator.processImage(image, img_msg->header);

5. ImageFrame imageframe(image, header.stamp.toSec())
类的成员包括了上面的image也就是特征点的信息,旋转R,平移T,预积分对象和关键帧标志位。

class ImageFrame
{
    public:
        ImageFrame(){};
        ImageFrame(const map<int, vector<pair<int, Eigen::Matrix<double, 7, 1>>>>& _points, double _t):t{_t},is_key_frame{false}
        {
            points = _points;
        };
        map<int, vector<pair<int, Eigen::Matrix<double, 7, 1>> > > points;
        double t;
        Matrix3d R;
        Vector3d T;
        IntegrationBase *pre_integration;
        bool is_key_frame;
};

6. all_image_frame
estimator.h中定义的变量,class Estimator 的成员
键是图像帧的时间戳,值是上面定义的图像帧类

map<double, ImageFrame> all_image_frame;

all_image_frame.insert(make_pair(header.stamp.toSec(), imageframe));

文章参考:https://blog.youkuaiyun.com/qq_41839222/article/details/86030962

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值