JeVois
1.22
JeVois Smart Embedded Machine Vision Toolkit
|
|
Helpers to facilitate data transfer to/from Python
Functions | |
void | jevois::python::setEngine (jevois::Engine *e) |
Initialize Python, numpy, and allow python modules to send serial outputs through the JeVois Engine. | |
bool | jevois::python::hasattr (boost::python::object &o, char const *name) |
Check whether a boost::python::object has an attribute. | |
template<class T > | |
boost::python::list | jevois::python::pyVecToList (std::vector< T > const &v) |
Helper to convert std::vector<T> to python list. | |
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> | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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) | |
template<typename T > | |
boost::python::object | jevois::python::topyobj (T const &val) |
Convert value to python, pass-through to python::object(val) | |
template<> | |
boost::python::object | jevois::python::topyobj (cv::Scalar_< float > const &val) |
Specialization for cv::Scalar<float>, returns a tuple with 4 float elements. | |
template<> | |
boost::python::object | jevois::python::topyobj (cv::Scalar_< int > const &val) |
Specialization for cv::Scalar<int>, returns a tuple with 4 int elements. | |
template<> | |
boost::python::object | jevois::python::topyobj (cv::Point_< float > const &val) |
Specialization for cv::Point<float>, returns a tuple with 2 float elements. | |
template<> | |
boost::python::object | jevois::python::topyobj (cv::Point_< int > const &val) |
Specialization for cv::Point<int>, returns a tuple with 2 int elements. | |
template<> | |
boost::python::object | jevois::python::topyobj (cv::Size_< float > const &val) |
Specialization for cv::Size<float>, returns a tuple with 2 float elements. | |
template<> | |
boost::python::object | jevois::python::topyobj (cv::Size_< int > const &val) |
Specialization for cv::Size<int>, returns a tuple with 2 int elements. | |
template<> | |
boost::python::object | jevois::python::topyobj (ImColor const &val) |
Specialization for ImColor, returns a tuple with 4 int elements. | |
bool jevois::python::hasattr | ( | boost::python::object & | o, |
char const * | name | ||
) |
Check whether a boost::python::object has an attribute.
Definition at line 116 of file PythonSupport.C.
References o.
Referenced by jevois::dnn::NetworkPythonImpl::doprocess(), jevois::dnn::NetworkPythonImpl::freeze(), jevois::dnn::PostProcessorPythonImpl::freeze(), jevois::dnn::PreProcessorPythonImpl::freeze(), jevois::dnn::NetworkPythonImpl::load(), jevois::dnn::NetworkPythonImpl::loadpy(), jevois::dnn::PostProcessorPythonImpl::loadpy(), jevois::dnn::PreProcessorPythonImpl::loadpy(), jevois::PythonModule::parseSerial(), jevois::PythonModule::postUninit(), jevois::PythonModule::preInit(), jevois::dnn::PreProcessorPythonImpl::process(), jevois::dnn::PostProcessorPythonImpl::process(), jevois::dnn::PostProcessorPythonImpl::report(), jevois::dnn::PreProcessorPythonImpl::report(), and jevois::PythonModule::supportedCommands().
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.
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.
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.
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.
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.
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.
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.
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)
std::vector< T > jevois::python::pyListToVec | ( | boost::python::object const & | lst | ) |
Helper to convert python list (or any iterable) to std::vector<T>
boost::python::list jevois::python::pyVecToList | ( | std::vector< T > const & | v | ) |
Helper to convert std::vector<T> to python list.
Referenced by jevois::dnn::NetworkPythonImpl::doprocess(), and jevois::dnn::PostProcessorPythonImpl::process().
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 102 of file PythonSupport.C.
References jevois::python::engineForPythonModule.
Referenced by jevois::Engine::postInit().
boost::python::object jevois::python::topyobj | ( | cv::Point_< float > const & | val | ) |
Specialization for cv::Point<float>, returns a tuple with 2 float elements.
boost::python::object jevois::python::topyobj | ( | cv::Point_< int > const & | val | ) |
Specialization for cv::Point<int>, returns a tuple with 2 int elements.
boost::python::object jevois::python::topyobj | ( | cv::Scalar_< float > const & | val | ) |
Specialization for cv::Scalar<float>, returns a tuple with 4 float elements.
boost::python::object jevois::python::topyobj | ( | cv::Scalar_< int > const & | val | ) |
Specialization for cv::Scalar<int>, returns a tuple with 4 int elements.
boost::python::object jevois::python::topyobj | ( | cv::Size_< float > const & | val | ) |
Specialization for cv::Size<float>, returns a tuple with 2 float elements.
boost::python::object jevois::python::topyobj | ( | cv::Size_< int > const & | val | ) |
Specialization for cv::Size<int>, returns a tuple with 2 int elements.
boost::python::object jevois::python::topyobj | ( | ImColor const & | val | ) |
Specialization for ImColor, returns a tuple with 4 int elements.
boost::python::object jevois::python::topyobj | ( | T const & | val | ) |
Convert value to python, pass-through to python::object(val)
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.
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.