From 3ce457006f0f642e8ea48410bde9d9ed656af9ea Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Wed, 6 Sep 2023 22:17:53 -0700 Subject: [PATCH] Remove video and streaming mode for face stylizer. PiperOrigin-RevId: 563312344 --- .../cc/vision/face_stylizer/face_stylizer.cc | 46 --------------- .../cc/vision/face_stylizer/face_stylizer.h | 56 ------------------- 2 files changed, 102 deletions(-) diff --git a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.cc b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.cc index 024452c04..89ec8766b 100644 --- a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.cc +++ b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.cc @@ -150,52 +150,6 @@ absl::StatusOr> FaceStylizer::Stylize( output_packets[kStylizedImageName].Get()); } -absl::StatusOr> FaceStylizer::StylizeForVideo( - mediapipe::Image image, int64_t timestamp_ms, - std::optional image_processing_options) { - if (image.UsesGpu()) { - return CreateStatusWithPayload( - absl::StatusCode::kInvalidArgument, - absl::StrCat("GPU input images are currently not supported."), - MediaPipeTasksStatus::kRunnerUnexpectedInputError); - } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image)); - ASSIGN_OR_RETURN( - auto output_packets, - ProcessVideoData( - {{kImageInStreamName, - MakePacket(std::move(image)) - .At(Timestamp(timestamp_ms * kMicroSecondsPerMilliSecond))}, - {kNormRectName, - MakePacket(std::move(norm_rect)) - .At(Timestamp(timestamp_ms * kMicroSecondsPerMilliSecond))}})); - return output_packets[kStylizedImageName].IsEmpty() - ? std::nullopt - : std::optional( - output_packets[kStylizedImageName].Get()); -} - -absl::Status FaceStylizer::StylizeAsync( - Image image, int64_t timestamp_ms, - std::optional image_processing_options) { - if (image.UsesGpu()) { - return CreateStatusWithPayload( - absl::StatusCode::kInvalidArgument, - absl::StrCat("GPU input images are currently not supported."), - MediaPipeTasksStatus::kRunnerUnexpectedInputError); - } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image)); - return SendLiveStreamData( - {{kImageInStreamName, - MakePacket(std::move(image)) - .At(Timestamp(timestamp_ms * kMicroSecondsPerMilliSecond))}, - {kNormRectName, - MakePacket(std::move(norm_rect)) - .At(Timestamp(timestamp_ms * kMicroSecondsPerMilliSecond))}}); -} - } // namespace face_stylizer } // namespace vision } // namespace tasks diff --git a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.h b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.h index fd4695f6f..7342b291d 100644 --- a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.h +++ b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.h @@ -81,62 +81,6 @@ class FaceStylizer : tasks::vision::core::BaseVisionTaskApi { std::optional image_processing_options = std::nullopt); - // Performs face stylization on the provided video frame. - // - // The optional 'image_processing_options' parameter can be used to specify: - // - the rotation to apply to the image before performing stylization, by - // setting its 'rotation_degrees' field. - // and/or - // - the region-of-interest on which to perform stylization, by setting its - // 'region_of_interest' field. If not specified, the full image is used. - // If both are specified, the crop around the region-of-interest is extracted - // first, then the specified rotation is applied to the crop. - // - // Only use this method when the FaceStylizer is created with the video - // running mode. - // - // The image can be of any size with format RGB or RGBA. It's required to - // provide the video frame's timestamp (in milliseconds). The input timestamps - // must be monotonically increasing. - // When no face is detected on the input image, the method returns a - // std::nullopt. Otherwise, returns the stylized image of the most visible - // face. The stylized output image size is the same as the model output size. - absl::StatusOr> StylizeForVideo( - mediapipe::Image image, int64_t timestamp_ms, - std::optional image_processing_options = - std::nullopt); - - // Sends live image data to perform face stylization, and the results will - // be available via the "result_callback" provided in the - // FaceStylizerOptions. - // - // The optional 'image_processing_options' parameter can be used to specify: - // - the rotation to apply to the image before performing stylization, by - // setting its 'rotation_degrees' field. - // and/or - // - the region-of-interest on which to perform stylization, by setting its - // 'region_of_interest' field. If not specified, the full image is used. - // If both are specified, the crop around the region-of-interest is extracted - // first, then the specified rotation is applied to the crop. - // - // Only use this method when the FaceStylizer is created with the live stream - // running mode. - // - // The image can be of any size with format RGB or RGBA. It's required to - // provide a timestamp (in milliseconds) to indicate when the input image is - // sent to the face stylizer. The input timestamps must be monotonically - // increasing. - // - // The "result_callback" provides: - // - When no face is detected on the input image, the method returns a - // std::nullopt. Otherwise, returns the stylized image of the most visible - // face. The stylized output image size is the same as the model output - // size. - // - The input timestamp in milliseconds. - absl::Status StylizeAsync(mediapipe::Image image, int64_t timestamp_ms, - std::optional - image_processing_options = std::nullopt); - // Shuts down the FaceStylizer when all works are done. absl::Status Close() { return runner_->Close(); } };