BayerSharpnessMap.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of NVIDIA CORPORATION nor the names of its
  13. * contributors may be used to endorse or promote products derived
  14. * from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  20. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  23. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  24. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. /**
  29. * @file
  30. * <b>Libargus Extension: Bayer Sharpness Map API</b>
  31. *
  32. * @b Description: This file defines the BayerSharpnessMap extension.
  33. */
  34. #ifndef _ARGUS_EXT_BAYER_SHARPNESS_MAP_H
  35. #define _ARGUS_EXT_BAYER_SHARPNESS_MAP_H
  36. namespace Argus
  37. {
  38. /**
  39. * Adds internally-generated sharpness metrics to CaptureMetadata results. These are used
  40. * in order to help determine the correct position of the lens to achieve the best focus.
  41. * It introduces two new interfaces:
  42. * - Ext::IBayerSharpnessMapSettings: enables sharness map generation in a capture Request.
  43. * - Ext::IBayerSharpnessMap: exposes the sharpness map metrics from the CaptureMetadata.
  44. *
  45. * @defgroup ArgusExtBayerSharpnessMap Ext::BayerSharpnessMap
  46. * @ingroup ArgusExtensions
  47. */
  48. DEFINE_UUID(ExtensionName, EXT_BAYER_SHARPNESS_MAP, 7d5e0470,4ea6,11e6,bdf4,08,00,20,0c,9a,66);
  49. namespace Ext
  50. {
  51. /**
  52. * @class IBayerSharpnessMapSettings
  53. *
  54. * Interface to Bayer sharpness map settings.
  55. *
  56. * @ingroup ArgusRequest ArgusExtBayerSharpnessMap
  57. */
  58. DEFINE_UUID(InterfaceID, IID_BAYER_SHARPNESS_MAP_SETTINGS, 7d5e0471,4ea6,11e6,bdf4,08,00,20,0c,9a,66);
  59. class IBayerSharpnessMapSettings : public Interface
  60. {
  61. public:
  62. static const InterfaceID& id() { return IID_BAYER_SHARPNESS_MAP_SETTINGS; }
  63. /**
  64. * Enables or disables Bayer sharpness map generation. When enabled, CaptureMetadata
  65. * returned by completed captures expose the IBayerSharpnessMap interface.
  66. * @param[in] enable If True, Bayer sharpness map generation is enabled.
  67. */
  68. virtual void setBayerSharpnessMapEnable(bool enable) = 0;
  69. /**
  70. * Returns True if sharpness map generation is enabled.
  71. */
  72. virtual bool getBayerSharpnessMapEnable() const = 0;
  73. protected:
  74. ~IBayerSharpnessMapSettings() {}
  75. };
  76. /**
  77. * @class IBayerSharpnessMap
  78. *
  79. * Interface to Bayer sharpness map metadata.
  80. *
  81. * The Bayer sharpness map exposes image sharpness metrics that can be used in order
  82. * to help determine the correct position of the lens to achieve the best focus.
  83. * Each metric is a normalized floating-point value representing the estimated sharpness
  84. * for a particular color channel and pixel region, called bins, where 0.0 and 1.0 map to
  85. * the minimum and maximum possible sharpness values, respectively. Sharpness values
  86. * generally correlate with image focus in that a low sharpness implies a poorly focused
  87. * (blurry) region while a high sharpness implies a well focused (sharp) region.
  88. *
  89. * The size and layout of the bins used to calculate the sharpness metrics are determined
  90. * by the libargus implementation, and are illustrated in the following diagram. The bin size
  91. * and interval are constant across the image, and are positioned such that the generated
  92. * metrics cover the majority of the full image. All dimensions are given in pixels.
  93. *
  94. * @code
  95. * start.x interval.width
  96. * _______ _________________
  97. * | | | |
  98. * _ ________________________________________________________
  99. * | | |
  100. * start.y | | |
  101. * |_ | _____ _____ _____ | _
  102. * | | | | | | | | |
  103. * | | 0,0 | | 1,0 | | 2,0 | | |
  104. * | |_____| |_____| |_____| | |
  105. * | | | interval.height
  106. * | | |
  107. * | | |
  108. * | _____ _____ _____ | _|
  109. * | | | | | | | |
  110. * | | 0,1 | | 1,1 | | 2,1 | |
  111. * | |_____| |_____| |_____| |
  112. * | |
  113. * | |
  114. * | |
  115. * | _____ _____ _____ | _
  116. * | | | | | | | | |
  117. * | | 0,2 | | 1,2 | | 2,2 | | | size.height
  118. * | |_____| |_____| |_____| | _|
  119. * | |
  120. * | |
  121. * |________________________________________________________|
  122. *
  123. * |_____|
  124. *
  125. * size.width
  126. * @endcode
  127. *
  128. * @ingroup ArgusCaptureMetadata ArgusExtBayerSharpnessMap
  129. */
  130. DEFINE_UUID(InterfaceID, IID_BAYER_SHARPNESS_MAP, 7d5e0472,4ea6,11e6,bdf4,08,00,20,0c,9a,66);
  131. class IBayerSharpnessMap : public Interface
  132. {
  133. public:
  134. static const InterfaceID& id() { return IID_BAYER_SHARPNESS_MAP; }
  135. /**
  136. * Returns the starting location of the first bin, in pixels, where the
  137. * location is relative to the top-left corner of the image.
  138. */
  139. virtual Point2D<uint32_t> getBinStart() const = 0;
  140. /**
  141. * Returns the size of each bin, in pixels.
  142. */
  143. virtual Size2D<uint32_t> getBinSize() const = 0;
  144. /**
  145. * Returns the number of bins in both the horizontal (width) and vertical (height) directions.
  146. */
  147. virtual Size2D<uint32_t> getBinCount() const = 0;
  148. /**
  149. * Returns the bin intervals for both the x and y axis. These intervals are defined as the
  150. * number of pixels between the first pixel of a bin and that of the immediate next bin.
  151. */
  152. virtual Size2D<uint32_t> getBinInterval() const = 0;
  153. /**
  154. * Returns the sharpness values for all bins and color channels. These values are normalized
  155. * such that 0.0 and 1.0 map to the minimum and maximum possible sharpness values, respectively.
  156. *
  157. * @param[out] values The output array to store the sharpness values for all bins. This
  158. * 2-dimensional array will be sized as returned by @see getBinCount(), where
  159. * each array element is a floating point BayerTuple containing the R, G_EVEN,
  160. * G_ODD, and B sharpness values for that bin.
  161. */
  162. virtual Status getSharpnessValues(Array2D< BayerTuple<float> >* values) const = 0;
  163. protected:
  164. ~IBayerSharpnessMap() {}
  165. };
  166. } // namespace Ext
  167. } // namespace Argus
  168. #endif // _ARGUS_EXT_BAYER_SHARPNESS_MAP_H