Skip to content

Commit

Permalink
added bool for wood-leaf separation in segmentcrown + updated for new…
Browse files Browse the repository at this point in the history
… tiling & naming
  • Loading branch information
apburt committed Mar 31, 2020
1 parent abc843a commit 4ff8332
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Below is an example usage of the treeseg binaries:
* findstems 15 0.2 2 ../FGC01_coords.dat ../FGC01.slice.pcd
* segmentstem 12.5 ../clusters/FGC01.cluster.*.pcd ../FGC01.tile.downsample.*.pcd
* getcrownvolume ../stems/FGC01.stem.*.pcd ../FGC01.tile.downsample.*.pcd
* segmentcrown [14 - 16] ../FGC01.volume.*.pcd
* segmentcrown [14 - 16] 0 ../FGC01.volume.*.pcd

## Authors

Expand Down
99 changes: 52 additions & 47 deletions src/segmentcrown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ int main (int argc, char* argv[])
pcl::PCDReader reader;
pcl::PCDWriter writer;
std::stringstream ss;
for(int i=2;i<argc;i++)
bool sepwoodleaf = atoi(argv[2]);
for(int i=3;i<argc;i++)
{
std::cout << "----------: " << argv[i] << std::endl;
std::cout << "Reading volume cloud: " << std::flush;
Expand All @@ -28,7 +29,7 @@ int main (int argc, char* argv[])
std::vector<pcl::PointCloud<PointTreeseg>::Ptr> clusters;
euclideanClustering(volume,nnmax,3,clusters);
ss.str("");
ss << "ec_" << id[0] << ".pcd";
ss << id[0] << ".ec." << id[1] << ".pcd";
writeClouds(clusters,ss.str(),false);
std::cout << ss.str() << std::endl;
//
Expand All @@ -40,65 +41,69 @@ int main (int argc, char* argv[])
float smoothness = atof(argv[1]);
regionSegmentation(clusters[idx],nnearest,nmin,smoothness,regions);
ss.str("");
ss << "ec_rg_" << id[0] << ".pcd";
ss << id[0] << ".ec.rg." << id[1] << ".pcd";
writeClouds(regions,ss.str(),false);
std::cout << ss.str() << std::endl;
//
std::cout << "Leaf stripping: " << std::endl;
//
std::cout << " Region-wise, " << std::flush;
arma::mat rfmat;
arma::gmm_full rmodel;
gmmByCluster(regions,5,1,5,50,100,rfmat,rmodel);
std::vector<int> rclassifications;
rclassifications = classifyGmmClusterModel(regions,5,rfmat,rmodel);
std::vector<pcl::PointCloud<PointTreeseg>::Ptr> csepclouds;
separateCloudsClassifiedByCluster(regions,rclassifications,csepclouds);
ss.str("");
ss << "ec_rg_rlw_" << id[0] << ".pcd";
writeCloudClassifiedByCluster(regions,rclassifications,ss.str());
std::cout << ss.str() << std::endl;
//
std::cout << " Point-wise, " << std::flush;
arma::mat pfmat;
arma::gmm_diag pmodel;
gmmByPoint(csepclouds[1],50,5,1,5,50,100,pfmat,pmodel);
std::vector<int> pclassifications;
pclassifications = classifyGmmPointModel(csepclouds[1],5,pfmat,pmodel);
std::vector<pcl::PointCloud<PointTreeseg>::Ptr> psepclouds;
separateCloudsClassifiedByPoint(csepclouds[1],pclassifications,psepclouds);
ss.str("");
ss << "ec_rg_rlw_plw_" << id[0] << ".pcd";
writeCloudClassifiedByPoint(csepclouds[1],pclassifications,ss.str());
std::cout << ss.str() << std::endl;
//
ss.str("");
ss << "ec_rg_rlw_plw_w_" << id[0] << ".pcd";
pcl::PointCloud<PointTreeseg>::Ptr wood(new pcl::PointCloud<PointTreeseg>);
*wood += *csepclouds[0] + *psepclouds[0];
writer.write(ss.str(),*wood,true);
std::cout << ss.str() << std::endl;
//
std::cout << "Re-segmenting regions: " << std::flush;
regions.clear();
regionSegmentation(wood,nnearest,nmin,smoothness+2.5,regions);
ss.str("");
ss << "ec_rg_rlw_plw_w_rg" << id[0] << ".pcd";
writeClouds(regions,ss.str(),false);
std::cout << ss.str() << std::endl;
if(sepwoodleaf == true)
{
std::cout << "Leaf stripping: " << std::endl;
//
std::cout << " Region-wise, " << std::flush;
arma::mat rfmat;
arma::gmm_full rmodel;
gmmByCluster(regions,5,1,5,50,100,rfmat,rmodel);
std::vector<int> rclassifications;
rclassifications = classifyGmmClusterModel(regions,5,rfmat,rmodel);
std::vector<pcl::PointCloud<PointTreeseg>::Ptr> csepclouds;
separateCloudsClassifiedByCluster(regions,rclassifications,csepclouds);
ss.str("");
ss << id[0] << ".ec.rg.rlw." << id[1] << ".pcd";
writeCloudClassifiedByCluster(regions,rclassifications,ss.str());
std::cout << ss.str() << std::endl;
//
std::cout << " Point-wise, " << std::flush;
arma::mat pfmat;
arma::gmm_diag pmodel;
gmmByPoint(csepclouds[1],50,5,1,5,50,100,pfmat,pmodel);
std::vector<int> pclassifications;
pclassifications = classifyGmmPointModel(csepclouds[1],5,pfmat,pmodel);
std::vector<pcl::PointCloud<PointTreeseg>::Ptr> psepclouds;
separateCloudsClassifiedByPoint(csepclouds[1],pclassifications,psepclouds);
ss.str("");
ss << id[0] << ".ec.rg.rlw.plw." << id[1] << ".pcd";
writeCloudClassifiedByPoint(csepclouds[1],pclassifications,ss.str());
std::cout << ss.str() << std::endl;
//
ss.str("");
ss << id[0] << ".ec.rg.rlw.plw.w." << id[1] << ".pcd";
pcl::PointCloud<PointTreeseg>::Ptr wood(new pcl::PointCloud<PointTreeseg>);
*wood += *csepclouds[0] + *psepclouds[0];
writer.write(ss.str(),*wood,true);
std::cout << ss.str() << std::endl;
//
std::cout << "Re-segmenting regions: " << std::flush;
regions.clear();
regionSegmentation(wood,nnearest,nmin,smoothness+2.5,regions);
ss.str("");
ss << id[0] << ".ec.rg.rlw.plw.w.rg." << id[1] << ".pcd";
writeClouds(regions,ss.str(),false);
std::cout << ss.str() << std::endl;
}
//
std::cout << "Optimising regions: " << std::flush;
removeFarRegions(regions);
ss.str("");
ss << "ec_rg_rlw_plw_w_rg_o" << id[0] << ".pcd";
if(sepwoodleaf == true) ss << id[0] << ".ec.rg.rlw.plw.w.rg.o." << id[1] << ".pcd";
else ss << id[0] << ".ec.rg.o." << id[1] << ".pcd";
writeClouds(regions,ss.str(),false);
std::cout << ss.str() << std::endl;
//
std::cout << "Building tree: " << std::flush;
pcl::PointCloud<PointTreeseg>::Ptr tree(new pcl::PointCloud<PointTreeseg>);
buildTree(regions,tree);
ss.str("");
ss << "tree_" << id[0] << ".pcd";
ss << id[0] << "_" << id[1] << ".pcd";
writer.write(ss.str(),*tree,true);
std::cout << ss.str() << std::endl;
}
Expand Down

0 comments on commit 4ff8332

Please sign in to comment.