-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_loader_bindings.cpp
More file actions
36 lines (28 loc) · 1.48 KB
/
image_loader_bindings.cpp
File metadata and controls
36 lines (28 loc) · 1.48 KB
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
/*
image_loader_bindings.cpp (c) 2025
Desc: Биндинг с++ методов к питону
*/
#include <../pybind11/include/pybind11/pybind11.h>
#include <../pybind11/include/pybind11/stl.h>
#include "image_loader.h" // Убедитесь, что путь корректен
namespace py = pybind11;
// Объявление функций из image_loader.h
extern ImageFileInfo getImageInfo(const std::string& path);
extern std::vector<unsigned char> loadImage4ub(const std::string &filename);
extern std::vector<unsigned char> image4fToUchar(const std::string &filename, int& outChannels);
extern bool saveImageLDR(const std::string& path, const std::vector<uint8_t>& data, int width, int height, int channels);
PYBIND11_MODULE(image_loader, m) {
m.doc() = "HydraImageConverter Python Bindings";
// Регистрация структуры ImageFileInfo
py::class_<ImageFileInfo>(m, "ImageFileInfo")
.def_readonly("width", &ImageFileInfo::width)
.def_readonly("height", &ImageFileInfo::height)
.def_readonly("channels", &ImageFileInfo::channels)
.def_readonly("path", &ImageFileInfo::path)
.def_readonly("is_ok", &ImageFileInfo::is_ok);
// Экспорт функций
m.def("getImageInfo", &getImageInfo, "Get image metadata");
m.def("loadImage4ub", &loadImage4ub, "Load 8-bit image");
m.def("image4fToUchar", &image4fToUchar, "Load image4f and convert to 8-bit");
m.def("saveImageLDR", &saveImageLDR, "Save LDR image");
}