You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+13-19
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,28 @@
1
1
# pybind11_opencv_numpy
2
2
3
-
An example of pybind11 for cv::Mat <-> np.array
3
+
Binding between cv::Mat and np.array. And a small code example of how it work. the code work for `OpenCV 2.4`, `OpenCV 3+` and `OpenCV 4+`
4
+
5
+
The code in this repository create a simple binding, function in c++ are implemented in `example.cpp` file and the script that use them is `test.py`.
4
6
5
7
```bash
6
8
/project folder
7
9
├── build
8
10
├── example
9
-
│ ├── exemple.so # generate with make
10
-
│ └── example.cpython-36m-x86_64-linux-gnu.so # generate with setup.py
11
+
│ ├── exemple.so # generate with cmake
12
+
│ └── example.cpython-36m-x86_64-linux-gnu.so # generate with setup.py (the name will depends of the python version use)
11
13
├── CMakeLists.txt
12
14
├── setup.py
15
+
├── ndarray_converter.cpp # Effective implementation of the binding
16
+
├── ndarray_converter.h # Header for binding functions
13
17
└── ...
14
18
```
15
19
16
-
## Generation with make
20
+
## Generation with cmake/make
21
+
22
+
*Note* : This method support opencv 2.4, opencv 3 and opencv 4.
17
23
18
24
We use [vcpkg](https://github.com/Microsoft/vcpkg) to install [pybind11](https://github.com/pybind/pybind11) library
19
25
20
-
*Note* : This method support opencv 2.4, opencv 3 and opencv 4.
21
26
22
27
```
23
28
./vcpkg install pybind11
@@ -36,11 +41,6 @@ make
36
41
make install
37
42
```
38
43
39
-
### Run
40
-
```bash
41
-
python3 test.py
42
-
```
43
-
44
44
## Generation with setup.py
45
45
46
46
@@ -52,15 +52,15 @@ pip3 install pybind11
52
52
53
53
### Compile
54
54
55
-
#### Opencv2.4+, Opencv3+
55
+
#### OpenCV 2.4+, OpenCV 3+
56
56
57
57
```
58
58
python3 setup.py build
59
59
```
60
60
61
-
#### Opencv4
61
+
#### OpenCV 4
62
62
63
-
In Opencv4, there a extra folder level for header (ex: `opencv4/opencv2/core/core.hpp`). To be able to compile with `setup.py` we need a extra command to indicate header location.
63
+
In OpenCV 4, there a extra folder level for headers (ex: `opencv4/opencv2/core/core.hpp`). To be able to compile with `setup.py` we need a extra command to indicate header location.
0 commit comments