yzrobot / online_learning

[ROS package] Online Learning for Human Detection in 3D Point Clouds
GNU General Public License v3.0
152 stars 70 forks source link

Is the CovarianceMatrix in Get3ZoneCovarianceMatrix should be 2D or 3D? #20

Closed RussellGee closed 8 months ago

RussellGee commented 3 years ago

Thank you for your work in advance. There are some questions about the feature 5 source code in the file of online_learning/object3d_detector/src/object3d_detector.cpp . In the function Get3ZoneCovarianceMatrix, cov-matrix shape is 3x3, the elements used is (0,1) (0,2) and (1,2). Since cov-matrix is symmetric, there are nine unique elements, why did you only use (0,1) (0,2) and (1,2). For my sample, cov-matrix elements are all valid, none of them is near to zero. In addtion, feature 5 is from the paper "Pedestrian Detection and Tracking Using Three-Dimensional LADAR Data". As description of the feature, the cov-matrix is 2D. Then i am confusion. May i have you explain about the difference. Thank you

yzrobot commented 3 years ago

Hi, which function are you referring to? compute3ZoneCovarianceMatrix or computeMomentOfInertiaTensorNormalized

RussellGee commented 3 years ago

refer to the function compute3ZoneCovarianceMatrix. Sorry, i make some error before, the elements used are as fellows: partial_covariance_2d[i3+0] = covariance(0,0); partial_covariance_2d[i3+1] = covariance(0,1); partial_covariance_2d[i*3+2] = covariance(1,1);

yzrobot commented 3 years ago

So I guess you refer to this block?

  Eigen::Matrix3f covariance;
  Eigen::Vector4f centroid;
  for(int i = 0; i < 3; i++) {
    pcl::compute3DCentroid(*zone_decomposed[i], centroid);
    pcl::computeCovarianceMatrix(*zone_decomposed[i], centroid, covariance);
    partial_covariance_2d[i*3+0] = covariance(0,0);
    partial_covariance_2d[i*3+1] = covariance(0,1);
    partial_covariance_2d[i*3+2] = covariance(1,1);
  }

As the original paper said These zones are the upper half, and the left and right lower halves. After separating the points into these zones, we calculate the covariance matrix (in 2D) over the transformed points laying inside each zone.This results in 9 additional features (3 unique values from each zone).

RussellGee commented 3 years ago

Hi, Yan, @yzrobot, thank you for your reply first. May i have your explanation of why have you chosed 3D cov-matirx, not the 2D cov-matirx(the original paper said). In addition, I have doubt about that "whether two cov-matirxs are equivalent if the eigenvectors and eigenvlaues are equal responding or not". I appreciate your help, looking forward your replay.

RussellGee commented 3 years ago

Then, I take a test, in the following block:

computeProjectedPlane(pc, pca.getEigenVectors(), 2, centroid, main_plane);
compute3ZoneCovarianceMatrix(main_plane, pca.getMean(), f.partial_covariance_2d);

The cov-matrix from the upper zone from "main_plane" is defined as main_plane_upper_cov_matrix. As the original paper said "we calculate the covariance matrix (in 2D) over the transformed points laying inside each zone", i conduct PCA process on "main_plane".

    computeProjectedPlane(pc, pca.getEigenVectors(), 2, centroid, main_plane);

    pcl::PCA<pcl::PointXYZI> main_plane_pca;
    pcl::PointCloud<pcl::PointXYZI>::Ptr main_plane_projected(new pcl::PointCloud<pcl::PointXYZI>);
    main_plane_pca.setInputCloud(main_plane);
    main_plane_pca.project(*main_plane, *main_plane_projected);

    pcl::PCA<pcl::PointXYZI> main_plane_pca_for_3zone;
    pcl::PointCloud<pcl::PointXYZI>::Ptr main_plane_pc_projected_(new pcl::PointCloud<pcl::PointXYZI>);
    main_plane_pca_for_3zone.setInputCloud(main_plane_pc_projected);
    main_plane_pca_for_3zone.project(*main_plane_pc_projected, *main_plane_pc_projected_);

    compute3ZoneCovarianceMatrix(main_plane_pc_projected, main_plane_pca_for_3zone.getMean(), f.partial_covariance_2d);

The cov-matrix from the upper zone from "main_plane_pc_projected" is defined as main_plane_prj_upper_cov_matrix. I found that the eigenvalues of main_plane_upper_cov_matrix is same to main_plane_prj_upper_cov_matrix. Then main_plane_upper_cov_matrix and main_plane_prj_upper_cov_matrix is similar matrix.

But i still do not understand why have you chose(0,0),(0,1),(1,1)elements of main_plane_upper_cov_matrix.How do you ensure that main_plane_upper_cov_matrix only have 3 unique elements.

Finally, i wonder that why papers chose cov-matrix as the feature of points in 3 zone. I have known that cov-matrix is the key of PCA analysis and PCA analysis is the common way for data analysis.

And as the original paper said that

We focus on the points included in the main plane, to analyze the ### patterns that would correspond to the legs and trunk of a pedestrian, as shown in Fig 3, center top. These zones are the upper half, and the left and right lower halves. After separating the points into these zones, we calculate the covariance matrix (in 2D) over the transformed points laying inside each zone. This results in 9 additional features (3 unique values from each zone)

How does cov-matrix represent the "patterns" of these zones. Is there any papers or blogs explain this. Looking forward your replay.

yzrobot commented 3 years ago

Hi, the implementation was followed the original paper Sec. 3.3.1 and the source code of pcl::compute3DCentroid and pcl::computeCovarianceMatrix, and I think the original text and code could help you understand. Cheers.

RussellGee commented 3 years ago

Thank you for your replay. I have know that cov-matrix represent the correlation between variables which similar to variance。Thank you again.