Create new image target | POST /targets
Upload recognition images to create a new image target
Action
POST /targets
Authentication
Required
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 | The base64-encoded string of the image content, supporting JPG and PNG formats. The maximum image size is 2MB. |
| active | String | No | "1" means the target is enabled, "0" means the target is disabled. Default is "1". |
| name | String | Yes | The target name, supporting only English letters, English punctuation, and numbers. The minimum length is 1 character, and the maximum is 64 characters. |
| size | String(Float) | Yes | The width of the recognition image (in cm). The height will be automatically calculated by the system based on the uploaded image. The size of the recognition image corresponds to the size of the virtual content. Default is 20. |
| meta | String | Yes | Generally used to store AR content information, in text string format, default is "". For example: JSON information of the recognized object, base64-encoded image, or the URL download address of a large file in cloud storage. Maximum 2MB. |
| type | String(Float) | Yes | Must be fixed as the string "ImageTarget", note that the case must be exactly the same. |
| allowSimilar | String | No | If similar images exist, whether to forcibly allow addition, default is 0. Similar images may affect recognition results, so the default is recommended. |
Note
- The maximum size for
imageis 2MB. - The maximum size for
metais 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"
}
Return 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. For more details, refer to status code |
| result | Error message or target image information |
| timestamp | Server-side time when the response is returned. Uses Unix timestamp format in milliseconds |
| result.targetId | Unique ID of the target image |
| result.trackingImage | Base64-encoded string of the tracking image |
| result.name | Target name |
| result.size | Width of the recognition image (in cm). The height of the recognition image will be automatically calculated by the system based on the uploaded image. The size of the recognition image corresponds to the size of the overlaid virtual content |
| result.meta | Base64-encoded additional information, such as a string generated by base64-encoding a JSON string |
| result.type | Fixed as ImageTarget |
| result.active | "1" for enabled, "0" for disabled |
Error codes
See Complete list of status codes and error codes
Meta usage instructions
- Associated video URL
- For each recognition target, you can store video URLs associated with that specific target in the meta field
- After your app recognizes the target, use the URL in the meta to connect to the server, download, and play the video, e.g.,
https://my_server/my_videos/my_video_001.mp4
- Associated 3D model
- For each recognition target, you can store a 3D model or Unity asset bundle associated with that specific target in the meta field
- The model must be base64-encoded before storing it in the meta, or you can store the model's URL in the metadata
- When the app recognizes the target, it will render the 3D model on the detected target