JeVois  1.18
JeVois Smart Embedded Machine Vision Toolkit
Share this page:

Helpers to facilitate data transfer to/from Python.

Collaboration diagram for Python support functions:

Functions

void jevois::python::setEngine (jevois::Engine *e)
 Initialize Python, numpy, and allow python modules to send serial outputs through the JeVois Engine. More...
 
bool jevois::python::hasattr (boost::python::object &o, char const *name)
 Check whether a boost::python::object has an attribute. More...
 
template<class T >
boost::python::list jevois::python::pyVecToList (std::vector< T > const &v)
 Helper to convert std::vector<T> to python list. More...
 
template<class T >
std::vector< T > jevois::python::pyListToVec (boost::python::object const &lst)
 Helper to convert python list (or any iterable) to std::vector<T> More...
 
template<typename T , size_t N>
std::array< T, N > jevois::python::tupleToArray (boost::python::object const &o)
 Helper to extract a tuple with elements of uniform type T into an std::array. More...
 
template<typename T , size_t N>
void jevois::python::tupleToArray (boost::python::object const &o, std::array< T, N > &arr, size_t minN=N)
 Helper to extract a tuple with elements of uniform type T into an std::array. More...
 
template<typename T >
jevois::python::pyextract (boost::python::object const &o)
 Generic value extraction, pass-through to boost::python::extract() for types that python knows how to extract. More...
 
template<>
cv::Scalar_< float > jevois::python::pyextract< cv::Scalar_< float > > (boost::python::object const &o)
 Specialization for cv::Scalar_<float>, extract from tuple of 1..4 float values. More...
 
template<>
cv::Scalar_< int > jevois::python::pyextract< cv::Scalar_< int > > (boost::python::object const &o)
 Specialization for cv::Scalar_<int>, extract from tuple of 1..4 int values. More...
 
template<>
cv::Point_< float > jevois::python::pyextract< cv::Point_< float > > (boost::python::object const &o)
 Specialization for cv::Point_<float>, extract from tuple of 2 float values. More...
 
template<>
cv::Point_< int > jevois::python::pyextract< cv::Point_< int > > (boost::python::object const &o)
 Specialization for cv::Point_<int>, extract from tuple of 2 int values. More...
 
template<>
cv::Size_< float > jevois::python::pyextract< cv::Size_< float > > (boost::python::object const &o)
 Specialization for cv::Size_<float>, extract from tuple of 2 float values. More...
 
template<>
cv::Size_< int > jevois::python::pyextract< cv::Size_< int > > (boost::python::object const &o)
 Specialization for cv::Size_<int>, extract from tuple of 2 int values. More...
 
template<>
ImColor jevois::python::pyextract< ImColor > (boost::python::object const &o)
 Specialization for ImColor, extract from tuple of 3..4 int values (if 3 then, alpha=255) More...
 
template<typename T >
boost::python::object jevois::python::topyobj (T const &val)
 Convert value to python, pass-through to python::object(val) More...
 
template<>
boost::python::object jevois::python::topyobj (cv::Scalar_< float > const &val)
 Specialization for cv::Scalar<float>, returns a tuple with 4 float elements. More...
 
template<>
boost::python::object jevois::python::topyobj (cv::Scalar_< int > const &val)
 Specialization for cv::Scalar<int>, returns a tuple with 4 int elements. More...
 
template<>
boost::python::object jevois::python::topyobj (cv::Point_< float > const &val)
 Specialization for cv::Point<float>, returns a tuple with 2 float elements. More...
 
template<>
boost::python::object jevois::python::topyobj (cv::Point_< int > const &val)
 Specialization for cv::Point<int>, returns a tuple with 2 int elements. More...
 
template<>
boost::python::object jevois::python::topyobj (cv::Size_< float > const &val)
 Specialization for cv::Size<float>, returns a tuple with 2 float elements. More...
 
template<>
boost::python::object jevois::python::topyobj (cv::Size_< int > const &val)
 Specialization for cv::Size<int>, returns a tuple with 2 int elements. More...
 
template<>
boost::python::object jevois::python::topyobj (ImColor const &val)
 Specialization for ImColor, returns a tuple with 4 int elements. More...
 

Function Documentation

◆ hasattr()

◆ pyextract()

template<typename T >
T jevois::python::pyextract ( boost::python::object const &  o)

Generic value extraction, pass-through to boost::python::extract() for types that python knows how to extract.

◆ pyextract< cv::Point_< float > >()

template<>
cv::Point_<float> jevois::python::pyextract< cv::Point_< float > > ( boost::python::object const &  o)

