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