├── .clang-tidy
├── .gitignore
├── CHANGELOG.md
├── CMakeLists.txt
├── LICENSE
├── Makefile
├── README.md
├── icon.png
├── include
└── cvplot
│ ├── color.h
│ ├── cvplot.h
│ ├── figure.h
│ ├── highgui.h
│ └── window.h
├── res
├── demo.jpg
└── line.jpg
├── src
├── cvplot
│ ├── color.cc
│ ├── figure.cc
│ ├── highgui.cc
│ ├── internal.h
│ └── window.cc
└── demo
│ └── demo.cc
└── test
└── cvplot
├── color_test.cc
├── figure_test.cc
└── window_test.cc
/.clang-tidy:
--------------------------------------------------------------------------------
1 | Checks: '*,-llvmlibc-*,-bugprone-*,-hicpp-*,-fuchsia-*,-altera-*,-*-magic-numbers'
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
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
33 |
34 | build/
35 | bin/
36 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Change Log
2 | ==========
3 |
4 | ### master (untagged)
5 |
6 | * Remove window tick
7 | * Remove paleness
8 | * Remove color uniq
9 | * Add lint rules
10 |
11 | ### 0.0.4 (2022-06-03)
12 |
13 | * Fix for axis color
14 | * Add draw to PNG file
15 | * More contrast, bye pale
16 | * Text sizing and drop shadow
17 | * Build and format fixes (thanks @palerikm)
18 |
19 | ### 0.0.3 (2018-01-05)
20 |
21 | * Add highgui wrapper
22 | * Add mouse
23 | * Add auto flush
24 |
25 | ### 0.0.2 (2018-01-03)
26 |
27 | * Add transparency demo
28 | * Add fill line type
29 |
30 | ### 0.0.1 (2017-12-22)
31 |
32 | * Add dynamic color
33 |
34 | ### 0.0.0 (2017-12-19)
35 |
36 | * Initial release
37 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0)
2 |
3 | project (cvplot)
4 |
5 | find_package(OpenCV REQUIRED)
6 |
7 | include_directories(include)
8 | include_directories(${OpenCV_INCLUDE_DIRS})
9 |
10 | set(CMAKE_CXX_STANDARD 11)
11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC ")
12 | set(CVPLOT_LIB cvplot)
13 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
14 | set(GOOGLE_TEST_VERSION "1.11.0")
15 |
16 | find_program(CLANG_TIDY_EXISTS clang-tidy)
17 | if(CLANG_TIDY_EXISTS AND NOT DEFINED CVPLOT_TEST)
18 | set(CMAKE_CXX_CLANG_TIDY clang-tidy)
19 | endif()
20 |
21 | if (DEFINED CVPLOT_LIB)
22 | file(GLOB LIB_SOURCES "${PROJECT_SOURCE_DIR}/src/cvplot/*.cc")
23 | add_library(${CVPLOT_LIB} ${LIB_SOURCES})
24 | endif()
25 |
26 | if (${CVPLOT_DEMO})
27 | file(GLOB BIN_SOURCES "${PROJECT_SOURCE_DIR}/src/demo/*.cc")
28 | foreach(filename ${BIN_SOURCES})
29 | get_filename_component(name ${filename} NAME_WE)
30 | add_executable(${name} ${filename})
31 | target_link_libraries(${name} ${CVPLOT_LIB} ${OpenCV_LIBS})
32 | endforeach()
33 | endif()
34 |
35 | target_include_directories ( cvplot PUBLIC ../include )
36 | target_include_directories ( cvplot PRIVATE ../src )
37 |
38 | install ( TARGETS cvplot
39 | LIBRARY DESTINATION lib
40 | ARCHIVE DESTINATION lib
41 | RUNTIME DESTINATION bin)
42 |
43 | install ( DIRECTORY include DESTINATION .
44 | PATTERN CMakeLists.txt EXCLUDE )
45 |
46 | if (${CVPLOT_TEST})
47 | include(FetchContent)
48 | FetchContent_Declare(googletest URL "https://github.com/google/googletest/archive/refs/tags/release-${GOOGLE_TEST_VERSION}.zip")
49 | FetchContent_MakeAvailable(googletest)
50 | enable_testing()
51 | include(GoogleTest)
52 |
53 | file(GLOB TEST_SOURCES "${PROJECT_SOURCE_DIR}/test/cvplot/*_test.cc")
54 | foreach(filename ${TEST_SOURCES})
55 | get_filename_component(name ${filename} NAME_WE)
56 | add_executable(${name} ${filename})
57 | target_link_libraries(${name} gtest_main ${CVPLOT_LIB} ${OpenCV_LIBS})
58 | gtest_discover_tests(${name})
59 | endforeach()
60 | endif()
61 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Leo Vandriel
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Proxy to CMake
2 |
3 | .PHONY: all clean demo test format
4 |
5 | all:
6 | @mkdir -p build && cd build && cmake .. && make
7 |
8 | debug:
9 | @rm -rf build && mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. && make
10 |
11 | clean:
12 | @rm -rf build bin
13 |
14 | demo:
15 | @mkdir -p build && cd build && cmake -DCVPLOT_DEMO=1 .. >/dev/null && make >/dev/null
16 | @./bin/demo
17 |
18 | test:
19 | @mkdir -p build && cd build && cmake -DCVPLOT_TEST=1 .. >/dev/null && make >/dev/null
20 | @find bin -regex "bin/[a-z_]*_test" -type f -exec ./{} \;
21 |
22 | format:
23 | @find . -iname "*.h" -o -iname "*.cc" | xargs clang-format --style=Google -i
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # cvplot
4 |
5 | *Graph plots, drawing, layout and windows in OpenCV.*
6 |
7 |
8 | ## About
9 |
10 | Yet another cvplot library? Yes. Because they're all pretty bad. Like this one.
11 |
12 |
13 | ## Build
14 |
15 | Install the dependencies CMake and [OpenCV](https://github.com/opencv/opencv). If you're on macOS, use Homebrew:
16 |
17 | brew install cmake opencv
18 |
19 | On Ubuntu:
20 |
21 | apt-get install cmake libopencv-dev
22 |
23 | Next build using CMake. The easiest way:
24 |
25 | make
26 |
27 | Internally it creates a `build` folder and runs CMake from there.
28 |
29 | This project is developed and tested on macOS and Ubuntu.
30 |
31 |
32 | ## Example
33 |
34 | To draw a simple line graph:
35 |
36 | cvplot::figure("myplot").series("myline")
37 | .addValue({1., 3., 2., 5., 4.});
38 | cvplot::figure("myplot").show();
39 |
40 |
41 |
42 |
43 | ## Features
44 |
45 | - Graphs: line, histogram, scatter
46 | - Time series, parametric, range
47 | - Automatic and dynamic coloring
48 | - Transparency (yes, really)
49 | - Image and text drawing
50 | - Sub-windows (views)
51 | - Window and view layout
52 | - Green view frame
53 | - Mouse support
54 | - OpenCV-like API (highgui)
55 |
56 |
57 | ## Demo
58 |
59 | To see some of the plotting in action, run the demo:
60 |
61 | make demo
62 |
63 | To learn more about these examples, take a look at `src/demo/demo.cc`.
64 |
65 |
66 |
67 | ## Test
68 |
69 | Run tests with:
70 |
71 | make test
72 |
73 |
74 | ## Contributing
75 |
76 | Your contributions to cvplot are welcome! cvplot is small and nimble, with lots of missing features. If you would like to see a new feature, get your code merged, or report a bug, please don't hesitate to reach out by filing a PR or issue.
77 |
78 |
79 | ## License
80 |
81 | MIT
82 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leovandriel/cvplot/2175092e95fce25464f849a84d3347da374ea813/icon.png
--------------------------------------------------------------------------------
/include/cvplot/color.h:
--------------------------------------------------------------------------------
1 | #ifndef CVPLOT_COLOR_H
2 | #define CVPLOT_COLOR_H
3 |
4 | #include
5 |
6 | namespace cvplot {
7 |
8 | struct Color {
9 | uint8_t r, g, b, a;
10 | Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
11 | : r(r), g(g), b(b), a(a) {}
12 | Color(const uint8_t *rgb, uint8_t a = 255)
13 | : Color(rgb[0], rgb[1], rgb[2], a) {}
14 | Color() : Color(0, 0, 0) {}
15 |
16 | auto alpha(uint8_t alpha) const -> Color;
17 | auto gamma(double gamma) const -> Color;
18 | auto hue() const -> double;
19 |
20 | static auto gray(uint8_t v) -> Color;
21 | static auto hue(double hue) -> Color;
22 | static auto cos(double hue) -> Color;
23 | static auto index(uint8_t index, uint8_t density = 16, double avoid = 2.,
24 | double range = 2.) -> Color;
25 | static auto hash(const std::string &seed) -> Color;
26 | };
27 |
28 | static const Color Red = Color::hue(0.);
29 | static const Color Orange = Color::hue(.5);
30 | static const Color Yellow = Color::hue(1.);
31 | static const Color Lawn = Color::hue(1.5);
32 | static const Color Green = Color::hue(2.);
33 | static const Color Aqua = Color::hue(2.5);
34 | static const Color Cyan = Color::hue(3.);
35 | static const Color Sky = Color::hue(3.5);
36 | static const Color Blue = Color::hue(4.);
37 | static const Color Purple = Color::hue(4.5);
38 | static const Color Magenta = Color::hue(5.);
39 | static const Color Pink = Color::hue(5.5);
40 | static const Color Black = Color::gray(0);
41 | static const Color Dark = Color::gray(32);
42 | static const Color Gray = Color::gray(128);
43 | static const Color Light = Color::gray(223);
44 | static const Color White = Color::gray(255);
45 |
46 | } // namespace cvplot
47 |
48 | #endif // CVPLOT_COLOR_H
49 |
--------------------------------------------------------------------------------
/include/cvplot/cvplot.h:
--------------------------------------------------------------------------------
1 | #ifndef CVPLOT_H
2 | #define CVPLOT_H
3 |
4 | #include "color.h"
5 | #include "figure.h"
6 | #include "highgui.h"
7 | #include "window.h"
8 |
9 | #endif // CVPLOT_H
10 |
--------------------------------------------------------------------------------
/include/cvplot/figure.h:
--------------------------------------------------------------------------------
1 | #ifndef CVPLOT_FIGURE_H
2 | #define CVPLOT_FIGURE_H
3 |
4 | #include