#include <pcl/filters/statistical_outlier_removal.h>
#include <pcl/filters/extract_indices.h>
inline void RemoveOutliers(std::vector<std::vector<double> > pts, std::vector<std::vector<double> >& pts_out, std::vector<int >& indices)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
cloud->width=pts.size();
cloud->height=1;
cloud->points.resize(cloud->width*cloud->height);
for(int i=0;i<cloud->points.size();i++)
{
cloud->points[i].x=pts[i][0];
cloud->points[i].y=pts[i][1];
cloud->points[i].z=pts[i][2];
}
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);
pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor(true);
sor.setInputCloud (cloud);
sor.setMeanK (50);
sor.setStddevMulThresh (1.0);
sor.filter (*cloud_filtered);
pts_out.resize(cloud_filtered->points.size());
for(int i=0;i<cloud_filtered->points.size();i++)
{
pts_out[i].resize(3);
pts_out[i][0]=cloud_filtered->points[i].x;
pts_out[i][1]=cloud_filtered->points[i].y;
pts_out[i][2]=cloud_filtered->points[i].z;
}
pcl::IndicesConstPtr ind=sor.getRemovedIndices();
pcl::PointIndices::Ptr removed_indices (new pcl::PointIndices());
removed_indices->indices = *ind;
indices.resize(removed_indices->indices.size());
for(int i=0;i<removed_indices->indices.size();i++)
{
indices[i]=removed_indices->indices[i];
}
}
Thursday, August 21, 2014
PCL Remove Outliers
Monday, August 18, 2014
3D rotation matrix composition and decomposition
Decomposition
theta_x=atan2(mat(3,2),mat(3,3));
theta_y=atan2(-mat(3,1),sqrt(mat(3,2)*mat(3,3)));
theta_z=atan2(mat(2,1),mat(1,1));
param=[theta_x,theta_y,theta_z,mat(1,4),mat(2,4),mat(3,4)];
Composition:
T1=cos(y)*cos(z);
T2=cos(z)*sin(x)*sin(y)-cos(x)*sin(z);
T3=cos(x)*cos(z)*sin(y)+sin(x)*sin(z);
T5=cos(y)*sin(z);
T6=cos(x)*cos(z)+sin(x)*sin(y)*sin(z);
T7=-cos(z)*sin(x)+cos(x)*sin(y)*sin(z);
T9=-sin(y);
T10=cos(y)*sin(x);
T11=cos(x)*cos(y);
All in matlab code.
theta_x=atan2(mat(3,2),mat(3,3));
theta_y=atan2(-mat(3,1),sqrt(mat(3,2)*mat(3,3)));
theta_z=atan2(mat(2,1),mat(1,1));
param=[theta_x,theta_y,theta_z,mat(1,4),mat(2,4),mat(3,4)];
Composition:
T1=cos(y)*cos(z);
T2=cos(z)*sin(x)*sin(y)-cos(x)*sin(z);
T3=cos(x)*cos(z)*sin(y)+sin(x)*sin(z);
T5=cos(y)*sin(z);
T6=cos(x)*cos(z)+sin(x)*sin(y)*sin(z);
T7=-cos(z)*sin(x)+cos(x)*sin(y)*sin(z);
T9=-sin(y);
T10=cos(y)*sin(x);
T11=cos(x)*cos(y);
All in matlab code.
Tuesday, August 12, 2014
matlab loop through folder
function [ flag ] = CropAll( folder_name,h )
files=dir(strcat(folder_name,'/*.png'));
for i=1:numel(files)
file_name=files(i).name;
img=imread([folder_name,'/',file_name]);
img2=img(1:h,:,:);
imwrite(img2,[folder_name,'/',file_name]);
end
flag=1;
end
Friday, August 8, 2014
Some matlab expressions (updating)
1. remove columns with all zeros
src(:,all(src==0,1))=[];
2. matlab options:
option=optimset('MaxFunEvals',5000);
src(:,all(src==0,1))=[];
2. matlab options:
option=optimset('MaxFunEvals',5000);
Thursday, August 7, 2014
Some Latex Exceptions
Recently I want to put some manuscript of mine in arXiv. But it only accepts latex versions. So I have to re-compile the latex, and there are some errors when I do this, as I was running it on a clean Linux:
1.
1.
IEEEtran.cls:366: leading text: \normalfont IEEEtran.cls:724: Font OT1/ptm/m/n/5=ptmr7t at 5.0pt not loadable: Metric (TFM)install the recommended fonts to fix the problem:
§ sudo apt-get install texlive-fonts-recommended
2.
Algortihm.sty not found.
Solution: add various algorithm packages by running: sudo apt-get install texlive-science.
Long Equations in Latex
I recently need to solve some nonlinear least square system, and the equations soon become very complex for an A4 page to display.
Of course you can solve it using eqnarray and show it in multiple lines, but it won't work if the equation cannot be separated, such as it is a long fraction.
I resolve this by adding \small before the equations, and add \normalsize after the equations. Actually, there is something else you can use:
Of course you can solve it using eqnarray and show it in multiple lines, but it won't work if the equation cannot be separated, such as it is a long fraction.
I resolve this by adding \small before the equations, and add \normalsize after the equations. Actually, there is something else you can use:
- \tiny
- \scriptsize
- \footnotesize
- \small
- \normalsize
- \large
- \Large
- \LARGE
- \huge
- \Huge
Subscribe to:
Posts (Atom)