Spaces:
Sleeping
Sleeping
c9887c76edf8bc22d935c6d311b9bc08e1b7b0e1fc7c155f7fc2fc66524fb1e7
Browse files- third-party/DPVO/Pangolin/LICENCE +22 -0
- third-party/DPVO/Pangolin/README.md +235 -0
- third-party/DPVO/Pangolin/examples/HelloPangolin/CMakeLists.txt +6 -0
- third-party/DPVO/Pangolin/examples/HelloPangolin/main.cpp +37 -0
- third-party/DPVO/Pangolin/examples/HelloPangolinOffscreen/CMakeLists.txt +6 -0
- third-party/DPVO/Pangolin/examples/HelloPangolinOffscreen/main.cpp +44 -0
- third-party/DPVO/Pangolin/examples/HelloPangolinThreads/CMakeLists.txt +9 -0
- third-party/DPVO/Pangolin/examples/HelloPangolinThreads/main.cpp +67 -0
- third-party/DPVO/Pangolin/examples/PythonExamples/SimpleDisplay.py +65 -0
- third-party/DPVO/Pangolin/examples/PythonExamples/SimplePlot.py +36 -0
- third-party/DPVO/Pangolin/examples/PythonExamples/SimpleVideo.py +58 -0
- third-party/DPVO/Pangolin/examples/SharedMemoryCamera/CMakeLists.txt +7 -0
- third-party/DPVO/Pangolin/examples/SharedMemoryCamera/main.cpp +53 -0
- third-party/DPVO/Pangolin/examples/SimpleDisplay/CMakeLists.txt +7 -0
- third-party/DPVO/Pangolin/examples/SimpleDisplay/app.cfg +26 -0
- third-party/DPVO/Pangolin/examples/SimpleDisplay/main.cpp +96 -0
- third-party/DPVO/Pangolin/examples/SimpleDisplayImage/CMakeLists.txt +6 -0
- third-party/DPVO/Pangolin/examples/SimpleDisplayImage/main.cpp +76 -0
- third-party/DPVO/Pangolin/examples/SimpleMultiDisplay/CMakeLists.txt +6 -0
- third-party/DPVO/Pangolin/examples/SimpleMultiDisplay/app.cfg +28 -0
- third-party/DPVO/Pangolin/examples/SimpleMultiDisplay/main.cpp +108 -0
- third-party/DPVO/Pangolin/examples/SimplePlot/CMakeLists.txt +6 -0
- third-party/DPVO/Pangolin/examples/SimplePlot/main.cpp +48 -0
- third-party/DPVO/Pangolin/examples/SimpleRecord/CMakeLists.txt +6 -0
- third-party/DPVO/Pangolin/examples/SimpleRecord/main.cpp +100 -0
- third-party/DPVO/Pangolin/examples/SimpleScene/CMakeLists.txt +6 -0
- third-party/DPVO/Pangolin/examples/SimpleScene/main.cpp +46 -0
- third-party/DPVO/Pangolin/examples/SimpleVideo/CMakeLists.txt +6 -0
- third-party/DPVO/Pangolin/examples/SimpleVideo/main.cpp +114 -0
- third-party/DPVO/Pangolin/examples/VBODisplay/CMakeLists.txt +19 -0
- third-party/DPVO/Pangolin/examples/VBODisplay/kernal.cu +30 -0
- third-party/DPVO/Pangolin/examples/VBODisplay/main.cpp +84 -0
- third-party/DPVO/Pangolin/package.xml +19 -0
- third-party/DPVO/Pangolin/scripts/install_prerequisites.sh +182 -0
- third-party/DPVO/Pangolin/scripts/utils/ansi2html.sh +527 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/.vcpkg-root +0 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/CHANGELOG.md +0 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/CONTRIBUTING.md +33 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/CONTRIBUTING_zh.md +33 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/bootstrap-vcpkg.bat +2 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/bootstrap-vcpkg.sh +4 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/docs/_config.yml +1 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/docs/about/faq.md +120 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/docs/about/privacy.md +50 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/installing-and-using-packages.md +180 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/manifest-mode-cmake.md +200 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/modify-baseline-to-pin-old-boost.md +190 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/overlay-triplets-linux-dynamic.md +126 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/packaging-github-repos.md +54 -0
- third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/packaging-zipfiles.md +76 -0
third-party/DPVO/Pangolin/LICENCE
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2011 Steven Lovegrove and Richard Newcombe
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person
|
4 |
+
obtaining a copy of this software and associated documentation
|
5 |
+
files (the "Software"), to deal in the Software without
|
6 |
+
restriction, including without limitation the rights to use,
|
7 |
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8 |
+
copies of the Software, and to permit persons to whom the
|
9 |
+
Software is furnished to do so, subject to the following
|
10 |
+
conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be
|
13 |
+
included in all copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17 |
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19 |
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20 |
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22 |
+
OTHER DEALINGS IN THE SOFTWARE.
|
third-party/DPVO/Pangolin/README.md
ADDED
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
What is Pangolin
|
2 |
+
====================================
|
3 |
+
|
4 |
+
Pangolin is a set of lightweight and portable utility libraries for prototyping 3D, numeric or video based programs and algorithms. It is used quite widely in the field of Computer Vision as a means to remove platform-specific boilerplate and make it easy to visualize data.
|
5 |
+
|
6 |
+
The general ethos of Pangolin is to minimize boilerplate and maximize portability and flexibility through simple interfaces and factories over things like windowing and video. It also offers a suite of utilities for interactive debugging, such as 3D manipulation, plotters, tweak variables, and a drop-down Quake-like console for python scripting and live tweaking.
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
## Main features
|
11 |
+
|
12 |
+
* Cross Platform Windowing
|
13 |
+
* Build for **Windows**, **Linux**, **OSX** and the **Web** (with [Emscripten](https://emscripten.org/))
|
14 |
+
* Support different windowing implementations including off-screen buffers
|
15 |
+
* Viewport Management and Interaction
|
16 |
+
* Simple and performant viewport management
|
17 |
+
* Intuitive 3D navigation and handlers
|
18 |
+
* Utilities to work with Computer Vision & Robotics camera and coordinate conventions
|
19 |
+
* Video Input and Output
|
20 |
+
* Extensive video input/output wrappers for ordinary and machine-vision cameras and media formats
|
21 |
+
* Flexible filter interface for easily post-processing video channels and formats, etc.
|
22 |
+
* Tweak Variables
|
23 |
+
* There are 101 widgeting libraries and several 'tweak' var libraries - Pangolin offers another implementation with a few pros and cons
|
24 |
+
* One-line definitions and extensible types
|
25 |
+
* Drop-down Console
|
26 |
+
* Extensible for different shells, but currently supports Python live console
|
27 |
+
* Easy access to introspect tweak variables
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
## Code ##
|
32 |
+
|
33 |
+
Find the latest version on [Github](http://github.com/stevenlovegrove/Pangolin):
|
34 |
+
|
35 |
+
```bash
|
36 |
+
# Clone Pangolin along with it's submodules
|
37 |
+
git clone --recursive https://github.com/stevenlovegrove/Pangolin.git
|
38 |
+
```
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
## Dependencies ##
|
43 |
+
|
44 |
+
*Pangolin* is split into a few *components* so you can include just what you need. Most dependencies are *optional* so you can pick and mix for your needs. Rather than enforcing a particular package manager, you can use a simple [script](https://github.com/stevenlovegrove/Pangolin/blob/master/scripts/install_prerequisites.sh) to generate a list of (**required**, **recommended** or **all**) packages for installation for that manager (e.g. apt, port, brew, dnf, vcpkg):
|
45 |
+
|
46 |
+
```bash
|
47 |
+
# See what package manager and packages are recommended
|
48 |
+
./scripts/install_prerequisites.sh --dry-run recommended
|
49 |
+
|
50 |
+
# Override the package manager choice and install all packages
|
51 |
+
./scripts/install_prerequisites.sh -m brew all
|
52 |
+
```
|
53 |
+
|
54 |
+
You'll see the dependencies are generally
|
55 |
+
|
56 |
+
* Build system (cmake, **required**)
|
57 |
+
* Windowing system (X11, Cocoa, Win, Web, ...)
|
58 |
+
* Rendering (OpenGL, GLES)
|
59 |
+
* Video and Image loading (DC1394, ffmpeg, jpeg, png, ...)
|
60 |
+
* Wrappers / Cross Compilers (Python3, pybind, Emscripten, ...)
|
61 |
+
|
62 |
+
Pangolin does it's best to build something with what it gets, so dependencies which are not found will be silently ignored. If you need a particular feature, check the output of the `cmake ..` stage and look for the *Found and Enabled* lines.
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
## Building ##
|
67 |
+
|
68 |
+
Pangolin uses the CMake portable pre-build tool. To checkout and build pangolin in the
|
69 |
+
directory 'build', execute the following at a shell (or the equivalent using a GUI):
|
70 |
+
|
71 |
+
```bash
|
72 |
+
# Get Pangolin
|
73 |
+
cd ~/your_fav_code_directory
|
74 |
+
git clone --recursive https://github.com/stevenlovegrove/Pangolin.git
|
75 |
+
cd Pangolin
|
76 |
+
|
77 |
+
# Install dependencies (as described above, or your preferred method)
|
78 |
+
./scripts/install_prerequisites.sh recommended
|
79 |
+
|
80 |
+
# Configure and build
|
81 |
+
cmake -B build
|
82 |
+
cmake --build build
|
83 |
+
|
84 |
+
# with Ninja for faster builds (sudo apt install ninja-build)
|
85 |
+
cmake -B build -GNinja
|
86 |
+
cmake --build build
|
87 |
+
|
88 |
+
# GIVEME THE PYTHON STUFF!!!! (Check the output to verify selected python version)
|
89 |
+
cmake --build build -t pypangolin_pip_install
|
90 |
+
|
91 |
+
# Run me some tests! (Requires Catch2 which must be manually installed on Ubuntu.)
|
92 |
+
ctest
|
93 |
+
```
|
94 |
+
|
95 |
+
 p.s. The *master* branch is a development branch. Choose a [stable tag](https://github.com/stevenlovegrove/Pangolin/tags) if you prefer.
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
#### On Windows
|
100 |
+
|
101 |
+
I'd recommend building natively with the [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) toolchain (and not mingw or WSL etc which is unsupported). I recommend [gitbash](https://git-scm.com/downloads) for executing the bash snippets on this page and cloning Pangolin. You can work from within their provided console or the fancy new [Windows Terminal](https://devblogs.microsoft.com/commandline/introducing-windows-terminal/) which is a huge improvement to the developer experience on Windows.
|
102 |
+
|
103 |
+
#### With Python
|
104 |
+
|
105 |
+
You have to be careful about what python version Pangolin has found and is attempting to link against. It will tell you during the `cmake ..` step and you can change it by explicitly telling it the python executable with `cmake -DPYTHON_EXECUTABLE=/path/to/python ..`or ``cmake -DPYTHON_EXECUTABLE=`which python3` `` to use the python accessed through the `python3` alias.
|
106 |
+
|
107 |
+
If python is found, the pypangolin module will be built with the default `all` target. A Python wheel can be built manually using the `pypangolin_wheel` target, and the wheel can be installed / uninstalled with `pypangolin_pip_install` and `pypangolin_pip_uninstall` targets.
|
108 |
+
|
109 |
+
**NOTE** The python wheel and install targets are only currently working on MacOS and Linux. On Windows, you're out of luck right now. Help appreciated!
|
110 |
+
|
111 |
+
#### On the Web
|
112 |
+
|
113 |
+
See [**Emscripten (Compile for web)**](#emscripten-compile-for-web) below.
|
114 |
+
|
115 |
+
|
116 |
+
## Examples
|
117 |
+
|
118 |
+
Pangolin is mostly documented through it's simple examples which you can find in the [*examples*](https://github.com/stevenlovegrove/Pangolin/tree/master/examples) folder and [*examples/PythonExamples*](https://github.com/stevenlovegrove/Pangolin/tree/master/examples/PythonExamples) for python versions.
|
119 |
+
|
120 |
+
Browse some [**online**](https://stevenlovegrove.github.io/Pangolin/examples) and even run them in your browser, such as [**SimplePlot**](https://stevenlovegrove.github.io/Pangolin/emscripten/examples/SimplePlot), [**SimpleDisplay**](https://stevenlovegrove.github.io/Pangolin/emscripten/examples/SimpleDisplay/) and [**SimpleMultiDisplay**](https://stevenlovegrove.github.io/Pangolin/emscripten/examples/SimpleMultiDisplay/).
|
121 |
+
|
122 |
+
## Issues ##
|
123 |
+
|
124 |
+
Please visit [Github Issues](https://github.com/stevenlovegrove/Pangolin/issues) to view and report problems with Pangolin. Issues and pull requests should be raised against the master branch which contains the current development version.
|
125 |
+
|
126 |
+
Please note; most Pangolin dependencies are optional - to disable a dependency which may be causing trouble on your machine, set the BUILD_PANGOLIN_(option) variable to false with a cmake configuration tool (e.g. ccmake or cmake-gui).
|
127 |
+
|
128 |
+
#### Common Runtime Problems
|
129 |
+
|
130 |
+
<u>Framebuffer with requested attributes not available</u>: You're building against an old or unaccelerated OpenGL version. Either your graphics drivers are not correctly installed or you are on an unusual platform (such as within Docker, in a VM, working over an X forwarding SSH session) which has limited graphics acceleration. For the former case, you need to make sure your system is using appropriate drivers (you can test glxgears / glxinfo on linux for instance). There isn't much you can do about the latter except changing your setup (e.g. finding a VM which can better accelerate your graphics, or perhaps using the [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) wrapper around docker to correctly pass through the graphics driver)
|
131 |
+
|
132 |
+
#### Common Python Problems
|
133 |
+
|
134 |
+
<u>error: unknown target 'pypangolin_wheels'</u> : cmake didn't find your python. Go back and adjust your cmake variables (such as the tip above) until you see something like "Selected Python: '/opt/local/bin/python3.9'" in the output.
|
135 |
+
|
136 |
+
<u>ModuleNotFoundError: No module named 'pypangolin'</u>: Did you install the wheel (see the bash comment under build)? Are you running using the same Python as Pangolin found during the `cmake ..` step?
|
137 |
+
|
138 |
+
|
139 |
+
|
140 |
+
## Contributions and Continuous Integration ##
|
141 |
+
|
142 |
+
For CI, Pangolin uses [Github Actions](https://github.com/stevenlovegrove/Pangolin/actions) for Windows, MacOS, Linux and Emscripten (Web).
|
143 |
+
|
144 |
+
To contribute to Pangolin, I would appreciate pull requests against the master branch. If you raise an issue, please include your environment (compiler, operating system, etc).
|
145 |
+
|
146 |
+
|
147 |
+
|
148 |
+
## Extensibility & Factories
|
149 |
+
|
150 |
+
Pangolin uses an extensible factory mechanism for modularising video drivers, windowing backends and console interpreters. Concrete instances are instantiated from a particular factory using a URI string which identifies which factory to use and what parameters it should use. As strings, URI's are a useful mechanism for providing and validating configuration from an end user. The URI form is:
|
151 |
+
`module_name:[option1=value1,option2=value2,...]//module_resource_to_open`.
|
152 |
+
|
153 |
+
#### Video URI's
|
154 |
+
|
155 |
+
The *VideoViewer* tool takes these URI's directly in order to specify what images or video to load and show:
|
156 |
+
|
157 |
+
```bash
|
158 |
+
VideoViewer test://
|
159 |
+
VideoViewer uvc:[size=640x480]///dev/video0
|
160 |
+
VideoViewer flip://debayer:[tile=rggb,method=downsample]//file://~/somefile.pango
|
161 |
+
```
|
162 |
+
|
163 |
+
Notice that for video, some modules support chaining to construct a simple filter graph.
|
164 |
+
|
165 |
+
#### Window URI's
|
166 |
+
|
167 |
+
Windowing in Pangolin is also backed by a factory. When an application calls CreateWindowAndBind() or similar, the default:// URI is specified. This can be overriden to use different windowing options by setting the`PANGOLIN_WINDOW_URI` environment variable. e.g.
|
168 |
+
|
169 |
+
|
170 |
+
```bash
|
171 |
+
# Use the X11 Window Driver and override the default double buffered option
|
172 |
+
PANGOLIN_WINDOW_URI="x11:[double_buffered=false]//" ./some_pangolin_app
|
173 |
+
|
174 |
+
# Create a 'virtual' window using a framebuffer
|
175 |
+
PANGOLIN_WINDOW_URI="headless://" ./another_pangolin_app
|
176 |
+
```
|
177 |
+
|
178 |
+
Some window parameters that may be interesting to override are `DISPLAYNAME`, `DOUBLEBUFFER`, `SAMPLE_BUFFERS`, `SAMPLES`, `HIGHRES`. Window modules currently include `x11`, `winapi`, `cocoa`.
|
179 |
+
|
180 |
+
#### Fonts
|
181 |
+
|
182 |
+
Additionally, there are a couple of special parameters that can be passed through the `PANGOLIN_WINDOW_URI` environment variable to change the default font or adjust the default font size:
|
183 |
+
|
184 |
+
```bash
|
185 |
+
PANGOLIN_WINDOW_URI="default:[default_font_size=20]//" ./some_pangolin_app
|
186 |
+
|
187 |
+
PANGOLIN_WINDOW_URI="default:[default_font=my_awesome_font.ttf,default_font_size=20]//" ./some_pangolin_app
|
188 |
+
```
|
189 |
+
|
190 |
+
To use Pangolin in your applications whilst being conscientious of changing fonts, you can query how long fonts or text are with:
|
191 |
+
|
192 |
+
```C++
|
193 |
+
#include <pangolin/display/default_font.h>
|
194 |
+
int func()
|
195 |
+
{
|
196 |
+
// E.g. Choose sensible size for Pangolin Panel
|
197 |
+
const int PANEL_WIDTH = 20* pangolin::default_font().MaxWidth();
|
198 |
+
...
|
199 |
+
// E.g. Work out some column width etc.
|
200 |
+
const int COL_WIDTH = pangolin::default_font().Text("How big is this text?").Width();
|
201 |
+
}
|
202 |
+
```
|
203 |
+
|
204 |
+
|
205 |
+
|
206 |
+
## Emscripten (Compile for web) ##
|
207 |
+
|
208 |
+
Emscripten is a neat c++ compiler which can output javascript executable code. That's right, your Pangolin programs can run on the web, too!
|
209 |
+
|
210 |
+
Follow Emscriptens instructions to install the SDK (summarized below):
|
211 |
+
|
212 |
+
```bash
|
213 |
+
mkdir ~/tools && cd ~/tools
|
214 |
+
git clone https://github.com/emscripten-core/emsdk.git
|
215 |
+
cd emsdk && ./emsdk install latest && ./emsdk activate latest
|
216 |
+
```
|
217 |
+
|
218 |
+
To build Pangolin with the Emscripten toolchain, create a new build directory, make sure Emscripten is on your PATH, and use the `emconfigure` utility to run CMake with the custom toolchain settings:
|
219 |
+
|
220 |
+
```bash
|
221 |
+
cd ~/code/Pangolin
|
222 |
+
mkdir build-em && cd build-em
|
223 |
+
source ~/tools/emsdk/emsdk_env.sh
|
224 |
+
emcmake cmake ..
|
225 |
+
```
|
226 |
+
|
227 |
+
## Acknowledgements ##
|
228 |
+
|
229 |
+
I'd like to thank the growing number of kind contributors to Pangolin for helping to make it more stable and feature rich. Many features of Pangolin have been influenced by other projects such as GFlags, GLConsole, and libcvd in particular. I'd also like to thank the FOSS projects on which Pangolin depends.
|
230 |
+
|
231 |
+
For a summary of those who have made code contributions, execute:
|
232 |
+
|
233 |
+
```bash
|
234 |
+
git shortlog -sne
|
235 |
+
```
|
third-party/DPVO/Pangolin/examples/HelloPangolin/CMakeLists.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(HelloPangolin main.cpp)
|
6 |
+
target_link_libraries(HelloPangolin pango_display pango_python)
|
third-party/DPVO/Pangolin/examples/HelloPangolin/main.cpp
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <pangolin/display/display.h>
|
2 |
+
#include <pangolin/display/view.h>
|
3 |
+
#include <pangolin/handler/handler.h>
|
4 |
+
#include <pangolin/gl/gldraw.h>
|
5 |
+
|
6 |
+
int main( int /*argc*/, char** /*argv*/ )
|
7 |
+
{
|
8 |
+
pangolin::CreateWindowAndBind("Main",640,480);
|
9 |
+
glEnable(GL_DEPTH_TEST);
|
10 |
+
|
11 |
+
// Define Projection and initial ModelView matrix
|
12 |
+
pangolin::OpenGlRenderState s_cam(
|
13 |
+
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.2,100),
|
14 |
+
pangolin::ModelViewLookAt(-2,2,-2, 0,0,0, pangolin::AxisY)
|
15 |
+
);
|
16 |
+
|
17 |
+
// Create Interactive View in window
|
18 |
+
pangolin::Handler3D handler(s_cam);
|
19 |
+
pangolin::View& d_cam = pangolin::CreateDisplay()
|
20 |
+
.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0f/480.0f)
|
21 |
+
.SetHandler(&handler);
|
22 |
+
|
23 |
+
while( !pangolin::ShouldQuit() )
|
24 |
+
{
|
25 |
+
// Clear screen and activate view to render into
|
26 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
27 |
+
d_cam.Activate(s_cam);
|
28 |
+
|
29 |
+
// Render OpenGL Cube
|
30 |
+
pangolin::glDrawColouredCube();
|
31 |
+
|
32 |
+
// Swap frames and Process Events
|
33 |
+
pangolin::FinishFrame();
|
34 |
+
}
|
35 |
+
|
36 |
+
return 0;
|
37 |
+
}
|
third-party/DPVO/Pangolin/examples/HelloPangolinOffscreen/CMakeLists.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.5 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(HelloPangolinOffscreen main.cpp)
|
6 |
+
target_link_libraries(HelloPangolinOffscreen pango_display)
|
third-party/DPVO/Pangolin/examples/HelloPangolinOffscreen/main.cpp
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <pangolin/display/display.h>
|
2 |
+
#include <pangolin/display/view.h>
|
3 |
+
#include <pangolin/handler/handler.h>
|
4 |
+
#include <pangolin/gl/gldraw.h>
|
5 |
+
|
6 |
+
int main( int /*argc*/, char** /*argv*/ )
|
7 |
+
{
|
8 |
+
static const int w = 640;
|
9 |
+
static const int h = 480;
|
10 |
+
|
11 |
+
pangolin::CreateWindowAndBind("Main",w,h,pangolin::Params({{"scheme", "headless"}}));
|
12 |
+
glEnable(GL_DEPTH_TEST);
|
13 |
+
|
14 |
+
// Define Projection and initial ModelView matrix
|
15 |
+
pangolin::OpenGlRenderState s_cam(
|
16 |
+
pangolin::ProjectionMatrix(w,h,420,420,320,240,0.2,100),
|
17 |
+
pangolin::ModelViewLookAt(-2,2,-2, 0,0,0, pangolin::AxisY)
|
18 |
+
);
|
19 |
+
|
20 |
+
// create a frame buffer object with colour and depth buffer
|
21 |
+
pangolin::GlTexture color_buffer(w,h);
|
22 |
+
pangolin::GlRenderBuffer depth_buffer(w,h);
|
23 |
+
pangolin::GlFramebuffer fbo_buffer(color_buffer, depth_buffer);
|
24 |
+
|
25 |
+
fbo_buffer.Bind();
|
26 |
+
{
|
27 |
+
// Clear screen and activate view to render into
|
28 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
29 |
+
glViewport(0,0,w,h);
|
30 |
+
s_cam.Apply();
|
31 |
+
|
32 |
+
// Render OpenGL Cube
|
33 |
+
pangolin::glDrawColouredCube();
|
34 |
+
|
35 |
+
// Swap frames and Process Events
|
36 |
+
pangolin::FinishFrame();
|
37 |
+
}
|
38 |
+
fbo_buffer.Unbind();
|
39 |
+
|
40 |
+
// download and save the colour buffer
|
41 |
+
color_buffer.Save("fbo.png", false);
|
42 |
+
|
43 |
+
return 0;
|
44 |
+
}
|
third-party/DPVO/Pangolin/examples/HelloPangolinThreads/CMakeLists.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.5 REQUIRED)
|
3 |
+
find_package(Threads QUIET)
|
4 |
+
|
5 |
+
if(Theads_FOUND)
|
6 |
+
add_executable(HelloPangolinThreads main.cpp)
|
7 |
+
target_include_directories(HelloPangolinThreads ${Pangolin_INCLUDE_DIRS})
|
8 |
+
target_link_libraries(HelloPangolinThreads pango_display Threads::Threads)
|
9 |
+
endif()
|
third-party/DPVO/Pangolin/examples/HelloPangolinThreads/main.cpp
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <pangolin/display/display.h>
|
2 |
+
#include <pangolin/display/view.h>
|
3 |
+
#include <pangolin/gl/gl.h>
|
4 |
+
|
5 |
+
#include <thread>
|
6 |
+
|
7 |
+
static const std::string window_name = "HelloPangolinThreads";
|
8 |
+
|
9 |
+
void setup() {
|
10 |
+
// create a window and bind its context to the main thread
|
11 |
+
pangolin::CreateWindowAndBind(window_name, 640, 480);
|
12 |
+
|
13 |
+
// enable depth
|
14 |
+
glEnable(GL_DEPTH_TEST);
|
15 |
+
|
16 |
+
// unset the current context from the main thread
|
17 |
+
pangolin::GetBoundWindow()->RemoveCurrent();
|
18 |
+
}
|
19 |
+
|
20 |
+
void run() {
|
21 |
+
// fetch the context and bind it to this thread
|
22 |
+
pangolin::BindToContext(window_name);
|
23 |
+
|
24 |
+
// we manually need to restore the properties of the context
|
25 |
+
glEnable(GL_DEPTH_TEST);
|
26 |
+
|
27 |
+
// Define Projection and initial ModelView matrix
|
28 |
+
pangolin::OpenGlRenderState s_cam(
|
29 |
+
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.2,100),
|
30 |
+
pangolin::ModelViewLookAt(-2,2,-2, 0,0,0, pangolin::AxisY)
|
31 |
+
);
|
32 |
+
|
33 |
+
// Create Interactive View in window
|
34 |
+
pangolin::Handler3D handler(s_cam);
|
35 |
+
pangolin::View& d_cam = pangolin::CreateDisplay()
|
36 |
+
.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0f/480.0f)
|
37 |
+
.SetHandler(&handler);
|
38 |
+
|
39 |
+
while( !pangolin::ShouldQuit() )
|
40 |
+
{
|
41 |
+
// Clear screen and activate view to render into
|
42 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
43 |
+
d_cam.Activate(s_cam);
|
44 |
+
|
45 |
+
// Render OpenGL Cube
|
46 |
+
pangolin::glDrawColouredCube();
|
47 |
+
|
48 |
+
// Swap frames and Process Events
|
49 |
+
pangolin::FinishFrame();
|
50 |
+
}
|
51 |
+
|
52 |
+
// unset the current context from the main thread
|
53 |
+
pangolin::GetBoundWindow()->RemoveCurrent();
|
54 |
+
}
|
55 |
+
|
56 |
+
int main( int /*argc*/, char** /*argv*/ )
|
57 |
+
{
|
58 |
+
// create window and context in the main thread
|
59 |
+
setup();
|
60 |
+
|
61 |
+
// use the context in a separate rendering thread
|
62 |
+
std::thread render_loop;
|
63 |
+
render_loop = std::thread(run);
|
64 |
+
render_loop.join();
|
65 |
+
|
66 |
+
return 0;
|
67 |
+
}
|
third-party/DPVO/Pangolin/examples/PythonExamples/SimpleDisplay.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
|
3 |
+
import pypangolin as pango
|
4 |
+
from OpenGL.GL import *
|
5 |
+
|
6 |
+
|
7 |
+
def a_callback():
|
8 |
+
print("a pressed")
|
9 |
+
|
10 |
+
|
11 |
+
def main():
|
12 |
+
win = pango.CreateWindowAndBind("pySimpleDisplay", 640, 480)
|
13 |
+
glEnable(GL_DEPTH_TEST)
|
14 |
+
|
15 |
+
pm = pango.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.1, 1000)
|
16 |
+
mv = pango.ModelViewLookAt(-0, 0.5, -3, 0, 0, 0, pango.AxisY)
|
17 |
+
s_cam = pango.OpenGlRenderState(pm, mv)
|
18 |
+
|
19 |
+
ui_width = 180
|
20 |
+
|
21 |
+
handler = pango.Handler3D(s_cam)
|
22 |
+
d_cam = (
|
23 |
+
pango.CreateDisplay()
|
24 |
+
.SetBounds(
|
25 |
+
pango.Attach(0),
|
26 |
+
pango.Attach(1),
|
27 |
+
pango.Attach.Pix(ui_width),
|
28 |
+
pango.Attach(1),
|
29 |
+
-640.0 / 480.0,
|
30 |
+
)
|
31 |
+
.SetHandler(handler)
|
32 |
+
)
|
33 |
+
|
34 |
+
pango.CreatePanel("ui").SetBounds(
|
35 |
+
pango.Attach(0), pango.Attach(1), pango.Attach(0), pango.Attach.Pix(ui_width)
|
36 |
+
)
|
37 |
+
var_ui = pango.Var("ui")
|
38 |
+
var_ui.a_Button = False
|
39 |
+
var_ui.a_Toggle = (False, pango.VarMeta(toggle=True))
|
40 |
+
var_ui.a_double = (0.0, pango.VarMeta(0, 5))
|
41 |
+
var_ui.an_int = (2, pango.VarMeta(0, 5))
|
42 |
+
var_ui.a_double_log = (3.0, pango.VarMeta(1, 1e4, logscale=True))
|
43 |
+
var_ui.a_checkbox = (False, pango.VarMeta(toggle=True))
|
44 |
+
var_ui.an_int_no_input = 2
|
45 |
+
var_ui.a_str = "sss"
|
46 |
+
|
47 |
+
ctrl = -96
|
48 |
+
pango.RegisterKeyPressCallback(ctrl + ord("a"), a_callback)
|
49 |
+
|
50 |
+
while not pango.ShouldQuit():
|
51 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
52 |
+
|
53 |
+
if var_ui.a_checkbox:
|
54 |
+
var_ui.an_int = var_ui.a_double
|
55 |
+
|
56 |
+
if var_ui.GuiChanged('an_int'):
|
57 |
+
var_ui.an_int_no_input = var_ui.an_int
|
58 |
+
|
59 |
+
d_cam.Activate(s_cam)
|
60 |
+
pango.glDrawColouredCube()
|
61 |
+
pango.FinishFrame()
|
62 |
+
|
63 |
+
|
64 |
+
if __name__ == "__main__":
|
65 |
+
main()
|
third-party/DPVO/Pangolin/examples/PythonExamples/SimplePlot.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
import sys
|
3 |
+
sys.path.append('../build/src')
|
4 |
+
|
5 |
+
from OpenGL.GL import *
|
6 |
+
import pypangolin as pango
|
7 |
+
import math
|
8 |
+
|
9 |
+
def main():
|
10 |
+
win = pango.CreateWindowAndBind("main py_pangolin", 640, 480)
|
11 |
+
log = pango.DataLog()
|
12 |
+
log.SetLabels(["sin(t)", "cos(t)", "sin(t)+cos(t)"])
|
13 |
+
|
14 |
+
t=0;
|
15 |
+
tinc=0.01
|
16 |
+
|
17 |
+
plotter = pango.Plotter(log,0,4*math.pi/tinc,-2,2,math.pi/(4*tinc),0.5);
|
18 |
+
plotter.Track("$i")
|
19 |
+
plotter.AddMarker(pango.Marker.Vertical, -1000, pango.Marker.LessThan, pango.Colour.Blue().WithAlpha(0.2))
|
20 |
+
plotter.AddMarker(pango.Marker.Horizontal, 100, pango.Marker.GreaterThan, pango.Colour.Red().WithAlpha(0.2))
|
21 |
+
plotter.AddMarker(pango.Marker.Horizontal, 10, pango.Marker.Equal, pango.Colour.Green().WithAlpha(0.2))
|
22 |
+
plotter.SetBounds(pango.Attach(0), pango.Attach(1),
|
23 |
+
pango.Attach(0), pango.Attach(1))
|
24 |
+
|
25 |
+
pango.DisplayBase().AddDisplay(plotter)
|
26 |
+
|
27 |
+
while not pango.ShouldQuit():
|
28 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
29 |
+
|
30 |
+
log.Log(math.sin(t), math.cos(t), math.sin(t)+math.cos(t))
|
31 |
+
t+=tinc
|
32 |
+
|
33 |
+
pango.FinishFrame()
|
34 |
+
|
35 |
+
if __name__ == "__main__":
|
36 |
+
main()
|
third-party/DPVO/Pangolin/examples/PythonExamples/SimpleVideo.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
import sys
|
3 |
+
import os
|
4 |
+
import argparse
|
5 |
+
import numpy as np
|
6 |
+
import time
|
7 |
+
import json
|
8 |
+
|
9 |
+
# If this example doesn't work, it's probably because this path is wrong...
|
10 |
+
sys.path.append('../build/src')
|
11 |
+
|
12 |
+
import pypangolin as pango
|
13 |
+
|
14 |
+
def main(flags):
|
15 |
+
vid_uri = flags.pango
|
16 |
+
vout_uri = flags.pangoOut
|
17 |
+
|
18 |
+
vid = pango.VideoInput(vid_uri)
|
19 |
+
vout = pango.VideoOutput(vout_uri) if vout_uri else None
|
20 |
+
|
21 |
+
device_properties = vid.DeviceProperties()
|
22 |
+
|
23 |
+
# print metadata
|
24 |
+
print("Opened video uri: '{}' with {} x {} dimensions".format( vid_uri,vid.Width(),vid.Height()))
|
25 |
+
|
26 |
+
# user specified initial frame
|
27 |
+
vid.Seek(flags.startFrame)
|
28 |
+
|
29 |
+
# show each frame
|
30 |
+
streamsBitDepth = vid.GetStreamsBitDepth()
|
31 |
+
|
32 |
+
for frame in vid:
|
33 |
+
if vout:
|
34 |
+
vout.WriteStreams(frame, streamsBitDepth, vid.FrameProperties(), device_properties);
|
35 |
+
|
36 |
+
# frame is a list of Images! One per stream
|
37 |
+
# process(frame)
|
38 |
+
|
39 |
+
# printing
|
40 |
+
sys.stdout.write('\rframe: {} / {}'.format(vid.GetCurrentFrameId(), vid.GetTotalFrames()))
|
41 |
+
|
42 |
+
print('\nDONE')
|
43 |
+
|
44 |
+
if __name__ == "__main__":
|
45 |
+
# input flags
|
46 |
+
parser = argparse.ArgumentParser('Read a .pango file frame by frame. Optionally stream to another video output.')
|
47 |
+
parser.add_argument(
|
48 |
+
'--pango', type=str,
|
49 |
+
help='path to the input pango file.')
|
50 |
+
parser.add_argument(
|
51 |
+
'--startFrame', type=int, default=0,
|
52 |
+
help='index of the start frame (inclusive)')
|
53 |
+
parser.add_argument(
|
54 |
+
'--pangoOut', type=str, default=None,
|
55 |
+
help='path to the output pango file.')
|
56 |
+
|
57 |
+
# main function
|
58 |
+
main(parser.parse_args())
|
third-party/DPVO/Pangolin/examples/SharedMemoryCamera/CMakeLists.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
if(UNIX)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(SharedMemoryCamera main.cpp)
|
6 |
+
target_link_libraries(SharedMemoryCamera pango_display)
|
7 |
+
endif()
|
third-party/DPVO/Pangolin/examples/SharedMemoryCamera/main.cpp
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <pangolin/pangolin.h>
|
2 |
+
|
3 |
+
#include <pangolin/utils/posix/condition_variable.h>
|
4 |
+
#include <pangolin/utils/posix/shared_memory_buffer.h>
|
5 |
+
#include <pangolin/utils/timer.h>
|
6 |
+
|
7 |
+
#include <cmath>
|
8 |
+
#include <memory>
|
9 |
+
|
10 |
+
// This sample acts as a soft camera. It writes a pattern of GRAY8 pixels to the
|
11 |
+
// shared memory space. It can be seen in Pangolin's SimpleVideo sample using
|
12 |
+
// the shmem:[size=640x480]//example video URI.
|
13 |
+
|
14 |
+
using namespace pangolin;
|
15 |
+
|
16 |
+
unsigned char generate_value(double t)
|
17 |
+
{
|
18 |
+
// 10s sinusoid
|
19 |
+
const double d = std::sin(t * 10.0 / M_PI) * 128.0 + 128.0;
|
20 |
+
return static_cast<unsigned char>(d);
|
21 |
+
}
|
22 |
+
|
23 |
+
int main(/*int argc, char *argv[]*/)
|
24 |
+
{
|
25 |
+
std::string shmem_name = "/example";
|
26 |
+
|
27 |
+
std::shared_ptr<SharedMemoryBufferInterface> shmem_buffer =
|
28 |
+
create_named_shared_memory_buffer(shmem_name, 640 * 480);
|
29 |
+
if (!shmem_buffer) {
|
30 |
+
perror("Unable to create shared memory buffer");
|
31 |
+
exit(1);
|
32 |
+
}
|
33 |
+
|
34 |
+
std::string cond_name = shmem_name + "_cond";
|
35 |
+
std::shared_ptr<ConditionVariableInterface> buffer_full =
|
36 |
+
create_named_condition_variable(cond_name);
|
37 |
+
|
38 |
+
// Sit in a loop and write gray values based on some timing pattern.
|
39 |
+
while (true) {
|
40 |
+
shmem_buffer->lock();
|
41 |
+
unsigned char *ptr = shmem_buffer->ptr();
|
42 |
+
unsigned char value = generate_value(std::chrono::system_clock::now().time_since_epoch().count());
|
43 |
+
|
44 |
+
for (int i = 0; i < 640*480; ++i) {
|
45 |
+
ptr[i] = value;
|
46 |
+
}
|
47 |
+
|
48 |
+
shmem_buffer->unlock();
|
49 |
+
buffer_full->signal();
|
50 |
+
|
51 |
+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
52 |
+
}
|
53 |
+
}
|
third-party/DPVO/Pangolin/examples/SimpleDisplay/CMakeLists.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(SimpleDisplay main.cpp)
|
6 |
+
target_link_libraries(SimpleDisplay pango_display pango_python )
|
7 |
+
|
third-party/DPVO/Pangolin/examples/SimpleDisplay/app.cfg
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2 |
+
% Pangolin Sample configuration file
|
3 |
+
% Comments start with '%' or '#'
|
4 |
+
%
|
5 |
+
% Declarations are name value pairs,
|
6 |
+
% seperated with '=' and terminated with ';'
|
7 |
+
|
8 |
+
% We can set any variable referenced in code directly
|
9 |
+
ui.A Double = 3.2;
|
10 |
+
ui.A Checkbox = false;
|
11 |
+
|
12 |
+
% We can set unreferenced variables too
|
13 |
+
a.b = 1;
|
14 |
+
a.c = 2;
|
15 |
+
z.b = 3;
|
16 |
+
z.c = 4;
|
17 |
+
start = z;
|
18 |
+
|
19 |
+
% Which we might refer to by reference
|
20 |
+
ui.An Int = ${${start}.c};
|
21 |
+
|
22 |
+
% Declarations can span multiple lines
|
23 |
+
M =
|
24 |
+
[1, 0, 0
|
25 |
+
0, 1, 0
|
26 |
+
0, 0, 1];
|
third-party/DPVO/Pangolin/examples/SimpleDisplay/main.cpp
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <iostream>
|
2 |
+
|
3 |
+
#include <pangolin/var/var.h>
|
4 |
+
#include <pangolin/var/varextra.h>
|
5 |
+
#include <pangolin/gl/gl.h>
|
6 |
+
#include <pangolin/gl/gldraw.h>
|
7 |
+
#include <pangolin/display/display.h>
|
8 |
+
#include <pangolin/display/view.h>
|
9 |
+
#include <pangolin/display/widgets.h>
|
10 |
+
#include <pangolin/display/default_font.h>
|
11 |
+
#include <pangolin/handler/handler.h>
|
12 |
+
|
13 |
+
int main(/*int argc, char* argv[]*/)
|
14 |
+
{
|
15 |
+
// Create OpenGL window in single line
|
16 |
+
pangolin::CreateWindowAndBind("Main",640,480);
|
17 |
+
|
18 |
+
// 3D Mouse handler requires depth testing to be enabled
|
19 |
+
glEnable(GL_DEPTH_TEST);
|
20 |
+
|
21 |
+
// Define Camera Render Object (for view / scene browsing)
|
22 |
+
pangolin::OpenGlRenderState s_cam(
|
23 |
+
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.1,1000),
|
24 |
+
pangolin::ModelViewLookAt(-0,0.5,-3, 0,0,0, pangolin::AxisY)
|
25 |
+
);
|
26 |
+
|
27 |
+
// Choose a sensible left UI Panel width based on the width of 20
|
28 |
+
// charectors from the default font.
|
29 |
+
const int UI_WIDTH = 20* pangolin::default_font().MaxWidth();
|
30 |
+
|
31 |
+
// Add named OpenGL viewport to window and provide 3D Handler
|
32 |
+
pangolin::View& d_cam = pangolin::CreateDisplay()
|
33 |
+
.SetBounds(0.0, 1.0, pangolin::Attach::Pix(UI_WIDTH), 1.0, 640.0f/480.0f)
|
34 |
+
.SetHandler(new pangolin::Handler3D(s_cam));
|
35 |
+
|
36 |
+
// Add named Panel and bind to variables beginning 'ui'
|
37 |
+
// A Panel is just a View with a default layout and input handling
|
38 |
+
pangolin::CreatePanel("ui")
|
39 |
+
.SetBounds(0.0, 1.0, 0.0, pangolin::Attach::Pix(UI_WIDTH));
|
40 |
+
|
41 |
+
// Safe and efficient binding of named variables.
|
42 |
+
// Specialisations mean no conversions take place for exact types
|
43 |
+
// and conversions between scalar types are cheap.
|
44 |
+
pangolin::Var<bool> a_button("ui.A_Button",false,false);
|
45 |
+
pangolin::Var<double> a_double("ui.A_Double",3,0,5);
|
46 |
+
pangolin::Var<int> an_int("ui.An_Int",2,0,5);
|
47 |
+
pangolin::Var<double> a_double_log("ui.Log_scale",3,1,1E4, true);
|
48 |
+
pangolin::Var<bool> a_checkbox("ui.A_Checkbox",false,true);
|
49 |
+
pangolin::Var<int> an_int_no_input("ui.An_Int_No_Input",2);
|
50 |
+
pangolin::Var<std::string> a_string("ui.A_String", "Edit ME!");
|
51 |
+
|
52 |
+
// std::function objects can be used for Var's too. These work great with C++11 closures.
|
53 |
+
pangolin::Var<std::function<void(void)>> save_window("ui.Save_Window", [](){
|
54 |
+
pangolin::SaveWindowOnRender("window");
|
55 |
+
});
|
56 |
+
|
57 |
+
pangolin::Var<std::function<void(void)>> save_cube_view("ui.Save_Cube", [&d_cam](){
|
58 |
+
pangolin::SaveWindowOnRender("cube", d_cam.v);
|
59 |
+
});
|
60 |
+
|
61 |
+
// Demonstration of how we can register a keyboard hook to alter a Var
|
62 |
+
pangolin::RegisterKeyPressCallback(pangolin::PANGO_CTRL + 'b', [&](){
|
63 |
+
a_double = 3.5;
|
64 |
+
});
|
65 |
+
|
66 |
+
// Default hooks for exiting (Esc) and fullscreen (tab).
|
67 |
+
while( !pangolin::ShouldQuit() )
|
68 |
+
{
|
69 |
+
// Clear entire screen
|
70 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
71 |
+
|
72 |
+
if( pangolin::Pushed(a_button) )
|
73 |
+
std::cout << "You Pushed a button!" << std::endl;
|
74 |
+
|
75 |
+
// Overloading of Var<T> operators allows us to treat them like
|
76 |
+
// their wrapped types, eg:
|
77 |
+
if( a_checkbox )
|
78 |
+
an_int = (int)a_double;
|
79 |
+
|
80 |
+
an_int_no_input = an_int;
|
81 |
+
|
82 |
+
if(d_cam.IsShown()) {
|
83 |
+
// Activate efficiently by object
|
84 |
+
d_cam.Activate(s_cam);
|
85 |
+
|
86 |
+
// Render some stuff
|
87 |
+
glColor3f(1.0,1.0,1.0);
|
88 |
+
pangolin::glDrawColouredCube();
|
89 |
+
}
|
90 |
+
|
91 |
+
// Swap frames and Process Events
|
92 |
+
pangolin::FinishFrame();
|
93 |
+
}
|
94 |
+
|
95 |
+
return 0;
|
96 |
+
}
|
third-party/DPVO/Pangolin/examples/SimpleDisplayImage/CMakeLists.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(SimpleDisplayImage main.cpp)
|
6 |
+
target_link_libraries(SimpleDisplayImage pango_display)
|
third-party/DPVO/Pangolin/examples/SimpleDisplayImage/main.cpp
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <limits>
|
2 |
+
#include <iostream>
|
3 |
+
|
4 |
+
#include <pangolin/display/display.h>
|
5 |
+
#include <pangolin/display/view.h>
|
6 |
+
#include <pangolin/handler/handler.h>
|
7 |
+
#include <pangolin/gl/gldraw.h>
|
8 |
+
|
9 |
+
void setImageData(unsigned char * imageArray, int size){
|
10 |
+
for(int i = 0 ; i < size;i++) {
|
11 |
+
imageArray[i] = (unsigned char)(rand()/(RAND_MAX/255.0));
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
int main(/*int argc, char* argv[]*/)
|
16 |
+
{
|
17 |
+
// Create OpenGL window in single line
|
18 |
+
pangolin::CreateWindowAndBind("Main",640,480);
|
19 |
+
|
20 |
+
// 3D Mouse handler requires depth testing to be enabled
|
21 |
+
glEnable(GL_DEPTH_TEST);
|
22 |
+
|
23 |
+
pangolin::OpenGlRenderState s_cam(
|
24 |
+
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.1,1000),
|
25 |
+
pangolin::ModelViewLookAt(-1,1,-1, 0,0,0, pangolin::AxisY)
|
26 |
+
);
|
27 |
+
|
28 |
+
// Aspect ratio allows us to constrain width and height whilst fitting within specified
|
29 |
+
// bounds. A positive aspect ratio makes a view 'shrink to fit' (introducing empty bars),
|
30 |
+
// whilst a negative ratio makes the view 'grow to fit' (cropping the view).
|
31 |
+
pangolin::View& d_cam = pangolin::Display("cam")
|
32 |
+
.SetBounds(0,1.0f,0,1.0f,-640/480.0)
|
33 |
+
.SetHandler(new pangolin::Handler3D(s_cam));
|
34 |
+
|
35 |
+
// This view will take up no more than a third of the windows width or height, and it
|
36 |
+
// will have a fixed aspect ratio to match the image that it will display. When fitting
|
37 |
+
// within the specified bounds, push to the top-left (as specified by SetLock).
|
38 |
+
pangolin::View& d_image = pangolin::Display("image")
|
39 |
+
.SetBounds(2/3.0f,1.0f,0,1/3.0f,640.0/480)
|
40 |
+
.SetLock(pangolin::LockLeft, pangolin::LockTop);
|
41 |
+
|
42 |
+
std::cout << "Resize the window to experiment with SetBounds, SetLock and SetAspect." << std::endl;
|
43 |
+
std::cout << "Notice that the cubes aspect is maintained even though it covers the whole screen." << std::endl;
|
44 |
+
|
45 |
+
const int width = 64;
|
46 |
+
const int height = 48;
|
47 |
+
|
48 |
+
unsigned char* imageArray = new unsigned char[3*width*height];
|
49 |
+
pangolin::GlTexture imageTexture(width,height,GL_RGB,false,0,GL_RGB,GL_UNSIGNED_BYTE);
|
50 |
+
|
51 |
+
// Default hooks for exiting (Esc) and fullscreen (tab).
|
52 |
+
while(!pangolin::ShouldQuit())
|
53 |
+
{
|
54 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
55 |
+
|
56 |
+
d_cam.Activate(s_cam);
|
57 |
+
|
58 |
+
glColor3f(1.0,1.0,1.0);
|
59 |
+
pangolin::glDrawColouredCube();
|
60 |
+
|
61 |
+
//Set some random image data and upload to GPU
|
62 |
+
setImageData(imageArray,3*width*height);
|
63 |
+
imageTexture.Upload(imageArray,GL_RGB,GL_UNSIGNED_BYTE);
|
64 |
+
|
65 |
+
//display the image
|
66 |
+
d_image.Activate();
|
67 |
+
glColor3f(1.0,1.0,1.0);
|
68 |
+
imageTexture.RenderToViewport();
|
69 |
+
|
70 |
+
pangolin::FinishFrame();
|
71 |
+
}
|
72 |
+
|
73 |
+
delete[] imageArray;
|
74 |
+
|
75 |
+
return 0;
|
76 |
+
}
|
third-party/DPVO/Pangolin/examples/SimpleMultiDisplay/CMakeLists.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(SimpleMultiDisplay main.cpp)
|
6 |
+
target_link_libraries(SimpleMultiDisplay pango_display)
|
third-party/DPVO/Pangolin/examples/SimpleMultiDisplay/app.cfg
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2 |
+
% Pangolin Sample configuration file
|
3 |
+
% Comments start with '%' or '#'
|
4 |
+
%
|
5 |
+
% Declarations are name value pairs,
|
6 |
+
% seperated with '=' and terminated with ';'
|
7 |
+
|
8 |
+
% We can set any variable referenced in code directly
|
9 |
+
ui.A Double = 3.2;
|
10 |
+
|
11 |
+
% We can set unreferenced variables too
|
12 |
+
a.b = 1;
|
13 |
+
a.c = 2;
|
14 |
+
z.b = 3;
|
15 |
+
z.c = 4;
|
16 |
+
start = z;
|
17 |
+
|
18 |
+
% Which we might refer to by reference
|
19 |
+
ui.An Int = ${${start}.c};
|
20 |
+
|
21 |
+
% Declarations can span multiple lines
|
22 |
+
M =
|
23 |
+
[1, 0, 0
|
24 |
+
0, 1, 0
|
25 |
+
0, 0, 1];
|
26 |
+
|
27 |
+
ui.Aliased Double = @ui.A Double;
|
28 |
+
ui.Aliased Double = 2.0;
|
third-party/DPVO/Pangolin/examples/SimpleMultiDisplay/main.cpp
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <pangolin/display/display.h>
|
2 |
+
#include <pangolin/display/view.h>
|
3 |
+
#include <pangolin/handler/handler.h>
|
4 |
+
#include <pangolin/gl/gldraw.h>
|
5 |
+
|
6 |
+
void setImageData(unsigned char * imageArray, int size){
|
7 |
+
for(int i = 0 ; i < size;i++) {
|
8 |
+
imageArray[i] = (unsigned char)(rand()/(RAND_MAX/255.0));
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
12 |
+
int main(/*int argc, char* argv[]*/)
|
13 |
+
{
|
14 |
+
// Create OpenGL window in single line
|
15 |
+
pangolin::CreateWindowAndBind("Main",640,480);
|
16 |
+
|
17 |
+
// 3D Mouse handler requires depth testing to be enabled
|
18 |
+
glEnable(GL_DEPTH_TEST);
|
19 |
+
|
20 |
+
// Issue specific OpenGl we might need
|
21 |
+
glEnable (GL_BLEND);
|
22 |
+
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
23 |
+
|
24 |
+
// Define Camera Render Object (for view / scene browsing)
|
25 |
+
pangolin::OpenGlMatrix proj = pangolin::ProjectionMatrix(640,480,420,420,320,240,0.1,1000);
|
26 |
+
pangolin::OpenGlRenderState s_cam(proj, pangolin::ModelViewLookAt(1,0.5,-2,0,0,0, pangolin::AxisY) );
|
27 |
+
pangolin::OpenGlRenderState s_cam2(proj, pangolin::ModelViewLookAt(0,0,-2,0,0,0, pangolin::AxisY) );
|
28 |
+
|
29 |
+
// Add named OpenGL viewport to window and provide 3D Handler
|
30 |
+
pangolin::View& d_cam1 = pangolin::Display("cam1")
|
31 |
+
.SetAspect(640.0f/480.0f)
|
32 |
+
.SetHandler(new pangolin::Handler3D(s_cam));
|
33 |
+
|
34 |
+
pangolin::View& d_cam2 = pangolin::Display("cam2")
|
35 |
+
.SetAspect(640.0f/480.0f)
|
36 |
+
.SetHandler(new pangolin::Handler3D(s_cam2));
|
37 |
+
|
38 |
+
pangolin::View& d_cam3 = pangolin::Display("cam3")
|
39 |
+
.SetAspect(640.0f/480.0f)
|
40 |
+
.SetHandler(new pangolin::Handler3D(s_cam));
|
41 |
+
|
42 |
+
pangolin::View& d_cam4 = pangolin::Display("cam4")
|
43 |
+
.SetAspect(640.0f/480.0f)
|
44 |
+
.SetHandler(new pangolin::Handler3D(s_cam2));
|
45 |
+
|
46 |
+
pangolin::View& d_img1 = pangolin::Display("img1")
|
47 |
+
.SetAspect(640.0f/480.0f);
|
48 |
+
|
49 |
+
pangolin::View& d_img2 = pangolin::Display("img2")
|
50 |
+
.SetAspect(640.0f/480.0f);
|
51 |
+
|
52 |
+
// LayoutEqual is an EXPERIMENTAL feature - it requires that all sub-displays
|
53 |
+
// share the same aspect ratio, placing them in a raster fasion in the
|
54 |
+
// viewport so as to maximise display size.
|
55 |
+
pangolin::Display("multi")
|
56 |
+
.SetBounds(0.0, 1.0, 0.0, 1.0)
|
57 |
+
.SetLayout(pangolin::LayoutEqual)
|
58 |
+
.AddDisplay(d_cam1)
|
59 |
+
.AddDisplay(d_img1)
|
60 |
+
.AddDisplay(d_cam2)
|
61 |
+
.AddDisplay(d_img2)
|
62 |
+
.AddDisplay(d_cam3)
|
63 |
+
.AddDisplay(d_cam4);
|
64 |
+
|
65 |
+
const int width = 64;
|
66 |
+
const int height = 48;
|
67 |
+
unsigned char* imageArray = new unsigned char[3*width*height];
|
68 |
+
pangolin::GlTexture imageTexture(width,height,GL_RGB,false,0,GL_RGB,GL_UNSIGNED_BYTE);
|
69 |
+
|
70 |
+
// Default hooks for exiting (Esc) and fullscreen (tab).
|
71 |
+
while( !pangolin::ShouldQuit() )
|
72 |
+
{
|
73 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
74 |
+
|
75 |
+
// Generate random image and place in texture memory for display
|
76 |
+
setImageData(imageArray,3*width*height);
|
77 |
+
imageTexture.Upload(imageArray,GL_RGB,GL_UNSIGNED_BYTE);
|
78 |
+
|
79 |
+
glColor3f(1.0,1.0,1.0);
|
80 |
+
|
81 |
+
d_cam1.Activate(s_cam);
|
82 |
+
pangolin::glDrawColouredCube();
|
83 |
+
|
84 |
+
d_cam2.Activate(s_cam2);
|
85 |
+
pangolin::glDrawColouredCube();
|
86 |
+
|
87 |
+
d_cam3.Activate(s_cam);
|
88 |
+
pangolin::glDrawColouredCube();
|
89 |
+
|
90 |
+
d_cam4.Activate(s_cam2);
|
91 |
+
pangolin::glDrawColouredCube();
|
92 |
+
|
93 |
+
d_img1.Activate();
|
94 |
+
glColor4f(1.0f,1.0f,1.0f,1.0f);
|
95 |
+
imageTexture.RenderToViewport();
|
96 |
+
|
97 |
+
d_img2.Activate();
|
98 |
+
glColor4f(1.0f,1.0f,1.0f,1.0f);
|
99 |
+
imageTexture.RenderToViewport();
|
100 |
+
|
101 |
+
// Swap frames and Process Events
|
102 |
+
pangolin::FinishFrame();
|
103 |
+
}
|
104 |
+
|
105 |
+
delete[] imageArray;
|
106 |
+
|
107 |
+
return 0;
|
108 |
+
}
|
third-party/DPVO/Pangolin/examples/SimplePlot/CMakeLists.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(SimplePlot main.cpp)
|
6 |
+
target_link_libraries(SimplePlot pango_display pango_plot)
|
third-party/DPVO/Pangolin/examples/SimplePlot/main.cpp
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <pangolin/display/display.h>
|
2 |
+
#include <pangolin/plot/plotter.h>
|
3 |
+
|
4 |
+
int main(/*int argc, char* argv[]*/)
|
5 |
+
{
|
6 |
+
// Create OpenGL window in single line
|
7 |
+
pangolin::CreateWindowAndBind("Main",640,480);
|
8 |
+
|
9 |
+
// Data logger object
|
10 |
+
pangolin::DataLog log;
|
11 |
+
|
12 |
+
// Optionally add named labels
|
13 |
+
std::vector<std::string> labels;
|
14 |
+
labels.push_back(std::string("sin(t)"));
|
15 |
+
labels.push_back(std::string("cos(t)"));
|
16 |
+
labels.push_back(std::string("sin(t)+cos(t)"));
|
17 |
+
log.SetLabels(labels);
|
18 |
+
|
19 |
+
const float tinc = 0.01f;
|
20 |
+
|
21 |
+
// OpenGL 'view' of data. We might have many views of the same data.
|
22 |
+
pangolin::Plotter plotter(&log,0.0f,4.0f*(float)M_PI/tinc,-2.0f,2.0f,(float)M_PI/(4.0f*tinc),0.5f);
|
23 |
+
plotter.SetBounds(0.0, 1.0, 0.0, 1.0);
|
24 |
+
plotter.Track("$i");
|
25 |
+
|
26 |
+
// Add some sample annotations to the plot
|
27 |
+
plotter.AddMarker(pangolin::Marker::Vertical, -1000, pangolin::Marker::LessThan, pangolin::Colour::Blue().WithAlpha(0.2f) );
|
28 |
+
plotter.AddMarker(pangolin::Marker::Horizontal, 100, pangolin::Marker::GreaterThan, pangolin::Colour::Red().WithAlpha(0.2f) );
|
29 |
+
plotter.AddMarker(pangolin::Marker::Horizontal, 10, pangolin::Marker::Equal, pangolin::Colour::Green().WithAlpha(0.2f) );
|
30 |
+
|
31 |
+
pangolin::DisplayBase().AddDisplay(plotter);
|
32 |
+
|
33 |
+
float t = 0;
|
34 |
+
|
35 |
+
// Default hooks for exiting (Esc) and fullscreen (tab).
|
36 |
+
while( !pangolin::ShouldQuit() )
|
37 |
+
{
|
38 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
39 |
+
|
40 |
+
log.Log(sin(t),cos(t),sin(t)+cos(t));
|
41 |
+
t += tinc;
|
42 |
+
|
43 |
+
// Render graph, Swap frames and Process Events
|
44 |
+
pangolin::FinishFrame();
|
45 |
+
}
|
46 |
+
|
47 |
+
return 0;
|
48 |
+
}
|
third-party/DPVO/Pangolin/examples/SimpleRecord/CMakeLists.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(SimpleRecord main.cpp)
|
6 |
+
target_link_libraries(SimpleRecord pango_display pango_video)
|
third-party/DPVO/Pangolin/examples/SimpleRecord/main.cpp
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <pangolin/display/display.h>
|
2 |
+
#include <pangolin/display/view.h>
|
3 |
+
#include <pangolin/gl/gl.h>
|
4 |
+
#include <pangolin/gl/gldraw.h>
|
5 |
+
#include <pangolin/video/video_input.h>
|
6 |
+
|
7 |
+
void RecordSample(const std::string input_uri, const std::string record_uri)
|
8 |
+
{
|
9 |
+
// Setup Video Source
|
10 |
+
pangolin::VideoInput video(input_uri);
|
11 |
+
const pangolin::PixelFormat vid_fmt = video.PixFormat();
|
12 |
+
const unsigned w = video.Width();
|
13 |
+
const unsigned h = video.Height();
|
14 |
+
|
15 |
+
pangolin::VideoOutput recorder( record_uri );
|
16 |
+
recorder.SetStreams(video.Streams());
|
17 |
+
|
18 |
+
// Create OpenGL window
|
19 |
+
pangolin::CreateWindowAndBind("Main",w,h);
|
20 |
+
|
21 |
+
// Create viewport for video with fixed aspect
|
22 |
+
pangolin::View vVideo((float)w/h);
|
23 |
+
|
24 |
+
// OpenGl Texture for video frame
|
25 |
+
pangolin::GlTexture texVideo(w,h,GL_RGBA);
|
26 |
+
|
27 |
+
// Allocate image buffer. The +1 is to give ffmpeg some alignment slack
|
28 |
+
// swscale seems to have a bug which goes over the array by 1...
|
29 |
+
unsigned char* img = new unsigned char[video.SizeBytes() + 1];
|
30 |
+
|
31 |
+
while( !pangolin::ShouldQuit() )
|
32 |
+
{
|
33 |
+
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
34 |
+
|
35 |
+
if( video.GrabNext(img,true) )
|
36 |
+
{
|
37 |
+
// Upload to GPU as texture for display
|
38 |
+
texVideo.Upload(img, vid_fmt.channels==1 ? GL_LUMINANCE:GL_RGB, GL_UNSIGNED_BYTE);
|
39 |
+
|
40 |
+
// Record video frame
|
41 |
+
recorder.WriteStreams(img);
|
42 |
+
}
|
43 |
+
|
44 |
+
// Activate video viewport and render texture
|
45 |
+
vVideo.Activate();
|
46 |
+
texVideo.RenderToViewportFlipY();
|
47 |
+
|
48 |
+
// Swap back buffer with front and process window events
|
49 |
+
pangolin::FinishFrame();
|
50 |
+
}
|
51 |
+
|
52 |
+
delete[] img;
|
53 |
+
}
|
54 |
+
|
55 |
+
int main( int argc, char* argv[] )
|
56 |
+
{
|
57 |
+
std::string record_uri = "ffmpeg:[fps=30,bps=8388608]//video.avi";
|
58 |
+
|
59 |
+
std::string input_uris[] = {
|
60 |
+
"convert:[fmt=RGB24]//v4l:///dev/video0",
|
61 |
+
"convert:[fmt=RGB24]//v4l:///dev/video1",
|
62 |
+
"dc1394:[fps=30,dma=10,size=640x480,iso=400]//0",
|
63 |
+
"openni:[img1=rgb]//",
|
64 |
+
"test:[size=160x120,n=1,fmt=RGB24]//"
|
65 |
+
""
|
66 |
+
};
|
67 |
+
|
68 |
+
if( argc >= 2 ) {
|
69 |
+
const std::string uri = std::string(argv[1]);
|
70 |
+
if( argc == 3 ) {
|
71 |
+
record_uri = std::string(argv[2]);
|
72 |
+
}
|
73 |
+
RecordSample(uri, record_uri);
|
74 |
+
}else{
|
75 |
+
std::cout << "Usage : SimpleRecord [video-uri] [output-uri]" << std::endl << std::endl;
|
76 |
+
std::cout << "Where video-uri describes a stream or file resource, e.g." << std::endl;
|
77 |
+
std::cout << "\tfile:[realtime=1]///home/user/video/movie.pvn" << std::endl;
|
78 |
+
std::cout << "\tfile:///home/user/video/movie.avi" << std::endl;
|
79 |
+
std::cout << "\tfiles:///home/user/seqiemce/foo%03d.jpeg" << std::endl;
|
80 |
+
std::cout << "\tdc1394:[fmt=RGB24,size=640x480,fps=30,iso=400,dma=10]//0" << std::endl;
|
81 |
+
std::cout << "\tdc1394:[fmt=FORMAT7_1,size=640x480,pos=2+2,iso=400,dma=10]//0" << std::endl;
|
82 |
+
std::cout << "\tv4l:///dev/video0" << std::endl;
|
83 |
+
std::cout << "\tconvert:[fmt=RGB24]//v4l:///dev/video0" << std::endl;
|
84 |
+
std::cout << "\tmjpeg://http://127.0.0.1/?action=stream" << std::endl;
|
85 |
+
std::cout << std::endl;
|
86 |
+
|
87 |
+
// Try to open some video device
|
88 |
+
for(int i=0; !input_uris[i].empty(); ++i )
|
89 |
+
{
|
90 |
+
try{
|
91 |
+
std::cout << "Trying: " << input_uris[i] << std::endl;
|
92 |
+
RecordSample(input_uris[i], record_uri);
|
93 |
+
return 0;
|
94 |
+
}catch(const std::exception&) {}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
return 0;
|
99 |
+
|
100 |
+
}
|
third-party/DPVO/Pangolin/examples/SimpleScene/CMakeLists.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(SimpleScene main.cpp)
|
6 |
+
target_link_libraries(SimpleScene pango_display pango_scene)
|
third-party/DPVO/Pangolin/examples/SimpleScene/main.cpp
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <pangolin/display/display.h>
|
2 |
+
#include <pangolin/display/view.h>
|
3 |
+
#include <pangolin/scene/axis.h>
|
4 |
+
#include <pangolin/scene/scenehandler.h>
|
5 |
+
|
6 |
+
int main( int /*argc*/, char** /*argv*/ )
|
7 |
+
{
|
8 |
+
pangolin::CreateWindowAndBind("Main",640,480);
|
9 |
+
glEnable(GL_DEPTH_TEST);
|
10 |
+
|
11 |
+
// Define Projection and initial ModelView matrix
|
12 |
+
pangolin::OpenGlRenderState s_cam(
|
13 |
+
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.2,100),
|
14 |
+
pangolin::ModelViewLookAt(-2,2,-2, 0,0,0, pangolin::AxisY)
|
15 |
+
);
|
16 |
+
|
17 |
+
pangolin::Renderable tree;
|
18 |
+
for(size_t i=0; i < 10; ++i )
|
19 |
+
{
|
20 |
+
auto axis_i = std::make_shared<pangolin::Axis>();
|
21 |
+
axis_i->T_pc = pangolin::OpenGlMatrix::Translate(i*2.0, i*0.1, 0.0);
|
22 |
+
tree.Add(axis_i);
|
23 |
+
}
|
24 |
+
|
25 |
+
// Create Interactive View in window
|
26 |
+
pangolin::SceneHandler handler(tree, s_cam);
|
27 |
+
pangolin::View& d_cam = pangolin::CreateDisplay()
|
28 |
+
.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0f/480.0f)
|
29 |
+
.SetHandler(&handler);
|
30 |
+
|
31 |
+
d_cam.SetDrawFunction([&](pangolin::View& view){
|
32 |
+
view.Activate(s_cam);
|
33 |
+
tree.Render();
|
34 |
+
});
|
35 |
+
|
36 |
+
while( !pangolin::ShouldQuit() )
|
37 |
+
{
|
38 |
+
// Clear screen and activate view to render into
|
39 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
40 |
+
|
41 |
+
// Swap frames and Process Events
|
42 |
+
pangolin::FinishFrame();
|
43 |
+
}
|
44 |
+
|
45 |
+
return 0;
|
46 |
+
}
|
third-party/DPVO/Pangolin/examples/SimpleVideo/CMakeLists.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
|
5 |
+
add_executable(SimpleVideo main.cpp)
|
6 |
+
target_link_libraries(SimpleVideo pango_display pango_video)
|
third-party/DPVO/Pangolin/examples/SimpleVideo/main.cpp
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @author Steven Lovegrove
|
3 |
+
* Copyright (C) 2010 Steven Lovegrove
|
4 |
+
* Imperial College London
|
5 |
+
**/
|
6 |
+
|
7 |
+
#include <pangolin/display/display.h>
|
8 |
+
#include <pangolin/display/view.h>
|
9 |
+
#include <pangolin/video/video_input.h>
|
10 |
+
#include <pangolin/gl/gl.h>
|
11 |
+
|
12 |
+
|
13 |
+
void SetGlFormat(GLint& glformat, GLenum& gltype, const pangolin::PixelFormat& fmt)
|
14 |
+
{
|
15 |
+
switch( fmt.channels) {
|
16 |
+
case 1: glformat = GL_LUMINANCE; break;
|
17 |
+
case 3: glformat = GL_RGB; break;
|
18 |
+
case 4: glformat = GL_RGBA; break;
|
19 |
+
default: throw std::runtime_error("Unable to display video format");
|
20 |
+
}
|
21 |
+
|
22 |
+
switch (fmt.channel_bits[0]) {
|
23 |
+
case 8: gltype = GL_UNSIGNED_BYTE; break;
|
24 |
+
case 16: gltype = GL_UNSIGNED_SHORT; break;
|
25 |
+
case 32: gltype = GL_FLOAT; break;
|
26 |
+
default: throw std::runtime_error("Unknown channel format");
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
void VideoSample(const std::string uri)
|
31 |
+
{
|
32 |
+
// Setup Video Source
|
33 |
+
pangolin::VideoInput video(uri);
|
34 |
+
const pangolin::PixelFormat vid_fmt = video.PixFormat();
|
35 |
+
const unsigned w = video.Width();
|
36 |
+
const unsigned h = video.Height();
|
37 |
+
|
38 |
+
// Work out appropriate GL channel and format options
|
39 |
+
GLint glformat;
|
40 |
+
GLenum gltype;
|
41 |
+
SetGlFormat(glformat, gltype, vid_fmt);
|
42 |
+
|
43 |
+
// Create OpenGL window
|
44 |
+
pangolin::CreateWindowAndBind("Main",w,h);
|
45 |
+
|
46 |
+
// Create viewport for video with fixed aspect
|
47 |
+
pangolin::View& vVideo = pangolin::Display("Video").SetAspect((float)w/h);
|
48 |
+
|
49 |
+
// OpenGl Texture for video frame.
|
50 |
+
pangolin::GlTexture texVideo(w,h,glformat,false,0,glformat,gltype);
|
51 |
+
|
52 |
+
unsigned char* img = new unsigned char[video.SizeBytes()];
|
53 |
+
|
54 |
+
for(int frame=0; !pangolin::ShouldQuit(); ++frame)
|
55 |
+
{
|
56 |
+
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
57 |
+
|
58 |
+
if( video.GrabNext(img,true) ) {
|
59 |
+
texVideo.Upload( img, glformat, gltype );
|
60 |
+
}
|
61 |
+
|
62 |
+
// Activate video viewport and render texture
|
63 |
+
vVideo.Activate();
|
64 |
+
texVideo.RenderToViewportFlipY();
|
65 |
+
|
66 |
+
// Swap back buffer with front and process window events
|
67 |
+
pangolin::FinishFrame();
|
68 |
+
}
|
69 |
+
|
70 |
+
delete[] img;
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
int main( int argc, char* argv[] )
|
75 |
+
{
|
76 |
+
std::string uris[] = {
|
77 |
+
"convert:[fmt=RGB24]//v4l:///dev/video0",
|
78 |
+
"convert:[fmt=RGB24]//v4l:///dev/video1",
|
79 |
+
"dc1394:[fps=30,dma=10,size=640x480,iso=400]//0",
|
80 |
+
"openni:[img1=rgb]//",
|
81 |
+
"test:[size=160x120,n=1,fmt=RGB24]//"
|
82 |
+
""
|
83 |
+
};
|
84 |
+
|
85 |
+
if( argc > 1 ) {
|
86 |
+
const std::string uri = std::string(argv[1]);
|
87 |
+
VideoSample(uri);
|
88 |
+
}else{
|
89 |
+
std::cout << "Usage : SimpleRecord [video-uri]" << std::endl << std::endl;
|
90 |
+
std::cout << "Where video-uri describes a stream or file resource, e.g." << std::endl;
|
91 |
+
std::cout << "\tfile:[realtime=1]///home/user/video/movie.pvn" << std::endl;
|
92 |
+
std::cout << "\tfile:///home/user/video/movie.avi" << std::endl;
|
93 |
+
std::cout << "\tfiles:///home/user/seqiemce/foo%03d.jpeg" << std::endl;
|
94 |
+
std::cout << "\tdc1394:[fmt=RGB24,size=640x480,fps=30,iso=400,dma=10]//0" << std::endl;
|
95 |
+
std::cout << "\tdc1394:[fmt=FORMAT7_1,size=640x480,pos=2+2,iso=400,dma=10]//0" << std::endl;
|
96 |
+
std::cout << "\tv4l:///dev/video0" << std::endl;
|
97 |
+
std::cout << "\tconvert:[fmt=RGB24]//v4l:///dev/video0" << std::endl;
|
98 |
+
std::cout << "\tmjpeg://http://127.0.0.1/?action=stream" << std::endl;
|
99 |
+
std::cout << "\topenni:[img1=rgb]//" << std::endl;
|
100 |
+
std::cout << std::endl;
|
101 |
+
|
102 |
+
// Try to open some video device
|
103 |
+
for(int i=0; !uris[i].empty(); ++i )
|
104 |
+
{
|
105 |
+
try{
|
106 |
+
std::cout << "Trying: " << uris[i] << std::endl;
|
107 |
+
VideoSample(uris[i]);
|
108 |
+
return 0;
|
109 |
+
}catch(const std::exception&) { }
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
return 0;
|
114 |
+
}
|
third-party/DPVO/Pangolin/examples/VBODisplay/CMakeLists.txt
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
|
2 |
+
find_package(Pangolin 0.8 REQUIRED)
|
3 |
+
include_directories(${Pangolin_INCLUDE_DIRS})
|
4 |
+
link_directories(${Pangolin_LIBRARY_DIRS})
|
5 |
+
link_libraries(${Pangolin_LIBRARIES})
|
6 |
+
|
7 |
+
find_package(CUDA QUIET)
|
8 |
+
|
9 |
+
# This example could be made to work with C++11, but the kernel code must be
|
10 |
+
# compiled without it.
|
11 |
+
if(CUDA_FOUND)
|
12 |
+
cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
13 |
+
|
14 |
+
cuda_add_executable(
|
15 |
+
VBODisplay
|
16 |
+
main.cpp kernal.cu
|
17 |
+
)
|
18 |
+
|
19 |
+
endif()
|
third-party/DPVO/Pangolin/examples/VBODisplay/kernal.cu
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Colour Sine wave Kernal
|
2 |
+
// Based on kernal_colour in kernelVBO.cpp by Rob Farber
|
3 |
+
__global__ void kernel(float4* dVertexArray, uchar4 *dColorArray,
|
4 |
+
unsigned int width, unsigned int height, float time)
|
5 |
+
{
|
6 |
+
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
|
7 |
+
unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
|
8 |
+
|
9 |
+
// Each thread is unique point (u,v) in interval [-1,1],[-1,1]
|
10 |
+
const float u = 2.0f* (x/(float)width) - 1.0f;
|
11 |
+
const float v = 2.0f* (y/(float)height) - 1.0f;
|
12 |
+
const float w = 0.5f * sinf(4.0f*u + time) * cosf(4.0f*v + time);
|
13 |
+
|
14 |
+
// Update vertex array for point
|
15 |
+
dVertexArray[y*width+x] = make_float4(u, w, v, 1.0f);
|
16 |
+
|
17 |
+
// Update colour array for point
|
18 |
+
dColorArray[y*width+x].w = 0.0f;
|
19 |
+
dColorArray[y*width+x].x = 255.0f *0.5f*(1.f+sinf(w+x));
|
20 |
+
dColorArray[y*width+x].y = 255.0f *0.5f*(1.f+sinf(x)*cosf(y));
|
21 |
+
dColorArray[y*width+x].z = 255.0f *0.5f*(1.f+sinf(w+time/10.0f));
|
22 |
+
}
|
23 |
+
|
24 |
+
extern "C" void launch_kernel(float4* dVertexArray, uchar4* dColourArray,
|
25 |
+
unsigned int width, unsigned int height, float time)
|
26 |
+
{
|
27 |
+
dim3 block(8, 8, 1);
|
28 |
+
dim3 grid(width / block.x, height / block.y, 1);
|
29 |
+
kernel<<< grid, block>>>(dVertexArray, dColourArray, width, height, time);
|
30 |
+
}
|
third-party/DPVO/Pangolin/examples/VBODisplay/main.cpp
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <iostream>
|
2 |
+
|
3 |
+
#include <GL/glew.h>
|
4 |
+
|
5 |
+
#include <pangolin/pangolin.h>
|
6 |
+
#include <pangolin/gl/glcuda.h>
|
7 |
+
#include <pangolin/gl/glvbo.h>
|
8 |
+
|
9 |
+
#include <cuda_runtime.h>
|
10 |
+
#include <cuda_gl_interop.h>
|
11 |
+
#include <vector_types.h>
|
12 |
+
|
13 |
+
using namespace pangolin;
|
14 |
+
using namespace std;
|
15 |
+
|
16 |
+
// Mesh size
|
17 |
+
const int mesh_width=256;
|
18 |
+
const int mesh_height=256;
|
19 |
+
|
20 |
+
extern "C" void launch_kernel(float4* dVertexArray, uchar4* dColourArray, unsigned int width, unsigned int height, float time);
|
21 |
+
|
22 |
+
int main( int /*argc*/, char* argv[] )
|
23 |
+
{
|
24 |
+
// cudaGLSetGLDevice(0);
|
25 |
+
|
26 |
+
pangolin::CreateWindowAndBind("Main",640,480);
|
27 |
+
glewInit();
|
28 |
+
|
29 |
+
// 3D Mouse handler requires depth testing to be enabled
|
30 |
+
glEnable(GL_DEPTH_TEST);
|
31 |
+
|
32 |
+
// Create vertex and colour buffer objects and register them with CUDA
|
33 |
+
GlBufferCudaPtr vertex_array(
|
34 |
+
GlArrayBuffer, mesh_width*mesh_height, GL_FLOAT, 4,
|
35 |
+
cudaGraphicsMapFlagsWriteDiscard, GL_STREAM_DRAW
|
36 |
+
);
|
37 |
+
GlBufferCudaPtr colour_array(
|
38 |
+
GlArrayBuffer, mesh_width*mesh_height, GL_UNSIGNED_BYTE, 4,
|
39 |
+
cudaGraphicsMapFlagsWriteDiscard, GL_STREAM_DRAW
|
40 |
+
);
|
41 |
+
|
42 |
+
// Define Camera Render Object (for view / scene browsing)
|
43 |
+
pangolin::OpenGlRenderState s_cam(
|
44 |
+
ProjectionMatrix(640,480,420,420,320,240,0.1,1000),
|
45 |
+
ModelViewLookAt(-0,2,-2, 0,0,0, AxisY)
|
46 |
+
);
|
47 |
+
const int UI_WIDTH = 180;
|
48 |
+
|
49 |
+
// Add named OpenGL viewport to window and provide 3D Handler
|
50 |
+
View& d_cam = pangolin::Display("cam")
|
51 |
+
.SetBounds(0.0, 1.0, Attach::Pix(UI_WIDTH), 1.0, -640.0f/480.0f)
|
52 |
+
.SetHandler(new Handler3D(s_cam));
|
53 |
+
|
54 |
+
// Add named Panel and bind to variables beginning 'ui'
|
55 |
+
// A Panel is just a View with a default layout and input handling
|
56 |
+
View& d_panel = pangolin::CreatePanel("ui")
|
57 |
+
.SetBounds(0.0, 1.0, 0.0, Attach::Pix(UI_WIDTH));
|
58 |
+
|
59 |
+
// Default hooks for exiting (Esc) and fullscreen (tab).
|
60 |
+
for(int frame=0; !pangolin::ShouldQuit(); ++frame)
|
61 |
+
{
|
62 |
+
static double time = 0;
|
63 |
+
static Var<double> delta("ui.time delta", 0.001, 0, 0.005);
|
64 |
+
|
65 |
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
66 |
+
|
67 |
+
d_cam.Activate(s_cam);
|
68 |
+
glColor3f(1.0,1.0,1.0);
|
69 |
+
|
70 |
+
{
|
71 |
+
CudaScopedMappedPtr var(vertex_array);
|
72 |
+
CudaScopedMappedPtr car(colour_array);
|
73 |
+
launch_kernel((float4*)*var,(uchar4*)*car,mesh_width,mesh_height,time);
|
74 |
+
time += delta;
|
75 |
+
}
|
76 |
+
|
77 |
+
pangolin::RenderVboCbo(vertex_array, colour_array);
|
78 |
+
|
79 |
+
// Swap frames and Process Events
|
80 |
+
pangolin::FinishFrame();
|
81 |
+
}
|
82 |
+
|
83 |
+
return 0;
|
84 |
+
}
|
third-party/DPVO/Pangolin/package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package format="2">
|
3 |
+
<name>pangolin</name>
|
4 |
+
<version>0.8.0</version>
|
5 |
+
<description>Pangolin is a set of lightweight and portable utility libraries for prototyping 3D, numeric or video based programs and algorithms.</description>
|
6 |
+
<maintainer email="[email protected]">Steven Lovegrove</maintainer>
|
7 |
+
<author email="[email protected]">Steven Lovegrove</author>
|
8 |
+
<license>MIT</license>
|
9 |
+
|
10 |
+
<buildtool_depend>cmake</buildtool_depend>
|
11 |
+
|
12 |
+
<depend>libglew-dev</depend>
|
13 |
+
<depend>python3-dev</depend>
|
14 |
+
<build_depend>eigen</build_depend>
|
15 |
+
|
16 |
+
<export>
|
17 |
+
<build_type>cmake</build_type>
|
18 |
+
</export>
|
19 |
+
</package>
|
third-party/DPVO/Pangolin/scripts/install_prerequisites.sh
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# exit when any command fails
|
4 |
+
set -e
|
5 |
+
|
6 |
+
MANAGERS=(dnf apt port vcpkg brew)
|
7 |
+
MANAGER=""
|
8 |
+
LIST=0
|
9 |
+
VERBOSE=0
|
10 |
+
DRYRUN=0
|
11 |
+
UPDATE=0
|
12 |
+
REQUIRED_RECOMMENDED_ALL=1
|
13 |
+
SUDO=""
|
14 |
+
|
15 |
+
PKGS_UPDATE=""
|
16 |
+
PKGS_REQUIRED=()
|
17 |
+
PKGS_RECOMMENDED=()
|
18 |
+
PKGS_ALL=()
|
19 |
+
PKGS_OPTIONS=()
|
20 |
+
|
21 |
+
# Parse Command line
|
22 |
+
PARAMS=""
|
23 |
+
while (( "$#" )); do
|
24 |
+
case "$1" in
|
25 |
+
-v|--verbose)
|
26 |
+
VERBOSE=1
|
27 |
+
shift
|
28 |
+
;;
|
29 |
+
-d|--dry-run)
|
30 |
+
DRYRUN=1
|
31 |
+
shift
|
32 |
+
;;
|
33 |
+
-l|--list)
|
34 |
+
LIST=1
|
35 |
+
shift
|
36 |
+
;;
|
37 |
+
-u|--update-package-list)
|
38 |
+
UPDATE=1
|
39 |
+
shift
|
40 |
+
;;
|
41 |
+
-m|--package-manager)
|
42 |
+
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
|
43 |
+
MANAGERS=($2)
|
44 |
+
shift 2
|
45 |
+
else
|
46 |
+
echo "Error: Argument for $1 is missing" >&2
|
47 |
+
exit 1
|
48 |
+
fi
|
49 |
+
;;
|
50 |
+
-h|--help)
|
51 |
+
echo "$0 [-vh] [-m package-manager-list] [required|recommended|all]"
|
52 |
+
echo " -m, --package-manager: preferred package manager order (default: \"${MANAGERS[*]}\")"
|
53 |
+
echo " -v, --verbose: verbose output"
|
54 |
+
echo " -d, --dry-run: print actions, but do not execute"
|
55 |
+
echo " -l, --list: just list the packages to install"
|
56 |
+
echo " -u, --update-package-list: update package manager package list"
|
57 |
+
echo " -h, --help: this help message"
|
58 |
+
echo " (required|recommended|all) the set of dependencies to select."
|
59 |
+
exit 0
|
60 |
+
;;
|
61 |
+
-*|--*=) # unsupported flags
|
62 |
+
echo "Error: Unsupported flag $1" >&2
|
63 |
+
exit 1
|
64 |
+
;;
|
65 |
+
*) # preserve positional arguments
|
66 |
+
PARAMS="$1"
|
67 |
+
shift
|
68 |
+
;;
|
69 |
+
esac
|
70 |
+
done
|
71 |
+
|
72 |
+
# Make lower case
|
73 |
+
PARAMS=$(echo "$PARAMS" | tr '[:upper:]' '[:lower:]' | tr -s "[:blank:]")
|
74 |
+
|
75 |
+
# Work out which set of dependencies we're installing
|
76 |
+
case "$PARAMS" in
|
77 |
+
required)
|
78 |
+
REQUIRED_RECOMMENDED_ALL=0
|
79 |
+
if ((VERBOSE > 0)); then echo "Selecting required dependencies only."; fi
|
80 |
+
;;
|
81 |
+
""|recommended)
|
82 |
+
REQUIRED_RECOMMENDED_ALL=1
|
83 |
+
if ((VERBOSE > 0)); then echo "Selecting required+recommended dependencies."; fi
|
84 |
+
;;
|
85 |
+
all)
|
86 |
+
REQUIRED_RECOMMENDED_ALL=2
|
87 |
+
if ((VERBOSE > 0)); then echo "Selecting all available dependencies."; fi
|
88 |
+
;;
|
89 |
+
*)
|
90 |
+
echo "Unrecognized positional argument \"$PARAMS\". Expecting one of (required,recommended [default],all)"
|
91 |
+
exit 1
|
92 |
+
;;
|
93 |
+
esac
|
94 |
+
|
95 |
+
|
96 |
+
# Find an available package manager from the preferred list
|
97 |
+
for m in ${MANAGERS[@]}
|
98 |
+
do
|
99 |
+
if [ -x "$(command -v $m)" ]; then
|
100 |
+
MANAGER="$m"
|
101 |
+
break
|
102 |
+
fi
|
103 |
+
done
|
104 |
+
|
105 |
+
# If no package manager is found, exit
|
106 |
+
if [ -z "$MANAGER" ]
|
107 |
+
then
|
108 |
+
echo "Error: No preferred package managers from list [${MANAGERS[*]}] found. Use -m to select manually." >&2
|
109 |
+
exit 1
|
110 |
+
fi
|
111 |
+
if ((VERBOSE > 0)); then echo "Using \"$MANAGER\" package manager (select another using -m)"; fi
|
112 |
+
|
113 |
+
# Setup prereq commands and packages.
|
114 |
+
if [[ "$MANAGER" == "apt" ]]; then
|
115 |
+
SUDO="sudo"
|
116 |
+
PKGS_UPDATE="apt update"
|
117 |
+
PKGS_OPTIONS+=(install --no-install-suggests --no-install-recommends)
|
118 |
+
if ((DRYRUN > 0)); then PKGS_OPTIONS+=(--dry-run); fi
|
119 |
+
PKGS_REQUIRED+=(libgl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols libegl1-mesa-dev)
|
120 |
+
PKGS_REQUIRED+=(libc++-dev libglew-dev libeigen3-dev cmake g++ ninja-build)
|
121 |
+
PKGS_RECOMMENDED+=(libjpeg-dev libpng-dev)
|
122 |
+
PKGS_RECOMMENDED+=(libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev)
|
123 |
+
PKGS_ALL+=(libdc1394-22-dev libraw1394-dev libopenni-dev python3.9-dev python3-distutils)
|
124 |
+
elif [[ "$MANAGER" == "dnf" ]]; then
|
125 |
+
SUDO="sudo"
|
126 |
+
PKGS_UPDATE="dnf check-update"
|
127 |
+
PKGS_OPTIONS+=(install)
|
128 |
+
PKGS_REQUIRED+=(wayland-devel libxkbcommon-devel g++ ninja-build)
|
129 |
+
PKGS_REQUIRED+=(glew-devel eigen3 cmake)
|
130 |
+
PKGS_RECOMMENDED+=(libjpeg-devel libpng-devel OpenEXR-devel)
|
131 |
+
PKGS_ALL+=(libdc1394-22-devel libraw1394-devel librealsense-devel openni-devel)
|
132 |
+
if ((DRYRUN > 0)); then
|
133 |
+
MANAGER="echo $MANAGER"
|
134 |
+
fi
|
135 |
+
elif [[ "$MANAGER" == "port" ]]; then
|
136 |
+
SUDO="sudo"
|
137 |
+
PKGS_UPDATE="port sync -q"
|
138 |
+
PKGS_OPTIONS+=(-N install -q)
|
139 |
+
if ((DRYRUN > 0)); then PKGS_OPTIONS+=(-y); fi
|
140 |
+
PKGS_REQUIRED+=(glew eigen3-devel cmake +gui ninja)
|
141 |
+
PKGS_RECOMMENDED+=(jpeg libpng openexr tiff ffmpeg-devel lz4 zstd py37-pybind11 catch2)
|
142 |
+
PKGS_ALL+=(libdc1394 openni)
|
143 |
+
elif [[ "$MANAGER" == "brew" ]]; then
|
144 |
+
PKGS_OPTIONS+=(install)
|
145 |
+
if ((VERBOSE > 0)); then PKGS_OPTIONS+=(--verbose); fi
|
146 |
+
PKGS_REQUIRED+=(glew eigen cmake ninja)
|
147 |
+
PKGS_RECOMMENDED+=(libjpeg libpng openexr libtiff ffmpeg lz4 zstd catch2)
|
148 |
+
# Brew doesn't have a dryrun option
|
149 |
+
if ((DRYRUN > 0)); then
|
150 |
+
MANAGER="echo $MANAGER"
|
151 |
+
fi
|
152 |
+
elif [[ "$MANAGER" == "vcpkg" ]]; then
|
153 |
+
# TODO: this should be a config option somehow...
|
154 |
+
PKGS_OPTIONS+=(install --triplet=x64-windows )
|
155 |
+
if ((DRYRUN > 0)); then PKGS_OPTIONS+=(--dry-run); fi
|
156 |
+
PKGS_REQUIRED+=(glew eigen3)
|
157 |
+
PKGS_RECOMMENDED+=(libjpeg-turbo libpng openexr tiff ffmpeg lz4 zstd python3 Catch2)
|
158 |
+
PKGS_ALL+=(openni2 realsense2)
|
159 |
+
else
|
160 |
+
echo "Error: Don't know how to use \"$MANAGER\", please fix the script." >&2
|
161 |
+
exit 1
|
162 |
+
fi
|
163 |
+
|
164 |
+
if ((REQUIRED_RECOMMENDED_ALL < 2)); then PKGS_ALL=(); fi
|
165 |
+
if ((REQUIRED_RECOMMENDED_ALL < 1)); then PKGS_RECOMMENDED=(); fi
|
166 |
+
|
167 |
+
PACKAGES=( "${PKGS_REQUIRED[*]}" "${PKGS_RECOMMENDED[*]}" "${PKGS_ALL[*]}" )
|
168 |
+
|
169 |
+
if ((LIST > 0)); then
|
170 |
+
echo "${PACKAGES[*]}"
|
171 |
+
exit 0
|
172 |
+
fi
|
173 |
+
|
174 |
+
if ((UPDATE > 0)); then
|
175 |
+
if ((VERBOSE > 0)); then echo "Requesting \"$MANAGER\" package update."; fi
|
176 |
+
$SUDO $PKGS_UPDATE
|
177 |
+
fi
|
178 |
+
|
179 |
+
if ((VERBOSE > 0)); then echo "Requesting install of: ${PACKAGES[*]}"; fi
|
180 |
+
|
181 |
+
# Install
|
182 |
+
$SUDO $MANAGER ${PKGS_OPTIONS[*]} ${PACKAGES[*]}
|
third-party/DPVO/Pangolin/scripts/utils/ansi2html.sh
ADDED
@@ -0,0 +1,527 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/sh
|
2 |
+
|
3 |
+
# Convert ANSI (terminal) colours and attributes to HTML
|
4 |
+
|
5 |
+
# Licence: LGPLv2
|
6 |
+
# Author:
|
7 |
+
# http://www.pixelbeat.org/docs/terminal_colours/
|
8 |
+
# Examples:
|
9 |
+
# ls -l --color=always | ansi2html.sh > ls.html
|
10 |
+
# git show --color | ansi2html.sh > last_change.html
|
11 |
+
# Generally one can use the `script` util to capture full terminal output.
|
12 |
+
# Changes:
|
13 |
+
# V0.1, 24 Apr 2008, Initial release
|
14 |
+
# V0.2, 01 Jan 2009, Phil Harnish <[email protected]>
|
15 |
+
# Support `git diff --color` output by
|
16 |
+
# matching ANSI codes that specify only
|
17 |
+
# bold or background colour.
|
18 | |
19 |
+
# Support `ls --color` output by stripping
|
20 |
+
# redundant leading 0s from ANSI codes.
|
21 |
+
# Support `grep --color=always` by stripping
|
22 |
+
# unhandled ANSI codes (specifically ^[[K).
|
23 |
+
# V0.3, 20 Mar 2009, http://eexpress.blog.ubuntu.org.cn/
|
24 |
+
# Remove cat -v usage which mangled non ascii input.
|
25 |
+
# Cleanup regular expressions used.
|
26 |
+
# Support other attributes like reverse, ...
|
27 | |
28 |
+
# Correctly nest <span> tags (even across lines).
|
29 |
+
# Add a command line option to use a dark background.
|
30 |
+
# Strip more terminal control codes.
|
31 |
+
# V0.4, 17 Sep 2009, [email protected]
|
32 |
+
# Handle codes with combined attributes and color.
|
33 |
+
# Handle isolated <bold> attributes with css.
|
34 |
+
# Strip more terminal control codes.
|
35 |
+
# V0.26, 16 Nov 2019
|
36 |
+
# http://github.com/pixelb/scripts/commits/master/scripts/ansi2html.sh
|
37 |
+
|
38 |
+
gawk --version >/dev/null || exit 1
|
39 |
+
|
40 |
+
if [ "$1" = "--version" ]; then
|
41 |
+
printf '0.26\n' && exit
|
42 |
+
fi
|
43 |
+
|
44 |
+
usage()
|
45 |
+
{
|
46 |
+
printf '%s\n' \
|
47 |
+
'This utility converts ANSI codes in data passed to stdin
|
48 |
+
It has 4 optional parameters:
|
49 |
+
--bg=dark --palette=linux|solarized|tango|xterm --css-only|--body-only
|
50 |
+
E.g.: ls -l --color=always | ansi2html.sh --bg=dark > ls.html' >&2
|
51 |
+
exit
|
52 |
+
}
|
53 |
+
|
54 |
+
if [ "$1" = "--help" ]; then
|
55 |
+
usage
|
56 |
+
fi
|
57 |
+
|
58 |
+
processArg()
|
59 |
+
{
|
60 |
+
[ "$1" = "--bg=dark" ] && { dark_bg=yes; return; }
|
61 |
+
[ "$1" = "--css-only" ] && { css_only=yes; return; }
|
62 |
+
[ "$1" = "--body-only" ] && { body_only=yes; return; }
|
63 |
+
if [ "$1" = "--palette=solarized" ]; then
|
64 |
+
# See http://ethanschoonover.com/solarized
|
65 |
+
P0=073642; P1=D30102; P2=859900; P3=B58900;
|
66 |
+
P4=268BD2; P5=D33682; P6=2AA198; P7=EEE8D5;
|
67 |
+
P8=002B36; P9=CB4B16; P10=586E75; P11=657B83;
|
68 |
+
P12=839496; P13=6C71C4; P14=93A1A1; P15=FDF6E3;
|
69 |
+
return;
|
70 |
+
elif [ "$1" = "--palette=solarized-xterm" ]; then
|
71 |
+
# Above mapped onto the xterm 256 color palette
|
72 |
+
P0=262626; P1=AF0000; P2=5F8700; P3=AF8700;
|
73 |
+
P4=0087FF; P5=AF005F; P6=00AFAF; P7=E4E4E4;
|
74 |
+
P8=1C1C1C; P9=D75F00; P10=585858; P11=626262;
|
75 |
+
P12=808080; P13=5F5FAF; P14=8A8A8A; P15=FFFFD7;
|
76 |
+
return;
|
77 |
+
elif [ "$1" = "--palette=tango" ]; then
|
78 |
+
# Gnome default
|
79 |
+
P0=000000; P1=CC0000; P2=4E9A06; P3=C4A000;
|
80 |
+
P4=3465A4; P5=75507B; P6=06989A; P7=D3D7CF;
|
81 |
+
P8=555753; P9=EF2929; P10=8AE234; P11=FCE94F;
|
82 |
+
P12=729FCF; P13=AD7FA8; P14=34E2E2; P15=EEEEEC;
|
83 |
+
return;
|
84 |
+
elif [ "$1" = "--palette=xterm" ]; then
|
85 |
+
P0=000000; P1=CD0000; P2=00CD00; P3=CDCD00;
|
86 |
+
P4=0000EE; P5=CD00CD; P6=00CDCD; P7=E5E5E5;
|
87 |
+
P8=7F7F7F; P9=FF0000; P10=00FF00; P11=FFFF00;
|
88 |
+
P12=5C5CFF; P13=FF00FF; P14=00FFFF; P15=FFFFFF;
|
89 |
+
return;
|
90 |
+
else # linux console
|
91 |
+
P0=000000; P1=AA0000; P2=00AA00; P3=AA5500;
|
92 |
+
P4=0000AA; P5=AA00AA; P6=00AAAA; P7=AAAAAA;
|
93 |
+
P8=555555; P9=FF5555; P10=55FF55; P11=FFFF55;
|
94 |
+
P12=5555FF; P13=FF55FF; P14=55FFFF; P15=FFFFFF;
|
95 |
+
[ "$1" = "--palette=linux" ] && return;
|
96 |
+
fi
|
97 |
+
}
|
98 |
+
|
99 |
+
processArg #defaults
|
100 |
+
for var in "$@"; do processArg $var; done
|
101 |
+
[ "$css_only" ] && [ "$body_only" ] && usage
|
102 |
+
|
103 |
+
# Mac OSX's GNU sed is installed as gsed
|
104 |
+
# use e.g. homebrew 'gnu-sed' to get it
|
105 |
+
if ! sed --version >/dev/null 2>&1; then
|
106 |
+
if gsed --version >/dev/null 2>&1; then
|
107 |
+
alias sed=gsed
|
108 |
+
else
|
109 |
+
echo "Error, can't find an acceptable GNU sed." >&2
|
110 |
+
exit 1
|
111 |
+
fi
|
112 |
+
fi
|
113 |
+
|
114 |
+
[ "$css_only" ] || [ "$body_only" ] || printf '%s' "<html>
|
115 |
+
<head>
|
116 |
+
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
|
117 |
+
<style type=\"text/css\">
|
118 |
+
pre { white-space: pre-wrap; }
|
119 |
+
"
|
120 |
+
[ "$body_only" ] || printf ".ef0,.f0 { color: #$P0; } .eb0,.b0 { background-color: #$P0; }
|
121 |
+
.ef1,.f1 { color: #$P1; } .eb1,.b1 { background-color: #$P1; }
|
122 |
+
.ef2,.f2 { color: #$P2; } .eb2,.b2 { background-color: #$P2; }
|
123 |
+
.ef3,.f3 { color: #$P3; } .eb3,.b3 { background-color: #$P3; }
|
124 |
+
.ef4,.f4 { color: #$P4; } .eb4,.b4 { background-color: #$P4; }
|
125 |
+
.ef5,.f5 { color: #$P5; } .eb5,.b5 { background-color: #$P5; }
|
126 |
+
.ef6,.f6 { color: #$P6; } .eb6,.b6 { background-color: #$P6; }
|
127 |
+
.ef7,.f7 { color: #$P7; } .eb7,.b7 { background-color: #$P7; }
|
128 |
+
.ef8, .f0 > .bold,.bold > .f0 { color: #$P8; font-weight: normal; }
|
129 |
+
.ef9, .f1 > .bold,.bold > .f1 { color: #$P9; font-weight: normal; }
|
130 |
+
.ef10,.f2 > .bold,.bold > .f2 { color: #$P10; font-weight: normal; }
|
131 |
+
.ef11,.f3 > .bold,.bold > .f3 { color: #$P11; font-weight: normal; }
|
132 |
+
.ef12,.f4 > .bold,.bold > .f4 { color: #$P12; font-weight: normal; }
|
133 |
+
.ef13,.f5 > .bold,.bold > .f5 { color: #$P13; font-weight: normal; }
|
134 |
+
.ef14,.f6 > .bold,.bold > .f6 { color: #$P14; font-weight: normal; }
|
135 |
+
.ef15,.f7 > .bold,.bold > .f7 { color: #$P15; font-weight: normal; }
|
136 |
+
.eb8 { background-color: #$P8; }
|
137 |
+
.eb9 { background-color: #$P9; }
|
138 |
+
.eb10 { background-color: #$P10; }
|
139 |
+
.eb11 { background-color: #$P11; }
|
140 |
+
.eb12 { background-color: #$P12; }
|
141 |
+
.eb13 { background-color: #$P13; }
|
142 |
+
.eb14 { background-color: #$P14; }
|
143 |
+
.eb15 { background-color: #$P15; }
|
144 |
+
"
|
145 |
+
# The default xterm 256 colour palette
|
146 |
+
for red in 0 1 2 3 4 5 ; do
|
147 |
+
for green in 0 1 2 3 4 5 ; do
|
148 |
+
for blue in 0 1 2 3 4 5 ; do
|
149 |
+
c=$((16 + ($red * 36) + ($green * 6) + $blue))
|
150 |
+
r=$((($red * 40 + 55) * ($red > 0)))
|
151 |
+
g=$((($green * 40 + 55) * ($green > 0)))
|
152 |
+
b=$((($blue * 40 + 55) * ($blue > 0)))
|
153 |
+
[ "$body_only" ] || printf ".ef%d { color: #%2.2x%2.2x%2.2x; } " $c $r $g $b
|
154 |
+
[ "$body_only" ] || printf ".eb%d { background-color: #%2.2x%2.2x%2.2x; }\n" $c $r $g $b
|
155 |
+
done
|
156 |
+
done
|
157 |
+
done
|
158 |
+
for gray in $(seq 0 23); do
|
159 |
+
c=$(($gray+232))
|
160 |
+
l=$(($gray*10 + 8))
|
161 |
+
[ "$body_only" ] || printf ".ef%d { color: #%2.2x%2.2x%2.2x; } " $c $l $l $l
|
162 |
+
[ "$body_only" ] || printf ".eb%d { background-color: #%2.2x%2.2x%2.2x; }\n" $c $l $l $l
|
163 |
+
done
|
164 |
+
|
165 |
+
[ "$body_only" ] || printf '%s' '
|
166 |
+
.f9 { color: '`[ "$dark_bg" ] && printf "#$P7;" || printf "#$P0;"`' }
|
167 |
+
.b9 { background-color: #'`[ "$dark_bg" ] && printf $P0 || printf $P15`'; }
|
168 |
+
.f9 > .bold,.bold > .f9, body.f9 > pre > .bold {
|
169 |
+
/* Bold is heavy black on white, or bright white
|
170 |
+
depending on the default background */
|
171 |
+
color: '`[ "$dark_bg" ] && printf "#$P15;" || printf "#$P0;"`'
|
172 |
+
font-weight: '`[ "$dark_bg" ] && printf 'normal;' || printf 'bold;'`'
|
173 |
+
}
|
174 |
+
.reverse {
|
175 |
+
/* CSS does not support swapping fg and bg colours unfortunately,
|
176 |
+
so just hardcode something that will look OK on all backgrounds. */
|
177 |
+
'"color: #$P0; background-color: #$P7;"'
|
178 |
+
}
|
179 |
+
.underline { text-decoration: underline; }
|
180 |
+
.line-through { text-decoration: line-through; }
|
181 |
+
.blink { text-decoration: blink; }
|
182 |
+
|
183 |
+
/* Avoid pixels between adjacent span elements.
|
184 |
+
Note this only works for lines less than 80 chars
|
185 |
+
where we close span elements on the same line.
|
186 |
+
span { display: inline-block; }
|
187 |
+
*/
|
188 |
+
'
|
189 |
+
[ "$body_only" ] || [ "$css_only" ] && printf '%s\n' \
|
190 |
+
'To use the css generated from --css-only, do: '\
|
191 |
+
'<head><link rel="stylesheet" type="text/css" href="style.css"></head>' >&2
|
192 |
+
[ "$css_only" ] && exit
|
193 |
+
[ "$body_only" ] || printf '%s' '</style>
|
194 |
+
</head>
|
195 |
+
|
196 |
+
<body class="f9 b9">
|
197 |
+
<pre>
|
198 |
+
'
|
199 |
+
[ "$body_only" ] && printf '%s\n' 'Be sure to use <body class="f9 b9"> and <pre>' >&2
|
200 |
+
|
201 |
+
p='\x1b\[' #shortcut to match escape codes
|
202 |
+
|
203 |
+
# Handle various xterm control sequences.
|
204 |
+
# See /usr/share/doc/xterm-*/ctlseqs.txt
|
205 |
+
sed "
|
206 |
+
# escape ampersand and quote
|
207 |
+
s#&#\&#g; s#\"#\"#g;
|
208 |
+
s#\x1b[^\x1b]*\x1b\\\##g # strip anything between \e and ST
|
209 |
+
s#\x1b][0-9]*;[^\a]*\a##g # strip any OSC (xterm title etc.)
|
210 |
+
|
211 |
+
s#\r\$## # strip trailing \r
|
212 |
+
|
213 |
+
# strip other non SGR escape sequences
|
214 |
+
s#[\x07]##g
|
215 |
+
s#\x1b[]>=\][0-9;]*##g
|
216 |
+
s#\x1bP+.\{5\}##g
|
217 |
+
# Mark cursor positioning codes \"Jr;c;
|
218 |
+
s#${p}\([0-9]\{1,2\}\)G#\"J;\1;#g
|
219 |
+
s#${p}\([0-9]\{1,2\}\);\([0-9]\{1,2\}\)H#\"J\1;\2;#g
|
220 |
+
|
221 |
+
# Mark clear as \"Cn where n=1 is screen and n=0 is to end-of-line
|
222 |
+
s#${p}H#\"C1;#g
|
223 |
+
s#${p}K#\"C0;#g
|
224 |
+
# Mark Cursor move columns as \"Mn where n is +ve for right, -ve for left
|
225 |
+
s#${p}C#\"M1;#g
|
226 |
+
s#${p}\([0-9]\{1,\}\)C#\"M\1;#g
|
227 |
+
s#${p}\([0-9]\{1,\}\)D#\"M-\1;#g
|
228 |
+
s#${p}\([0-9]\{1,\}\)P#\"X\1;#g
|
229 |
+
|
230 |
+
s#${p}[0-9;?]*[^0-9;?m]##g
|
231 |
+
|
232 |
+
" |
|
233 |
+
|
234 |
+
# Normalize the input before transformation
|
235 |
+
sed "
|
236 |
+
# escape HTML (ampersand and quote done above)
|
237 |
+
s#>#\>#g; s#<#\<#g;
|
238 |
+
|
239 |
+
# handle truecolor
|
240 |
+
s#${p}38;2;\([0-9]\{1,3\}\);\([0-9]\{1,3\}\);\([0-9]\{1,3\}\)m#\
|
241 |
+
<span style=\"color:rgb(\1\,\2\,\3\)\">#g
|
242 |
+
s#${p}48;2;\([0-9]\{1,3\}\);\([0-9]\{1,3\}\);\([0-9]\{1,3\}\)m#\
|
243 |
+
<span style=\"background-color:rgb(\1\,\2\,\3\)\">#g
|
244 |
+
|
245 |
+
# normalize SGR codes a little
|
246 |
+
|
247 |
+
# split 256 colors out and mark so that they're not
|
248 |
+
# recognised by the following 'split combined' line
|
249 |
+
:e
|
250 |
+
s#${p}\([0-9;]\{1,\}\);\([34]8;5;[0-9]\{1,3\}\)m#${p}\1m${p}¬\2m#g; t e
|
251 |
+
s#${p}\([34]8;5;[0-9]\{1,3\}\)m#${p}¬\1m#g;
|
252 |
+
|
253 |
+
:c
|
254 |
+
s#${p}\([0-9]\{1,\}\);\([0-9;]\{1,\}\)m#${p}\1m${p}\2m#g; t c # split combined
|
255 |
+
s#${p}0\([0-7]\)#${p}\1#g #strip leading 0
|
256 |
+
s#${p}1m\(\(${p}[4579]m\)*\)#\1${p}1m#g #bold last (with clr)
|
257 |
+
s#${p}m#${p}0m#g #add leading 0 to norm
|
258 |
+
|
259 |
+
# undo any 256 color marking
|
260 |
+
s#${p}¬\([34]8;5;[0-9]\{1,3\}\)m#${p}\1m#g;
|
261 |
+
|
262 |
+
# map 16 color codes to color + bold
|
263 |
+
s#${p}9\([0-7]\)m#${p}3\1m${p}1m#g;
|
264 |
+
s#${p}10\([0-7]\)m#${p}4\1m${p}1m#g;
|
265 |
+
|
266 |
+
# change 'reset' code to \"R
|
267 |
+
s#${p}0m#\"R;#g
|
268 |
+
" |
|
269 |
+
|
270 |
+
# Convert SGR sequences to HTML
|
271 |
+
sed "
|
272 |
+
# common combinations to minimise html (optional)
|
273 |
+
:f
|
274 |
+
s#${p}3[0-7]m${p}3\([0-7]\)m#${p}3\1m#g; t f
|
275 |
+
:b
|
276 |
+
s#${p}4[0-7]m${p}4\([0-7]\)m#${p}4\1m#g; t b
|
277 |
+
s#${p}3\([0-7]\)m${p}4\([0-7]\)m#<span class=\"f\1 b\2\">#g
|
278 |
+
s#${p}4\([0-7]\)m${p}3\([0-7]\)m#<span class=\"f\2 b\1\">#g
|
279 |
+
|
280 |
+
s#${p}1m#<span class=\"bold\">#g
|
281 |
+
s#${p}4m#<span class=\"underline\">#g
|
282 |
+
s#${p}5m#<span class=\"blink\">#g
|
283 |
+
s#${p}7m#<span class=\"reverse\">#g
|
284 |
+
s#${p}9m#<span class=\"line-through\">#g
|
285 |
+
s#${p}3\([0-9]\)m#<span class=\"f\1\">#g
|
286 |
+
s#${p}4\([0-9]\)m#<span class=\"b\1\">#g
|
287 |
+
|
288 |
+
s#${p}38;5;\([0-9]\{1,3\}\)m#<span class=\"ef\1\">#g
|
289 |
+
s#${p}48;5;\([0-9]\{1,3\}\)m#<span class=\"eb\1\">#g
|
290 |
+
|
291 |
+
s#${p}[0-9;]*m##g # strip unhandled codes
|
292 |
+
" |
|
293 |
+
|
294 |
+
# Convert alternative character set and handle cursor movement codes
|
295 |
+
# Note we convert here, as if we do at start we have to worry about avoiding
|
296 |
+
# conversion of SGR codes etc., whereas doing here we only have to
|
297 |
+
# avoid conversions of stuff between &...; or <...>
|
298 |
+
#
|
299 |
+
# Note we could use sed to do this based around:
|
300 |
+
# sed 'y/abcdefghijklmnopqrstuvwxyz{}`~/▒␉␌␍␊°±␋┘┐┌└┼⎺⎻─⎼⎽├┤┴┬│≤≥π£◆·/'
|
301 |
+
# However that would be very awkward as we need to only conv some input.
|
302 |
+
# The basic scheme that we do in the awk script below is:
|
303 |
+
# 1. enable transliterate once "T1; is seen
|
304 |
+
# 2. disable once "T0; is seen (may be on diff line)
|
305 |
+
# 3. never transliterate between &; or <> chars
|
306 |
+
# 4. track x,y movements and active display mode at each position
|
307 |
+
# 5. buffer line/screen and dump when required
|
308 |
+
sed "
|
309 |
+
# change 'smacs' and 'rmacs' to \"T1 and \"T0 to simplify matching.
|
310 |
+
s#\x1b(0#\"T1;#g;
|
311 |
+
s#\x0E#\"T1;#g;
|
312 |
+
|
313 |
+
s#\x1b(B#\"T0;#g
|
314 |
+
s#\x0F#\"T0;#g
|
315 |
+
" |
|
316 |
+
(
|
317 |
+
gawk '
|
318 |
+
function dump_line(l,del,c,blanks,ret) {
|
319 |
+
for(c=1;c<maxX;c++) {
|
320 |
+
if ((c SUBSEP l) in attr || alength(cur)) {
|
321 |
+
ret = ret blanks fixas(cur,attr[c,l])
|
322 |
+
if(del) delete attr[c,l]
|
323 |
+
blanks=""
|
324 |
+
}
|
325 |
+
if ((c SUBSEP l) in dump) {
|
326 |
+
ret=ret blanks dump[c,l]
|
327 |
+
if(del) delete dump[c,l]
|
328 |
+
blanks=""
|
329 |
+
} else blanks=blanks " "
|
330 |
+
}
|
331 |
+
if(alength(cur)) ret=ret blanks
|
332 |
+
return ret
|
333 |
+
}
|
334 |
+
|
335 |
+
function dump_screen(l,ret) {
|
336 |
+
for(l=1;l<=maxY;l++)
|
337 |
+
ret=ret dump_line(l,0) "\n"
|
338 |
+
return ret fixas(cur, "")
|
339 |
+
}
|
340 |
+
|
341 |
+
function atos(a,i,ret) {
|
342 |
+
for(i=1;i<=alength(a);i++) if(i in a) ret=ret a[i]
|
343 |
+
return ret
|
344 |
+
}
|
345 |
+
|
346 |
+
function alength(a, i, k) {
|
347 |
+
k = 0
|
348 |
+
for(i in a) k++
|
349 |
+
return k
|
350 |
+
}
|
351 |
+
|
352 |
+
function fixas(a,s,spc,i,attr,rm,ret) {
|
353 |
+
spc=alength(a)
|
354 |
+
l=split(s,attr,">")
|
355 |
+
for(i=1;i<=spc;i++) {
|
356 |
+
rm=rm?rm:(a[i]!=attr[i]">")
|
357 |
+
if(rm) {
|
358 |
+
ret=ret "</span>"
|
359 |
+
delete a[i];
|
360 |
+
}
|
361 |
+
}
|
362 |
+
for(i=1;i<l;i++) {
|
363 |
+
attr[i]=attr[i]">"
|
364 |
+
if(a[i]!=attr[i]) {
|
365 |
+
a[i]=attr[i]
|
366 |
+
ret = ret attr[i]
|
367 |
+
}
|
368 |
+
}
|
369 |
+
return ret
|
370 |
+
}
|
371 |
+
|
372 |
+
function encode(string,start,end,i,ret,pos,sc,buf) {
|
373 |
+
if(!end) end=length(string);
|
374 |
+
if(!start) start=1;
|
375 |
+
state=3
|
376 |
+
for(i=1;i<=length(string);i++) {
|
377 |
+
c=substr(string,i,1)
|
378 |
+
if(state==2) {
|
379 |
+
sc=sc c
|
380 |
+
if(c==";") {
|
381 |
+
c=sc
|
382 |
+
state=last_mode
|
383 |
+
} else continue
|
384 |
+
} else {
|
385 |
+
if(c=="\r") { x=1; continue }
|
386 |
+
if(c=="<") {
|
387 |
+
# Change attributes - store current active
|
388 |
+
# attributes in span array
|
389 |
+
split(substr(string,i),cord,">");
|
390 |
+
i+=length(cord[1])
|
391 |
+
span[++spc]=cord[1] ">"
|
392 |
+
continue
|
393 |
+
}
|
394 |
+
else if(c=="&") {
|
395 |
+
# All goes to single position till we see a semicolon
|
396 |
+
sc=c
|
397 |
+
state=2
|
398 |
+
continue
|
399 |
+
}
|
400 |
+
else if(c=="\b") {
|
401 |
+
# backspace move insertion point back 1
|
402 |
+
if(spc) attr[x,y]=atos(span)
|
403 |
+
x=x>1?x-1:1
|
404 |
+
continue
|
405 |
+
}
|
406 |
+
else if(c=="\"") {
|
407 |
+
split(substr(string,i+2),cord,";")
|
408 |
+
cc=substr(string,i+1,1);
|
409 |
+
if(cc=="T") {
|
410 |
+
# Transliterate on/off
|
411 |
+
if(cord[1]==1&&state==3) last_mode=state=4
|
412 |
+
if(cord[1]==0&&state==4) last_mode=state=3
|
413 |
+
}
|
414 |
+
else if(cc=="C") {
|
415 |
+
# Clear
|
416 |
+
if(cord[1]+0) {
|
417 |
+
# Screen - if Recording dump screen
|
418 |
+
if(dumpStatus==dsActive) ret=ret dump_screen()
|
419 |
+
dumpStatus=dsActive
|
420 |
+
delete dump
|
421 |
+
delete attr
|
422 |
+
x=y=1
|
423 |
+
} else {
|
424 |
+
# To end of line
|
425 |
+
for(pos=x;pos<maxX;pos++) {
|
426 |
+
dump[pos,y]=" "
|
427 |
+
if (!spc) delete attr[pos,y]
|
428 |
+
else attr[pos,y]=atos(span)
|
429 |
+
}
|
430 |
+
}
|
431 |
+
}
|
432 |
+
else if(cc=="J") {
|
433 |
+
# Jump to x,y
|
434 |
+
i+=length(cord[2])+1
|
435 |
+
# If line is higher - dump previous screen
|
436 |
+
if(dumpStatus==dsActive&&cord[1]<y) {
|
437 |
+
ret=ret dump_screen();
|
438 |
+
dumpStatus=dsNew;
|
439 |
+
}
|
440 |
+
x=cord[2]
|
441 |
+
if(length(cord[1]) && y!=cord[1]){
|
442 |
+
y=cord[1]
|
443 |
+
if(y>maxY) maxY=y
|
444 |
+
# Change y - start recording
|
445 |
+
dumpStatus=dumpStatus?dumpStatus:dsReset
|
446 |
+
}
|
447 |
+
}
|
448 |
+
else if(cc=="M") {
|
449 |
+
# Move left/right on current line
|
450 |
+
x+=cord[1]
|
451 |
+
}
|
452 |
+
else if(cc=="X") {
|
453 |
+
# delete on right
|
454 |
+
for(pos=x;pos<=maxX;pos++) {
|
455 |
+
nx=pos+cord[1]
|
456 |
+
if(nx<maxX) {
|
457 |
+
if((nx SUBSEP y) in attr) attr[pos,y] = attr[nx,y]
|
458 |
+
else delete attr[pos,y]
|
459 |
+
if((nx SUBSEP y) in dump) dump[pos,y] = dump[nx,y]
|
460 |
+
else delete dump[pos,y]
|
461 |
+
} else if(spc) {
|
462 |
+
attr[pos,y]=atos(span)
|
463 |
+
dump[pos,y]=" "
|
464 |
+
}
|
465 |
+
}
|
466 |
+
}
|
467 |
+
else if(cc=="R") {
|
468 |
+
# Reset attributes
|
469 |
+
while(spc) delete span[spc--]
|
470 |
+
}
|
471 |
+
i+=length(cord[1])+2
|
472 |
+
continue
|
473 |
+
}
|
474 |
+
else if(state==4&&i>=start&&i<=end&&c in Trans) c=Trans[c]
|
475 |
+
}
|
476 |
+
if(dumpStatus==dsReset) {
|
477 |
+
delete dump
|
478 |
+
delete attr
|
479 |
+
ret=ret"\n"
|
480 |
+
dumpStatus=dsActive
|
481 |
+
}
|
482 |
+
if(dumpStatus==dsNew) {
|
483 |
+
# After moving/clearing we are now ready to write
|
484 |
+
# somthing to the screen so start recording now
|
485 |
+
ret=ret"\n"
|
486 |
+
dumpStatus=dsActive
|
487 |
+
}
|
488 |
+
if(dumpStatus==dsActive||dumpStatus==dsOff) {
|
489 |
+
dump[x,y] = c
|
490 |
+
if(!spc) delete attr[x,y]
|
491 |
+
else attr[x,y] = atos(span)
|
492 |
+
if(++x>maxX) maxX=x;
|
493 |
+
}
|
494 |
+
}
|
495 |
+
# End of line if dumping increment y and set x back to first col
|
496 |
+
x=1
|
497 |
+
if(!dumpStatus) return ret dump_line(y,1);
|
498 |
+
else if(++y>maxY) maxY=y;
|
499 |
+
return ret
|
500 |
+
}
|
501 |
+
BEGIN{
|
502 |
+
OFS=FS
|
503 |
+
# dump screen status
|
504 |
+
dsOff=0 # Not dumping screen contents just write output direct
|
505 |
+
dsNew=1 # Just after move/clear waiting for activity to start recording
|
506 |
+
dsReset=2 # Screen cleared build new empty buffer and record
|
507 |
+
dsActive=3 # Currently recording
|
508 |
+
F="abcdefghijklmnopqrstuvwxyz{}`~"
|
509 |
+
T="▒␉␌␍␊°±␋┘┐┌└┼⎺⎻─⎼⎽├┤┴┬│≤≥π£◆·"
|
510 |
+
maxX=80
|
511 |
+
delete cur;
|
512 |
+
x=y=1
|
513 |
+
for(i=1;i<=length(F);i++)Trans[substr(F,i,1)]=substr(T,i,1);
|
514 |
+
}
|
515 |
+
|
516 |
+
{ $0=encode($0) }
|
517 |
+
1
|
518 |
+
END {
|
519 |
+
if(dumpStatus) {
|
520 |
+
print dump_screen();
|
521 |
+
}
|
522 |
+
}'
|
523 |
+
)
|
524 |
+
|
525 |
+
[ "$body_only" ] || printf '</pre>
|
526 |
+
</body>
|
527 |
+
</html>\n'
|
third-party/DPVO/Pangolin/scripts/vcpkg/.vcpkg-root
ADDED
File without changes
|
third-party/DPVO/Pangolin/scripts/vcpkg/CHANGELOG.md
ADDED
The diff for this file is too large to render.
See raw diff
|
|
third-party/DPVO/Pangolin/scripts/vcpkg/CONTRIBUTING.md
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contribution Guidelines
|
2 |
+
|
3 |
+
Vcpkg is a community driven effort to build a productive and robust ecosystem of native libraries - your contributions are invaluable!
|
4 |
+
|
5 |
+
## Issues
|
6 |
+
|
7 |
+
The easiest way to contribute is by reporting issues with either `vcpkg.exe` or an existing package on [GitHub](https://github.com/Microsoft/vcpkg). When reporting an issue with `vcpkg.exe`, make sure to clearly state:
|
8 |
+
- The machine setup: "I'm using Windows 10 Anniversary Update. My machine is using the fr-fr locale. I successfully ran 'install boost'."
|
9 |
+
- The steps to reproduce: "I run 'vcpkg list'"
|
10 |
+
- The outcome you expected: "I expected to see 'boost:x86-windows'"
|
11 |
+
- The actual outcome: "I get no output at all" or "I get a crash dialog"
|
12 |
+
|
13 |
+
When reporting an issue with a package, make sure to clearly state:
|
14 |
+
- The machine setup (as above)
|
15 |
+
- What package and version you're building: "opencv 3.1.0"
|
16 |
+
- Any relevant error logs from the build process.
|
17 |
+
|
18 |
+
## Pull Requests
|
19 |
+
|
20 |
+
We are happy to accept pull requests for fixes, features, new packages, and updates to existing packages. In order to avoid wasting your time, we highly encourage opening an issue to discuss whether the PR you're thinking about making will be acceptable. This is doubly true for features and new packages.
|
21 |
+
|
22 |
+
### New package Guidelines
|
23 |
+
|
24 |
+
We're glad you're interested in submitting a new package! Here are some guidelines to help you author an excellent portfile:
|
25 |
+
- Avoid functional patches. Patches should be considered a last resort to implement compatibility when there's no other way.
|
26 |
+
- When patches can't be avoided, do not modify the default behavior. The ideal lifecycle of a patch is to get merged upstream and no longer be needed. Try to keep this goal in mind when deciding how to patch something.
|
27 |
+
- Prefer to use the `vcpkg_xyz` functions over raw `execute_command` calls. This makes long term maintenance easier when new features (such as custom compiler flags or generators) are added.
|
28 |
+
|
29 |
+
## Legal
|
30 |
+
|
31 |
+
You will need to complete a Contributor License Agreement (CLA) before your pull request can be accepted. This agreement testifies that you are granting us permission to use the source code you are submitting, and that this work is being submitted under appropriate license that we can use it.
|
32 |
+
|
33 |
+
You can complete the CLA by going through the steps at https://cla.microsoft.com. Once we have received the signed CLA, we'll review the request. You will only need to do this once.
|
third-party/DPVO/Pangolin/scripts/vcpkg/CONTRIBUTING_zh.md
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 贡献准则
|
2 |
+
|
3 |
+
Vcpkg 是一个尝试由社区驱动,旨在构建一个多产的、健壮的本地库生态系统 - 您的贡献价值不可估量!
|
4 |
+
|
5 |
+
## 报告问题
|
6 |
+
|
7 |
+
最简单的方法是通过 `vcpkg.exe` 或 [GitHub](https://github.com/Microsoft/vcpkg) 报告已有的包的问题。 当报告 `vcpkg.exe` 的问题时,确保清楚地说明:
|
8 |
+
- 机器设置: “我用的是Windows 10周年更新。 我的机器正位于fr-fr区域。 我成功地运行了'install boost'。”
|
9 |
+
- 复现步骤: “运行 'vcpkg list'”
|
10 |
+
- 预期结果: “我预期看到 'boost:x86-windows'”
|
11 |
+
- 实际结果: “没有输出” 或 “我得到一个崩溃对话框”
|
12 |
+
|
13 |
+
当报告包的问题时,一定要清楚地说明:
|
14 |
+
- 机器设置 (上述)
|
15 |
+
- 您正在构建什么包以及它的版本,例如: “opencv 3.1.0”
|
16 |
+
- 构建过程中的任何相关错误日志
|
17 |
+
|
18 |
+
## 贡献 (PR)
|
19 |
+
|
20 |
+
我们很乐意接受关于修复、特性、新包和更新现有包的拉取请求。 为了避免浪费您的时间,我们强烈建议您提交一个问题来讨论您想要制作的PR是否能被接受。 对于特性和新包来说也是如此。
|
21 |
+
|
22 |
+
### 新包贡献准则
|
23 |
+
|
24 |
+
我们很高兴您有兴趣来提交一个新的包! 这里有一些指导方针来帮助您编写一个优秀的端口文件:
|
25 |
+
- 避免功能补丁。 当没有其他方法时,补丁应该被视为实现兼容性的最后手段。
|
26 |
+
- 当无法避免补丁时,请不要修改默认行为。 一个补丁的理想生命周期是与上游合并,不再被需要。 在决定如何修补某些内容时,请记住这一目标。
|
27 |
+
- 相比原始的 `execute_command` 调用,尽量改为通过 `vcpkg_xyz` 函数实现。这使得在添加新特性(如自定义编译器标志或生成器)时更容易进行长期维护。
|
28 |
+
|
29 |
+
## 法律声明
|
30 |
+
|
31 |
+
在您的拉取请求被接受之前,您需要完成一个贡献者许可协议 (CLA)。 本协议证明您允许我们使用您提交的源代码,并且本作品是在合适的许可下提交的,我们可以使用它。
|
32 |
+
|
33 |
+
您可以通过 https://cla.microsoft.com 上的步骤来完成CLA。 一旦我们收到已签署的CLA,我们将审查请求。 您只需要这样做一次。
|
third-party/DPVO/Pangolin/scripts/vcpkg/bootstrap-vcpkg.bat
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
@echo off
|
2 |
+
powershell.exe -NoProfile -ExecutionPolicy Bypass "& {& '%~dp0scripts\bootstrap.ps1' %*}"
|
third-party/DPVO/Pangolin/scripts/vcpkg/bootstrap-vcpkg.sh
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/sh -e
|
2 |
+
|
3 |
+
vcpkgRootDir=$(X= cd -- "$(dirname -- "$0")" && pwd -P)
|
4 |
+
. "$vcpkgRootDir/scripts/bootstrap.sh"
|
third-party/DPVO/Pangolin/scripts/vcpkg/docs/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
theme: jekyll-theme-cayman
|
third-party/DPVO/Pangolin/scripts/vcpkg/docs/about/faq.md
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Frequently Asked Questions
|
2 |
+
|
3 |
+
## Can I contribute a new library?
|
4 |
+
Yes! Start out by reading our [contribution guidelines](https://github.com/Microsoft/vcpkg/blob/master/CONTRIBUTING.md).
|
5 |
+
If you want to contribute but don't have a particular library in mind then take a look at the list
|
6 |
+
of [new port requests](https://github.com/Microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+label%3Acategory%3Anew-port).
|
7 |
+
|
8 |
+
## Can Vcpkg create pre-built binary packages? What is the binary format used by Vcpkg?
|
9 |
+
Yes! See [the `export` command](../users/integration.md#export-command).
|
10 |
+
|
11 |
+
## How do I update libraries?
|
12 |
+
The `vcpkg update` command lists all packages which are out-of-sync with your current portfiles. To update a package, follow the instructions in the command.
|
13 |
+
|
14 |
+
## How do I get more libraries?
|
15 |
+
The list of libraries is enumerated from the [`ports\`](https://github.com/Microsoft/vcpkg/blob/master/ports) directory. By design, you can add and remove libraries from this directory as you see fit for yourself or your company -- see our examples on packaging [zipfiles](../examples/packaging-zipfiles.md) and [GitHub repos](../examples/packaging-github-repos.md).
|
16 |
+
|
17 |
+
We recommend cloning directly from [GitHub](https://github.com/microsoft/vcpkg) and using `git pull` to update the list of portfiles. Once you've updated your portfiles, `vcpkg update` will indicate any installed libraries that are now out of date.
|
18 |
+
|
19 |
+
## Can I build a private library with this tool?
|
20 |
+
Yes. Follow [our packaging zlib Example](../examples/packaging-zipfiles.md) for creating a portfile using a fake URL. Then, either pre-seed the `downloads\` folder with a zip containing your private sources or replace the normal calls to `vcpkg_download_distfile` and `vcpkg_extract_source_archive` with functions that unpack your source code.
|
21 |
+
|
22 |
+
## Can I use a prebuilt private library with this tool?
|
23 |
+
Yes. The `portfile.cmake` for a library is fundamentally a script that places the headers and binaries into the correct arrangement in the `${CURRENT_PACKAGES_DIR}`, so to pull in prebuilt binaries you can write a portfile which directly downloads and arranges the files.
|
24 |
+
|
25 |
+
To see an example of this, look at [`ports\opengl\portfile.cmake`](https://github.com/microsoft/vcpkg/blob/master/ports/opengl/portfile.cmake) which simply copies files out of the Windows SDK.
|
26 |
+
|
27 |
+
## Which platforms I can target with Vcpkg?
|
28 |
+
We currently target Windows Desktop (x86 and x64) as well as the Universal Windows Platform (x86, x64, and ARM). See `vcpkg help triplet` for the current list.
|
29 |
+
|
30 |
+
## Does Vcpkg run on Linux/OSX?
|
31 |
+
Yes! We continuously test on OSX and Ubuntu 16.04, however we know users have been successful with Arch, Fedora, and FreeBSD. If you have trouble with your favorite Linux distribution, let us know in an issue and we'd be happy to help!
|
32 |
+
|
33 |
+
## How do I update vcpkg?
|
34 |
+
Execute `git pull` to get the latest sources, then run `bootstrap-vcpkg.bat` (Windows) or `./bootstrap-vcpkg.sh` (Unix) to update vcpkg.
|
35 |
+
|
36 |
+
## How do I use different versions of a library on one machine?
|
37 |
+
Within a single instance of Vcpkg (e.g. one set of `installed\`, `packages\`, `ports\` and so forth), you can only have one version of a library installed (otherwise, the headers would conflict with each other!). For those with experience with system-wide package managers, packages in Vcpkg correspond to the `X-dev` or `X-devel` packages.
|
38 |
+
|
39 |
+
To use different versions of a library for different projects, we recommend making separate instances of Vcpkg and using the [per-project integration mechanisms](../users/integration.md). The versions of each library are specified by the files in `ports\`, so they are easily manipulated using standard `git` commands. This makes it very easy to roll back the entire set of libraries to a consistent set of older versions which all work with each other. If you need to then pin a specific library forward, that is as easy as checking out the appropriate version of `ports\<package>\`.
|
40 |
+
|
41 |
+
If your application is very sensitive to the versions of libraries, we recommend checking in the specific set of portfiles you need into your source control along with your project sources and using the `--vcpkg-root` option to redirect the working directory of `vcpkg.exe`.
|
42 |
+
|
43 |
+
## How does Vcpkg protect my privacy?
|
44 |
+
See the [Privacy document](privacy.md) for all information regarding privacy.
|
45 |
+
|
46 |
+
## Can I use my own CMake toolchain file with Vcpkg's toolchain file?
|
47 |
+
Yes. If you already have a CMake toolchain file, you will need to include our toolchain file at the end of yours. This should be as simple as an `include(<vcpkg_root>\scripts\buildsystems\vcpkg.cmake)` directive. Alternatively, you could copy the contents of our `scripts\buildsystems\vcpkg.cmake` into the end of your existing toolchain file.
|
48 |
+
|
49 |
+
## Can I use my own/specific flags for rebuilding libs?
|
50 |
+
Yes. In the current version, there is not yet a standardized global way to change them, however you can edit individual portfiles and tweak the exact build process however you'd like.
|
51 |
+
|
52 |
+
By saving the changes to the portfile (and checking them in), you'll get the same results even if you're rebuilding from scratch in the future and forgot what exact settings you used.
|
53 |
+
|
54 |
+
## Can I get Vcpkg integration for custom configurations?
|
55 |
+
|
56 |
+
Yes. While Vcpkg will only produce the standard "Release" and "Debug" configurations when building a library, you can get integration support for your projects' custom configurations, in addition to your project's standard configurations.
|
57 |
+
|
58 |
+
First of all, Vcpkg will automatically assume any custom configuration starting with "Release" (resp. "Debug") as a configuration that is compatible with the standard "Release" (resp. "Debug") configuration and will act accordingly.
|
59 |
+
|
60 |
+
For other configurations, you only need to override the MSBuild `$(VcpkgConfiguration)` macro in your project file (.vcxproj) to declare the compatibility between your configuration, and the target standard configuration. Unfortunately, due to the sequential nature of MSBuild, you'll need to add those settings much higher in your vcxproj so that it is declared before the Vcpk integration is loaded. It is recommend that the `$(VcpkgConfiguration)` macro is added to the "Globals" PropertyGroup.
|
61 |
+
|
62 |
+
For example, you can add support for your "MyRelease" configuration by adding in your project file:
|
63 |
+
```
|
64 |
+
<PropertyGroup Label="Globals">
|
65 |
+
...
|
66 |
+
<VcpkgConfiguration Condition="'$(Configuration)' == 'MyRelease'">Release</VcpkgConfiguration>
|
67 |
+
</PropertyGroup>
|
68 |
+
```
|
69 |
+
Of course, this will only produce viable binaries if your custom configuration is compatible with the target configuration (e.g. they should both link with the same runtime library).
|
70 |
+
|
71 |
+
## I can't use user-wide integration. Can I use a per-project integration?
|
72 |
+
|
73 |
+
Yes. A NuGet package suitable for per-project use can be generated via either the `vcpkg integrate project` command (lightweight linking) or the `vcpkg export --nuget` command (shrinkwrapped).
|
74 |
+
|
75 |
+
A lower level mechanism to achieve the same as the `vcpkg integrate project` NuGet package is via the `<vcpkg_root>\scripts\buildsystems\msbuild\vcpkg.targets` file. All you need is to import it in your .vcxproj file, replacing `<vcpkg_root>` with the path where you installed vcpkg:
|
76 |
+
|
77 |
+
```
|
78 |
+
<Import Project="<vcpkg_root>\scripts\buildsystems\msbuild\vcpkg.targets" />
|
79 |
+
```
|
80 |
+
|
81 |
+
## How can I remove temporary files?
|
82 |
+
|
83 |
+
You can save some disk space by completely removing the `packages\`, `buildtrees\`, and `downloads\` folders.
|
84 |
+
|
85 |
+
## How is CMake used internally by Vcpkg?
|
86 |
+
Vcpkg uses CMake internally as a build scripting language. This is because CMake is already an extremely common build system for cross-platform open source libraries and is becoming very popular for C++ projects in general. It is easy to acquire on Windows, does not require system-wide installation, and legible for unfamiliar users.
|
87 |
+
|
88 |
+
## Will Vcpkg support downloading compiled binaries from a public or private server?
|
89 |
+
We would like to eventually support downloading precompiled binaries, similar to other system package managers.
|
90 |
+
|
91 |
+
In a corporate scenario, we currently recommend building the libraries once and distributing the entire vcpkg root directory to everyone else on the project through some raw file transport such as a network share or HTTP host. See the [`export`](../users/integration.md#export) command.
|
92 |
+
|
93 |
+
## What Visual C++ toolsets are supported?
|
94 |
+
We support Visual Studio 2015 Update 3 and above.
|
95 |
+
|
96 |
+
## Why does Visual Studio not use my libraries with user-wide integration enabled?
|
97 |
+
Enabling user-wide integration (`vcpkg integrate install`) changes the default for some project properties. In particular, "C/C++/General/Additional Include Directories" and "Linker/General/Additional Library Directories" are normally blank *without* user-wide integration. *With* integration, a blank value means that the augmented default supplied by vcpkg is overridden, and headers/libraries will not be found. To reinstate the default, set the properties to inherit from parent.
|
98 |
+
|
99 |
+
## Why not NuGet?
|
100 |
+
NuGet is a package manager for .NET libraries with a strong dependency on MSBuild. It does not meet the specific needs of Native C++ customers in at least three ways.
|
101 |
+
|
102 |
+
- **Compilation Flavors**. With so many possible combinations of compilation options, the task of providing a truly complete set of options is intrinsically impossible. Furthermore, the download size for reasonably complete binary packages becomes enormous. This makes it a requirement to split the results into multiple packages, but then searching becomes very difficult.
|
103 |
+
|
104 |
+
- **Binary vs Source**. Very closely tied to the first point, NuGet is designed from the ground up to provide relatively small, prebuilt binaries. Due to the nature of native code, developers need to have access to the source code to ensure ABI compatibility, performance, integrity, and debuggability.
|
105 |
+
|
106 |
+
- **Per-dll vs Per-application**. NuGet is highly project centric. This works well in managed languages with naturally stable ABIs, because base libraries can continue to evolve without breaking those higher up. However, in native languages where the ABI is much more fragile, the only robust strategy is to explicitly build each library against the exact dependencies that will be included in the final application. This is difficult to ensure in NuGet and leads to a highly disconnected and independently versioned ecosystem.
|
107 |
+
|
108 |
+
## Why not Conan?
|
109 |
+
Conan.io is a publicly-federated, project-centric, cross-platform, C++ package manager written in python. Our primary differences are:
|
110 |
+
|
111 |
+
- **Public federation vs private federation**. Conan relies on individuals publishing independent copies of each package. We believe this approach encourages a large number of packages that are all broken in different ways. We believe it is a waste of user's time to pick through the list of 20+ public packages for Boost 1.56 to determine the handful that will work for their particular situation. In contrast, we believe there should be a single, collaboratively maintained version which works for the vast majority of cases and allow users to hack freely on their private versions. We believe this will result in a set of high quality packages that are heavily tested with each other and form a fantastic base for any private modifications you need.
|
112 |
+
|
113 |
+
- **Per-dll vs Per-application**. When dependencies are independently versioned on a library level, it encourages every build environment to be a completely unique, unable to take advantage of or contribute to a solid, well tested ecosystem. In contrast, by versioning all libraries together as a platform (similar to a system package manager), we hope to congregate testing and effort on very common sets of library versions to maximize the quality and stability of the ecosystem. This also completely designs out the ability for a library to ask for versions that conflict with the application's choices (I want openssl Z and boost X but X only claims to work with openssl Y).
|
114 |
+
|
115 |
+
- **Cross-platform vs single-platform**. While being hosted on many platforms is an excellent north star, we believe the level of system integration and stability provided by apt-get, yum, and homebrew is well worth needing to exchange `apt-get install libboost-all-dev` with `brew install boost` in automated scripts. We chose to make our system as easy as possible to integrate into a world with these very successful system managers -- one more line for `vcpkg install boost` -- instead of attempting to replace them where they are already so successful and well-loved.
|
116 |
+
|
117 |
+
- **C++/CMake vs python**. While Python is an excellent language loved by many, we believe that transparency and familiarity are the most important factors when choosing a tool as important to your workflow as a package manager. Consequently, we chose to make the implementation languages be as universally accepted as possible: C++ should be used in a C++ package manager for C++ programmers. You should not be required to learn another programming language just to understand your package manager.
|
118 |
+
|
119 |
+
## Why not Chocolatey?
|
120 |
+
Chocolatey is an excellent system for managing applications. However, it is not currently designed to acquire redistributable developer assets and help you with debugging. Vcpkg, in comparison, is designed to get you the libraries you need to build your application and help you deliver through any platform you'd like (including Chocolatey!).
|
third-party/DPVO/Pangolin/scripts/vcpkg/docs/about/privacy.md
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Vcpkg Telemetry and Privacy
|
2 |
+
|
3 |
+
vcpkg collects telemetry data to understand usage issues, such as failing packages, and to guide tool improvements. The collected data is anonymous.
|
4 |
+
For more information about how Microsoft protects your privacy, see https://privacy.microsoft.com/en-US/privacystatement#mainenterprisedeveloperproductsmodule
|
5 |
+
|
6 |
+
## Scope
|
7 |
+
|
8 |
+
We explicitly ONLY collect information from invocations of the tool itself; we do NOT add any tracking information into the produced libraries. Telemetry is collected when using any of the `vcpkg` commands.
|
9 |
+
|
10 |
+
## How to opt out
|
11 |
+
|
12 |
+
The vcpkg telemetry feature is enabled by default. In order to opt-out of data collection, you can re-run the bootstrap script with the following flag, for Windows and Linux/OSX, respectively:
|
13 |
+
|
14 |
+
```PS> .\bootstrap-vcpkg.bat -disableMetrics```
|
15 |
+
|
16 |
+
```~/$ ./bootstrap-vcpkg.sh -disableMetrics```
|
17 |
+
|
18 |
+
## Disclosure
|
19 |
+
|
20 |
+
vcpkg displays text similar to the following when you build vcpkg. This is how Microsoft notifies you about data collection.
|
21 |
+
|
22 |
+
```
|
23 |
+
Telemetry
|
24 |
+
---------
|
25 |
+
vcpkg collects usage data in order to help us improve your experience.
|
26 |
+
The data collected by Microsoft is anonymous.
|
27 |
+
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
|
28 |
+
passing --disable-metrics to vcpkg on the command line,
|
29 |
+
or by setting the VCPKG_DISABLE_METRICS environment variable.
|
30 |
+
|
31 |
+
Read more about vcpkg telemetry at docs/about/privacy.md
|
32 |
+
```
|
33 |
+
|
34 |
+
## Data Collected
|
35 |
+
|
36 |
+
The telemetry feature doesn't collect personal data, such as usernames or email addresses. It doesn't scan your code and doesn't extract project-level data, such as name, repository, or author. The data is sent securely to Microsoft servers and held under restricted access.
|
37 |
+
|
38 |
+
Protecting your privacy is important to us. If you suspect the telemetry is collecting sensitive data or the data is being insecurely or inappropriately handled, file an issue in the Microsoft/vcpkg repository or send an email to [email protected] for investigation.
|
39 |
+
|
40 |
+
We collect various telemetry events such as the command line used, the time of invocation, and how long execution took. Some commands also add additional calculated information (such as the full set of libraries to install). We generate a completely random UUID on first use and attach it to each event.
|
41 |
+
|
42 |
+
You can see the telemetry events any command by appending `--printmetrics` after the vcpkg command line.
|
43 |
+
|
44 |
+
In the source code (included at https://github.com/microsoft/vcpkg-tool/ ), you can search for calls to the functions `track_property()`, `track_feature()`, `track_metric()`, and `track_buildtime()`
|
45 |
+
to see every specific data point we collect.
|
46 |
+
|
47 |
+
## Avoid inadvertent disclosure information
|
48 |
+
|
49 |
+
vcpkg contributors and anyone else running a version of vcpkg that they built themselves should consider the path to their source code. If a crash occurs when using vcpkg, the file path from the build machine is collected as part of the stack trace and isn't hashed.
|
50 |
+
Because of this, builds of vcpkg shouldn't be located in directories whose path names expose personal or sensitive information.
|
third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/installing-and-using-packages.md
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Installing and Using Packages Example: SQLite
|
2 |
+
|
3 |
+
- [Step 1: Install](#install)
|
4 |
+
- [Step 2: Use](#use)
|
5 |
+
- [VS/MSBuild Project (User-wide integration)](#msbuild)
|
6 |
+
- [CMake (Toolchain file)](#cmake)
|
7 |
+
- [Other integration options](../users/integration.md)
|
8 |
+
|
9 |
+
---
|
10 |
+
<a name="install"></a>
|
11 |
+
## Step 1: Install
|
12 |
+
|
13 |
+
First, we need to know what name [SQLite](https://sqlite.org) goes by in the ports tree. To do that, we'll run the `search` command and inspect the output:
|
14 |
+
```no-highlight
|
15 |
+
PS D:\src\vcpkg> .\vcpkg search sqlite
|
16 |
+
libodb-sqlite 2.4.0 Sqlite support for the ODB ORM library
|
17 |
+
sqlite3 3.32.1 SQLite is a software library that implements a se...
|
18 |
+
|
19 |
+
If your library is not listed, please open an issue at:
|
20 |
+
https://github.com/Microsoft/vcpkg/issues
|
21 |
+
```
|
22 |
+
Looking at the list, we can see that the port is named "sqlite3". You can also run the `search` command without arguments to see the full list of packages.
|
23 |
+
|
24 |
+
Installing is then as simple as using the `install` command.
|
25 |
+
```no-highlight
|
26 |
+
PS D:\src\vcpkg> .\vcpkg install sqlite3
|
27 |
+
Computing installation plan...
|
28 |
+
The following packages will be built and installed:
|
29 |
+
sqlite3[core]:x86-windows
|
30 |
+
Starting package 1/1: sqlite3:x86-windows
|
31 |
+
Building package sqlite3[core]:x86-windows...
|
32 |
+
-- Downloading https://sqlite.org/2020/sqlite-amalgamation-3320100.zip...
|
33 |
+
-- Extracting source C:/src/vcpkg/downloads/sqlite-amalgamation-3320100.zip
|
34 |
+
-- Applying patch fix-arm-uwp.patch
|
35 |
+
-- Using source at C:/src/vcpkg/buildtrees/sqlite3/src/3320100-15aeda126a.clean
|
36 |
+
-- Configuring x86-windows
|
37 |
+
-- Building x86-windows-dbg
|
38 |
+
-- Building x86-windows-rel
|
39 |
+
-- Performing post-build validation
|
40 |
+
-- Performing post-build validation done
|
41 |
+
Building package sqlite3[core]:x86-windows... done
|
42 |
+
Installing package sqlite3[core]:x86-windows...
|
43 |
+
Installing package sqlite3[core]:x86-windows... done
|
44 |
+
Elapsed time for package sqlite3:x86-windows: 12 s
|
45 |
+
|
46 |
+
Total elapsed time: 12.04 s
|
47 |
+
|
48 |
+
The package sqlite3:x86-windows provides CMake targets:
|
49 |
+
|
50 |
+
find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
51 |
+
target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3))
|
52 |
+
|
53 |
+
```
|
54 |
+
|
55 |
+
We can check that sqlite3 was successfully installed for x86 Windows desktop by running the `list` command.
|
56 |
+
```no-highlight
|
57 |
+
PS D:\src\vcpkg> .\vcpkg list
|
58 |
+
sqlite3:x86-windows 3.32.1 SQLite is a software library that implements a se...
|
59 |
+
```
|
60 |
+
|
61 |
+
To install for other architectures and platforms such as Universal Windows Platform or x64 Desktop, you can suffix the package name with `:<target>`.
|
62 |
+
```no-highlight
|
63 |
+
PS D:\src\vcpkg> .\vcpkg install sqlite3:x86-uwp zlib:x64-windows
|
64 |
+
```
|
65 |
+
|
66 |
+
See `.\vcpkg help triplet` for all supported targets.
|
67 |
+
|
68 |
+
---
|
69 |
+
<a name="use"></a>
|
70 |
+
## Step 2: Use
|
71 |
+
<a name="msbuild"></a>
|
72 |
+
#### VS/MSBuild Project (User-wide integration)
|
73 |
+
|
74 |
+
The recommended and most productive way to use vcpkg is via user-wide integration, making the system available for all projects you build. The user-wide integration will prompt for administrator access the first time it is used on a given machine, but afterwards is no longer required and the integration is configured on a per-user basis.
|
75 |
+
```no-highlight
|
76 |
+
PS D:\src\vcpkg> .\vcpkg integrate install
|
77 |
+
Applied user-wide integration for this vcpkg root.
|
78 |
+
|
79 |
+
All C++ projects can now #include any installed libraries.
|
80 |
+
Linking will be handled automatically.
|
81 |
+
Installing new libraries will make them instantly available.
|
82 |
+
```
|
83 |
+
*Note: You will need to restart Visual Studio or perform a Build to update intellisense with the changes.*
|
84 |
+
|
85 |
+
You can now simply use File -> New Project in Visual Studio and the library will be automatically available. For SQLite, you can try out their [C/C++ sample](https://sqlite.org/quickstart.html).
|
86 |
+
|
87 |
+
To remove the integration for your user, you can use `.\vcpkg integrate remove`.
|
88 |
+
|
89 |
+
<a name="cmake"></a>
|
90 |
+
#### CMake (Toolchain File)
|
91 |
+
|
92 |
+
The best way to use installed libraries with cmake is via the toolchain file `scripts\buildsystems\vcpkg.cmake`. To use this file, you simply need to add it onto your CMake command line as:
|
93 |
+
`-DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.cmake`.
|
94 |
+
|
95 |
+
If you are using CMake through Open Folder with Visual Studio you can define `CMAKE_TOOLCHAIN_FILE` by adding a "variables" section to each of your `CMakeSettings.json` configurations:
|
96 |
+
|
97 |
+
```json
|
98 |
+
{
|
99 |
+
"configurations": [{
|
100 |
+
"name": "x86-Debug",
|
101 |
+
"generator": "Visual Studio 15 2017",
|
102 |
+
"configurationType" : "Debug",
|
103 |
+
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
|
104 |
+
"cmakeCommandArgs": "",
|
105 |
+
"buildCommandArgs": "-m -v:minimal",
|
106 |
+
"variables": [{
|
107 |
+
"name": "CMAKE_TOOLCHAIN_FILE",
|
108 |
+
"value": "D:\\src\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
|
109 |
+
}]
|
110 |
+
}]
|
111 |
+
}
|
112 |
+
```
|
113 |
+
*Note: It might be necessary to delete the CMake cache folder of each modified configuration, to force a full regeneration. In the `CMake` menu, under `Cache (<configuration name>)` you'll find `Delete Cache Folders`.*
|
114 |
+
|
115 |
+
Now let's make a simple CMake project with a main file.
|
116 |
+
```cmake
|
117 |
+
# CMakeLists.txt
|
118 |
+
cmake_minimum_required(VERSION 3.0)
|
119 |
+
project(test)
|
120 |
+
|
121 |
+
find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
122 |
+
|
123 |
+
add_executable(main main.cpp)
|
124 |
+
|
125 |
+
target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3)
|
126 |
+
```
|
127 |
+
```cpp
|
128 |
+
// main.cpp
|
129 |
+
#include <sqlite3.h>
|
130 |
+
#include <stdio.h>
|
131 |
+
|
132 |
+
int main()
|
133 |
+
{
|
134 |
+
printf("%s\n", sqlite3_libversion());
|
135 |
+
return 0;
|
136 |
+
}
|
137 |
+
```
|
138 |
+
|
139 |
+
Then, we build our project in the normal CMake way:
|
140 |
+
```no-highlight
|
141 |
+
PS D:\src\cmake-test> mkdir build
|
142 |
+
PS D:\src\cmake-test> cd build
|
143 |
+
PS D:\src\cmake-test\build> cmake .. "-DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.cmake"
|
144 |
+
// omitted CMake output here //
|
145 |
+
-- Build files have been written to: D:/src/cmake-test/build
|
146 |
+
PS D:\src\cmake-test\build> cmake --build .
|
147 |
+
// omitted MSBuild output here //
|
148 |
+
Build succeeded.
|
149 |
+
0 Warning(s)
|
150 |
+
0 Error(s)
|
151 |
+
|
152 |
+
Time Elapsed 00:00:02.38
|
153 |
+
PS D:\src\cmake-test\build> .\Debug\main.exe
|
154 |
+
3.15.0
|
155 |
+
```
|
156 |
+
|
157 |
+
*Note: The correct sqlite3.dll is automatically copied to the output folder when building for x86-windows. You will need to distribute this along with your application.*
|
158 |
+
|
159 |
+
##### Handling libraries without native cmake support
|
160 |
+
|
161 |
+
Unlike other platforms, we do not automatically add the `include\` directory to your compilation line by default. If you're using a library that does not provide CMake integration, you will need to explicitly search for the files and add them yourself using [`find_path()`][1] and [`find_library()`][2].
|
162 |
+
|
163 |
+
```cmake
|
164 |
+
# To find and use catch
|
165 |
+
find_path(CATCH_INCLUDE_DIR catch.hpp)
|
166 |
+
include_directories(${CATCH_INCLUDE_DIR})
|
167 |
+
|
168 |
+
# To find and use azure-storage-cpp
|
169 |
+
find_path(WASTORAGE_INCLUDE_DIR was/blob.h)
|
170 |
+
find_library(WASTORAGE_LIBRARY wastorage)
|
171 |
+
include_directories(${WASTORAGE_INCLUDE_DIR})
|
172 |
+
link_libraries(${WASTORAGE_LIBRARY})
|
173 |
+
|
174 |
+
# Note that we recommend using the target-specific directives for a cleaner cmake:
|
175 |
+
# target_include_directories(main ${LIBRARY})
|
176 |
+
# target_link_libraries(main PRIVATE ${LIBRARY})
|
177 |
+
```
|
178 |
+
|
179 |
+
[1]: https://cmake.org/cmake/help/latest/command/find_path.html
|
180 |
+
[2]: https://cmake.org/cmake/help/latest/command/find_library.html
|
third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/manifest-mode-cmake.md
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Manifest Mode: CMake Example
|
2 |
+
|
3 |
+
We would like to add [vcpkg manifest support](../users/manifests.md) to an existing cmake project!
|
4 |
+
Let's create a simple project that prints the fibonacci sequence up to a certain number,
|
5 |
+
using some common dependencies.
|
6 |
+
|
7 |
+
## Initial Layout
|
8 |
+
|
9 |
+
Let's create the following file layout:
|
10 |
+
|
11 |
+
```no-highlight
|
12 |
+
fibo/
|
13 |
+
src/
|
14 |
+
main.cxx
|
15 |
+
CMakeLists.txt
|
16 |
+
```
|
17 |
+
|
18 |
+
And we wish to use [fmt](https://github.com/fmtlib/fmt), [range-v3](https://github.com/ericniebler/range-v3),
|
19 |
+
and [cxxopts](https://github.com/jarro2783/cxxopts).
|
20 |
+
|
21 |
+
Let's write our `CMakeLists.txt` first:
|
22 |
+
|
23 |
+
```cmake
|
24 |
+
cmake_minimum_required(VERSION 3.15)
|
25 |
+
|
26 |
+
project(fibo CXX)
|
27 |
+
|
28 |
+
find_package(fmt REQUIRED)
|
29 |
+
find_package(range-v3 REQUIRED)
|
30 |
+
find_package(cxxopts REQUIRED)
|
31 |
+
|
32 |
+
add_executable(fibo src/main.cxx)
|
33 |
+
target_compile_features(fibo PRIVATE cxx_std_17)
|
34 |
+
|
35 |
+
target_link_libraries(fibo
|
36 |
+
PRIVATE
|
37 |
+
fmt::fmt
|
38 |
+
range-v3::range-v3
|
39 |
+
cxxopts::cxxopts)
|
40 |
+
```
|
41 |
+
|
42 |
+
And then we should add `main.cxx`:
|
43 |
+
|
44 |
+
```cxx
|
45 |
+
#include <cxxopts.hpp>
|
46 |
+
#include <fmt/format.h>
|
47 |
+
#include <range/v3/view.hpp>
|
48 |
+
|
49 |
+
namespace view = ranges::views;
|
50 |
+
|
51 |
+
int fib(int x) {
|
52 |
+
int a = 0, b = 1;
|
53 |
+
|
54 |
+
for (int it : view::repeat(0) | view::take(x)) {
|
55 |
+
(void)it;
|
56 |
+
int tmp = a;
|
57 |
+
a += b;
|
58 |
+
b = tmp;
|
59 |
+
}
|
60 |
+
|
61 |
+
return a;
|
62 |
+
}
|
63 |
+
|
64 |
+
int main(int argc, char** argv) {
|
65 |
+
cxxopts::Options options("fibo", "Print the fibonacci sequence up to a value 'n'");
|
66 |
+
options.add_options()
|
67 |
+
("n,value", "The value to print to", cxxopts::value<int>()->default_value("10"));
|
68 |
+
|
69 |
+
auto result = options.parse(argc, argv);
|
70 |
+
auto n = result["value"].as<int>();
|
71 |
+
|
72 |
+
for (int x : view::iota(1) | view::take(n)) {
|
73 |
+
fmt::print("fib({}) = {}\n", x, fib(x));
|
74 |
+
}
|
75 |
+
}
|
76 |
+
```
|
77 |
+
|
78 |
+
This is a simple project of course, but it should give us a clean project to start with.
|
79 |
+
Let's try it out!
|
80 |
+
|
81 |
+
Let's assume you have `fmt`, `range-v3`, and `cxxopts` installed with vcpkg classic mode;
|
82 |
+
then, you can just do a simple:
|
83 |
+
|
84 |
+
```cmd
|
85 |
+
D:\src\fibo> cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.cmake
|
86 |
+
-- Building for: Visual Studio 16 2019
|
87 |
+
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
|
88 |
+
-- The CXX compiler identification is MSVC 19.27.29111.0
|
89 |
+
-- Detecting CXX compiler ABI info
|
90 |
+
-- Detecting CXX compiler ABI info - done
|
91 |
+
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
|
92 |
+
-- Detecting CXX compile features
|
93 |
+
-- Detecting CXX compile features - done
|
94 |
+
-- Configuring done
|
95 |
+
-- Generating done
|
96 |
+
-- Build files have been written to: D:/src/fibo/build
|
97 |
+
D:\src\fibo> cmake --build build
|
98 |
+
Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework
|
99 |
+
Copyright (C) Microsoft Corporation. All rights reserved.
|
100 |
+
|
101 |
+
Checking Build System
|
102 |
+
Building Custom Rule D:/src/fibo/CMakeLists.txt
|
103 |
+
main.cxx
|
104 |
+
The contents of <span> are available only with C++20 or later.
|
105 |
+
fibo.vcxproj -> D:\src\fibo\build\Debug\fibo.exe
|
106 |
+
Building Custom Rule D:/src/fibo/CMakeLists.txt
|
107 |
+
```
|
108 |
+
|
109 |
+
And now we can try out the `fibo` binary!
|
110 |
+
|
111 |
+
```cmd
|
112 |
+
D:\src\fibo> .\build\Debug\fibo.exe -n 7
|
113 |
+
fib(1) = 1
|
114 |
+
fib(2) = 1
|
115 |
+
fib(3) = 2
|
116 |
+
fib(4) = 3
|
117 |
+
fib(5) = 5
|
118 |
+
fib(6) = 8
|
119 |
+
fib(7) = 13
|
120 |
+
```
|
121 |
+
|
122 |
+
it works!
|
123 |
+
|
124 |
+
## Converting to Manifest Mode
|
125 |
+
|
126 |
+
We now wish to use manifest mode, so all of our dependencies are managed for us! Let's write a `vcpkg.json`:
|
127 |
+
|
128 |
+
```json
|
129 |
+
{
|
130 |
+
"name": "fibo",
|
131 |
+
"version-string": "0.1.0",
|
132 |
+
"dependencies": [
|
133 |
+
"cxxopts",
|
134 |
+
"fmt",
|
135 |
+
"range-v3"
|
136 |
+
]
|
137 |
+
}
|
138 |
+
```
|
139 |
+
|
140 |
+
Let's delete the build directory and rerun the build:
|
141 |
+
|
142 |
+
```cmd
|
143 |
+
D:\src\fibo> rmdir /S /Q build
|
144 |
+
D:\src\fibo> cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.cmake
|
145 |
+
-- Running vcpkg install
|
146 |
+
Detecting compiler hash for triplet x64-windows...
|
147 |
+
The following packages will be built and installed:
|
148 |
+
cxxopts[core]:x64-windows
|
149 |
+
fmt[core]:x64-windows
|
150 |
+
range-v3[core]:x64-windows
|
151 |
+
Starting package 1/3: cxxopts:x64-windows
|
152 |
+
Building package cxxopts[core]:x64-windows...
|
153 |
+
Using cached binary package: C:\Users\me\AppData\Local\vcpkg/archives\d2\d2d1e5302cdfefef2fd090d8eda84cc0c1fbe6f1.zip
|
154 |
+
Building package cxxopts[core]:x64-windows... done
|
155 |
+
Installing package cxxopts[core]:x64-windows...
|
156 |
+
Installing package cxxopts[core]:x64-windows... done
|
157 |
+
Elapsed time for package cxxopts:x64-windows: 50.64 ms
|
158 |
+
Starting package 2/3: fmt:x64-windows
|
159 |
+
Building package fmt[core]:x64-windows...
|
160 |
+
Using cached binary package: C:\Users\me\AppData\Local\vcpkg/archives\bf\bf00d5214e912d71414b545b241f54ef87fdf6e5.zip
|
161 |
+
Building package fmt[core]:x64-windows... done
|
162 |
+
Installing package fmt[core]:x64-windows...
|
163 |
+
Installing package fmt[core]:x64-windows... done
|
164 |
+
Elapsed time for package fmt:x64-windows: 225 ms
|
165 |
+
Starting package 3/3: range-v3:x64-windows
|
166 |
+
Building package range-v3[core]:x64-windows...
|
167 |
+
Using cached binary package: C:\Users\me\AppData\Local\vcpkg/archives\fe\fe2cdedef6953bf954e8ddca471bf3cc8d9b06d7.zip
|
168 |
+
Building package range-v3[core]:x64-windows... done
|
169 |
+
Installing package range-v3[core]:x64-windows...
|
170 |
+
Installing package range-v3[core]:x64-windows... done
|
171 |
+
Elapsed time for package range-v3:x64-windows: 1.466 s
|
172 |
+
|
173 |
+
Total elapsed time: 1.742 s
|
174 |
+
|
175 |
+
-- Running vcpkg install - done
|
176 |
+
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
|
177 |
+
-- The CXX compiler identification is MSVC 19.27.29111.0
|
178 |
+
-- Detecting CXX compiler ABI info
|
179 |
+
-- Detecting CXX compiler ABI info - done
|
180 |
+
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
|
181 |
+
-- Detecting CXX compile features
|
182 |
+
-- Detecting CXX compile features - done
|
183 |
+
-- Configuring done
|
184 |
+
-- Generating done
|
185 |
+
-- Build files have been written to: D:/src/fibo/build
|
186 |
+
D:\src\fibo> cmake --build build
|
187 |
+
Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework
|
188 |
+
Copyright (C) Microsoft Corporation. All rights reserved.
|
189 |
+
|
190 |
+
Checking Build System
|
191 |
+
Building Custom Rule D:/src/fibo/CMakeLists.txt
|
192 |
+
main.cxx
|
193 |
+
The contents of <span> are available only with C++20 or later.
|
194 |
+
fibo.vcxproj -> D:\src\fibo\build\Debug\fibo.exe
|
195 |
+
Building Custom Rule D:/src/fibo/CMakeLists.txt
|
196 |
+
```
|
197 |
+
|
198 |
+
You can see that with just a _single file_, we've changed over to manifests without _any_ trouble.
|
199 |
+
The build system doesn't change _at all_! We just add a `vcpkg.json` file, delete the build directory,
|
200 |
+
and reconfigure. And we're done!
|
third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/modify-baseline-to-pin-old-boost.md
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Pin old Boost versions
|
2 |
+
This document will teach you how to set versions of meta-packages like `boost` or `qt5`.
|
3 |
+
|
4 |
+
**What is a meta-package?**
|
5 |
+
In vcpkg we call meta-packages to ports that by themselves don't install anything but that instead forward installation to another port or ports. The reasons for these meta-packages to exist are plenty: to install different versions of a library depending on platform (like the old OpenSSL port did), to allow for multiple versions to exist in the vcpkg registry at the same time (OpenCV), or to conveniently install/uninstall a catalog of related packages (Boost and Qt).
|
6 |
+
|
7 |
+
In the case of Boost, it is unlikely that a user requires all of the 140+ Boost libraries in their project. For the sake of convenience, vcpkg splits Boost into multiple sub-packages broken down to individual libraries. By doing so, users can limit the subset of Boost libraries that they depend on.
|
8 |
+
|
9 |
+
If a user wants to install all of the Boost libraries available in vcpkg, they can do so by installing the `boost` meta-package.
|
10 |
+
|
11 |
+
Due to the nature of meta-packages, some unexpected issues arise when trying to use them with versioning. If a user writes the following manifest file:
|
12 |
+
|
13 |
+
`vcpkg.json`
|
14 |
+
```json
|
15 |
+
{
|
16 |
+
"name": "demo",
|
17 |
+
"version": "1.0.0",
|
18 |
+
"builtin-baseline": "787fe1418ea968913cc6daf11855ffd8b0b5e9d4",
|
19 |
+
"dependencies": [ "boost-tuple" ],
|
20 |
+
"overrides": [
|
21 |
+
{ "name": "boost", "version": "1.72.0" }
|
22 |
+
]
|
23 |
+
}
|
24 |
+
```
|
25 |
+
|
26 |
+
The resulting installation plan is:
|
27 |
+
```
|
28 |
+
The following packages will be built and installed:
|
29 |
+
boost-assert[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-assert\3393715b4ebe30fe1c3b68acf7f84363e611f156
|
30 |
+
boost-compatibility[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-compatibility\cda5675366367789659c59aca65fc57d03c51deb
|
31 |
+
boost-config[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-config\ca82ca1b9c1739c91f3cf42c68cee56c896ae6bd
|
32 |
+
boost-container-hash[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-container-hash\bf472c23d29c3d80b562c43471eb92cea998f372
|
33 |
+
boost-core[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-core\20a19f6ece37686a02eed33e1f58add8b7a2582a
|
34 |
+
boost-detail[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-detail\96744251f025f9b3c856a275dfc338031876777b
|
35 |
+
boost-integer[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-integer\de70ce0d1500df1eda3496c4f98f42f5db256b4a
|
36 |
+
boost-io[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-io\7bf3407372f8fc2a99321d24a0e952d44fe25bf3
|
37 |
+
boost-preprocessor[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-preprocessor\8d78b8ba2e9f54cb00137115ddd2ffec1c63c149
|
38 |
+
boost-static-assert[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-static-assert\2a41c4703c7122de25b1c60510c43edc9371f63d
|
39 |
+
boost-throw-exception[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-throw-exception\b13bdf32a20786a0165cc20205ef63765cac0627
|
40 |
+
boost-tuple[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-tuple\22e3d000a178a88992c430d8ae8a0244c7dea674
|
41 |
+
boost-type-traits[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-type-traits\8829793f6c6c913257314caa317599f8d253a5ca
|
42 |
+
boost-uninstall[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-uninstall\08933bad27b6d41caef0940c31e2069ecb6a079c
|
43 |
+
boost-utility[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-utility\47572946bf6a63c731b9c4142eecb8bef3d3b270
|
44 |
+
boost-vcpkg-helpers[core]:x64-windows -> 7#2 -- D:\vcpkg\buildtrees\versioning\versions\boost-vcpkg-helpers\2a21e5ab45d1ce41c185faf85dff0670ea6def1d
|
45 |
+
```
|
46 |
+
|
47 |
+
It is reasonable to expect that overriding `boost` to version 1.72.0 results in all Boost packages being pinned to version 1.72.0. **However, vcpkg does not treat the `boost` meta-package any differently that any other port.** In other words, vcpkg has no notion that `boost` is related to all the other `boost-*` libraries, other than it depends on all of them. For this reason, all the other boost packages are installed at version 1.75.0, which is the baseline version.
|
48 |
+
|
49 |
+
Below, we describe two methods to pin down Boost versions effectively.
|
50 |
+
|
51 |
+
## Method 1: Pin specific packages
|
52 |
+
Use `"overrides"` to force specific versions in a package-by-package basis.
|
53 |
+
|
54 |
+
`vcpkg.json`
|
55 |
+
```json
|
56 |
+
{
|
57 |
+
"name": "demo",
|
58 |
+
"version": "1.0.0",
|
59 |
+
"builtin-baseline": "787fe1418ea968913cc6daf11855ffd8b0b5e9d4",
|
60 |
+
"dependencies": [ "boost-tuple" ],
|
61 |
+
"overrides": [
|
62 |
+
{ "name": "boost-core", "version": "1.72" },
|
63 |
+
{ "name": "boost-integer", "version": "1.72" },
|
64 |
+
{ "name": "boost-io", "version": "1.72" },
|
65 |
+
{ "name": "boost-tuple", "version": "1.72" }
|
66 |
+
]
|
67 |
+
}
|
68 |
+
```
|
69 |
+
|
70 |
+
This method allows you to quickly set the specific versions you want, but you will need to write an override for each package. Boost libraries are also heavily interdependent, which means that you may end up writing a lot of override lines.
|
71 |
+
|
72 |
+
The second method makes it easy to pin the entire Boost collection and end up with a very simple manifest file.
|
73 |
+
|
74 |
+
## Method 2: Modify baseline
|
75 |
+
An easy way to set the version for the entirety of boost is to use the `"builtin-baseline"` property.
|
76 |
+
|
77 |
+
As of right now, it is only possible to go back to Boost version `1.75.0` using a baseline. Since that was the contemporary Boost version when the versioning feature was merged. **But, it is possible to modify the baseline to whatever you like and use that instead.**
|
78 |
+
|
79 |
+
### Step 1: Create a new branch
|
80 |
+
As described in the versioning documentation. The value that goes in `"builtin-baseline"` is a Git commit in the vcpkg repository's history. Then it stands to reason, that if you want to customize the baseline you should be able to create a new commit with said custom baseline.
|
81 |
+
|
82 |
+
Let's start by creating a new branch to hold our modified baseline.
|
83 |
+
In the directory containing your clone of the vcpkg Git repository run:
|
84 |
+
|
85 |
+
```
|
86 |
+
git checkout -b custom-boost-baseline
|
87 |
+
```
|
88 |
+
|
89 |
+
This will create a new branch named `custom-boost-baseline` and check it out immediately.
|
90 |
+
|
91 |
+
### Step 2: Modify the baseline
|
92 |
+
The next step is to modify the baseline file, open the file in your editor of choice and modify the entries for the Boost libraries.
|
93 |
+
|
94 |
+
Change the `"baseline"` version to your desired version.
|
95 |
+
_NOTE: Remember to also set the port versions to 0 (or your desired version)._
|
96 |
+
|
97 |
+
`${vcpkg-root}/versions/baseline.json`
|
98 |
+
```diff
|
99 |
+
...
|
100 |
+
"boost": {
|
101 |
+
- "baseline": "1.75.0",
|
102 |
+
+ "baseline": "1.72.0",
|
103 |
+
"port-version": 0
|
104 |
+
},
|
105 |
+
"boost-accumulators": {
|
106 |
+
- "baseline": "1.75.0",
|
107 |
+
- "port-version": 1
|
108 |
+
+ "baseline": "1.72.0",
|
109 |
+
+ "port-version": 0
|
110 |
+
},
|
111 |
+
"boost-algorithm": {
|
112 |
+
- "baseline": "1.75.0",
|
113 |
+
+ "baseline": "1.72.0",
|
114 |
+
"port-version": 0
|
115 |
+
},
|
116 |
+
"boost-align": {
|
117 |
+
- "baseline": "1.75.0",
|
118 |
+
+ "baseline": "1.72.0",
|
119 |
+
"port-version": 0
|
120 |
+
},
|
121 |
+
...
|
122 |
+
"boost-uninstall: {
|
123 |
+
"baseline": "1.75.0",
|
124 |
+
"port-version": 0
|
125 |
+
},
|
126 |
+
...
|
127 |
+
```
|
128 |
+
|
129 |
+
Some `boost-` packages are helpers used by vcpkg and are not part of Boost. For example, `"boost-uninstall"` is a vcpkg helper to conveniently uninstall all Boost libraries, but it didn't exist for Boost version `1.72.0`, in this case it is fine to leave it at `1.75.0` to avoid baseline errors (since all versions in `baseline.json` must have existed).
|
130 |
+
|
131 |
+
### Step 3: Commit your changes
|
132 |
+
After saving your modified file, run these commands to commit your changes:
|
133 |
+
|
134 |
+
```
|
135 |
+
git add versions/baseline.json
|
136 |
+
git commit -m "Baseline Boost 1.72.0"
|
137 |
+
```
|
138 |
+
|
139 |
+
You can set the commit message to whatever you want, just make it useful for you.
|
140 |
+
|
141 |
+
### Step 4: Get your baseline commit SHA
|
142 |
+
Once all your changes are ready, you can get the commit SHA by running:
|
143 |
+
```
|
144 |
+
git rev-parse HEAD
|
145 |
+
```
|
146 |
+
|
147 |
+
The output of that command will be the commit SHA you need to put as the `"builtin-baseline"` in your project's manifest file. Copy the 40-hex digits and save them to use later in your manifest file.
|
148 |
+
|
149 |
+
### Step 5: (Optional) Go back to the main repository branch
|
150 |
+
Once your changes have been committed locally, you can refer to the commit SHA regardless of the repository branch you're working on. So, let's go back to the main vcpkg repository branch.
|
151 |
+
|
152 |
+
```
|
153 |
+
git checkout master
|
154 |
+
```
|
155 |
+
|
156 |
+
### Step 6: Create your manifest file with your custom baseline
|
157 |
+
|
158 |
+
```json
|
159 |
+
{
|
160 |
+
"name": "demo",
|
161 |
+
"version": "1.0.0",
|
162 |
+
"builtin-baseline": "9b5cf7c3d9376ddf43429671282972ec4f99aa85",
|
163 |
+
"dependencies": [ "boost-tuple" ]
|
164 |
+
}
|
165 |
+
```
|
166 |
+
|
167 |
+
In this example, commit SHA `9b5cf7c3d9376ddf43429671282972ec4f99aa85` is the commit ID with the modified baseline. Even when a different branch (`master` in this case) is checked out, Git is able to find the commit as long as the branch with the modified baseline exists (the `custom-boost-baseline` branch we created in step 1).
|
168 |
+
|
169 |
+
We run `vcpkg install` in the directory containing our manifest file and the output looks like this:
|
170 |
+
|
171 |
+
```
|
172 |
+
The following packages will be built and installed:
|
173 |
+
boost-assert[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-assert\6754398591f48435b28014ca0d60e5375a4c04d1
|
174 |
+
boost-compatibility[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-compatibility\9893ff3c554575bc712df4108a949e07b269f401
|
175 |
+
boost-config[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-config\de2784767046b06ec31eb718f10df512e51f2aad
|
176 |
+
boost-container-hash[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-container-hash\cc19fb0154bbef188f309f49b2664ec7623b96b6
|
177 |
+
boost-core[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-core\0eb5e20df9e267e9eca325be946f52ceb8a60229
|
178 |
+
boost-detail[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-detail\759d7c6a3f9dbaed0b0c69fa0bb764f7606bb02d
|
179 |
+
boost-integer[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-integer\173956c61a26e83b0f8b58b0baf60f06aeee637c
|
180 |
+
boost-preprocessor[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-preprocessor\86eb3938b7875f124feb845331dbe84cbab5d1c6
|
181 |
+
boost-static-assert[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-static-assert\e82d8f7f3ee07e927dc374f5a08ed6d6f4ef81f4
|
182 |
+
boost-throw-exception[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-throw-exception\64df295f7df41de4fcb219834889b126b5020def
|
183 |
+
boost-tuple[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-tuple\b3e1b01ffce6e367e4fed0a5538a8546abacb6b2
|
184 |
+
boost-type-traits[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-type-traits\5e44ec657660eccf4d3b2710b092dd238e1e7a2d
|
185 |
+
boost-uninstall[core]:x64-windows -> 1.75.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-uninstall\08933bad27b6d41caef0940c31e2069ecb6a079c
|
186 |
+
boost-utility[core]:x64-windows -> 1.72.0 -- D:\vcpkg\buildtrees\versioning\versions\boost-utility\7d721b2458d5d595ac341eb54883274f38a4b8c2
|
187 |
+
boost-vcpkg-helpers[core]:x64-windows -> 7#2 -- D:\vcpkg\buildtrees\versioning\versions\boost-vcpkg-helpers\2a21e5ab45d1ce41c185faf85dff0670ea6def1d
|
188 |
+
```
|
189 |
+
|
190 |
+
Notice how simple our manifest file has become, instead of having a multitude of `"overrides"` you can pin down all Boost packages just by setting the `"builtin-baseline"` to be your modified baseline commit SHA.
|
third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/overlay-triplets-linux-dynamic.md
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Overlay triplets example
|
2 |
+
|
3 |
+
## Building dynamic libraries on Linux
|
4 |
+
|
5 |
+
Using **vcpkg** you can build libraries for many configurations out of the box. However, this doesn't currently include shared libraries on Linux and Mac OS.
|
6 |
+
|
7 |
+
This doesn't mean that you cannot use **vcpkg** to build your dynamic libraries on these platforms! This document will guide you through creating your own custom triplets with `--overlay-triplets` to easily build dynamic libraries on Linux.
|
8 |
+
|
9 |
+
### Step 1: Create the custom triplet files
|
10 |
+
|
11 |
+
To save time, copy the existing `x64-linux.cmake` triplet file.
|
12 |
+
|
13 |
+
```sh
|
14 |
+
~/git$ mkdir custom-triplets
|
15 |
+
~/git$ cp vcpkg/triplets/x64-linux.cmake custom-triplets/x64-linux-dynamic.cmake
|
16 |
+
```
|
17 |
+
|
18 |
+
And modify `custom-triplets/x64-linux-dynamic.cmake` to match the contents below:
|
19 |
+
```cmake
|
20 |
+
# ~/git/custom-triplets/x64-linux-dynamic.cmake
|
21 |
+
set(VCPKG_TARGET_ARCHITECTURE x64)
|
22 |
+
set(VCPKG_CRT_LINKAGE dynamic)
|
23 |
+
set(VCPKG_LIBRARY_LINKAGE dynamic) # This changed from static to dynamic
|
24 |
+
|
25 |
+
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
|
26 |
+
```
|
27 |
+
|
28 |
+
### Step 2: Use `--overlay-triplets` to build dynamic libraries
|
29 |
+
|
30 |
+
Use the `--overlay-triplets` option to include the triplets in the `custom-triplets` directory.
|
31 |
+
|
32 |
+
```
|
33 |
+
~/git$ vcpkg/vcpkg install sqlite3:x64-linux-dynamic --overlay-triplets=custom-triplets
|
34 |
+
The following packages will be built and installed:
|
35 |
+
sqlite3[core]:x64-linux-dynamic
|
36 |
+
Starting package 1/1: sqlite3:x64-linux-dynamic
|
37 |
+
Building package sqlite3[core]:x64-linux-dynamic...
|
38 |
+
-- Loading triplet configuration from: /home/victor/git/custom-triplets/x64-linux-dynamic.cmake
|
39 |
+
-- Downloading https://sqlite.org/2019/sqlite-amalgamation-3280000.zip...
|
40 |
+
-- Extracting source /home/victor/git/vcpkg/downloads/sqlite-amalgamation-3280000.zip
|
41 |
+
-- Applying patch fix-arm-uwp.patch
|
42 |
+
-- Using source at /home/victor/git/vcpkg/buildtrees/sqlite3/src/3280000-6a3ff7ce92
|
43 |
+
-- Configuring x64-linux-dynamic-dbg
|
44 |
+
-- Configuring x64-linux-dynamic-rel
|
45 |
+
-- Building x64-linux-dynamic-dbg
|
46 |
+
-- Building x64-linux-dynamic-rel
|
47 |
+
-- Performing post-build validation
|
48 |
+
-- Performing post-build validation done
|
49 |
+
Building package sqlite3[core]:x64-linux-dynamic... done
|
50 |
+
Installing package sqlite3[core]:x64-linux-dynamic...
|
51 |
+
Installing package sqlite3[core]:x64-linux-dynamic... done
|
52 |
+
Elapsed time for package sqlite3:x64-linux-dynamic: 44.82 s
|
53 |
+
|
54 |
+
Total elapsed time: 44.82 s
|
55 |
+
|
56 |
+
The package sqlite3:x64-linux-dynamic provides CMake targets:
|
57 |
+
|
58 |
+
find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
59 |
+
target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3)
|
60 |
+
```
|
61 |
+
|
62 |
+
Overlay triplets enables your custom triplet files when using `vcpkg install`, `vcpkg update`, `vcpkg upgrade`, and `vcpkg remove`.
|
63 |
+
|
64 |
+
When using the `--overlay-triplets` option, a message like the following lets you know that a custom triplet is being used:
|
65 |
+
|
66 |
+
```
|
67 |
+
-- Loading triplet configuration from: /home/custom-triplets/x64-linux-dynamic.cmake
|
68 |
+
```
|
69 |
+
|
70 |
+
## Overriding default triplets
|
71 |
+
|
72 |
+
As you may have noticed, the default triplets for Windows (`x86-windows` and `x64-windows`) install dynamic libraries, while a suffix (`-static`) is needed for static libraries. This is different with Linux and Mac OS where static libraries are built by `x64-linux` and `x64-osx`.
|
73 |
+
|
74 |
+
Using `--overlay-triplets` it is possible to override the default triplets to accomplish the same behavior on Linux:
|
75 |
+
|
76 |
+
* `x64-linux`: Builds dynamic libraries,
|
77 |
+
* `x64-linux-static`: Builds static libraries.
|
78 |
+
|
79 |
+
### Step 1: Create the overlay triplets
|
80 |
+
|
81 |
+
Using the custom triplet created in the previous example, rename `custom-triplets/x64-linux-dynamic.cmake` to `custom-triplets/x64-linux.cmake`. Then, copy the default `x64-linux` triplet (which builds static libraries) in your `custom-triplets` folder and rename it to `x64-linux-static.cmake`.
|
82 |
+
|
83 |
+
```sh
|
84 |
+
~/git$ mv custom-triplets/x64-linux-dynamic.cmake custom-triplets/x64-linux.cmake
|
85 |
+
~/git$ cp vcpkg/triplets/x64-linux.cmake custom-triplets/x64-linux-static.cmake
|
86 |
+
```
|
87 |
+
|
88 |
+
### Step 2: Use `--overlay-triplets` to override default triplets
|
89 |
+
|
90 |
+
Use the `--overlay-triplets` option to include the triplets in the `custom-triplets` directory.
|
91 |
+
|
92 |
+
```
|
93 |
+
~/git$ vcpkg/vcpkg install sqlite3:x64-linux --overlay-triplets=custom-triplets
|
94 |
+
The following packages will be built and installed:
|
95 |
+
sqlite3[core]:x64-linux
|
96 |
+
Starting package 1/1: sqlite3:x64-linux
|
97 |
+
Building package sqlite3[core]:x64-linux...
|
98 |
+
-- Loading triplet configuration from: /home/victor/git/custom-triplets/x64-linux.cmake
|
99 |
+
-- Downloading https://sqlite.org/2019/sqlite-amalgamation-3280000.zip...
|
100 |
+
-- Extracting source /home/victor/git/vcpkg/downloads/sqlite-amalgamation-3280000.zip
|
101 |
+
-- Applying patch fix-arm-uwp.patch
|
102 |
+
-- Using source at /home/victor/git/vcpkg/buildtrees/sqlite3/src/3280000-6a3ff7ce92
|
103 |
+
-- Configuring x64-linux-dbg
|
104 |
+
-- Configuring x64-linux-rel
|
105 |
+
-- Building x64-linux-dbg
|
106 |
+
-- Building x64-linux-rel
|
107 |
+
-- Performing post-build validation
|
108 |
+
-- Performing post-build validation done
|
109 |
+
Building package sqlite3[core]:x64-linux... done
|
110 |
+
Installing package sqlite3[core]:x64-linux...
|
111 |
+
Installing package sqlite3[core]:x64-linux... done
|
112 |
+
Elapsed time for package sqlite3:x64-linux: 44.82 s
|
113 |
+
|
114 |
+
Total elapsed time: 44.82 s
|
115 |
+
|
116 |
+
The package sqlite3:x64-linux provides CMake targets:
|
117 |
+
|
118 |
+
find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
119 |
+
target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3)
|
120 |
+
```
|
121 |
+
|
122 |
+
Note that the default triplet is masked by your custom triplet:
|
123 |
+
|
124 |
+
```
|
125 |
+
-- Loading triplet configuration from: /home/victor/git/custom-triplets/x64-linux.cmake
|
126 |
+
```
|
third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/packaging-github-repos.md
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Packaging Github Repos Example: libogg
|
2 |
+
### Create the manifest file
|
3 |
+
The manifest file (called `vcpkg.json`) is a json file describing the package's metadata.
|
4 |
+
|
5 |
+
For libogg, we'll create the file `ports/libogg/vcpkg.json` with the following content:
|
6 |
+
|
7 |
+
```json
|
8 |
+
{
|
9 |
+
"name": "libogg",
|
10 |
+
"version-string": "1.3.3",
|
11 |
+
"description": "Ogg is a multimedia container format, and the native file and stream format for the Xiph.org multimedia codecs."
|
12 |
+
}
|
13 |
+
```
|
14 |
+
|
15 |
+
You can format the manifest file to our specifications with `vcpkg format-manifest ports/libogg/vcpkg.json`.
|
16 |
+
|
17 |
+
### Create the portfile
|
18 |
+
`portfile.cmake` describes how to build and install the package. First we download the project from Github with [`vcpkg_from_github`](../maintainers/vcpkg_from_github.md):
|
19 |
+
|
20 |
+
```cmake
|
21 |
+
vcpkg_from_github(
|
22 |
+
OUT_SOURCE_PATH SOURCE_PATH
|
23 |
+
REPO xiph/ogg
|
24 |
+
REF v1.3.3
|
25 |
+
SHA512 0bd6095d647530d4cb1f509eb5e99965a25cc3dd9b8125b93abd6b248255c890cf20710154bdec40568478eb5c4cde724abfb2eff1f3a04e63acef0fbbc9799b
|
26 |
+
HEAD_REF master
|
27 |
+
)
|
28 |
+
```
|
29 |
+
|
30 |
+
The important parts to update are `REPO` for the GitHub repository path, `REF` for a stable tag/commit to use, and `SHA512` with the checksum of the downloaded zipfile (you can get this easily by setting it to `0`, trying to install the package, and copying the checksum).
|
31 |
+
|
32 |
+
Finally, we configure the project with CMake, install the package, and copy over the license file:
|
33 |
+
|
34 |
+
```cmake
|
35 |
+
vcpkg_cmake_configure(SOURCE_PATH ${SOURCE_PATH})
|
36 |
+
vcpkg_cmake_install()
|
37 |
+
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/libogg" RENAME copyright)
|
38 |
+
```
|
39 |
+
|
40 |
+
Check the documentation for [`vcpkg_cmake_configure`](../maintainers/ports/vcpkg-cmake/vcpkg_cmake_configure.md) and [`vcpkg_cmake_install`](../maintainers/ports/vcpkg-cmake/vcpkg_cmake_install.md) if your package needs additional options.
|
41 |
+
|
42 |
+
Now you can run `vcpkg install libogg` to build and install the package.
|
43 |
+
|
44 |
+
### Suggested example portfiles
|
45 |
+
In the `ports/` directory are many libraries that can be used as examples, including many that are not based on CMake.
|
46 |
+
|
47 |
+
- Header only libraries
|
48 |
+
- rapidjson
|
49 |
+
- range-v3
|
50 |
+
- MSBuild-based
|
51 |
+
- mpg123
|
52 |
+
- Non-CMake, custom buildsystem
|
53 |
+
- openssl
|
54 |
+
- ffmpeg
|
third-party/DPVO/Pangolin/scripts/vcpkg/docs/examples/packaging-zipfiles.md
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Packaging `.zip` Files Example: zlib
|
2 |
+
|
3 |
+
### Bootstrap with `create`
|
4 |
+
First, locate a globally accessible archive of the library's sources. Zip, gzip, and bzip are all supported. Strongly prefer official sources or mirrors over unofficial mirrors.
|
5 |
+
|
6 |
+
*Looking at zlib's website, the URL http://zlib.net/zlib-1.2.11.tar.gz looks appropriate.*
|
7 |
+
|
8 |
+
Second, determine a suitable package name. This should be ASCII, lowercase, and recognizable to someone who knows the library's "human name". If the library is already packaged in another package manager, prefer that name.
|
9 |
+
|
10 |
+
*Since zlib is already packaged as zlib, we will use the name zlib2 for this example.*
|
11 |
+
|
12 |
+
Finally, if the server's name for the archive is not very descriptive (such as downloading a zipped commit or branch from GitHub), choose a nice archive name of the form `<packagename>-<version>.zip`.
|
13 |
+
|
14 |
+
*`zlib1211.zip` is a fine name, so no change needed.*
|
15 |
+
|
16 |
+
All this information can then be passed into the `create` command, which will download the sources and bootstrap the packaging process inside `ports/<packagename>`.
|
17 |
+
|
18 |
+
```no-highlight
|
19 |
+
PS D:\src\vcpkg> .\vcpkg create zlib2 http://zlib.net/zlib-1.2.11.tar.gz zlib1211.tar.gz
|
20 |
+
-- Generated portfile: D:/src/vcpkg/ports/zlib2/portfile.cmake
|
21 |
+
```
|
22 |
+
|
23 |
+
### Create the manifest file
|
24 |
+
In addition to the generated `ports/<package>/portfile.cmake`, we also need a `ports/<package>/vcpkg.json` file. This file is a simple set of fields describing the package's metadata.
|
25 |
+
|
26 |
+
*For zlib2, we'll create the file `ports/zlib2/vcpkg.json` with the following contents:*
|
27 |
+
```json
|
28 |
+
{
|
29 |
+
"name": "zlib2",
|
30 |
+
"version-string": "1.2.11",
|
31 |
+
"description": "A Massively Spiffy Yet Delicately Unobtrusive Compression Library"
|
32 |
+
}
|
33 |
+
```
|
34 |
+
|
35 |
+
### Tweak the generated portfile
|
36 |
+
The generated `portfile.cmake` will need some editing to correctly package most libraries in the wild, however we can start by trying out the build.
|
37 |
+
|
38 |
+
```no-highlight
|
39 |
+
PS D:\src\vcpkg> .\vcpkg install zlib2
|
40 |
+
Computing installation plan...
|
41 |
+
The following packages will be built and installed:
|
42 |
+
zlib2[core]:x64-uwp
|
43 |
+
Starting package 1/1: zlib2:x64-uwp
|
44 |
+
Building package zlib2[core]:x64-uwp...
|
45 |
+
-- Using cached C:/src/vcpkg/downloads/zlib1211.tar.gz
|
46 |
+
-- Cleaning sources at C:/src/vcpkg/buildtrees/zlib2/src/1.2.11-deec42f53b.clean. Pass --editable to vcpkg to reuse sources.
|
47 |
+
-- Extracting source C:/src/vcpkg/downloads/zlib1211.tar.gz
|
48 |
+
-- Applying patch cmake_dont_build_more_than_needed.patch
|
49 |
+
-- Using source at C:/src/vcpkg/buildtrees/zlib2/src/1.2.11-deec42f53b.clean
|
50 |
+
-- Configuring x64-uwp
|
51 |
+
-- Building x64-uwp-dbg
|
52 |
+
-- Building x64-uwp-rel
|
53 |
+
-- Installing: C:/src/vcpkg/packages/zlib2_x64-uwp/share/zlib2/copyright
|
54 |
+
-- Performing post-build validation
|
55 |
+
Include files should not be duplicated into the /debug/include directory. If this cannot be disabled in the project cmake, use
|
56 |
+
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
57 |
+
/debug/share should not exist. Please reorganize any important files, then use
|
58 |
+
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
|
59 |
+
The software license must be available at ${CURRENT_PACKAGES_DIR}/share/zlib2/copyright
|
60 |
+
Found 3 error(s). Please correct the portfile:
|
61 |
+
D:\src\vcpkg\ports\zlib2\portfile.cmake
|
62 |
+
```
|
63 |
+
|
64 |
+
At this point, it is a matter of reading the error messages and log files while steadily improving the quality of the portfile. Zlib required providing a discrete copy of the LICENSE to copy into the package, suppressing the build and installation of executables and headers, and removing the static libraries after they were installed.
|
65 |
+
|
66 |
+
### Suggested example portfiles
|
67 |
+
In the `ports/` directory are many libraries that can be used as examples, including many that are not based on CMake.
|
68 |
+
|
69 |
+
- Header only libraries
|
70 |
+
- rapidjson
|
71 |
+
- range-v3
|
72 |
+
- MSBuild-based
|
73 |
+
- mpg123
|
74 |
+
- Non-CMake, custom buildsystem
|
75 |
+
- openssl
|
76 |
+
- ffmpeg
|