Bayes Filter Explained
In this tutorial I explain the bayes filter from scratch:
Bayes Filter Explained Read More »
In this tutorial I explain the bayes filter from scratch:
Bayes Filter Explained Read More »
The snippet below shows how to computer PCA eigenvectors and eigenvalues (in this case could be interpreted as the moment of inertia).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
#include <pcl/features/moment_of_inertia_estimation.h> #include <pcl/point_cloud.h> #include <pcl/io/pcd_io.h> #include <pcl/visualization/cloud_viewer.h> #include <pcl/io/ply_io.h> template <typename PointT> void computeMomentOfInertia(boost::shared_ptr<pcl::PointCloud<PointT> > cloud_ptr) { pcl::MomentOfInertiaEstimation <PointT> feature_extractor; feature_extractor.setInputCloud (cloud_ptr); feature_extractor.compute (); std::vector <float> moment_of_inertia; std::vector <float> eccentricity; pcl::PointXYZRGB min_point_AABB; pcl::PointXYZRGB max_point_AABB; pcl::PointXYZRGB min_point_OBB; pcl::PointXYZRGB max_point_OBB; pcl::PointXYZRGB position_OBB; Eigen::Matrix3f rotational_matrix_OBB; float major_value, middle_value, minor_value; Eigen::Vector3f major_vector, middle_vector, minor_vector; Eigen::Vector3f mass_center; feature_extractor.getMomentOfInertia (moment_of_inertia); feature_extractor.getEccentricity (eccentricity); feature_extractor.getAABB (min_point_AABB, max_point_AABB); feature_extractor.getOBB (min_point_OBB, max_point_OBB, position_OBB, rotational_matrix_OBB); feature_extractor.getEigenValues (major_value, middle_value, minor_value); feature_extractor.getEigenVectors (major_vector, middle_vector, minor_vector); feature_extractor.getMassCenter (mass_center); boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer")); viewer->setBackgroundColor (0, 0, 0); viewer->addCoordinateSystem (0.1); viewer->initCameraParameters (); pcl::PointXYZ center (mass_center (0), mass_center (1), mass_center (2)); pcl::PointXYZ x_axis (major_vector (0) + mass_center (0), major_vector (1) + mass_center (1), major_vector (2) + mass_center (2)); pcl::PointXYZ y_axis (middle_vector (0) + mass_center (0), middle_vector (1) + mass_center (1), middle_vector (2) + mass_center (2)); pcl::PointXYZ z_axis (minor_vector (0) + mass_center (0), minor_vector (1) + mass_center (1), minor_vector (2) + mass_center (2)); viewer->addLine (center, x_axis, 1.0f, 0.0f, 0.0f, "major eigen vector"); viewer->addLine (center, y_axis, 0.0f, 1.0f, 0.0f, "middle eigen vector"); viewer->addLine (center, z_axis, 0.0f, 0.0f, 1.0f, "minor eigen vector"); viewer->addPointCloud<pcl::PointXYZRGB> (cloud_ptr, "Moment Of Inertia (PCA Eigen Vector Axes)"); while (!viewer->wasStopped ()) { viewer->spinOnce (); } } int main(int argc, char **argv) { pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudrgb_ptr(new pcl::PointCloud<pcl::PointXYZRGB>); pcl::PLYReader PLYFileReader; const int offset=0; PLYFileReader.read< pcl::PointXYZRGB >(argv[1],*cloudrgb_ptr,offset); //pcl::io::loadPCDFile(argv[1],*cloudrgb_ptr); computeMomentOfInertia(cloudrgb_ptr); return 0; } |
Eigenvectors of PCL pointcloud (moment of inertia) Read More »
This ROS package enables you to crop the scene from Kinect (input topic type: PCL pointcloud). You can even enable fitting a plane to remove the ground from the scene and by adjusting correct parameter you can get the desired object from the scene. code available on my Github.
A GUI ROS-package for cropping pcl pointcloud with dynamic reconfigure Read More »
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
/* C1 C2 C3 C4 CV_8U 0 8 16 24 CV_8S 1 9 17 25 CV_16U 2 10 18 26 CV_16S 3 11 19 27 CV_32S 4 12 20 28 CV_32F 5 13 21 29 CV_64F 6 14 22 30 Unsigned 8bits uchar 0~255 IplImage: IPL_DEPTH_8U Mat: CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4 Signed 8bits char -128~127 IplImage: IPL_DEPTH_8S Mat: CV_8SC1,CV_8SC2,CV_8SC3,CV_8SC4 Unsigned 16bits ushort 0~65535 IplImage: IPL_DEPTH_16U Mat: CV_16UC1,CV_16UC2,CV_16UC3,CV_16UC4 Signed 16bits short -32768~32767 IplImage: IPL_DEPTH_16S Mat: CV_16SC1,CV_16SC2,CV_16SC3,CV_16SC4 Signed 32bits int -2147483648~2147483647 IplImage: IPL_DEPTH_32S Mat: CV_32SC1,CV_32SC2,CV_32SC3,CV_32SC4 Float 32bits float -1.18*10-38~3.40*10-38 IplImage: IPL_DEPTH_32F Mat: CV_32FC1,CV_32FC2,CV_32FC3,CV_32FC4 Double 64bits double Mat: CV_64FC1,CV_64FC2,CV_64FC3,CV_64FC4 Unsigned 1bit bool IplImage: IPL_DEPTH_1U */ //example: int number_of_rows, number_of_columns; number_of_rows=3; number_of_columns=4; cv::Mat mat_CV_8U(number_of_rows, number_of_columns,CV_8UC1); std::cout<<"mat_CV_8U.type(): " <<mat_CV_8U.type() <<std::endl; cv::Mat mat_CV_64FC1(number_of_rows, number_of_columns,CV_64FC1); std::cout<<"mat_CV_64FC1.type(): " <<mat_CV_64FC1.type() <<std::endl; |
ref: Special thanks to this post.
List of OpenCv matrix types and mapping numbers Read More »
There are several approaches for estimating the probability distribution function of a given data: 1)Parametric 2)Semi-parametric 3)Non-parametric A parametric one is GMM via algorithm such as expectation maximization. Here is my other post for expectation maximization. Example of Non-parametric is the histogram, where data are assigned to only one bin and depending on the number bins that fall within
Kernel Density Estimation (KDE) for estimating probability distribution function Read More »
Silhouette coefficient is another method to determine the optimal number of clusters. Here I introduced c-index earlier. The silhouette coefficient of a data measures how well data are assigned to its own cluster and how far they are from other clusters. A silhouette close to 1 means the data points are in an appropriate cluster and a silhouette
Silhouette coefficient for finding optimal number of clusters Read More »
This module finds the optimal number of components (number of clusters) for a given dataset. In order to find the optimal number of components for, first we used k-means algorithm with a different number of clusters, starting from 1 to a fixed max number. Then we checked the cluster validity by deploying \( C-index \) algorithm and
Finding optimal number of Clusters by using Cluster validation Read More »
I was looking for a way to create an octomap tree from arbitrary mesh file. Well at first I tried to convert my data into PCL pointcloud and then convert them into an octomap tree. But the problem was, for instance when you a cuboid mesh, you only have 8 vertex, which gives you 8 point and the walls between
How to create octomap tree from mesh Read More »
In this tutorial, I explain the concept, probabilistic sensor fusion model and the sensor model used in Octomap library. related publication: OctoMap: An Efficient Probabilistic 3D Mapping Framework Based on Octrees 1)Octamap Volumetric Model 2)Probabilistic Sensor Fusion Model 3)Sensor Model for Laser Range Data
Octomap explanierend Read More »
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* http://planning.cs.uiuc.edu/node103.html |r11 r12 r13 | |r21 r22 r23 | |r31 r32 r33 | yaw: alpha=arctan(r21/r11) pitch: beta=arctan(-r31/sqrt( r32^2+r33^2 ) ) roll: gamma=arctan(r32/r33) */ double roll, pitch, yaw; roll=M_PI/3; pitch=M_PI/4; yaw=M_PI/6; Eigen::AngleAxisd rollAngle(roll, Eigen::Vector3d::UnitX()); Eigen::AngleAxisd pitchAngle(pitch, Eigen::Vector3d::UnitY()); Eigen::AngleAxisd yawAngle(yaw, Eigen::Vector3d::UnitZ()); Eigen::Quaternion<double> q = yawAngle*pitchAngle *rollAngle; Eigen::Matrix3d rotationMatrix = q.matrix(); std::cout<<"roll is Pi/" <<M_PI/atan2( rotationMatrix(2,1),rotationMatrix(2,2) ) <<std::endl; std::cout<<"pitch: Pi/" <<M_PI/atan2( -rotationMatrix(2,0), std::pow( rotationMatrix(2,1)*rotationMatrix(2,1) +rotationMatrix(2,2)*rotationMatrix(2,2) ,0.5 ) ) <<std::endl; std::cout<<"yaw is Pi/" <<M_PI/atan2( rotationMatrix(1,0),rotationMatrix(0,0) ) <<std::endl; |
Finding roll, pitch yaw from 3X3 rotation matrix with Eigen Read More »