import numpysane_pywrap as npsp docstring_module = '''Internal triangulation routines This is the written-in-C Python extension module that underlies the triangulation routines. The user-facing functions are available in mrcal.triangulation module in mrcal/triangulation.py All functions are exported into the mrcal module. So you can call these via mrcal._triangulation_npsp.fff() or mrcal.fff(). The latter is preferred. ''' m = npsp.module(name="_triangulation_npsp", docstring=docstring_module, header=r''' #include "mrcal.h" ''') # All the triangulation routines except Lindstrom have an identical structure. # Lindstrom is slightly different: it takes LOCAL v1 instead of a cam0-coords v1 NAME = "_triangulate_{WHAT}" DOCS = r"""Internal {LONGNAME} triangulation routine This is the internals for mrcal.triangulate_{WHAT}(get_gradients = False). As a user, please call THAT function, and see the docs for that function. The differences: - This is just the no-gradients function. The internal function that returns gradients is _triangulate_{WHAT}_withgrad
m = npsp.module(name="_mrcal_npsp", docstring=docstring_module, header=r''' #include "mrcal.h" static bool validate_lensmodel_un_project(// out; valid if we returned true mrcal_lensmodel_t* lensmodel, // in const char* lensmodel_str, int Nintrinsics_in_arg, bool is_project) { if(lensmodel_str == NULL) { PyErr_Format(PyExc_RuntimeError, "The 'lensmodel' argument is required"); return false; } mrcal_lensmodel_from_name(lensmodel, lensmodel_str); if( !mrcal_lensmodel_type_is_valid(lensmodel->type) ) { PyErr_Format(PyExc_RuntimeError, "Couldn't parse 'lensmodel' argument '%s'", lensmodel_str); return false; } mrcal_lensmodel_metadata_t meta = mrcal_lensmodel_metadata(lensmodel); if( !is_project && !meta.has_gradients ) { PyErr_Format(PyExc_RuntimeError, "The internal _unproject() routine requires lens models that have gradients implemented. Use the Python mrcal.unproject() as a workaround"); return false; } int NlensParams = mrcal_lensmodel_num_params(lensmodel); if( NlensParams != Nintrinsics_in_arg ) { PyErr_Format(PyExc_RuntimeError, "Lens model '%s' has %d parameters, but the given array has %d", lensmodel_str, NlensParams, Nintrinsics_in_arg); return false; } return true; } ''')
m = npsp.module(name="_mrcal_npsp", docstring=docstring_module, header=r''' #include "mrcal.h" static bool validate_lensmodel(// out; valid if we returned true mrcal_lensmodel_t* lensmodel, // in const char* lensmodel_str, int Nintrinsics_in_arg, bool is_project) { if(lensmodel_str == NULL) { PyErr_Format(PyExc_RuntimeError, "The 'lensmodel' argument is required"); return false; } *lensmodel = mrcal_lensmodel_from_name(lensmodel_str); if( !mrcal_lensmodel_type_is_valid(lensmodel->type) ) { PyErr_Format(PyExc_RuntimeError, "Couldn't parse 'lensmodel' argument '%s'", lensmodel_str); return false; } if( !is_project && lensmodel->type == MRCAL_LENSMODEL_CAHVORE ) { PyErr_Format(PyExc_RuntimeError, "The internal _unproject() routine does not support CAHVORE. Use the Python mrcal.unproject() for that"); return false; } int NlensParams = mrcal_lensmodel_num_params(*lensmodel); if( NlensParams != Nintrinsics_in_arg ) { PyErr_Format(PyExc_RuntimeError, "Lens model '%s' has %d parameters, but the given array has %d", lensmodel_str, NlensParams, Nintrinsics_in_arg); return false; } return true; } ''')
docstring_module = '''Low-level routines to manipulate poses, transformations and points This is the written-in-C Python extension module. Most of the time you want to use the mrcal.poseutils wrapper module instead of this module directly. Any functions not prefixed with "_" are meant to be called directly, without the wrapper. All functions are exported into the mrcal module. So you can call these via mrcal._poseutils.fff() or mrcal.fff(). The latter is preferred. ''' m = npsp.module(name="_poseutils_npsp", docstring=docstring_module, header=r''' #include "poseutils.h" #include <string.h> ''') m.function( "identity_R", """Return an identity rotation matrix SYNOPSIS print( mrcal.identity_R() ) ===> [[1. 0. 0.] [0. 1. 0.] [0. 0. 1.]] As with all the poseutils functions, the output can be written directly into a