-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.cpp
More file actions
52 lines (37 loc) · 1.03 KB
/
example.cpp
File metadata and controls
52 lines (37 loc) · 1.03 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <pybind11/pybind11.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include "ndarray_converter.h"
#include <string>
#include <iostream>
namespace py = pybind11;
void show_image(cv::Mat image)
{
cv::imshow("image_from_Cpp", image);
cv::waitKey(0);
}
cv::Mat read_image(std::string image_name)
{
cv::Mat image = cv::imread(image_name, CV_LOAD_IMAGE_COLOR);
return image;
}
cv::Mat passthru(cv::Mat image)
{
return image;
}
cv::Mat cloneimg(cv::Mat image)
{
return image.clone();
}
PYBIND11_MODULE(example, m)
{
NDArrayConverter::init_numpy();
m.doc() = "pybind11 opencv example plugin";
m.def("read_image", &read_image, "A function that read an image",
py::arg("image"));
m.def("show_image", &show_image, "A function that show an image",
py::arg("image"));
m.def("passthru", &passthru, "Passthru function", py::arg("image"));
m.def("clone", &cloneimg, "Clone function", py::arg("image"));
}