Skip to content

Commit

Permalink
Improving README + docker fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adujardin committed Jun 14, 2019
1 parent e16f322 commit 17dbeec
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 20 deletions.
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,42 @@ This is a brief explanation on how to enable the ZED camera support.

- Windows 7 64bits or later, Ubuntu 16.04 or 18.04
- [ZED SDK](https://www.stereolabs.com/developers/) and its dependencies ([CUDA](https://developer.nvidia.com/cuda-downloads))
- **Darknet** : https://github.com/AlexeyAB/darknet
- **Darknet** : https://github.com/AlexeyAB/darknet and its dependencies ([cuDNN](https://developer.nvidia.com/cudnn) and OpenCV)

## Installing Darknet
## Preparing Darknet installation

### cuDNN

In order to get the best performance, [cuDNN](https://developer.nvidia.com/cudnn) should be install before compiling darknet. Heads over to this [TensorFlow documentation article](https://www.tensorflow.org/install/gpu#install_cuda_with_apt) which explains how to setup both CUDA and cuDNN on Ubuntu and Windows.

### OpenCV

OpenCV binaries can be downloaded and install from [opencv.org](https://opencv.org/releases/).

Alternatively, on Ubuntu :

sudo apt install pkg-config libopencv-dev

### CMake

On Windows, download and install CMAKE using the binary [available here](https://cmake.org/download/).

On Ubuntu, cmake can be installed using the package manager, i.e : `sudo apt install cmake`

However the default version of cmake might be too old, it can easily be updated using the script (located in this repository):

```bash
sudo bash cmake_apt_update.sh
```

## Compiling Darknet

[Download](https://github.com/AlexeyAB/darknet) and compile darknet, following the instructions:

- [How to compile on Linux](https://github.com/AlexeyAB/darknet#how-to-compile-on-linux)
- [How to compile on Windows](https://github.com/AlexeyAB/darknet#how-to-compile-on-windows-using-vcpkg)

### ZED Support Using CMake
### ZED Support Using CMake (recommended)

If the ZED SDK is installed, CMake will automatically detect it and compile with the ZED support. During the CMake configuration, a message will confirm that the ZED SDK was found.

Expand All @@ -33,17 +59,21 @@ If the ZED SDK is installed, CMake will automatically detect it and compile with
-- Found OpenMP_C: -fopenmp (found version "4.5")
...


### ZED support Using Makefile

To enable the ZED support in YOLO using the Makefile, simply enable [`GPU` and `ZED_CAMERA`](https://github.com/AlexeyAB/darknet/blob/cce34712f6928495f1fbc5d69332162fc23491b9/Makefile#L8), it's also recommended to enable `CUDNN` for improved performances.

## 2. Launching the sample

./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights zed_camera
Download the yolo weights, either [yolov3](https://pjreddie.com/media/files/yolov3.weights) or [yolov3-tiny](https://pjreddie.com/media/files/yolov3-tiny.weights) for instance, and put them in the local folder.


./uselib data/coco.names cfg/yolov3.cfg yolov3.weights zed_camera

SVO files are also supported :

./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights /path/to/svo/file.svo
./uselib data/coco.names cfg/yolov3.cfg yolov3.weights /path/to/svo/file.svo

## How to use YOLO 3D in Python

Expand Down
19 changes: 19 additions & 0 deletions cmake_apt_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi

# https://apt.kitware.com/
if [ -n "$(uname -a | grep Ubuntu)" ]; then
apt-get update ; apt-get install lsb-release apt-transport-https ca-certificates gnupg software-properties-common wget -y
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
codename=`lsb_release --codename | cut -f2`
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ '$codename' main'
apt-get install kitware-archive-keyring
apt-key --keyring /etc/apt/trusted.gpg del C1F34CDD40CD72DA
apt-get cmake
else
echo "This script is only meant for Ubuntu"
fi
19 changes: 12 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM stereolabs/zed:ubuntu1604-cuda9.0-zed2.7-gl
FROM stereolabs/zed:ubuntu1604-cuda9.0-zed2.8-gl

ENV CUDNN_VERSION 7.4.1.5

RUN apt-get update && apt-get upgrade -y
RUN apt-get install python3-dev python3-pip unzip sudo libopencv-dev -y
RUN apt-get install -y --no-install-recommends libcudnn7=$CUDNN_VERSION-1+cuda9.0 libcudnn7-dev=$CUDNN_VERSION-1+cuda9.0 && apt-mark hold libcudnn7
RUN apt-get update && apt-get upgrade -y ; \
apt-get install python3-dev python3-pip unzip sudo libopencv-dev apt-transport-https ca-certificates gnupg software-properties-common wget -y ; \
apt-get install -y --no-install-recommends libcudnn7=$CUDNN_VERSION-1+cuda9.0 libcudnn7-dev=$CUDNN_VERSION-1+cuda9.0 && apt-mark hold libcudnn7

RUN sudo chmod 777 -R /usr/local/zed ; \
pip3 install --upgrade pip opencv-python ; \
Expand All @@ -15,12 +15,17 @@ USER docker
WORKDIR /home/docker

RUN git clone http://github.com/stereolabs/zed-python.git ; \
cd zed-python; sudo pip3 install -r requirements.txt; sudo python3 setup.py install
cd zed-python; sudo pip3 install -r requirements.txt; sudo python3 setup.py install ; cd .. ; sudo rm -rf zed-python

RUN git clone https://github.com/stereolabs/zed-yolo.git ; \
cd zed-yolo/libdarknet ; make -j8
cd zed-yolo ; sudo bash cmake_apt_update.sh ; \
cd libdarknet ; make -j8

RUN git clone https://github.com/alexeyAB/darknet.git ; \
cd darknet ; cmake . ; make -j8

WORKDIR /home/docker/zed-yolo/
RUN wget https://pjreddie.com/media/files/yolov3-tiny.weights ; \
ln -s /home/docker/zed-yolo/yolov3-tiny.weights /home/docker/zed-yolo/zed_python_sample/
ln -s /home/docker/zed-yolo/yolov3-tiny.weights /home/docker/zed-yolo/zed_python_sample/ ; \
ln -s /home/docker/zed-yolo/yolov3-tiny.weights /home/docker/darknet/
CMD /bin/bash
11 changes: 3 additions & 8 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ python3 darknet_zed.py -s /data/<path/to/SVO>

### Run the C++ sample

From within the container compile the C++ sample :
From within the container the C++ sample can be started :

```Bash
cd /home/docker/zed-yolo/zed_cpp_sample/ ; mkdir build ; cd build; cmake .. ; make ; cd /home/docker/zed-yolo/
```

Then start it :

```Bash
zed_cpp_sample/build/darknet_zed libdarknet/data/coco.names libdarknet/cfg/yolov3-tiny.cfg yolov3-tiny.weights /data/<path/to/SVO>
cd ~/darknet
./uselib libdarknet/data/coco.names libdarknet/cfg/yolov3-tiny.cfg yolov3-tiny.weights /data/<path/to/SVO>
```

0 comments on commit 17dbeec

Please sign in to comment.