%module spt %{ // Includes the header in the wrapper code #include "../spt/camera.hpp" #include "../spt/interface.hpp" %} // Some modules need extra imports beside the main .hpp file %include "std_array.i" %include "std_string.i" %include "std_vector.i" // Instantiate templates used by example // If the template is too nested (>2), parts of it need to be declared as well namespace std { %template(DoubleMatrix_3x3) array, 3>; %template(VectorDouble) vector; %template(DoubleMatrix_3x1) array, 3>; %template(DoubleMatrix_3x4) array, 4>; %template(Matrix_Jx4) vector>; %template(Matrix_NxJx4) vector>>; %template(Matrix_Jx3) vector>; %template(Matrix_VxNxJx3) vector>>>; %template(VectorCamera) vector; %template(DoubleMatrix_2x3) array, 2>; %template(VectorString) vector; } // Convert vector to native (python) list %naturalvar Camera::K; %naturalvar Camera::DC; %naturalvar Camera::R; %naturalvar Camera::T; // Improve printing of result objects %extend Camera { std::string __str__() const { return $self->to_string(); } } // Ignore: Warning 503: Can't wrap 'operator <<' unless renamed to a valid identifier. %warnfilter(503) Camera; // Ignore: Warning 511: Can't use keyword arguments with overloaded functions. // The warning is cause by enabling keyword arguments, which doesn't work for vectors. #pragma SWIG nowarn=511 // Parse the header file to generate wrappers %include "../spt/camera.hpp" %include "../spt/interface.hpp"