aws_sdk_rekognition/operation/detect_labels/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::detect_labels::_detect_labels_output::DetectLabelsOutputBuilder;
3
4pub use crate::operation::detect_labels::_detect_labels_input::DetectLabelsInputBuilder;
5
6impl crate::operation::detect_labels::builders::DetectLabelsInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::detect_labels::DetectLabelsOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::detect_labels::DetectLabelsError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.detect_labels();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `DetectLabels`.
24///
25/// <p>Detects instances of real-world entities within an image (JPEG or PNG) provided as input. This includes objects like flower, tree, and table; events like wedding, graduation, and birthday party; and concepts like landscape, evening, and nature.</p>
26/// <p>For an example, see Analyzing images stored in an Amazon S3 bucket in the Amazon Rekognition Developer Guide.</p>
27/// <p>You pass the input image as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file.</p>
28/// <p><b>Optional Parameters</b></p>
29/// <p>You can specify one or both of the <code>GENERAL_LABELS</code> and <code>IMAGE_PROPERTIES</code> feature types when calling the DetectLabels API. Including <code>GENERAL_LABELS</code> will ensure the response includes the labels detected in the input image, while including <code>IMAGE_PROPERTIES </code>will ensure the response includes information about the image quality and color.</p>
30/// <p>When using <code>GENERAL_LABELS</code> and/or <code>IMAGE_PROPERTIES</code> you can provide filtering criteria to the Settings parameter. You can filter with sets of individual labels or with label categories. You can specify inclusive filters, exclusive filters, or a combination of inclusive and exclusive filters. For more information on filtering see <a href="https://docs.aws.amazon.com/rekognition/latest/dg/labels-detect-labels-image.html">Detecting Labels in an Image</a>.</p>
31/// <p>When getting labels, you can specify <code>MinConfidence</code> to control the confidence threshold for the labels returned. The default is 55%. You can also add the <code>MaxLabels</code> parameter to limit the number of labels returned. The default and upper limit is 1000 labels. These arguments are only valid when supplying GENERAL_LABELS as a feature type.</p>
32/// <p><b>Response Elements</b></p>
33/// <p>For each object, scene, and concept the API returns one or more labels. The API returns the following types of information about labels:</p>
34/// <ul>
35/// <li>
36/// <p>Name - The name of the detected label.</p></li>
37/// <li>
38/// <p>Confidence - The level of confidence in the label assigned to a detected object.</p></li>
39/// <li>
40/// <p>Parents - The ancestor labels for a detected label. DetectLabels returns a hierarchical taxonomy of detected labels. For example, a detected car might be assigned the label car. The label car has two parent labels: Vehicle (its parent) and Transportation (its grandparent). The response includes the all ancestors for a label, where every ancestor is a unique label. In the previous example, Car, Vehicle, and Transportation are returned as unique labels in the response.</p></li>
41/// <li>
42/// <p>Aliases - Possible Aliases for the label.</p></li>
43/// <li>
44/// <p>Categories - The label categories that the detected label belongs to.</p></li>
45/// <li>
46/// <p>BoundingBox — Bounding boxes are described for all instances of detected common object labels, returned in an array of Instance objects. An Instance object contains a BoundingBox object, describing the location of the label on the input image. It also includes the confidence for the accuracy of the detected bounding box.</p></li>
47/// </ul>
48/// <p>The API returns the following information regarding the image, as part of the ImageProperties structure:</p>
49/// <ul>
50/// <li>
51/// <p>Quality - Information about the Sharpness, Brightness, and Contrast of the input image, scored between 0 to 100. Image quality is returned for the entire image, as well as the background and the foreground.</p></li>
52/// <li>
53/// <p>Dominant Color - An array of the dominant colors in the image.</p></li>
54/// <li>
55/// <p>Foreground - Information about the sharpness, brightness, and dominant colors of the input image’s foreground.</p></li>
56/// <li>
57/// <p>Background - Information about the sharpness, brightness, and dominant colors of the input image’s background.</p></li>
58/// </ul>
59/// <p>The list of returned labels will include at least one label for every detected object, along with information about that label. In the following example, suppose the input image has a lighthouse, the sea, and a rock. The response includes all three labels, one for each object, as well as the confidence in the label:</p>
60/// <p><code>{Name: lighthouse, Confidence: 98.4629}</code></p>
61/// <p><code>{Name: rock,Confidence: 79.2097}</code></p>
62/// <p><code> {Name: sea,Confidence: 75.061}</code></p>
63/// <p>The list of labels can include multiple labels for the same object. For example, if the input image shows a flower (for example, a tulip), the operation might return the following three labels.</p>
64/// <p><code>{Name: flower,Confidence: 99.0562}</code></p>
65/// <p><code>{Name: plant,Confidence: 99.0562}</code></p>
66/// <p><code>{Name: tulip,Confidence: 99.0562}</code></p>
67/// <p>In this example, the detection algorithm more precisely identifies the flower as a tulip.</p><note>
68/// <p>If the object detected is a person, the operation doesn't provide the same facial details that the <code>DetectFaces</code> operation provides.</p>
69/// </note>
70/// <p>This is a stateless API operation that doesn't return any data.</p>
71/// <p>This operation requires permissions to perform the <code>rekognition:DetectLabels</code> action.</p>
72#[derive(::std::clone::Clone, ::std::fmt::Debug)]
73pub struct DetectLabelsFluentBuilder {
74    handle: ::std::sync::Arc<crate::client::Handle>,
75    inner: crate::operation::detect_labels::builders::DetectLabelsInputBuilder,
76    config_override: ::std::option::Option<crate::config::Builder>,
77}
78impl
79    crate::client::customize::internal::CustomizableSend<
80        crate::operation::detect_labels::DetectLabelsOutput,
81        crate::operation::detect_labels::DetectLabelsError,
82    > for DetectLabelsFluentBuilder
83{
84    fn send(
85        self,
86        config_override: crate::config::Builder,
87    ) -> crate::client::customize::internal::BoxFuture<
88        crate::client::customize::internal::SendResult<
89            crate::operation::detect_labels::DetectLabelsOutput,
90            crate::operation::detect_labels::DetectLabelsError,
91        >,
92    > {
93        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
94    }
95}
96impl DetectLabelsFluentBuilder {
97    /// Creates a new `DetectLabelsFluentBuilder`.
98    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
99        Self {
100            handle,
101            inner: ::std::default::Default::default(),
102            config_override: ::std::option::Option::None,
103        }
104    }
105    /// Access the DetectLabels as a reference.
106    pub fn as_input(&self) -> &crate::operation::detect_labels::builders::DetectLabelsInputBuilder {
107        &self.inner
108    }
109    /// Sends the request and returns the response.
110    ///
111    /// If an error occurs, an `SdkError` will be returned with additional details that
112    /// can be matched against.
113    ///
114    /// By default, any retryable failures will be retried twice. Retry behavior
115    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
116    /// set when configuring the client.
117    pub async fn send(
118        self,
119    ) -> ::std::result::Result<
120        crate::operation::detect_labels::DetectLabelsOutput,
121        ::aws_smithy_runtime_api::client::result::SdkError<
122            crate::operation::detect_labels::DetectLabelsError,
123            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
124        >,
125    > {
126        let input = self
127            .inner
128            .build()
129            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
130        let runtime_plugins = crate::operation::detect_labels::DetectLabels::operation_runtime_plugins(
131            self.handle.runtime_plugins.clone(),
132            &self.handle.conf,
133            self.config_override,
134        );
135        crate::operation::detect_labels::DetectLabels::orchestrate(&runtime_plugins, input).await
136    }
137
138    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
139    pub fn customize(
140        self,
141    ) -> crate::client::customize::CustomizableOperation<
142        crate::operation::detect_labels::DetectLabelsOutput,
143        crate::operation::detect_labels::DetectLabelsError,
144        Self,
145    > {
146        crate::client::customize::CustomizableOperation::new(self)
147    }
148    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
149        self.set_config_override(::std::option::Option::Some(config_override.into()));
150        self
151    }
152
153    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
154        self.config_override = config_override;
155        self
156    }
157    /// <p>The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. Images stored in an S3 Bucket do not need to be base64-encoded.</p>
158    /// <p>If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the <code>Bytes</code> field. For more information, see Images in the Amazon Rekognition developer guide.</p>
159    pub fn image(mut self, input: crate::types::Image) -> Self {
160        self.inner = self.inner.image(input);
161        self
162    }
163    /// <p>The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. Images stored in an S3 Bucket do not need to be base64-encoded.</p>
164    /// <p>If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the <code>Bytes</code> field. For more information, see Images in the Amazon Rekognition developer guide.</p>
165    pub fn set_image(mut self, input: ::std::option::Option<crate::types::Image>) -> Self {
166        self.inner = self.inner.set_image(input);
167        self
168    }
169    /// <p>The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. Images stored in an S3 Bucket do not need to be base64-encoded.</p>
170    /// <p>If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the <code>Bytes</code> field. For more information, see Images in the Amazon Rekognition developer guide.</p>
171    pub fn get_image(&self) -> &::std::option::Option<crate::types::Image> {
172        self.inner.get_image()
173    }
174    /// <p>Maximum number of labels you want the service to return in the response. The service returns the specified number of highest confidence labels. Only valid when GENERAL_LABELS is specified as a feature type in the Feature input parameter.</p>
175    pub fn max_labels(mut self, input: i32) -> Self {
176        self.inner = self.inner.max_labels(input);
177        self
178    }
179    /// <p>Maximum number of labels you want the service to return in the response. The service returns the specified number of highest confidence labels. Only valid when GENERAL_LABELS is specified as a feature type in the Feature input parameter.</p>
180    pub fn set_max_labels(mut self, input: ::std::option::Option<i32>) -> Self {
181        self.inner = self.inner.set_max_labels(input);
182        self
183    }
184    /// <p>Maximum number of labels you want the service to return in the response. The service returns the specified number of highest confidence labels. Only valid when GENERAL_LABELS is specified as a feature type in the Feature input parameter.</p>
185    pub fn get_max_labels(&self) -> &::std::option::Option<i32> {
186        self.inner.get_max_labels()
187    }
188    /// <p>Specifies the minimum confidence level for the labels to return. Amazon Rekognition doesn't return any labels with confidence lower than this specified value.</p>
189    /// <p>If <code>MinConfidence</code> is not specified, the operation returns labels with a confidence values greater than or equal to 55 percent. Only valid when GENERAL_LABELS is specified as a feature type in the Feature input parameter.</p>
190    pub fn min_confidence(mut self, input: f32) -> Self {
191        self.inner = self.inner.min_confidence(input);
192        self
193    }
194    /// <p>Specifies the minimum confidence level for the labels to return. Amazon Rekognition doesn't return any labels with confidence lower than this specified value.</p>
195    /// <p>If <code>MinConfidence</code> is not specified, the operation returns labels with a confidence values greater than or equal to 55 percent. Only valid when GENERAL_LABELS is specified as a feature type in the Feature input parameter.</p>
196    pub fn set_min_confidence(mut self, input: ::std::option::Option<f32>) -> Self {
197        self.inner = self.inner.set_min_confidence(input);
198        self
199    }
200    /// <p>Specifies the minimum confidence level for the labels to return. Amazon Rekognition doesn't return any labels with confidence lower than this specified value.</p>
201    /// <p>If <code>MinConfidence</code> is not specified, the operation returns labels with a confidence values greater than or equal to 55 percent. Only valid when GENERAL_LABELS is specified as a feature type in the Feature input parameter.</p>
202    pub fn get_min_confidence(&self) -> &::std::option::Option<f32> {
203        self.inner.get_min_confidence()
204    }
205    ///
206    /// Appends an item to `Features`.
207    ///
208    /// To override the contents of this collection use [`set_features`](Self::set_features).
209    ///
210    /// <p>A list of the types of analysis to perform. Specifying GENERAL_LABELS uses the label detection feature, while specifying IMAGE_PROPERTIES returns information regarding image color and quality. If no option is specified GENERAL_LABELS is used by default.</p>
211    pub fn features(mut self, input: crate::types::DetectLabelsFeatureName) -> Self {
212        self.inner = self.inner.features(input);
213        self
214    }
215    /// <p>A list of the types of analysis to perform. Specifying GENERAL_LABELS uses the label detection feature, while specifying IMAGE_PROPERTIES returns information regarding image color and quality. If no option is specified GENERAL_LABELS is used by default.</p>
216    pub fn set_features(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::DetectLabelsFeatureName>>) -> Self {
217        self.inner = self.inner.set_features(input);
218        self
219    }
220    /// <p>A list of the types of analysis to perform. Specifying GENERAL_LABELS uses the label detection feature, while specifying IMAGE_PROPERTIES returns information regarding image color and quality. If no option is specified GENERAL_LABELS is used by default.</p>
221    pub fn get_features(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::DetectLabelsFeatureName>> {
222        self.inner.get_features()
223    }
224    /// <p>A list of the filters to be applied to returned detected labels and image properties. Specified filters can be inclusive, exclusive, or a combination of both. Filters can be used for individual labels or label categories. The exact label names or label categories must be supplied. For a full list of labels and label categories, see <a href="https://docs.aws.amazon.com/rekognition/latest/dg/labels.html">Detecting labels</a>.</p>
225    pub fn settings(mut self, input: crate::types::DetectLabelsSettings) -> Self {
226        self.inner = self.inner.settings(input);
227        self
228    }
229    /// <p>A list of the filters to be applied to returned detected labels and image properties. Specified filters can be inclusive, exclusive, or a combination of both. Filters can be used for individual labels or label categories. The exact label names or label categories must be supplied. For a full list of labels and label categories, see <a href="https://docs.aws.amazon.com/rekognition/latest/dg/labels.html">Detecting labels</a>.</p>
230    pub fn set_settings(mut self, input: ::std::option::Option<crate::types::DetectLabelsSettings>) -> Self {
231        self.inner = self.inner.set_settings(input);
232        self
233    }
234    /// <p>A list of the filters to be applied to returned detected labels and image properties. Specified filters can be inclusive, exclusive, or a combination of both. Filters can be used for individual labels or label categories. The exact label names or label categories must be supplied. For a full list of labels and label categories, see <a href="https://docs.aws.amazon.com/rekognition/latest/dg/labels.html">Detecting labels</a>.</p>
235    pub fn get_settings(&self) -> &::std::option::Option<crate::types::DetectLabelsSettings> {
236        self.inner.get_settings()
237    }
238}