CaptureMetadata.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. /*
  2. * Copyright (c) 2016-2023, 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 sensor source index for this capture. This is useful to know which sensor
  172. * captured frame and metadata belongs to, in case of sync sensor usecase.
  173. */
  174. virtual uint32_t getSourceIndex() const = 0;
  175. /**
  176. * Returns the @c clientData value for the Request used in the capture
  177. * that generated this metadata.
  178. *
  179. * @see ICaptureSession::createRequest()
  180. */
  181. virtual uint32_t getClientData() const = 0;
  182. /**
  183. * Returns the per-stream metadata provider for @c stream.
  184. * This object will provide the IStreamCaptureMetadata interface.
  185. */
  186. virtual InterfaceProvider* getStreamMetadata(const OutputStream* stream) const = 0;
  187. /**
  188. * Returns the Bayer histogram for this capture.
  189. * This object will provide the IBayerHistogram interface.
  190. */
  191. virtual const InterfaceProvider* getBayerHistogram() const = 0;
  192. /**
  193. * Returns the RGB histogram for this capture.
  194. * This object will provide the IRGBHistogram interface.
  195. */
  196. virtual const InterfaceProvider* getRGBHistogram() const = 0;
  197. /**
  198. * Returns true if and only if AE was locked for this capture.
  199. */
  200. virtual bool getAeLocked() const = 0;
  201. /**
  202. * Gets the AE regions of interest used for this capture.
  203. *
  204. * @param[in] regions A vector that will be populated with the AE regions used in capture.
  205. *
  206. * @returns success/status of the call.
  207. */
  208. virtual Status getAeRegions(std::vector<AcRegion>* regions) const = 0;
  209. /**
  210. * Returns the rectangle of the bayer histogram region of interest.
  211. */
  212. virtual Rectangle<uint32_t> getBayerHistogramRegion() const = 0;
  213. /**
  214. * Returns the state of AE when it ran for this capture.
  215. */
  216. virtual AeState getAeState() const = 0;
  217. /**
  218. * Returns the flicker state of this capture.
  219. */
  220. virtual AeFlickerState getFlickerState() const = 0;
  221. /**
  222. * Returns the aperture position.
  223. */
  224. virtual int32_t getAperturePosition() const = 0;
  225. /**
  226. * Returns the focuser position used for this capture (in focuser steps).
  227. */
  228. virtual int32_t getFocuserPosition() const = 0;
  229. /**
  230. * Returns the CCT calculated by AWB for this capture.
  231. */
  232. virtual uint32_t getAwbCct() const = 0;
  233. /**
  234. * Returns the AWB gains used for this capture as per AwbMode.
  235. */
  236. virtual BayerTuple<float> getAwbGains() const = 0;
  237. /**
  238. * Returns the AWB mode used for this capture.
  239. */
  240. virtual AwbMode getAwbMode() const = 0;
  241. /**
  242. * Gets the AWB regions of interest used for this capture.
  243. *
  244. * @param[in] regions A vector that will be populated with the AWB regions used in capture.
  245. *
  246. * @returns success/status of the call.
  247. */
  248. virtual Status getAwbRegions(std::vector<AcRegion>* regions) const = 0;
  249. /**
  250. * Gets the AF regions of interest used for this capture.
  251. *
  252. * @param[in] regions A vector that will be populated with the AF regions used in capture.
  253. *
  254. * @returns success/status of the call.
  255. */
  256. virtual Status getAfRegions(std::vector<AcRegion>* regions) const = 0;
  257. /**
  258. * Gets the sharpness score values calculated for corresponding AF regions.
  259. *
  260. * @param[in] values A vector that will be populated with the sharpness scores used in capture.
  261. *
  262. * @returns success/status of the call.
  263. */
  264. virtual Status getSharpnessScore(std::vector<float>* values) const = 0;
  265. /**
  266. * @returns the state of AWB when it ran for this capture.
  267. */
  268. virtual AwbState getAwbState() const = 0;
  269. /**
  270. * Gets the current AWB WB estimate as a vector of NUM_AWB_WB_ESTIMATE_ELEMENTS values.
  271. * @todo Document the meaning of an AWB WB estimate.
  272. *
  273. * @param[in] estimate A vector that will be populated with the AWB WB estimates.
  274. *
  275. * @returns success/status of the call.
  276. */
  277. virtual Status getAwbWbEstimate(std::vector<float>* estimate) const = 0;
  278. /**
  279. * Returns the enable state for the client-supplied Color Correction Matrix.
  280. */
  281. virtual bool getColorCorrectionMatrixEnable() const = 0;
  282. /**
  283. * Gets the 3x3 client-supplied Color Correction Matrix as a flattened
  284. * (row-major) vector of 9 values. This matrix is irrelevant if
  285. * <tt>getColorCorrectionMatrixEnable() == false</tt>.
  286. *
  287. * @param[in] ccMatrix A vector that will be populated with the color correction matrix.
  288. *
  289. * @returns success/status of the call.
  290. */
  291. virtual Status getColorCorrectionMatrix(std::vector<float>* ccMatrix) const = 0;
  292. /**
  293. * Returns the color saturation value used for this capture (including biasing).
  294. */
  295. virtual float getColorSaturation() const = 0;
  296. /**
  297. * Returns the time it took to integrate this capture (in nanoseconds).
  298. * @todo Provide a more precise description of frame duration.
  299. */
  300. virtual uint64_t getFrameDuration() const = 0;
  301. /**
  302. * Returns the digital gain used for this capture.
  303. */
  304. virtual float getIspDigitalGain() const = 0;
  305. /**
  306. * Returns the frame readout time for this capture (in nanoseconds) from
  307. * the beginning of the first line to the beginning of the last line.
  308. */
  309. virtual uint64_t getFrameReadoutTime() const = 0;
  310. /**
  311. * Returns the estimated scene brightness for this capture (in lux).
  312. */
  313. virtual float getSceneLux() const = 0;
  314. /**
  315. * Returns the sensor analog gain used for this capture.
  316. */
  317. virtual float getSensorAnalogGain() const = 0;
  318. /**
  319. * Returns the sensor exposure time for this capture (in nanoseconds).
  320. */
  321. virtual uint64_t getSensorExposureTime() const = 0;
  322. /**
  323. * Returns the ISO value used for this capture.
  324. */
  325. virtual uint32_t getSensorSensitivity() const = 0;
  326. /**
  327. * Returns the start timestamp for the sensor (in nanoseconds).
  328. * This is the time that the first data from this capture arrives from the sensor.
  329. */
  330. virtual uint64_t getSensorTimestamp() const = 0;
  331. /**
  332. * Returns true if and only if a user-specified tone map curve was used for this capture.
  333. */
  334. virtual bool getToneMapCurveEnabled() const = 0;
  335. /**
  336. * Returns the specified color channel for the tone mapping table
  337. * (as a vector of NUM_TONE_MAP_ELEMENTS values). These values are irrelevant if
  338. * <tt>getToneMapCurveEnabled() == false</tt>.
  339. *
  340. * @param[in] channel Specified the color channel for which the curve will be returned.
  341. * @param[in] curve A vector that will be populated with the color curve used in capture.
  342. *
  343. * @returns success/status of the call.
  344. */
  345. virtual Status getToneMapCurve(RGBChannel channel, std::vector<float>* curve) const = 0;
  346. protected:
  347. ~ICaptureMetadata() {}
  348. };
  349. /**
  350. * @class IDenoiseMetadata
  351. *
  352. * Interface to denoise metadata.
  353. *
  354. * @ingroup ArgusCaptureMetadata
  355. */
  356. DEFINE_UUID(InterfaceID, IID_DENOISE_METADATA, 7A461D23,6AE1,11E6,BDF4,08,00,20,0C,9A,66);
  357. class IDenoiseMetadata : public Interface
  358. {
  359. public:
  360. static const InterfaceID& id() { return IID_DENOISE_METADATA; }
  361. /**
  362. * Returns the denoise mode used for the capture.
  363. */
  364. virtual DenoiseMode getDenoiseMode() const = 0;
  365. /**
  366. * Returns the denoise strength used for the capture.
  367. */
  368. virtual float getDenoiseStrength() const = 0;
  369. protected:
  370. ~IDenoiseMetadata() {}
  371. };
  372. /**
  373. * @class IEdgeEnhanceMetadata
  374. *
  375. * Interface to edge enhancement metadata.
  376. *
  377. * @ingroup ArgusCaptureMetadata
  378. */
  379. DEFINE_UUID(InterfaceID, IID_EDGE_ENHANCE_METADATA, 7A461D24,6AE1,11E6,BDF4,08,00,20,0C,9A,66);
  380. class IEdgeEnhanceMetadata : public Interface
  381. {
  382. public:
  383. static const InterfaceID& id() { return IID_EDGE_ENHANCE_METADATA; }
  384. /**
  385. * Returns the edge enhancement mode used for the capture.
  386. */
  387. virtual EdgeEnhanceMode getEdgeEnhanceMode() const = 0;
  388. /**
  389. * Returns the edge enhancement strength used for the capture.
  390. */
  391. virtual float getEdgeEnhanceStrength() const = 0;
  392. protected:
  393. ~IEdgeEnhanceMetadata() {}
  394. };
  395. } // namespace Argus
  396. #endif // _ARGUS_CAPTURE_METADATA_H