Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
RussellGee opened this issue Jan 8, 2021 · 7 comments

Comments

@RussellGee
Copy link

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
Copy link
Owner

yzrobot commented Jan 8, 2021

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

@RussellGee
Copy link
Author

RussellGee commented Jan 8, 2021

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[i
3+1] = covariance(0,1);
partial_covariance_2d[i*3+2] = covariance(1,1);

@yzrobot
Copy link
Owner

yzrobot commented Jan 8, 2021

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
Copy link
Author

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
Copy link
Author

RussellGee commented Jan 11, 2021

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
Copy link
Owner

yzrobot commented Jan 11, 2021

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
Copy link
Author

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

@yzrobot yzrobot closed this as completed Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants