国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

c++ pcl點云變換骨架枝干添加樹葉源碼實例

這篇具有很好參考價值的文章主要介紹了c++ pcl點云變換骨架枝干添加樹葉源碼實例。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

程序示例精選
c++ pcl點云變換骨架枝干添加樹葉源碼實例
如需安裝運行環(huán)境或遠程調試,見文章底部個人QQ名片,由專業(yè)技術人員遠程協(xié)助!

前言

這篇博客針對《c++ pcl點云變換骨架枝干添加樹葉源碼實例》編寫代碼,代碼整潔,規(guī)則,易讀。 學習與應用推薦首選。


運行結果

c++ pcl點云變換骨架枝干添加樹葉源碼實例,C++,c++,數(shù)據庫,開發(fā)語言,點云,pcl,visual studioc++ pcl點云變換骨架枝干添加樹葉源碼實例,C++,c++,數(shù)據庫,開發(fā)語言,點云,pcl,visual studio ***

文章目錄

一、所需工具軟件
二、使用步驟
???????1. 主要代碼
???????2. 運行結果
三、在線協(xié)助

一、所需工具軟件

???????1. VS2019, Qt
???????2. C++

二、使用步驟

代碼如下(示例):

/*
*	Copyright (C) 2019 by
*       Shenglan Du (dushenglan940128@163.com)
*       Liangliang Nan (liangliang.nan@gmail.com)
*       3D Geoinformation, TU Delft, https://3d.bk.tudelft.nl
*
*	This file is part of AdTree, which implements the 3D tree
*   reconstruction method described in the following paper:
*   -------------------------------------------------------------------------------------
*       Shenglan Du, Roderik Lindenbergh, Hugo Ledoux, Jantien Stoter, and Liangliang Nan.
*       AdTree: Accurate, Detailed, and Automatic Modeling of Laser-Scanned Trees.
*       Remote Sensing. 2019, 11(18), 2074.
*   -------------------------------------------------------------------------------------
*   Please consider citing the above paper if you use the code/program (or part of it).
*
*	AdTree is free software; you can redistribute it and/or modify
*	it under the terms of the GNU General Public License Version 3
*	as published by the Free Software Foundation.
*
*	AdTree is distributed in the hope that it will be useful,
*	but WITHOUT ANY WARRANTY; without even the implied warranty of
*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*	GNU General Public License for more details.
*
*	You should have received a copy of the GNU General Public License
*	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// save the smoothed skeleton into a PLY file (where each vertex has a radius)
void save_skeleton(Skeleton* skeleton, PointCloud* cloud, const std::string& file_name) {
	const ::Graph& sgraph = skeleton->get_smoothed_skeleton();
	if (boost::num_edges(sgraph) == 0) {
		std::cerr << "failed to save skeleton (no edge exists)" << std::endl;
		return;
	}

	// convert the boost graph to Graph (avoid modifying easy3d's GraphIO, or writing IO for boost graph)

	std::unordered_map<SGraphVertexDescriptor, easy3d::Graph::Vertex>  vvmap;
	easy3d::Graph g;

	auto vertexRadius = g.add_vertex_property<float>("v:radius");
	auto vts = boost::vertices(sgraph);
	for (SGraphVertexIterator iter = vts.first; iter != vts.second; ++iter) {
		SGraphVertexDescriptor vd = *iter;
		if (boost::degree(vd, sgraph) != 0) { // ignore isolated vertices
			const vec3& vp = sgraph[vd].cVert;
			auto v = g.add_vertex(vp);
			vertexRadius[v] = sgraph[vd].radius;
			vvmap[vd] = v;
		}
	}

	auto egs = boost::edges(sgraph);
	for (SGraphEdgeIterator iter = egs.first; iter != egs.second; ++iter) {
		SGraphEdgeDescriptor ed = *iter;    // the edge descriptor
		SGraphEdgeProp ep = sgraph[ed];   // the edge property

		SGraphVertexDescriptor s = boost::source(*iter, sgraph);
		SGraphVertexDescriptor t = boost::target(*iter, sgraph);
		g.add_edge(vvmap[s], vvmap[t]);
	}

	auto offset = cloud->get_model_property<dvec3>("translation");
	if (offset) {
		auto prop = g.model_property<dvec3>("translation");
		prop[0] = offset[0];
	}

	if (GraphIO::save(file_name, &g))
        std::cout << "model of skeletons saved to: " << file_name << std::endl;
    else
		std::cerr << "failed to save the model of skeletons into file" << std::endl;
}


// returns the number of processed input files.
int batch_reconstruct(std::vector<std::string>& point_cloud_files, const std::string& output_folder, bool export_skeleton) {
    int count(0);
    for (std::size_t i=0; i<point_cloud_files.size(); ++i) {
        const std::string& xyz_file = point_cloud_files[i];
        std::cout << "------------- " << i + 1 << "/" << point_cloud_files.size() << " -------------" << std::endl;
        std::cout << "processing xyz_file: " << xyz_file << std::endl;

        if (!file_system::is_directory(output_folder)) {
            if (file_system::create_directory(output_folder))
                std::cout << "created output directory '" << output_folder << "'" << std::endl;
            else {
                std::cerr << "failed creating output directory" << std::endl;
                return 0;
            }
        }

        // load point_cloud
        PointCloud *cloud = PointCloudIO::load(xyz_file);
        if (cloud) {
            std::cout << "cloud loaded. num points: " << cloud->n_vertices() << std::endl;

            // compute bbox
            Box3 box;
            auto points = cloud->get_vertex_property<vec3>("v:point");
            for (auto v : cloud->vertices())
                box.add_point(points[v]);

            // remove duplicated points
            const float threshold = box.diagonal() * 0.001f;
            const auto &points_to_remove = RemoveDuplication::apply(cloud, threshold);
            for (auto v : points_to_remove)
                cloud->delete_vertex(v);
            cloud->garbage_collection();
            std::cout << "removed too-close points. num points: " << cloud->n_vertices() << std::endl;
        }
        else {
            std::cerr << "failed to load point cloud from '" << xyz_file << "'" << std::endl;
            continue;
        }

        // reconstruct branches
        SurfaceMesh *mesh = new SurfaceMesh;
        const std::string &branch_filename = file_system::base_name(cloud->name()) + "_branches.obj";
        mesh->set_name(branch_filename);

        Skeleton *skeleton = new Skeleton();
        bool status = skeleton->reconstruct_branches(cloud, mesh);
        if (!status) {
            std::cerr << "failed in reconstructing branches" << std::endl;
            delete cloud;
            delete mesh;
            delete skeleton;
            continue;
        }

        // copy translation property from point_cloud to surface_mesh
        SurfaceMesh::ModelProperty<dvec3> prop = mesh->add_model_property<dvec3>("translation");
        prop[0] = cloud->get_model_property<dvec3>("translation")[0];

        // save branches model
        const std::string branch_file = output_folder + "/" + branch_filename;
        if (SurfaceMeshIO::save(branch_file, mesh)) {
            std::cout << "model of branches saved to: " << branch_file << std::endl;
            ++count;
        }
        else
            std::cerr << "failed to save the model of branches" << std::endl;

        if (export_skeleton) {
            const std::string& skeleton_file = output_folder + "/" + file_system::base_name(cloud->name()) + "_skeleton.ply";
            save_skeleton(skeleton, cloud, skeleton_file);
        }

        delete cloud;
        delete mesh;
        delete skeleton;
    }

    return count;
}


int main(int argc, char *argv[]) {
//    argc = 2;
//    argv[1] = "/Users/lnan/Projects/adtree/data";
//    argv[2] = "/Users/lnan/Projects/adtree/data-results";

    if (argc == 1) {
        TreeViewer viewer;
        viewer.run();
        return EXIT_SUCCESS;
    } else if (argc >= 3) {
        bool export_skeleton = false;
        for (int i = 0; i < argc; ++i) {
            if (strcmp(argv[i], "-s") == 0 || strcmp(argv[i], "-skeleton") == 0) {
                export_skeleton = true;
                break;
            }
        }

        if (export_skeleton) {
            std::cout << "You have requested to save the reconstructed tree skeleton(s) in PLY format into the output directory." << std::endl;
            std::cout << "The skeleton file(s) can be visualized using Easy3D: https://github.com/LiangliangNan/Easy3D" << std::endl;
        }
        else
            std::cout << "Tree skeleton(s) will not be saved (append '-s' or '-skeleton' in commandline to enable it)" << std::endl;

        std::string first_arg(argv[1]);
        std::string second_arg(argv[2]);
        if (file_system::is_file(second_arg))
            std::cerr << "WARNING: second argument cannot be an existing file (expecting a directory)." << std::endl;
        else {
            std::string output_dir = second_arg;
            if (file_system::is_file(first_arg)) {
                std::vector<std::string> cloud_files = {first_arg};
                return batch_reconstruct(cloud_files, output_dir, export_skeleton) > 0;
            } else if (file_system::is_directory(first_arg)) {
                std::vector<std::string> entries;
                file_system::get_directory_entries(first_arg, entries, false);
                std::vector<std::string> cloud_files;
                for (const auto &file_name : entries) {
                    if (file_name.size() > 3 && file_name.substr(file_name.size() - 3) == "xyz")
                        cloud_files.push_back(first_arg + "/" + file_name);
                }
                return batch_reconstruct(cloud_files, output_dir, export_skeleton) > 0;
            } else
                std::cerr
                        << "WARNING: unknown first argument (expecting either a point cloud file in *.xyz format or a\n"
                           "\tdirectory containing *.xyz point cloud files)." << std::endl;
        }
    }
    return EXIT_FAILURE;
}


運行結果
c++ pcl點云變換骨架枝干添加樹葉源碼實例,C++,c++,數(shù)據庫,開發(fā)語言,點云,pcl,visual studioc++ pcl點云變換骨架枝干添加樹葉源碼實例,C++,c++,數(shù)據庫,開發(fā)語言,點云,pcl,visual studio

三、在線協(xié)助:

如需安裝運行環(huán)境或遠程調試,見文章底部個人 QQ 名片,由專業(yè)技術人員遠程協(xié)助!

1)遠程安裝運行環(huán)境,代碼調試
2)Visual Studio, Qt, C++, Python編程語言入門指導
3)界面美化
4)軟件制作
5)云服務器申請
6)網站制作

當前文章連接:https://blog.csdn.net/alicema1111/article/details/132666851
個人博客主頁:https://blog.csdn.net/alicema1111?type=blog
博主所有文章點這里:https://blog.csdn.net/alicema1111?type=blog

博主推薦:
Python人臉識別考勤打卡系統(tǒng):
https://blog.csdn.net/alicema1111/article/details/133434445
Python果樹水果識別:https://blog.csdn.net/alicema1111/article/details/130862842
Python+Yolov8+Deepsort入口人流量統(tǒng)計:https://blog.csdn.net/alicema1111/article/details/130454430
Python+Qt人臉識別門禁管理系統(tǒng):https://blog.csdn.net/alicema1111/article/details/130353433
Python+Qt指紋錄入識別考勤系統(tǒng):https://blog.csdn.net/alicema1111/article/details/129338432
Python Yolov5火焰煙霧識別源碼分享:https://blog.csdn.net/alicema1111/article/details/128420453
Python+Yolov8路面橋梁墻體裂縫識別:https://blog.csdn.net/alicema1111/article/details/133434445
文章來源地址http://www.zghlxwxcb.cn/news/detail-722197.html

到了這里,關于c++ pcl點云變換骨架枝干添加樹葉源碼實例的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!

本文來自互聯(lián)網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • PCL 計算點云法向量與表面曲率(C++詳細過程版)

    ??計算點云法向量和表面曲率是PCL里的經典算法之一,具體算法原理和實現(xiàn)代碼見:PCL 計算點云法向量并顯示。為充分了解算法實現(xiàn)的每一個細節(jié)和有待改進的地方,使用C++代碼對算法實現(xiàn)過程進行復現(xiàn)。 注意: PCL中的算法鄰域搜索只能是K近鄰搜索或半徑搜索,無法實現(xiàn)

    2024年02月12日
    瀏覽(29)
  • Ubuntu 20.04.06 PCL C++學習記錄(二十七)【附所用點云】

    Ubuntu 20.04.06 PCL C++學習記錄(二十七)【附所用點云】

    @[TOC]PCL中點云配準模塊的學習 參考書籍:《點云庫PCL從入門到精通》以及官方代碼PCL官方代碼鏈接,,PCL版本為1.10.0,CMake版本為3.16,可用點云下載地址 使用正態(tài)分布算法來確定兩個大型點云之間的剛體變換,正態(tài)分布變換算法是一個配準算法,它應用于三維點的統(tǒng)計模型,

    2024年04月27日
    瀏覽(51)
  • (02)Cartographer源碼無死角解析-(19) SensorBridge→雷達點云數(shù)據幀處理與坐標系變換(涉及函數(shù)重載)

    (02)Cartographer源碼無死角解析-(19) SensorBridge→雷達點云數(shù)據幀處理與坐標系變換(涉及函數(shù)重載)

    本人講解關于slam一系列文章匯總鏈接:史上最全slam從零開始,針對于本欄目講解(02)Cartographer源碼無死角解析-鏈接如下: (02)Cartographer源碼無死角解析- (00)目錄_最新無死角講解:https://blog.csdn.net/weixin_43013761/article/details/127350885 ? 文 末 正 下 方 中 心 提 供 了 本 人 聯(lián) 系 方 式

    2024年02月01日
    瀏覽(70)
  • PCL 點云組件聚類

    該算法與歐式聚類、DBSCAN聚類很是類似,聚類過程如下所述: 1. 首先,我們需要提供一個種子點集合,對種子點集合進行初始的聚類操作,聚類的評估器(即聚類條件),可以指定為法向評估,也可以是距離評估,以此我們就可以提取出點云中各個位置的組件部分。 2. 合并

    2024年02月10日
    瀏覽(19)
  • PCL點云庫(2) - IO模塊

    PCL點云庫(2) - IO模塊

    目錄 2.1 IO模塊接口 2.2?PCD數(shù)據讀寫 (1) PCD數(shù)據解析 (2)PCD文件讀寫示例 2.3?PLY數(shù)據讀寫 (1)PLY數(shù)據解析 (2)PLY文件讀寫示例 2.4 OBJ數(shù)據讀寫 (1)OBJ數(shù)據解析 (2)OBJ文件讀寫示例 2.5?VTK數(shù)據讀寫 (1)VTK數(shù)據解析 (2)VTK文件讀寫示例 2.6 保存為PNG 參考文章:PCL函數(shù)庫

    2023年04月22日
    瀏覽(23)
  • 點云分割-pcl區(qū)域生長算法

    點云分割-pcl區(qū)域生長算法

    1、本文內容 pcl的區(qū)域生長算法的使用和原理 2、平臺/環(huán)境 cmake, pcl 3、轉載請注明出處: https://blog.csdn.net/qq_41102371/article/details/131927376 參考:https://pcl.readthedocs.io/projects/tutorials/en/master/region_growing_segmentation.html#region-growing-segmentation https://blog.csdn.net/taifyang/article/details/124097186

    2024年02月15日
    瀏覽(23)
  • VisualStudio如何配置PCL點云庫?

    VisualStudio如何配置PCL點云庫?

    ??因筆者課題涉及點云處理,需要通過PCL進行點云數(shù)據分析處理,查閱現(xiàn)有網絡資料,實現(xiàn)了VisualStudio2015(x86)配置PCL1.8.1點云庫,本文記錄實現(xiàn)配置的過程。 ?? (1)下載PCL ??下載地址: https://github.com/PointCloudLibrary/pcl/releases/tag/pcl-1.8.1 ??筆者的VS軟件為32位的VS2015,

    2024年02月06日
    瀏覽(21)
  • PCL 改進點云雙邊濾波算法

    PCL 改進點云雙邊濾波算法

    我們先來回顧一下之前該算法的計算過程,在二維圖像領域中,雙邊濾波算法是通過考慮中心像素點到鄰域像素點的距離(一邊)以及像素亮度差值所確定的權重(另一邊)來修正當前采樣中心點的位置,從而達到平滑濾波效果。同時也會有選擇性的剔除部分與當前采樣點“差異”

    2024年02月07日
    瀏覽(30)
  • PCL - 3D點云配準(registration)介紹

    PCL - 3D點云配準(registration)介紹

    前面多篇博客都提到過,要善于從官網去熟悉一樣東西。API部分詳細介紹見 Point Cloud Library (PCL): Module registration 這里博主主要借鑒Tutorial里內容(博主整體都有看完) Introduction — Point Cloud Library 0.0 documentation 接下來主要跑下Registration中的sample例子 一.直接運行下How to use iter

    2024年02月12日
    瀏覽(27)
  • (學習筆記)PCL點云庫的基本使用

    (學習筆記)PCL點云庫的基本使用

    目錄 前言 1、理解點云庫 1.1、不同的點云類型 1.2、PCL中的算法 1.3、ROS的PCL接口 2、創(chuàng)建第一個PCL程序 2.1、創(chuàng)建點云 2.2、加載點云文件 2.3、創(chuàng)建點云文件 2.4、點云可視化 2.5、點云濾波和下采樣 2.5.1、點云濾波 ?2.5.2、點云下采樣 2.6、點云配準與匹配 ????????點云是一種

    2023年04月08日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包