
#include#include #include #include using namespace std; //using namespace cv; namespace py = pybind11; double getimg(py::array_t input) { // read input arrays buffer_info py::buffer_info buf = input.request(); // allocate the output buffer py::array_t result = py::array_t (buf.size); double* ptr = (double*)buf.ptr; double high = buf.shape[0]; double width = buf.shape[1]; cout << "high" << high << endl; cout << "width" << width << endl; cout << "ptr" << ptr << endl; //Mat mat(high, width, CV_8UC3, ptr); // Add both arrays return 1; } PYBIND11_MODULE(meiyan, m) { m.doc() = "Add two vectors using pybind11"; // optional module docstring m.def("getimg", &getimg, "Add two NumPy arrays"); }
import numpy as np
import cv2
import meiyan
img = cv2.imread('1.jpg')
print(np.shape(img))
print(type(img))
c = meiyan.getimg(img)
print(c)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)