Sha256: dff33f96ddafe0689c73d8b45ddaade47bccd6206122fbdb17476ab3cd1fba99

Contents?: true

Size: 1.15 KB

Versions: 13

Compression:

Stored size: 1.15 KB

Contents

#include <dlib/python.h>
#include <boost/python/args.hpp>
#include "dlib/pixel.h"

using namespace dlib;
using namespace std;
using namespace boost::python;

// ----------------------------------------------------------------------------------------

string print_rgb_pixel_str(const rgb_pixel& p)
{
    std::ostringstream sout;
    sout << "red: "<< (int)p.red
         << ", green: "<< (int)p.green
         << ", blue: "<< (int)p.blue;
    return sout.str();
}

string print_rgb_pixel_repr(const rgb_pixel& p)
{
    std::ostringstream sout;
    sout << "rgb_pixel(" << p.red << "," << p.green << "," << p.blue << ")";
    return sout.str();
}

// ----------------------------------------------------------------------------------------
void bind_image_classes()
{
    using boost::python::arg;

    class_<rgb_pixel>("rgb_pixel")
        .def(init<unsigned char,unsigned char,unsigned char>( (arg("red"),arg("green"),arg("blue")) ))
        .def("__str__", &print_rgb_pixel_str)
        .def("__repr__", &print_rgb_pixel_repr)
        .add_property("red", &rgb_pixel::red)
        .add_property("green", &rgb_pixel::green)
        .add_property("blue", &rgb_pixel::blue);
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dlib-1.2.2 ext/dlib-19.4/tools/python/src/image.cpp
dlib-1.2.1 ext/dlib-19.4/tools/python/src/image.cpp
dlib-1.2.0 ext/dlib-19.4/tools/python/src/image.cpp
dlib-1.1.5 ext/dlib-19.4/tools/python/src/image.cpp
dlib-1.1.4 ext/dlib-19.4/tools/python/src/image.cpp
dlib-1.1.3 ext/dlib-19.4/tools/python/src/image.cpp
dlib-1.1.2 ext/dlib-19.4/tools/python/src/image.cpp
dlib-1.1.1 ext/dlib-19.4/tools/python/src/image.cpp
dlib-1.1.0 ext/dlib-19.4/tools/python/src/image.cpp
dlib-1.0.3 ext/dlib-18.13/tools/python/src/image.cpp
dlib-1.0.2 ext/dlib-18.13/tools/python/src/image.cpp
dlib-1.0.1 ext/dlib-18.13/tools/python/src/image.cpp
dlib-1.0.0 ext/dlib-18.13/tools/python/src/image.cpp