File tree Expand file tree Collapse file tree 4 files changed +26
-10
lines changed
Expand file tree Collapse file tree 4 files changed +26
-10
lines changed Original file line number Diff line number Diff line change 11requests == 2.22.0
22timeout-decorator == 0.4.1
3+ urllib3 == 1.25.3
Original file line number Diff line number Diff line change 1+ """
2+ Tools for interacting with the Vuforia Cloud Recognition Web APIs.
3+ """
4+
15import io
2- import json
6+ from typing import Any , Dict , List
37from urllib .parse import urljoin
48
59import requests
1317
1418class CloudRecoService :
1519 """
16- TODO
20+ An interface to the Vuforia Cloud Recognition Web APIs.
1721 """
1822
1923 def __init__ (
@@ -37,9 +41,19 @@ def query(
3741 self ,
3842 image : io .BytesIO ,
3943 max_num_results : int = 1 ,
40- ) -> str :
44+ ) -> List [ Dict [ str , Any ]] :
4145 """
42- TODO docstring
46+ Use the Vuforia Web Query API to make an Image Recognition Query.
47+
48+ See
49+ https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query
50+ for parameter details.
51+
52+ Args:
53+ image: The image to make a query against.
54+
55+ Returns:
56+ An ordered list of target details of matching targets.
4357 """
4458 image_content = image .getvalue ()
4559 body = {
@@ -79,4 +93,4 @@ def query(
7993 raise MaxNumResultsOutOfRange (response = response )
8094
8195 raise_for_result_code (response = response , expected_result_code = 'Success' )
82- return response .json ()['results' ]
96+ return list ( response .json ()['results' ])
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ def _mock_database() -> Iterator[VuforiaDatabase]:
2929@pytest .fixture ()
3030def vws_client (_mock_database : VuforiaDatabase ) -> Iterator [VWS ]:
3131 """
32- Yield a VWS client which connects to a mock.
32+ Yield a VWS client which connects to a mock database .
3333 """
3434 yield VWS (
3535 server_access_key = _mock_database .server_access_key ,
@@ -38,9 +38,10 @@ def vws_client(_mock_database: VuforiaDatabase) -> Iterator[VWS]:
3838
3939
4040@pytest .fixture ()
41- def cloud_reco_client (_mock_database : VuforiaDatabase ) -> Iterator [VWS ]:
41+ def cloud_reco_client (_mock_database : VuforiaDatabase ,
42+ ) -> Iterator [CloudRecoService ]:
4243 """
43- TODO Docstring
44+ Yield a ``CloudRecoService`` client which connects to a mock database.
4445 """
4546 yield CloudRecoService (
4647 client_access_key = _mock_database .client_access_key ,
Original file line number Diff line number Diff line change 11"""
2- TODO
2+ Tests for the ``CloudRecoService`` querying functionality.
33"""
44
55import io
1414
1515class TestQuery :
1616 """
17- TODO
17+ Tests for making image queries.
1818 """
1919
2020 def test_no_matches (
You can’t perform that action at this time.
0 commit comments