Skip to content

Commit

Permalink
Changed from downstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Lovegrove committed Nov 21, 2018
1 parent cd9f24a commit 279bfde
Show file tree
Hide file tree
Showing 69 changed files with 1,155 additions and 495 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Expand Up @@ -17,8 +17,9 @@ SET(CPACK_PACKAGE_VERSION_MINOR ${PANGOLIN_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH "0")
include(CPack)

option( BUILD_EXAMPLES "Build Examples" ON )
option( BUILD_TESTS "Build Tests" ON )
option( BUILD_TOOLS "Build Examples" ON )
option( BUILD_EXAMPLES "Build Tools" ON )

set (CMAKE_CXX_STANDARD 14)

Expand Down Expand Up @@ -93,12 +94,16 @@ add_subdirectory("external")
add_subdirectory("src")

if(BUILD_TESTS)
set(Pangolin_DIR ${Pangolin_BINARY_DIR}/src)
add_subdirectory("test")
set(Pangolin_DIR ${Pangolin_BINARY_DIR}/src)
add_subdirectory("test")
endif()

if(BUILD_TOOLS)
set(Pangolin_DIR ${Pangolin_BINARY_DIR}/src)
add_subdirectory(tools)
endif()

if(BUILD_EXAMPLES)
set(Pangolin_DIR ${Pangolin_BINARY_DIR}/src)
add_subdirectory(examples)
add_subdirectory(tools)
set(Pangolin_DIR ${Pangolin_BINARY_DIR}/src)
add_subdirectory(examples)
endif()
2 changes: 1 addition & 1 deletion external/pybind11
Submodule pybind11 updated 83 files
+2 −0 .appveyor.yml
+1 −0 .gitignore
+1 −1 .gitmodules
+8 −7 .travis.yml
+2 −0 CMakeLists.txt
+2 −0 CONTRIBUTING.md
+2 −4 README.md
+1 −1 docs/advanced/cast/eigen.rst
+2 −0 docs/advanced/cast/overview.rst
+1 −4 docs/advanced/cast/stl.rst
+3 −1 docs/advanced/cast/strings.rst
+95 −14 docs/advanced/classes.rst
+39 −39 docs/advanced/exceptions.rst
+1 −1 docs/advanced/functions.rst
+42 −8 docs/advanced/misc.rst
+23 −3 docs/advanced/pycpp/numpy.rst
+91 −3 docs/changelog.rst
+26 −5 docs/classes.rst
+5 −1 docs/compiling.rst
+2 −2 docs/conf.py
+43 −37 docs/faq.rst
+2 −4 docs/intro.rst
+1 −1 docs/reference.rst
+5 −2 include/pybind11/attr.h
+127 −62 include/pybind11/cast.h
+4 −0 include/pybind11/complex.h
+1 −5 include/pybind11/detail/class.h
+52 −47 include/pybind11/detail/common.h
+56 −141 include/pybind11/detail/descr.h
+1 −1 include/pybind11/detail/init.h
+49 −7 include/pybind11/detail/internals.h
+29 −34 include/pybind11/eigen.h
+7 −1 include/pybind11/embed.h
+2 −4 include/pybind11/functional.h
+2 −2 include/pybind11/iostream.h
+55 −48 include/pybind11/numpy.h
+271 −160 include/pybind11/pybind11.h
+99 −0 include/pybind11/pytypes.h
+27 −11 include/pybind11/stl.h
+1 −1 pybind11/_version.py
+1 −1 setup.cfg
+2 −2 setup.py
+4 −3 tests/CMakeLists.txt
+1 −1 tests/constructor_stats.h
+1 −1 tests/test_buffers.cpp
+11 −7 tests/test_buffers.py
+12 −0 tests/test_builtin_casters.cpp
+17 −0 tests/test_builtin_casters.py
+2 −16 tests/test_call_policies.cpp
+1 −30 tests/test_call_policies.py
+35 −1 tests/test_class.cpp
+13 −0 tests/test_class.py
+14 −0 tests/test_constants_and_functions.cpp
+1 −1 tests/test_copy_move.cpp
+1 −1 tests/test_eigen.cpp
+1 −1 tests/test_eigen.py
+1 −1 tests/test_embed/catch.cpp
+17 −3 tests/test_enum.cpp
+50 −4 tests/test_enum.py
+1 −0 tests/test_factory_constructors.cpp
+11 −0 tests/test_iostream.py
+7 −7 tests/test_kwargs_and_defaults.py
+8 −0 tests/test_methods_and_attributes.cpp
+40 −4 tests/test_methods_and_attributes.py
+3 −3 tests/test_multiple_inheritance.cpp
+9 −0 tests/test_numpy_array.cpp
+10 −0 tests/test_numpy_array.py
+15 −0 tests/test_numpy_dtypes.cpp
+13 −1 tests/test_numpy_dtypes.py
+7 −3 tests/test_opaque_types.cpp
+6 −0 tests/test_pickling.py
+24 −0 tests/test_pytypes.cpp
+13 −0 tests/test_pytypes.py
+95 −1 tests/test_smart_ptr.cpp
+65 −0 tests/test_smart_ptr.py
+46 −0 tests/test_stl.cpp
+41 −2 tests/test_stl.py
+136 −0 tests/test_tagbased_polymorphic.cpp
+20 −0 tests/test_tagbased_polymorphic.py
+31 −3 tests/test_virtual_functions.cpp
+6 −0 tests/test_virtual_functions.py
+3 −0 tools/FindPythonLibsNew.cmake
+25 −4 tools/pybind11Tools.cmake
3 changes: 3 additions & 0 deletions include/pangolin/display/opengl_render_state.h
Expand Up @@ -222,6 +222,9 @@ class PANGOLIN_EXPORT OpenGlRenderState
PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixRUB_BottomLeft(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );

PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixRUB_TopLeft(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );

PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixRDF_TopLeft(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );

Expand Down
1 change: 1 addition & 0 deletions include/pangolin/display/widgets/widgets.h
Expand Up @@ -132,6 +132,7 @@ struct PANGOLIN_EXPORT TextInput : public Widget<std::string>
void ResizeChildren();
GlText gltext;
GLfloat raster[2];
bool can_edit;
bool do_edit;
int sel[2];
};
Expand Down
1 change: 1 addition & 0 deletions include/pangolin/factory/factory_registry.h
Expand Up @@ -41,6 +41,7 @@ struct FactoryInterface
{
typedef T FactoryItem;

virtual ~FactoryInterface() = default;
virtual std::unique_ptr<T> Open(const Uri& uri) = 0;
};

