Skip to content

Python: wrap Algorithm::read and Algorithm::write#9247

Merged
opencv-pushbot merged 2 commits intoopencv:masterfrom
paroj:wrap_alog_rw
Nov 28, 2017
Merged

Python: wrap Algorithm::read and Algorithm::write#9247
opencv-pushbot merged 2 commits intoopencv:masterfrom
paroj:wrap_alog_rw

Conversation

@paroj
Copy link
Copy Markdown
Contributor

@paroj paroj commented Jul 27, 2017

No description provided.

@vpisarev vpisarev self-assigned this Jul 31, 2017
@vpisarev
Copy link
Copy Markdown
Contributor

thank you! it would be useful to provide some test for this functionality

@paroj
Copy link
Copy Markdown
Contributor Author

paroj commented Jul 31, 2017

I could not find a testing unit for the Algorithm API to add such a test to. It seems the only the Feature2D tests are currently using the Algorithm API at all. The HOGDescriptor provides a similar API, but does not derive from Algorithm.

Creating a new testing unit is beyond the scope of this PR though.

@paroj
Copy link
Copy Markdown
Contributor Author

paroj commented Jul 31, 2017

or do you mean a pure python test? It would still have to depend on a random non-core algorithm implementing the API.

@paroj
Copy link
Copy Markdown
Contributor Author

paroj commented Aug 17, 2017

bump

@paroj
Copy link
Copy Markdown
Contributor Author

paroj commented Aug 28, 2017

@alalek @sovrasov

@paroj
Copy link
Copy Markdown
Contributor Author

paroj commented Sep 7, 2017

bump

@alalek
Copy link
Copy Markdown
Member

alalek commented Nov 22, 2017

Problem of this patch (actually in bindings generator) is here:

must rename it as it is overloaded in e.g Feature2D

Renaming "read => read2" in base class (not in derived) class doesn't look as appropriate change.
I believe we should fix bindings generator for this problem somehow.

@paroj
Copy link
Copy Markdown
Contributor Author

paroj commented Nov 22, 2017

Renaming "read => read2" in base class (not in derived) class doesn't look as appropriate change.

yes, but manual renaming is necessary as python does not support overloading. However we can not rename "read" in derived class as it would break the python API - therefore we must rename it in the base class.

Which alternative behavior would you have in mind? An dispatcher in the bindings that emulates overloading for python?

@alalek
Copy link
Copy Markdown
Member

alalek commented Nov 22, 2017

dispatcher in the bindings that emulates overloading

Emulation already exists in Python bindings, but it doesn't look into base classes.
Actually C++ doesn't look on overloads from base class too. To enable this we need "using base_class::method_name;" in derived classes.

Also there is another question about Java bindings.

I have some POC, but it is still very questionable.
Tested on Linux (with python2):

(opencv_build)$ (export PYTHONPATH=`pwd`/lib; cd opencv_src_dir/dev/modules/python/test; OPENCV_PYTEST_FILTER=test_algorithm_rw python2 test.py -v)

@alalek
Copy link
Copy Markdown
Member

alalek commented Nov 23, 2017

@paroj Try to apply this patch: alalek@pr9247_r2

@paroj
Copy link
Copy Markdown
Contributor Author

paroj commented Nov 24, 2017

works for me/ python3, linux. Thats an elegant way to trick the parser into doing the right thing. 👍

@alalek
Copy link
Copy Markdown
Member

alalek commented Nov 27, 2017

@paroj Thank you for checking that!
Could you apply these changes to this PR?

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@opencv-pushbot opencv-pushbot merged commit 3c795a0 into opencv:master Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants