CaptureMetadata.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. /*
  2. * Copyright (c) 2016-2021, 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 API: Capture Metadata API</b>
  31. *
  32. * @b Description: Defines the CaptureMetadata objects and interfaces.
  33. */
  34. #ifndef _ARGUS_CAPTURE_METADATA_H
  35. #define _ARGUS_CAPTURE_METADATA_H
  36. namespace Argus
  37. {
  38. /**
  39. * Container for metadata generated by a single completed capture.
  40. *
  41. * @defgroup ArgusCaptureMetadata CaptureMetadata
  42. * @ingroup ArgusObjects
  43. */
  44. class CaptureMetadata : public InterfaceProvider
  45. {
  46. protected:
  47. ~CaptureMetadata() {}
  48. };
  49. /**
  50. * An object that holds a CaptureMetadata instance
  51. * and is used to read the capture metadata from a consumer thread directly from
  52. * the embedded EGLStream metadata. It exposes the same interfaces as
  53. * CaptureMetadata, but is owned by the consumer.
  54. */
  55. class CaptureMetadataContainer : public InterfaceProvider, public Destructable
  56. {
  57. protected:
  58. ~CaptureMetadataContainer() {}
  59. };
  60. /**
  61. * @class IBayerHistogram
  62. *
  63. * Interface to Bayer histogram metadata (provided by ICaptureMetadata::getBayerHistogram()).
  64. *
  65. * Bins are evenly distributed across the possible range of values, each containing
  66. * the number of pixels whose value fell within the range for that bin.
  67. *
  68. * @ingroup ArgusBayerHistogram
  69. */
  70. DEFINE_UUID(InterfaceID, IID_BAYER_HISTOGRAM, 50bc4f1c,6424,beb7,baae,b0,90,c9,c3,25,9e);
  71. class IBayerHistogram : public Interface
  72. {
  73. public:
  74. static const InterfaceID& id() { return IID_BAYER_HISTOGRAM; }
  75. /**
  76. * Returns the number of bins in the histogram.
  77. */
  78. virtual uint32_t getBinCount() const = 0;
  79. /**
  80. * Returns the histogram data.
  81. *
  82. * @param[out] histogram The output vector to store the histogram data. Upon successful
  83. * return, this vector will be replaced with getBinCount() bin values,
  84. * each containing per-channel pixel counts within a BayerTuple container.
  85. */
  86. virtual Status getHistogram(std::vector< BayerTuple<uint32_t> >* histogram) const = 0;
  87. protected:
  88. ~IBayerHistogram() {}
  89. };
  90. /**
  91. * @class IRGBHistogram
  92. *
  93. * Interface to RGB histogram metadata (provided by ICaptureMetadata::getRGBHistogram()).
  94. *
  95. * Bins are evenly distributed across the possible range of values, each containing
  96. * the number of pixels whose value fell within the range for that bin.
  97. *
  98. * @ingroup ArgusRGBHistogram
  99. */
  100. DEFINE_UUID(InterfaceID, IID_RGB_HISTOGRAM, 50bc4f1d,6424,beb7,baae,b0,90,c9,c3,25,9e);
  101. class IRGBHistogram : public Interface
  102. {
  103. public:
  104. static const InterfaceID& id() { return IID_RGB_HISTOGRAM; }
  105. /**
  106. * Returns the number of bins in the histogram.
  107. */
  108. virtual uint32_t getBinCount() const = 0;
  109. /**
  110. * Returns the histogram data.
  111. *
  112. * @param[out] histogram The output vector to store the histogram data. Upon successful
  113. * return, this vector will be replaced with getBinCount() bin values,
  114. * each containing per-channel pixel counts within an RGBTuple container.
  115. */
  116. virtual Status getHistogram(std::vector< RGBTuple<uint32_t> >* histogram) const = 0;
  117. protected:
  118. ~IRGBHistogram() {}
  119. };
  120. /**
  121. * @class IStreamCaptureMetadata
  122. *
  123. * Interface to per-stream metadata (provided by ICaptureMetadata::getStreamMetadata()).
  124. *
  125. * @ingroup ArgusStreamCaptureMetadata
  126. */
  127. DEFINE_UUID(InterfaceID, IID_STREAM_CAPTURE_METADATA, 61cbe0a8,0ee1,4c67,baae,02,02,1a,b8,d9,47);
  128. class IStreamCaptureMetadata : public Interface
  129. {
  130. public:
  131. static const InterfaceID& id() { return IID_STREAM_CAPTURE_METADATA; }
  132. /**
  133. * Returns the clip rectangle used for this stream.
  134. */
  135. virtual Rectangle<float> getSourceClipRect() const = 0;
  136. protected:
  137. ~IStreamCaptureMetadata() {}
  138. };
  139. /**
  140. * @class ICaptureMetadata
  141. *
  142. * Interface to the core capture metadata.
  143. *
  144. * @ingroup ArgusCaptureMetadata
  145. *
  146. * @defgroup ArgusStreamCaptureMetadata StreamMetadata
  147. * Child stream metadata, returned by ICaptureMetadata::getStreamMetadata
  148. * @ingroup ArgusCaptureMetadata
  149. *
  150. * @defgroup ArgusRGBHistogram RGBHistogram
  151. * Child RGB histogram metadata, returned by ICaptureMetadata::getRGBHistogram
  152. * @ingroup ArgusCaptureMetadata
  153. *
  154. * @defgroup ArgusBayerHistogram BayerHistogram
  155. * Child Bayer histogram metadata, returned by ICaptureMetadata::getBayerHistogram
  156. * @ingroup ArgusCaptureMetadata
  157. */
  158. DEFINE_UUID(InterfaceID, IID_CAPTURE_METADATA, 5f6ac5d4,59e8,45d0,8bac,38,09,1f,f8,74,a9);
  159. class ICaptureMetadata : public Interface
  160. {
  161. public:
  162. static const InterfaceID& id() { return IID_CAPTURE_METADATA; }
  163. static const uint32_t NUM_COLOR_CORRECTION_ELEMENTS = 9;
  164. static const uint32_t NUM_AWB_WB_ESTIMATE_ELEMENTS = 4;
  165. /**
  166. * Returns the capture id (the value returned from ICaptureSession::capture())
  167. * of the capture that generated this metadata.
  168. */
  169. virtual uint32_t getCaptureId() const = 0;
  170. /**
  171. * Returns the @c clientData value for the Request used in the capture
  172. * that generated this metadata.
  173. *
  174. * @see ICaptureSession::createRequest()
  175. */
  176. virtual uint32_t getClientData() const = 0;
  177. /**
  178. * Returns the per-stream metadata provider for @c stream.
  179. * This object will provide the IStreamCaptureMetadata interface.
  180. */
  181. virtual InterfaceProvider* getStreamMetadata(const OutputStream* stream) const = 0;
  182. /**
  183. * Returns the Bayer histogram for this capture.
  184. * This object will provide the IBayerHistogram interface.
  185. */
  186. virtual const InterfaceProvider* getBayerHistogram() const = 0;
  187. /**
  188. * Returns the RGB histogram for this capture.
  189. * This object will provide the IRGBHistogram interface.
  190. */
  191. virtual const InterfaceProvider* getRGBHistogram() const = 0;
  192. /**
  193. * Returns true if and only if AE was locked for this capture.
  194. */
  195. virtual bool getAeLocked() const = 0;
  196. /**
  197. * Gets the AE regions of interest used for this capture.
  198. *
  199. * @param[in] regions A vector that will be populated with the AE regions used in capture.
  200. *
  201. * @returns success/status of the call.
  202. */
  203. virtual Status getAeRegions(std::vector<AcRegion>* regions) const = 0;
  204. /**
  205. * Returns the rectangle of the bayer histogram region of interest.
  206. */
  207. virtual Rectangle<uint32_t> getBayerHistogramRegion() const = 0;
  208. /**
  209. * Returns the state of AE when it ran for this capture.
  210. */
  211. virtual AeState getAeState() const = 0;
  212. /**
  213. * Returns the flicker state of this capture.
  214. */
  215. virtual AeFlickerState getFlickerState() const = 0;
  216. /**
  217. * Returns the aperture position.
  218. */
  219. virtual int32_t getAperturePosition() const = 0;
  220. /**
  221. * Returns the focuser position used for this capture (in focuser steps).
  222. */
  223. virtual int32_t getFocuserPosition() const = 0;
  224. /**
  225. * Returns the CCT calculated by AWB for this capture.
  226. */
  227. virtual uint32_t getAwbCct() const = 0;
  228. /**
  229. * Returns the AWB gains used for this capture as per AwbMode.
  230. */
  231. virtual BayerTuple<float> getAwbGains() const = 0;
  232. /**
  233. * Returns the AWB mode used for this capture.
  234. */
  235. virtual AwbMode getAwbMode() const = 0;
  236. /**
  237. * Gets the AWB regions of interest used for this capture.
  238. *
  239. * @param[in] regions A vector that will be populated with the AWB regions used in capture.
  240. *
  241. * @returns success/status of the call.
  242. */
  243. virtual Status getAwbRegions(std::vector<AcRegion>* regions) const = 0;
  244. /**
  245. * Gets the AF regions of interest used for this capture.
  246. *
  247. * @param[in] regions A vector that will be populated with the AF regions used in capture.
  248. *
  249. * @returns success/status of the call.
  250. */
  251. virtual Status getAfRegions(std::vector<AcRegion>* regions) const = 0;
  252. /**
  253. * Gets the sharpness score values calculated for corresponding AF regions.
  254. *
  255. * @param[in] values A vector that will be populated with the sharpness scores used in capture.
  256. *
  257. * @returns success/status of the call.
  258. */
  259. virtual Status getSharpnessScore(std::vector<float>* values) const = 0;
  260. /**
  261. * @returns the state of AWB when it ran for this capture.
  262. */
  263. virtual AwbState getAwbState() const = 0;
  264. /**
  265. * Gets the current AWB WB estimate as a vector of NUM_AWB_WB_ESTIMATE_ELEMENTS values.
  266. * @todo Document the meaning of an AWB WB estimate.
  267. *
  268. * @param[in] estimate A vector that will be populated with the AWB WB estimates.
  269. *
  270. * @returns success/status of the call.
  271. */
  272. virtual Status getAwbWbEstimate(std::vector<float>* estimate) const = 0;
  273. /**
  274. * Returns the enable state for the client-supplied Color Correction Matrix.
  275. */
  276. virtual bool getColorCorrectionMatrixEnable() const = 0;
  277. /**
  278. * Gets the 3x3 client-supplied Color Correction Matrix as a flattened
  279. * (row-major) vector of 9 values. This matrix is irrelevant if
  280. * <tt>getColorCorrectionMatrixEnable() == false</tt>.
  281. *
  282. * @param[in] ccMatrix A vector that will be populated with the color correction matrix.
  283. *
  284. * @returns success/status of the call.
  285. */
  286. virtual Status getColorCorrectionMatrix(std::vector<float>* ccMatrix) const = 0;
  287. /**
  288. * Returns the color saturation value used for this capture (including biasing).
  289. */
  290. virtual float getColorSaturation() const = 0;
  291. /**
  292. * Returns the time it took to integrate this capture (in nanoseconds).
  293. * @todo Provide a more precise description of frame duration.
  294. */
  295. virtual uint64_t getFrameDuration() const = 0;
  296. /**
  297. * Returns the digital gain used for this capture.
  298. */
  299. virtual float getIspDigitalGain() const = 0;
  300. /**
  301. * Returns the frame readout time for this capture (in nanoseconds) from
  302. * the beginning of the first line to the beginning of the last line.
  303. */
  304. virtual uint64_t getFrameReadoutTime() const = 0;
  305. /**
  306. * Returns the estimated scene brightness for this capture (in lux).
  307. */
  308. virtual float getSceneLux() const = 0;
  309. /**
  310. * Returns the sensor analog gain used for this capture.
  311. */
  312. virtual float getSensorAnalogGain() const = 0;
  313. /**
  314. * Returns the sensor exposure time for this capture (in nanoseconds).
  315. */
  316. virtual uint64_t getSensorExposureTime() const = 0;
  317. /**
  318. * Returns the ISO value used for this capture.
  319. */
  320. virtual uint32_t getSensorSensitivity() const = 0;
  321. /**
  322. * Returns the start timestamp for the sensor (in nanoseconds).
  323. * This is the time that the first data from this capture arrives from the sensor.
  324. */
  325. virtual uint64_t getSensorTimestamp() const = 0;
  326. /**
  327. * Returns true if and only if a user-specified tone map curve was used for this capture.
  328. */
  329. virtual bool getToneMapCurveEnabled() const = 0;
  330. /**
  331. * Returns the specified color channel for the tone mapping table
  332. * (as a vector of NUM_TONE_MAP_ELEMENTS values). These values are irrelevant if
  333. * <tt>getToneMapCurveEnabled() == false</tt>.
  334. *
  335. * @param[in] channel Specified the color channel for which the curve will be returned.
  336. * @param[in] curve A vector that will be populated with the color curve used in capture.
  337. *
  338. * @returns success/status of the call.
  339. */
  340. virtual Status getToneMapCurve(RGBChannel channel, std::vector<float>* curve) const = 0;
  341. protected:
  342. ~ICaptureMetadata() {}
  343. };
  344. /**
  345. * @class IDenoiseMetadata
  346. *
  347. * Interface to denoise metadata.
  348. *
  349. * @ingroup ArgusCaptureMetadata
  350. */
  351. DEFINE_UUID(InterfaceID, IID_DENOISE_METADATA, 7A461D23,6AE1,11E6,BDF4,08,00,20,0C,9A,66);
  352. class IDenoiseMetadata : public Interface
  353. {
  354. public:
  355. static const InterfaceID& id() { return IID_DENOISE_METADATA; }
  356. /**
  357. * Returns the denoise mode used for the capture.
  358. */
  359. virtual DenoiseMode getDenoiseMode() const = 0;
  360. /**
  361. * Returns the denoise strength used for the capture.
  362. */
  363. virtual float getDenoiseStrength() const = 0;
  364. protected:
  365. ~IDenoiseMetadata() {}
  366. };
  367. /**
  368. * @class IEdgeEnhanceMetadata
  369. *
  370. * Interface to edge enhancement metadata.
  371. *
  372. * @ingroup ArgusCaptureMetadata
  373. */
  374. DEFINE_UUID(InterfaceID, IID_EDGE_ENHANCE_METADATA, 7A461D24,6AE1,11E6,BDF4,08,00,20,0C,9A,66);
  375. class IEdgeEnhanceMetadata : public Interface
  376. {
  377. public:
  378. static const InterfaceID& id() { return IID_EDGE_ENHANCE_METADATA; }
  379. /**
  380. * Returns the edge enhancement mode used for the capture.
  381. */
  382. virtual EdgeEnhanceMode getEdgeEnhanceMode() const = 0;
  383. /**
  384. * Returns the edge enhancement strength used for the capture.
  385. */
  386. virtual float getEdgeEnhanceStrength() const = 0;
  387. protected:
  388. ~IEdgeEnhanceMetadata() {}
  389. };
  390. } // namespace Argus
  391. #endif // _ARGUS_CAPTURE_METADATA_H