Create new image target | POST /targets
Upload a recognition image to create a new image target
Action
POST /targets
Authentication
Http header
Content-Type=application/json
HTTP Header: Authorization (when using API Key Token authentication)
Request parameters
| Field | Type | Required | Description |
|---|---|---|---|
| image | String(base64) | Yes | Base64-encoded string of image content, supports JPG and PNG formats. Maximum image size 2MB. |
| active | String | No | "1" means target enabled, "0" means target disabled. Default is "1". |
| name | String | Yes | Target name, only supports English letters, English punctuation, and numbers. Minimum 1 character, maximum 64 characters. |
| size | String (Float) | Yes | Recognition image width (unit: cm). Height is automatically calculated based on uploaded image. Corresponds to virtual content size. Default 20. |
| meta | String | Yes | Typically used to store AR content information, text string format, default "". Example: JSON info of recognized object, base64-encoded image, or cloud storage URL for large files. Maximum 2MB. |
| type | String (Float) | Yes | Must be set to string "ImageTarget", case-sensitive. |
| allowSimilar | String | No | Whether to force allow adding if similar images exist, default 0. Similar images may affect recognition accuracy, default recommended. |
Note
- image limit: maximum 2MB
- meta limit: maximum 2MB
Request example
POST /targets/ HTTP/1.1
Host:
Date: Mon, 1 Jan 2018 00:00:00 GMT
Content-Type: application/json
{
"image":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgM...",
"active":"1",
"name":"easyar",
"size":"5",
"meta":"496fbbabc2b38ecs3460a...",
"type":"ImageTarget",
"timestamp": 1514736000000,
"appKey": "test_app_key",
"signature": "89985e2420899196db5bdf16b3c2ed0922c0c221"
}
Response example
HTTP/1.1 200 OK
Content-Type: application/json
{
"statusCode": 0,
"result": {
"target": {
"targetId":"e61db301-e80f-4025-b822-9a00eb48d8d2",
"trackingImage":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgM...",
"name": "easyar",
"size": "5",
"meta": "496fbbabc2b38ecs3460a...",
"type": "ImageTarget",
"modified":1514735000000
"active":"1",
"trackableRate": 0,
"detectableRate": 0,
"detectableDistinctiveness":0,
"detectableFeatureCount", 0,
"trackableDistinctiveness", 0,
"trackableFeatureCount", 0,
"trackableFeatureDistribution", 0,
"trackablePatchContrast": 0,
"trackablePatchAmbiguity": 0
}
},
"timestamp": 1514736000000
}
Return fields
| Field | Description |
|---|---|
| statusCode | Status code 0 indicates correct authentication, see more in Status codes |
| result | Error message or target image information |
| timestamp | Server-side time when response is returned. Unix timestamp in milliseconds |
| result.targetId | Unique ID of target image |
| result.trackingImage | Base64-encoded string of tracking image |
| result.name | Target name |
| result.size | Recognition image width (unit: cm). Height automatically calculated based on image. Corresponds to virtual content size |
| result.meta | Base64-encoded additional info, e.g. base64-encoded JSON string |
| result.type | Fixed as ImageTarget |
| result.active | "1" enabled, "0" disabled |
Error codes
See Status codes and error codes
Meta usage instructions
- Associating video URL
- For each recognition target, store the video URL associated with that specific target in the meta field
- After your app recognizes the target, use the URL in meta to connect to server, download and play video, e.g.
https://my_server/my_videos/my_video_001.mp4
- Associating 3D models
- For each recognition target, store the 3D model or Unity asset bundle associated with that specific target in the meta field
- Need to base64-encode the model before storing in meta, or store model URL in metadata
- When app recognizes target, it renders the 3D model on detected target