HiPipe  0.7.0
C++17 data pipeline with Python bindings.
pyboost_cv_point_converter.hpp
1 /****************************************************************************
2  * hipipe library
3  * Copyright (c) 2018, Iterait a.s.
4  * Author(s) Adam Blazek
5  *
6  * This file is distributed under the MIT License.
7  * See the accompanying file LICENSE.txt for the complete license agreement.
8  ****************************************************************************/
9 
10 #pragma once
11 #if defined HIPIPE_BUILD_PYTHON && defined HIPIPE_BUILD_PYTHON_OPENCV
12 
13 // this header has to be included before the numpy header
14 #include <hipipe/core/python/initialize.hpp>
15 
16 #include <Python.h>
17 #include <boost/python.hpp>
18 #include <numpy/ndarrayobject.h>
19 #include <opencv2/core/core.hpp>
20 
21 namespace hipipe::python::utility {
22 
23 struct pointToTupleBoostConverter {
24  static PyObject* convert(const cv::Point2f& pt);
25 };
26 
27 struct pointFromTupleBoostConverter {
28 
29  pointFromTupleBoostConverter();
30 
31  // check if PyObject is a tuple of numbers and can be converted to point
32  static void* convertible(PyObject* object);
33 
34  // construct Point2f from a tuple
35  static void construct(PyObject* object,
36  boost::python::converter::rvalue_from_python_stage1_data* data);
37 };
38 
39 } // namespace hipipe::python::utility
40 
41 #endif // defined HIPIPE_BUILD_PYTHON && defined HIPIPE_BUILD_PYTHON_OPENCV