|
| 1 | +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. |
| 2 | +
|
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +you may not use this file except in compliance with the License. |
| 5 | +You may obtain a copy of the License at |
| 6 | +
|
| 7 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +
|
| 9 | +Unless required by applicable law or agreed to in writing, software |
| 10 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +See the License for the specific language governing permissions and |
| 13 | +limitations under the License. |
| 14 | +==============================================================================*/ |
| 15 | +#ifndef TENSORFLOW_LITE_SUPPORT_C_TASK_PROCESSOR_DETECTION_RESULT_H_ |
| 16 | +#define TENSORFLOW_LITE_SUPPORT_C_TASK_PROCESSOR_DETECTION_RESULT_H_ |
| 17 | + |
| 18 | +#include "tensorflow_lite_support/c/task/processor/bounding_box.h" |
| 19 | +#include "tensorflow_lite_support/c/task/processor/category.h" |
| 20 | + |
| 21 | +// Defines C structure for Object Detection Results and associated helper |
| 22 | +// methods. |
| 23 | + |
| 24 | +#ifdef __cplusplus |
| 25 | +extern "C" { |
| 26 | +#endif // __cplusplus |
| 27 | + |
| 28 | +// Bounding box and list of predicted classes (aka labels) for a detected |
| 29 | +// object. |
| 30 | +typedef struct TfLiteDetection { |
| 31 | + // The bounding box of the detected object. |
| 32 | + TfLiteBoundingBox bounding_box; |
| 33 | + |
| 34 | + // The array of predicted classes for the object detection represented by an |
| 35 | + // instance of TfLiteDetection, usually sorted by descending scores (e.g. from |
| 36 | + // high to low probability). Since this array is dynamically allocated, use |
| 37 | + // size to traverse through the array. |
| 38 | + TfLiteCategory* categories; |
| 39 | + |
| 40 | + // Number of detectd objects be used to traverse the array of the detected |
| 41 | + // objects. |
| 42 | + int size; |
| 43 | +} TfLiteDetection; |
| 44 | + |
| 45 | +// Holds Object Detection results. |
| 46 | +// Contains one set of results per detected object. |
| 47 | +typedef struct TfLiteDetectionResult { |
| 48 | + // Number of detectd objects be used to traverse the array of the detected |
| 49 | + // objects. |
| 50 | + int size; |
| 51 | + |
| 52 | + // Array of results per detected object. This array can |
| 53 | + // have any number of results. size holds the size of this array. size should |
| 54 | + // be used to traverse this array. |
| 55 | + TfLiteDetection* detections; |
| 56 | +} TfLiteDetectionResult; |
| 57 | + |
| 58 | +// Frees up the DetectionResult Structure. |
| 59 | +void TfLiteDetectionResultDelete(TfLiteDetectionResult* detection_result); |
| 60 | + |
| 61 | +#ifdef __cplusplus |
| 62 | +} // extern "C" |
| 63 | +#endif // __cplusplus |
| 64 | + |
| 65 | +#endif // TENSORFLOW_LITE_SUPPORT_C_TASK_VISION_DETECTION_H_ |
0 commit comments