API Reference

class mock_vws.MockVWS(base_vws_url: str = 'https://vws.vuforia.com', base_vwq_url: str = 'https://cloudreco.vuforia.com', duplicate_match_checker: ImageMatcher = <mock_vws.image_matchers.StructuralSimilarityMatcher object>, query_match_checker: ImageMatcher = <mock_vws.image_matchers.StructuralSimilarityMatcher object>, processing_time_seconds: float = 2, target_tracking_rater: TargetTrackingRater = <mock_vws.target_raters.BrisqueTargetTrackingRater object>, *, real_http: bool = False)

Route requests to Vuforia’s Web Service APIs to fakes of those APIs.

Parameters:
  • real_http – Whether or not to forward requests to the real server if they are not handled by the mock. See https://requests-mock.readthedocs.io/en/latest/mocker.html#real-http-requests.

  • processing_time_seconds – The number of seconds to process each image for. In the real Vuforia Web Services, this is not deterministic.

  • base_vwq_url – The base URL for the VWQ API.

  • base_vws_url – The base URL for the VWS API.

  • query_match_checker – A callable which takes two image values and returns whether they will match in a query request.

  • duplicate_match_checker – A callable which takes two image values and returns whether they are duplicates.

  • target_tracking_rater – A callable for rating targets for tracking.

Raises:

requests.exceptions.MissingSchema – There is no schema in a given URL.

add_database(database: VuforiaDatabase) None

Add a cloud database.

Parameters:

database – The database to add.

Raises:

ValueError – One of the given database keys matches a key for an existing database.

class mock_vws.database.VuforiaDatabase(database_name: str = <factory>, server_access_key: str = <factory>, server_secret_key: str = <factory>, client_access_key: str = <factory>, client_secret_key: str = <factory>, targets: set[~mock_vws.target.Target] = <factory>, state: ~mock_vws.states.States = States.WORKING, request_quota: int = 100000, reco_threshold: int = 1000, current_month_recos: int = 0, previous_month_recos: int = 0, total_recos: int = 0, target_quota: int = 1000)

Credentials for VWS APIs.

Parameters:
  • database_name – The name of a VWS target manager database name. Defaults to a random string.

  • server_access_key – A VWS server access key. Defaults to a random string.

  • server_secret_key – A VWS server secret key. Defaults to a random string.

  • client_access_key – A VWS client access key. Defaults to a random string.

  • client_secret_key – A VWS client secret key. Defaults to a random string.

  • state – The state of the database.

database_name: str
server_access_key: str
server_secret_key: str
client_access_key: str
client_secret_key: str
targets: set[Target]
state: States = 'working'
request_quota: int = 100000
reco_threshold: int = 1000
current_month_recos: int = 0
previous_month_recos: int = 0
total_recos: int = 0
target_quota: int = 1000
enum mock_vws.states.States(value)

Constants representing various web service states.

Member Type:

str

Valid values are as follows:

WORKING = <States.WORKING: 'working'>
PROJECT_INACTIVE = <States.PROJECT_INACTIVE: 'project_inactive'>
class mock_vws.target.Target(active_flag: bool, application_metadata: str | None, image_value: bytes, name: str, processing_time_seconds: float, width: float, target_tracking_rater: TargetTrackingRater, current_month_recos: int = 0, delete_date: datetime.datetime | None = None, last_modified_date: datetime.datetime = <factory>, previous_month_recos: int = 0, reco_rating: str = '', target_id: str = <factory>, total_recos: int = 0, upload_date: datetime.datetime = <factory>)

A Vuforia Target as managed in https://developer.vuforia.com/target-manager.

Image matchers

protocol mock_vws.image_matchers.ImageMatcher

Protocol for a matcher for query and duplicate requests.

This protocol is runtime checkable.

Classes that implement this protocol must have the following methods / attributes:

__call__(first_image_content: bytes, second_image_content: bytes) bool

Whether one image’s content matches another’s closely enough.

Parameters:
  • first_image_content – One image’s content.

  • second_image_content – Another image’s content.

class mock_vws.image_matchers.ExactMatcher

A matcher which returns whether two images are exactly equal.

class mock_vws.image_matchers.StructuralSimilarityMatcher

A matcher which returns whether two images are similar using SSIM.

Target raters

protocol mock_vws.target_raters.TargetTrackingRater

Protocol for a rater of target quality.

This protocol is runtime checkable.

Classes that implement this protocol must have the following methods / attributes:

__call__(image_content: bytes) int

The target tracking rating.

Parameters:

image_content – A target’s image’s content.

class mock_vws.target_raters.RandomTargetTrackingRater

A rater which returns a random number.

class mock_vws.target_raters.HardcodedTargetTrackingRater(rating: int)
Parameters:

rating – The rating to return.

class mock_vws.target_raters.BrisqueTargetTrackingRater

A rater which returns a rating based on a BRISQUE score.