Cloud Image Recognition API Overview¶
Use a cloud database to detect and track amongst millions of Cloud Image Targets. This article presents the general steps to implement Cloud Image Recognition in native.
A Cloud Image Target is an Image Target stored in the Vuforia Servers. This allows you to store, detect, and track between millions of Image Targets from a single Cloud Database. Upload your Cloud Image Targets using the Target Manager. See also Cloud Targets Web API.
General Setup¶
Please see the Vuforia Engine Lifecycle for a general introduction to the Vuforia Engine lifecycle. The Engine is required for creating and using Observers.
Create a Cloud Image Target Observer¶
Cloud Image Recognition is handled by the Engine via the Cloud Image Target Observer. Configure the Cloud Image Recognition with VuCloudImageTargetConfig
and detect recognition events with VuCloudImageTargetObservationTargetInfo
.
Differently from other tracking API in the SDK, where you get continuous tracking updates via pull mechanisms from the State, Cloud Image Recognition does not necessarily get continuous information; you need to register a handler for getting updates. Do this with the vuCloudImageTargetObserverRegisterHandlers
. Once the Observer is created and activated, search results will be reported via the registered callback function VuCloudImageTargetObservationsHandler
.
Create Observer from VuCloudImageTargetConfig¶
To use Cloud Recognition, you first need to initialize the system and set the credentials for your cloud database. The creation process requires an active network connection and runs asynchronously.
The following creates the Cloud Image Target Observer. It is activated by default.
NOTE: Find your authentication keys in the Cloud Database's details in the Target Manager.
Starting and stopping a Cloud Image Recognition search¶
Register handlers for Cloud Image Targets with VuCloudImageTargetObservationsHandler
. This observation handler is triggered whenever a new Cloud Image Target is detected. You can then choose to create an Image Target Observer with vuEngineCreateImageTargetObserverFromCloudObservation()
to start tracking the image.
Handling Search Results¶
At runtime, you need to handle new Cloud Image Recognition search results and, if desired, create the Image Target Observer for tracking.
Below is a sample code snippet that inspects information about the detected targets via vuCloudImageTargetObservationGetTargetInfo
. Target info includes name, unique id, metadata, and tracking rating.
From the observations, the sample then creates an Image Target Observer with vuEngineCreateImageTargetObserverFromCloudObservation
.
For more information on counting and handling the Cloud Image Recognition search results, please see Counting Cloud Image Recognition Events.
Error Messages¶
Errors that are detected asynchronously after the Observer is created are reported via the error handler callback. Here is an example of how to write such a handler:
The following error codes may be returned by the VuCloudImageTargetQueryError
. This table lists the codes alongside their meanings.
Code | Meaning |
---|---|
VU_CLOUD_IMAGE_TARGET_QUERY_ERROR_NO_NETWORK_CONNECTION | No network connection |
VU_CLOUD_IMAGE_TARGET_QUERY_ERROR_SERVICE_NOT_AVAILABLE | Server not found, down, or overloaded |
VU_CLOUD_IMAGE_TARGET_QUERY_ERROR_AUTHORIZATION_FAILED | Credentials are wrong or outdated |
VU_CLOUD_IMAGE_TARGET_QUERY_ERROR_PROJECT_SUSPENDED | The specified project was suspended |
VU_CLOUD_IMAGE_TARGET_QUERY_ERROR_BAD_FRAME_QUALITY | Low frame quality has been continuously observed |
VU_CLOUD_IMAGE_TARGET_QUERY_ERROR_UPDATE_SDK | SDK version outdated |
VU_CLOUD_IMAGE_TARGET_QUERY_ERROR_TIMESTAMP_OUT_OF_RANGE | Client/Server clocks too far apart |
VU_CLOUD_IMAGE_TARGET_QUERY_ERROR_REQUEST_TIMEOUT | No response to network request after timeout |