New Target | POST /targets/

Create a new image target.

Action

POST /targets/

Content-Type=application/json

Authentication

Yes

Request parameters

Field

Type

Required

Description

image

String(base64 encoded)

Yes

base64(image),jpg and png are supported. Maximum size is 2MB.

active

String

No

“1” is active,”0” is inactive。 Default is “1”

name

String

Yes

Target Name. ASCII character, numbers and punctuation can be supported, and characters length is limited between 1 and 64

size

String(Float)

Yes

Width of target image ( cm )。The hight( or length) of the image will be computed by system. Help mapping the virtual object to target image. Default is 20

meta

String

Yes

Custemized info storage, must be text. Default is “”
E.x. JSON text, or base64 encoding of image, or url of file stored in cloud.

type

String (Float)

Yes

Constant Value: “ImageTarget”. More types will be supported in future.

allowSimilar

String

No

Force to add image if similar targets exist

Note: You can also pass in any other fields you like, such as meta data to attach to the target. They would be returned unmodified in responses.

Example for request

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"
}

Example for response

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
}

Response Field

statusCode:0 is OK,1 is invalid appKey,2 is invalid signature,3 is invalid date

result:core result body

timestamp:Milliseconds since Epoch of response at server.

targetId:Unique identity of the target

trackingImage:tracking image stored in server for AR tracking

name: Target Name

size:Width of target image ( cm )

meta:users’ custemized info uploaded: e.x. json text, base64 encoded, or url-encoded, etcd

type:”ImageTarget”

active:”1” is active, “0” is inactive

Common use meta examples

  • Video URLs

    • For each target, you store metadata containing the URL of a video associated to the specific target

    • After your app recognizes the target, uses the URL in the metadata to connect to a server, to download, and to play the video (for example, http://my_server/my_videos/my_video_001.mp4)

  • 3D models

    • For each target, you can store metadata containing 3D model or unity asset bundle to associate with the specific target

    • You can encode your model with base64 and store directly in metadata, or store URL of model in meta as video example showed.

    • After your app recognize the target, renders the 3D model on the detected target

Note:

image: maximum size is 2MB.

meta: maximum size is 2MB.

Source Code of Samples

EasyAR also provides Target Management Samples for developers by following languages: