|
| 1 | +|Build Status| |codecov| |PyPI| |Documentation Status| |
| 2 | + |
| 3 | +vws-python |
| 4 | +========== |
| 5 | + |
| 6 | +Python library for the Vuforia Web Services (VWS) API and the Vuforia |
| 7 | +Web Query API. |
| 8 | + |
| 9 | +Installation |
| 10 | +------------ |
| 11 | + |
| 12 | +.. code:: sh |
| 13 | +
|
| 14 | + pip install vws-python |
| 15 | +
|
| 16 | +This is tested on Python 3.11+. Get in touch with |
| 17 | +``adamdangoor@gmail.com`` if you would like to use this with another |
| 18 | +language. |
| 19 | + |
| 20 | +Getting Started |
| 21 | +--------------- |
| 22 | + |
| 23 | +.. invisible-code-block: python |
| 24 | +
|
| 25 | + import pathlib |
| 26 | + import shutil |
| 27 | +
|
| 28 | + import vws_test_fixtures |
| 29 | + from mock_vws import MockVWS |
| 30 | + from mock_vws.database import VuforiaDatabase |
| 31 | +
|
| 32 | + mock = MockVWS(real_http=False) |
| 33 | + database = VuforiaDatabase( |
| 34 | + server_access_key='[server-access-key]', |
| 35 | + server_secret_key='[server-secret-key]', |
| 36 | + client_access_key='[client-access-key]', |
| 37 | + client_secret_key='[client-secret-key]', |
| 38 | + ) |
| 39 | + mock.add_database(database=database) |
| 40 | + mock.__enter__() |
| 41 | +
|
| 42 | + # We rely on implementation details of the fixtures package. |
| 43 | + image = pathlib.Path(vws_test_fixtures.__path__[0]) / 'high_quality_image.jpg' |
| 44 | + assert image.exists(), image.resolve() |
| 45 | + new_image = pathlib.Path('high_quality_image.jpg') |
| 46 | + shutil.copy(image, new_image) |
| 47 | +
|
| 48 | +
|
| 49 | +.. code-block:: python |
| 50 | +
|
| 51 | + import pathlib |
| 52 | +
|
| 53 | + from vws import VWS, CloudRecoService |
| 54 | +
|
| 55 | + server_access_key = '[server-access-key]' |
| 56 | + server_secret_key = '[server-secret-key]' |
| 57 | + client_access_key = '[client-access-key]' |
| 58 | + client_secret_key = '[client-secret-key]' |
| 59 | +
|
| 60 | + vws_client = VWS( |
| 61 | + server_access_key=server_access_key, |
| 62 | + server_secret_key=server_secret_key, |
| 63 | + ) |
| 64 | + cloud_reco_client = CloudRecoService( |
| 65 | + client_access_key=client_access_key, |
| 66 | + client_secret_key=client_secret_key, |
| 67 | + ) |
| 68 | + name = 'my_image_name' |
| 69 | +
|
| 70 | + image = pathlib.Path('high_quality_image.jpg') |
| 71 | + with image.open(mode='rb') as my_image_file: |
| 72 | + target_id = vws_client.add_target( |
| 73 | + name=name, |
| 74 | + width=1, |
| 75 | + image=my_image_file, |
| 76 | + active_flag=True, |
| 77 | + application_metadata=None, |
| 78 | + ) |
| 79 | + vws_client.wait_for_target_processed(target_id=target_id) |
| 80 | + matching_targets = cloud_reco_client.query(image=my_image_file) |
| 81 | +
|
| 82 | + assert matching_targets[0].target_id == target_id |
| 83 | +
|
| 84 | +.. invisible-code-block: python |
| 85 | + new_image = pathlib.Path('high_quality_image.jpg') |
| 86 | + new_image.unlink() |
| 87 | + mock.__exit__() |
| 88 | +
|
| 89 | +Full Documentation |
| 90 | +------------------ |
| 91 | + |
| 92 | +See the `full |
| 93 | +documentation <https://vws-python.readthedocs.io/en/latest>`__. |
| 94 | + |
| 95 | +.. |Build Status| image:: https://github.com/VWS-Python/vws-python/workflows/CI/badge.svg |
| 96 | + :target: https://github.com/VWS-Python/vws-python/actions |
| 97 | +.. |codecov| image:: https://codecov.io/gh/VWS-Python/vws-python/branch/master/graph/badge.svg |
| 98 | + :target: https://codecov.io/gh/VWS-Python/vws-python |
| 99 | +.. |PyPI| image:: https://badge.fury.io/py/VWS-Python.svg |
| 100 | + :target: https://badge.fury.io/py/VWS-Python |
| 101 | +.. |Documentation Status| image:: https://readthedocs.org/projects/vws-python/badge/?version=latest |
| 102 | + :target: https://vws-python.readthedocs.io/en/latest/?badge=latest |
0 commit comments