KPI - Planogram Compliance Analysis
Planogram compliance is a metric that measures the extent to which a store's shelf arrangement and product placement align with the predetermined planogram or visual merchandising guidelines set by the retailer or brand.
This endpoint is currently in beta. It is not yet available in our production URL. Please contact us if you want to use this endpoint. Contact us via hi[at]glair.ai or via our representative for your company.
Planogram Analysis Object
- Name
status
- Type
- string
- Description
Enum code indicating the status of the reading result.
SUCCESS
NO_FILE
FILE_INVALID_FORMAT
FAILED
- Name
reason
- Type
- string
- Description
A human-readable message providing more details about the reading result.
- Name
planogram_compliance
- Type
- object
- Description
Planogram compliance is a metric that measures the extent to which a store's shelf arrangement and product placement align with the predetermined planogram or visual merchandising guidelines set by the retailer or brand.
- Name
score
- Type
- number
- Description
Integer representing planogram compliance score.
- Name
comply
- Type
- array of ProductWithIndex
- Description
Array of containing detected SKU that match with the planogram reference.
- Name
not_comply
- Type
- array of Product
- Description
Array of containing SKU in the planogram reference that not match with the detected SKU.
- Name
excluded
- Type
- array of ProductWithIndex
- Description
Array of containing detected SKU that not match with the planogram reference.
- Name
error?
- Type
- boolean
- Description
Determine whether the planogram compliance score is calculated successfully.
- Name
message?
- Type
- string
- Description
The reason why the planogram compliance score isn't calculated successfully.
- Name
realogram
- Type
- array of array of Realogram
- Description
Realogram is a visual representation or snapshot of the actual shelf arrangement and product placement in a store, providing an accurate view of how products are positioned and organized in real-time.
- Name
products
- Type
- array of Product
- Description
Array of object containing planogram reference product in that specific position. Note that the type is array so we can define multiple alternative product in a specific planogram reference position.
- Name
index
- Type
- number
- Description
The numbers represents index in the detected object array.
- Name
match
- Type
- boolean
- Description
Determine whether the detected SKU from AI is matched with the planogram reference.
- Name
detected_object
- Type
- array of DetectedObject
- Description
Array of object containing result provided by object detection AI service.
- Name
index
- Type
- number
- Description
Integer for indexing purpose, specifically referred by the items field that can be found in planogram compliance subsection.
- Name
item
- Type
- object
- Description
Object container for holding all the information related to the detected item.
- Name
class_id
- Type
- string
- Description
The class ID of the detected object.
- Name
label
- Type
- string
- Description
String specifying the given name of the detected object/product.
- Name
coordinates
- Type
- object
- Description
The exact pixel coordinate that represents the rectangular area in the image where the object is detected. - [xmin, ymin]: upper-left corner coordinate of the object. - [xmax, ymax]: lower-right corner coordinate of the object.
- Name
confidence
- Type
- number
- Description
Float, score representing the likelihood that the output given by the AI service/model is correct, the higher the score means better result.
- Name
position
- Type
- object
- Description
Object representing relative position of the object on the planogram (based on shelf-partition / row-column metrics).
- Name
shelf
- Type
- string
- Description
The shelf in which the object is located. If there are no shelves in the image, this will be 0 (Start from index 0).
- Name
partition
- Type
- number
- Description
The partition in which the object is located. If there are no partitions, this will be 0 (Start from index 0).
Product
- Name
class_id
- Type
- string
- Description
The class ID of the detected object.
- Name
label
- Type
- string
- Description
String specifying the given name of the detected object/product.
ProductWithIndex
- Name
class_id
- Type
- string
- Description
The class ID of the detected object.
- Name
label
- Type
- string
- Description
String specifying the given name of the detected object/product.
- Name
count
- Type
- number
- Description
Total products.
- Name
indexes
- Type
- array of number
- Description
The list of numbers represents indexes in the detected object array.
Analyze Planogram Compliance KPI
Calculate planogram compliance score and realogram comparison using the response received from computer vision.
Required parameter
- Name
image
- Type
- file (.png, .jpg, .jpeg)
- Description
The image file.
Request
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Minimum Node 18. Save the code as 'index.mjs' and run it by executing 'node index.mjs'
import { readFileSync } from 'fs';
const url = 'https://api.vision.glair.ai/retail/v1/kpi/planogram';
const basicAuth = 'Basic ' + Buffer.from('USERNAME' + ':' + 'PASSWORD').toString('base64');
const apiKey = API_KEY;
const data = new FormData();
data.append('image', new Blob(
[readFileSync('/path/to/image/image.jpg')],
{ type: 'image/jpg' }
));
data.append('showcaseId', '1');
const config = {
method: 'POST',
headers: {
Authorization: basicAuth,
'x-api-key': apiKey,
},
body: data,
};
const response = await fetch(url, config);
console.log(await response.json());
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
{
"status": "SUCCESS",
"reason": "File successfully read",
"planogram_compliance": {
"score": 55.56,
"comply": [
{
"class_id": 338,
"label": "Mie Sedaap Cup Soto",
"count": 3,
"indexes": [0, 1, 4]
},
{
"class_id": 337,
"label": "Mie Sedaap Cup Rawit Bingit",
"count": 2,
"indexes": [5, 6]
}
],
"not_comply": [
{
"class_id": 336,
"label": "Mie Sedaap Cup Korean"
},
{
"class_id": 337,
"label": "Mie Sedaap Cup Rawit Bingit"
}
],
"excluded": [
{
"class_id": 335,
"label": "Mie Sedaap Cup Kari Spesial",
"count": 2,
"indexes": [2, 3]
},
{
"class_id": 437,
"label": "Pop Mie",
"count": 1,
"indexes": [7]
},
{
"class_id": 170,
"label": "Gaga Mi Instan Cup",
"count": 1,
"indexes": [8]
}
]
},
"realogram": [
[
{
"products": [
{
"class_id": 338,
"label": "Mie Sedaap Cup Soto"
}
],
"comparisons": [{ "index": 0, "match": true }]
},
{
"products": [
{
"class_id": 338,
"label": "Mie Sedaap Cup Soto"
}
],
"comparisons": [{ "index": 1, "match": true }]
},
{
"products": [
{
"class_id": 338,
"label": "Mie Sedaap Cup Soto"
}
],
"comparisons": [{ "index": 4, "match": true }]
}
],
[
{
"products": [
{
"class_id": 336,
"label": "Mie Sedaap Cup Korean"
}
],
"comparisons": [{ "index": 2, "match": false }]
},
{
"products": [
{
"class_id": 336,
"label": "Mie Sedaap Cup Korean"
}
],
"comparisons": [{ "index": 3, "match": false }]
},
{
"products": [
{
"class_id": 336,
"label": "Mie Sedaap Cup Korean"
}
],
"comparisons": [{ "index": 7, "match": false }]
}
],
[
{
"products": [
{
"class_id": 337,
"label": "Mie Sedaap Cup Rawit Bingit"
}
],
"comparisons": [{ "index": 5, "match": true }]
},
{
"products": [
{
"class_id": 337,
"label": "Mie Sedaap Cup Rawit Bingit"
}
],
"comparisons": [{ "index": 6, "match": true }]
},
{
"products": [
{
"class_id": 337,
"label": "Mie Sedaap Cup Rawit Bingit"
}
],
"comparisons": [{ "index": 8, "match": false }]
}
]
],
"detected_object": [
{
"index": 0,
"item": {
"class_id": 338,
"coordinates": {
"xmin": 6,
"ymin": 120,
"xmax": 96,
"ymax": 238
},
"label": "Mie Sedaap Cup Soto",
"confidence": 0.463654100894928,
"color": "#6A0C4F",
"group": [
{
"label": "category",
"value": "Instant Noodle"
},
{
"label": "brand",
"value": "Mie Sedaap"
}
]
},
"position": {
"shelf": 0,
"partition": 0
}
},
{
"index": 1,
"item": {
"class_id": 338,
"coordinates": {
"xmin": 17,
"ymin": 329,
"xmax": 115,
"ymax": 431
},
"label": "Mie Sedaap Cup Soto",
"confidence": 0.4637259542942047,
"color": "#6A0C4F",
"group": [
{
"label": "category",
"value": "Instant Noodle"
},
{
"label": "brand",
"value": "Mie Sedaap"
}
]
},
"position": {
"shelf": 0,
"partition": 0
}
},
{
"index": 2,
"item": {
"class_id": 335,
"coordinates": {
"xmin": 23,
"ymin": 489,
"xmax": 107,
"ymax": 585
},
"label": "Mie Sedaap Cup Kari Spesial",
"confidence": 0.5406119227409363,
"color": "#6A0C4F",
"group": [
{
"label": "category",
"value": "Instant Noodle"
},
{
"label": "brand",
"value": "Mie Sedaap"
}
]
},
"position": {
"shelf": 1,
"partition": 0
}
},
{
"index": 3,
"item": {
"class_id": 335,
"coordinates": {
"xmin": 24,
"ymin": 582,
"xmax": 110,
"ymax": 683
},
"label": "Mie Sedaap Cup Kari Spesial",
"confidence": 0.5788369178771973,
"color": "#6A0C4F",
"group": [
{
"label": "category",
"value": "Instant Noodle"
},
{
"label": "brand",
"value": "Mie Sedaap"
}
]
},
"position": {
"shelf": 1,
"partition": 0
}
},
{
"index": 4,
"item": {
"class_id": 338,
"coordinates": {
"xmin": 24,
"ymin": 226,
"xmax": 112,
"ymax": 331
},
"label": "Mie Sedaap Cup Soto",
"confidence": 0.5329965353012085,
"color": "#6A0C4F",
"group": [
{
"label": "category",
"value": "Instant Noodle"
},
{
"label": "brand",
"value": "Mie Sedaap"
}
]
},
"position": {
"shelf": 0,
"partition": 0
}
},
{
"index": 5,
"item": {
"class_id": 337,
"coordinates": {
"xmin": 42,
"ymin": 735,
"xmax": 125,
"ymax": 828
},
"label": "Mie Sedaap Cup Rawit Bingit",
"confidence": 0.5875117778778076,
"color": "#6A0C4F",
"group": [
{
"label": "category",
"value": "Instant Noodle"
},
{
"label": "brand",
"value": "Mie Sedaap"
}
]
},
"position": {
"shelf": 2,
"partition": 0
}
},
{
"index": 6,
"item": {
"class_id": 337,
"coordinates": {
"xmin": 43,
"ymin": 819,
"xmax": 132,
"ymax": 913
},
"label": "Mie Sedaap Cup Rawit Bingit",
"confidence": 0.5880478024482727,
"color": "#6A0C4F",
"group": [
{
"label": "category",
"value": "Instant Noodle"
},
{
"label": "brand",
"value": "Mie Sedaap"
}
]
},
"position": {
"shelf": 2,
"partition": 0
}
},
{
"index": 7,
"item": {
"class_id": 437,
"coordinates": {
"xmin": 109,
"ymin": 487,
"xmax": 201,
"ymax": 583
},
"label": "Pop Mie",
"confidence": 0.4853852689266205,
"color": "#6A0C4F",
"group": [
{
"label": "category",
"value": "Instant Noodle"
},
{
"label": "brand",
"value": "Pop Mie"
}
]
},
"position": {
"shelf": 1,
"partition": 0
}
},
{
"index": 8,
"item": {
"class_id": 170,
"coordinates": {
"xmin": 127,
"ymin": 735,
"xmax": 215,
"ymax": 831
},
"label": "Gaga Mi Instan Cup",
"confidence": 0.6708394885063171,
"color": "#6A0C4F",
"group": [
{
"label": "category",
"value": "Instant Noodle"
},
{
"label": "brand",
"value": "Gaga"
}
]
},
"position": {
"shelf": 2,
"partition": 0
}
}
]
}
Request ID
An associated request identifier is generated for every request made to this endpoint.
This value can be found in the response headers under Request-Id
Responses
Various responses for this endpoint, in addition to general responses specified in Errors.
200 - OK
Request with readable image
Response
1
2
3
4
5
{
"status": "SUCCESS",
"reason": "File successfully read",
//...,
}
400 - Bad Request
Request without form-data image
Response
1
2
3
4
{
"status": "NO_FILE",
"reason": "No file in request body",
}
415 - Unsupported Media Type
Request with non-image file format
Response
1
2
3
4
{
"status": "FILE_INVALID_FORMAT",
"reason": "Failed to process invalid request",
}