Expand Down
1 change: 1 addition & 0 deletions include/pangolin/geometry/glgeometry.h
Expand Up @@ -37,6 +37,7 @@ struct GlGeometry
{
GlGeometry() = default;
GlGeometry(GlGeometry&&) = default;
GlGeometry& operator=(GlGeometry&&) = default;

struct Element : public GlBufferData
{
Expand Down
6 changes: 4 additions & 2 deletions include/pangolin/gl/gl.h
Expand Up @@ -61,7 +61,7 @@ class PANGOLIN_EXPORT GlTexture

//! Move Constructor / asignment
GlTexture(GlTexture&& tex);
void operator=(GlTexture&& tex);
GlTexture& operator=(GlTexture&& tex);

//! Default constructor represents 'no texture'
GlTexture();
Expand Down Expand Up @@ -149,7 +149,9 @@ struct PANGOLIN_EXPORT GlFramebuffer

GlFramebuffer(GlTexture& colour, GlRenderBuffer& depth);
GlFramebuffer(GlTexture& colour0, GlTexture& colour1, GlRenderBuffer& depth);

GlFramebuffer(GlTexture& colour0, GlTexture& colour1, GlTexture& colour2, GlRenderBuffer& depth);
GlFramebuffer(GlTexture& colour0, GlTexture& colour1, GlTexture& colour2, GlTexture& colour3, GlRenderBuffer& depth);

void Bind() const;
void Unbind() const;

Expand Down
41 changes: 35 additions & 6 deletions include/pangolin/gl/gl.hpp
Expand Up @@ -122,13 +122,19 @@ inline GlTexture::GlTexture(GlTexture&& tex)
{
*this = std::move(tex);
}
inline void GlTexture::operator=(GlTexture&& tex)
{
internal_format = tex.internal_format;
tid = tex.tid;

tex.internal_format = 0;
tex.tid = 0;
inline GlTexture& GlTexture::operator=(GlTexture&& tex)
{
if (&tex != this) {
internal_format = tex.internal_format;
tid = tex.tid;
width = tex.width;
height = tex.height;

tex.internal_format = 0;
tex.tid = 0;
}
return *this;
}

inline bool GlTexture::IsValid() const
Expand Down Expand Up @@ -553,6 +559,29 @@ inline GlFramebuffer::GlFramebuffer(GlTexture& colour0, GlTexture& colour1, GlRe
CheckGlDieOnError();
}

inline GlFramebuffer::GlFramebuffer(GlTexture& colour0, GlTexture& colour1, GlTexture& colour2, GlRenderBuffer& depth)
: attachments(0)
{
glGenFramebuffersEXT(1, &fbid);
AttachColour(colour0);
AttachColour(colour1);
AttachColour(colour2);
AttachDepth(depth);
CheckGlDieOnError();
}

inline GlFramebuffer::GlFramebuffer(GlTexture& colour0, GlTexture& colour1, GlTexture& colour2, GlTexture& colour3, GlRenderBuffer& depth)
: attachments(0)
{
glGenFramebuffersEXT(1, &fbid);
AttachColour(colour0);
AttachColour(colour1);
AttachColour(colour2);
AttachColour(colour3);
AttachDepth(depth);
CheckGlDieOnError();
}

inline void GlFramebuffer::Bind() const
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbid);
Expand Down
3 changes: 3 additions & 0 deletions include/pangolin/handler/handler_image.h
Expand Up @@ -83,6 +83,8 @@ class ImageViewHandler : public Handler

bool& UseNN();

bool& FlipTextureX();

bool& FlipTextureY();

pangolin::XYRangef& GetViewToRender();
Expand Down Expand Up @@ -153,6 +155,7 @@ class ImageViewHandler : public Handler
int last_mouse_pos[2];

bool use_nn;
bool flipTextureX;
bool flipTextureY;
};

Expand Down
4 changes: 2 additions & 2 deletions include/pangolin/tools/video_viewer.h
Expand Up @@ -55,8 +55,8 @@ class VideoViewer
void SetDiscardBufferedFrames(bool new_state);
void SetWaitForFrames(bool new_state);
void Skip(int frames);
void ChangeExposure(int delta_us);
void ChangeGain(float delta);
bool ChangeExposure(int delta_us);
bool ChangeGain(float delta);
void SetActiveCamera(int delta);
void DrawEveryNFrames(int n);

Expand Down
1 change: 1 addition & 0 deletions include/pangolin/utils/file_extension.h
Expand Up @@ -46,6 +46,7 @@ enum ImageFileType
ImageFileTypePvn,
ImageFileTypeZstd,
ImageFileTypeLz4,
ImageFileTypeP12b,
ImageFileTypePly,
ImageFileTypeObj,
ImageFileTypeUnknown
Expand Down
32 changes: 22 additions & 10 deletions include/pangolin/var/var.h
Expand Up @@ -49,7 +49,7 @@ inline void InitialiseNewVarMetaGeneric(
v.Meta().range[0] = 0.0;
v.Meta().range[1] = 0.0;
v.Meta().increment = 0.0;
v.Meta().flags = 0;
v.Meta().flags = META_FLAG_NONE;
v.Meta().logscale = false;
v.Meta().generic = true;

Expand All @@ -59,7 +59,8 @@ inline void InitialiseNewVarMetaGeneric(
template<typename T>
inline void InitialiseNewVarMeta(
VarValue<T>& v, const std::string& name,
double min = 0, double max = 0, int flags = 1, bool logscale = false
double min = 0, double max = 0, int flags = META_FLAG_TOGGLE,
bool logscale = false
) {
// Initialise meta parameters
const std::vector<std::string> parts = pangolin::Split(name,'.');
Expand Down Expand Up @@ -99,16 +100,16 @@ class Var
if (min <= 0 || max <= 0) {
throw std::runtime_error("LogScale: range of numbers must be positive!");
}
InitialiseNewVarMeta(*nv, name, std::log(min), std::log(max), 1, logscale);
InitialiseNewVarMeta<T&>(*nv, name, std::log(min), std::log(max), META_FLAG_TOGGLE, logscale);
}else{
InitialiseNewVarMeta(*nv, name, min, max, 1, logscale);
InitialiseNewVarMeta<T&>(*nv, name, min, max, META_FLAG_TOGGLE, logscale);
}
}
return variable;
}

static T& Attach(
const std::string& name, T& variable, bool toggle = false
const std::string& name, T& variable, int flags = META_FLAG_NONE
) {
// Find name in VarStore
VarValueGeneric*& v = VarState::I()[name];
Expand All @@ -119,11 +120,17 @@ class Var
// new VarRef<T> (owned by VarStore)
VarValue<T&>* nv = new VarValue<T&>(variable);
v = nv;
InitialiseNewVarMeta<T&>(*nv, name, 0.0, 0.0, toggle);
InitialiseNewVarMeta<T&>(*nv, name, 0.0, 0.0, flags);
}
return variable;
}

