Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erro: scores, dt_box_lidar, types, pred_dict = proc_1.run(np_p, frame) #1271

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ venv/
*.pkl
*.zip
*.bin
*.pcd
output
version.py
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
This repo is modified by Kin, check the commit to see the modification.



Tutorials:

- **ROS Inference**: [https://github.com/Kin-Zhang/OpenPCDet_ros](https://github.com/Kin-Zhang/OpenPCDet_ros)

- Chinese Video: [https://www.bilibili.com/video/BV1xe4y1j72q](https://www.bilibili.com/video/BV1xe4y1j72q)

- Chiese Blog: [【点云检测】OpenPCDet 教程系列 安装 与 ROS运行](https://www.cnblogs.com/kin-zhang/p/17002980.html))



---
<details>
<summary>[Please check the official repo or below origin read for more detail]</summary>


<img src="docs/open_mmlab.png" align="right" width="30%">

# OpenPCDet
Expand Down Expand Up @@ -264,3 +283,5 @@ If you find this project useful in your research, please consider cite:
Welcome to be a member of the OpenPCDet development team by contributing to this repo, and feel free to contact us for any potential contributions.



</details>
86 changes: 31 additions & 55 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,31 @@
FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

# Install basics
RUN apt-get update -y \
&& apt-get install build-essential \
&& apt-get install -y apt-utils git curl ca-certificates bzip2 tree htop wget \
&& apt-get install -y libglib2.0-0 libsm6 libxext6 libxrender-dev bmon iotop g++ python3.7 python3.7-dev python3.7-distutils

# Install cmake v3.13.2
RUN apt-get purge -y cmake && \
mkdir /root/temp && \
cd /root/temp && \
wget https://github.com/Kitware/CMake/releases/download/v3.13.2/cmake-3.13.2.tar.gz && \
tar -xzvf cmake-3.13.2.tar.gz && \
cd cmake-3.13.2 && \
bash ./bootstrap && \
make && \
make install && \
cmake --version && \
rm -rf /root/temp

# Install python
RUN ln -sv /usr/bin/python3.7 /usr/bin/python
RUN wget https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py

# Install python packages
RUN PIP_INSTALL="python -m pip --no-cache-dir install" && \
$PIP_INSTALL numpy==1.19.3 llvmlite numba

# Install torch and torchvision
# See https://pytorch.org/ for other options if you use a different version of CUDA
RUN pip install --user torch==1.6 torchvision==0.7.0 -f https://download.pytorch.org/whl/cu102/torch_stable.html

# Install python packages
RUN PIP_INSTALL="python -m pip --no-cache-dir install" && \
$PIP_INSTALL tensorboardX easydict pyyaml scikit-image tqdm SharedArray six

WORKDIR /root

# Install Boost geometry
RUN wget https://jaist.dl.sourceforge.net/project/boost/boost/1.68.0/boost_1_68_0.tar.gz && \
tar xzvf boost_1_68_0.tar.gz && \
cp -r ./boost_1_68_0/boost /usr/include && \
rm -rf ./boost_1_68_0 && \
rm -rf ./boost_1_68_0.tar.gz

# A weired problem that hasn't been solved yet
RUN pip uninstall -y SharedArray && \
pip install SharedArray

RUN pip install spconv-cu102
FROM nvidia/cuda:11.3.0-devel-ubuntu20.04
LABEL maintainer="Kin Zhang https://kin-zhang.github.io/"
# Just in case we need it
ENV DEBIAN_FRONTEND noninteractive

RUN apt update && apt install -y --no-install-recommends git curl wget git zsh tmux vim g++
# needs to be done before we can apply the patches
RUN git config --global user.email "kin_eng@163.com"
RUN git config --global user.name "kin-docker"

# install zsh
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.2/zsh-in-docker.sh)" -- \
-t robbyrussell \
-p git \
-p ssh-agent \
-p https://github.com/agkozak/zsh-z \
-p https://github.com/zsh-users/zsh-autosuggestions \
-p https://github.com/zsh-users/zsh-completions \
-p https://github.com/zsh-users/zsh-syntax-highlighting

# =========> INSTALL OpenPCDet <=============
RUN apt update && apt install -y python3-pip
RUN pip3 install torch==1.10.0+cu113 torchvision==0.11.0+cu113 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
RUN pip3 install spconv-cu113
RUN apt update && apt install -y python3-setuptools
RUN mkdir -p /home/kin/workspace
WORKDIR /home/kin/workspace
RUN git clone https://github.com/Kin-Zhang/OpenPCDet.git
RUN cd OpenPCDet && pip3 install -r requirements.txt
RUN pip3 install pyquaternion numpy==1.23 pillow==8.4 mayavi open3d
# RUN cd OpenPCDet && python3 setup.py develop # need run inside the container!!!
5 changes: 4 additions & 1 deletion pcdet/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ def cfg_from_list(cfg_list, config):


def merge_new_config(config, new_config):
# fix maybe?
import os
openpcdet_path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..'))
if '_BASE_CONFIG_' in new_config:
with open(new_config['_BASE_CONFIG_'], 'r') as f:
with open(os.path.join(openpcdet_path, 'tools', new_config['_BASE_CONFIG_']), 'r') as f:
try:
yaml_config = yaml.safe_load(f, Loader=yaml.FullLoader)
except:
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ scikit-image
tqdm
torchvision
SharedArray
json
cv2
2 changes: 1 addition & 1 deletion tools/cfgs/dataset_configs/kitti_dataset.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DATASET: 'KittiDataset'
DATA_PATH: '../data/kitti'

POINT_CLOUD_RANGE: [0, -40, -3, 70.4, 40, 1]
POINT_CLOUD_RANGE: [-50, -50, -3, 70.4, 40, 1]

DATA_SPLIT: {
'train': train,
Expand Down
8 changes: 6 additions & 2 deletions tools/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ def __len__(self):
return len(self.sample_file_list)

def __getitem__(self, index):
if self.ext == '.bin':
file_postfix = self.sample_file_list[index].as_posix().split(".")[-1]
if file_postfix == 'bin':
points = np.fromfile(self.sample_file_list[index], dtype=np.float32).reshape(-1, 4)
elif self.ext == '.npy':
elif file_postfix == 'npy':
points = np.load(self.sample_file_list[index])
elif file_postfix == 'pcd':
print("\033[93mPlease run the pcd2bin file first!\033[0m Check the file in this folder, \n\ror click here: https://github.com/Kin-Zhang/OpenPCDet/blob/master/tools/pcd2bin.py \n\r")
raise NotImplementedError
else:
raise NotImplementedError

Expand Down
127 changes: 127 additions & 0 deletions tools/pcd2bin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#
# Module: pcd2bin.py
# Description: .pcd to .bin converter
#
# Author: Yuseung Na (ys.na0220@gmail.com) origin link: https://github.com/Yuseung-Na/pcd2bin
# Version: 1.0
# Date: January 19, 2021
#
# Author: Kin ZHANG (https://kin-zhang.github.io/)
# Version: 2.0
# Date: 2023-01-04

# Please run following to install the package: (TESTED on py37 py38), check issue: https://github.com/Yuseung-Na/pcd2bin/issues/8
# pip uninstall pypcd
# pip install --upgrade git+https://github.com/klintan/pypcd.git

# How to use:
# python3 pcd2bin.py --pcd_path /home/kin/test/data --bin_path /home/kin/test/data/bin

import numpy as np
import os
import argparse
from pypcd import pypcd
import csv
from tqdm import tqdm

def main():
## Add parser
parser = argparse.ArgumentParser(description="Convert .pcd to .bin")
parser.add_argument(
"--pcd_path",
help=".pcd file path.",
type=str,
default="/home/kin/test/data"
)
parser.add_argument(
"--bin_path",
help=".bin file path.",
type=str,
default="/home/kin/test/data"
)
parser.add_argument(
"--file_name",
help="File name.",
type=str,
default="file_name"
)
args = parser.parse_args()

## Find all pcd files
pcd_files = []
for (path, dir, files) in os.walk(args.pcd_path):
for filename in files:
# print(filename)
ext = os.path.splitext(filename)[-1]
if ext == '.pcd':
pcd_files.append(path + "/" + filename)

## Sort pcd files by file name
pcd_files.sort()
print("Finish to load point clouds!")

## Make bin_path directory
try:
if not (os.path.isdir(args.bin_path)):
os.makedirs(os.path.join(args.bin_path))
except OSError as e:
if e.errno != errno.EEXIST:
print ("Failed to create directory!!!!!")
raise

## Generate csv meta file
csv_file_path = os.path.join(args.bin_path, "meta.csv")
csv_file = open(csv_file_path, "w")
meta_file = csv.writer(
csv_file, delimiter=",", quotechar="|", quoting=csv.QUOTE_MINIMAL
)
## Write csv meta file header
meta_file.writerow(
[
"pcd file name",
"bin file name",
]
)
print("Finish to generate csv meta file")

## Converting Process
print("Converting Start!")
seq = 0
for pcd_file in tqdm(pcd_files):
## Get pcd file
pc = pypcd.PointCloud.from_path(pcd_file)

pcd_file_name = pcd_file.split("/")[-1].split(".")[0]
## Generate bin file name
bin_file_name = "{}.bin".format(pcd_file_name)
bin_file_path = os.path.join(args.bin_path, bin_file_name)

## Get data from pcd (x, y, z, intensity, ring, time)
np_x = (np.array(pc.pc_data['x'], dtype=np.float32)).astype(np.float32)
np_y = (np.array(pc.pc_data['y'], dtype=np.float32)).astype(np.float32)
np_z = (np.array(pc.pc_data['z'], dtype=np.float32)).astype(np.float32)
np_i = np.zeros_like(np_x)
if 'intensity' in pc.fields:
np_i = (np.array(pc.pc_data['intensity'], dtype=np.float32)).astype(np.float32)/256
elif 'Intensity' in pc.fields:
np_i = (np.array(pc.pc_data['Intensity'], dtype=np.float32)).astype(np.float32)/256
else:
print(f"The pt fields: {pc.fields}. Please check whether there is an intensity field and add to codes")
# np_r = (np.array(pc.pc_data['ring'], dtype=np.float32)).astype(np.float32)
# np_t = (np.array(pc.pc_data['time'], dtype=np.float32)).astype(np.float32)

## Stack all data
points_32 = np.transpose(np.vstack((np_x, np_y, np_z, np_i)))

## Save bin file
points_32.tofile(bin_file_path)

## Write csv meta file
meta_file.writerow(
[os.path.split(pcd_file)[-1], bin_file_name]
)

seq = seq + 1

if __name__ == "__main__":
main()