Spaces:
Sleeping
Sleeping
1e553fb4cd9e020fcd57e1db93bb22f5e2d7c5f9eb8bc2727833ad6dba5ec47e
Browse files- third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/pybind11NewTools.cmake +267 -0
- third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/pybind11Tools.cmake +220 -0
- third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/pyproject.toml +3 -0
- third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/setup_global.py.in +65 -0
- third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/setup_main.py.in +41 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pyinterpreter.cpp +217 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/attach.cpp +48 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/attach.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/colour.cpp +48 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/colour.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/datalog.cpp +86 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/datalog.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/display.cpp +81 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/display.hpp +36 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/gl.cpp +119 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/gl.hpp +36 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/gl_draw.cpp +112 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/gl_draw.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/glsl.cpp +72 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/glsl.hpp +36 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/glvbo.cpp +48 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/glvbo.hpp +36 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/handler.cpp +58 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/handler.hpp +62 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/image.cpp +34 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/image.hpp +67 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/image_view.cpp +81 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/image_view.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/opengl_render_state.cpp +116 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/opengl_render_state.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/params.cpp +43 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/params.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pixel_format.cpp +43 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pixel_format.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/plotter.cpp +143 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/plotter.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pypangoio.cpp +35 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pypangoio.h +59 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pypangolin.h +87 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/var.cpp +184 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/var.hpp +74 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/video.cpp +645 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/video.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/view.cpp +84 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/view.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/viewport.cpp +56 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/viewport.hpp +38 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/widget.cpp +36 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/widget.hpp +37 -0
- third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/window.cpp +120 -0
third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/pybind11NewTools.cmake
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# tools/pybind11NewTools.cmake -- Build system for the pybind11 modules
|
| 2 |
+
#
|
| 3 |
+
# Copyright (c) 2020 Wenzel Jakob <wenzel@inf.ethz.ch> and Henry Schreiner
|
| 4 |
+
#
|
| 5 |
+
# All rights reserved. Use of this source code is governed by a
|
| 6 |
+
# BSD-style license that can be found in the LICENSE file.
|
| 7 |
+
|
| 8 |
+
get_property(
|
| 9 |
+
is_config
|
| 10 |
+
TARGET pybind11::headers
|
| 11 |
+
PROPERTY IMPORTED)
|
| 12 |
+
|
| 13 |
+
if(pybind11_FIND_QUIETLY)
|
| 14 |
+
set(_pybind11_quiet QUIET)
|
| 15 |
+
else()
|
| 16 |
+
set(_pybind11_quiet "")
|
| 17 |
+
endif()
|
| 18 |
+
|
| 19 |
+
if(CMAKE_VERSION VERSION_LESS 3.12)
|
| 20 |
+
message(FATAL_ERROR "You cannot use the new FindPython module with CMake < 3.12")
|
| 21 |
+
endif()
|
| 22 |
+
|
| 23 |
+
if(NOT Python_FOUND
|
| 24 |
+
AND NOT Python3_FOUND
|
| 25 |
+
AND NOT Python2_FOUND)
|
| 26 |
+
if(NOT DEFINED Python_FIND_IMPLEMENTATIONS)
|
| 27 |
+
set(Python_FIND_IMPLEMENTATIONS CPython PyPy)
|
| 28 |
+
endif()
|
| 29 |
+
|
| 30 |
+
# GitHub Actions like activation
|
| 31 |
+
if(NOT DEFINED Python_ROOT_DIR AND DEFINED ENV{pythonLocation})
|
| 32 |
+
set(Python_ROOT_DIR "$ENV{pythonLocation}")
|
| 33 |
+
endif()
|
| 34 |
+
|
| 35 |
+
find_package(Python REQUIRED COMPONENTS Interpreter Development ${_pybind11_quiet})
|
| 36 |
+
|
| 37 |
+
# If we are in submodule mode, export the Python targets to global targets.
|
| 38 |
+
# If this behavior is not desired, FindPython _before_ pybind11.
|
| 39 |
+
if(NOT is_config)
|
| 40 |
+
set_property(TARGET Python::Python PROPERTY IMPORTED_GLOBAL TRUE)
|
| 41 |
+
set_property(TARGET Python::Interpreter PROPERTY IMPORTED_GLOBAL TRUE)
|
| 42 |
+
if(TARGET Python::Module)
|
| 43 |
+
set_property(TARGET Python::Module PROPERTY IMPORTED_GLOBAL TRUE)
|
| 44 |
+
endif()
|
| 45 |
+
endif()
|
| 46 |
+
endif()
|
| 47 |
+
|
| 48 |
+
if(Python_FOUND)
|
| 49 |
+
set(_Python
|
| 50 |
+
Python
|
| 51 |
+
CACHE INTERNAL "" FORCE)
|
| 52 |
+
elseif(Python3_FOUND AND NOT Python2_FOUND)
|
| 53 |
+
set(_Python
|
| 54 |
+
Python3
|
| 55 |
+
CACHE INTERNAL "" FORCE)
|
| 56 |
+
elseif(Python2_FOUND AND NOT Python3_FOUND)
|
| 57 |
+
set(_Python
|
| 58 |
+
Python2
|
| 59 |
+
CACHE INTERNAL "" FORCE)
|
| 60 |
+
else()
|
| 61 |
+
message(AUTHOR_WARNING "Python2 and Python3 both present, pybind11 in "
|
| 62 |
+
"PYBIND11_NOPYTHON mode (manually activate to silence warning)")
|
| 63 |
+
set(_pybind11_nopython ON)
|
| 64 |
+
return()
|
| 65 |
+
endif()
|
| 66 |
+
|
| 67 |
+
if(PYBIND11_MASTER_PROJECT)
|
| 68 |
+
if(${_Python}_INTERPRETER_ID MATCHES "PyPy")
|
| 69 |
+
message(STATUS "PyPy ${${_Python}_PyPy_VERSION} (Py ${${_Python}_VERSION})")
|
| 70 |
+
else()
|
| 71 |
+
message(STATUS "${_Python} ${${_Python}_VERSION}")
|
| 72 |
+
endif()
|
| 73 |
+
endif()
|
| 74 |
+
|
| 75 |
+
# If a user finds Python, they may forget to include the Interpreter component
|
| 76 |
+
# and the following two steps require it. It is highly recommended by CMake
|
| 77 |
+
# when finding development libraries anyway, so we will require it.
|
| 78 |
+
if(NOT DEFINED ${_Python}_EXECUTABLE)
|
| 79 |
+
message(
|
| 80 |
+
FATAL_ERROR
|
| 81 |
+
"${_Python} was found without the Interpreter component. Pybind11 requires this component.")
|
| 82 |
+
|
| 83 |
+
endif()
|
| 84 |
+
|
| 85 |
+
if(NOT DEFINED PYTHON_IS_DEBUG)
|
| 86 |
+
# Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter
|
| 87 |
+
execute_process(
|
| 88 |
+
COMMAND "${${_Python}_EXECUTABLE}" "-c"
|
| 89 |
+
"import sys; sys.exit(hasattr(sys, 'gettotalrefcount'))"
|
| 90 |
+
RESULT_VARIABLE _PYTHON_IS_DEBUG)
|
| 91 |
+
set(PYTHON_IS_DEBUG
|
| 92 |
+
"${_PYTHON_IS_DEBUG}"
|
| 93 |
+
CACHE INTERNAL "Python debug status")
|
| 94 |
+
endif()
|
| 95 |
+
|
| 96 |
+
# Get the suffix - SO is deprecated, should use EXT_SUFFIX, but this is
|
| 97 |
+
# required for PyPy3 (as of 7.3.1)
|
| 98 |
+
if(NOT DEFINED PYTHON_MODULE_EXTENSION)
|
| 99 |
+
execute_process(
|
| 100 |
+
COMMAND
|
| 101 |
+
"${${_Python}_EXECUTABLE}" "-c"
|
| 102 |
+
"from distutils import sysconfig as s;print(s.get_config_var('EXT_SUFFIX') or s.get_config_var('SO'))"
|
| 103 |
+
OUTPUT_VARIABLE _PYTHON_MODULE_EXTENSION
|
| 104 |
+
ERROR_VARIABLE _PYTHON_MODULE_EXTENSION_ERR
|
| 105 |
+
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
| 106 |
+
|
| 107 |
+
if(_PYTHON_MODULE_EXTENSION STREQUAL "")
|
| 108 |
+
message(
|
| 109 |
+
FATAL_ERROR "pybind11 could not query the module file extension, likely the 'distutils'"
|
| 110 |
+
"package is not installed. Full error message:\n${_PYTHON_MODULE_EXTENSION_ERR}")
|
| 111 |
+
endif()
|
| 112 |
+
|
| 113 |
+
# This needs to be available for the pybind11_extension function
|
| 114 |
+
set(PYTHON_MODULE_EXTENSION
|
| 115 |
+
"${_PYTHON_MODULE_EXTENSION}"
|
| 116 |
+
CACHE INTERNAL "")
|
| 117 |
+
endif()
|
| 118 |
+
|
| 119 |
+
# Python debug libraries expose slightly different objects before 3.8
|
| 120 |
+
# https://docs.python.org/3.6/c-api/intro.html#debugging-builds
|
| 121 |
+
# https://stackoverflow.com/questions/39161202/how-to-work-around-missing-pymodule-create2-in-amd64-win-python35-d-lib
|
| 122 |
+
if(PYTHON_IS_DEBUG)
|
| 123 |
+
set_property(
|
| 124 |
+
TARGET pybind11::pybind11
|
| 125 |
+
APPEND
|
| 126 |
+
PROPERTY INTERFACE_COMPILE_DEFINITIONS Py_DEBUG)
|
| 127 |
+
endif()
|
| 128 |
+
|
| 129 |
+
# Check on every access - since Python2 and Python3 could have been used - do nothing in that case.
|
| 130 |
+
|
| 131 |
+
if(DEFINED ${_Python}_INCLUDE_DIRS)
|
| 132 |
+
# Only add Python for build - must be added during the import for config
|
| 133 |
+
# since it has to be re-discovered.
|
| 134 |
+
#
|
| 135 |
+
# This needs to be a target to be included after the local pybind11
|
| 136 |
+
# directory, just in case there there is an installed pybind11 sitting
|
| 137 |
+
# next to Python's includes. It also ensures Python is a SYSTEM library.
|
| 138 |
+
add_library(pybind11::python_headers INTERFACE IMPORTED)
|
| 139 |
+
set_property(
|
| 140 |
+
TARGET pybind11::python_headers PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
| 141 |
+
"$<BUILD_INTERFACE:${${_Python}_INCLUDE_DIRS}>")
|
| 142 |
+
set_property(
|
| 143 |
+
TARGET pybind11::pybind11
|
| 144 |
+
APPEND
|
| 145 |
+
PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python_headers)
|
| 146 |
+
set(pybind11_INCLUDE_DIRS
|
| 147 |
+
"${pybind11_INCLUDE_DIR}" "${${_Python}_INCLUDE_DIRS}"
|
| 148 |
+
CACHE INTERNAL "Directories where pybind11 and possibly Python headers are located")
|
| 149 |
+
endif()
|
| 150 |
+
|
| 151 |
+
if(DEFINED ${_Python}_VERSION AND ${_Python}_VERSION VERSION_LESS 3)
|
| 152 |
+
set_property(
|
| 153 |
+
TARGET pybind11::pybind11
|
| 154 |
+
APPEND
|
| 155 |
+
PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python2_no_register)
|
| 156 |
+
endif()
|
| 157 |
+
|
| 158 |
+
# In CMake 3.18+, you can find these separately, so include an if
|
| 159 |
+
if(TARGET ${_Python}::Python)
|
| 160 |
+
set_property(
|
| 161 |
+
TARGET pybind11::embed
|
| 162 |
+
APPEND
|
| 163 |
+
PROPERTY INTERFACE_LINK_LIBRARIES ${_Python}::Python)
|
| 164 |
+
endif()
|
| 165 |
+
|
| 166 |
+
# CMake 3.15+ has this
|
| 167 |
+
if(TARGET ${_Python}::Module)
|
| 168 |
+
set_property(
|
| 169 |
+
TARGET pybind11::module
|
| 170 |
+
APPEND
|
| 171 |
+
PROPERTY INTERFACE_LINK_LIBRARIES ${_Python}::Module)
|
| 172 |
+
else()
|
| 173 |
+
set_property(
|
| 174 |
+
TARGET pybind11::module
|
| 175 |
+
APPEND
|
| 176 |
+
PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python_link_helper)
|
| 177 |
+
endif()
|
| 178 |
+
|
| 179 |
+
# WITHOUT_SOABI and WITH_SOABI will disable the custom extension handling used by pybind11.
|
| 180 |
+
# WITH_SOABI is passed on to python_add_library.
|
| 181 |
+
function(pybind11_add_module target_name)
|
| 182 |
+
cmake_parse_arguments(PARSE_ARGV 1 ARG
|
| 183 |
+
"STATIC;SHARED;MODULE;THIN_LTO;OPT_SIZE;NO_EXTRAS;WITHOUT_SOABI" "" "")
|
| 184 |
+
|
| 185 |
+
if(ARG_STATIC)
|
| 186 |
+
set(lib_type STATIC)
|
| 187 |
+
elseif(ARG_SHARED)
|
| 188 |
+
set(lib_type SHARED)
|
| 189 |
+
else()
|
| 190 |
+
set(lib_type MODULE)
|
| 191 |
+
endif()
|
| 192 |
+
|
| 193 |
+
if("${_Python}" STREQUAL "Python")
|
| 194 |
+
python_add_library(${target_name} ${lib_type} ${ARG_UNPARSED_ARGUMENTS})
|
| 195 |
+
elseif("${_Python}" STREQUAL "Python3")
|
| 196 |
+
python3_add_library(${target_name} ${lib_type} ${ARG_UNPARSED_ARGUMENTS})
|
| 197 |
+
elseif("${_Python}" STREQUAL "Python2")
|
| 198 |
+
python2_add_library(${target_name} ${lib_type} ${ARG_UNPARSED_ARGUMENTS})
|
| 199 |
+
else()
|
| 200 |
+
message(FATAL_ERROR "Cannot detect FindPython version: ${_Python}")
|
| 201 |
+
endif()
|
| 202 |
+
|
| 203 |
+
target_link_libraries(${target_name} PRIVATE pybind11::headers)
|
| 204 |
+
|
| 205 |
+
if(lib_type STREQUAL "MODULE")
|
| 206 |
+
target_link_libraries(${target_name} PRIVATE pybind11::module)
|
| 207 |
+
else()
|
| 208 |
+
target_link_libraries(${target_name} PRIVATE pybind11::embed)
|
| 209 |
+
endif()
|
| 210 |
+
|
| 211 |
+
if(MSVC)
|
| 212 |
+
target_link_libraries(${target_name} PRIVATE pybind11::windows_extras)
|
| 213 |
+
endif()
|
| 214 |
+
|
| 215 |
+
if(DEFINED ${_Python}_VERSION AND ${_Python}_VERSION VERSION_LESS 3)
|
| 216 |
+
target_link_libraries(${target_name} PRIVATE pybind11::python2_no_register)
|
| 217 |
+
endif()
|
| 218 |
+
|
| 219 |
+
# -fvisibility=hidden is required to allow multiple modules compiled against
|
| 220 |
+
# different pybind versions to work properly, and for some features (e.g.
|
| 221 |
+
# py::module_local). We force it on everything inside the `pybind11`
|
| 222 |
+
# namespace; also turning it on for a pybind module compilation here avoids
|
| 223 |
+
# potential warnings or issues from having mixed hidden/non-hidden types.
|
| 224 |
+
if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
|
| 225 |
+
set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden")
|
| 226 |
+
endif()
|
| 227 |
+
|
| 228 |
+
if(NOT DEFINED CMAKE_CUDA_VISIBILITY_PRESET)
|
| 229 |
+
set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden")
|
| 230 |
+
endif()
|
| 231 |
+
|
| 232 |
+
# If we don't pass a WITH_SOABI or WITHOUT_SOABI, use our own default handling of extensions
|
| 233 |
+
if(NOT ARG_WITHOUT_SOABI AND NOT "WITH_SOABI" IN_LIST ARG_UNPARSED_ARGUMENTS)
|
| 234 |
+
pybind11_extension(${target_name})
|
| 235 |
+
endif()
|
| 236 |
+
|
| 237 |
+
if(ARG_NO_EXTRAS)
|
| 238 |
+
return()
|
| 239 |
+
endif()
|
| 240 |
+
|
| 241 |
+
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
| 242 |
+
if(ARG_THIN_LTO)
|
| 243 |
+
target_link_libraries(${target_name} PRIVATE pybind11::thin_lto)
|
| 244 |
+
else()
|
| 245 |
+
target_link_libraries(${target_name} PRIVATE pybind11::lto)
|
| 246 |
+
endif()
|
| 247 |
+
endif()
|
| 248 |
+
|
| 249 |
+
if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
|
| 250 |
+
# Strip unnecessary sections of the binary on Linux/macOS
|
| 251 |
+
pybind11_strip(${target_name})
|
| 252 |
+
endif()
|
| 253 |
+
|
| 254 |
+
if(MSVC)
|
| 255 |
+
target_link_libraries(${target_name} PRIVATE pybind11::windows_extras)
|
| 256 |
+
endif()
|
| 257 |
+
|
| 258 |
+
if(ARG_OPT_SIZE)
|
| 259 |
+
target_link_libraries(${target_name} PRIVATE pybind11::opt_size)
|
| 260 |
+
endif()
|
| 261 |
+
endfunction()
|
| 262 |
+
|
| 263 |
+
function(pybind11_extension name)
|
| 264 |
+
# The extension is precomputed
|
| 265 |
+
set_target_properties(${name} PROPERTIES PREFIX "" SUFFIX "${PYTHON_MODULE_EXTENSION}")
|
| 266 |
+
|
| 267 |
+
endfunction()
|
third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/pybind11Tools.cmake
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# tools/pybind11Tools.cmake -- Build system for the pybind11 modules
|
| 2 |
+
#
|
| 3 |
+
# Copyright (c) 2020 Wenzel Jakob <wenzel.jakob@epfl.ch>
|
| 4 |
+
#
|
| 5 |
+
# All rights reserved. Use of this source code is governed by a
|
| 6 |
+
# BSD-style license that can be found in the LICENSE file.
|
| 7 |
+
|
| 8 |
+
# Built-in in CMake 3.5+
|
| 9 |
+
include(CMakeParseArguments)
|
| 10 |
+
|
| 11 |
+
if(pybind11_FIND_QUIETLY)
|
| 12 |
+
set(_pybind11_quiet QUIET)
|
| 13 |
+
else()
|
| 14 |
+
set(_pybind11_quiet "")
|
| 15 |
+
endif()
|
| 16 |
+
|
| 17 |
+
# If this is the first run, PYTHON_VERSION can stand in for PYBIND11_PYTHON_VERSION
|
| 18 |
+
if(NOT DEFINED PYBIND11_PYTHON_VERSION AND DEFINED PYTHON_VERSION)
|
| 19 |
+
message(WARNING "Set PYBIND11_PYTHON_VERSION to search for a specific version, not "
|
| 20 |
+
"PYTHON_VERSION (which is an output). Assuming that is what you "
|
| 21 |
+
"meant to do and continuing anyway.")
|
| 22 |
+
set(PYBIND11_PYTHON_VERSION
|
| 23 |
+
"${PYTHON_VERSION}"
|
| 24 |
+
CACHE STRING "Python version to use for compiling modules")
|
| 25 |
+
unset(PYTHON_VERSION)
|
| 26 |
+
unset(PYTHON_VERSION CACHE)
|
| 27 |
+
elseif(DEFINED PYBIND11_PYTHON_VERSION)
|
| 28 |
+
# If this is set as a normal variable, promote it
|
| 29 |
+
set(PYBIND11_PYTHON_VERSION
|
| 30 |
+
"${PYBIND11_PYTHON_VERSION}"
|
| 31 |
+
CACHE STRING "Python version to use for compiling modules")
|
| 32 |
+
else()
|
| 33 |
+
# Make an empty cache variable.
|
| 34 |
+
set(PYBIND11_PYTHON_VERSION
|
| 35 |
+
""
|
| 36 |
+
CACHE STRING "Python version to use for compiling modules")
|
| 37 |
+
endif()
|
| 38 |
+
|
| 39 |
+
# A user can set versions manually too
|
| 40 |
+
set(Python_ADDITIONAL_VERSIONS
|
| 41 |
+
"3.10;3.9;3.8;3.7;3.6;3.5;3.4"
|
| 42 |
+
CACHE INTERNAL "")
|
| 43 |
+
|
| 44 |
+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
| 45 |
+
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED ${_pybind11_quiet})
|
| 46 |
+
list(REMOVE_AT CMAKE_MODULE_PATH -1)
|
| 47 |
+
|
| 48 |
+
# Cache variables so pybind11_add_module can be used in parent projects
|
| 49 |
+
set(PYTHON_INCLUDE_DIRS
|
| 50 |
+
${PYTHON_INCLUDE_DIRS}
|
| 51 |
+
CACHE INTERNAL "")
|
| 52 |
+
set(PYTHON_LIBRARIES
|
| 53 |
+
${PYTHON_LIBRARIES}
|
| 54 |
+
CACHE INTERNAL "")
|
| 55 |
+
set(PYTHON_MODULE_PREFIX
|
| 56 |
+
${PYTHON_MODULE_PREFIX}
|
| 57 |
+
CACHE INTERNAL "")
|
| 58 |
+
set(PYTHON_MODULE_EXTENSION
|
| 59 |
+
${PYTHON_MODULE_EXTENSION}
|
| 60 |
+
CACHE INTERNAL "")
|
| 61 |
+
set(PYTHON_VERSION_MAJOR
|
| 62 |
+
${PYTHON_VERSION_MAJOR}
|
| 63 |
+
CACHE INTERNAL "")
|
| 64 |
+
set(PYTHON_VERSION_MINOR
|
| 65 |
+
${PYTHON_VERSION_MINOR}
|
| 66 |
+
CACHE INTERNAL "")
|
| 67 |
+
set(PYTHON_VERSION
|
| 68 |
+
${PYTHON_VERSION}
|
| 69 |
+
CACHE INTERNAL "")
|
| 70 |
+
set(PYTHON_IS_DEBUG
|
| 71 |
+
"${PYTHON_IS_DEBUG}"
|
| 72 |
+
CACHE INTERNAL "")
|
| 73 |
+
|
| 74 |
+
if(PYBIND11_MASTER_PROJECT)
|
| 75 |
+
if(PYTHON_MODULE_EXTENSION MATCHES "pypy")
|
| 76 |
+
if(NOT DEFINED PYPY_VERSION)
|
| 77 |
+
execute_process(
|
| 78 |
+
COMMAND ${PYTHON_EXECUTABLE} -c
|
| 79 |
+
[=[import sys; sys.stdout.write(".".join(map(str, sys.pypy_version_info[:3])))]=]
|
| 80 |
+
OUTPUT_VARIABLE pypy_version)
|
| 81 |
+
set(PYPY_VERSION
|
| 82 |
+
${pypy_version}
|
| 83 |
+
CACHE INTERNAL "")
|
| 84 |
+
endif()
|
| 85 |
+
message(STATUS "PYPY ${PYPY_VERSION} (Py ${PYTHON_VERSION})")
|
| 86 |
+
else()
|
| 87 |
+
message(STATUS "PYTHON ${PYTHON_VERSION}")
|
| 88 |
+
endif()
|
| 89 |
+
endif()
|
| 90 |
+
|
| 91 |
+
# Only add Python for build - must be added during the import for config since
|
| 92 |
+
# it has to be re-discovered.
|
| 93 |
+
#
|
| 94 |
+
# This needs to be an target to it is included after the local pybind11
|
| 95 |
+
# directory, just in case there are multiple versions of pybind11, we want the
|
| 96 |
+
# one we expect.
|
| 97 |
+
add_library(pybind11::python_headers INTERFACE IMPORTED)
|
| 98 |
+
set_property(TARGET pybind11::python_headers PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
| 99 |
+
"$<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>")
|
| 100 |
+
set_property(
|
| 101 |
+
TARGET pybind11::pybind11
|
| 102 |
+
APPEND
|
| 103 |
+
PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python_headers)
|
| 104 |
+
|
| 105 |
+
set(pybind11_INCLUDE_DIRS
|
| 106 |
+
"${pybind11_INCLUDE_DIR}" "${PYTHON_INCLUDE_DIRS}"
|
| 107 |
+
CACHE INTERNAL "Directories where pybind11 and possibly Python headers are located")
|
| 108 |
+
|
| 109 |
+
# Python debug libraries expose slightly different objects before 3.8
|
| 110 |
+
# https://docs.python.org/3.6/c-api/intro.html#debugging-builds
|
| 111 |
+
# https://stackoverflow.com/questions/39161202/how-to-work-around-missing-pymodule-create2-in-amd64-win-python35-d-lib
|
| 112 |
+
if(PYTHON_IS_DEBUG)
|
| 113 |
+
set_property(
|
| 114 |
+
TARGET pybind11::pybind11
|
| 115 |
+
APPEND
|
| 116 |
+
PROPERTY INTERFACE_COMPILE_DEFINITIONS Py_DEBUG)
|
| 117 |
+
endif()
|
| 118 |
+
|
| 119 |
+
set_property(
|
| 120 |
+
TARGET pybind11::module
|
| 121 |
+
APPEND
|
| 122 |
+
PROPERTY
|
| 123 |
+
INTERFACE_LINK_LIBRARIES pybind11::python_link_helper
|
| 124 |
+
"$<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Cygwin>>:$<BUILD_INTERFACE:${PYTHON_LIBRARIES}>>")
|
| 125 |
+
|
| 126 |
+
if(PYTHON_VERSION VERSION_LESS 3)
|
| 127 |
+
set_property(
|
| 128 |
+
TARGET pybind11::pybind11
|
| 129 |
+
APPEND
|
| 130 |
+
PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python2_no_register)
|
| 131 |
+
endif()
|
| 132 |
+
|
| 133 |
+
set_property(
|
| 134 |
+
TARGET pybind11::embed
|
| 135 |
+
APPEND
|
| 136 |
+
PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11 $<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
|
| 137 |
+
|
| 138 |
+
function(pybind11_extension name)
|
| 139 |
+
# The prefix and extension are provided by FindPythonLibsNew.cmake
|
| 140 |
+
set_target_properties(${name} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
|
| 141 |
+
SUFFIX "${PYTHON_MODULE_EXTENSION}")
|
| 142 |
+
endfunction()
|
| 143 |
+
|
| 144 |
+
# Build a Python extension module:
|
| 145 |
+
# pybind11_add_module(<name> [MODULE | SHARED] [EXCLUDE_FROM_ALL]
|
| 146 |
+
# [NO_EXTRAS] [THIN_LTO] [OPT_SIZE] source1 [source2 ...])
|
| 147 |
+
#
|
| 148 |
+
function(pybind11_add_module target_name)
|
| 149 |
+
set(options "MODULE;SHARED;EXCLUDE_FROM_ALL;NO_EXTRAS;SYSTEM;THIN_LTO;OPT_SIZE")
|
| 150 |
+
cmake_parse_arguments(ARG "${options}" "" "" ${ARGN})
|
| 151 |
+
|
| 152 |
+
if(ARG_MODULE AND ARG_SHARED)
|
| 153 |
+
message(FATAL_ERROR "Can't be both MODULE and SHARED")
|
| 154 |
+
elseif(ARG_SHARED)
|
| 155 |
+
set(lib_type SHARED)
|
| 156 |
+
else()
|
| 157 |
+
set(lib_type MODULE)
|
| 158 |
+
endif()
|
| 159 |
+
|
| 160 |
+
if(ARG_EXCLUDE_FROM_ALL)
|
| 161 |
+
set(exclude_from_all EXCLUDE_FROM_ALL)
|
| 162 |
+
else()
|
| 163 |
+
set(exclude_from_all "")
|
| 164 |
+
endif()
|
| 165 |
+
|
| 166 |
+
add_library(${target_name} ${lib_type} ${exclude_from_all} ${ARG_UNPARSED_ARGUMENTS})
|
| 167 |
+
|
| 168 |
+
target_link_libraries(${target_name} PRIVATE pybind11::module)
|
| 169 |
+
|
| 170 |
+
if(ARG_SYSTEM)
|
| 171 |
+
message(
|
| 172 |
+
STATUS
|
| 173 |
+
"Warning: this does not have an effect - use NO_SYSTEM_FROM_IMPORTED if using imported targets"
|
| 174 |
+
)
|
| 175 |
+
endif()
|
| 176 |
+
|
| 177 |
+
pybind11_extension(${target_name})
|
| 178 |
+
|
| 179 |
+
# -fvisibility=hidden is required to allow multiple modules compiled against
|
| 180 |
+
# different pybind versions to work properly, and for some features (e.g.
|
| 181 |
+
# py::module_local). We force it on everything inside the `pybind11`
|
| 182 |
+
# namespace; also turning it on for a pybind module compilation here avoids
|
| 183 |
+
# potential warnings or issues from having mixed hidden/non-hidden types.
|
| 184 |
+
if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
|
| 185 |
+
set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden")
|
| 186 |
+
endif()
|
| 187 |
+
|
| 188 |
+
if(NOT DEFINED CMAKE_CUDA_VISIBILITY_PRESET)
|
| 189 |
+
set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden")
|
| 190 |
+
endif()
|
| 191 |
+
|
| 192 |
+
if(ARG_NO_EXTRAS)
|
| 193 |
+
return()
|
| 194 |
+
endif()
|
| 195 |
+
|
| 196 |
+
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
| 197 |
+
if(ARG_THIN_LTO)
|
| 198 |
+
target_link_libraries(${target_name} PRIVATE pybind11::thin_lto)
|
| 199 |
+
else()
|
| 200 |
+
target_link_libraries(${target_name} PRIVATE pybind11::lto)
|
| 201 |
+
endif()
|
| 202 |
+
endif()
|
| 203 |
+
|
| 204 |
+
if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
|
| 205 |
+
pybind11_strip(${target_name})
|
| 206 |
+
endif()
|
| 207 |
+
|
| 208 |
+
if(MSVC)
|
| 209 |
+
target_link_libraries(${target_name} PRIVATE pybind11::windows_extras)
|
| 210 |
+
endif()
|
| 211 |
+
|
| 212 |
+
if(ARG_OPT_SIZE)
|
| 213 |
+
target_link_libraries(${target_name} PRIVATE pybind11::opt_size)
|
| 214 |
+
endif()
|
| 215 |
+
endfunction()
|
| 216 |
+
|
| 217 |
+
# Provide general way to call common Python commands in "common" file.
|
| 218 |
+
set(_Python
|
| 219 |
+
PYTHON
|
| 220 |
+
CACHE INTERNAL "" FORCE)
|
third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/pyproject.toml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[build-system]
|
| 2 |
+
requires = ["setuptools>=42", "wheel"]
|
| 3 |
+
build-backend = "setuptools.build_meta"
|
third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/setup_global.py.in
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
|
| 4 |
+
# Setup script for pybind11-global (in the sdist or in tools/setup_global.py in the repository)
|
| 5 |
+
# This package is targeted for easy use from CMake.
|
| 6 |
+
|
| 7 |
+
import contextlib
|
| 8 |
+
import glob
|
| 9 |
+
import os
|
| 10 |
+
import re
|
| 11 |
+
import shutil
|
| 12 |
+
import subprocess
|
| 13 |
+
import sys
|
| 14 |
+
import tempfile
|
| 15 |
+
|
| 16 |
+
# Setuptools has to be before distutils
|
| 17 |
+
from setuptools import setup
|
| 18 |
+
|
| 19 |
+
from distutils.command.install_headers import install_headers
|
| 20 |
+
|
| 21 |
+
class InstallHeadersNested(install_headers):
|
| 22 |
+
def run(self):
|
| 23 |
+
headers = self.distribution.headers or []
|
| 24 |
+
for header in headers:
|
| 25 |
+
# Remove pybind11/include/
|
| 26 |
+
short_header = header.split("/", 2)[-1]
|
| 27 |
+
|
| 28 |
+
dst = os.path.join(self.install_dir, os.path.dirname(short_header))
|
| 29 |
+
self.mkpath(dst)
|
| 30 |
+
(out, _) = self.copy_file(header, dst)
|
| 31 |
+
self.outfiles.append(out)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
main_headers = glob.glob("pybind11/include/pybind11/*.h")
|
| 35 |
+
detail_headers = glob.glob("pybind11/include/pybind11/detail/*.h")
|
| 36 |
+
stl_headers = glob.glob("pybind11/include/pybind11/stl/*.h")
|
| 37 |
+
cmake_files = glob.glob("pybind11/share/cmake/pybind11/*.cmake")
|
| 38 |
+
headers = main_headers + detail_headers + stl_headers
|
| 39 |
+
|
| 40 |
+
cmdclass = {"install_headers": InstallHeadersNested}
|
| 41 |
+
$extra_cmd
|
| 42 |
+
|
| 43 |
+
# This will _not_ affect installing from wheels,
|
| 44 |
+
# only building wheels or installing from SDist.
|
| 45 |
+
# Primarily intended on Windows, where this is sometimes
|
| 46 |
+
# customized (for example, conda-forge uses Library/)
|
| 47 |
+
base = os.environ.get("PYBIND11_GLOBAL_PREFIX", "")
|
| 48 |
+
|
| 49 |
+
# Must have a separator
|
| 50 |
+
if base and not base.endswith("/"):
|
| 51 |
+
base += "/"
|
| 52 |
+
|
| 53 |
+
setup(
|
| 54 |
+
name="pybind11_global",
|
| 55 |
+
version="$version",
|
| 56 |
+
packages=[],
|
| 57 |
+
headers=headers,
|
| 58 |
+
data_files=[
|
| 59 |
+
(base + "share/cmake/pybind11", cmake_files),
|
| 60 |
+
(base + "include/pybind11", main_headers),
|
| 61 |
+
(base + "include/pybind11/detail", detail_headers),
|
| 62 |
+
(base + "include/pybind11/stl", stl_headers),
|
| 63 |
+
],
|
| 64 |
+
cmdclass=cmdclass,
|
| 65 |
+
)
|
third-party/DPVO/Pangolin/components/pango_python/pybind11/tools/setup_main.py.in
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
|
| 4 |
+
# Setup script (in the sdist or in tools/setup_main.py in the repository)
|
| 5 |
+
|
| 6 |
+
from setuptools import setup
|
| 7 |
+
|
| 8 |
+
cmdclass = {}
|
| 9 |
+
$extra_cmd
|
| 10 |
+
|
| 11 |
+
setup(
|
| 12 |
+
name="pybind11",
|
| 13 |
+
version="$version",
|
| 14 |
+
download_url='https://github.com/pybind/pybind11/tarball/v$version',
|
| 15 |
+
packages=[
|
| 16 |
+
"pybind11",
|
| 17 |
+
"pybind11.include.pybind11",
|
| 18 |
+
"pybind11.include.pybind11.detail",
|
| 19 |
+
"pybind11.include.pybind11.stl",
|
| 20 |
+
"pybind11.share.cmake.pybind11",
|
| 21 |
+
],
|
| 22 |
+
package_data={
|
| 23 |
+
"pybind11": ["py.typed", "*.pyi"],
|
| 24 |
+
"pybind11.include.pybind11": ["*.h"],
|
| 25 |
+
"pybind11.include.pybind11.detail": ["*.h"],
|
| 26 |
+
"pybind11.include.pybind11.stl": ["*.h"],
|
| 27 |
+
"pybind11.share.cmake.pybind11": ["*.cmake"],
|
| 28 |
+
},
|
| 29 |
+
extras_require={
|
| 30 |
+
"global": ["pybind11_global==$version"]
|
| 31 |
+
},
|
| 32 |
+
entry_points={
|
| 33 |
+
"console_scripts": [
|
| 34 |
+
"pybind11-config = pybind11.__main__:main",
|
| 35 |
+
],
|
| 36 |
+
"pipx.run": [
|
| 37 |
+
"pybind11 = pybind11.__main__:main",
|
| 38 |
+
]
|
| 39 |
+
},
|
| 40 |
+
cmdclass=cmdclass
|
| 41 |
+
)
|
third-party/DPVO/Pangolin/components/pango_python/src/pyinterpreter.cpp
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) 2011 Steven Lovegrove
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
#include <pangolin/python/pyinterpreter.h>
|
| 28 |
+
#include <pangolin/utils/file_utils.h>
|
| 29 |
+
#include <pangolin/var/varextra.h>
|
| 30 |
+
#include <pangolin/factory/factory_registry.h>
|
| 31 |
+
|
| 32 |
+
#include <pybind11/embed.h>
|
| 33 |
+
namespace py = pybind11;
|
| 34 |
+
|
| 35 |
+
#include "pypangolin/pypangoio.h"
|
| 36 |
+
|
| 37 |
+
namespace pangolin
|
| 38 |
+
{
|
| 39 |
+
|
| 40 |
+
void PyInterpreter::NewVarCallback(const pangolin::VarState::Event& e)
|
| 41 |
+
{
|
| 42 |
+
if(e.action == VarState::Event::Action::Added) {
|
| 43 |
+
const std::string name = e.var->Meta().full_name;
|
| 44 |
+
const size_t dot = name.find_first_of('.');
|
| 45 |
+
if(dot != std::string::npos) {
|
| 46 |
+
const std::string base_prefix = name.substr(0,dot);
|
| 47 |
+
if( base_prefixes.find(base_prefix) == base_prefixes.end() ) {
|
| 48 |
+
base_prefixes.insert(base_prefix);
|
| 49 |
+
std::string cmd =
|
| 50 |
+
base_prefix + std::string(" = pypangolin.Var('") +
|
| 51 |
+
base_prefix + std::string("')\n");
|
| 52 |
+
PyRun_SimpleString(cmd.c_str());
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
PyInterpreter::PyInterpreter()
|
| 59 |
+
{
|
| 60 |
+
using namespace py_pangolin;
|
| 61 |
+
auto pypangolin = py::module_::import("pypangolin");
|
| 62 |
+
|
| 63 |
+
auto sys = py::module_::import("sys");
|
| 64 |
+
if(sys) {
|
| 65 |
+
// TODO: What is the lifetime of PyPangoIO?
|
| 66 |
+
PyPangoIO* wrap_stdout = new PyPangoIO(line_queue, ConsoleLineTypeStdout);
|
| 67 |
+
PyPangoIO* wrap_stderr = new PyPangoIO(line_queue, ConsoleLineTypeStderr);
|
| 68 |
+
sys.add_object("stdout", py::cast(wrap_stdout), true);
|
| 69 |
+
sys.add_object("stderr", py::cast(wrap_stderr), true);
|
| 70 |
+
} else {
|
| 71 |
+
pango_print_error("Couldn't import module sys.\n");
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
// Attempt to setup readline completion
|
| 75 |
+
py::exec(
|
| 76 |
+
"import pypangolin\n"
|
| 77 |
+
"try:\n"
|
| 78 |
+
" import readline\n"
|
| 79 |
+
"except ImportError:\n"
|
| 80 |
+
" import pyreadline as readline\n"
|
| 81 |
+
"\n"
|
| 82 |
+
"import rlcompleter\n"
|
| 83 |
+
"pypangolin.completer = rlcompleter.Completer()\n"
|
| 84 |
+
);
|
| 85 |
+
CheckPrintClearError();
|
| 86 |
+
|
| 87 |
+
// Get reference to rlcompleter.Completer() for tab-completion
|
| 88 |
+
pycompleter = pypangolin.attr("completer");
|
| 89 |
+
pycomplete = pycompleter.attr("complete");
|
| 90 |
+
|
| 91 |
+
// Register for notifications on var additions
|
| 92 |
+
var_added_connection = VarState::I().RegisterForVarEvents(
|
| 93 |
+
std::bind(&PyInterpreter::NewVarCallback,this,std::placeholders::_1),
|
| 94 |
+
true
|
| 95 |
+
);
|
| 96 |
+
|
| 97 |
+
CheckPrintClearError();
|
| 98 |
+
|
| 99 |
+
// TODO: For some reason the completion will crash when the command contains '.'
|
| 100 |
+
// unless we have executed anything that returns a value...
|
| 101 |
+
// We probably have a PyRef issue, maybe?
|
| 102 |
+
py::eval<py::eval_single_statement>("import sys");
|
| 103 |
+
py::eval<py::eval_single_statement>("sys.version");
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
PyInterpreter::~PyInterpreter()
|
| 107 |
+
{
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
std::string PyInterpreter::ToString(const py::object& py)
|
| 111 |
+
{
|
| 112 |
+
auto pystr = py::repr(py);
|
| 113 |
+
return std::string(PyUnicode_AsUTF8(pystr.ptr()));
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
void PyInterpreter::CheckPrintClearError()
|
| 117 |
+
{
|
| 118 |
+
if(PyErr_Occurred()) {
|
| 119 |
+
PyErr_Print();
|
| 120 |
+
PyErr_Clear();
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
py::object PyInterpreter::EvalExec(const std::string& cmd)
|
| 125 |
+
{
|
| 126 |
+
py::object ret = py::none();
|
| 127 |
+
|
| 128 |
+
if(!cmd.empty()) {
|
| 129 |
+
try {
|
| 130 |
+
ret = py::eval(cmd);
|
| 131 |
+
} catch (const pybind11::error_already_set& e) {
|
| 132 |
+
line_queue.push(
|
| 133 |
+
InterpreterLine(e.what(), ConsoleLineTypeStderr)
|
| 134 |
+
);
|
| 135 |
+
}
|
| 136 |
+
CheckPrintClearError();
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
return ret;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
std::vector<std::string> PyInterpreter::Complete(const std::string& cmd, int max_options)
|
| 143 |
+
{
|
| 144 |
+
// TODO: When there is exactly 1 completion and it is smaller than our current string, we must invoke again with the prefix removed.
|
| 145 |
+
|
| 146 |
+
std::vector<std::string> ret;
|
| 147 |
+
PyErr_Clear();
|
| 148 |
+
|
| 149 |
+
if(pycomplete) {
|
| 150 |
+
for(int i=0; i < max_options; ++i) {
|
| 151 |
+
auto args = PyTuple_Pack( 2, PyUnicode_FromString(cmd.c_str()), PyLong_FromSize_t(i) );
|
| 152 |
+
auto result = PyObject_CallObject(pycomplete.ptr(), args);
|
| 153 |
+
|
| 154 |
+
if (result && PyUnicode_Check(result)) {
|
| 155 |
+
std::string res_str(PyUnicode_AsUTF8(result));
|
| 156 |
+
ret.push_back( res_str );
|
| 157 |
+
Py_DecRef(args);
|
| 158 |
+
Py_DecRef(result);
|
| 159 |
+
}else{
|
| 160 |
+
Py_DecRef(args);
|
| 161 |
+
Py_DecRef(result);
|
| 162 |
+
break;
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
return ret;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
void PyInterpreter::PushCommand(const std::string& cmd)
|
| 171 |
+
{
|
| 172 |
+
if(!cmd.empty()) {
|
| 173 |
+
try {
|
| 174 |
+
py::eval<py::eval_single_statement>(cmd);
|
| 175 |
+
} catch (const pybind11::error_already_set& e) {
|
| 176 |
+
line_queue.push(
|
| 177 |
+
InterpreterLine(e.what(), ConsoleLineTypeStderr)
|
| 178 |
+
);
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
bool PyInterpreter::PullLine(InterpreterLine& line)
|
| 184 |
+
{
|
| 185 |
+
if(line_queue.size()) {
|
| 186 |
+
line = line_queue.front();
|
| 187 |
+
line_queue.pop();
|
| 188 |
+
return true;
|
| 189 |
+
}else{
|
| 190 |
+
return false;
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
PANGOLIN_REGISTER_FACTORY_WITH_STATIC_INITIALIZER(PyInterpreter)
|
| 195 |
+
{
|
| 196 |
+
struct PyInterpreterFactory final : public TypedFactoryInterface<InterpreterInterface> {
|
| 197 |
+
std::map<std::string,Precedence> Schemes() const override
|
| 198 |
+
{
|
| 199 |
+
return {{"python",10}};
|
| 200 |
+
}
|
| 201 |
+
const char* Description() const override
|
| 202 |
+
{
|
| 203 |
+
return "Python line interpreter.";
|
| 204 |
+
}
|
| 205 |
+
ParamSet Params() const override
|
| 206 |
+
{
|
| 207 |
+
return {{}};
|
| 208 |
+
}
|
| 209 |
+
std::unique_ptr<InterpreterInterface> Open(const Uri& /*uri*/) override {
|
| 210 |
+
return std::unique_ptr<InterpreterInterface>(new PyInterpreter());
|
| 211 |
+
}
|
| 212 |
+
};
|
| 213 |
+
|
| 214 |
+
return FactoryRegistry::I()->RegisterFactory<InterpreterInterface>(std::make_shared<PyInterpreterFactory>());
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
}
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/attach.cpp
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "attach.hpp"
|
| 29 |
+
#include <pangolin/gl/glinclude.h>
|
| 30 |
+
#include <pangolin/display/attach.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
void bind_attach(pybind11::module &m){
|
| 34 |
+
pybind11::enum_<pangolin::Unit>(m, "Unit")
|
| 35 |
+
.value("Fraction", pangolin::Unit::Fraction)
|
| 36 |
+
.value("Pixel", pangolin::Unit::Pixel)
|
| 37 |
+
.value("ReversePixel", pangolin::Unit::ReversePixel)
|
| 38 |
+
.export_values();
|
| 39 |
+
|
| 40 |
+
pybind11::class_<pangolin::Attach>(m, "Attach")
|
| 41 |
+
.def(pybind11::init<>())
|
| 42 |
+
.def(pybind11::init<pangolin::Unit, GLfloat>())
|
| 43 |
+
.def(pybind11::init<GLfloat>())
|
| 44 |
+
.def_static("Pix", &pangolin::Attach::Pix)
|
| 45 |
+
.def_static("ReversePix", &pangolin::Attach::ReversePix)
|
| 46 |
+
.def_static("Frac", &pangolin::Attach::Frac);
|
| 47 |
+
}
|
| 48 |
+
}
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/attach.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_attach(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/colour.cpp
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "colour.hpp"
|
| 29 |
+
#include <pangolin/gl/colour.h>
|
| 30 |
+
|
| 31 |
+
namespace py_pangolin {
|
| 32 |
+
|
| 33 |
+
void bind_colour(pybind11::module& m){
|
| 34 |
+
pybind11::class_<pangolin::Colour> (m, "Colour")
|
| 35 |
+
.def(pybind11::init<>())
|
| 36 |
+
.def(pybind11::init<const float, const float, const float, const float>(), pybind11::arg("red"), pybind11::arg("green"), pybind11::arg("blue"), pybind11::arg("alpha")=1.0f)
|
| 37 |
+
// .def(pybind11::init<float[4]>())
|
| 38 |
+
.def("Get", &pangolin::Colour::Get)
|
| 39 |
+
.def_static("White", &pangolin::Colour::White)
|
| 40 |
+
.def_static("Black", &pangolin::Colour::Black)
|
| 41 |
+
.def_static("Red", &pangolin::Colour::Red)
|
| 42 |
+
.def_static("Green", &pangolin::Colour::Green)
|
| 43 |
+
.def_static("Blue", &pangolin::Colour::Blue)
|
| 44 |
+
.def_static("Hsv", &pangolin::Colour::Hsv)
|
| 45 |
+
.def("WithAlpha", &pangolin::Colour::WithAlpha);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/colour.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_colour(pybind11::module& m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/datalog.cpp
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "datalog.hpp"
|
| 29 |
+
|
| 30 |
+
#include <pybind11/stl.h>
|
| 31 |
+
#include <pangolin/plot/datalog.h>
|
| 32 |
+
|
| 33 |
+
namespace py_pangolin {
|
| 34 |
+
|
| 35 |
+
void bind_datalog(pybind11::module& m){
|
| 36 |
+
pybind11::class_<pangolin::DimensionStats >(m, "DimensionStats")
|
| 37 |
+
.def(pybind11::init<>())
|
| 38 |
+
.def("Reset", &pangolin::DimensionStats::Reset)
|
| 39 |
+
.def("Add", &pangolin::DimensionStats::Add)
|
| 40 |
+
.def_readwrite("isMonotonic", &pangolin::DimensionStats::isMonotonic)
|
| 41 |
+
.def_readwrite("sum", &pangolin::DimensionStats::sum)
|
| 42 |
+
.def_readwrite("sum_sq", &pangolin::DimensionStats::sum_sq)
|
| 43 |
+
.def_readwrite("min", &pangolin::DimensionStats::min)
|
| 44 |
+
.def_readwrite("max", &pangolin::DimensionStats::max);
|
| 45 |
+
|
| 46 |
+
pybind11::class_<pangolin::DataLogBlock>(m, "DataLogBlock")
|
| 47 |
+
.def(pybind11::init<size_t,size_t,size_t>())
|
| 48 |
+
.def("Samples", &pangolin::DataLogBlock::Samples)
|
| 49 |
+
.def("MaxSamples", &pangolin::DataLogBlock::MaxSamples)
|
| 50 |
+
.def("SampleSpaceLeft", &pangolin::DataLogBlock::SampleSpaceLeft)
|
| 51 |
+
.def("IsFull", &pangolin::DataLogBlock::IsFull)
|
| 52 |
+
.def("AddSamples", &pangolin::DataLogBlock::AddSamples)
|
| 53 |
+
.def("ClearLinked", &pangolin::DataLogBlock::ClearLinked)
|
| 54 |
+
.def("NextBlock", &pangolin::DataLogBlock::NextBlock)
|
| 55 |
+
.def("StartId", &pangolin::DataLogBlock::StartId)
|
| 56 |
+
.def("DimData", &pangolin::DataLogBlock::DimData)
|
| 57 |
+
.def("Dimensions", &pangolin::DataLogBlock::Dimensions)
|
| 58 |
+
.def("Sample", &pangolin::DataLogBlock::Sample)
|
| 59 |
+
.def("StartId", &pangolin::DataLogBlock::StartId);
|
| 60 |
+
|
| 61 |
+
pybind11::class_<pangolin::DataLog>(m, "DataLog")
|
| 62 |
+
.def(pybind11::init<unsigned int>(), pybind11::arg("block_samples_alloc")=10000)
|
| 63 |
+
.def("SetLabels", &pangolin::DataLog::SetLabels)
|
| 64 |
+
.def("Labels", &pangolin::DataLog::Labels)
|
| 65 |
+
.def("Log", (void (pangolin::DataLog::*)(size_t, const float*, unsigned int))&pangolin::DataLog::Log, pybind11::arg("dimension"), pybind11::arg("vals"), pybind11::arg("samples")=1)
|
| 66 |
+
.def("Log", (void (pangolin::DataLog::*)(float))&pangolin::DataLog::Log)
|
| 67 |
+
.def("Log", (void (pangolin::DataLog::*)(float, float))&pangolin::DataLog::Log)
|
| 68 |
+
.def("Log", (void (pangolin::DataLog::*)(float, float, float))&pangolin::DataLog::Log)
|
| 69 |
+
.def("Log", (void (pangolin::DataLog::*)(float, float, float, float))&pangolin::DataLog::Log)
|
| 70 |
+
.def("Log", (void (pangolin::DataLog::*)(float, float, float, float, float))&pangolin::DataLog::Log)
|
| 71 |
+
.def("Log", (void (pangolin::DataLog::*)(float, float, float, float, float, float))&pangolin::DataLog::Log)
|
| 72 |
+
.def("Log", (void (pangolin::DataLog::*)(float, float, float, float, float, float, float))&pangolin::DataLog::Log)
|
| 73 |
+
.def("Log", (void (pangolin::DataLog::*)(float, float, float, float, float, float, float, float))&pangolin::DataLog::Log)
|
| 74 |
+
.def("Log", (void (pangolin::DataLog::*)(float, float, float, float, float, float, float, float, float))&pangolin::DataLog::Log)
|
| 75 |
+
.def("Log", (void (pangolin::DataLog::*)(float, float, float, float, float, float, float, float, float, float))&pangolin::DataLog::Log)
|
| 76 |
+
.def("Log", (void (pangolin::DataLog::*)(const std::vector<float>&))&pangolin::DataLog::Log)
|
| 77 |
+
.def("Clear", &pangolin::DataLog::Clear)
|
| 78 |
+
.def("Save", &pangolin::DataLog::Save)
|
| 79 |
+
.def("FirstBlock", &pangolin::DataLog::FirstBlock)
|
| 80 |
+
.def("LastBlock", &pangolin::DataLog::LastBlock)
|
| 81 |
+
.def("Samples", &pangolin::DataLog::Samples)
|
| 82 |
+
.def("Sample", &pangolin::DataLog::Sample)
|
| 83 |
+
.def("Stats", &pangolin::DataLog::Stats);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/datalog.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_datalog(pybind11::module& m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/display.cpp
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "display.hpp"
|
| 29 |
+
#include <pangolin/display/display.h>
|
| 30 |
+
#include <pangolin/display/view.h>
|
| 31 |
+
#include <pybind11/functional.h>
|
| 32 |
+
|
| 33 |
+
namespace py_pangolin {
|
| 34 |
+
|
| 35 |
+
void bind_display(pybind11::module &m) {
|
| 36 |
+
m.def("CreateWindowAndBind",
|
| 37 |
+
&pangolin::CreateWindowAndBind,
|
| 38 |
+
pybind11::return_value_policy::reference,
|
| 39 |
+
pybind11::arg("window_title"),
|
| 40 |
+
pybind11::arg("w") = 640,
|
| 41 |
+
pybind11::arg("h") = 480,
|
| 42 |
+
pybind11::arg("params") = pangolin::Params());
|
| 43 |
+
|
| 44 |
+
m.def("DestroyWindow",
|
| 45 |
+
&pangolin::DestroyWindow,
|
| 46 |
+
pybind11::arg("window_title"));
|
| 47 |
+
|
| 48 |
+
m.def("CreateDisplay",
|
| 49 |
+
&pangolin::CreateDisplay,
|
| 50 |
+
pybind11::return_value_policy::reference);
|
| 51 |
+
|
| 52 |
+
m.def("ShouldQuit",
|
| 53 |
+
&pangolin::ShouldQuit);
|
| 54 |
+
|
| 55 |
+
m.def("FinishFrame",
|
| 56 |
+
&pangolin::FinishFrame);
|
| 57 |
+
|
| 58 |
+
m.def("ShowFullscreen",
|
| 59 |
+
&pangolin::ShowFullscreen);
|
| 60 |
+
|
| 61 |
+
m.def("ShowConsole",
|
| 62 |
+
&pangolin::ShowConsole);
|
| 63 |
+
|
| 64 |
+
m.def("RegisterKeyPressCallback",
|
| 65 |
+
[](int v, const std::function<void()>& f){
|
| 66 |
+
pangolin::RegisterKeyPressCallback(v, f);
|
| 67 |
+
}
|
| 68 |
+
);
|
| 69 |
+
|
| 70 |
+
m.def("DisplayBase",
|
| 71 |
+
&pangolin::DisplayBase,
|
| 72 |
+
pybind11::return_value_policy::reference);
|
| 73 |
+
|
| 74 |
+
m.def("Display",
|
| 75 |
+
&pangolin::Display,
|
| 76 |
+
pybind11::return_value_policy::reference,
|
| 77 |
+
pybind11::arg("name"));
|
| 78 |
+
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
} // Py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/display.hpp
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_display(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/gl.cpp
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "gl.hpp"
|
| 29 |
+
#include <pangolin/gl/gl.h>
|
| 30 |
+
#include <pybind11/numpy.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
bool is_packed(const pybind11::buffer_info & info) {
|
| 35 |
+
int next_expected_stride = info.itemsize;
|
| 36 |
+
for (int i = info.ndim-1; i >= 0; --i) {
|
| 37 |
+
if (!(info.strides[i] == next_expected_stride)) {
|
| 38 |
+
return false;
|
| 39 |
+
}
|
| 40 |
+
next_expected_stride *= info.shape[i];
|
| 41 |
+
}
|
| 42 |
+
return true;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
void bind_gl(pybind11::module &m) {
|
| 46 |
+
|
| 47 |
+
pybind11::class_<pangolin::GlTexture>(m, "GlTexture")
|
| 48 |
+
.def(pybind11::init<>())
|
| 49 |
+
.def(pybind11::init<GLint, GLint, GLint, bool, int, GLenum, GLenum>(), pybind11::arg("width"), pybind11::arg("height"), pybind11::arg("internal_format") = GL_RGBA8, pybind11::arg("sampling_linear") = true, pybind11::arg("border") = 0, pybind11::arg("glformat") = GL_RGBA, pybind11::arg("gltype") = GL_UNSIGNED_BYTE)
|
| 50 |
+
.def("Reinitialise", &pangolin::GlTexture::Reinitialise)
|
| 51 |
+
.def("Bind", &pangolin::GlTexture::Bind)
|
| 52 |
+
.def("Unbind", &pangolin::GlTexture::Unbind)
|
| 53 |
+
.def("Upload", [](pangolin::GlTexture & texture, pybind11::buffer b, GLenum data_format, GLenum type){
|
| 54 |
+
pybind11::buffer_info info = b.request();
|
| 55 |
+
texture.Upload(info.ptr, data_format, type);
|
| 56 |
+
})
|
| 57 |
+
.def("Download", [](pangolin::GlTexture & texture, pybind11::buffer b, GLenum data_layout, GLenum data_type) {
|
| 58 |
+
pybind11::buffer_info info = b.request();
|
| 59 |
+
if (!is_packed(info)) {
|
| 60 |
+
throw std::runtime_error("cannot Download into non-packed buffer");
|
| 61 |
+
}
|
| 62 |
+
texture.Download(info.ptr, data_layout, data_type);
|
| 63 |
+
})
|
| 64 |
+
.def("Save", &pangolin::GlTexture::Save, pybind11::arg("filename"), pybind11::arg("top_line_first")=true)
|
| 65 |
+
.def("RenderToViewport", (void (pangolin::GlTexture::*)() const)&pangolin::GlTexture::RenderToViewport)
|
| 66 |
+
.def("RenderToViewportFlipY", &pangolin::GlTexture::RenderToViewportFlipY)
|
| 67 |
+
.def("SetNearestNeighbour", &pangolin::GlTexture::SetNearestNeighbour)
|
| 68 |
+
.def_readonly("width", &pangolin::GlTexture::width)
|
| 69 |
+
.def_readonly("height", &pangolin::GlTexture::height)
|
| 70 |
+
.def_readonly("id", &pangolin::GlTexture::tid);
|
| 71 |
+
|
| 72 |
+
pybind11::class_<pangolin::GlRenderBuffer>(m, "GlRenderBuffer")
|
| 73 |
+
.def(pybind11::init<GLint, GLint, GLint>(), pybind11::arg("width")=0, pybind11::arg("height")=0, pybind11::arg("internal_format") = GL_DEPTH_COMPONENT24)
|
| 74 |
+
.def("Reinitialise", &pangolin::GlRenderBuffer::Reinitialise);
|
| 75 |
+
|
| 76 |
+
pybind11::class_<pangolin::GlFramebuffer>(m, "GlFramebuffer")
|
| 77 |
+
.def(pybind11::init<>())
|
| 78 |
+
.def(pybind11::init<pangolin::GlTexture &, pangolin::GlRenderBuffer &>())
|
| 79 |
+
.def("Reinitialise", &pangolin::GlFramebuffer::Reinitialise)
|
| 80 |
+
.def("AttachColour", &pangolin::GlFramebuffer::AttachColour)
|
| 81 |
+
.def("AttachDepth", &pangolin::GlFramebuffer::AttachDepth)
|
| 82 |
+
.def("Bind", &pangolin::GlFramebuffer::Bind)
|
| 83 |
+
.def("Unbind", &pangolin::GlFramebuffer::Unbind);
|
| 84 |
+
|
| 85 |
+
pybind11::enum_<pangolin::GlBufferType>(m, "GlBufferType")
|
| 86 |
+
.value("GlUndefined", pangolin::GlBufferType::GlUndefined)
|
| 87 |
+
.value("GlArrayBuffer", pangolin::GlBufferType::GlArrayBuffer)
|
| 88 |
+
.value("GlElementArrayBuffer", pangolin::GlBufferType::GlElementArrayBuffer)
|
| 89 |
+
#ifndef HAVE_GLES
|
| 90 |
+
.value("GlPixelPackBuffer", pangolin::GlBufferType::GlPixelPackBuffer)
|
| 91 |
+
.value("GlPixelUnpackBuffer", pangolin::GlBufferType::GlPixelUnpackBuffer)
|
| 92 |
+
.value("GlShaderStorageBuffer", pangolin::GlBufferType::GlShaderStorageBuffer)
|
| 93 |
+
#endif
|
| 94 |
+
.export_values();
|
| 95 |
+
|
| 96 |
+
pybind11::class_<pangolin::GlBufferData>(m, "GlBufferData")
|
| 97 |
+
.def(pybind11::init<>())
|
| 98 |
+
.def("Reinitialise", [](pangolin::GlBufferData & gl_buffer, pangolin::GlBufferType buffer_type, GLuint size_bytes, GLenum gl_use) {
|
| 99 |
+
gl_buffer.Reinitialise(buffer_type, size_bytes, gl_use);
|
| 100 |
+
})
|
| 101 |
+
.def("Bind", &pangolin::GlBufferData::Bind)
|
| 102 |
+
.def("Unbind", &pangolin::GlBufferData::Unbind)
|
| 103 |
+
.def("Upload", [](pangolin::GlBufferData & gl_buffer, pybind11::buffer b, GLsizeiptr size_bytes, GLintptr offset) {
|
| 104 |
+
pybind11::buffer_info info = b.request();
|
| 105 |
+
gl_buffer.Upload(info.ptr, size_bytes, offset);
|
| 106 |
+
}, pybind11::arg("data"), pybind11::arg("size_bytes"), pybind11::arg("offset")=0)
|
| 107 |
+
.def_readwrite("size_bytes", &pangolin::GlBufferData::size_bytes);
|
| 108 |
+
|
| 109 |
+
pybind11::class_<pangolin::GlBuffer, pangolin::GlBufferData>(m, "GlBuffer")
|
| 110 |
+
.def(pybind11::init<>())
|
| 111 |
+
.def(pybind11::init<pangolin::GlBufferType, GLuint, GLenum, GLuint, GLenum>(), pybind11::arg("buffer_type"), pybind11::arg("num_elements"), pybind11::arg("datatype"), pybind11::arg("count_per_element"), pybind11::arg("gluse")=GL_DYNAMIC_DRAW)
|
| 112 |
+
.def("Resize", &pangolin::GlBuffer::Resize, pybind11::arg("num_elements"))
|
| 113 |
+
.def_readwrite("num_elements", &pangolin::GlBuffer::num_elements)
|
| 114 |
+
.def_readwrite("count_per_element", &pangolin::GlBuffer::count_per_element);
|
| 115 |
+
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
} // namespace py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/gl.hpp
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_gl(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/gl_draw.cpp
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "gl_draw.hpp"
|
| 29 |
+
#include <pangolin/gl/gldraw.h>
|
| 30 |
+
#include <pybind11/eigen.h>
|
| 31 |
+
#include <pybind11/stl.h>
|
| 32 |
+
|
| 33 |
+
namespace py_pangolin {
|
| 34 |
+
|
| 35 |
+
void bind_gl_draw(pybind11::module &m){
|
| 36 |
+
|
| 37 |
+
m.def("glDrawAxis",
|
| 38 |
+
(void (*)(float))&pangolin::glDrawAxis);
|
| 39 |
+
|
| 40 |
+
m.def("glDrawColouredCube",
|
| 41 |
+
&pangolin::glDrawColouredCube,
|
| 42 |
+
pybind11::arg("axis_min") = -0.5f,
|
| 43 |
+
pybind11::arg("axis_max") = +0.5f);
|
| 44 |
+
|
| 45 |
+
m.def("glDraw_x0",
|
| 46 |
+
&pangolin::glDraw_x0);
|
| 47 |
+
m.def("glDraw_y0",
|
| 48 |
+
&pangolin::glDraw_y0);
|
| 49 |
+
m.def("glDraw_z0",
|
| 50 |
+
&pangolin::glDraw_z0);
|
| 51 |
+
|
| 52 |
+
m.def("glDrawFrustum", (void (*)(GLfloat, GLfloat, GLfloat, GLfloat, int, int, GLfloat)) &pangolin::glDrawFrustum);
|
| 53 |
+
m.def("glDrawFrustum", (void (*)(const Eigen::Matrix3f &, int, int, GLfloat)) &pangolin::glDrawFrustum<float>);
|
| 54 |
+
m.def("glDrawFrustum", (void (*)(const Eigen::Matrix3d &, int, int, GLfloat)) &pangolin::glDrawFrustum<double>);
|
| 55 |
+
m.def("glDrawFrustum", (void (*)(const Eigen::Matrix3f &, int, int, const Eigen::Matrix4f &, float)) &pangolin::glDrawFrustum<float>);
|
| 56 |
+
m.def("glDrawFrustum", (void (*)(const Eigen::Matrix3d &, int, int, const Eigen::Matrix4d &, double)) &pangolin::glDrawFrustum<double>);
|
| 57 |
+
|
| 58 |
+
m.def("glDrawTexture", (void (*)(GLenum, GLint)) &pangolin::glDrawTexture);
|
| 59 |
+
m.def("glDrawTextureFlipY", (void (*)(GLenum, GLint)) &pangolin::glDrawTextureFlipY);
|
| 60 |
+
|
| 61 |
+
m.def("glDrawAxis", (void (*)(float)) &pangolin::glDrawAxis);
|
| 62 |
+
m.def("glDrawAxis", (void (*)(const Eigen::Matrix4f &, float)) &pangolin::glDrawAxis<Eigen::Matrix4f, float>);
|
| 63 |
+
m.def("glDrawAxis", (void (*)(const Eigen::Matrix4d &, float)) &pangolin::glDrawAxis<Eigen::Matrix4d, float>);
|
| 64 |
+
|
| 65 |
+
m.def("glSetFrameOfReference", (void (*)(const Eigen::Matrix4f &)) &pangolin::glSetFrameOfReference);
|
| 66 |
+
m.def("glSetFrameOfReference", (void (*)(const Eigen::Matrix4d &)) &pangolin::glSetFrameOfReference);
|
| 67 |
+
|
| 68 |
+
m.def("glUnsetFrameOfReference", &pangolin::glUnsetFrameOfReference);
|
| 69 |
+
|
| 70 |
+
m.def("glDrawVertices", &pangolin::glDrawPoints<float, 2, std::allocator<Eigen::Vector2f> >);
|
| 71 |
+
m.def("glDrawVertices", &pangolin::glDrawPoints<float, 3, std::allocator<Eigen::Vector3f> >);
|
| 72 |
+
m.def("glDrawVertices", &pangolin::glDrawPoints<double, 2, std::allocator<Eigen::Vector2d> >);
|
| 73 |
+
m.def("glDrawVertices", &pangolin::glDrawPoints<double, 3, std::allocator<Eigen::Vector3d> >);
|
| 74 |
+
|
| 75 |
+
m.def("glDrawPoints", &pangolin::glDrawPoints<float, 2, std::allocator<Eigen::Vector2f> >);
|
| 76 |
+
m.def("glDrawPoints", &pangolin::glDrawPoints<float, 3, std::allocator<Eigen::Vector3f> >);
|
| 77 |
+
m.def("glDrawPoints", &pangolin::glDrawPoints<double, 2, std::allocator<Eigen::Vector2d> >);
|
| 78 |
+
m.def("glDrawPoints", &pangolin::glDrawPoints<double, 3, std::allocator<Eigen::Vector3d> >);
|
| 79 |
+
|
| 80 |
+
m.def("glDrawLines", &pangolin::glDrawLines<float, 2, std::allocator<Eigen::Vector2f> >);
|
| 81 |
+
m.def("glDrawLines", &pangolin::glDrawLines<float, 3, std::allocator<Eigen::Vector3f> >);
|
| 82 |
+
m.def("glDrawLines", &pangolin::glDrawLines<double, 2, std::allocator<Eigen::Vector2d> >);
|
| 83 |
+
m.def("glDrawLines", &pangolin::glDrawLines<double, 3, std::allocator<Eigen::Vector3d> >);
|
| 84 |
+
|
| 85 |
+
m.def("glDrawLineStrip", &pangolin::glDrawLineStrip<float, 2, std::allocator<Eigen::Vector2f> >);
|
| 86 |
+
m.def("glDrawLineStrip", &pangolin::glDrawLineStrip<float, 3, std::allocator<Eigen::Vector3f> >);
|
| 87 |
+
m.def("glDrawLineStrip", &pangolin::glDrawLineStrip<double, 2, std::allocator<Eigen::Vector2d> >);
|
| 88 |
+
m.def("glDrawLineStrip", &pangolin::glDrawLineStrip<double, 3, std::allocator<Eigen::Vector3d> >);
|
| 89 |
+
|
| 90 |
+
m.def("glDrawLineLoop", &pangolin::glDrawLineLoop<float, 2, std::allocator<Eigen::Vector2f> >);
|
| 91 |
+
m.def("glDrawLineLoop", &pangolin::glDrawLineLoop<float, 3, std::allocator<Eigen::Vector3f> >);
|
| 92 |
+
m.def("glDrawLineLoop", &pangolin::glDrawLineLoop<double, 2, std::allocator<Eigen::Vector2d> >);
|
| 93 |
+
m.def("glDrawLineLoop", &pangolin::glDrawLineLoop<double, 3, std::allocator<Eigen::Vector3d> >);
|
| 94 |
+
|
| 95 |
+
m.def("glDrawAlignedBox", (void (*)(const Eigen::AlignedBox2f &, GLenum)) &pangolin::glDrawAlignedBox<float>, pybind11::arg("box"), pybind11::arg("mode") = GL_TRIANGLE_FAN);
|
| 96 |
+
|
| 97 |
+
m.def("glDrawCirclePerimeter", (void (*)(float, float, float)) &pangolin::glDrawCirclePerimeter);
|
| 98 |
+
m.def("glDrawCirclePerimeter", (void (*)(const Eigen::Vector2d &, double)) &pangolin::glDrawCirclePerimeter);
|
| 99 |
+
|
| 100 |
+
m.def("glDrawRectPerimeter", &pangolin::glDrawRectPerimeter);
|
| 101 |
+
|
| 102 |
+
m.def("glDrawCross", (void (*)(GLfloat, GLfloat, GLfloat)) &pangolin::glDrawCross);
|
| 103 |
+
m.def("glDrawCross", (void (*)(GLfloat, GLfloat, GLfloat, GLfloat)) &pangolin::glDrawCross);
|
| 104 |
+
m.def("glDrawCross", (void (*)(const Eigen::Vector2d &, double)) &pangolin::glDrawCross);
|
| 105 |
+
m.def("glDrawCross", (void (*)(const Eigen::Vector3d &, double)) &pangolin::glDrawCross);
|
| 106 |
+
|
| 107 |
+
m.def("glDrawCircle", (void (*)(float, float, float)) &pangolin::glDrawCircle);
|
| 108 |
+
m.def("glDrawCircle", (void (*)(const Eigen::Vector2d &, double)) &pangolin::glDrawCircle);
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/gl_draw.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_gl_draw(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/glsl.cpp
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "glsl.hpp"
|
| 29 |
+
#include <pangolin/gl/glsl.h>
|
| 30 |
+
#include <pybind11/eigen.h>
|
| 31 |
+
#include <pybind11/stl.h>
|
| 32 |
+
|
| 33 |
+
namespace py_pangolin {
|
| 34 |
+
|
| 35 |
+
void bind_glsl(pybind11::module &m) {
|
| 36 |
+
|
| 37 |
+
pybind11::enum_<pangolin::GlSlShaderType>(m, "GlSlShaderType")
|
| 38 |
+
.value("GlSlAnnotatedShader", pangolin::GlSlShaderType::GlSlAnnotatedShader)
|
| 39 |
+
.value("GlSlFragmentShader", pangolin::GlSlShaderType::GlSlFragmentShader)
|
| 40 |
+
.value("GlSlVertexShader", pangolin::GlSlShaderType::GlSlVertexShader)
|
| 41 |
+
.value("GlSlGeometryShader", pangolin::GlSlShaderType::GlSlGeometryShader)
|
| 42 |
+
.value("GlSlComputeShader", pangolin::GlSlShaderType::GlSlComputeShader)
|
| 43 |
+
.export_values();
|
| 44 |
+
|
| 45 |
+
pybind11::class_<pangolin::GlSlProgram>(m, "GlSlProgram")
|
| 46 |
+
.def(pybind11::init<>())
|
| 47 |
+
.def("AddShader", &pangolin::GlSlProgram::AddShader, pybind11::arg("shader_type"), pybind11::arg("filename"), pybind11::arg("program_defines")=std::map<std::string,std::string>(), pybind11::arg("search_path")=std::vector<std::string>())
|
| 48 |
+
.def("AddShaderFromFile", &pangolin::GlSlProgram::AddShaderFromFile)
|
| 49 |
+
.def("Link", &pangolin::GlSlProgram::Link)
|
| 50 |
+
.def("GetAttributeHandle", &pangolin::GlSlProgram::GetAttributeHandle)
|
| 51 |
+
.def("GetUniformHandle", &pangolin::GlSlProgram::GetUniformHandle)
|
| 52 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, int))&pangolin::GlSlProgram::SetUniform)
|
| 53 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, int, int))&pangolin::GlSlProgram::SetUniform)
|
| 54 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, int, int, int))&pangolin::GlSlProgram::SetUniform)
|
| 55 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, int, int, int, int))&pangolin::GlSlProgram::SetUniform)
|
| 56 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, float))&pangolin::GlSlProgram::SetUniform)
|
| 57 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, float, float))&pangolin::GlSlProgram::SetUniform)
|
| 58 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, float, float, float))&pangolin::GlSlProgram::SetUniform)
|
| 59 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, float, float, float, float))&pangolin::GlSlProgram::SetUniform)
|
| 60 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, const pangolin::OpenGlMatrix &))&pangolin::GlSlProgram::SetUniform)
|
| 61 |
+
#ifdef HAVE_EIGEN
|
| 62 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, const Eigen::Matrix3f &))&pangolin::GlSlProgram::SetUniform)
|
| 63 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, const Eigen::Matrix4f &))&pangolin::GlSlProgram::SetUniform)
|
| 64 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, const Eigen::Matrix3d &))&pangolin::GlSlProgram::SetUniform)
|
| 65 |
+
.def("SetUniform", (void (pangolin::GlSlProgram::*)(const std::string &, const Eigen::Matrix4d &))&pangolin::GlSlProgram::SetUniform)
|
| 66 |
+
#endif
|
| 67 |
+
.def("Bind", &pangolin::GlSlProgram::Bind)
|
| 68 |
+
.def("Unbind", &pangolin::GlSlProgram::Unbind);
|
| 69 |
+
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
}
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/glsl.hpp
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_glsl(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/glvbo.cpp
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "glvbo.hpp"
|
| 29 |
+
#include <pangolin/gl/glvbo.h>
|
| 30 |
+
|
| 31 |
+
namespace py_pangolin {
|
| 32 |
+
|
| 33 |
+
void bind_glvbo(pybind11::module &m){
|
| 34 |
+
|
| 35 |
+
m.def("MakeTriangleStripIboForVbo", (pangolin::GlBuffer (*)(int, int))&pangolin::MakeTriangleStripIboForVbo, pybind11::arg("w"), pybind11::arg("h"), pybind11::return_value_policy::move);
|
| 36 |
+
|
| 37 |
+
m.def("RenderVbo", (void(*)(pangolin::GlBuffer&, GLenum))&pangolin::RenderVbo, pybind11::arg("vbo"), pybind11::arg("mode")=GL_POINTS);
|
| 38 |
+
m.def("RenderVbo", (void(*)(pangolin::GlBuffer&, const GLuint, GLenum))&pangolin::RenderVbo, pybind11::arg("vbo"), pybind11::arg("count"), pybind11::arg("mode")=GL_POINTS);
|
| 39 |
+
m.def("RenderVboCbo", &pangolin::RenderVboCbo, pybind11::arg("vbo"), pybind11::arg("cbo"), pybind11::arg("draw_color")=true, pybind11::arg("mode")=GL_POINTS);
|
| 40 |
+
m.def("RenderVboIbo", &pangolin::RenderVboIbo, pybind11::arg("vbo"), pybind11::arg("ibo"), pybind11::arg("draw_mesh")=true);
|
| 41 |
+
m.def("RenderVboIboCbo", &pangolin::RenderVboIboCbo, pybind11::arg("vbo"), pybind11::arg("ibo"), pybind11::arg("cbo"), pybind11::arg("draw_mesh")=true, pybind11::arg("draw_color")=true);
|
| 42 |
+
m.def("RenderVboIboNbo", &pangolin::RenderVboIboNbo, pybind11::arg("vbo"), pybind11::arg("ibo"), pybind11::arg("nbo"), pybind11::arg("draw_mesh")=true, pybind11::arg("draw_normals")=true);
|
| 43 |
+
m.def("RenderVboIboCboNbo", &pangolin::RenderVboIboCboNbo, pybind11::arg("vbo"), pybind11::arg("ibo"), pybind11::arg("cbo"), pybind11::arg("nbo"), pybind11::arg("draw_mesh")=true, pybind11::arg("draw_color")=true, pybind11::arg("draw_normals")=true);
|
| 44 |
+
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/glvbo.hpp
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_glvbo(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/handler.cpp
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "handler.hpp"
|
| 29 |
+
#include <pangolin/handler/handler.h>
|
| 30 |
+
#include <pangolin/gl/opengl_render_state.h>
|
| 31 |
+
#include <pangolin/plot/plotter.h>
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
namespace py_pangolin {
|
| 35 |
+
|
| 36 |
+
void bind_handler(pybind11::module &m) {
|
| 37 |
+
|
| 38 |
+
pybind11::class_<pangolin::Handler, PyHandler> handler(m, "Handler");
|
| 39 |
+
handler
|
| 40 |
+
.def(pybind11::init<>())
|
| 41 |
+
.def("Keyboard", &pangolin::Handler::Keyboard)
|
| 42 |
+
.def("Mouse", &pangolin::Handler::Mouse)
|
| 43 |
+
.def("MouseMotion", &pangolin::Handler::MouseMotion)
|
| 44 |
+
.def("PassiveMouseMotion", &pangolin::Handler::PassiveMouseMotion)
|
| 45 |
+
.def("Special", &pangolin::Handler::Special);
|
| 46 |
+
|
| 47 |
+
pybind11::class_<pangolin::Handler3D>(m, "Handler3D", handler)
|
| 48 |
+
.def(pybind11::init<pangolin::OpenGlRenderState&, pangolin::AxisDirection, float, float>(), pybind11::arg("state"), pybind11::arg("enforce_up") = pangolin::AxisNone, pybind11::arg("trans_scale")=0.01f, pybind11::arg("zoom_factor")=PANGO_DFLT_HANDLER3D_ZF)
|
| 49 |
+
.def("ValidWinDepth", &pangolin::Handler3D::ValidWinDepth)
|
| 50 |
+
.def("PixelUnproject", &pangolin::Handler3D::PixelUnproject)
|
| 51 |
+
.def("GetPosNormal", &pangolin::Handler3D::GetPosNormal)
|
| 52 |
+
.def("Keyboard", &pangolin::Handler3D::Keyboard)
|
| 53 |
+
.def("Mouse", &pangolin::Handler3D::Mouse)
|
| 54 |
+
.def("MouseMotion", &pangolin::Handler3D::MouseMotion)
|
| 55 |
+
.def("Special", &pangolin::Handler3D::Special);
|
| 56 |
+
|
| 57 |
+
}
|
| 58 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/handler.hpp
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
#include <pangolin/handler/handler.h>
|
| 32 |
+
#include <pangolin/display/view.h>
|
| 33 |
+
|
| 34 |
+
namespace py_pangolin {
|
| 35 |
+
|
| 36 |
+
class PyHandler : public pangolin::Handler {
|
| 37 |
+
public:
|
| 38 |
+
using pangolin::Handler::Handler;
|
| 39 |
+
|
| 40 |
+
void Keyboard(pangolin::View& v, unsigned char key, int x, int y, bool pressed) override {
|
| 41 |
+
PYBIND11_OVERLOAD(void, pangolin::Handler, Keyboard, v, key, x, y, pressed);
|
| 42 |
+
}
|
| 43 |
+
void Mouse(pangolin::View& v, pangolin::MouseButton button, int x, int y, bool pressed, int button_state) override {
|
| 44 |
+
PYBIND11_OVERLOAD(void, pangolin::Handler, Mouse, v, button, x, y, pressed, button_state);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
void MouseMotion(pangolin::View& v, int x, int y, int button_state) override {
|
| 48 |
+
PYBIND11_OVERLOAD(void, pangolin::Handler, MouseMotion, v, x, y, button_state);
|
| 49 |
+
}
|
| 50 |
+
void PassiveMouseMotion(pangolin::View& v, int x, int y, int button_state) override {
|
| 51 |
+
PYBIND11_OVERLOAD(void, pangolin::Handler, PassiveMouseMotion, v, x, y, button_state);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
void Special(pangolin::View& v, pangolin::InputSpecial inType, float x, float y, float p1, float p2, float p3, float p4, int button_state) override{
|
| 55 |
+
PYBIND11_OVERLOAD(void, pangolin::Handler, Special, v, inType, x, y, p1, p2, p3, p4, button_state);
|
| 56 |
+
}
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
void bind_handler(pybind11::module &m);
|
| 60 |
+
|
| 61 |
+
} // py_pangolin
|
| 62 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/image.cpp
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "image.hpp"
|
| 29 |
+
#include <pangolin/image/image.h>
|
| 30 |
+
|
| 31 |
+
namespace py_pangolin {
|
| 32 |
+
|
| 33 |
+
} // py_pangolin
|
| 34 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/image.hpp
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
#include <pangolin/image/image.h>
|
| 32 |
+
|
| 33 |
+
namespace py_pangolin {
|
| 34 |
+
|
| 35 |
+
template<typename T>
|
| 36 |
+
void bind_image(pybind11::module& m, const std::string& pyname){
|
| 37 |
+
pybind11::class_<pangolin::Image<T> >(m, pyname.c_str())
|
| 38 |
+
.def(pybind11::init<>())
|
| 39 |
+
.def(pybind11::init<T*, size_t, size_t, size_t>())
|
| 40 |
+
.def("SizeBytes", &pangolin::Image<T>::SizeBytes)
|
| 41 |
+
.def("Area", &pangolin::Image<T>::Area)
|
| 42 |
+
.def("IsValid", &pangolin::Image<T>::IsValid)
|
| 43 |
+
.def("IsContiguous", &pangolin::Image<T>::IsContiguous)
|
| 44 |
+
.def("begin", (unsigned char* (pangolin::Image<T>::*)())&pangolin::Image<T>::begin)
|
| 45 |
+
.def("end", (unsigned char* (pangolin::Image<T>::*)())&pangolin::Image<T>::end)
|
| 46 |
+
.def("begin", (const unsigned char* (pangolin::Image<T>::*)() const )&pangolin::Image<T>::begin)
|
| 47 |
+
.def("end", (const unsigned char* (pangolin::Image<T>::*)() const )&pangolin::Image<T>::end)
|
| 48 |
+
.def("size", &pangolin::Image<T>::size)
|
| 49 |
+
.def("Fill", &pangolin::Image<T>::Fill)
|
| 50 |
+
.def("Replace", &pangolin::Image<T>::Replace)
|
| 51 |
+
.def("Memset", &pangolin::Image<T>::Memset)
|
| 52 |
+
.def("CopyFrom", &pangolin::Image<T>::CopyFrom)
|
| 53 |
+
.def("MinMax", &pangolin::Image<T>::MinMax)
|
| 54 |
+
// .def("Sum", [](pangolin::Image<T>& v){ return v.Sum();})
|
| 55 |
+
// .def("Mean", [](pangolin::Image<T>& v){ return v.Mean();})
|
| 56 |
+
.def("RowPtr", (T* (pangolin::Image<T>::*)(size_t))&pangolin::Image<T>::RowPtr)
|
| 57 |
+
.def("RowPtr", (const T* (pangolin::Image<T>::*)(size_t) const )&pangolin::Image<T>::RowPtr)
|
| 58 |
+
.def("InImage", &pangolin::Image<T>::InImage)
|
| 59 |
+
.def("InBounds", (bool (pangolin::Image<T>::*)(int, int) const)&pangolin::Image<T>::InBounds)
|
| 60 |
+
.def("InBounds", (bool (pangolin::Image<T>::*)(float, float, float) const)&pangolin::Image<T>::InBounds)
|
| 61 |
+
// .def("SubImage", (pangolin::Image<T> (pangolin::Image<T>::*)(size_t, size_t, size_t, size_t))&pangolin::Image<T>::SubImage)
|
| 62 |
+
// .def("Row", &pangolin::Image<T>::Row)
|
| 63 |
+
// .def("Col", &pangolin::Image<T>::Col)
|
| 64 |
+
.def("InImage", &pangolin::Image<T>::InImage);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/image_view.cpp
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Steven Lovegrove
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "image_view.hpp"
|
| 29 |
+
#include <pangolin/display/image_view.h>
|
| 30 |
+
#include <pybind11/numpy.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_image_view(pybind11::module &m) {
|
| 35 |
+
using namespace pangolin;
|
| 36 |
+
pybind11::class_<ImageView, View>(m, "ImageView")
|
| 37 |
+
.def(pybind11::init<>())
|
| 38 |
+
.def("SetImage", [](ImageView& view, pybind11::array_t<float>& img, const std::string & format) -> ImageView&{
|
| 39 |
+
if(img.ndim() == 2) {
|
| 40 |
+
Image<uint8_t> wrapper((uint8_t*)img.mutable_data(0,0), img.shape(1), img.shape(0), img.strides(0));
|
| 41 |
+
return view.SetImage(wrapper, GlPixFormat(PixelFormatFromString(format.empty() ? "GRAY32F" : format)) );
|
| 42 |
+
}else if(img.ndim() == 3 && img.shape()[2] == 3) {
|
| 43 |
+
Image<uint8_t> wrapper((uint8_t*)img.mutable_data(0,0), img.shape(1), img.shape(0), img.strides(0));
|
| 44 |
+
return view.SetImage(wrapper, GlPixFormat(PixelFormatFromString(format.empty() ? "RGB96F" : format)) );
|
| 45 |
+
}else if(img.ndim() == 3 && img.shape()[2] == 4) {
|
| 46 |
+
Image<uint8_t> wrapper((uint8_t*)img.mutable_data(0,0), img.shape(1), img.shape(0), img.strides(0));
|
| 47 |
+
return view.SetImage(wrapper, GlPixFormat(PixelFormatFromString(format.empty() ? "RGB128F" : format)) );
|
| 48 |
+
}else{
|
| 49 |
+
throw std::runtime_error("Unsupported format for now.");
|
| 50 |
+
}
|
| 51 |
+
}, "Set image to display by ImageView", pybind11::arg("img"), pybind11::arg("format") = "")
|
| 52 |
+
.def("SetImage", [](ImageView& view, pybind11::array_t<uint8_t>& img, const std::string & format) -> ImageView&{
|
| 53 |
+
if(img.ndim() == 2) {
|
| 54 |
+
Image<uint8_t> wrapper((uint8_t*)img.mutable_data(0,0), img.shape(1), img.shape(0), img.strides(0));
|
| 55 |
+
return view.SetImage(wrapper, GlPixFormat(PixelFormatFromString(format.empty() ? "GRAY8" : format)) );
|
| 56 |
+
}else if(img.ndim() == 3 && img.shape()[2] == 3) {
|
| 57 |
+
Image<uint8_t> wrapper((uint8_t*)img.mutable_data(0,0), img.shape(1), img.shape(0), img.strides(0));
|
| 58 |
+
return view.SetImage(wrapper, GlPixFormat(PixelFormatFromString(format.empty() ? "RGB24" : format)) );
|
| 59 |
+
}else if(img.ndim() == 3 && img.shape()[2] == 4) {
|
| 60 |
+
Image<uint8_t> wrapper((uint8_t*)img.mutable_data(0,0), img.shape(1), img.shape(0), img.strides(0));
|
| 61 |
+
return view.SetImage(wrapper, GlPixFormat(PixelFormatFromString(format.empty() ? "RGB32" : format)) );
|
| 62 |
+
}else{
|
| 63 |
+
throw std::runtime_error("Unsupported format for now.");
|
| 64 |
+
}
|
| 65 |
+
}, "Set image to display by ImageView", pybind11::arg("img"), pybind11::arg("format") = "")
|
| 66 |
+
.def("SetImage", [](ImageView& view, pybind11::array_t<uint16_t>& img, const std::string & format) -> ImageView&{
|
| 67 |
+
if(img.ndim() == 2) {
|
| 68 |
+
Image<uint8_t> wrapper((uint8_t*)img.mutable_data(0,0), img.shape(1), img.shape(0), img.strides(0));
|
| 69 |
+
return view.SetImage(wrapper, GlPixFormat(PixelFormatFromString(format.empty() ? "GRAY16" : format)) );
|
| 70 |
+
}else if(img.ndim() == 3 && img.shape()[2] == 3) {
|
| 71 |
+
Image<uint8_t> wrapper((uint8_t*)img.mutable_data(0,0), img.shape(1), img.shape(0), img.strides(0));
|
| 72 |
+
return view.SetImage(wrapper, GlPixFormat(PixelFormatFromString(format.empty() ? "RGB48" : format)) );
|
| 73 |
+
}else if(img.ndim() == 3 && img.shape()[2] == 4) {
|
| 74 |
+
Image<uint8_t> wrapper((uint8_t*)img.mutable_data(0,0), img.shape(1), img.shape(0), img.strides(0));
|
| 75 |
+
return view.SetImage(wrapper, GlPixFormat(PixelFormatFromString(format.empty() ? "RGB64" : format)) );
|
| 76 |
+
}else{
|
| 77 |
+
throw std::runtime_error("Unsupported format for now.");
|
| 78 |
+
}
|
| 79 |
+
}, "Set image to display by ImageView", pybind11::arg("img"), pybind11::arg("format") = "");
|
| 80 |
+
}
|
| 81 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/image_view.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Steven Lovegrove
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
namespace py_pangolin{
|
| 34 |
+
|
| 35 |
+
void bind_image_view(pybind11::module &m);
|
| 36 |
+
|
| 37 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/opengl_render_state.cpp
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "opengl_render_state.hpp"
|
| 29 |
+
#include <pangolin/gl/opengl_render_state.h>
|
| 30 |
+
#include <pybind11/eigen.h>
|
| 31 |
+
#include <pybind11/operators.h>
|
| 32 |
+
#include <pybind11/numpy.h>
|
| 33 |
+
|
| 34 |
+
namespace py_pangolin {
|
| 35 |
+
|
| 36 |
+
void bind_opengl_render_state(pybind11::module &m){
|
| 37 |
+
pybind11::enum_<pangolin::AxisDirection>(m, "AxisDirection")
|
| 38 |
+
.value("AxisNone", pangolin::AxisDirection::AxisNone)
|
| 39 |
+
.value("AxisNegX", pangolin::AxisDirection::AxisNegX)
|
| 40 |
+
.value("AxisNegY", pangolin::AxisDirection::AxisNegY)
|
| 41 |
+
.value("AxisNegZ", pangolin::AxisDirection::AxisNegZ)
|
| 42 |
+
.value("AxisX", pangolin::AxisDirection::AxisX)
|
| 43 |
+
.value("AxisY", pangolin::AxisDirection::AxisY)
|
| 44 |
+
.value("AxisZ", pangolin::AxisDirection::AxisZ)
|
| 45 |
+
.export_values();
|
| 46 |
+
|
| 47 |
+
pybind11::enum_<pangolin::OpenGlStack>(m, "OpenGlStack")
|
| 48 |
+
.value("GlModelViewStack", pangolin::OpenGlStack::GlModelViewStack)
|
| 49 |
+
.value("GlProjectionStack", pangolin::OpenGlStack::GlProjectionStack)
|
| 50 |
+
.value("GlTextureStack", pangolin::OpenGlStack::GlTextureStack)
|
| 51 |
+
.export_values();
|
| 52 |
+
|
| 53 |
+
pybind11::class_<pangolin::OpenGlMatrix>(m, "OpenGlMatrix")
|
| 54 |
+
.def("Translate", &pangolin::OpenGlMatrix::Translate)
|
| 55 |
+
.def("Scale", &pangolin::OpenGlMatrix::Scale)
|
| 56 |
+
.def("RotateX", &pangolin::OpenGlMatrix::RotateX)
|
| 57 |
+
.def("RotateY", &pangolin::OpenGlMatrix::RotateY)
|
| 58 |
+
.def("RotateZ", &pangolin::OpenGlMatrix::RotateZ)
|
| 59 |
+
.def(pybind11::init<>())
|
| 60 |
+
.def(pybind11::init<const Eigen::Matrix<float, 4, 4> >())
|
| 61 |
+
.def(pybind11::init<const Eigen::Matrix<double, 4, 4> >())
|
| 62 |
+
.def("Load", &pangolin::OpenGlMatrix::Load)
|
| 63 |
+
.def("Multiply", &pangolin::OpenGlMatrix::Multiply)
|
| 64 |
+
.def("SetIdentity", &pangolin::OpenGlMatrix::SetIdentity)
|
| 65 |
+
.def("Transpose", &pangolin::OpenGlMatrix::Transpose)
|
| 66 |
+
.def("Inverse", &pangolin::OpenGlMatrix::Inverse)
|
| 67 |
+
.def("Matrix", [](pangolin::OpenGlMatrix& mat){
|
| 68 |
+
using T = pangolin::GLprecision;
|
| 69 |
+
return pybind11::array_t<T>( {4, 4 }, {1*sizeof(T), 4*sizeof(T)}, mat.m );
|
| 70 |
+
})
|
| 71 |
+
.def(pybind11::self * pybind11::self);
|
| 72 |
+
|
| 73 |
+
pybind11::class_<pangolin::OpenGlMatrixSpec, pangolin::OpenGlMatrix>(m, "OpenGlMatrixSpec")
|
| 74 |
+
.def(pybind11::init<>());
|
| 75 |
+
|
| 76 |
+
m.def("ProjectionMatrixRUB_BottomLeft", &pangolin::ProjectionMatrixRUB_BottomLeft);
|
| 77 |
+
m.def("ProjectionMatrixRUB_TopLeft", &pangolin::ProjectionMatrixRUB_TopLeft);
|
| 78 |
+
m.def("ProjectionMatrixRDF_BottomLeft", &pangolin::ProjectionMatrixRDF_BottomLeft);
|
| 79 |
+
m.def("ProjectionMatrixRDF_TopLeft", &pangolin::ProjectionMatrixRDF_TopLeft);
|
| 80 |
+
m.def("ProjectionMatrix", &pangolin::ProjectionMatrix);
|
| 81 |
+
m.def("ProjectionMatrixOrthographic", &pangolin::ProjectionMatrixOrthographic);
|
| 82 |
+
m.def("ModelViewLookAtRUB", &pangolin::ModelViewLookAtRUB);
|
| 83 |
+
m.def("ModelViewLookAtRDF", &pangolin::ModelViewLookAtRDF);
|
| 84 |
+
m.def("ModelViewLookAt", (pangolin::OpenGlMatrix (*)(pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::AxisDirection))&pangolin::ModelViewLookAt);
|
| 85 |
+
m.def("ModelViewLookAt", (pangolin::OpenGlMatrix (*)(pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision, pangolin::GLprecision))&pangolin::ModelViewLookAt);
|
| 86 |
+
m.def("IdentityMatrix", (pangolin::OpenGlMatrix (*)())&pangolin::IdentityMatrix);
|
| 87 |
+
m.def("IdentityMatrix", (pangolin::OpenGlMatrixSpec (*)(pangolin::OpenGlStack))&pangolin::IdentityMatrix);
|
| 88 |
+
m.def("negIdentityMatrix", &pangolin::negIdentityMatrix);
|
| 89 |
+
|
| 90 |
+
pybind11::class_<pangolin::OpenGlRenderState>(m, "OpenGlRenderState")
|
| 91 |
+
.def(pybind11::init<const pangolin::OpenGlMatrix&>())
|
| 92 |
+
.def(pybind11::init<const pangolin::OpenGlMatrix&, const pangolin::OpenGlMatrix&>())
|
| 93 |
+
.def(pybind11::init<>())
|
| 94 |
+
.def("ApplyIdentity", &pangolin::OpenGlRenderState::ApplyIdentity)
|
| 95 |
+
.def("Apply", &pangolin::OpenGlRenderState::Apply)
|
| 96 |
+
.def("SetProjectionMatrix", &pangolin::OpenGlRenderState::SetProjectionMatrix)
|
| 97 |
+
.def("SetModelViewMatrix", &pangolin::OpenGlRenderState::SetModelViewMatrix)
|
| 98 |
+
.def("GetProjectionMatrix", (pangolin::OpenGlMatrix& (pangolin::OpenGlRenderState::*)())&pangolin::OpenGlRenderState::GetProjectionMatrix)
|
| 99 |
+
.def("GetProjectionMatrix", (pangolin::OpenGlMatrix (pangolin::OpenGlRenderState::*)() const)&pangolin::OpenGlRenderState::GetProjectionMatrix)
|
| 100 |
+
.def("GetModelViewMatrix", (pangolin::OpenGlMatrix& (pangolin::OpenGlRenderState::*)())&pangolin::OpenGlRenderState::GetModelViewMatrix)
|
| 101 |
+
.def("GetModelViewMatrix", (pangolin::OpenGlMatrix (pangolin::OpenGlRenderState::*)() const)&pangolin::OpenGlRenderState::GetModelViewMatrix)
|
| 102 |
+
.def("GetProjectionModelViewMatrix", &pangolin::OpenGlRenderState::GetProjectionModelViewMatrix)
|
| 103 |
+
.def("GetProjectiveTextureMatrix", &pangolin::OpenGlRenderState::GetProjectiveTextureMatrix)
|
| 104 |
+
.def("EnableProjectiveTexturing", &pangolin::OpenGlRenderState::EnableProjectiveTexturing)
|
| 105 |
+
.def("DisableProjectiveTexturing", &pangolin::OpenGlRenderState::DisableProjectiveTexturing)
|
| 106 |
+
.def("Follow", &pangolin::OpenGlRenderState::Follow, pybind11::arg("T_wc"), pybind11::arg("follow")=true)
|
| 107 |
+
.def("Unfollow", &pangolin::OpenGlRenderState::Unfollow)
|
| 108 |
+
.def("GetProjectionMatrix", (pangolin::OpenGlMatrix& (pangolin::OpenGlRenderState::*)(unsigned int))&pangolin::OpenGlRenderState::GetProjectionMatrix)
|
| 109 |
+
.def("GetProjectionMatrix", (pangolin::OpenGlMatrix (pangolin::OpenGlRenderState::*)(unsigned int) const)&pangolin::OpenGlRenderState::GetProjectionMatrix)
|
| 110 |
+
.def("GetViewOffset", (pangolin::OpenGlMatrix& (pangolin::OpenGlRenderState::*)(unsigned int))&pangolin::OpenGlRenderState::GetViewOffset)
|
| 111 |
+
.def("GetViewOffset", (pangolin::OpenGlMatrix (pangolin::OpenGlRenderState::*)(unsigned int) const)&pangolin::OpenGlRenderState::GetViewOffset)
|
| 112 |
+
.def("GetModelViewMatrix", (pangolin::OpenGlMatrix (pangolin::OpenGlRenderState::*)(int) const)&pangolin::OpenGlRenderState::GetModelViewMatrix)
|
| 113 |
+
.def("ApplyNView", &pangolin::OpenGlRenderState::ApplyNView);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/opengl_render_state.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_opengl_render_state(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/params.cpp
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "params.hpp"
|
| 29 |
+
#include <pangolin/utils/params.h>
|
| 30 |
+
|
| 31 |
+
namespace py_pangolin {
|
| 32 |
+
|
| 33 |
+
void bind_params(pybind11::module &m) {
|
| 34 |
+
pybind11::class_<pangolin::Params>(m, "Params")
|
| 35 |
+
.def(pybind11::init<>())
|
| 36 |
+
.def("Contains", &pangolin::Params::Contains)
|
| 37 |
+
.def("Set", &pangolin::Params::Set<int>)
|
| 38 |
+
.def("Get", &pangolin::Params::Get<int>)
|
| 39 |
+
.def("Set", &pangolin::Params::Set<std::string>)
|
| 40 |
+
.def("Get", &pangolin::Params::Get<std::string>);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/params.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_params(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pixel_format.cpp
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "pixel_format.hpp"
|
| 29 |
+
#include <pangolin/image/pixel_format.h>
|
| 30 |
+
|
| 31 |
+
namespace py_pangolin {
|
| 32 |
+
|
| 33 |
+
void bind_pixel_format(pybind11::module& m){
|
| 34 |
+
pybind11::class_<pangolin::PixelFormat>(m, "PixelFormat")
|
| 35 |
+
.def_readwrite("format", &pangolin::PixelFormat::format)
|
| 36 |
+
.def_readwrite("channels", &pangolin::PixelFormat::channels)
|
| 37 |
+
// .def_readwrite("channel_bits", &pangolin::PixelFormat::channel_bits) //channel_bits[4]
|
| 38 |
+
.def_readwrite("bpp", &pangolin::PixelFormat::bpp)
|
| 39 |
+
.def_readwrite("planar", &pangolin::PixelFormat::planar);
|
| 40 |
+
|
| 41 |
+
m.def("PixelFormatFromString", &pangolin::PixelFormatFromString);
|
| 42 |
+
}
|
| 43 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pixel_format.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_pixel_format(pybind11::module& m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/plotter.cpp
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov, Steven Lovegrove
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "view.hpp"
|
| 29 |
+
#include "plotter.hpp"
|
| 30 |
+
#include "handler.hpp"
|
| 31 |
+
#include <pangolin/plot/plotter.h>
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
namespace py_pangolin {
|
| 35 |
+
|
| 36 |
+
template<typename P>
|
| 37 |
+
void bind_range(pybind11::module& m, const char* python_name_postfix)
|
| 38 |
+
{
|
| 39 |
+
pybind11::class_<pangolin::Range<P>>(m, (std::string("Range") + python_name_postfix).c_str() )
|
| 40 |
+
.def_readwrite("min", &pangolin::Range<P>::min)
|
| 41 |
+
.def_readwrite("max", &pangolin::Range<P>::max);
|
| 42 |
+
|
| 43 |
+
pybind11::class_<pangolin::XYRange<P>>(m, (std::string("XYRange") + python_name_postfix).c_str() )
|
| 44 |
+
.def_readwrite("x", &pangolin::XYRange<P>::x)
|
| 45 |
+
.def_readwrite("y", &pangolin::XYRange<P>::y);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
void bind_plotter(pybind11::module& m){
|
| 49 |
+
// pybind11::class_<pangolin::Handler, PyHandler> handler1(m, "Handler1");
|
| 50 |
+
// handler1
|
| 51 |
+
// .def(pybind11::init<>())
|
| 52 |
+
// .def("Keyboard", &pangolin::Handler::Keyboard)
|
| 53 |
+
// .def("Mouse", &pangolin::Handler::Mouse)
|
| 54 |
+
// .def("MouseMotion", &pangolin::Handler::MouseMotion)
|
| 55 |
+
// .def("PassiveMouseMotion", &pangolin::Handler::PassiveMouseMotion)
|
| 56 |
+
// .def("Special", &pangolin::Handler::Special);
|
| 57 |
+
|
| 58 |
+
bind_range<float>(m, "f");
|
| 59 |
+
|
| 60 |
+
pybind11::enum_<pangolin::DrawingMode>(m, "DrawingMode")
|
| 61 |
+
.value("DrawingModePoints", pangolin::DrawingMode::DrawingModePoints)
|
| 62 |
+
.value("DrawingModeDashed", pangolin::DrawingMode::DrawingModeDashed)
|
| 63 |
+
.value("DrawingModeLine", pangolin::DrawingMode::DrawingModeLine)
|
| 64 |
+
.value("DrawingModeNone", pangolin::DrawingMode::DrawingModeNone)
|
| 65 |
+
.export_values();
|
| 66 |
+
|
| 67 |
+
pybind11::class_<pangolin::Marker> marker(m, "Marker");
|
| 68 |
+
|
| 69 |
+
pybind11::enum_<pangolin::Marker::Direction>(marker, "Direction")
|
| 70 |
+
.value("Horizontal", pangolin::Marker::Direction::Horizontal)
|
| 71 |
+
.value("Vertical", pangolin::Marker::Direction::Vertical)
|
| 72 |
+
.export_values();
|
| 73 |
+
|
| 74 |
+
pybind11::enum_<pangolin::Marker::Equality>(marker, "Equality")
|
| 75 |
+
.value("LessThan", pangolin::Marker::Equality::LessThan)
|
| 76 |
+
.value("Equal", pangolin::Marker::Equality::Equal)
|
| 77 |
+
.value("GreaterThan", pangolin::Marker::Equality::GreaterThan)
|
| 78 |
+
.export_values();
|
| 79 |
+
|
| 80 |
+
marker.def(pybind11::init<pangolin::Marker::Direction, float, pangolin::Marker::Equality, pangolin::Colour>(), pybind11::arg("d"), pybind11::arg("value"), pybind11::arg("leg") = pangolin::Marker::Equality::Equal, pybind11::arg("c")=pangolin::Colour())
|
| 81 |
+
.def(pybind11::init<const pangolin::XYRangef&, const pangolin::Colour&>(), pybind11::arg("range"), pybind11::arg("c")=pangolin::Colour())
|
| 82 |
+
.def_readwrite("range", &pangolin::Marker::range)
|
| 83 |
+
.def_readwrite("colour", &pangolin::Marker::colour);
|
| 84 |
+
|
| 85 |
+
pybind11::class_<pangolin::Plotter,pangolin::View>(m, "Plotter")
|
| 86 |
+
.def(pybind11::init<pangolin::DataLog*, float, float, float, float, float, float, pangolin::Plotter*, pangolin::Plotter*>(),
|
| 87 |
+
pybind11::arg("default_log"),
|
| 88 |
+
pybind11::arg("left")=0,
|
| 89 |
+
pybind11::arg("right")=600,
|
| 90 |
+
pybind11::arg("bottom")=-1,
|
| 91 |
+
pybind11::arg("top")=1,
|
| 92 |
+
pybind11::arg("tickx")=30,
|
| 93 |
+
pybind11::arg("ticky")=0.5,
|
| 94 |
+
pybind11::arg("linked_plotter_x")=NULL,
|
| 95 |
+
pybind11::arg("linked_plotter_y")=NULL)
|
| 96 |
+
.def(pybind11::init([](pangolin::DataLog* log, float left, float right, float bottom, float top, float tickx, float ticky){return new pangolin::Plotter(log, left, right, bottom, top,tickx, ticky);}),
|
| 97 |
+
pybind11::arg("default_log"),
|
| 98 |
+
pybind11::arg("left")=0,
|
| 99 |
+
pybind11::arg("right")=600,
|
| 100 |
+
pybind11::arg("bottom")=-1,
|
| 101 |
+
pybind11::arg("top")=1,
|
| 102 |
+
pybind11::arg("tickx")=30,
|
| 103 |
+
pybind11::arg("ticky")=0.5)
|
| 104 |
+
|
| 105 |
+
.def("Render", &pangolin::Plotter::Render)
|
| 106 |
+
.def("GetSelection", &pangolin::Plotter::GetSelection)
|
| 107 |
+
.def("GetDefaultView", &pangolin::Plotter::GetDefaultView)
|
| 108 |
+
.def("SetDefaultView", &pangolin::Plotter::SetDefaultView)
|
| 109 |
+
.def("GetView", &pangolin::Plotter::GetView)
|
| 110 |
+
.def("SetView", &pangolin::Plotter::SetView)
|
| 111 |
+
.def("SetViewSmooth", &pangolin::Plotter::SetViewSmooth)
|
| 112 |
+
.def("ScrollView", &pangolin::Plotter::ScrollView)
|
| 113 |
+
.def("ScrollViewSmooth", &pangolin::Plotter::ScrollViewSmooth)
|
| 114 |
+
.def("ScaleView", &pangolin::Plotter::ScaleView)
|
| 115 |
+
.def("ScaleViewSmooth", &pangolin::Plotter::ScaleViewSmooth)
|
| 116 |
+
.def("SetTicks", &pangolin::Plotter::SetTicks)
|
| 117 |
+
.def("Track", &pangolin::Plotter::Track, pybind11::arg("x")="$i", pybind11::arg("y")="")
|
| 118 |
+
.def("ToggleTracking", &pangolin::Plotter::ToggleTracking)
|
| 119 |
+
.def("Trigger", &pangolin::Plotter::Trigger, pybind11::arg("x")="$0", pybind11::arg("edge")=-1, pybind11::arg("value")=0.0f)
|
| 120 |
+
.def("ToggleTrigger", &pangolin::Plotter::ToggleTrigger)
|
| 121 |
+
.def("SetBackgroundColour", &pangolin::Plotter::SetBackgroundColour)
|
| 122 |
+
.def("SetAxisColour", &pangolin::Plotter::SetAxisColour)
|
| 123 |
+
.def("SetTickColour", &pangolin::Plotter::SetTickColour)
|
| 124 |
+
.def("Keyboard", &pangolin::Plotter::Keyboard)
|
| 125 |
+
.def("Mouse", &pangolin::Plotter::Mouse)
|
| 126 |
+
.def("MouseMotion", &pangolin::Plotter::MouseMotion)
|
| 127 |
+
.def("PassiveMouseMotion", &pangolin::Plotter::PassiveMouseMotion)
|
| 128 |
+
.def("Special", &pangolin::Plotter::Special)
|
| 129 |
+
.def("ClearSeries", &pangolin::Plotter::ClearSeries)
|
| 130 |
+
.def("AddSeries", &pangolin::Plotter::AddSeries)
|
| 131 |
+
.def("PlotTitleFromExpr", &pangolin::Plotter::PlotTitleFromExpr)
|
| 132 |
+
.def("ClearMarkers", &pangolin::Plotter::ClearMarkers)
|
| 133 |
+
.def("AddMarker", (pangolin::Marker& (pangolin::Plotter::*)(pangolin::Marker::Direction, float, pangolin::Marker::Equality, pangolin::Colour))&pangolin::Plotter::AddMarker, pybind11::arg("d"), pybind11::arg("value"), pybind11::arg("leg") = pangolin::Marker::Equality::Equal, pybind11::arg("c")=pangolin::Colour())
|
| 134 |
+
.def("AddMarker", (pangolin::Marker& (pangolin::Plotter::*)(const pangolin::Marker&))&pangolin::Plotter::AddMarker)
|
| 135 |
+
// .def("ClearImplicitPlots", &pangolin::Plotter::ClearImplicitPlots);
|
| 136 |
+
// .def("AddImplicitPlot", &pangolin::Plotter::AddImplicitPlot);
|
| 137 |
+
.def("SetBounds", (pangolin::View& (pangolin::Plotter::*)(pangolin::Attach, pangolin::Attach, pangolin::Attach, pangolin::Attach))&pangolin::Plotter::SetBounds)
|
| 138 |
+
.def("SetBounds", (pangolin::View& (pangolin::Plotter::*)(pangolin::Attach, pangolin::Attach, pangolin::Attach, pangolin::Attach, bool))&pangolin::Plotter::SetBounds)
|
| 139 |
+
.def("SetBounds", (pangolin::View& (pangolin::Plotter::*)(pangolin::Attach, pangolin::Attach, pangolin::Attach, pangolin::Attach, double))&pangolin::Plotter::SetBounds);
|
| 140 |
+
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/plotter.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_plotter(pybind11::module& m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pypangoio.cpp
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include "pypangoio.h"
|
| 2 |
+
|
| 3 |
+
namespace py_pangolin
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
PyPangoIO::PyPangoIO(std::queue<InterpreterLine>& line_queue, InterpreterLineType line_type)
|
| 7 |
+
: line_queue(line_queue), line_type(line_type)
|
| 8 |
+
{
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
void PyPangoIO::write(const std::string& text)
|
| 12 |
+
{
|
| 13 |
+
buffer += text;
|
| 14 |
+
size_t nl = buffer.find_first_of('\n');
|
| 15 |
+
while(nl != std::string::npos) {
|
| 16 |
+
const std::string line = buffer.substr(0,nl);
|
| 17 |
+
line_queue.push(InterpreterLine(line,line_type));
|
| 18 |
+
buffer = buffer.substr(nl+1);
|
| 19 |
+
nl = buffer.find_first_of('\n');
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
void PyPangoIO::flush()
|
| 24 |
+
{
|
| 25 |
+
// Do nothing
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
void bind_pango_write_object(pybind11::module& m)
|
| 29 |
+
{
|
| 30 |
+
pybind11::class_<PyPangoIO>(m, "PyPangoIO")
|
| 31 |
+
.def("write", &PyPangoIO::write)
|
| 32 |
+
.def("flush", &PyPangoIO::flush);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
}
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pypangoio.h
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) 2011 Steven Lovegrove
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/embed.h>
|
| 31 |
+
#include <iomanip>
|
| 32 |
+
#include <queue>
|
| 33 |
+
|
| 34 |
+
#include <pangolin/var/var.h>
|
| 35 |
+
#include <pangolin/console/InterpreterInterface.h>
|
| 36 |
+
|
| 37 |
+
namespace py_pangolin
|
| 38 |
+
{
|
| 39 |
+
|
| 40 |
+
using namespace pangolin;
|
| 41 |
+
|
| 42 |
+
void bind_pango_write_object(pybind11::module& m);
|
| 43 |
+
|
| 44 |
+
struct PyPangoIO {
|
| 45 |
+
PyPangoIO(std::queue<InterpreterLine>& line_queue, InterpreterLineType line_type);
|
| 46 |
+
|
| 47 |
+
void write(const std::string& text);
|
| 48 |
+
|
| 49 |
+
void flush();
|
| 50 |
+
|
| 51 |
+
std::string buffer;
|
| 52 |
+
std::queue<InterpreterLine>& line_queue;
|
| 53 |
+
InterpreterLineType line_type;
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
}
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/pypangolin.h
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Steven Lovegrove
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
#include <pybind11/stl.h>
|
| 32 |
+
#include <pybind11/embed.h>
|
| 33 |
+
|
| 34 |
+
#include "attach.hpp"
|
| 35 |
+
#include "colour.hpp"
|
| 36 |
+
#include "datalog.hpp"
|
| 37 |
+
#include "display.hpp"
|
| 38 |
+
#include "gl.hpp"
|
| 39 |
+
#include "glsl.hpp"
|
| 40 |
+
#include "gl_draw.hpp"
|
| 41 |
+
#include "glvbo.hpp"
|
| 42 |
+
#include "handler.hpp"
|
| 43 |
+
#include "image.hpp"
|
| 44 |
+
#include "opengl_render_state.hpp"
|
| 45 |
+
#include "params.hpp"
|
| 46 |
+
#include "pixel_format.hpp"
|
| 47 |
+
#include "plotter.hpp"
|
| 48 |
+
#include "var.hpp"
|
| 49 |
+
#include "video.hpp"
|
| 50 |
+
#include "view.hpp"
|
| 51 |
+
#include "viewport.hpp"
|
| 52 |
+
#include "widget.hpp"
|
| 53 |
+
#include "window.hpp"
|
| 54 |
+
#include "image_view.hpp"
|
| 55 |
+
#include "pypangoio.h"
|
| 56 |
+
|
| 57 |
+
namespace pypangolin {
|
| 58 |
+
|
| 59 |
+
inline void PopulateModule(pybind11::module& m)
|
| 60 |
+
{
|
| 61 |
+
m.doc() = "pypangolin python wrapper for Pangolin rapid prototyping graphics and video library.";
|
| 62 |
+
|
| 63 |
+
py_pangolin::bind_var(m);
|
| 64 |
+
py_pangolin::bind_params(m);
|
| 65 |
+
py_pangolin::bind_viewport(m);
|
| 66 |
+
py_pangolin::bind_view(m);
|
| 67 |
+
py_pangolin::bind_window(m);
|
| 68 |
+
py_pangolin::bind_display(m);
|
| 69 |
+
py_pangolin::bind_opengl_render_state(m);
|
| 70 |
+
py_pangolin::bind_attach(m);
|
| 71 |
+
py_pangolin::bind_colour(m);
|
| 72 |
+
py_pangolin::bind_datalog(m);
|
| 73 |
+
py_pangolin::bind_plotter(m);
|
| 74 |
+
py_pangolin::bind_handler(m);
|
| 75 |
+
py_pangolin::bind_gl(m);
|
| 76 |
+
py_pangolin::bind_glsl(m);
|
| 77 |
+
py_pangolin::bind_gl_draw(m);
|
| 78 |
+
py_pangolin::bind_glvbo(m);
|
| 79 |
+
py_pangolin::bind_widget(m);
|
| 80 |
+
py_pangolin::bind_pixel_format(m);
|
| 81 |
+
py_pangolin::bind_image<unsigned char>(m, "Image");
|
| 82 |
+
py_pangolin::bind_video(m);
|
| 83 |
+
py_pangolin::bind_image_view(m);
|
| 84 |
+
py_pangolin::bind_pango_write_object(m);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
}
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/var.cpp
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "var.hpp"
|
| 29 |
+
#include <functional>
|
| 30 |
+
#include <pybind11/functional.h>
|
| 31 |
+
#include <pybind11/stl.h>
|
| 32 |
+
|
| 33 |
+
namespace py_pangolin {
|
| 34 |
+
|
| 35 |
+
var_t::var_t(const std::string& top_level_ns){
|
| 36 |
+
if( top_level_ns=="" || top_level_ns.find_first_of('.') != std::string::npos ) {
|
| 37 |
+
throw std::invalid_argument("Expected top level namespace name, got '" + top_level_ns + "'");
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
namespace_prefix=top_level_ns+".";
|
| 41 |
+
|
| 42 |
+
// Callback function to populate sub-namespaces
|
| 43 |
+
var_callback_connection = pangolin::VarState::I().RegisterForVarEvents(
|
| 44 |
+
std::bind(&var_t::new_var_callback,this,std::placeholders::_1),
|
| 45 |
+
true
|
| 46 |
+
);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
void var_t::new_var_callback(const pangolin::VarState::Event& e)
|
| 50 |
+
{
|
| 51 |
+
if(e.action == pangolin::VarState::Event::Action::Added) {
|
| 52 |
+
const int namespace_size = namespace_prefix.size();
|
| 53 |
+
const std::string name = e.var->Meta().full_name;
|
| 54 |
+
if (!name.compare(0, namespace_size, namespace_prefix)) {
|
| 55 |
+
const size_t dot = name.find_first_of('.', namespace_size);
|
| 56 |
+
members.push_back(
|
| 57 |
+
(dot != std::string::npos) ? name.substr(namespace_size, dot - namespace_size) :
|
| 58 |
+
name.substr(namespace_size)
|
| 59 |
+
);
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
var_t::~var_t() noexcept{}
|
| 66 |
+
|
| 67 |
+
var_t::var_t(const var_t &/*other*/){}
|
| 68 |
+
|
| 69 |
+
var_t::var_t(var_t &&/*other*/) noexcept{}
|
| 70 |
+
|
| 71 |
+
var_t& var_t::operator=(const var_t &/*other*/){
|
| 72 |
+
return *this;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
var_t& var_t::operator=(var_t &&/*other*/) noexcept{
|
| 76 |
+
return *this;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
pybind11::object var_t::get_attr(const std::string &name){
|
| 80 |
+
const std::shared_ptr<pangolin::VarValueGeneric> var = pangolin::VarState::I().GetByName(namespace_prefix+name);
|
| 81 |
+
if(var) {
|
| 82 |
+
if (!strcmp(var->TypeId(), typeid(bool).name())) {
|
| 83 |
+
const bool val = pangolin::Var<bool>(var).Get();
|
| 84 |
+
return pybind11::bool_(val);
|
| 85 |
+
} else if (!strcmp(var->TypeId(), typeid(short).name()) ||
|
| 86 |
+
!strcmp(var->TypeId(), typeid(int).name()) ||
|
| 87 |
+
!strcmp(var->TypeId(), typeid(long).name())) {
|
| 88 |
+
const long val = pangolin::Var<long>(var).Get();
|
| 89 |
+
return pybind11::int_(val);
|
| 90 |
+
} else if (!strcmp(var->TypeId(), typeid(double).name()) ||
|
| 91 |
+
!strcmp(var->TypeId(), typeid(float).name())) {
|
| 92 |
+
const double val = pangolin::Var<double>(var).Get();
|
| 93 |
+
return pybind11::float_(val);
|
| 94 |
+
} else {
|
| 95 |
+
const std::string val = var->str->Get();
|
| 96 |
+
return pybind11::str(val);
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
return pybind11::none();
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
template <typename T>
|
| 103 |
+
void var_t::set_attr_(const std::string& name, T val, const PyVarMeta & meta){
|
| 104 |
+
using namespace pangolin;
|
| 105 |
+
|
| 106 |
+
const std::string full_name = namespace_prefix+name;
|
| 107 |
+
auto p_var = VarState::I().GetByName(full_name);
|
| 108 |
+
|
| 109 |
+
if (p_var) {
|
| 110 |
+
Var<T> setter(p_var);
|
| 111 |
+
setter = val;
|
| 112 |
+
} else {
|
| 113 |
+
int flags = pangolin::META_FLAG_NONE;
|
| 114 |
+
if (meta.toggle) flags |= pangolin::META_FLAG_TOGGLE;
|
| 115 |
+
if (meta.read_only) flags |= pangolin::META_FLAG_READONLY;
|
| 116 |
+
pangolin::Var<T> pango_var(namespace_prefix+name, val, flags);
|
| 117 |
+
pango_var.Meta().gui_changed = true;
|
| 118 |
+
pango_var.Meta().range[0] = meta.low;
|
| 119 |
+
pango_var.Meta().range[1] = meta.high;
|
| 120 |
+
pango_var.Meta().logscale = meta.logscale;
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
pybind11::object var_t::gui_changed(const std::string &name){
|
| 126 |
+
const std::shared_ptr<pangolin::VarValueGeneric> var = pangolin::VarState::I().GetByName(namespace_prefix+name);
|
| 127 |
+
if(var) {
|
| 128 |
+
bool result = var->Meta().gui_changed;
|
| 129 |
+
var->Meta().gui_changed = false;
|
| 130 |
+
return pybind11::bool_(result);
|
| 131 |
+
}
|
| 132 |
+
return pybind11::none();
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
std::vector<std::string>& var_t::get_members(){
|
| 137 |
+
return members;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
template <typename ... Ts>
|
| 141 |
+
struct VarBinder {
|
| 142 |
+
|
| 143 |
+
static inline void Bind(pybind11::class_<var_t> & varClass) {}
|
| 144 |
+
|
| 145 |
+
};
|
| 146 |
+
|
| 147 |
+
template <typename Head, typename ... Tail>
|
| 148 |
+
struct VarBinder<Head, Tail...> {
|
| 149 |
+
|
| 150 |
+
static inline void Bind(pybind11::class_<var_t> & varClass) {
|
| 151 |
+
|
| 152 |
+
varClass.def("__setattr__", [](var_t& v, const std::string& name, Head val) {
|
| 153 |
+
v.set_attr_<Head>(name, val);
|
| 154 |
+
}).def("__setattr__", [](var_t& v, const std::string& name, const std::tuple<Head, PyVarMeta> & valMeta) {
|
| 155 |
+
v.set_attr_<Head>(name, std::get<0>(valMeta), std::get<1>(valMeta));
|
| 156 |
+
});
|
| 157 |
+
|
| 158 |
+
VarBinder<Tail...>::Bind(varClass);
|
| 159 |
+
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
};
|
| 163 |
+
|
| 164 |
+
void bind_var(pybind11::module& m){
|
| 165 |
+
|
| 166 |
+
pybind11::class_<PyVarMeta>(m, "VarMeta")
|
| 167 |
+
.def(pybind11::init<double, double, bool, bool, bool>(),
|
| 168 |
+
pybind11::arg("low") = 0.0,
|
| 169 |
+
pybind11::arg("high") = 1.0,
|
| 170 |
+
pybind11::arg("logscale") = false,
|
| 171 |
+
pybind11::arg("toggle") = false,
|
| 172 |
+
pybind11::arg("read_only") = false);
|
| 173 |
+
|
| 174 |
+
pybind11::class_<py_pangolin::var_t> varClass(m, "Var");
|
| 175 |
+
varClass.def(pybind11::init<const std::string &>())
|
| 176 |
+
.def("__members__", &py_pangolin::var_t::get_members)
|
| 177 |
+
.def("__getattr__", &py_pangolin::var_t::get_attr)
|
| 178 |
+
.def("GuiChanged", &py_pangolin::var_t::gui_changed);
|
| 179 |
+
|
| 180 |
+
VarBinder<bool, int, double, std::string, std::function<void(void)> >::Bind(varClass);
|
| 181 |
+
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/var.hpp
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
#include <pangolin/var/var.h>
|
| 32 |
+
#include <Python.h>
|
| 33 |
+
|
| 34 |
+
namespace py_pangolin {
|
| 35 |
+
|
| 36 |
+
struct PyVarMeta {
|
| 37 |
+
double low;
|
| 38 |
+
double high;
|
| 39 |
+
bool logscale;
|
| 40 |
+
bool toggle;
|
| 41 |
+
bool read_only;
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
void bind_var(pybind11::module& m);
|
| 45 |
+
|
| 46 |
+
// This class exposes Pangolin top-level Var namespaces to
|
| 47 |
+
// Python.
|
| 48 |
+
class var_t
|
| 49 |
+
{
|
| 50 |
+
public:
|
| 51 |
+
var_t(const std::string& top_level_ns);
|
| 52 |
+
virtual ~var_t() noexcept;
|
| 53 |
+
pybind11::object get_attr(const std::string &name);
|
| 54 |
+
|
| 55 |
+
template <typename T>
|
| 56 |
+
void set_attr_(const std::string& name, T val, const PyVarMeta & meta = {});
|
| 57 |
+
|
| 58 |
+
pybind11::object gui_changed(const std::string &name);
|
| 59 |
+
|
| 60 |
+
std::vector<std::string>& get_members();
|
| 61 |
+
protected:
|
| 62 |
+
var_t(const var_t &other);
|
| 63 |
+
var_t(var_t &&other) noexcept;
|
| 64 |
+
var_t& operator=(const var_t &other);
|
| 65 |
+
var_t& operator=(var_t &&other) noexcept;
|
| 66 |
+
private:
|
| 67 |
+
void new_var_callback(const pangolin::VarState::Event &);
|
| 68 |
+
|
| 69 |
+
std::vector<std::string> members;
|
| 70 |
+
std::string namespace_prefix;
|
| 71 |
+
sigslot::scoped_connection var_callback_connection;
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/video.cpp
ADDED
|
@@ -0,0 +1,645 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "video.hpp"
|
| 29 |
+
#include <pangolin/video/video_interface.h>
|
| 30 |
+
#include <pangolin/video/video_input.h>
|
| 31 |
+
|
| 32 |
+
#include <pybind11/numpy.h>
|
| 33 |
+
#include <pybind11/stl.h>
|
| 34 |
+
|
| 35 |
+
namespace py_pangolin {
|
| 36 |
+
|
| 37 |
+
class PyVideoInterface: public pangolin::VideoInterface{
|
| 38 |
+
public:
|
| 39 |
+
using pangolin::VideoInterface::VideoInterface;
|
| 40 |
+
|
| 41 |
+
size_t SizeBytes() const override {
|
| 42 |
+
PYBIND11_OVERLOAD_PURE(
|
| 43 |
+
size_t,
|
| 44 |
+
pangolin::VideoInterface,
|
| 45 |
+
SizeBytes);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
const std::vector<pangolin::StreamInfo>& Streams() const override {
|
| 49 |
+
PYBIND11_OVERLOAD_PURE(
|
| 50 |
+
const std::vector<pangolin::StreamInfo>&,
|
| 51 |
+
pangolin::VideoInterface,
|
| 52 |
+
Streams);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
void Start() override {
|
| 56 |
+
PYBIND11_OVERLOAD_PURE(
|
| 57 |
+
void,
|
| 58 |
+
pangolin::VideoInterface,
|
| 59 |
+
Start);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
void Stop() override {
|
| 63 |
+
PYBIND11_OVERLOAD_PURE(
|
| 64 |
+
void,
|
| 65 |
+
pangolin::VideoInterface,
|
| 66 |
+
Stop);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
bool GrabNext(unsigned char* image, bool wait = true) override {
|
| 70 |
+
PYBIND11_OVERLOAD_PURE(
|
| 71 |
+
bool,
|
| 72 |
+
pangolin::VideoInterface,
|
| 73 |
+
GrabNext,
|
| 74 |
+
image,
|
| 75 |
+
wait);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
bool GrabNewest(unsigned char* image, bool wait = true) override {
|
| 79 |
+
PYBIND11_OVERLOAD_PURE(
|
| 80 |
+
bool,
|
| 81 |
+
pangolin::VideoInterface,
|
| 82 |
+
GrabNewest,
|
| 83 |
+
image,
|
| 84 |
+
wait);
|
| 85 |
+
}
|
| 86 |
+
};
|
| 87 |
+
|
| 88 |
+
class PyGenicamVideoInterface: public pangolin::GenicamVideoInterface{
|
| 89 |
+
public:
|
| 90 |
+
using pangolin::GenicamVideoInterface::GenicamVideoInterface;
|
| 91 |
+
|
| 92 |
+
bool GetParameter(const std::string& name, std::string& result) override {
|
| 93 |
+
PYBIND11_OVERLOAD_PURE(
|
| 94 |
+
bool,
|
| 95 |
+
pangolin::GenicamVideoInterface,
|
| 96 |
+
GetParameter,
|
| 97 |
+
name,
|
| 98 |
+
result);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
bool SetParameter(const std::string& name, const std::string& value) override {
|
| 102 |
+
PYBIND11_OVERLOAD_PURE(
|
| 103 |
+
bool,
|
| 104 |
+
pangolin::GenicamVideoInterface,
|
| 105 |
+
SetParameter,
|
| 106 |
+
name,
|
| 107 |
+
value);
|
| 108 |
+
}
|
| 109 |
+
size_t CameraCount() const override
|
| 110 |
+
{
|
| 111 |
+
PYBIND11_OVERLOAD_PURE(
|
| 112 |
+
size_t,
|
| 113 |
+
pangolin::GenicamVideoInterface,
|
| 114 |
+
CameraCount);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
class PyBufferAwareVideoInterface: public pangolin::BufferAwareVideoInterface{
|
| 122 |
+
public:
|
| 123 |
+
using pangolin::BufferAwareVideoInterface::BufferAwareVideoInterface;
|
| 124 |
+
|
| 125 |
+
uint32_t AvailableFrames() const override {
|
| 126 |
+
PYBIND11_OVERLOAD_PURE(
|
| 127 |
+
uint32_t,
|
| 128 |
+
pangolin::BufferAwareVideoInterface,
|
| 129 |
+
AvailableFrames);
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
bool DropNFrames(uint32_t n) override {
|
| 133 |
+
PYBIND11_OVERLOAD_PURE(
|
| 134 |
+
bool,
|
| 135 |
+
pangolin::BufferAwareVideoInterface,
|
| 136 |
+
DropNFrames,
|
| 137 |
+
n);
|
| 138 |
+
}
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
class PyVideoPropertiesInterface: public pangolin::VideoPropertiesInterface{
|
| 142 |
+
public:
|
| 143 |
+
using pangolin::VideoPropertiesInterface::VideoPropertiesInterface;
|
| 144 |
+
|
| 145 |
+
const picojson::value& DeviceProperties() const override {
|
| 146 |
+
PYBIND11_OVERLOAD_PURE(
|
| 147 |
+
const picojson::value&,
|
| 148 |
+
pangolin::VideoPropertiesInterface,
|
| 149 |
+
DeviceProperties);
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
const picojson::value& FrameProperties() const override {
|
| 153 |
+
PYBIND11_OVERLOAD_PURE(
|
| 154 |
+
const picojson::value&,
|
| 155 |
+
pangolin::VideoPropertiesInterface,
|
| 156 |
+
FrameProperties);
|
| 157 |
+
}
|
| 158 |
+
};
|
| 159 |
+
|
| 160 |
+
class PyVideoFilterInterface: public pangolin::VideoFilterInterface{
|
| 161 |
+
public:
|
| 162 |
+
using pangolin::VideoFilterInterface::VideoFilterInterface;
|
| 163 |
+
|
| 164 |
+
// template <typename T>
|
| 165 |
+
// std::vector<T*> FindMatchingStreams() override {
|
| 166 |
+
// PYBIND11_OVERLOAD(
|
| 167 |
+
// std::vector<T*>,
|
| 168 |
+
// pangolin::VideoFilterInterface,
|
| 169 |
+
// FindMatchingStreams);
|
| 170 |
+
// }
|
| 171 |
+
|
| 172 |
+
std::vector<pangolin::VideoInterface*>& InputStreams() override {
|
| 173 |
+
PYBIND11_OVERLOAD_PURE(
|
| 174 |
+
std::vector<pangolin::VideoInterface*>&,
|
| 175 |
+
pangolin::VideoFilterInterface,
|
| 176 |
+
InputStreams);
|
| 177 |
+
}
|
| 178 |
+
};
|
| 179 |
+
|
| 180 |
+
class PyVideoUvcInterface: public pangolin::VideoUvcInterface{
|
| 181 |
+
public:
|
| 182 |
+
using pangolin::VideoUvcInterface::VideoUvcInterface;
|
| 183 |
+
|
| 184 |
+
int IoCtrl(uint8_t unit, uint8_t ctrl, unsigned char* data, int len, pangolin::UvcRequestCode req_code) override {
|
| 185 |
+
PYBIND11_OVERLOAD_PURE(
|
| 186 |
+
int,
|
| 187 |
+
pangolin::VideoUvcInterface,
|
| 188 |
+
IoCtrl,
|
| 189 |
+
unit,
|
| 190 |
+
ctrl,
|
| 191 |
+
data,
|
| 192 |
+
len,
|
| 193 |
+
req_code);
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
bool GetExposure(int& exp_us) override {
|
| 197 |
+
PYBIND11_OVERLOAD_PURE(
|
| 198 |
+
bool,
|
| 199 |
+
pangolin::VideoUvcInterface,
|
| 200 |
+
GetExposure,
|
| 201 |
+
exp_us);
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
bool SetExposure(int exp_us) override {
|
| 205 |
+
PYBIND11_OVERLOAD_PURE(
|
| 206 |
+
bool,
|
| 207 |
+
pangolin::VideoUvcInterface,
|
| 208 |
+
SetExposure,
|
| 209 |
+
exp_us);
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
bool GetGain(float& gain) override {
|
| 213 |
+
PYBIND11_OVERLOAD_PURE(
|
| 214 |
+
bool,
|
| 215 |
+
pangolin::VideoUvcInterface,
|
| 216 |
+
GetGain,
|
| 217 |
+
gain);
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
bool SetGain(float gain) override {
|
| 221 |
+
PYBIND11_OVERLOAD_PURE(
|
| 222 |
+
bool,
|
| 223 |
+
pangolin::VideoUvcInterface,
|
| 224 |
+
SetGain,
|
| 225 |
+
gain);
|
| 226 |
+
}
|
| 227 |
+
};
|
| 228 |
+
|
| 229 |
+
class PyVideoPlaybackInterface: public pangolin::VideoPlaybackInterface{
|
| 230 |
+
public:
|
| 231 |
+
using pangolin::VideoPlaybackInterface::VideoPlaybackInterface;
|
| 232 |
+
|
| 233 |
+
size_t GetCurrentFrameId() const override {
|
| 234 |
+
PYBIND11_OVERLOAD_PURE(
|
| 235 |
+
size_t,
|
| 236 |
+
pangolin::VideoPlaybackInterface,
|
| 237 |
+
GetCurrentFrameId);
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
size_t GetTotalFrames() const override {
|
| 241 |
+
PYBIND11_OVERLOAD_PURE(
|
| 242 |
+
size_t,
|
| 243 |
+
pangolin::VideoPlaybackInterface,
|
| 244 |
+
GetTotalFrames);
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
size_t Seek(size_t frameid) override {
|
| 248 |
+
PYBIND11_OVERLOAD_PURE(
|
| 249 |
+
size_t,
|
| 250 |
+
pangolin::VideoPlaybackInterface,
|
| 251 |
+
Seek,
|
| 252 |
+
frameid);
|
| 253 |
+
}
|
| 254 |
+
};
|
| 255 |
+
|
| 256 |
+
class PyVideoOutputInterface: public pangolin::VideoOutputInterface{
|
| 257 |
+
public:
|
| 258 |
+
using pangolin::VideoOutputInterface::VideoOutputInterface;
|
| 259 |
+
|
| 260 |
+
const std::vector<pangolin::StreamInfo>& Streams() const override {
|
| 261 |
+
PYBIND11_OVERLOAD_PURE(
|
| 262 |
+
const std::vector<pangolin::StreamInfo>&,
|
| 263 |
+
pangolin::VideoOutputInterface,
|
| 264 |
+
Streams);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
void SetStreams(const std::vector<pangolin::StreamInfo>& streams, const std::string& uri, const picojson::value& properties) override {
|
| 268 |
+
PYBIND11_OVERLOAD_PURE(
|
| 269 |
+
void,
|
| 270 |
+
pangolin::VideoOutputInterface,
|
| 271 |
+
SetStreams,
|
| 272 |
+
streams,
|
| 273 |
+
uri,
|
| 274 |
+
properties);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
int WriteStreams(const unsigned char* data, const picojson::value& frame_properties) override {
|
| 278 |
+
PYBIND11_OVERLOAD_PURE(
|
| 279 |
+
int,
|
| 280 |
+
pangolin::VideoOutputInterface,
|
| 281 |
+
WriteStreams,
|
| 282 |
+
data,
|
| 283 |
+
frame_properties);
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
bool IsPipe() const override {
|
| 287 |
+
PYBIND11_OVERLOAD_PURE(
|
| 288 |
+
bool,
|
| 289 |
+
pangolin::VideoOutputInterface,
|
| 290 |
+
IsPipe);
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
};
|
| 294 |
+
|
| 295 |
+
pybind11::list VideoInputGrab(pangolin::VideoInput& vi, bool wait, bool newest){
|
| 296 |
+
unsigned char *buffer = new unsigned char[vi.SizeBytes()];
|
| 297 |
+
|
| 298 |
+
std::vector<pangolin::Image<unsigned char>> imgs;
|
| 299 |
+
pybind11::list imgsList;
|
| 300 |
+
|
| 301 |
+
if(vi.Grab(buffer,imgs,wait,newest)) {
|
| 302 |
+
for(size_t s=0; s < vi.Streams().size(); ++s) {
|
| 303 |
+
// Let's just return the first stream for the moment
|
| 304 |
+
const pangolin::StreamInfo& si = vi.Streams()[s];
|
| 305 |
+
const pangolin::Image<uint8_t> img = si.StreamImage(buffer);
|
| 306 |
+
|
| 307 |
+
const int c = si.PixFormat().channels;
|
| 308 |
+
const std::string fmt = si.PixFormat().format;
|
| 309 |
+
const int Bpp = si.PixFormat().bpp / (8);
|
| 310 |
+
const int Bpc = Bpp / c;
|
| 311 |
+
const int bpc = si.PixFormat().bpp / c;
|
| 312 |
+
PANGO_ASSERT(bpc == 8 || bpc == 16 || bpc == 32, "only support 8, 16, 32 bits channel");
|
| 313 |
+
|
| 314 |
+
pangolin::Image<uint8_t> dstImage(
|
| 315 |
+
new unsigned char[img.h * img.w * Bpp],
|
| 316 |
+
img.w, img.h, img.w*Bpp
|
| 317 |
+
);
|
| 318 |
+
|
| 319 |
+
pangolin::PitchedCopy((char*)dstImage.ptr, dstImage.pitch, (char*)img.ptr, img.pitch, img.w * Bpp, img.h);
|
| 320 |
+
|
| 321 |
+
// Create a Python object that will free the allocated memory
|
| 322 |
+
pybind11::capsule free_when_done(dstImage.ptr,[](void* f) {
|
| 323 |
+
unsigned char* buffer = (unsigned char*)f;
|
| 324 |
+
delete[] buffer;
|
| 325 |
+
});
|
| 326 |
+
|
| 327 |
+
if (bpc == 8) {
|
| 328 |
+
imgsList.append(
|
| 329 |
+
pybind11::array_t<uint8_t>(
|
| 330 |
+
{(int)dstImage.h, (int)dstImage.w, c },
|
| 331 |
+
{(int)dstImage.pitch, Bpp, Bpc},
|
| 332 |
+
(uint8_t*)dstImage.ptr,
|
| 333 |
+
free_when_done)
|
| 334 |
+
);
|
| 335 |
+
}
|
| 336 |
+
else if (bpc == 16){
|
| 337 |
+
imgsList.append(
|
| 338 |
+
pybind11::array_t<uint16_t>(
|
| 339 |
+
{(int)dstImage.h, (int)dstImage.w, c },
|
| 340 |
+
{(int)dstImage.pitch, Bpp, Bpc},
|
| 341 |
+
(uint16_t*)dstImage.ptr,
|
| 342 |
+
free_when_done)
|
| 343 |
+
);
|
| 344 |
+
}
|
| 345 |
+
else if (bpc == 32){
|
| 346 |
+
if (fmt == "GRAY32")
|
| 347 |
+
{
|
| 348 |
+
imgsList.append(
|
| 349 |
+
pybind11::array_t<uint32_t>(
|
| 350 |
+
{(int)dstImage.h, (int)dstImage.w, c },
|
| 351 |
+
{(int)dstImage.pitch, Bpp, Bpc},
|
| 352 |
+
(uint32_t*)dstImage.ptr,
|
| 353 |
+
free_when_done)
|
| 354 |
+
);
|
| 355 |
+
}
|
| 356 |
+
else if (fmt == "GRAY32F" ||
|
| 357 |
+
fmt == "RGB96F" ||
|
| 358 |
+
fmt == "RGBA128F")
|
| 359 |
+
{
|
| 360 |
+
imgsList.append(
|
| 361 |
+
pybind11::array_t<float>(
|
| 362 |
+
{(int)dstImage.h, (int)dstImage.w, c },
|
| 363 |
+
{(int)dstImage.pitch, Bpp, Bpc},
|
| 364 |
+
(float*)dstImage.ptr,
|
| 365 |
+
free_when_done)
|
| 366 |
+
);
|
| 367 |
+
}
|
| 368 |
+
else{
|
| 369 |
+
PANGO_ASSERT(false, "unsupported 32 bpc format");
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
else{
|
| 373 |
+
PANGO_ASSERT(false, "incompatible bpc");
|
| 374 |
+
}
|
| 375 |
+
}
|
| 376 |
+
}
|
| 377 |
+
delete[] buffer;
|
| 378 |
+
return imgsList;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
picojson::value PicojsonFromPyObject(pybind11::object& obj)
|
| 382 |
+
{
|
| 383 |
+
// convert frame_properties to std::string via json.dumps(...)
|
| 384 |
+
pybind11::module pymodjson = pybind11::module::import("json");
|
| 385 |
+
auto pydumps = pymodjson.attr("dumps");
|
| 386 |
+
const std::string json = pydumps(obj).cast<pybind11::str>();
|
| 387 |
+
std::stringstream ss(json);
|
| 388 |
+
picojson::value pjson;
|
| 389 |
+
picojson::parse(pjson, ss);
|
| 390 |
+
return pjson;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
void bind_video(pybind11::module& m){
|
| 394 |
+
pybind11::class_<pangolin::VideoInterface, PyVideoInterface > video_interface(m, "VideoInterface");
|
| 395 |
+
video_interface
|
| 396 |
+
.def(pybind11::init<>())
|
| 397 |
+
.def("SizeBytes", &pangolin::VideoInterface::SizeBytes)
|
| 398 |
+
.def("Streams", &pangolin::VideoInterface::Streams)
|
| 399 |
+
.def("Start", &pangolin::VideoInterface::Start)
|
| 400 |
+
.def("Stop", &pangolin::VideoInterface::Stop)
|
| 401 |
+
.def("GrabNext", &pangolin::VideoInterface::GrabNext)
|
| 402 |
+
.def("GrabNewest", &pangolin::VideoInterface::GrabNewest);
|
| 403 |
+
|
| 404 |
+
pybind11::class_<pangolin::GenicamVideoInterface, PyGenicamVideoInterface > genicam_video_interface(m, "GenicamVideoInterface");
|
| 405 |
+
genicam_video_interface
|
| 406 |
+
.def(pybind11::init<>())
|
| 407 |
+
.def("GetParameter", &pangolin::GenicamVideoInterface::GetParameter)
|
| 408 |
+
.def("SetParameter", &pangolin::GenicamVideoInterface::SetParameter);
|
| 409 |
+
|
| 410 |
+
pybind11::class_<pangolin::BufferAwareVideoInterface, PyBufferAwareVideoInterface > buffer_aware_video_interface(m, "BufferAwareVideoInterface");
|
| 411 |
+
buffer_aware_video_interface
|
| 412 |
+
.def(pybind11::init<>())
|
| 413 |
+
.def("AvailableFrames", &pangolin::BufferAwareVideoInterface::AvailableFrames)
|
| 414 |
+
.def("DropNFrames", &pangolin::BufferAwareVideoInterface::DropNFrames);
|
| 415 |
+
|
| 416 |
+
pybind11::class_<pangolin::VideoPropertiesInterface, PyVideoPropertiesInterface > video_properties_interface(m, "VideoPropertiesInterface");
|
| 417 |
+
video_properties_interface
|
| 418 |
+
.def(pybind11::init<>())
|
| 419 |
+
.def("DeviceProperties", &pangolin::VideoPropertiesInterface::DeviceProperties)
|
| 420 |
+
.def("FrameProperties", &pangolin::VideoPropertiesInterface::FrameProperties);
|
| 421 |
+
|
| 422 |
+
pybind11::class_<pangolin::VideoFilterInterface, PyVideoFilterInterface > video_filter_interface(m, "VideoFilterInterface");
|
| 423 |
+
video_filter_interface
|
| 424 |
+
.def(pybind11::init<>())
|
| 425 |
+
// .def("FindMatchingStreams", &pangolin::VideoFilterInterface::FindMatchingStreams)
|
| 426 |
+
.def("InputStreams", &pangolin::VideoFilterInterface::InputStreams);
|
| 427 |
+
|
| 428 |
+
pybind11::class_<pangolin::VideoUvcInterface, PyVideoUvcInterface > video_uvc_interface(m, "VideoUvcInterface");
|
| 429 |
+
video_uvc_interface
|
| 430 |
+
.def(pybind11::init<>())
|
| 431 |
+
.def("IoCtrl", &pangolin::VideoUvcInterface::IoCtrl)
|
| 432 |
+
.def("GetExposure", &pangolin::VideoUvcInterface::GetExposure)
|
| 433 |
+
.def("SetExposure", &pangolin::VideoUvcInterface::SetExposure)
|
| 434 |
+
.def("GetGain", &pangolin::VideoUvcInterface::GetGain)
|
| 435 |
+
.def("SetGain", &pangolin::VideoUvcInterface::SetGain);
|
| 436 |
+
|
| 437 |
+
pybind11::class_<pangolin::VideoPlaybackInterface, PyVideoPlaybackInterface > video_playback_interface(m, "VideoPlaybackInterface");
|
| 438 |
+
video_playback_interface
|
| 439 |
+
.def(pybind11::init<>())
|
| 440 |
+
.def("GetCurrentFrameId", &pangolin::VideoPlaybackInterface::GetCurrentFrameId)
|
| 441 |
+
.def("GetTotalFrames", &pangolin::VideoPlaybackInterface::GetTotalFrames)
|
| 442 |
+
.def("Seek", &pangolin::VideoPlaybackInterface::Seek);
|
| 443 |
+
|
| 444 |
+
pybind11::class_<pangolin::VideoOutputInterface, PyVideoOutputInterface > video_output_interface(m, "VideoOutputInterface");
|
| 445 |
+
video_output_interface
|
| 446 |
+
.def(pybind11::init<>())
|
| 447 |
+
.def("Streams", &pangolin::VideoOutputInterface::Streams)
|
| 448 |
+
.def("SetStreams", &pangolin::VideoOutputInterface::SetStreams)
|
| 449 |
+
.def("WriteStreams", &pangolin::VideoOutputInterface::WriteStreams)
|
| 450 |
+
.def("IsPipe", &pangolin::VideoOutputInterface::IsPipe);
|
| 451 |
+
|
| 452 |
+
pybind11::enum_<pangolin::UvcRequestCode>(m, "UvcRequestCode")
|
| 453 |
+
.value("UVC_RC_UNDEFINED", pangolin::UvcRequestCode::UVC_RC_UNDEFINED)
|
| 454 |
+
.value("UVC_SET_CUR", pangolin::UvcRequestCode::UVC_SET_CUR)
|
| 455 |
+
.value("UVC_GET_CUR", pangolin::UvcRequestCode::UVC_GET_CUR)
|
| 456 |
+
.value("UVC_GET_MIN", pangolin::UvcRequestCode::UVC_GET_MIN)
|
| 457 |
+
.value("UVC_GET_MAX", pangolin::UvcRequestCode::UVC_GET_MAX)
|
| 458 |
+
.value("UVC_GET_RES", pangolin::UvcRequestCode::UVC_GET_RES)
|
| 459 |
+
.value("UVC_GET_LEN", pangolin::UvcRequestCode::UVC_GET_LEN)
|
| 460 |
+
.value("UVC_GET_INFO", pangolin::UvcRequestCode::UVC_GET_INFO)
|
| 461 |
+
.value("UVC_GET_DEF", pangolin::UvcRequestCode::UVC_GET_DEF)
|
| 462 |
+
.export_values();
|
| 463 |
+
|
| 464 |
+
/// This iterator enable pythonic video iterations a la `for frame in video_input: ...`
|
| 465 |
+
struct VideoInputIterator {
|
| 466 |
+
VideoInputIterator(pangolin::VideoInput& vi, pybind11::object ref) : vi(vi), ref(ref) { }
|
| 467 |
+
|
| 468 |
+
pybind11::list next() {
|
| 469 |
+
pybind11::list result = VideoInputGrab(vi, true, false);
|
| 470 |
+
if(result.size()==0)
|
| 471 |
+
throw pybind11::stop_iteration();
|
| 472 |
+
return result;
|
| 473 |
+
}
|
| 474 |
+
pangolin::VideoInput& vi;
|
| 475 |
+
pybind11::object ref; // keep a reference
|
| 476 |
+
};
|
| 477 |
+
pybind11::class_<VideoInputIterator>(m, "Iterator")
|
| 478 |
+
.def("__iter__", [](VideoInputIterator &it) -> VideoInputIterator& { return it; })
|
| 479 |
+
.def("__next__", &VideoInputIterator::next);
|
| 480 |
+
|
| 481 |
+
pybind11::class_<pangolin::VideoInput>(m, "VideoInput", video_interface)
|
| 482 |
+
.def(pybind11::init<>())
|
| 483 |
+
.def(pybind11::init<const std::string&, const std::string&>(), pybind11::arg("input_uri"), pybind11::arg("output_uri")="pango:[buffer_size_mb=100]//video_log.pango")
|
| 484 |
+
.def("SizeBytes", &pangolin::VideoInput::SizeBytes)
|
| 485 |
+
.def("Streams", &pangolin::VideoInput::Streams)
|
| 486 |
+
.def("Start", &pangolin::VideoInput::Start)
|
| 487 |
+
.def("Stop", &pangolin::VideoInput::Stop)
|
| 488 |
+
.def("InputStreams", &pangolin::VideoInput::InputStreams)
|
| 489 |
+
.def("Open", &pangolin::VideoInput::Open, pybind11::arg("input_uri"), pybind11::arg("output_uri")="pango:[buffer_size_mb=100]//video_log.pango")
|
| 490 |
+
.def("Close", &pangolin::VideoInput::Close)
|
| 491 |
+
.def("Grab", VideoInputGrab, pybind11::arg("wait")=true, pybind11::arg("newest")=false )
|
| 492 |
+
.def("GetStreamsBitDepth", [](pangolin::VideoInput& vi){
|
| 493 |
+
std::vector<int> bitDepthList;
|
| 494 |
+
for(size_t s=0; s < vi.Streams().size(); ++s) {
|
| 495 |
+
bitDepthList.push_back(vi.Streams()[s].PixFormat().channel_bit_depth);
|
| 496 |
+
}
|
| 497 |
+
return bitDepthList;
|
| 498 |
+
})
|
| 499 |
+
.def("GetNumStreams", [](pangolin::VideoInput& vi){
|
| 500 |
+
return (int) vi.Streams().size();
|
| 501 |
+
})
|
| 502 |
+
.def("GetCurrentFrameId", [](pangolin::VideoInput& vi){
|
| 503 |
+
return (int) vi.Cast<pangolin::VideoPlaybackInterface>()->GetCurrentFrameId();
|
| 504 |
+
})
|
| 505 |
+
.def("GetTotalFrames", [](pangolin::VideoInput& vi){
|
| 506 |
+
return (int) vi.Cast<pangolin::VideoPlaybackInterface>()->GetTotalFrames();
|
| 507 |
+
})
|
| 508 |
+
.def("Seek", [](pangolin::VideoInput& vi, size_t frameid){
|
| 509 |
+
vi.Cast<pangolin::VideoPlaybackInterface>()->Seek(frameid);
|
| 510 |
+
return;
|
| 511 |
+
})
|
| 512 |
+
.def("DeviceProperties", [](pangolin::VideoInput& vi) -> pybind11::object {
|
| 513 |
+
// Use std::string as an intermediate representation
|
| 514 |
+
const std::string props = vi.template Cast<pangolin::VideoPropertiesInterface>()->DeviceProperties().serialize();
|
| 515 |
+
pybind11::module pymodjson = pybind11::module::import("json");
|
| 516 |
+
auto pyloads = pymodjson.attr("loads");
|
| 517 |
+
auto json = pyloads(pybind11::str(props));
|
| 518 |
+
return json;
|
| 519 |
+
})
|
| 520 |
+
.def("FrameProperties", [](pangolin::VideoInput& vi) -> pybind11::object {
|
| 521 |
+
// Use std::string as an intermediate representation
|
| 522 |
+
const std::string props = vi.template Cast<pangolin::VideoPropertiesInterface>()->FrameProperties().serialize();
|
| 523 |
+
pybind11::module pymodjson = pybind11::module::import("json");
|
| 524 |
+
auto pyloads = pymodjson.attr("loads");
|
| 525 |
+
auto json = pyloads(pybind11::str(props));
|
| 526 |
+
return json;
|
| 527 |
+
})
|
| 528 |
+
.def("Width", &pangolin::VideoInput::Width)
|
| 529 |
+
.def("Height", &pangolin::VideoInput::Height)
|
| 530 |
+
.def("PixFormat", &pangolin::VideoInput::PixFormat)
|
| 531 |
+
.def("VideoUri", &pangolin::VideoInput::VideoUri)
|
| 532 |
+
.def("Reset", &pangolin::VideoInput::Reset)
|
| 533 |
+
.def("LogFilename", (const std::string& (pangolin::VideoInput::*)() const)&pangolin::VideoInput::LogFilename)
|
| 534 |
+
.def("LogFilename", (std::string& (pangolin::VideoInput::*)())&pangolin::VideoInput::LogFilename)
|
| 535 |
+
.def("Record", &pangolin::VideoInput::Record)
|
| 536 |
+
.def("RecordOneFrame", &pangolin::VideoInput::RecordOneFrame)
|
| 537 |
+
.def("SetTimelapse", &pangolin::VideoInput::SetTimelapse)
|
| 538 |
+
.def("IsRecording", &pangolin::VideoInput::IsRecording)
|
| 539 |
+
.def("__iter__", [](pybind11::object s) { return VideoInputIterator(s.cast<pangolin::VideoInput&>(), s);});
|
| 540 |
+
|
| 541 |
+
pybind11::class_<pangolin::VideoOutput>(m, "VideoOutput", video_output_interface)
|
| 542 |
+
.def(pybind11::init<>())
|
| 543 |
+
.def(pybind11::init<const std::string&>())
|
| 544 |
+
.def("IsOpen", &pangolin::VideoOutput::IsOpen)
|
| 545 |
+
.def("Open", &pangolin::VideoOutput::Open)
|
| 546 |
+
.def("Close", &pangolin::VideoOutput::Close)
|
| 547 |
+
.def("Streams", &pangolin::VideoOutput::Streams)
|
| 548 |
+
.def("WriteStreams", [](pangolin::VideoOutput& vo, pybind11::list images, const std::vector<int> &streamsBitDepth, pybind11::object frame_properties, pybind11::object device_properties, const std::string& descriptive_uri){
|
| 549 |
+
if(vo.SizeBytes()==0) {
|
| 550 |
+
PANGO_ASSERT(streamsBitDepth.size() == images.size() || streamsBitDepth.size() == 0);
|
| 551 |
+
|
| 552 |
+
// Setup stream info
|
| 553 |
+
for(size_t i = 0; i < images.size(); ++i){
|
| 554 |
+
// num bits per channel
|
| 555 |
+
auto arr = pybind11::array::ensure(images[i]);
|
| 556 |
+
|
| 557 |
+
// num channels
|
| 558 |
+
PANGO_ASSERT(arr.ndim() == 2 || arr.ndim() == 3, "Method only accepts ndarrays of 2 or 3 dimensions.");
|
| 559 |
+
const size_t channels = (arr.ndim() == 3) ? arr.shape(2) : 1;
|
| 560 |
+
|
| 561 |
+
std::string fmtStr;
|
| 562 |
+
if(pybind11::isinstance<pybind11::array_t<std::uint8_t>>(arr)){
|
| 563 |
+
if(channels == 1) fmtStr = "GRAY8";
|
| 564 |
+
else if(channels == 3) fmtStr = "RGB24";
|
| 565 |
+
else if(channels == 4) fmtStr = "RGBA32";
|
| 566 |
+
else PANGO_ASSERT(false, "Only 1, 3 and 4 channel uint8_t formats are supported.");
|
| 567 |
+
} else if (pybind11::isinstance<pybind11::array_t<std::uint16_t>>(arr)){
|
| 568 |
+
if(channels == 1) fmtStr = "GRAY16LE";
|
| 569 |
+
else if(channels == 3) fmtStr = "RGB48";
|
| 570 |
+
else if(channels == 4) fmtStr = "RGBA64";
|
| 571 |
+
else PANGO_ASSERT(false, "Only 1, 3 and 4 channel uint16_t formats are supported.");
|
| 572 |
+
} else if (pybind11::isinstance<pybind11::array_t<std::float_t>>(arr)){
|
| 573 |
+
if(channels == 1) fmtStr = "GRAY32F";
|
| 574 |
+
else if(channels == 3) fmtStr = "RGB96F";
|
| 575 |
+
else if(channels == 4) fmtStr = "RGBA128F";
|
| 576 |
+
else PANGO_ASSERT(false, "Only 1, 3 and 4 channel float_t formats are supported.");
|
| 577 |
+
} else if (pybind11::isinstance<pybind11::array_t<std::double_t>>(arr)){
|
| 578 |
+
if(channels == 1) fmtStr = "GRAY64F";
|
| 579 |
+
else PANGO_ASSERT(false, "Only 1 channel double_t format is supported.");
|
| 580 |
+
} else {
|
| 581 |
+
PANGO_ASSERT(false, "numpy dtype must be either uint8_t, uint16_t, float_t or double_t");
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
pangolin::PixelFormat pf = pangolin::PixelFormatFromString(fmtStr);
|
| 585 |
+
if(streamsBitDepth.size())
|
| 586 |
+
pf.channel_bit_depth = (unsigned int) streamsBitDepth[i];
|
| 587 |
+
|
| 588 |
+
vo.AddStream(pf, arr.shape(1), arr.shape(0));
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
picojson::value json_device_properties;
|
| 592 |
+
if(device_properties) {
|
| 593 |
+
json_device_properties = PicojsonFromPyObject(device_properties);
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
vo.SetStreams(descriptive_uri, json_device_properties);
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
picojson::value json_frame_properties;
|
| 600 |
+
if(frame_properties) {
|
| 601 |
+
json_frame_properties = PicojsonFromPyObject(frame_properties);
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
std::unique_ptr<uint8_t[]> buffer(new uint8_t[vo.SizeBytes()]);
|
| 605 |
+
std::vector<pangolin::Image<unsigned char>> bimgs = vo.GetOutputImages(buffer.get());
|
| 606 |
+
PANGO_ASSERT(bimgs.size() == images.size(), "length of input streams not consistent");
|
| 607 |
+
for(size_t i=0; i < images.size(); ++i) {
|
| 608 |
+
const pangolin::StreamInfo& so = vo.Streams()[i];
|
| 609 |
+
const unsigned int bpc = so.PixFormat().channel_bit_depth;
|
| 610 |
+
const unsigned int Bpp = so.PixFormat().bpp / (8);
|
| 611 |
+
if (bpc == 8){
|
| 612 |
+
pybind11::array_t<uint8_t> arr = images[i].cast<pybind11::array_t<unsigned char, pybind11::array::c_style | pybind11::array::forcecast>>();
|
| 613 |
+
pangolin::Image<uint8_t> srcImg(arr.mutable_data(0,0), bimgs[i].w, bimgs[i].h, bimgs[i].w * Bpp);
|
| 614 |
+
pangolin::PitchedCopy((char*)bimgs[i].ptr, bimgs[i].pitch, (char*)srcImg.ptr,
|
| 615 |
+
srcImg.pitch, srcImg.pitch, srcImg.h);
|
| 616 |
+
}else if (bpc == 12 || bpc == 16){
|
| 617 |
+
pybind11::array_t<uint16_t> arr = images[i].cast<pybind11::array_t<uint16_t, pybind11::array::c_style | pybind11::array::forcecast>>();
|
| 618 |
+
pangolin::Image<uint16_t> srcImg(arr.mutable_data(0,0), bimgs[i].w, bimgs[i].h, bimgs[i].w * Bpp);
|
| 619 |
+
pangolin::PitchedCopy((char*)bimgs[i].ptr, bimgs[i].pitch, (char*)srcImg.ptr,
|
| 620 |
+
srcImg.pitch, srcImg.pitch, srcImg.h);
|
| 621 |
+
}else if (bpc == 32){
|
| 622 |
+
pybind11::array_t<float_t> arr = images[i].cast<pybind11::array_t<float_t, pybind11::array::c_style | pybind11::array::forcecast>>();
|
| 623 |
+
pangolin::Image<float_t> srcImg(arr.mutable_data(0,0), bimgs[i].w, bimgs[i].h, bimgs[i].w * Bpp);
|
| 624 |
+
pangolin::PitchedCopy((char*)bimgs[i].ptr, bimgs[i].pitch, (char*)srcImg.ptr,
|
| 625 |
+
srcImg.pitch, srcImg.pitch, srcImg.h);
|
| 626 |
+
}else if (bpc == 64){
|
| 627 |
+
pybind11::array_t<double_t> arr = images[i].cast<pybind11::array_t<double_t, pybind11::array::c_style | pybind11::array::forcecast>>();
|
| 628 |
+
pangolin::Image<double_t> srcImg(arr.mutable_data(0,0), bimgs[i].w, bimgs[i].h, bimgs[i].w * Bpp);
|
| 629 |
+
pangolin::PitchedCopy((char*)bimgs[i].ptr, bimgs[i].pitch, (char*)srcImg.ptr,
|
| 630 |
+
srcImg.pitch, srcImg.pitch, srcImg.h);
|
| 631 |
+
}else{
|
| 632 |
+
PANGO_ASSERT(false, "format must have 8, 12, 16, 32 or 64 bit depth");
|
| 633 |
+
}
|
| 634 |
+
}
|
| 635 |
+
vo.WriteStreams(buffer.get(), json_frame_properties);
|
| 636 |
+
}, pybind11::arg("images"), pybind11::arg("streamsBitDepth") = std::vector<int>(), pybind11::arg("frame_properties") = pybind11::none(), pybind11::arg("device_properties") = pybind11::none(), pybind11::arg("descriptive_uri") = "python://")
|
| 637 |
+
.def("IsPipe", &pangolin::VideoOutput::IsPipe)
|
| 638 |
+
.def("AddStream", (void (pangolin::VideoOutput::*)(const pangolin::PixelFormat&, size_t,size_t,size_t))&pangolin::VideoOutput::AddStream)
|
| 639 |
+
.def("AddStream", (void (pangolin::VideoOutput::*)(const pangolin::PixelFormat&, size_t,size_t))&pangolin::VideoOutput::AddStream)
|
| 640 |
+
.def("SizeBytes", &pangolin::VideoOutput::SizeBytes)
|
| 641 |
+
.def("GetOutputImages", (std::vector<pangolin::Image<unsigned char>> (pangolin::VideoOutput::*)(unsigned char*) const)&pangolin::VideoOutput::GetOutputImages)
|
| 642 |
+
.def("GetOutputImages", (std::vector<pangolin::Image<unsigned char>> (pangolin::VideoOutput::*)(std::vector<unsigned char>&) const)&pangolin::VideoOutput::GetOutputImages);
|
| 643 |
+
|
| 644 |
+
}
|
| 645 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/video.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_video(pybind11::module& m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/view.cpp
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "view.hpp"
|
| 29 |
+
#include <pangolin/display/view.h>
|
| 30 |
+
#include <pangolin/gl/opengl_render_state.h>
|
| 31 |
+
#include <pangolin/handler/handler.h>
|
| 32 |
+
#include <pybind11/functional.h>
|
| 33 |
+
|
| 34 |
+
namespace py_pangolin {
|
| 35 |
+
|
| 36 |
+
void bind_view(pybind11::module &m) {
|
| 37 |
+
pybind11::class_<pangolin::View>(m, "View")
|
| 38 |
+
.def(pybind11::init<double>(), pybind11::arg("aspect") = 0.0)
|
| 39 |
+
.def("Activate", (void(pangolin::View::*)() const)&pangolin::View::Activate)
|
| 40 |
+
.def("Activate", (void(pangolin::View::*)(const pangolin::OpenGlRenderState&) const)&pangolin::View::Activate)
|
| 41 |
+
.def("ActivateAndScissor", (void(pangolin::View::*)() const)&pangolin::View::ActivateAndScissor)
|
| 42 |
+
.def("ActivateScissorAndClear", (void(pangolin::View::*)() const)&pangolin::View::ActivateScissorAndClear)
|
| 43 |
+
.def("ActivateAndScissor", (void(pangolin::View::*)(const pangolin::OpenGlRenderState&) const)&pangolin::View::ActivateAndScissor)
|
| 44 |
+
.def("ActivateScissorAndClear", (void(pangolin::View::*)(const pangolin::OpenGlRenderState&) const)&pangolin::View::ActivateScissorAndClear)
|
| 45 |
+
.def("ActivatePixelOrthographic", &pangolin::View::ActivatePixelOrthographic)
|
| 46 |
+
.def("ActivateIdentity", &pangolin::View::ActivateIdentity)
|
| 47 |
+
.def("GetClosestDepth", &pangolin::View::GetClosestDepth)
|
| 48 |
+
.def("GetCamCoordinates", &pangolin::View::GetCamCoordinates)
|
| 49 |
+
.def("GetObjectCoordinates", &pangolin::View::GetObjectCoordinates)
|
| 50 |
+
.def("Resize", &pangolin::View::Resize)
|
| 51 |
+
.def("ResizeChildren", &pangolin::View::ResizeChildren)
|
| 52 |
+
.def("Render", &pangolin::View::Render)
|
| 53 |
+
.def("RenderChildren", &pangolin::View::RenderChildren)
|
| 54 |
+
.def("SetFocus", &pangolin::View::SetFocus, pybind11::return_value_policy::reference)
|
| 55 |
+
.def("HasFocus", &pangolin::View::HasFocus)
|
| 56 |
+
.def("SetBounds", (pangolin::View& (pangolin::View::*)(pangolin::Attach, pangolin::Attach, pangolin::Attach, pangolin::Attach))&pangolin::View::SetBounds, pybind11::return_value_policy::reference)
|
| 57 |
+
.def("SetBounds", (pangolin::View& (pangolin::View::*)(pangolin::Attach, pangolin::Attach, pangolin::Attach, pangolin::Attach, bool))&pangolin::View::SetBounds, pybind11::return_value_policy::reference)
|
| 58 |
+
.def("SetBounds", (pangolin::View& (pangolin::View::*)(pangolin::Attach, pangolin::Attach, pangolin::Attach, pangolin::Attach, double))&pangolin::View::SetBounds, pybind11::return_value_policy::reference)
|
| 59 |
+
.def("SetHandler", &pangolin::View::SetHandler, pybind11::return_value_policy::reference)
|
| 60 |
+
.def("SetDrawFunction", &pangolin::View::SetDrawFunction, pybind11::return_value_policy::reference)
|
| 61 |
+
.def("SetAspect", &pangolin::View::SetAspect, pybind11::return_value_policy::reference)
|
| 62 |
+
.def("SetLock", &pangolin::View::SetLock, pybind11::return_value_policy::reference)
|
| 63 |
+
.def("SetLayout", &pangolin::View::SetLayout, pybind11::return_value_policy::reference)
|
| 64 |
+
.def("AddDisplay", &pangolin::View::AddDisplay, pybind11::return_value_policy::reference)
|
| 65 |
+
.def("Show", &pangolin::View::Show, pybind11::arg("show") = true, pybind11::return_value_policy::reference)
|
| 66 |
+
.def("ToggleShow", &pangolin::View::ToggleShow)
|
| 67 |
+
.def("IsShown", &pangolin::View::IsShown)
|
| 68 |
+
.def("GetBounds", &pangolin::View::GetBounds)
|
| 69 |
+
.def("NumChildren", &pangolin::View::NumChildren)
|
| 70 |
+
.def("GetChild", [] (pangolin::View &v, size_t i) -> pangolin::View& { return v[i];}, pybind11::return_value_policy::reference)
|
| 71 |
+
.def("VisibleChild", &pangolin::View::VisibleChild, pybind11::return_value_policy::reference)
|
| 72 |
+
.def("FindChild", &pangolin::View::FindChild)
|
| 73 |
+
.def("NumVisibleChildren", &pangolin::View::NumVisibleChildren);
|
| 74 |
+
|
| 75 |
+
pybind11::enum_<pangolin::Layout>(m, "Layout")
|
| 76 |
+
.value("Overlay", pangolin::LayoutOverlay)
|
| 77 |
+
.value("Vertical", pangolin::LayoutVertical)
|
| 78 |
+
.value("Horizontal", pangolin::LayoutHorizontal)
|
| 79 |
+
.value("Equal", pangolin::LayoutEqual)
|
| 80 |
+
.value("EqualVertical", pangolin::LayoutEqualVertical)
|
| 81 |
+
.value("EqualHorizontal", pangolin::LayoutEqualHorizontal);
|
| 82 |
+
|
| 83 |
+
}
|
| 84 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/view.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_view(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/viewport.cpp
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "viewport.hpp"
|
| 29 |
+
#include <pangolin/gl/viewport.h>
|
| 30 |
+
|
| 31 |
+
namespace py_pangolin {
|
| 32 |
+
|
| 33 |
+
void bind_viewport(pybind11::module &m) {
|
| 34 |
+
pybind11::class_<pangolin::Viewport>(m, "Viewport")
|
| 35 |
+
.def(pybind11::init<>())
|
| 36 |
+
.def(pybind11::init<int, int, int, int>())
|
| 37 |
+
.def("Activate", &pangolin::Viewport::Activate)
|
| 38 |
+
.def("ActivateIdentity", &pangolin::Viewport::ActivateIdentity)
|
| 39 |
+
.def("ActivatePixelOrthographic", &pangolin::Viewport::ActivatePixelOrthographic)
|
| 40 |
+
.def("Scissor", &pangolin::Viewport::Scissor)
|
| 41 |
+
.def("ActivateAndScissor", &pangolin::Viewport::ActivateAndScissor)
|
| 42 |
+
.def("Contains", &pangolin::Viewport::Contains)
|
| 43 |
+
.def("Inset", (pangolin::Viewport (pangolin::Viewport::*)(int)const)&pangolin::Viewport::Inset)
|
| 44 |
+
.def("Inset", (pangolin::Viewport (pangolin::Viewport::*)(int, int)const)&pangolin::Viewport::Inset)
|
| 45 |
+
.def("Insetsect", &pangolin::Viewport::Intersect)
|
| 46 |
+
.def("DisableScissor", &pangolin::Viewport::DisableScissor)
|
| 47 |
+
.def("r", &pangolin::Viewport::r)
|
| 48 |
+
.def("t", &pangolin::Viewport::t)
|
| 49 |
+
.def("aspect", &pangolin::Viewport::aspect)
|
| 50 |
+
.def_readwrite("l", &pangolin::Viewport::l)
|
| 51 |
+
.def_readwrite("b", &pangolin::Viewport::b)
|
| 52 |
+
.def_readwrite("w", &pangolin::Viewport::w)
|
| 53 |
+
.def_readwrite("h", &pangolin::Viewport::h);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/viewport.hpp
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
namespace py_pangolin{
|
| 34 |
+
|
| 35 |
+
void bind_viewport(pybind11::module &m);
|
| 36 |
+
|
| 37 |
+
} // py_pangolin
|
| 38 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/widget.cpp
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "widget.hpp"
|
| 29 |
+
#include <pangolin/display/widgets.h>
|
| 30 |
+
|
| 31 |
+
namespace py_pangolin {
|
| 32 |
+
|
| 33 |
+
void bind_widget(pybind11::module &m){
|
| 34 |
+
m.def("CreatePanel", &pangolin::CreatePanel, pybind11::return_value_policy::reference);
|
| 35 |
+
}
|
| 36 |
+
} // py_pangolin
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/widget.hpp
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#pragma once
|
| 29 |
+
|
| 30 |
+
#include <pybind11/pybind11.h>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
void bind_widget(pybind11::module &m);
|
| 35 |
+
|
| 36 |
+
} // py_pangolin
|
| 37 |
+
|
third-party/DPVO/Pangolin/components/pango_python/src/pypangolin/window.cpp
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of the Pangolin Project.
|
| 2 |
+
* http://github.com/stevenlovegrove/Pangolin
|
| 3 |
+
*
|
| 4 |
+
* Copyright (c) Andrey Mnatsakanov
|
| 5 |
+
*
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person
|
| 7 |
+
* obtaining a copy of this software and associated documentation
|
| 8 |
+
* files (the "Software"), to deal in the Software without
|
| 9 |
+
* restriction, including without limitation the rights to use,
|
| 10 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
* copies of the Software, and to permit persons to whom the
|
| 12 |
+
* Software is furnished to do so, subject to the following
|
| 13 |
+
* conditions:
|
| 14 |
+
*
|
| 15 |
+
* The above copyright notice and this permission notice shall be
|
| 16 |
+
* included in all copies or substantial portions of the Software.
|
| 17 |
+
*
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
| 20 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 21 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 22 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 23 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 24 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 25 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
#include "window.hpp"
|
| 29 |
+
#include <pangolin/windowing/window.h>
|
| 30 |
+
#include <functional>
|
| 31 |
+
|
| 32 |
+
namespace py_pangolin {
|
| 33 |
+
|
| 34 |
+
class PyWindowInterface: public pangolin::WindowInterface{
|
| 35 |
+
public:
|
| 36 |
+
using pangolin::WindowInterface::WindowInterface;
|
| 37 |
+
|
| 38 |
+
void ShowFullscreen(const pangolin::TrueFalseToggle on_off) override {
|
| 39 |
+
PYBIND11_OVERLOAD_PURE(
|
| 40 |
+
void,
|
| 41 |
+
pangolin::WindowInterface,
|
| 42 |
+
ShowFullscreen,
|
| 43 |
+
on_off);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
void Move(int x, int y) override {
|
| 47 |
+
PYBIND11_OVERLOAD_PURE(
|
| 48 |
+
void,
|
| 49 |
+
pangolin::WindowInterface,
|
| 50 |
+
Move,
|
| 51 |
+
x,
|
| 52 |
+
y);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
void Resize(unsigned int w, unsigned int h) override {
|
| 56 |
+
PYBIND11_OVERLOAD_PURE(
|
| 57 |
+
void,
|
| 58 |
+
pangolin::WindowInterface,
|
| 59 |
+
Resize,
|
| 60 |
+
w,
|
| 61 |
+
h);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
void MakeCurrent() override {
|
| 65 |
+
PYBIND11_OVERLOAD_PURE(
|
| 66 |
+
void,
|
| 67 |
+
pangolin::WindowInterface,
|
| 68 |
+
MakeCurrent);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
void RemoveCurrent() override {
|
| 72 |
+
PYBIND11_OVERLOAD_PURE(
|
| 73 |
+
void,
|
| 74 |
+
pangolin::WindowInterface,
|
| 75 |
+
RemoveCurrent);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
void ProcessEvents() override {
|
| 79 |
+
PYBIND11_OVERLOAD_PURE(
|
| 80 |
+
void,
|
| 81 |
+
pangolin::WindowInterface,
|
| 82 |
+
ProcessEvents);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
void SwapBuffers() override {
|
| 87 |
+
PYBIND11_OVERLOAD_PURE(
|
| 88 |
+
void,
|
| 89 |
+
pangolin::WindowInterface,
|
| 90 |
+
SwapBuffers);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
void SetOnRender(std::function<void ()> on_render) {
|
| 94 |
+
PYBIND11_OVERLOAD_PURE(
|
| 95 |
+
void,
|
| 96 |
+
pangolin::WindowInterface,
|
| 97 |
+
SetOnRender,
|
| 98 |
+
on_render);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
void Run() {
|
| 102 |
+
PYBIND11_OVERLOAD_PURE(
|
| 103 |
+
void,
|
| 104 |
+
pangolin::WindowInterface,
|
| 105 |
+
Run);
|
| 106 |
+
}
|
| 107 |
+
};
|
| 108 |
+
|
| 109 |
+
void bind_window(pybind11::module &m) {
|
| 110 |
+
pybind11::class_<pangolin::WindowInterface, PyWindowInterface > windows_interface(m, "WindowsInterface");
|
| 111 |
+
windows_interface
|
| 112 |
+
.def(pybind11::init<>())
|
| 113 |
+
.def("ShowFullscreen", &pangolin::WindowInterface::ShowFullscreen)
|
| 114 |
+
.def("Move", &pangolin::WindowInterface::Move)
|
| 115 |
+
.def("Resize", &pangolin::WindowInterface::Resize)
|
| 116 |
+
.def("MakeCurrent", &pangolin::WindowInterface::MakeCurrent)
|
| 117 |
+
.def("ProcessEvents", &pangolin::WindowInterface::ProcessEvents)
|
| 118 |
+
.def("SwapBuffers", &pangolin::WindowInterface::SwapBuffers);
|
| 119 |
+
}
|
| 120 |
+
}
|