I want to convert keypoints in C++ to python [closed]
Hi,
Recently, I implemented a new method about detecting keypoints in C++. (the method is not included in OpenCV library yet) Then I want to evaluate the keypoint results in python. So I need to write a python wrapper to convert the keypoints in C++ to Keypoints in python.
Specifically: I performed
vector<KeyPoint> kps1 = NewAlgorithm_KeypointDetector(XXX); //in C++
and then I want to transfer the keypoint result to python.
I searched many materials, including using CV_WRAP, but I don't know how to use it. Or I checked cv2.cpp file, there is pyopencv_from() and pyopencv_to() function, but I am not able to directly call them to do the python wrapper. Im using Boost.python currently, so how should I deal with it?
Thanks in advance.
Best regards, Weibo Qiu.
what is XXX ?
are you able to build the cv2 bindings locally ?
it's probably far easier, if you put your function inside the opencv modules (or maybe add a new one) and build it along with the other opencv code
XXX are just some parameters. The function returns result as vector <keypoint> cv2 bindings building is successful, I have python_binding_generator folder.
But what do you mean "put your function inside the opencv modules" ? which opencv module?
nonetheless, please specify your XXX parameters exactly.
then, we can try to help you to add your function e.g. to the features2d module, so you can use it in the same way as the builtin function.
I also found a function "static PyObject pyopencv_cv_KeyPoint_convert(PyObject* , PyObject* args, PyObject* kw)*" in pyopencv_generated_funcs.h file . Can I use it directly to convert?
Hi berak,
Thanks for your reply. But this algorithm has not been published yet and has some credential issue. So there is no easier way to convert keypoints from c++ to python?
imho, you're trying this from the wrong end.
vector<KeyPoint>
as well asKeyPoint::convert()
are already perfectly covered from the existing cv2 functionality, there is nothing you have to do here.it's only a problem, if you try to use Boost for wrapping, because then, you have to start from scratch (so don't do that !)
But I also read how to extend new modules to Python (link text)
Is it possible to use CV_WRAP to extend my NewAlgorithm_KeypointDetector() function ? So that the results keypoints can be wrappered to python.
CV_EXPORTS, not CV_WRAP. (and that's exactly what i'm trying to push you to do all the time... ;)
but again, tell us, what XXX is exactly, and we can give you the correct syntax ...
Hi berak,
I'll check it tomorrow and see if it is feasible to reveal the NewAlgorithm_KeypointDetector() function. Thanks for your help!
lol, you don't have to reveal your function only the signature of it.