首先确认电脑是否已装nodejs和gulp,若已装,跳到第三步
一 安装nodejs
sudo apt-get install nodejs
sudo apt-get install npm
#验证是否安装成功命令
node -v
二 安装gulp
sudo npm install -g gulp
#验证是否安装成功命令
gulp -v
三 安装potree
在终端依次输入以下命令:
git clone https://github.com/potree/potree
cd Potree #安装目录
npm install
npm install -g gulp
gulp watch
此时Potree的安装目录下应当有了一个build的文件夹。
四 PotreeConverter安装
Potree可视化数据需要使用具备Potree它定义的格式的数据,因此需要对txt、las等数据使用PotreeConverter转换格式
4.1 LAStools安装
1、输入命令:git clone https://github.com/LAStools/LAStools
2、在终端依次输入以下命令:
cd ~/laz/lastools #自己创建的文件夹laz
git clone https://github.com/m-schuetz/LAStools.git master
cd master/LASzip
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
这就配置好PotreeConverter所需要的LAStool依赖了
4.2 PotreeConverter
终端输入以下命令:
cd ~/laz/PotreeConverter
git clone https://github.com/potree/PotreeConverter.git master
cd master
mkdir build
cd build
cmake ../
make
此过程若出现TBB.camke类错误,可源码安装tbb(必须源码安装,不能使用apt-get install libtbb-dev,这样安装的库最后在编译链接PotreeConverter时会链接出错),
安装过程如下:
sudo apt install build-essential
sudo git clone https://github.com/wjakob/tbb.git
cd tbb/build
sudo cmake ..
sudo make -j #若编译过程出现系统卡住,速度过慢等,可增大ubuntu系统分配内存,并将命令改成sudo make -j4
sudo make install
五 数据转换
几种转换方法
# convert data.las and generate web page.
./PotreeConverter.exe C:/data.las -o C:/potree_converted -p pageName
# generate compressed LAZ files instead of the default BIN format.
./PotreeConverter.exe C:/data.las -o C:/potree_converted --output-format LAZ
# convert all files inside the data directory
./PotreeConverter.exe C:/data -o C:/potree_converted
# first, convert with custom bounding box and then append new_data.las afterwards.
# points in new_data MUST fit into bounding box!
./PotreeConverter.exe C:/data -o C:/potree_converted -aabb "-0.748 -2.780 2.547 3.899 1.867 7.195"
./PotreeConverter.exe C:/new_data.las -o C:/potree_converted --incremental
# tell the converter that coordinates are in a UTM zone 10N projection. Also, create output in LAZ format
./PotreeConverter.exe C:/data -o C:/potree_converted -p pageName --projection "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs" --overwrite --output-format LAZ
# using a swiss projection. Use http://spatialreference.org/ to find projections in proj4 format
./PotreeConverter.exe C:/data -o C:/potree_converted -p pageName --projection "+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs" --overwrite
六 potree点云可视化
##In Potree, modify one of the examples with following load command:
let url = "../pointclouds/D/temp/test/metadata.json";
Potree.loadPointCloud(url).then(e => {
let pointcloud = e.pointcloud;
let material = pointcloud.material;
material.activeAttributeName = "rgba";
material.minSize = 2;
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
viewer.scene.addPointCloud(pointcloud);
viewer.fitToScreen();
});
① 在potree目录下运行npm start
② 打开链接http://localhost:1234/examples/,即可看到examples中的文件,点击打开即可。