Starts asynchronous detection of labels in a stored video.
Amazon Rekognition Video can detect labels in a video. Labels are instances of real-world entities. This includes objects like flower, tree, and table; events like wedding, graduation, and birthday party; concepts like landscape, evening, and nature; and activities like a person getting out of a car or a person skiing.
The video must be stored in an Amazon S3 bucket. Use Video to specify the bucket name and the filename of the video. StartLabelDetection returns a job identifier (JobId) which you use to get the results of the operation. When label detection is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in NotificationChannel.
To get the results of the label detection operation, first check that the status value published to the Amazon SNS topic is SUCCEEDED. If so, call GetLabelDetection and pass the job identifier (JobId) from the initial call to StartLabelDetection.
Optional Parameters
StartLabelDetection has the GENERAL_LABELS Feature applied by default. This feature allows you to 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 Detecting labels in a video.
You can specify MinConfidence to control the confidence threshold for the labels returned. The default is 50.
Parameters:
-
video
(Video)
–
The video in which you want to detect labels. The video must be stored in an Amazon S3 bucket.
-
client_request_token
(Optional[ClientRequestToken], default:
None
)
–
Idempotent token used to identify the start request. If you use the same token with multiple StartLabelDetection requests, the same JobId is returned. Use ClientRequestToken to prevent the same job from being accidently started more than once.
-
min_confidence
(Optional[Percent], default:
None
)
–
Specifies the minimum confidence that Amazon Rekognition Video must have in order to return a detected label. Confidence represents how certain Amazon Rekognition is that a label is correctly identified.0 is the lowest confidence. 100 is the highest confidence. Amazon Rekognition Video doesn't return any labels with a confidence level lower than this specified value.
If you don't specify MinConfidence, the operation returns labels and bounding boxes (if detected) with confidence values greater than or equal to 50 percent.
-
notification_channel
(Optional[NotificationChannel], default:
None
)
–
The Amazon SNS topic ARN you want Amazon Rekognition Video to publish the completion status of the label detection operation to. The Amazon SNS topic must have a topic name that begins with AmazonRekognition if you are using the AmazonRekognitionServiceRole permissions policy.
-
job_tag
(Optional[JobTag], default:
None
)
–
An identifier you specify that's returned in the completion notification that's published to your Amazon Simple Notification Service topic. For example, you can use JobTag to group related jobs and identify them in the completion notification.
-
features
(Optional[LabelDetectionFeatureList], default:
None
)
–
The features to return after video analysis. You can specify that GENERAL_LABELS are returned.
-
settings
(Optional[LabelDetectionSettings], default:
None
)
–
The settings for a StartLabelDetection request.Contains the specified parameters for the label detection request of an asynchronous label analysis operation. Settings can include filters for GENERAL_LABELS.
Raises:
-
AccessDeniedException
–
You are not authorized to perform the action.
-
IdempotentParameterMismatchException
–
A ClientRequestToken input parameter was reused with an operation, but at least one of the other input parameters is different from the previous call to the operation.
-
InternalServerError
–
Amazon Rekognition experienced a service issue. Try your call again.
-
InvalidParameterException
–
Input parameter violated a constraint. Validate your parameter before calling the API operation again.
-
InvalidS3ObjectException
–
Amazon Rekognition is unable to access the S3 object specified in the request.
-
LimitExceededException
–
An Amazon Rekognition service limit was exceeded. For example, if you start too many jobs concurrently, subsequent calls to start operations (ex: StartLabelDetection) will raise a LimitExceededException exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Rekognition service limit.
-
ProvisionedThroughputExceededException
–
The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.
-
ThrottlingException
–
Amazon Rekognition is temporarily unable to process the request. Try your call again.
-
VideoTooLargeException
–
The file size or duration of the supplied media is too large. The maximum file size is 10GB. The maximum duration is 6 hours.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_rekognition/_services/async_rekognition.py
| async def start_label_detection(
self,
video: "capo_rekognition.types.video.Video",
*,
config_overrides: Optional[AsyncRekognitionClientConfig] = None,
client_request_token: Optional[
"capo_rekognition.types.client_request_token.ClientRequestToken"
] = None,
min_confidence: Optional["capo_rekognition.types.percent.Percent"] = None,
notification_channel: Optional[
"capo_rekognition.types.notification_channel.NotificationChannel"
] = None,
job_tag: Optional["capo_rekognition.types.job_tag.JobTag"] = None,
features: Optional[
"capo_rekognition.types.label_detection_feature_list.LabelDetectionFeatureList"
] = None,
settings: Optional[
"capo_rekognition.types.label_detection_settings.LabelDetectionSettings"
] = None,
) -> "capo_rekognition.types.start_label_detection_response.StartLabelDetectionResponse":
"""<p>Starts asynchronous detection of labels in a stored video.</p> <p>Amazon Rekognition Video can detect labels in a video. Labels are instances of real-world entities. This includes objects like flower, tree, and table; events like wedding, graduation, and birthday party; concepts like landscape, evening, and nature; and activities like a person getting out of a car or a person skiing.</p> <p>The video must be stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartLabelDetection</code> returns a job identifier (<code>JobId</code>) which you use to get the results of the operation. When label detection is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>.</p> <p>To get the results of the label detection operation, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetLabelDetection</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartLabelDetection</code>.</p> <p> <i>Optional Parameters</i> </p> <p> <code>StartLabelDetection</code> has the <code>GENERAL_LABELS</code> Feature applied by default. This feature allows you to provide filtering criteria to the <code>Settings</code> 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-detecting-labels-video.html">Detecting labels in a video</a>.</p> <p>You can specify <code>MinConfidence</code> to control the confidence threshold for the labels returned. The default is 50.</p>
Args:
video: <p>The video in which you want to detect labels. The video must be stored in an Amazon S3 bucket.</p>
client_request_token: <p>Idempotent token used to identify the start request. If you use the same token with multiple <code>StartLabelDetection</code> requests, the same <code>JobId</code> is returned. Use <code>ClientRequestToken</code> to prevent the same job from being accidently started more than once. </p>
min_confidence: <p>Specifies the minimum confidence that Amazon Rekognition Video must have in order to return a detected label. Confidence represents how certain Amazon Rekognition is that a label is correctly identified.0 is the lowest confidence. 100 is the highest confidence. Amazon Rekognition Video doesn't return any labels with a confidence level lower than this specified value.</p> <p>If you don't specify <code>MinConfidence</code>, the operation returns labels and bounding boxes (if detected) with confidence values greater than or equal to 50 percent.</p>
notification_channel: <p>The Amazon SNS topic ARN you want Amazon Rekognition Video to publish the completion status of the label detection operation to. The Amazon SNS topic must have a topic name that begins with <i>AmazonRekognition</i> if you are using the AmazonRekognitionServiceRole permissions policy.</p>
job_tag: <p>An identifier you specify that's returned in the completion notification that's published to your Amazon Simple Notification Service topic. For example, you can use <code>JobTag</code> to group related jobs and identify them in the completion notification.</p>
features: <p>The features to return after video analysis. You can specify that GENERAL_LABELS are returned.</p>
settings: <p>The settings for a StartLabelDetection request.Contains the specified parameters for the label detection request of an asynchronous label analysis operation. Settings can include filters for GENERAL_LABELS.</p>
Raises:
capo_rekognition.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to perform the action.</p>
capo_rekognition.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>A <code>ClientRequestToken</code> input parameter was reused with an operation, but at least one of the other input parameters is different from the previous call to the operation.</p>
capo_rekognition.errors.internal_server_error.InternalServerError: <p>Amazon Rekognition experienced a service issue. Try your call again.</p>
capo_rekognition.errors.invalid_parameter_exception.InvalidParameterException: <p>Input parameter violated a constraint. Validate your parameter before calling the API operation again.</p>
capo_rekognition.errors.invalid_s3_object_exception.InvalidS3ObjectException: <p>Amazon Rekognition is unable to access the S3 object specified in the request.</p>
capo_rekognition.errors.limit_exceeded_exception.LimitExceededException: <p>An Amazon Rekognition service limit was exceeded. For example, if you start too many jobs concurrently, subsequent calls to start operations (ex: <code>StartLabelDetection</code>) will raise a <code>LimitExceededException</code> exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Rekognition service limit. </p>
capo_rekognition.errors.provisioned_throughput_exceeded_exception.ProvisionedThroughputExceededException: <p>The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.</p>
capo_rekognition.errors.throttling_exception.ThrottlingException: <p>Amazon Rekognition is temporarily unable to process the request. Try your call again.</p>
capo_rekognition.errors.video_too_large_exception.VideoTooLargeException: <p>The file size or duration of the supplied media is too large. The maximum file size is 10GB. The maximum duration is 6 hours. </p>
capo_rekognition.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_rekognition.types.start_label_detection_request.StartLabelDetectionRequest]",
) -> AsyncOperationResponse[
"capo_rekognition.types.start_label_detection_response.StartLabelDetectionResponse"
]:
import capo_rekognition._operations.rekognition_service.start_label_detection
(
output,
http_response,
) = await capo_rekognition._operations.rekognition_service.start_label_detection.async_start_label_detection(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("StartLabelDetection")
)
input_: capo_rekognition.types.start_label_detection_request.StartLabelDetectionRequest = {
"video": video
}
if client_request_token is not None:
input_["client_request_token"] = client_request_token
if min_confidence is not None:
input_["min_confidence"] = min_confidence
if notification_channel is not None:
input_["notification_channel"] = notification_channel
if job_tag is not None:
input_["job_tag"] = job_tag
if features is not None:
input_["features"] = features
if settings is not None:
input_["settings"] = settings
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|