I want to genrate python binding for :
struct CV_EXPORTS ImageFeatures
{
int img_idx;
Size img_size;
std::vector<KeyPoint> keypoints;
UMat descriptors;
};
I have done :
struct CV_EXPORTS_W_SIMPLE ImageFeatures
{
CV_PROP_RW int img_idx;
CV_PROP_RW Size img_size;
std::vector<KeyPoint> keypoints;
CV_PROP_RW UMat descriptors;
CV_WRAP std::vector<KeyPoint> getKeypoints() { return keypoints; };
};
and it works :
import numpy as cv
import cv2 as cv
finder= cv.xfeatures2d_SURF.create()
img = cv.imread('g:/lib/opencv/samples/data/baboon.jpg')
imgFea= cv.detail.computeImageFeatures2(finder,img)
x=imgFea.getKeypoints()
x[0].pt
(334.60760498046875, 54.20581817626953)
My problem is when I add CV_PROP_RW before std::vector<keypoint> keypoints; I have got a compilation error :
10>G:\Lib\opencv\modules\python\src2\cv2.cpp(24): error C2039: 'to': is not a member of 'PyOpenCV_Converter<T,void>'
10> with
10> [
10> T=vector_KeyPoint
10> ]
10>G:\Lib\opencv\modules\python\src2\cv2.cpp(24): note: see declaration of 'PyOpenCV_Converter<T,void>'
10> with
10> [
10> T=vector_KeyPoint
10> ]
10>G:\Lib\build\opencv\modules\python_bindings_generator\pyopencv_generated_types.h(72119): note: see reference to function template instantiation 'bool pyopencv_to<vector_KeyPoint>(PyObject *,T &,const char *)' being compiled
10> with
10> [
10> T=vector_KeyPoint
10> ]
10>G:\Lib\opencv\modules\python\src2\cv2.cpp(24): error C3861: 'to': identifier not found
10>Done building project "opencv_python3.vcxproj" -- FAILED.
Then i add a method to get vector<keypoints> and removed CV_WRAP_RW. Is it only way to get a c++ vector in python ?