vx_khr_class.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (c) 2012-2017 The Khronos Group Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _VX_KHR_CLASSIFIER_H_
  17. #define _VX_KHR_CLASSIFIER_H_
  18. /*!
  19. * \file
  20. * \brief The Khronos Extension for general classification.
  21. *
  22. */
  23. #define OPENVX_KHR_CLASS "vx_khr_class"
  24. #include <VX/vx.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /*! \brief The Classifier Extension Library Set
  29. * \ingroup group_classifier
  30. */
  31. #define VX_LIBRARY_KHR_CLASS_EXTENSION (0x2)
  32. /*! \brief The list of Classifier Extension Kernels.
  33. * \ingroup group_classifier
  34. */
  35. enum vx_kernel_nn_ext_e {
  36. /*! \brief The Classifier Extension scan kernel.
  37. * \see group_classifier
  38. */
  39. VX_KERNEL_SCAN_CLASSIFIER = VX_KERNEL_BASE(VX_ID_KHRONOS, VX_LIBRARY_KHR_CLASS_EXTENSION) + 0x0,
  40. };
  41. /*! \brief Classifier Extension type enums.
  42. * \ingroup group_classifier
  43. */
  44. enum vx_class_enum_e
  45. {
  46. VX_ENUM_CLASSIFIER_MODEL= 0x1E, /*!< \brief Classifier model */
  47. };
  48. /*!
  49. * \brief classification model to be used in <tt>\ref vxScanClassifierNode</tt>.
  50. * The classification models are loadable by undefined binary format see <tt>\ref vxImportClassifierModel</tt>.
  51. * Extensions will be added to the specification, to support a defined binary format.
  52. * \ingroup group_object_classifier_model
  53. */
  54. typedef struct _vx_classifier_model* vx_classifier_model;
  55. /*! \brief Classifier model format enums.
  56. * In the main specification only undefined binary format is supported. Extensions to the specification will be added in order to support specific binary format.
  57. * \ingroup group_object_classifier_model
  58. */
  59. enum vx_classifier_model_format_e
  60. {
  61. /*! \brief Undefined binary format.
  62. * Using this enumeration will result in an implementation defined behaviour.
  63. */
  64. VX_CLASSIFIER_MODEL_UNDEFINED = VX_ENUM_BASE( VX_ID_KHRONOS, VX_ENUM_CLASSIFIER_MODEL ) + 0x0,
  65. };
  66. /*! \brief The type enumeration lists all classifier extension types.
  67. * \ingroup group_object_classifier_model
  68. */
  69. enum vx_classifier_type_e {
  70. VX_TYPE_CLASSIFER_MODEL = 0x02C,/*!< \brief A <tt>\ref vx_classifier_model</tt>. type */
  71. };
  72. /*==============================================================================
  73. CLASSIFIER MODEL
  74. =============================================================================*/
  75. /*!
  76. * \brief Creates an opaque reference classifier model
  77. * This function creates a classifier model to be used in <tt>\ref vxScanClassifierNode</tt>. The object classifier object is a read-only constant object. It cannot be changed during graph execution.
  78. * \param [in] context Reference to the context where to create the ClassifierModel.
  79. * \param [in] format The binary format which contain the classifier model. See <tt>\ref vx_classifier_model_format_e</tt>. Currently only undefined binary format is supported.
  80. * Extensions will be added to the specification, to support a classification model defined binary format.
  81. * \param [in] ptr A memory pointer to the binary format.
  82. * \param [in] length size in bytes of binary format data.
  83. * \returns A ClassifierModel reference <tt>\ref vx_classifier_model</tt>. Any possible errors preventing a
  84. * successful creation should be checked using <tt>\ref vxGetStatus</tt>.
  85. * \ingroup group_object_classifier_model
  86. */
  87. VX_API_ENTRY vx_classifier_model vxImportClassifierModel(vx_context context, vx_enum format, const vx_uint8* ptr, vx_size length);
  88. /*!
  89. * \brief Releases a reference of an ClassifierModel object.
  90. * The object may not be garbage collected until its total reference and its contained objects
  91. * count is zero. After returning from this function the reference is zeroed/cleared.
  92. * \param [in] model The pointer to the ClassifierModel to release.
  93. * \return A <tt>\ref vx_status_e</tt> enumeration.
  94. * \retval <tt>\ref VX_SUCCESS</tt> No errors; all other values indicate failure
  95. * \retval * An error occurred. See <tt\ref >vx_status_e</tt>.
  96. * \ingroup group_object_classifier_model
  97. */
  98. VX_API_ENTRY vx_status vxReleaseClassifierModel(vx_classifier_model* model);
  99. /*! \brief [Graph] Scans a feature-map (input_feature_map) and detect the classification for each scan-window.
  100. * \param [in] graph The reference to the graph
  101. * \param [in] input_feature_map The Feature-map, example is the output of <tt>\ref vxHOGFeaturesNode</tt>.
  102. * \param [in] model The pre-trained model loaded. Loaded using <tt>\ref vxImportClassifierModel</tt>
  103. * \param [in] scan_window_width Width of the scan window
  104. * \param [in] scan_window_height Height of the scan window
  105. * \param [in] step_x Horizontal step-size (along x-axis)
  106. * \param [in] step_y Vertical step-size (along y-axis)
  107. * \param [out] object_confidences [Optional] An array of confidences measure, the measure is of type <tt>\ref VX_TYPE_UINT16</tt>. The confidence measure is defined by the extensions which define classification model with defined binary format.
  108. * This output can be used as class index as well. In case we detect several different classes in single execution. The output will be an array of indexes of the classes.
  109. * \param [out] object_rectangles An array of object positions, in <tt>\ref VX_TYPE_RECTANGLE</tt>
  110. * \param [out] num_objects [optional] The number of object detected in a <tt>\ref VX_SIZE</tt> scalar
  111. * \note The border mode <tt>\ref VX_NODE_BORDER</tt> value <tt>\ref VX_BORDER_UNDEFINED</tt> is supported.
  112. * \ingroup group_vision_function_classifier
  113. * \return <tt>\ref vx_node</tt>.
  114. * \retval vx_node A node reference. Any possible errors preventing a successful creation should be checked using <tt>\ref vxGetStatus</tt>
  115. */
  116. VX_API_ENTRY vx_node vxScanClassifierNode(vx_graph graph,vx_tensor input_feature_map, vx_classifier_model model, vx_int32 scanwindow_width, vx_int32 scanwindow_height, vx_int32 step_x, vx_int32 step_y,
  117. vx_array object_confidences, vx_array object_rectangles, vx_scalar num_objects);
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif