Background supergraphic

KPI Analysis

KPI is a quantifiable metric that measures the performance and success of a specific aspect of a business. In this case, the KPI will be calculated using the response received from computer vision.

KPI Analysis Object

  • Name
    status
    Type
    string
    Description

    Enum code indicating the status of the reading result.

    1. SUCCESS
    2. NO_FILE
    3. FILE_INVALID_FORMAT
    4. FAILED
  • Name
    reason
    Type
    string
    Description

    A human-readable message providing more details about the reading result.

  • Name
    kpi
    Type
    object
    Description

    Object containing KPI result calculated using the response by object detection AI service.

    • Name
      on_shelf_availability
      Type
      object
      Description

      On shelf availability is a metric that measures the availability of products on store shelves, indicating the percentage of items that are properly stocked and accessible to customers.

      • Name
        score
        Type
        number
        Description

        Integer representing on shelf availability score in percentage.

      • Name
        sku_detected
        Type
        array of ProductWithIndex
        Description

        Array of containing detected SKU that match with the must have reference for On Shelf Availability.

      • Name
        sku_missing
        Type
        array of Product
        Description

        Array of containing must have reference that missing from the list of detected SKU.

      • Name
        sku_excluded
        Type
        array of ProductWithIndex
        Description

        Array of containing detected SKU that not match with the must have reference for On Shelf Availability.

    • Name
      share_of_shelf
      Type
      object
      Description

      Share of shelf is a metric that measures the proportion or percentage of shelf space occupied by a particular brand compared to all brands shown in the same shelf.

      • Name
        own_product_score
        Type
        number
        Description

        Integer representing proportion of own product's score in percentage.

      • Name
        competitor_product_score
        Type
        number
        Description

        Integer representing proportion of other or competitor's product score in percentage.

      • Name
        competitor_products_detail
        Type
        array of CompetitorShare
        Description

        Array of proportion of other/competitor's product and score.

        • Name
          brand
          Type
          string
          Description

          Other / competitor's brand name.

        • Name
          score
          Type
          number
          Description

          Integer representing proportion of other or competitor's product score in percentage.

    • Name
      available_products
      Type
      array of AvailableProduct
      Description

      Available products are an array of detected SKUs based on specific criteria, allowing for flexible categorization. SKUs are organized into categories, and within each category, further grouping occurs based on distinct values. This approach accommodates various attributes such as brand, type, or any relevant criteria defined for each SKU.

      • Name
        label
        Type
        string
        Description

        Group criterial label.

      • Name
        groups
        Type
        array of AvailableProductGroup
        Description

        Array of detected group from specific criterial label.

        • Name
          label
          Type
          string
          Description

          Group label.

        • Name
          indexes
          Type
          array of number
          Description

          The list of numbers represents indexes in the detected object array.

    • 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 on shelf availability, available products, and planogram compliance subsection in KPI section.

    • 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
        color
        Type
        string
        Description

        String that specifies the color representing the detected object or product.

      • Name
        group
        Type
        array of Group
        Description

        Array of objects containing group information related to the detected objects or products.

        • Name
          label
          Type
          string
          Description

          Label for the group (e.g., "category," "variant," etc.).

        • Name
          value
          Type
          number
          Description

          The value corresponding to the group label.

    • 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.


POST/retail/v1/kpi

Analyze KPI

Calculate KPI score using the response received from computer vision.

Required parameter

  • Name
    image
    Type
    file (.png, .jpg, .jpeg)
    Description

    The image file.

  • Name
    showcaseId
    Type
    string
    Description

    The showcase id.

Request

POST
/retail/v1/kpi
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'; 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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
{ "status": "SUCCESS", "reason": "File successfully read", "kpi": { "on_shelf_availability": { "score": 66.67, "detected": [ { "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] } ], "missing": [ { "class_id": 336, "label": "Mie Sedaap Cup Korean" } ], "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] } ] }, "share_of_shelf": { "own_product_score": 77.78, "competitor_product_score": 22.22, "competitor_products": [ { "brand": "Pop Mie", "score": 11.11 }, { "brand": "Gaga", "score": 11.11 } ] }, "available_products": [ { "label": "category", "groups": [ { "label": "Instant Noodle", "indexes": [0, 1, 2, 3, 4, 5, 6, 7, 8] } ] }, { "label": "brand", "groups": [ { "label": "Mie Sedaap", "indexes": [0, 1, 2, 3, 4, 5, 6] }, { "label": "Gaga", "indexes": [8] }, { "label": "Pop Mie", "indexes": [7] } ] } ], "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", }