pybind11 C++读取图像

pybind11 C++读取图像,第1张

pybind11 C++读取图像
#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)

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5719081.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-18
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存