dlib.cpp 1.94 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <boost/python.hpp>
#include <dlib/matrix.h>
#include <sstream>
#include <string>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
#include <boost/python/suite/indexing/indexing_suite.hpp>
#include <boost/shared_ptr.hpp>

#include <dlib/string.h>
#include "serialize_pickle.h"

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


void bind_matrix();
void bind_vector();
void bind_svm_c_trainer();

BOOST_PYTHON_MODULE(dlib)
{
    bind_matrix();
    bind_vector();
    bind_svm_c_trainer();

    class_<std::vector<double> >("array")
        .def(vector_indexing_suite<std::vector<double> >())
        .def_pickle(serialize_pickle<std::vector<double> >());

    class_<std::vector<matrix<double,0,1> > >("vectors")
        .def(vector_indexing_suite<std::vector<matrix<double,0,1> > >())
        .def_pickle(serialize_pickle<std::vector<matrix<double,0,1> > >());

    typedef pair<unsigned long,double> pair_type;
    class_<pair_type>("pair", "help message", init<>() )
        .def(init<unsigned long,double>())
        .def_readwrite("first",&pair_type::first, "THE FIRST, LOVE IT!")
        .def_readwrite("second",&pair_type::second)
        .def_pickle(serialize_pickle<pair_type>());

    class_<std::vector<pair_type> >("sparse_vector")
        .def(vector_indexing_suite<std::vector<pair_type> >())
        .def_pickle(serialize_pickle<std::vector<pair_type> >());

    class_<std::vector<std::vector<pair_type> > >("sparse_vectors")
        .def(vector_indexing_suite<std::vector<std::vector<pair_type> > >())
        .def_pickle(serialize_pickle<std::vector<std::vector<pair_type> > >());

    /*
    def("tomat",tomat);
    def("add_to_map", add_to_map);
    def("getpair", getpair);
    def("getmatrix", getmatrix);
    def("yay", yay);
    def("sum", sum_mat);
    def("getmap", getmap);
    def("go", go);
    def("append_to_vector", append_to_vector);
    */




}