Spacely AI Enterprise
  • Introduction
    • Overview
    • Getting Started
    • Authentication
    • Rate Limiting
    • Credit consumption
  • Instant Rendering API
    • Create renders from Spacely AI preset styles
    • Create renders from custom input
    • Create renders from image style transferring
  • Product Visualization API
    • Furniture placement
    • Decoration placement
    • Color transfer
  • Precision Space Planning API
    • 1-Point perspective
    • 2-Point perspective
  • OTHER ENDPOINTS
    • Get Resources
    • Polling Data
Powered by GitBook
On this page
  • Description
  • Use cases
  • Credit
  • API
  • Example
  • Tips and tricks
  • Support
  1. Product Visualization API

Decoration placement

PreviousFurniture placementNextColor transfer

Last updated 1 year ago

Description

Add your decoration into the existing room. Spacely AI furniture placement AI will place the furniture into the room, making it smooth, seamless, and realistic. This API is better for a high detail decoration.

Use cases

  1. Visual style experimentation for client proposals.

  2. Rapid concept generation for design projects.

Credit

1 successful decoration placement API call = 1 credit.

API

POST https://api.spacely.ai/api/v1/generate/decoration-placement

This endpoint is used to standard generate

Headers

Name
Type
Description

X-API-KEY*

String

Request Body

Name
Type
Description

imageUrl*

String

This field contains the URL of the background image where decoration will be placed.

productImageUrl*

String

This field contains the URL of the PNG decoration product image that will be placed within the background image.

The product should be in PNG format with no background.

productWidth*

Float

The actual width of the product image. Must be in the same unit as productHeight and lineLength

If the product image has lots of padding, the productWidth might need to be bigger than the actual product width.

productHeight*

Float

The actual height of the product image. Must be in the same unit as productWidth and lineLength

If the product image has lots of padding, the productHeight might need to be bigger than the actual product height.

referenceLine*

Object[]

The reference line in the background image that the actual length is known.

The Object has 2 attributes: x, y.

e.g.

[{ "x": 0, "y": 0},{"x":100.2,"y":100.2}]

lineLength*

Float

The actual length of the referenceLine.

Must be in the same unit as productWidth and productHeight.

placement*

Object

This object describes the position and size of the decoration within the background image. It includes four attributes:

x: The x-coordinate (horizontal position) of the top-left corner of the decoration placement.

y: The y-coordinate (vertical position) of the top-left corner of the decoration placement.

w: The width of the decoration placement.

h: The height of the decoration placement.

Please note that the x,y coordinate starts at the top-left corner of the image and can only be positive.

isRemove

Boolean

Whether or not to remove something from the background image before placing the decoration.

removeArea

Object

This object defines the area within the background image where there is existing decoration and should be removed.

It includes four attributes similar to placement.

{
  "data": REF_ID
}

Example

curl --location 'https://api.spacely.ai/api/v1/generate/decoration-placement' \
--header 'X-API-KEY: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "imageUrl": IMAGE_URL,
    "productImageUrl": IMAGE_URL,
    "productWidth": 100.1,
    "productHeight": 120.1,
    "referenceLine": [
        {
            "x": 361.1,
            "y": 424.1
        },
        {
            "x": 361.1,
            "y": 289.1
        }
    ],
    "lineLength": 100.1,
    "placement": {
        "x": 85.1,
        "y": 0.1,
        "w": 90.1,
        "h": 250.1
    },
    "isRemove": true,
    "removeArea": {
        "x": 85.1,
        "y": 0.1,
        "w": 90.1,
        "h": 250.1
    }
}'

const myHeaders = new Headers();
myHeaders.append("X-API-KEY", YOUR_API_KEY);
myHeaders.append("Content-Type", "application/json");

const raw = JSON.stringify({
  "imageUrl": IMAGE_URL,
  "productImageUrl": IMAGE_URL,
  "productWidth": 100.1,
  "productHeight": 120.1,
  "referenceLine": [
    {
      "x": 361.1,
      "y": 424.1
    },
    {
      "x": 361.1,
      "y": 289.1
    }
  ],
  "lineLength": 100.1,
  "placement": {
    "x": 85.1,
    "y": 0.1,
    "w": 90.1,
    "h": 250.1
  },
  "isRemove": true,
  "removeArea": {
    "x": 85.1,
    "y": 0.1,
    "w": 90.1,
    "h": 250.1
  }
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://api.spacely.ai/api/v1/generate/decoration-placement", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
const axios = require('axios');
let data = JSON.stringify({
  "imageUrl": IMAGE_URL,
  "productImageUrl": IMAGE_URL,
  "productWidth": 100.1,
  "productHeight": 120.1,
  "referenceLine": [
    {
      "x": 361.1,
      "y": 424.1
    },
    {
      "x": 361.1,
      "y": 289.1
    }
  ],
  "lineLength": 100.1,
  "placement": {
    "x": 85.1,
    "y": 0.1,
    "w": 90.1,
    "h": 250.1
  },
  "isRemove": true,
  "removeArea": {
    "x": 85.1,
    "y": 0.1,
    "w": 90.1,
    "h": 250.1
  }
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.spacely.ai/api/v1/generate/decoration-placement',
  headers: { 
    'X-API-KEY': 'YOUR_API_KEY', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.spacely.ai/api/v1/generate/decoration-placement"
  method := "POST"

  payload := strings.NewReader(`{
    "imageUrl": IMAGE_URL,
    "productImageUrl": IMAGE_URL,
    "productWidth": 100.1,
    "productHeight": 120.1,
    "referenceLine": [
        {
            "x": 361.1,
            "y": 424.1
        },
        {
            "x": 361.1,
            "y": 289.1
        }
    ],
    "lineLength": 100.1,
    "placement": {
        "x": 85.1,
        "y": 0.1,
        "w": 90.1,
        "h": 250.1
    },
    "isRemove": true,
    "removeArea": {
        "x": 85.1,
        "y": 0.1,
        "w": 90.1,
        "h": 250.1
    }
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("X-API-KEY", "YOUR_API_KEY")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
import requests
import json

url = "https://api.spacely.ai/api/v1/generate/decoration-placement"

payload = json.dumps({
  "imageUrl": IMAGE_URL,
  "productImageUrl": IMAGE_URL,
  "productWidth": 100.1,
  "productHeight": 120.1,
  "referenceLine": [
    {
      "x": 361.1,
      "y": 424.1
    },
    {
      "x": 361.1,
      "y": 289.1
    }
  ],
  "lineLength": 100.1,
  "placement": {
    "x": 85.1,
    "y": 0.1,
    "w": 90.1,
    "h": 250.1
  },
  "isRemove": True,
  "removeArea": {
    "x": 85.1,
    "y": 0.1,
    "w": 90.1,
    "h": 250.1
  }
})
headers = {
  'X-API-KEY': 'YOUR_API_KEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Tips and tricks

After receiving the response, use this api to retrieve the data.

Support

Any question? Contact us at support@spacely.ai

(e.g., ")

(e.g., ")

Get Resources
https://storage.googleapis.com/spacely-dev/product-placement-images/2e53a5ce9664dee4a2177bee61716893.jpg
https://storage.googleapis.com/spacely-dev/product-placement-images/1.png
Before
After - Decoration placed