Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dictionary bindings #3229

Merged
merged 2 commits into from
Apr 25, 2022

Conversation

AleksandrPanov
Copy link
Contributor

@AleksandrPanov AleksandrPanov commented Apr 14, 2022

Added python bindings for identify()/getDistanceToId()

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov
Copy link
Contributor

@AleksandrPanov please add smoke test with python to check that API is available.

@asmorkalov
Copy link
Contributor

Ubuntu 18.04 amd64, python 3.6.9:

alexander@asmorkalov-pc:~/Projects/opencv_contrib/modules/aruco/misc/python/test$ python3 -m pytest -v .
============================================================================================================================= test session starts =============================================================================================================================
platform linux -- Python 3.6.9, pytest-6.0.1, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/alexander/Projects/opencv_contrib/modules/aruco/misc/python/test
collected 5 items                                                                                                                                                                                                                                                             

test_aruco.py::aruco_test::test_drawCharucoDiamond PASSED                                                                                                                                                                                                               [ 20%]
test_aruco.py::aruco_test::test_getDistanceToId FAILED                                                                                                                                                                                                                  [ 40%]
test_aruco.py::aruco_test::test_identify PASSED                                                                                                                                                                                                                         [ 60%]
test_aruco.py::aruco_test::test_idsAccessibility PASSED                                                                                                                                                                                                                 [ 80%]
test_aruco.py::aruco_test::test_write_read_dict PASSED                                                                                                                                                                                                                  [100%]

================================================================================================================================== FAILURES ===================================================================================================================================
_______________________________________________________________________________________________________________________ aruco_test.test_getDistanceToId _______________________________________________________________________________________________________________________

self = <test_aruco.aruco_test testMethod=test_getDistanceToId>

    def test_getDistanceToId(self):
        aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
        idx = 7
        rotation = 3
        bit_marker = np.array([[0, 1, 0, 1], [0, 1, 1, 1], [1, 1, 0, 0], [0, 1, 0, 0]])
>       dist = aruco_dict.getDistanceToId(bit_marker, idx, dtype=np.uint8)
E       cv2.error: OpenCV(4.5.5-dev) :-1: error: (-5:Bad argument) in function 'getDistanceToId'
E       > Overload resolution failed:
E       >  - 'dtype' is an invalid keyword argument for this function
E       >  - 'dtype' is an invalid keyword argument for this function

test_aruco.py:84: error

@AleksandrPanov
Copy link
Contributor Author

AleksandrPanov commented Apr 21, 2022

Ubuntu 18.04 amd64, python 3.6.9:

alexander@asmorkalov-pc:~/Projects/opencv_contrib/modules/aruco/misc/python/test$ python3 -m pytest -v .
============================================================================================================================= test session starts =============================================================================================================================
platform linux -- Python 3.6.9, pytest-6.0.1, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/alexander/Projects/opencv_contrib/modules/aruco/misc/python/test
collected 5 items                                                                                                                                                                                                                                                             

test_aruco.py::aruco_test::test_drawCharucoDiamond PASSED                                                                                                                                                                                                               [ 20%]
test_aruco.py::aruco_test::test_getDistanceToId FAILED                                                                                                                                                                                                                  [ 40%]
test_aruco.py::aruco_test::test_identify PASSED                                                                                                                                                                                                                         [ 60%]
test_aruco.py::aruco_test::test_idsAccessibility PASSED                                                                                                                                                                                                                 [ 80%]
test_aruco.py::aruco_test::test_write_read_dict PASSED                                                                                                                                                                                                                  [100%]

================================================================================================================================== FAILURES ===================================================================================================================================
_______________________________________________________________________________________________________________________ aruco_test.test_getDistanceToId _______________________________________________________________________________________________________________________

self = <test_aruco.aruco_test testMethod=test_getDistanceToId>

    def test_getDistanceToId(self):
        aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
        idx = 7
        rotation = 3
        bit_marker = np.array([[0, 1, 0, 1], [0, 1, 1, 1], [1, 1, 0, 0], [0, 1, 0, 0]])
>       dist = aruco_dict.getDistanceToId(bit_marker, idx, dtype=np.uint8)
E       cv2.error: OpenCV(4.5.5-dev) :-1: error: (-5:Bad argument) in function 'getDistanceToId'
E       > Overload resolution failed:
E       >  - 'dtype' is an invalid keyword argument for this function
E       >  - 'dtype' is an invalid keyword argument for this function

test_aruco.py:84: error

@asmorkalov fixed

Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

Tested on Ubuntu 18.04 amd64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants