feng-gui homepage
Feng-GUI Services: API Documentation

SetImageAOIs method
Set the AOIs data of an image.
The request AOIs data is in JSON format.
Credit: no credit is charged when using this method.

Arguments
ImageID (String)
   The unique id of an image.
   for example, the image id of the following URL is 9aa34142-669d-4261-a08f-f80b4c0b58ba
   http://service.feng-gui.com/users/USERNAME/files/heatmaps/9aa34142-669d-4261-a08f-f80b4c0b58ba.png
AOIs (String)
   JSON string of the AOIs regions.

Scale AOI values
AOI values need to be scaled to 384x256

Here is how to calculate the AOI values for a 1024x768 image:
aoiWidth = 384
aoiHeight = 256
imgWidth = 1024
imgHeight = 768

aoiRatio = aoiWidth / aoiHeight
imageRatio = imgWidth / imgHeight

if (aoiRatio < imageRatio) {
  aoiHeight = aoiWidth / imageRatio
}
else {
  aoiWidth = aoiHeight * imageRatio
}

aoi.top = realAoi.top / (imgHeight / aoiHeight)
aoi.left = realAoi.left / (imgWidth / aoiWidth)
aoi.width = realAoi.width / (imgWidth / aoiWidth)
aoi.height = realAoi.height / (imgHeight / aoiHeight)
calculation example for an AOI of top:100,left:100,width:50,height:50
aoiRatio = 384 / 256 = 1.5
imageRatio = 1024 / 768 = 1.3333
aoiHeight = 256
aoiWidth = 256 * 1.3333 = 341.333
aoi.top = 100 / (768 / 256) = 33.33
aoi.left = 100 / (1024 / 341.333) = 33.33
aoi.width = 50 / (1024 / 341.333) = 16.66
aoi.height = 50 / (768/ 256) = 16.66

[{"top":33,"left":33,"width":17,"height":17,"text":"face","id":"1","editable":true}]

Example
To generate an AOIs report:
1. Call ImageAttention
2. from ImageAttention response, extract the newly created ImageID from the OutputImage URL
Here is an example of OutputImage URL
http://service.feng-gui.com/users/USERNAME/files/heatmaps/9aa34142-669d-4261-a08f-f80b4c0b58ba.png
The ImageID is 9aa34142-669d-4261-a08f-f80b4c0b58ba

3. Use this ImageID and a JSON AOIs string to call SetImageAOIs(ImageID, AOIs)
Here is an example of an AOIs string

[{"top":36,"left":75,"width":40,"height":40,"text":"face","id":"1","editable":true},
{"top":3,"left":220,"width":40,"height":50,"text":"product","id":"2","editable":true},
{"top":82,"left":14,"width":40,"height":40,"text":"face2","id":"3","editable":true},
{"top":0,"left":3,"width":32,"height":20,"text":"company name","id":"4","editable":true},
{"top":212,"left":317,"width":55,"height":23,"text":"brand name","id":"5","editable":true},
{"top":192,"left":221,"width":136,"height":25,"text":"tag line","id":"6","editable":true}]

4. Download the AOIs report image with an additional timestamp parameter at the end of the URL. For example:
http://service.feng-gui.com/users/USERNAME/files/heatmaps/9aa34142-669d-4261-a08f-f80b4c0b58ba_aoi.png + "?" + (new Date()).getTime();
The AOIs report files are http cached and if you will not add a random parameter (like timestamp) to the URL, you will receive an HTTP status “304 Not Modified”

Response
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SetImageAOIsResponse xmlns="http://www.feng-gui.com/" />
  </soap:Body>
</soap:Envelope>