static T& Attach(
const std::string& name, T& variable, bool toggle
) {
return Attach(name, variable, toggle ? META_FLAG_TOGGLE : META_FLAG_NONE);
}

~Var()
{
delete ptr;
Expand Down Expand Up @@ -159,7 +166,7 @@ class Var
}
}

Var( const std::string& name, const T& value, bool toggle = false )
Var(const std::string& name, const T& value, int flags = META_FLAG_NONE)
: ptr(0)
{
// Find name in VarStore
Expand All @@ -178,10 +185,15 @@ class Var
}
v = nv;
var = nv;
InitialiseNewVarMeta(*nv, name, 0, 1, toggle);
InitialiseNewVarMeta(*nv, name, 0, 1, flags);
}
}

Var(const std::string& name, const T& value, bool toggle)
: Var(name, value, toggle ? META_FLAG_TOGGLE : META_FLAG_NONE)
{
}

Var(
const std::string& name, const T& value,
double min, double max, bool logscale = false
Expand All @@ -207,7 +219,7 @@ class Var
if (min <= 0 || max <= 0) {
throw std::runtime_error("LogScale: range of numbers must be positive!");
}
InitialiseNewVarMeta(*nv, name, std::log(min), std::log(max), 1, true);
InitialiseNewVarMeta(*nv, name, std::log(min), std::log(max), META_FLAG_TOGGLE, true);
}else{
InitialiseNewVarMeta(*nv, name, min, max);
}
Expand All @@ -223,7 +235,7 @@ class Var
{
try{
return var->Get();
}catch(BadInputException)
}catch(const BadInputException &e)
{
const_cast<Var<T> *>(this)->Reset();
return var->Get();
Expand Down
5 changes: 4 additions & 1 deletion include/pangolin/var/varvaluegeneric.h
Expand Up @@ -31,12 +31,15 @@

namespace pangolin
{
constexpr int META_FLAG_NONE = 0x0000;
constexpr int META_FLAG_TOGGLE = 0x0001;
constexpr int META_FLAG_READONLY = 0x0002;

struct VarMeta
{
VarMeta() :
increment(0.),
flags(0),
flags(META_FLAG_NONE),
gui_changed(false),
logscale(false),
generic(false)
Expand Down
2 changes: 1 addition & 1 deletion include/pangolin/var/varwrapper.h
Expand Up @@ -77,7 +77,7 @@ class VarWrapper : public VarValueT<T>
cache = val;
try {
src.Set( Convert<VarS, T>::Do(val) );
}catch(BadInputException) {
}catch(const BadInputException &e) {
pango_print_warn("Unable to set variable with type %s from %s. Resetting.", typeid(VarS).name(), typeid(T).name() );
Reset();
}
Expand Down
84 changes: 84 additions & 0 deletions include/pangolin/video/drivers/pack.h
@@ -0,0 +1,84 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2014 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

#pragma once

#include <pangolin/pangolin.h>
#include <pangolin/video/video.h>

namespace pangolin
{

// Video class that packs its video input using the given method.
class PANGOLIN_EXPORT PackVideo :
public VideoInterface,
public VideoFilterInterface,
public BufferAwareVideoInterface
{
public:
PackVideo(std::unique_ptr<VideoInterface>& videoin, PixelFormat new_fmt);
~PackVideo();

//! Implement VideoInput::Start()
void Start();

//! Implement VideoInput::Stop()
void Stop();

//! Implement VideoInput::SizeBytes()
size_t SizeBytes() const;

//! Implement VideoInput::Streams()
const std::vector<StreamInfo>& Streams() const;

//! Implement VideoInput::GrabNext()
bool GrabNext( unsigned char* image, bool wait = true );

//! Implement VideoInput::GrabNewest()
bool GrabNewest( unsigned char* image, bool wait = true );

//! Implement VideoFilterInterface method
std::vector<VideoInterface*>& InputStreams();

uint32_t AvailableFrames() const;

bool DropNFrames(uint32_t n);

protected:
void Process(unsigned char* image, const unsigned char* buffer);

std::unique_ptr<VideoInterface> src;
std::vector<VideoInterface*> videoin;
std::vector<StreamInfo> streams;
size_t size_bytes;
unsigned char* buffer;

picojson::value device_properties;
picojson::value frame_properties;
};

}

0 comments on commit 279bfde

Please sign in to comment.