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

Restructured README.md #232

Merged
merged 3 commits into from
Oct 21, 2021
Merged
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
101 changes: 55 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,53 @@ MacOS: `brew install libusb`, optionally with `brew install opencv`

Linux: `sudo apt install libusb-1.0-0-dev`, optionally with `sudo apt install libopencv-dev`

## Building

Make sure submodules are updated
```
git submodule update --init --recursive
```

Then configure and build

```
cmake -S. -Bbuild
cmake --build build
```

> ℹ️ To speed up build times, use `cmake --build build --parallel [num CPU cores]` (CMake >= 3.12).
For older versions use: Linux/macOS: `cmake --build build -- -j[num CPU cores]`, MSVC: `cmake --build build -- /MP[num CPU cores]`

> ⚠️ If any CMake commands error with `CMake Error: The source directory "" does not exist.` replace argument `-S` with `-H`

### Dynamic library

To build dynamic version of library configure with following option added
```
cmake -S. -Bbuild -D BUILD_SHARED_LIBS=ON
cmake --build build
```

## Running examples

To build the examples configure with following option added
```
cmake -S. -Bbuild -D DEPTHAI_BUILD_EXAMPLES=ON
cmake --build build
```

Then navigate to `build/examples` folder and run a preferred example
```
cd build/examples
./MobileNet/rgb_mobilenet
```

> ℹ️ Multi-Config generators (like Visual Studio on Windows) will have the examples built in `build/examples/MobileNet/[Debug/Release/...]/rgb_mobilenet`

## Integration

Under releases you may find prebuilt library for Windows, for use in either integration method. See [Releases](https://github.com/luxonis/depthai-core/releases)

### CMake

Targets available to link to are:
Expand All @@ -31,7 +76,7 @@ Targets available to link to are:

#### Using find_package

Build static or dynamic version of library and install (See: [Building](##building) and [Installing](##installing))
Build static or dynamic version of library (See: [Building](##building) and optionally [Installing](##installing))

Add `find_package` and `target_link_libraries` to your project
```
Expand Down Expand Up @@ -69,14 +114,16 @@ target_link_libraries([my-app] PRIVATE depthai::opencv)
To integrate into a different build system than CMake, prefered way is compiling as dynamic library and setting correct build options.
1. First build as dynamic library: [Building Dynamic library](###dynamic-library)
2. Then install: [Installing](##installing)
3. Set needed library directories:

In your non-CMake project (new Visual Studio project, ...)
1. Set needed library directories:
- `build/install/lib` (for linking to either depthai-core or depthai-opencv)
- `build/install/bin` (for .dll's)
4. And include directories
2. And include directories
- `build/install/include` (library headers)
- `build/install/include/depthai-shared/3rdparty` (shared 3rdparty headers)
- `build/install/lib/cmake/depthai/dependencies/include` (dependency headers)
5. Add the following defines
3. Add the following defines
- `XLINK_USE_MX_ID_NAME=ON`
- `__PC__=ON`

Expand All @@ -85,43 +132,22 @@ To integrate into a different build system than CMake, prefered way is compiling
> ℹ️ Check `build/depthai-core-integration.txt` or `build/depthai-opencv-integration.txt` for up to date define options.
The generated integration file also specifies include paths without requiring installation.

## Building

Make sure submodules are updated
```
git submodule update --init --recursive
```

> ℹ️ To speed up build times, use `cmake --build build --parallel [num CPU cores]` (CMake >= 3.12).
For older versions use: Linux/macOS: `cmake --build build -- -j[num CPU cores]`, MSVC: `cmake --build build -- /MP[num CPU cores]`

### Static library
```
cmake -H. -Bbuild
cmake --build build
```

### Dynamic library
```
cmake -H. -Bbuild -D BUILD_SHARED_LIBS=ON
cmake --build build
```
## Installing

To install specify optional prefix and build target install
```
cmake -H. -Bbuild -D CMAKE_INSTALL_PREFIX=[path/to/install/dir]
cmake --build build
cmake -S. -Bbuild -D CMAKE_INSTALL_PREFIX=[path/to/install/dir]
cmake --build build --target install
```

If `CMAKE_INSTALL_PREFIX` isn't specified, the library is installed under build folder `install`.


## Running tests

To run the tests build the library with the following options
```
cmake -H. -Bbuild -D DEPTHAI_TEST_EXAMPLES=ON -D DEPTHAI_BUILD_TESTS=ON -D DEPTHAI_BUILD_EXAMPLES=ON
cmake -S. -Bbuild -D DEPTHAI_TEST_EXAMPLES=ON -D DEPTHAI_BUILD_TESTS=ON -D DEPTHAI_BUILD_EXAMPLES=ON
cmake --build build
```

Expand All @@ -131,23 +157,6 @@ cd build
ctest
```

## Running examples

To run the tests build the library with the following options
```
cmake -H. -Bbuild -D DEPTHAI_BUILD_EXAMPLES=ON
cmake --build build
```

Then navigate to `build/examples` folder and run a preferred example
```
cd build/examples
./rgb_mobilenet
```

Please be aware that multi config generators (like Visual Studio on Windows) will have the examples built in `build/examples/[Debug/Release/...]/rgb_mobilenet`


## Style check

The library uses clang format to enforce a certain coding style.
Expand Down Expand Up @@ -196,7 +205,7 @@ If your build process happen to fail due to OpenCV library not being found, but
run build with additional `-D OpenCV_DIR` flag (replacing default Ubuntu path `/usr/lib/x86_64-linux-gnu/cmake/opencv4` with yours)

```
cmake -H. -Bbuild -D OpenCV_DIR=/usr/lib/x86_64-linux-gnu/cmake/opencv4
cmake -S. -Bbuild -D OpenCV_DIR=/usr/lib/x86_64-linux-gnu/cmake/opencv4
```

Now the build process should correctly discover your OpenCV installation
Expand Down