Python binding stitcher class
My problem is translate this C++ code in python ... I want to generate 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 np
import cv2 as cv
finder= cv.xfeatures2d_SURF.create()
imgListe=[]
img = cv.imread('f:/images/pano/pano1.jpg')
imgListe.append(img)
img = cv.imread('f:/images/pano/pano2.jpg')
imgListe.append(img)
img = cv.imread('f:/images/pano/pano3.jpg')
imgListe.append(img)
features=[]
for img in imgListe:
imgFea= cv.detail.computeImageFeatures2(finder,img)
features.append(imgFea)
matcher=cv.detail.BestOf2NearestMatcher_create(False,0.3,6,6)
p=matcher.apply2(features)
indices=cv.detail.leaveBiggestComponent(features,p,0.3)
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 value of c++ vector in python ?
private message : @berak any idea?
lol, i already promise: you won't get happy with the idea. the solution for #13187 might be:
(but you obviously have found out on your own, i guess ;)
but i'm puzzled. shouldn't the current problem with
to()
be covered from here ?can you add the resp. c++ wrapper from build/modules/python_bindings_generator/pyopencv_???.h
also, isn't everything in ImageFeatures "read-only" ?
hmm, (alternative idea) -- what would be the c++ use-case of the functionality, you're trying to wrap here ?
sometimes, it might be easier, to add a new c++ function (with an "easier to wrap" interface), that does it all under the hood (without having to expose "problematic types"). related: https://github.com/opencv/opencv_cont...
CV_WRAP_AS(apply) thanks I didn't find it : I was looking how to generate python doc in VS 2017. (update cmake and add BeautifulSoup and -DPYTHON_EXECUTABLE="C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe"
I pushed on https://github.com/LaurentBerger/open... Is it enough?
I want to write stitching_detailed in python : Brute force method
what do you think of the "alternative" idea? would not that be far easier (and more clean) ?
python_binding genrator
"what do you think of the "alternative" idea?" use c++ class and simply wrap as here https://github.com/opencv/opencv_cont...
Change this:
@LBerger, can you add the c++ code for your pipeline to the question ?
(again, imho, wrapping that (with already known types would be far more useful,than having to extend the python / java ??? wrappers, based on your original idea.)
Problem : CV_WRAP_AS(apply) operator() does not generate any python documentation
work in progress