[1]PCL的安裝和使用(w7+pcl1.8.0+vs17)

[1]安裝及配置教程
Windows + VS2017超詳細點雲庫(PCL)配置
PCL1.8.1_VS2017_win64版本:鏈接: https://pan.baidu.com/s/1gREl9tDmX-sKGMB6sKxfFA 提取碼: gxdg
【2】配置項目屬性表
一般的配置第三方庫是建立一個空白的文件,然後在裏面進行配置如(PCL安裝及配置教程
但是我的vs2017只能在這個配置好的文件裏面進行試驗,新建文件後需要從新配置。因此通過建立項目屬性表可以解決此類問題,具體的做法如下:
(1)建立屬性表
在這裏插入圖片描述
(2)配置屬性表
配置過程同文件屬性頁中配置一樣
在這裏插入圖片描述
(3)保存屬性表
保存至自己的加載的目錄(方便後期加載)
在這裏插入圖片描述
(4)加載屬性表
(加載上面目錄下的屬性表)
在這裏插入圖片描述
總結:這樣的好處時不需要每次配置環境,解決了空文件不能多次利用的情況

一次配置 永久使用
在下面的屬性表中配置環境一次配置永久使用
在這裏插入圖片描述

【3】點雲例程運行的錯誤解決
(1)error C4996: ‘pcl::SAC_SAMPLE_SIZE’: PCL1.8問題
在這裏插入圖片描述
(2)無法打開pch.h
更改爲不使用
在這裏插入圖片描述
(3)c4996錯誤
嚴重性 代碼 說明 行 項目 文件 禁止顯示狀態
錯誤 C4996 ‘std::fpos<_Mbstatet>::seekpos’: warning STL4019: The member std::fpos::seekpos() is non-Standard, and is preserved only for compatibility with workarounds for old versions of Visual C++. It will be removed in a future release, and in this release always returns 0. Please use standards-conforming mechanisms to manipulate fpos, such as conversions to and from streamoff, or an integral type, instead. If you are receiving this message while compiling Boost.IOStreams, a fix has been submitted upstream to make Boost use standards-conforming mechanisms, as it does for other compilers. You can define _SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING to acknowledge that you have received this warning, or define _REMOVE_FPOS_SEEKPOS to remove std::fpos::seekpos entirely. 96 PCL18FirstExamople g:\vs2017\pcllibrary\pcl 1.8.1\3rdparty\boost\include\boost-1_64\boost\iostreams\positioning.hpp

在這裏插入圖片描述
解決方法如下
在這裏插入圖片描述
以上爲我在使用pcl第一個點雲例程中遇到的問題

【4】源碼

// PCL18FirstExamople.cpp : 此文件包含 "main" 函數。程序執行將在此處開始並結束。
//


#include"pch.h"
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/filters/project_inliers.h>
#pragma warning
int
main(int argc, char** argv)
{
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected(new pcl::PointCloud<pcl::PointXYZ>);

	// Fill in the cloud data
	cloud->width = 5;
	cloud->height = 1;
	cloud->points.resize(cloud->width * cloud->height);

	for (std::size_t i = 0; i < cloud->points.size(); ++i)
	{
		cloud->points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
		cloud->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
		cloud->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
	}

	std::cerr << "Cloud before projection: " << std::endl;
	for (std::size_t i = 0; i < cloud->points.size(); ++i)
		std::cerr << "    " << cloud->points[i].x << " "
		<< cloud->points[i].y << " "
		<< cloud->points[i].z << std::endl;

	// Create a set of planar coefficients with X=Y=0,Z=1
	pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
	coefficients->values.resize(4);
	coefficients->values[0] = coefficients->values[1] = 0;
	coefficients->values[2] = 1.0;
	coefficients->values[3] = 0;

	// Create the filtering object
	pcl::ProjectInliers<pcl::PointXYZ> proj;
	proj.setModelType(pcl::SACMODEL_PLANE);
	proj.setInputCloud(cloud);
	proj.setModelCoefficients(coefficients);
	proj.filter(*cloud_projected);

	std::cerr << "Cloud after projection: " << std::endl;
	for (std::size_t i = 0; i < cloud_projected->points.size(); ++i)
		std::cerr << "    " << cloud_projected->points[i].x << " "
		<< cloud_projected->points[i].y << " "
		<< cloud_projected->points[i].z << std::endl;

	return (0);
}

結果
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章