Skip to content

Commit 6fb3318

Browse files
committed
Progress towards usage documentation
1 parent 9d7969f commit 6fb3318

File tree

3 files changed

+93
-16
lines changed

3 files changed

+93
-16
lines changed

README.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ Getting Started
2424
2525
from vws import VWS, CloudRecoService
2626
27-
vws_client = VWS(server_access_key='...', server_secret_key='...')
28-
cloud_reco_client = CloudRecoService(client_access_key='...', client_secret_key='...')
27+
server_access_key = '[server-access-key]'
28+
server_secret_key = '[server-secret-key]'
29+
client_access_key = '[client-access-key]'
30+
client_secret_key = '[client-secret-key]'
31+
32+
vws_client = VWS(
33+
server_access_key=server_access_key,
34+
server_secret_key=server_secret_key,
35+
)
36+
cloud_reco_client = CloudRecoService(
37+
client_access_key=client_access_key,
38+
client_secret_key=client_secret_key,
39+
)
2940
name = 'my_image_name'
3041
3142
with open('/path/to/image.png', 'rb') as my_image_file:

docs/source/api-reference.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
API Reference
2+
=============
3+
4+
.. automodule:: vws
5+
:undoc-members:
6+
:members:
7+
8+
.. automodule:: vws.include_target_data
9+
:undoc-members:
10+
:members:

docs/source/index.rst

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,94 @@ Installation
66

77
.. code:: sh
88
9-
pip install vws-python
9+
pip3 install vws-python
1010
1111
This is tested on Python 3.7+.
1212
Get in touch with ``[email protected]`` if you would like to use this with another language.
1313

14-
Example usage
15-
-------------
14+
Usage
15+
-----
1616

1717
See the :doc:`api-reference` for full usage details.
1818

1919
.. code:: python
2020
21+
import io
22+
23+
from vws import VWS, CloudRecoService
24+
25+
server_access_key = '[server-access-key]'
26+
server_secret_key = '[server-secret-key]'
27+
client_access_key = '[client-access-key]'
28+
client_secret_key = '[client-secret-key]'
29+
30+
vws_client = VWS(
31+
server_access_key=server_access_key,
32+
server_secret_key=server_secret_key,
33+
)
34+
cloud_reco_client = CloudRecoService(
35+
client_access_key=client_access_key,
36+
client_secret_key=client_secret_key,
37+
)
38+
name = 'my_image_name'
39+
40+
with open('/path/to/image.png', 'rb') as my_image_file:
41+
my_image = io.BytesIO(my_image_file.read())
42+
43+
target_id = vws_client.add_target(
44+
name=name,
45+
width=1,
46+
image=my_image,
47+
)
48+
vws_client.wait_for_target_processed(target_id=target_id)
49+
matching_targets = cloud_reco_client.query(image=my_image)
50+
51+
assert matching_targets[0]['target_id'] == target_id
52+
2153
Testing
2254
-------
2355

24-
To write unit tests for code which uses this library, without using your Vuforia quota, you can use the https://github.com/adamtheturtle/vws-python-mock tool:
56+
To write unit tests for code which uses this library, without using your Vuforia quota, you can use the `VWS Python Mock`_ tool:
2557

26-
XXX example
58+
.. code:: sh
2759
28-
There are some differences... see XXX for details
60+
pip3 install vws-python-mock
2961
62+
.. code:: python
3063
31-
Reference
32-
---------
64+
from mock_vws import MockVWS, VuforiaDatabase
65+
66+
with MockVWS() as mock:
67+
database = VuforiaDatabase()
68+
mock.add_database(database=database)
69+
vws_client = VWS(
70+
server_access_key=server_access_key,
71+
server_secret_key=server_secret_key,
72+
)
73+
cloud_reco_client = CloudRecoService(
74+
client_access_key=client_access_key,
75+
client_secret_key=client_secret_key,
76+
)
77+
78+
name = 'my_image_name'
79+
80+
with open('/path/to/image.png', 'rb') as my_image_file:
81+
my_image = io.BytesIO(my_image_file.read())
82+
83+
target_id = vws_client.add_target(
84+
name=name,
85+
width=1,
86+
image=my_image,
87+
)
3388
34-
.. automodule:: vws
35-
:undoc-members:
36-
:members:
89+
There are some differences between the mock and the real Vuforia.
90+
See https://vws-python-mock.readthedocs.io/en/latest/differences-to-vws.html for details.
3791

38-
.. automodule:: vws.include_target_data
39-
:undoc-members:
40-
:members:
92+
.. _VWS Python Mock: https://github.com/adamtheturtle/vws-python-mock
93+
94+
95+
Reference
96+
---------
4197

4298
.. toctree::
4399
:maxdepth: 3

0 commit comments

Comments
 (0)