Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 应为LP_c_ubyte实例,而不是memoryview_Python_Opencv_Ctypes - Fatal编程技术网

Python 应为LP_c_ubyte实例,而不是memoryview

Python 应为LP_c_ubyte实例,而不是memoryview,python,opencv,ctypes,Python,Opencv,Ctypes,当我将图像数据发送到c函数时,出现了一个错误 ctypes.ArgumentError: argument 2: <class 'TypeError'>: expected LP_c_ubyte instance instead of memoryview P>和C++,我注意到C++用CV包< /P>发送图像数据。 using namespace cv; Mat m_image_mat; m_image_mat = imread ( full_file_name ); cv

当我将图像数据发送到c函数时,出现了一个错误

ctypes.ArgumentError: argument 2: <class 'TypeError'>: expected LP_c_ubyte instance instead of memoryview
<> P>和C++,我注意到C++用CV包< /P>发送图像数据。
using namespace cv;

Mat m_image_mat;
m_image_mat = imread ( full_file_name );

cv_face_detect(..., m_image_mat.data, ...);
在python中,我设置了argtypes,并使用vc2发送图像数据

cv_face_detect.argtypes = (..., POINTER(c_ubyte), ...)

img = cv2.imread('1.jpg')
cv_face_detect(..., img.data, ...)
然后,错误出现了

我不知道如何将memoryview转换为const unsigned char*数据,我可以将图像数据发送到c函数


谢谢

从任何代码> >记忆视图>代码>引用,可能有更直接的路径,而不是使用视图。@ ErrkSun谢谢,我使用CVMAT= CV.FROMARRY(IMG),我得到CVMAT对象,我认为它与C++ CV::Mat数据属性相似,但是CVMAT没有数据属性…
cv_face_detect.argtypes = (..., POINTER(c_ubyte), ...)

img = cv2.imread('1.jpg')
cv_face_detect(..., img.data, ...)