1 /* This file is part of the Pangolin Project. 2 * http://github.com/stevenlovegrove/Pangolin 3 * 4 * Copyright (c) Andrey Mnatsakanov 5 * 6 * Permission is hereby granted, free of charge, to any person 7 * obtaining a copy of this software and associated documentation 8 * files (the "Software"), to deal in the Software without 9 * restriction, including without limitation the rights to use, 10 * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 * copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following 13 * conditions: 14 * 15 * The above copyright notice and this permission notice shall be 16 * included in all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 * OTHER DEALINGS IN THE SOFTWARE. 26 */ 27 28 #pragma once 29 30 #include <pybind11/pybind11.h> 31 #include <pangolin/image/image.h> 32 33 namespace py_pangolin { 34 35 template<typename T> bind_image(pybind11::module & m,const std::string & pyname)36 void bind_image(pybind11::module& m, const std::string& pyname){ 37 pybind11::class_<pangolin::Image<T> >(m, pyname.c_str()) 38 .def(pybind11::init<>()) 39 .def(pybind11::init<T*, size_t, size_t, size_t>()) 40 .def("SizeBytes", &pangolin::Image<T>::SizeBytes) 41 .def("Area", &pangolin::Image<T>::Area) 42 .def("IsValid", &pangolin::Image<T>::IsValid) 43 .def("IsContiguous", &pangolin::Image<T>::IsContiguous) 44 .def("begin", (unsigned char* (pangolin::Image<T>::*)())&pangolin::Image<T>::begin) 45 .def("end", (unsigned char* (pangolin::Image<T>::*)())&pangolin::Image<T>::end) 46 .def("begin", (const unsigned char* (pangolin::Image<T>::*)() const )&pangolin::Image<T>::begin) 47 .def("end", (const unsigned char* (pangolin::Image<T>::*)() const )&pangolin::Image<T>::end) 48 .def("size", &pangolin::Image<T>::size) 49 .def("Fill", &pangolin::Image<T>::Fill) 50 .def("Replace", &pangolin::Image<T>::Replace) 51 .def("Memset", &pangolin::Image<T>::Memset) 52 .def("CopyFrom", &pangolin::Image<T>::CopyFrom) 53 .def("MinMax", &pangolin::Image<T>::MinMax) 54 // .def("Sum", [](pangolin::Image<T>& v){ return v.Sum();}) 55 // .def("Mean", [](pangolin::Image<T>& v){ return v.Mean();}) 56 .def("RowPtr", (T* (pangolin::Image<T>::*)(size_t))&pangolin::Image<T>::RowPtr) 57 .def("RowPtr", (const T* (pangolin::Image<T>::*)(size_t) const )&pangolin::Image<T>::RowPtr) 58 .def("InImage", &pangolin::Image<T>::InImage) 59 .def("InBounds", (bool (pangolin::Image<T>::*)(int, int) const)&pangolin::Image<T>::InBounds) 60 .def("InBounds", (bool (pangolin::Image<T>::*)(float, float, float) const)&pangolin::Image<T>::InBounds) 61 // .def("SubImage", (pangolin::Image<T> (pangolin::Image<T>::*)(size_t, size_t, size_t, size_t))&pangolin::Image<T>::SubImage) 62 // .def("Row", &pangolin::Image<T>::Row) 63 // .def("Col", &pangolin::Image<T>::Col) 64 .def("InImage", &pangolin::Image<T>::InImage); 65 } 66 67 } // py_pangolin 68