OpenPCDet从环境配置到模型训练

一、环境安装:

操作系统 :ubuntu 20.04+docker [11.8.0-cudnn8-devel-ubuntu18.04] 

代码下载地址GitHub - open-mmlab/OpenPCDet: OpenPCDet Toolbox for LiDAR-based 3D Object Detection.OpenPCDet Toolbox for LiDAR-based 3D Object Detection. - open-mmlab/OpenPCDethttps://github.com/open-mmlab/OpenPCDet.git

下载代码到本地,然后按照readmd.md 进行环境配置,官方提供的pytorch 推荐版本:1.1, 1,3, 1,5

本次选择的版本为 1.5。选择相匹配的cuda和cudnn 版本。cuda-10.2+cudnn-7.6.5.

pytorch 1.5 + cuda10.2 + cudnn-7.6.5

1、创建一个name为pp的容器:

sudo docker run -dt \   -e DISPLAY=$DISPLAY \   -v /tmp/.X11-unix:/tmp/.X11-unix \   --mount type=bind,source=/home/document/Section,target=/mnt/section \   --restart=always \ --name pp \ --gpus all  、-p 8080:80 你的镜像名

2、在容器内安装annconda:

Download Now | AnacondaAnaconda is the birthplace of Python data science. We are a movement of data scientists, data-driven enterprises, and open source communities.https://www.anaconda.com/download/success3、安装cuda-10.2+cudnn7.6.5

CUDA Toolkit Archive | NVIDIA Developerhttps://developer.nvidia.com/cuda-toolkit-archivecuDNN Archive | NVIDIA Developerhttps://developer.nvidia.com/rdp/cudnn-archive

tar -xvf cudnn-10.2-linux-x64-v7.6.5.32.tgz

sudo cp cuda/include/cudnn.h /usr/local/cuda/include/

sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/

sudo chmod a+r /usr/local/cuda/include/cudnn.h

sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

4、pip install -r requirements.txt

5、安装spconv1.2 

git clone  https://github.com/traveller59/spconv.git --resursive

6、安装mayavi conda install -c conda-forge mayavi

pip 环境版本

目前出现的一个问题是numba 版本问题,在模型训练的时候,如果进行模型评估,进需要0.55.1版本,可视化需要0.58.1。

执行 python setup.py develop

python demo.py --cfg_file tools/kitti_models/pointpillar.yaml --data_path  data/demo.bin --ckpt model.pth 完成测试

至此以上环境搭建完成。

二、数据标注

标注工具安装 

git  clone  https://github.com/ch-sa/labelCloud.git

conda create -n labelimg python=3.8 -y  #创建环境

conda activate label3.8  #激活命令

cd labelCLoud    #进入下载文件夹

pip install labelCloud   #安装labelCloud

pip install -r requirements.txt   #安装环境

python3 labelCloud.py  #运行命令

私有数据是录制的.bag 包文件,通过

rosrun pcl_ros bag_to_pcd your_bag_file.bag /your_point_cloud_topic output_directory


pcd 文件转成bin 文件,C++ 脚本

#include <omp.h>
#include <ctime>
#include <vector>
#include <string>
#include <algorithm>
#include <pcl/io/pcd_io.h>
#include <pcl/common/common_headers.h>
#include <sys/stat.h>
#include <pcl/io/boost.h>
#include <boost/program_options.hpp>
#include <fstream>
#include <iostream>
#include <vector>
#include <dirent.h> 
#include <cstring>
#include <sys/stat.h> 

void convertPCDtoBin(std::string &in_file, std::string& out_file)
{
	pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>);
	if (pcl::io::loadPCDFile<pcl::PointXYZI>(in_file, *cloud) == -1) //* load the file
	{  
		std::string err = "Couldn't read file " + in_file;
		PCL_ERROR(err.c_str());
		return;
	}
	std::cout << "Loaded "
		<< cloud->width * cloud->height
		<< " data points from "
		<< in_file
		<< " with the following fields: "
		<< std::endl;
        
	std::string out_file1 = out_file + ".bin";
	std::ofstream myFile(out_file1.c_str(), std::ios::out | std::ios::binary);
	for (int j = 0; j < cloud->size(); j++) {
		cloud->at(j).x=0-cloud->at(j).x;
        std::cout << "3 "<< std::endl;
		myFile.write((char*)& cloud->at(j).y, sizeof(cloud->at(j).y));
		myFile.write((char*)& cloud->at(j).x, sizeof(cloud->at(j).x));
		myFile.write((char*)& cloud->at(j).z, sizeof(cloud->at(j).z));
		myFile.write((char *)& cloud->at(j).intensity, sizeof(cloud->at(j).intensity));
		//myFile << cloud->at(j).x << " " << cloud->at(j).y << " " << cloud->at(j).z << endl;
		
	}
	//myFile.write(reinterpret_cast<char*>(myFile),nume*7sizeof(float));
	myFile.close();
	
}

void traverseDirectory(const std::string& directoryPath,const std::string& outPath) {
    DIR* dir;
    struct dirent* entry;

    if ((dir = opendir(directoryPath.c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值