Argus API
Argus Camera API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BayerSharpnessMap.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, 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 #ifndef _ARGUS_EXT_BAYER_SHARPNESS_MAP_H
30 #define _ARGUS_EXT_BAYER_SHARPNESS_MAP_H
31 
32 namespace Argus
33 {
34 
35 /**
36  * The Ext::BayerSharpnessMap extension adds internally-generated sharpness metrics
37  * to CaptureMetadata results in order to help determine the correct position of the lens
38  * to achieve the best focus. It introduces two new interfaces:
39  * - IBayerSharpnessMapSettings; used to enable sharness map generation in a capture Request.
40  * - IBayerSharpnessMapMetadata; exposes the sharpness map metrics from the CaptureMetadata.
41  */
42 DEFINE_UUID(ExtensionName, EXT_BAYER_SHARPNESS_MAP, 7d5e0470,4ea6,11e6,bdf4,08,00,20,0c,9a,66);
43 
44 namespace Ext
45 {
46 
47 /**
48  * @class IBayerSharpnessMapSettings
49  *
50  * Request settings used to configure Bayer sharpness map generation.
51  */
52 DEFINE_UUID(InterfaceID, IID_BAYER_SHARPNESS_MAP_SETTINGS, 7d5e0471,4ea6,11e6,bdf4,08,00,20,0c,9a,66);
54 {
55 public:
56  static const InterfaceID& id() { return IID_BAYER_SHARPNESS_MAP_SETTINGS; }
57 
58  /**
59  * Enables or disables Bayer sharpness map generation. When enabled, CaptureMetadata
60  * returned by completed captures will expose the IBayerSharpnessMap interface.
61  * @param[in] enable whether or not Bayer sharpness map generation is enabled.
62  */
63  virtual void setBayerSharpnessMapEnable(bool enable) = 0;
64 
65  /**
66  * @returns whether or not Bayer sharpness map generation is enabled.
67  */
68  virtual bool getBayerSharpnessMapEnable() const = 0;
69 
70 protected:
72 };
73 
74 /**
75  * @class IBayerSharpnessMap
76  *
77  * The Bayer sharpness map exposes image sharpness metrics that can be used in order
78  * to help determine the correct position of the lens to achieve the best focus.
79  * Each metric is a normalized floating-point value representing the estimated sharpness
80  * for a particular color channel and pixel region, called bins, where 0.0 and 1.0 map to
81  * the minimum and maximum possible sharpness values, respectively. Sharpness values
82  * generally correlate with image focus in that a low sharpness implies a poorly focused
83  * (blurry) region while a high sharpness implies a well focused (sharp) region.
84  *
85  * The size and layout of the bins used to calculate the sharpness metrics are determined
86  * by the Argus implementation, and are illustrated in the following diagram. The bin size
87  * and interval are constant across the image, and are positioned such that the generated
88  * metrics cover the majority of the full image. All dimensions are given in pixels.
89  *
90  * start.x interval.width
91  * _______ _________________
92  * | | | |
93  * _ ________________________________________________________
94  * | | |
95  * start.y | | |
96  * |_ | _____ _____ _____ | _
97  * | | | | | | | | |
98  * | | 0,0 | | 1,0 | | 2,0 | | |
99  * | |_____| |_____| |_____| | |
100  * | | | interval.height
101  * | | |
102  * | | |
103  * | _____ _____ _____ | _|
104  * | | | | | | | |
105  * | | 0,1 | | 1,1 | | 2,1 | |
106  * | |_____| |_____| |_____| |
107  * | |
108  * | |
109  * | |
110  * | _____ _____ _____ | _
111  * | | | | | | | | |
112  * | | 0,2 | | 1,2 | | 2,2 | | | size.height
113  * | |_____| |_____| |_____| | _|
114  * | |
115  * | |
116  * |________________________________________________________|
117  *
118  * |_____|
119  *
120  * size.width
121  *
122  */
123 DEFINE_UUID(InterfaceID, IID_BAYER_SHARPNESS_MAP, 7d5e0472,4ea6,11e6,bdf4,08,00,20,0c,9a,66);
125 {
126 public:
127  static const InterfaceID& id() { return IID_BAYER_SHARPNESS_MAP; }
128 
129  /**
130  * Returns the starting location of the first bin, in pixels.
131  * Relative to the top-left corner of the image.
132  */
133  virtual Point2D<uint32_t> getBinStart() const = 0;
134 
135  /**
136  * Returns the size of each bin, in pixels.
137  */
138  virtual Size2D<uint32_t> getBinSize() const = 0;
139 
140  /**
141  * Returns the number of bins in both the horizontal (width) and vertical (height) directions.
142  */
143  virtual Size2D<uint32_t> getBinCount() const = 0;
144 
145  /**
146  * Returns the bin intervals for both the x and y axis. These intervals are defined as the
147  * number of pixels between the first pixel of a bin and that of the immediate next bin.
148  */
149  virtual Size2D<uint32_t> getBinInterval() const = 0;
150 
151  /**
152  * Returns the sharpness values for all bins and color channels. These values are normalized
153  * such that 0.0 and 1.0 map to the minimum and maximum possible sharpness values, respectively.
154  *
155  * @param[out] values The output array to store the sharpness values for all bins. This
156  * 2-dimensional array will be sized as returned by @see getBinCount(), where
157  * each array element is a floating point BayerTuple containing the R, G_EVEN,
158  * G_ODD, and B sharpness values for that bin.
159  */
160  virtual Status getSharpnessValues(Array2D< BayerTuple<float> >* values) const = 0;
161 
162 protected:
164 };
165 
166 } // namespace Ext
167 
168 } // namespace Argus
169 
170 #endif // _ARGUS_EXT_BAYER_SHARPNESS_MAP_H