Your first Target Collections
Target Collections are central to working with Cloud Recognition service. They keep all your target images and are the base for the cloud archive.
Think of TargetCollection as a directory, where your images are stored. A TargetCollection forms a logical group, which is searched as a whole. Of course you can have several TargetCollections in your account, each consisting up to 50,000 images each.
What is the difference between Cloud Archive and Target Collection
Structure of a TargetCollection
Property | Type | Description |
---|---|---|
id | (String) | An ID that uniquely identifies the TargetCollection |
name | (String) | The Name of the TargetCollection, as defined by the user |
creDat | (Number) | A timestamp when the TargetCollection was created (as returned by JavaScript's Date.now() function) |
modDat | (Number) | A timestamp when the TargetCollection was last modified (as returned by JavaScript's Date.now() function) |
Create a Target Collection
Creating a Target Collection is easy and can be done without any prerequisites in your account. In general it is your starting point and most likely your very first action.
Call the endpoint
https://api.wikitude.com/cloudrecognition/targetCollection
with the mandatory name
field as a POST
request and you will create a new TargetCollection. The response will contain a TargetCollection object, where the ID is most important parameter. You can also add metadata
to a TargetCollection in case you want to some additional descriptive information. The next step is to add images to your TargetCollection, so they can be recognized.
Add Target Images
A Target is an plain image that can be recognized by the Wikitude Cloud Recognition service. Adding or creating a target means to provide a URL to your image to the server, which then downloads the image, analyzes it and adds it to the TargetCollection. To add an image call the endpoint
https://api.wikitude.com/cloudrecognition/targetCollection/:tcId/target
with the ID
of the TargetCollection, where you want to add the image. You need to add the a field imageUrl
to your request. The image must be publicly accessible.
Pay attention to the optional fields name
and metadata
. name
is a unique identifier for your target within the TargetCollection. It is up to you to set and use this. The same is true for the metadata
object, which takes a full JSON object and can be filled with any value you like. The metadata
object will be present in the recognition response.
Structure of a Target
Property | Type | Description |
---|---|---|
id | (String) | An ID that uniquely identifies the Target |
name | (String) | The Name of the Target, as defined by the user |
imageUrl | (String) | The URL pointing to the original, uncompressed and uncropped Target binary file |
thumbnailUrl | (String) | The URL pointing to a thumbnail representation of the Target |
rating | (Number) | The rating (from 0 to 3) of the Target |
fileSize | (Number) | The file size of the original Target binary image file, in KB |
creDat | (Number) | A timestamp when the Target was created (as returned by JavaScript's Date.now() function) |
modDat | (Number) | A timestamp when the Target was last modified (as returned by JavaScript's Date.now() function) |
metadata | (JSON) | Arbitrary JSON data that is stored together with the target. |
Generate a Cloud Archive
Once you are done with adding targets you need to tell the server that it should generate your TargetCollection into a Cloud Archive. Call
https://api.wikitude.com/cloudrecognition/targetCollection/:tcId/generation
again with the ID
of your TargetCollection and the process will be kicked-off. Note that the generation process can take a while when generating a large TargetCollection for the first time. Small additions to existing cloud archives are processed a lot faster. While a cloud archive is generated it is locked and you can't execute any other actions on it. A 204
HTTP response will tell you that the generation process was successful and is done. In case of a time-out you can call the endpoint again and it will tell you the status of the generation process - see the three different error codes for a 412
HTTP response.
- your newly added image will not be recognized
- your deleted image will still be recognized
Your Cloud Archive is now ready on the server and can be used in combination with the Wikitude SDK from your app. See the SDK sample called Cloud Recognition for more details.
Additional calls
Beside the above described steps the Manager API also offers to Delete TargetCollections and Delete Targets.
Using GET
request you can query details about a single TargetCollection, all Target Collections in your account, a single Target and all Targets within a TargetCollection.