Skip to content

Commit eb65105

Browse files
authored
Merge pull request #1 from rerun-io/roym899/cpp_example
Add C++ example with OpenCV and Eigen
2 parents 628dd6d + c97cef5 commit eb65105

File tree

8 files changed

+15185
-31
lines changed

8 files changed

+15185
-31
lines changed

.clang-format

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
BasedOnStyle: Google
2+
3+
# Make it slightly more similar to Rust.
4+
# Based loosely on https://gist.github.com/YodaEmbedding/c2c77dc693d11f3734d78489f9a6eea4
5+
AccessModifierOffset: -2
6+
AlignAfterOpenBracket: BlockIndent
7+
AllowAllArgumentsOnNextLine: false
8+
AllowShortBlocksOnASingleLine: false
9+
AllowShortCaseLabelsOnASingleLine: false
10+
AllowShortFunctionsOnASingleLine: Empty
11+
AllowShortIfStatementsOnASingleLine: Never
12+
AlwaysBreakAfterReturnType: None
13+
AlwaysBreakBeforeMultilineStrings: true
14+
BinPackArguments: false
15+
BreakStringLiterals: false
16+
ColumnLimit: 100
17+
ContinuationIndentWidth: 4
18+
DerivePointerAlignment: false
19+
EmptyLineBeforeAccessModifier: LogicalBlock
20+
IndentWidth: 4
21+
IndentWrappedFunctionNames: true
22+
InsertTrailingCommas: Wrapped
23+
MaxEmptyLinesToKeep: 1
24+
NamespaceIndentation: All
25+
PointerAlignment: Left
26+
ReflowComments: false
27+
SeparateDefinitionBlocks: Always
28+
SpacesBeforeTrailingComments: 1
29+
30+
# Don't change include blocks, we want to control this manually.
31+
# Sorting headers however is allowed as all our headers should be standalone.
32+
IncludeBlocks: Preserve
33+
SortIncludes: CaseInsensitive

.gitignore

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,5 @@
1-
# Prerequisites
2-
*.d
1+
# Build directory
2+
build
33

4-
# Compiled Object files
5-
*.slo
6-
*.lo
7-
*.o
8-
*.obj
9-
10-
# Precompiled Headers
11-
*.gch
12-
*.pch
13-
14-
# Compiled Dynamic libraries
15-
*.so
16-
*.dylib
17-
*.dll
18-
19-
# Fortran module files
20-
*.mod
21-
*.smod
22-
23-
# Compiled Static libraries
24-
*.lai
25-
*.la
26-
*.a
27-
*.lib
28-
29-
# Executables
30-
*.exe
31-
*.out
32-
*.app
4+
# Pixi environment
5+
.pixi

CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
project(rerun_external_cpp_proj LANGUAGES CXX)
4+
5+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6+
7+
if(NOT DEFINED CMAKE_CXX_STANDARD)
8+
set(CMAKE_CXX_STANDARD 17)
9+
endif()
10+
11+
include(FetchContent)
12+
FetchContent_Declare(rerun_sdk URL https://build.rerun.io/commit/06dd483/rerun_cpp_sdk.zip) # 2023-10-20
13+
FetchContent_MakeAvailable(rerun_sdk)
14+
15+
find_package(Eigen3 REQUIRED)
16+
find_package(OpenCV REQUIRED)
17+
18+
add_executable(rerun_ext_example src/main.cpp)
19+
20+
target_link_libraries(rerun_ext_example Eigen3::Eigen ${OpenCV_LIBS} rerun_sdk)

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# C++ Example with OpenCV and Eigen
2+
3+
This is a minimal CMake project that shows how to use [Rerun](https://github.com/rerun-io/rerun) in your code in conjunction with [Eigen](https://eigen.tuxfamily.org/) and [OpenCV](https://opencv.org/).
4+
5+
## Installing the Rerun viewer
6+
The Rerun C++ SDK works by connecting to an awaiting Rerun Viewer over TCP.
7+
8+
#### Building from source
9+
* [Install `cargo`](https://rustup.rs/)
10+
* `cargo install rerun-cli`
11+
12+
#### Using `pip`
13+
* `pip install rerun-sdk`
14+
15+
### Running the Rerun viewer
16+
Just type `rerun` and the rerun viewer should show up. Then it is time to run this example!
17+
18+
19+
## Run this example
20+
21+
### Using `pixi`
22+
The easiest way to get started is to install [pixi](https://prefix.dev/docs/pixi/overview).
23+
24+
* Start the rerun viewer with `rerun` (see above)
25+
* Run the example with `rerun run run`
26+
27+
28+
### Manually
29+
First install the required dependencies:
30+
* `arrow-cpp`` (required by Rerun)
31+
* `eigen` and `opencv` (required by this example)
32+
* `cmake` and `ninja` (build tools)
33+
34+
Build using:
35+
36+
```bash
37+
mkdir build
38+
cd build
39+
cmake ..
40+
cmake --build . -- -j8
41+
```
42+
43+
Then run the binary with:
44+
45+
`build/rerun_ext_example`

0 commit comments

Comments
 (0)