Beispiel #1
0
void init_pykmstest(py::module &m)
{
    py::class_<RGB>(m, "RGB")
    .def(py::init<>())
    .def(py::init<uint8_t, uint8_t, uint8_t&>())
    .def(py::init<uint8_t, uint8_t, uint8_t, uint8_t&>())
    .def_property_readonly("rgb888", &RGB::rgb888)
    .def_property_readonly("argb8888", &RGB::argb8888)
    .def_property_readonly("abgr8888", &RGB::abgr8888)
    .def_property_readonly("rgb565", &RGB::rgb565)
    ;

    py::class_<ResourceManager>(m, "ResourceManager")
    .def(py::init<Card&>())
    .def("reset", &ResourceManager::reset)
    .def("reserve_connector", &ResourceManager::reserve_connector,
         py::arg("name") = string())
    .def("reserve_crtc", &ResourceManager::reserve_crtc)
    .def("reserve_plane", &ResourceManager::reserve_plane,
         py::arg("crtc"),
         py::arg("type"),
         py::arg("format") = PixelFormat::Undefined)
    .def("reserve_primary_plane", &ResourceManager::reserve_primary_plane,
         py::arg("crtc"),
         py::arg("format") = PixelFormat::Undefined)
    .def("reserve_overlay_plane", &ResourceManager::reserve_overlay_plane,
         py::arg("crtc"),
         py::arg("format") = PixelFormat::Undefined)
    ;

    // Use lambdas to handle IMappedFramebuffer
    m.def("draw_test_pattern", [](MappedFramebuffer& fb) {
        draw_test_pattern(fb);
    } );
    m.def("draw_color_bar", [](MappedFramebuffer& fb, int old_xpos, int xpos, int width) {
        draw_color_bar(fb, old_xpos, xpos, width);
    } );
    m.def("draw_rect", [](MappedFramebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color) {
        draw_rect(fb, x, y, w, h, color);
    } );
}
Beispiel #2
0
void bind_numpy_returns(py::module &m)
{
    m.def("load_rgb_image", &load_rgb_image, 
	"Takes a path and returns a numpy array (RGB) containing the image",
	py::arg("path")
    );

    m.def("save_image", &save_image<rgb_pixel>, 
	"Saves the given image to the specified path. Determines the file type from the file extension specified in the path",
	py::arg("img"), py::arg("path")
    );
    m.def("save_image", &save_image<unsigned char>, 
	"Saves the given image to the specified path. Determines the file type from the file extension specified in the path",
	py::arg("img"), py::arg("path")
    );

    m.def("jitter_image", &get_jitter_images, 
    "Takes an image and returns a list of jittered images."
    "The returned list contains num_jitters images (default is 1)."
    "If disturb_colors is set to True, the colors of the image are disturbed (default is False)", 
    py::arg("img"), py::arg("num_jitters")=1, py::arg("disturb_colors")=false
    );

    m.def("get_face_chip", &get_face_chip, 
	"Takes an image and a full_object_detection that references a face in that image and returns the face as a Numpy array representing the image.  The face will be rotated upright and scaled to 150x150 pixels or with the optional specified size and padding.", 
	py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25
    );

    m.def("get_face_chips", &get_face_chips, 
	"Takes an image and a full_object_detections object that reference faces in that image and returns the faces as a list of Numpy arrays representing the image.  The faces will be rotated upright and scaled to 150x150 pixels or with the optional specified size and padding.",
	py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25
    );
}
void for_python_result_set(pybind11::module & module)
{
	// expose base result set with explicit holder class to allow passing of
	// shared pointer arguments
	pybind11::class_<base_result_set, std::shared_ptr<base_result_set>>(module, "BaseResultSet");

	pybind11::class_<python_result_set>(module, "ResultSet")
			.def("get_column_info", &python_result_set::get_column_info)
			.def("fetch_row", &python_result_set::fetch_row)
		;

	module.def("make_row_based_result_set", make_python_result_set);
}
Beispiel #4
0
void export_common(py::module& m)
{
  py::enum_<sc::DType>(m, "dtype")
      .value("float32", sc::DType::FLOAT_TYPE)
      .value("float64", sc::DType::DOUBLE_TYPE)
      .export_values();

  m.def("size_of", sc::size_of);

  py::class_<sc::scalar>(m, "Scalar")
      .def(py::init<float, sc::DType>())
      .def(py::init<double, sc::DType>())
      .def_property_readonly("dtype", &sc::scalar::dtype);
}
Beispiel #5
0
void bind_svm_rank_trainer(py::module& m)
{
    py::class_<ranking_pair<sample_type> >(m, "ranking_pair")
        .def(py::init())
        .def_readwrite("relevant", &ranking_pair<sample_type>::relevant)
        .def_readwrite("nonrelevant", &ranking_pair<sample_type>::nonrelevant)
        .def(py::pickle(&getstate<ranking_pair<sample_type>>, &setstate<ranking_pair<sample_type>>));

    py::class_<ranking_pair<sparse_vect> >(m, "sparse_ranking_pair")
        .def(py::init())
        .def_readwrite("relevant", &ranking_pair<sparse_vect>::relevant)
        .def_readwrite("nonrelevant", &ranking_pair<sparse_vect>::nonrelevant)
        .def(py::pickle(&getstate<ranking_pair<sparse_vect>>, &setstate<ranking_pair<sparse_vect>>));

    py::bind_vector<ranking_pairs>(m, "ranking_pairs")
        .def("clear", &ranking_pairs::clear)
        .def("resize", resize<ranking_pairs>)
        .def("extend", extend_vector_with_python_list<ranking_pair<sample_type>>)
        .def(py::pickle(&getstate<ranking_pairs>, &setstate<ranking_pairs>));

    py::bind_vector<sparse_ranking_pairs>(m, "sparse_ranking_pairs")
        .def("clear", &sparse_ranking_pairs::clear)
        .def("resize", resize<sparse_ranking_pairs>)
        .def("extend", extend_vector_with_python_list<ranking_pair<sparse_vect>>)
        .def(py::pickle(&getstate<sparse_ranking_pairs>, &setstate<sparse_ranking_pairs>));

    add_ranker<svm_rank_trainer<linear_kernel<sample_type> > >(m, "svm_rank_trainer");
    add_ranker<svm_rank_trainer<sparse_linear_kernel<sparse_vect> > >(m, "svm_rank_trainer_sparse");

    m.def("cross_validate_ranking_trainer", &_cross_ranking_validate_trainer<
                svm_rank_trainer<linear_kernel<sample_type> >,sample_type>,
                py::arg("trainer"), py::arg("samples"), py::arg("folds") );
    m.def("cross_validate_ranking_trainer", &_cross_ranking_validate_trainer<
                svm_rank_trainer<sparse_linear_kernel<sparse_vect> > ,sparse_vect>,
                py::arg("trainer"), py::arg("samples"), py::arg("folds") );
}
void wrapper_95d0d4d7e8215bf98789264a4aeb8c71(pybind11::module& module)
{

    module.def("set_seed", function_pointer_95d0d4d7e8215bf98789264a4aeb8c71, "");
}
Beispiel #7
0
void exportPyLazyCaller(py::module m)
{
    m.def("callLater", [](py::function func){ cnoid::callLater(PyFunc(func)); });
    m.def("callSynchronously", [](py::function func){ cnoid::callSynchronously(PyFunc(func)); });
}
Beispiel #8
0
void fifi_utils(pybind11::module& m, const std::string& field)
{
    using namespace pybind11;

    m.def((field + std::string("_elements_to_length")).c_str(),
          &fifi::elements_to_length<Field>,
          arg("elements"),
          "Returns the number of value_type elements needed to store a "
          "certain number of field elements.\n\n"
          "elemenets.\n\n"
          "\t:param elements: The number of elements.\n"
          "\t:return: The number of value_type elements needed.\n");
    m.def((field + std::string("_elements_to_size")).c_str(),
          &fifi::elements_to_size<Field>,
          arg("elements"),
          "Returns the minimum size in bytes required to accommodate a "
          "certain number of field elements.\n\n"
          "\t:param elements: the number of field elements.\n"
          "\t:return: the size in bytes needed to store the field "
          "elements.\n");
    m.def((field + std::string("_size_to_length")).c_str(),
          &fifi::size_to_length<Field>, arg("bytes"),
          "Returns the number of value_type elements needed to store "
          "a certain number of bytes.\n\n"
          "\t:param bytes: the number of bytes to store.\n"
          "\t:return: the number of value_type elements that need to be "
          "stored.\n");
    m.def((field + std::string("_length_to_size")).c_str(),
          &fifi::length_to_size<Field>, arg("length"),
          "Returns the size in bytes needed to store a certain "
          "number of value_type elements.\n\n"
          "\t:param length: the number of value_type elements to store.\n"
          "\t:return: the size in bytes needed to store the value_type "
          "elements.\n");
    m.def((field + std::string("_length_to_elements")).c_str(),
          &fifi::length_to_elements<Field>,
          arg("length"),
          "Returns the number of field elements needed to store a certain "
          "number of value_type elements.\n\n"
          "\t:param length: the number of value_type elements.\n"
          "\t:return: the number of field elements needed.\n");
    m.def((field + std::string("_size_to_elements")).c_str(),
          &fifi::size_to_elements<Field>, arg("bytes"),
          "Returns the number of field elements that can fit within a "
          "certain number of bytes.\n\n"
          "\t:param bytes: the number of bytes to store the field elements.\n"
          "\t:return: the number of field elements stored within the bytes.\n");
    m.def((field + std::string("_get_value")).c_str(),
          &get_value<Field>,
          arg("elements"), arg("index"),
          "Useful abstraction function for accessing field elements in a "
          "buffer. Note this function assumes that values are packed.\n\n"
          "\t:param elements: elements to get value from.\n"
          "\t:param index: index of element to access in the packed buffer.\n"
          "\t:return: the value of the element at specified index.\n");
    m.def((field + std::string("_set_value")).c_str(),
          &set_value<Field>,
          arg("elements"), arg("index"), arg("value"),
          "Useful abstraction function for assigning field elements in a "
          "buffer a specific value. Note this function assumes that values "
          "are packed.\n\n"
          "\t:param elements: elements to manipulate.\n"
          "\t:param index: index of element.\n"
          "\t:param value: value to assign element.\n"
          "\t:return: The modified buffer.\n");
    m.def((field + std::string("_pack_constant")).c_str(),
          &fifi::pack_constant<Field>, arg("constant"),
          "Helper function for creating packed constants. In Fifi we refer "
          "to values as packed if they utilize the entire underlying data "
          "type. As an example binary4 uses four bits for every field "
          "element but since no 4-bit data types are available we store it's "
          "value in an uint8_t. When using APIs requiring packed data we "
          "therefore have to pack the constant which ensures that both the "
          "high an low 4 bits have the right constant value (in the case of "
          "binary4).\n\n"
          "\t:param constant: The constant to pack.\n"
          "\t:return: The packed constant.\n");
}
void wrapper_cfd7d1ec1fbc514b9feba31d16e55cf6(pybind11::module& module)
{

    module.def("get_nn", function_pointer_cfd7d1ec1fbc514b9feba31d16e55cf6, pybind11::return_value_policy::copy, "");
}
Beispiel #10
0
void install_toolmain(pybind11::module& m)
{
    m.def("toolmain", &toolmain);
}
void wrapper_1a16c32a3d8f5d01b8d739fb757db381(pybind11::module& module)
{

    module.def("set_seed", function_pointer_1a16c32a3d8f5d01b8d739fb757db381, "");
}