Specialization for cv::Point_<float>, extract from tuple of 2 float values.

◆ pyextract< cv::Point_< int > >()

template<>
cv::Point_<int> jevois::python::pyextract< cv::Point_< int > > ( boost::python::object const &  o)

Specialization for cv::Point_<int>, extract from tuple of 2 int values.

◆ pyextract< cv::Scalar_< float > >()

template<>
cv::Scalar_<float> jevois::python::pyextract< cv::Scalar_< float > > ( boost::python::object const &  o)

Specialization for cv::Scalar_<float>, extract from tuple of 1..4 float values.

◆ pyextract< cv::Scalar_< int > >()

template<>
cv::Scalar_<int> jevois::python::pyextract< cv::Scalar_< int > > ( boost::python::object const &  o)

Specialization for cv::Scalar_<int>, extract from tuple of 1..4 int values.

◆ pyextract< cv::Size_< float > >()

template<>
cv::Size_<float> jevois::python::pyextract< cv::Size_< float > > ( boost::python::object const &  o)

Specialization for cv::Size_<float>, extract from tuple of 2 float values.

◆ pyextract< cv::Size_< int > >()

template<>
cv::Size_<int> jevois::python::pyextract< cv::Size_< int > > ( boost::python::object const &  o)

Specialization for cv::Size_<int>, extract from tuple of 2 int values.

◆ pyextract< ImColor >()

template<>
ImColor jevois::python::pyextract< ImColor > ( boost::python::object const &  o)

Specialization for ImColor, extract from tuple of 3..4 int values (if 3 then, alpha=255)

◆ pyListToVec()

template<class T >
std::vector<T> jevois::python::pyListToVec ( boost::python::object const &  lst)

Helper to convert python list (or any iterable) to std::vector<T>

◆ pyVecToList()

template<class T >
boost::python::list jevois::python::pyVecToList ( std::vector< T > const &  v)

◆ setEngine()

void jevois::python::setEngine ( jevois::Engine e)

Initialize Python, numpy, and allow python modules to send serial outputs through the JeVois Engine.

This command is not for common use, only Engine should use it.

Definition at line 93 of file PythonSupport.C.

References jevois::python::engineForPythonModule.

Referenced by jevois::Engine::postInit().

◆ topyobj() [1/8]

template<>
boost::python::object jevois::python::topyobj ( cv::Point_< float > const &  val)

Specialization for cv::Point<float>, returns a tuple with 2 float elements.

◆ topyobj() [2/8]

template<>
boost::python::object jevois::python::topyobj ( cv::Point_< int > const &  val)

Specialization for cv::Point<int>, returns a tuple with 2 int elements.

◆ topyobj() [3/8]

template<>
boost::python::object jevois::python::topyobj ( cv::Scalar_< float > const &  val)

Specialization for cv::Scalar<float>, returns a tuple with 4 float elements.

◆ topyobj() [4/8]

template<>
boost::python::object jevois::python::topyobj ( cv::Scalar_< int > const &  val)

Specialization for cv::Scalar<int>, returns a tuple with 4 int elements.

◆ topyobj() [5/8]

template<>
boost::python::object jevois::python::topyobj ( cv::Size_< float > const &  val)

Specialization for cv::Size<float>, returns a tuple with 2 float elements.

◆ topyobj() [6/8]

template<>
boost::python::object jevois::python::topyobj ( cv::Size_< int > const &  val)

Specialization for cv::Size<int>, returns a tuple with 2 int elements.

◆ topyobj() [7/8]

template<>
boost::python::object jevois::python::topyobj ( ImColor const &  val)

Specialization for ImColor, returns a tuple with 4 int elements.

◆ topyobj() [8/8]

template<typename T >
boost::python::object jevois::python::topyobj ( T const &  val)

Convert value to python, pass-through to python::object(val)

◆ tupleToArray() [1/2]

template<typename T , size_t N>
std::array<T, N> jevois::python::tupleToArray ( boost::python::object const &  o)

Helper to extract a tuple with elements of uniform type T into an std::array.

◆ tupleToArray() [2/2]

template<typename T , size_t N>
void jevois::python::tupleToArray ( boost::python::object const &  o,
std::array< T, N > &  arr,
size_t  minN = N 
)

Helper to extract a tuple with elements of uniform type T into an std::array.

minN is the smallest number of tuple elements required, allowing for partial tuples. If minN<N, we assume that the array has been initialized with default values, and we allow receiving a tuple that is smaller than N, in which case we only assign the first elements of the array. Useful to exract things like cv::Scalar which can contain 1 to 4 elements.