diff --git a/mediapipe/calculators/core/bypass_calculator.cc b/mediapipe/calculators/core/bypass_calculator.cc index 4e007329b..3392d8f3c 100644 --- a/mediapipe/calculators/core/bypass_calculator.cc +++ b/mediapipe/calculators/core/bypass_calculator.cc @@ -92,7 +92,7 @@ class BypassCalculator : public Node { auto options = cc->Options(); RET_CHECK_EQ(options.pass_input_stream().size(), options.pass_output_stream().size()); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto pass_streams, GetPassMap(options, *cc->Inputs().TagMap(), *cc->Outputs().TagMap())); std::set pass_out; @@ -121,8 +121,9 @@ class BypassCalculator : public Node { // Saves the map of passthrough input and output stream ids. absl::Status Open(CalculatorContext* cc) override { auto options = cc->Options(); - ASSIGN_OR_RETURN(pass_streams_, GetPassMap(options, *cc->Inputs().TagMap(), - *cc->Outputs().TagMap())); + MP_ASSIGN_OR_RETURN( + pass_streams_, + GetPassMap(options, *cc->Inputs().TagMap(), *cc->Outputs().TagMap())); return absl::OkStatus(); } diff --git a/mediapipe/calculators/image/affine_transformation_runner_gl.cc b/mediapipe/calculators/image/affine_transformation_runner_gl.cc index 0fe2d2744..6d4a9a1a2 100644 --- a/mediapipe/calculators/image/affine_transformation_runner_gl.cc +++ b/mediapipe/calculators/image/affine_transformation_runner_gl.cc @@ -223,7 +223,7 @@ class GlTextureWarpAffineRunner absl::StrCat(mediapipe::kMediaPipeFragmentShaderPreamble, interpolation_def, kFragShader); - ASSIGN_OR_RETURN(program_, create_fn(vert_src, frag_src)); + MP_ASSIGN_OR_RETURN(program_, create_fn(vert_src, frag_src)); auto create_custom_zero_fn = [&]() -> absl::StatusOr { std::string custom_zero_border_mode_def = R"( @@ -236,10 +236,10 @@ class GlTextureWarpAffineRunner }; #if GL_CLAMP_TO_BORDER_MAY_BE_SUPPORTED if (!IsGlClampToBorderSupported(gl_helper_->GetGlContext())) { - ASSIGN_OR_RETURN(program_custom_zero_, create_custom_zero_fn()); + MP_ASSIGN_OR_RETURN(program_custom_zero_, create_custom_zero_fn()); } #else - ASSIGN_OR_RETURN(program_custom_zero_, create_custom_zero_fn()); + MP_ASSIGN_OR_RETURN(program_custom_zero_, create_custom_zero_fn()); #endif // GL_CLAMP_TO_BORDER_MAY_BE_SUPPORTED glGenFramebuffers(1, &framebuffer_); diff --git a/mediapipe/calculators/image/image_file_properties_calculator.cc b/mediapipe/calculators/image/image_file_properties_calculator.cc index 97478f9f8..db01400cd 100644 --- a/mediapipe/calculators/image/image_file_properties_calculator.cc +++ b/mediapipe/calculators/image/image_file_properties_calculator.cc @@ -92,11 +92,11 @@ absl::StatusOr GetImageFileProperites( properties.set_focal_length_mm(result.FocalLength); properties.set_focal_length_35mm(result.FocalLengthIn35mm); - ASSIGN_OR_RETURN(auto focal_length_pixels, - ComputeFocalLengthInPixels(properties.image_width(), - properties.image_height(), - properties.focal_length_35mm(), - properties.focal_length_mm())); + MP_ASSIGN_OR_RETURN(auto focal_length_pixels, + ComputeFocalLengthInPixels(properties.image_width(), + properties.image_height(), + properties.focal_length_35mm(), + properties.focal_length_mm())); properties.set_focal_length_pixels(focal_length_pixels); return properties; @@ -151,7 +151,7 @@ class ImageFilePropertiesCalculator : public CalculatorBase { if (cc->InputSidePackets().NumEntries() == 1) { const std::string& image_bytes = cc->InputSidePackets().Index(0).Get(); - ASSIGN_OR_RETURN(properties_, GetImageFileProperites(image_bytes)); + MP_ASSIGN_OR_RETURN(properties_, GetImageFileProperites(image_bytes)); read_properties_ = true; } @@ -169,7 +169,7 @@ class ImageFilePropertiesCalculator : public CalculatorBase { return absl::OkStatus(); } const std::string& image_bytes = cc->Inputs().Index(0).Get(); - ASSIGN_OR_RETURN(properties_, GetImageFileProperites(image_bytes)); + MP_ASSIGN_OR_RETURN(properties_, GetImageFileProperites(image_bytes)); read_properties_ = true; } if (read_properties_) { diff --git a/mediapipe/calculators/image/warp_affine_calculator.cc b/mediapipe/calculators/image/warp_affine_calculator.cc index dcc371036..1d19c661d 100644 --- a/mediapipe/calculators/image/warp_affine_calculator.cc +++ b/mediapipe/calculators/image/warp_affine_calculator.cc @@ -79,8 +79,8 @@ class WarpAffineRunnerHolder { } absl::StatusOr GetRunner() { if (!runner_) { - ASSIGN_OR_RETURN(runner_, - CreateAffineTransformationOpenCvRunner(interpolation_)); + MP_ASSIGN_OR_RETURN( + runner_, CreateAffineTransformationOpenCvRunner(interpolation_)); } return runner_.get(); } @@ -108,8 +108,9 @@ class WarpAffineRunnerHolder { } absl::StatusOr GetRunner() { if (!runner_) { - ASSIGN_OR_RETURN(runner_, CreateAffineTransformationGlRunner( - gl_helper_, gpu_origin_, interpolation_)); + MP_ASSIGN_OR_RETURN( + runner_, CreateAffineTransformationGlRunner(gl_helper_, gpu_origin_, + interpolation_)); } return runner_.get(); } @@ -151,24 +152,25 @@ class WarpAffineRunnerHolder { AffineTransformation::BorderMode border_mode) override { if (input.UsesGpu()) { #if !MEDIAPIPE_DISABLE_GPU - ASSIGN_OR_RETURN(auto* runner, gpu_holder_.GetRunner()); - ASSIGN_OR_RETURN(auto result, runner->Run(input.GetGpuBuffer(), matrix, - size, border_mode)); + MP_ASSIGN_OR_RETURN(auto* runner, gpu_holder_.GetRunner()); + MP_ASSIGN_OR_RETURN( + auto result, + runner->Run(input.GetGpuBuffer(), matrix, size, border_mode)); return mediapipe::Image(*result); #else return absl::UnavailableError("GPU support is disabled"); #endif // !MEDIAPIPE_DISABLE_GPU } #if !MEDIAPIPE_DISABLE_OPENCV - ASSIGN_OR_RETURN(auto* runner, cpu_holder_.GetRunner()); + MP_ASSIGN_OR_RETURN(auto* runner, cpu_holder_.GetRunner()); const auto& frame_ptr = input.GetImageFrameSharedPtr(); // Wrap image into image frame. const ImageFrame image_frame(frame_ptr->Format(), frame_ptr->Width(), frame_ptr->Height(), frame_ptr->WidthStep(), const_cast(frame_ptr->PixelData()), [](uint8_t* data){}); - ASSIGN_OR_RETURN(auto result, - runner->Run(image_frame, matrix, size, border_mode)); + MP_ASSIGN_OR_RETURN(auto result, + runner->Run(image_frame, matrix, size, border_mode)); return mediapipe::Image(std::make_shared(std::move(result))); #else return absl::UnavailableError("OpenCV support is disabled"); @@ -213,8 +215,8 @@ class WarpAffineCalculatorImpl : public mediapipe::api2::NodeImpl { AffineTransformation::Size output_size; output_size.width = out_width; output_size.height = out_height; - ASSIGN_OR_RETURN(auto* runner, holder_.GetRunner()); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(auto* runner, holder_.GetRunner()); + MP_ASSIGN_OR_RETURN( auto result, runner->Run( *InterfaceT::kInImage(cc), transform, output_size, diff --git a/mediapipe/calculators/tensor/audio_to_tensor_calculator.cc b/mediapipe/calculators/tensor/audio_to_tensor_calculator.cc index eaf593a69..c8d38a653 100644 --- a/mediapipe/calculators/tensor/audio_to_tensor_calculator.cc +++ b/mediapipe/calculators/tensor/audio_to_tensor_calculator.cc @@ -517,8 +517,8 @@ absl::Status AudioToTensorCalculator::OutputTensor(const Matrix& block, // The last two elements are Nyquist component. fft_output_matrix(fft_size_ - 2) = fft_output_[1]; // Nyquist real part fft_output_matrix(fft_size_ - 1) = 0.0f; // Nyquist imagery part - ASSIGN_OR_RETURN(output_tensor, ConvertToTensor(fft_output_matrix, - {2, fft_size_ / 2})); + MP_ASSIGN_OR_RETURN(output_tensor, ConvertToTensor(fft_output_matrix, + {2, fft_size_ / 2})); break; } case Options::WITH_DC_AND_NYQUIST: { @@ -529,7 +529,7 @@ absl::Status AudioToTensorCalculator::OutputTensor(const Matrix& block, // The last two elements are Nyquist component. fft_output_matrix(fft_size_) = fft_output_[1]; // Nyquist real part fft_output_matrix(fft_size_ + 1) = 0.0f; // Nyquist imagery part - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( output_tensor, ConvertToTensor(fft_output_matrix, {2, (fft_size_ + 2) / 2})); break; @@ -537,7 +537,7 @@ absl::Status AudioToTensorCalculator::OutputTensor(const Matrix& block, case Options::WITHOUT_DC_AND_NYQUIST: { Matrix fft_output_matrix = Eigen::Map(fft_output_.data() + 2, 1, fft_size_ - 2); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( output_tensor, ConvertToTensor(fft_output_matrix, {2, (fft_size_ - 2) / 2})); break; @@ -547,8 +547,8 @@ absl::Status AudioToTensorCalculator::OutputTensor(const Matrix& block, } } else { - ASSIGN_OR_RETURN(output_tensor, - ConvertToTensor(block, {num_channels_, num_samples_})); + MP_ASSIGN_OR_RETURN(output_tensor, + ConvertToTensor(block, {num_channels_, num_samples_})); } kTensorsOut(cc).Send(std::move(output_tensor), timestamp); return absl::OkStatus(); diff --git a/mediapipe/calculators/tensor/bert_preprocessor_calculator.cc b/mediapipe/calculators/tensor/bert_preprocessor_calculator.cc index 12db1493c..0633d6cb8 100644 --- a/mediapipe/calculators/tensor/bert_preprocessor_calculator.cc +++ b/mediapipe/calculators/tensor/bert_preprocessor_calculator.cc @@ -161,9 +161,9 @@ absl::Status BertPreprocessorCalculator::Open(CalculatorContext* cc) { &kMetadataExtractorSideIn(cc).Get(); const tflite::ProcessUnit* tokenizer_metadata = metadata_extractor->GetInputProcessUnit(kTokenizerProcessUnitIndex); - ASSIGN_OR_RETURN(tokenizer_, - tasks::text::tokenizers::CreateTokenizerFromProcessUnit( - tokenizer_metadata, metadata_extractor)); + MP_ASSIGN_OR_RETURN(tokenizer_, + tasks::text::tokenizers::CreateTokenizerFromProcessUnit( + tokenizer_metadata, metadata_extractor)); auto* input_tensors_metadata = metadata_extractor->GetInputTensorMetadata(); input_ids_tensor_index_ = FindTensorIndexByMetadataName( diff --git a/mediapipe/calculators/tensor/bert_preprocessor_calculator_test.cc b/mediapipe/calculators/tensor/bert_preprocessor_calculator_test.cc index 619b54c06..e209b164f 100644 --- a/mediapipe/calculators/tensor/bert_preprocessor_calculator_test.cc +++ b/mediapipe/calculators/tensor/bert_preprocessor_calculator_test.cc @@ -67,9 +67,10 @@ absl::StatusOr>> RunBertPreprocessorCalculator( tool::AddVectorSink("tensors", &graph_config, &output_packets); std::string model_buffer = tasks::core::LoadBinaryContent(model_path.data()); - ASSIGN_OR_RETURN(std::unique_ptr metadata_extractor, - ModelMetadataExtractor::CreateFromModelBuffer( - model_buffer.data(), model_buffer.size())); + MP_ASSIGN_OR_RETURN( + std::unique_ptr metadata_extractor, + ModelMetadataExtractor::CreateFromModelBuffer(model_buffer.data(), + model_buffer.size())); // Run the graph. CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize( diff --git a/mediapipe/calculators/tensor/image_to_tensor_calculator.cc b/mediapipe/calculators/tensor/image_to_tensor_calculator.cc index 26fb1d868..171b28eb4 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_calculator.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_calculator.cc @@ -192,18 +192,19 @@ class ImageToTensorCalculator : public Node { } #if MEDIAPIPE_DISABLE_GPU - ASSIGN_OR_RETURN(auto image, GetInputImage(kIn(cc))); + MP_ASSIGN_OR_RETURN(auto image, GetInputImage(kIn(cc))); #else const bool is_input_gpu = kInGpu(cc).IsConnected(); - ASSIGN_OR_RETURN(auto image, is_input_gpu ? GetInputImage(kInGpu(cc)) - : GetInputImage(kIn(cc))); + MP_ASSIGN_OR_RETURN(auto image, is_input_gpu ? GetInputImage(kInGpu(cc)) + : GetInputImage(kIn(cc))); #endif // MEDIAPIPE_DISABLE_GPU RotatedRect roi = GetRoi(image->width(), image->height(), norm_rect); const int tensor_width = params_.output_width.value_or(image->width()); const int tensor_height = params_.output_height.value_or(image->height()); - ASSIGN_OR_RETURN(auto padding, PadRoi(tensor_width, tensor_height, - options_.keep_aspect_ratio(), &roi)); + MP_ASSIGN_OR_RETURN(auto padding, + PadRoi(tensor_width, tensor_height, + options_.keep_aspect_ratio(), &roi)); if (kOutLetterboxPadding(cc).IsConnected()) { kOutLetterboxPadding(cc).Send(padding); } @@ -247,20 +248,20 @@ class ImageToTensorCalculator : public Node { if (!gpu_converter_) { #if !MEDIAPIPE_DISABLE_GPU #if MEDIAPIPE_METAL_ENABLED - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( gpu_converter_, CreateMetalConverter(cc, GetBorderMode(options_.border_mode()))); #elif MEDIAPIPE_OPENGL_ES_VERSION >= MEDIAPIPE_OPENGL_ES_31 - ASSIGN_OR_RETURN(gpu_converter_, - CreateImageToGlBufferTensorConverter( - cc, DoesGpuInputStartAtBottom(options_), - GetBorderMode(options_.border_mode()))); + MP_ASSIGN_OR_RETURN(gpu_converter_, + CreateImageToGlBufferTensorConverter( + cc, DoesGpuInputStartAtBottom(options_), + GetBorderMode(options_.border_mode()))); #else if (!gpu_converter_) { - ASSIGN_OR_RETURN(gpu_converter_, - CreateImageToGlTextureTensorConverter( - cc, DoesGpuInputStartAtBottom(options_), - GetBorderMode(options_.border_mode()))); + MP_ASSIGN_OR_RETURN(gpu_converter_, + CreateImageToGlTextureTensorConverter( + cc, DoesGpuInputStartAtBottom(options_), + GetBorderMode(options_.border_mode()))); } if (!gpu_converter_) { return absl::UnimplementedError( @@ -272,18 +273,20 @@ class ImageToTensorCalculator : public Node { } else { if (!cpu_converter_) { #if !MEDIAPIPE_DISABLE_OPENCV - ASSIGN_OR_RETURN(cpu_converter_, - CreateOpenCvConverter( - cc, GetBorderMode(options_.border_mode()), - GetOutputTensorType(/*uses_gpu=*/false, params_))); + MP_ASSIGN_OR_RETURN( + cpu_converter_, + CreateOpenCvConverter( + cc, GetBorderMode(options_.border_mode()), + GetOutputTensorType(/*uses_gpu=*/false, params_))); // TODO: FrameBuffer-based converter needs to call GetGpuBuffer() // to get access to a FrameBuffer view. Investigate if GetGpuBuffer() can be // made available even with MEDIAPIPE_DISABLE_GPU set. #elif MEDIAPIPE_ENABLE_HALIDE - ASSIGN_OR_RETURN(cpu_converter_, - CreateFrameBufferConverter( - cc, GetBorderMode(options_.border_mode()), - GetOutputTensorType(/*uses_gpu=*/false, params_))); + MP_ASSIGN_OR_RETURN( + cpu_converter_, + CreateFrameBufferConverter( + cc, GetBorderMode(options_.border_mode()), + GetOutputTensorType(/*uses_gpu=*/false, params_))); #else ABSL_LOG(FATAL) << "Cannot create image to tensor CPU converter since " "MEDIAPIPE_DISABLE_OPENCV is defined and " diff --git a/mediapipe/calculators/tensor/image_to_tensor_converter_frame_buffer.cc b/mediapipe/calculators/tensor/image_to_tensor_converter_frame_buffer.cc index 6f6f6f11c..c77575d96 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_converter_frame_buffer.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_converter_frame_buffer.cc @@ -175,9 +175,9 @@ absl::Status FrameBufferProcessor::CropRotateResize90Degrees( cropped_buffer_ = std::make_unique(cropped_buffer_size); cropped_buffer_size_ = cropped_buffer_size; } - ASSIGN_OR_RETURN(cropped, - frame_buffer::CreateFromRawBuffer( - cropped_buffer_.get(), cropped_dims, input->format())); + MP_ASSIGN_OR_RETURN( + cropped, frame_buffer::CreateFromRawBuffer( + cropped_buffer_.get(), cropped_dims, input->format())); } MP_RETURN_IF_ERROR( frame_buffer::Crop(*input, left, top, right, bottom, cropped.get())); @@ -194,9 +194,9 @@ absl::Status FrameBufferProcessor::CropRotateResize90Degrees( rotated_buffer_ = std::make_unique(rotated_buffer_size); rotated_buffer_size_ = rotated_buffer_size; } - ASSIGN_OR_RETURN(auto rotated, frame_buffer::CreateFromRawBuffer( - rotated_buffer_.get(), rotated_dims, - cropped->format())); + MP_ASSIGN_OR_RETURN(auto rotated, frame_buffer::CreateFromRawBuffer( + rotated_buffer_.get(), rotated_dims, + cropped->format())); } MP_RETURN_IF_ERROR( frame_buffer::Rotate(*cropped, rotation_degrees, rotated.get())); @@ -217,9 +217,10 @@ absl::Status FrameBufferProcessor::ConvertToFloatTensor( RET_CHECK(output_tensor.element_type() == Tensor::ElementType::kFloat32); constexpr float kInputImageRangeMin = 0.0f; constexpr float kInputImageRangeMax = 255.0f; - ASSIGN_OR_RETURN(auto transform, GetValueRangeTransformation( - kInputImageRangeMin, kInputImageRangeMax, - range_min, range_max)); + MP_ASSIGN_OR_RETURN( + auto transform, + GetValueRangeTransformation(kInputImageRangeMin, kInputImageRangeMax, + range_min, range_max)); return frame_buffer::ToFloatTensor(*input_frame, transform.scale, transform.offset, output_tensor); } diff --git a/mediapipe/calculators/tensor/image_to_tensor_converter_gl_buffer.cc b/mediapipe/calculators/tensor/image_to_tensor_converter_gl_buffer.cc index eb1726aac..b32b67869 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_converter_gl_buffer.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_converter_gl_buffer.cc @@ -255,7 +255,7 @@ class GlProcessor : public ImageToTensorConverter { << "OpenGL ES 3.1 is required."; command_queue_ = tflite::gpu::gl::NewCommandQueue(gpu_info); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto extractor, SubRectExtractorGl::Create(gl_helper_.GetGlContext(), input_starts_at_bottom, border_mode)); @@ -293,10 +293,10 @@ class GlProcessor : public ImageToTensorConverter { constexpr float kInputImageRangeMin = 0.0f; constexpr float kInputImageRangeMax = 1.0f; - ASSIGN_OR_RETURN(auto transform, - GetValueRangeTransformation(kInputImageRangeMin, - kInputImageRangeMax, - range_min, range_max)); + MP_ASSIGN_OR_RETURN(auto transform, + GetValueRangeTransformation( + kInputImageRangeMin, kInputImageRangeMax, + range_min, range_max)); const int output_size = output_tensor.bytes() / output_shape.dims[0]; auto buffer_view = output_tensor.GetOpenGlBufferWriteView(); diff --git a/mediapipe/calculators/tensor/image_to_tensor_converter_gl_texture.cc b/mediapipe/calculators/tensor/image_to_tensor_converter_gl_texture.cc index 5604aea8f..2522cae85 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_converter_gl_texture.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_converter_gl_texture.cc @@ -193,10 +193,10 @@ class GlProcessor : public ImageToTensorConverter { constexpr float kInputImageRangeMin = 0.0f; constexpr float kInputImageRangeMax = 1.0f; - ASSIGN_OR_RETURN(auto transform, - GetValueRangeTransformation(kInputImageRangeMin, - kInputImageRangeMax, - range_min, range_max)); + MP_ASSIGN_OR_RETURN(auto transform, + GetValueRangeTransformation( + kInputImageRangeMin, kInputImageRangeMax, + range_min, range_max)); auto tensor_view = output_tensor.GetOpenGlTexture2dWriteView(); MP_RETURN_IF_ERROR(ExtractSubRect(input_texture, roi, /*flip_horizontaly=*/false, diff --git a/mediapipe/calculators/tensor/image_to_tensor_converter_metal.cc b/mediapipe/calculators/tensor/image_to_tensor_converter_metal.cc index 354547042..cef2abcd7 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_converter_metal.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_converter_metal.cc @@ -345,9 +345,9 @@ class MetalProcessor : public ImageToTensorConverter { absl::Status Init(CalculatorContext* cc, BorderMode border_mode) { metal_helper_ = [[MPPMetalHelper alloc] initWithCalculatorContext:cc]; RET_CHECK(metal_helper_); - ASSIGN_OR_RETURN(extractor_, SubRectExtractorMetal::Make( - metal_helper_.mtlDevice, - OutputFormat::kF32C4, border_mode)); + MP_ASSIGN_OR_RETURN(extractor_, SubRectExtractorMetal::Make( + metal_helper_.mtlDevice, + OutputFormat::kF32C4, border_mode)); return absl::OkStatus(); } @@ -373,7 +373,7 @@ class MetalProcessor : public ImageToTensorConverter { constexpr float kInputImageRangeMin = 0.0f; constexpr float kInputImageRangeMax = 1.0f; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto transform, GetValueRangeTransformation(kInputImageRangeMin, kInputImageRangeMax, range_min, range_max)); diff --git a/mediapipe/calculators/tensor/image_to_tensor_converter_opencv.cc b/mediapipe/calculators/tensor/image_to_tensor_converter_opencv.cc index bb4c6de79..75a29c2e6 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_converter_opencv.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_converter_opencv.cc @@ -159,7 +159,7 @@ class OpenCvProcessor : public ImageToTensorConverter { constexpr float kInputImageRangeMin = 0.0f; constexpr float kInputImageRangeMax = 255.0f; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto transform, GetValueRangeTransformation(kInputImageRangeMin, kInputImageRangeMax, range_min, range_max)); diff --git a/mediapipe/calculators/tensor/inference_calculator_cpu.cc b/mediapipe/calculators/tensor/inference_calculator_cpu.cc index 0c22fc7a1..64f67e41c 100644 --- a/mediapipe/calculators/tensor/inference_calculator_cpu.cc +++ b/mediapipe/calculators/tensor/inference_calculator_cpu.cc @@ -60,7 +60,7 @@ absl::Status InferenceCalculatorCpuImpl::UpdateContract( } absl::Status InferenceCalculatorCpuImpl::Open(CalculatorContext* cc) { - ASSIGN_OR_RETURN(inference_runner_, CreateInferenceRunner(cc)); + MP_ASSIGN_OR_RETURN(inference_runner_, CreateInferenceRunner(cc)); return absl::OkStatus(); } @@ -71,8 +71,8 @@ absl::Status InferenceCalculatorCpuImpl::Process(CalculatorContext* cc) { const auto& input_tensors = *kInTensors(cc); RET_CHECK(!input_tensors.empty()); - ASSIGN_OR_RETURN(std::vector output_tensors, - inference_runner_->Run(cc, input_tensors)); + MP_ASSIGN_OR_RETURN(std::vector output_tensors, + inference_runner_->Run(cc, input_tensors)); kOutTensors(cc).Send(std::move(output_tensors)); return absl::OkStatus(); } @@ -84,11 +84,11 @@ absl::Status InferenceCalculatorCpuImpl::Close(CalculatorContext* cc) { absl::StatusOr> InferenceCalculatorCpuImpl::CreateInferenceRunner(CalculatorContext* cc) { - ASSIGN_OR_RETURN(auto model_packet, GetModelAsPacket(cc)); - ASSIGN_OR_RETURN(auto op_resolver_packet, GetOpResolverAsPacket(cc)); + MP_ASSIGN_OR_RETURN(auto model_packet, GetModelAsPacket(cc)); + MP_ASSIGN_OR_RETURN(auto op_resolver_packet, GetOpResolverAsPacket(cc)); const int interpreter_num_threads = cc->Options().cpu_num_thread(); - ASSIGN_OR_RETURN(TfLiteDelegatePtr delegate, MaybeCreateDelegate(cc)); + MP_ASSIGN_OR_RETURN(TfLiteDelegatePtr delegate, MaybeCreateDelegate(cc)); return CreateInferenceInterpreterDelegateRunner( std::move(model_packet), std::move(op_resolver_packet), std::move(delegate), interpreter_num_threads); diff --git a/mediapipe/calculators/tensor/inference_calculator_gl.cc b/mediapipe/calculators/tensor/inference_calculator_gl.cc index 27b8bc23a..9ae16e2a2 100644 --- a/mediapipe/calculators/tensor/inference_calculator_gl.cc +++ b/mediapipe/calculators/tensor/inference_calculator_gl.cc @@ -100,7 +100,7 @@ absl::Status InferenceCalculatorGlImpl::GpuInferenceRunner::Init( absl::Status InferenceCalculatorGlImpl::GpuInferenceRunner::LoadModel( CalculatorContext* cc) { - ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(cc)); + MP_ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(cc)); const auto& model = *model_packet_.Get(); if (kSideInOpResolver(cc).IsConnected()) { const tflite::OpResolver& op_resolver = kSideInOpResolver(cc).Get(); diff --git a/mediapipe/calculators/tensor/inference_calculator_gl_advanced.cc b/mediapipe/calculators/tensor/inference_calculator_gl_advanced.cc index 28ea45de0..f22def239 100644 --- a/mediapipe/calculators/tensor/inference_calculator_gl_advanced.cc +++ b/mediapipe/calculators/tensor/inference_calculator_gl_advanced.cc @@ -170,7 +170,7 @@ absl::Status InferenceCalculatorGlAdvancedImpl::GpuInferenceRunner::InitTFLiteGPURunner( CalculatorContext* cc, const mediapipe::InferenceCalculatorOptions::Delegate& delegate) { - ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(cc)); + MP_ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(cc)); const auto& model = *model_packet_.Get(); bool allow_precision_loss = delegate.gpu().allow_precision_loss(); @@ -306,16 +306,16 @@ InferenceCalculatorGlAdvancedImpl::OnDiskCacheHelper::SaveGpuCaches( tflite::gpu::TFLiteGPURunner* gpu_runner) const { if (use_kernel_caching_) { // Save kernel file. - ASSIGN_OR_RETURN(std::vector kernel_cache, - gpu_runner->GetSerializedBinaryCache()); + MP_ASSIGN_OR_RETURN(std::vector kernel_cache, + gpu_runner->GetSerializedBinaryCache()); std::string cache_str(kernel_cache.begin(), kernel_cache.end()); MP_RETURN_IF_ERROR( mediapipe::file::SetContents(cached_kernel_filename_, cache_str)); } if (use_serialized_model_) { // Save serialized model file. - ASSIGN_OR_RETURN(std::vector serialized_model_vec, - gpu_runner->GetSerializedModel()); + MP_ASSIGN_OR_RETURN(std::vector serialized_model_vec, + gpu_runner->GetSerializedModel()); absl::string_view serialized_model( reinterpret_cast(serialized_model_vec.data()), serialized_model_vec.size()); @@ -412,8 +412,8 @@ absl::Status InferenceCalculatorGlAdvancedImpl::Process(CalculatorContext* cc) { RET_CHECK(!input_tensors.empty()); auto output_tensors = absl::make_unique>(); - ASSIGN_OR_RETURN(*output_tensors, - gpu_inference_runner_->Process(cc, input_tensors)); + MP_ASSIGN_OR_RETURN(*output_tensors, + gpu_inference_runner_->Process(cc, input_tensors)); kOutTensors(cc).Send(std::move(output_tensors)); return absl::OkStatus(); diff --git a/mediapipe/calculators/tensor/inference_calculator_metal.cc b/mediapipe/calculators/tensor/inference_calculator_metal.cc index 253091a8a..e3451b423 100644 --- a/mediapipe/calculators/tensor/inference_calculator_metal.cc +++ b/mediapipe/calculators/tensor/inference_calculator_metal.cc @@ -208,9 +208,9 @@ absl::Status InferenceCalculatorMetalImpl::Close(CalculatorContext* cc) { absl::Status InferenceCalculatorMetalImpl::InitInterpreter( CalculatorContext* cc) { - ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(cc)); + MP_ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(cc)); const auto& model = *model_packet_.Get(); - ASSIGN_OR_RETURN(auto op_resolver_packet, GetOpResolverAsPacket(cc)); + MP_ASSIGN_OR_RETURN(auto op_resolver_packet, GetOpResolverAsPacket(cc)); const auto& op_resolver = op_resolver_packet.Get(); tflite::InterpreterBuilder interpreter_builder(model, op_resolver); AddDelegate(cc, &interpreter_builder); diff --git a/mediapipe/calculators/tensor/inference_calculator_xnnpack.cc b/mediapipe/calculators/tensor/inference_calculator_xnnpack.cc index a9417d508..59ec726d6 100644 --- a/mediapipe/calculators/tensor/inference_calculator_xnnpack.cc +++ b/mediapipe/calculators/tensor/inference_calculator_xnnpack.cc @@ -58,7 +58,7 @@ absl::Status InferenceCalculatorXnnpackImpl::UpdateContract( } absl::Status InferenceCalculatorXnnpackImpl::Open(CalculatorContext* cc) { - ASSIGN_OR_RETURN(inference_runner_, CreateInferenceRunner(cc)); + MP_ASSIGN_OR_RETURN(inference_runner_, CreateInferenceRunner(cc)); return absl::OkStatus(); } @@ -69,8 +69,8 @@ absl::Status InferenceCalculatorXnnpackImpl::Process(CalculatorContext* cc) { const auto& input_tensors = *kInTensors(cc); RET_CHECK(!input_tensors.empty()); - ASSIGN_OR_RETURN(std::vector output_tensors, - inference_runner_->Run(cc, input_tensors)); + MP_ASSIGN_OR_RETURN(std::vector output_tensors, + inference_runner_->Run(cc, input_tensors)); kOutTensors(cc).Send(std::move(output_tensors)); return absl::OkStatus(); } @@ -82,11 +82,11 @@ absl::Status InferenceCalculatorXnnpackImpl::Close(CalculatorContext* cc) { absl::StatusOr> InferenceCalculatorXnnpackImpl::CreateInferenceRunner(CalculatorContext* cc) { - ASSIGN_OR_RETURN(auto model_packet, GetModelAsPacket(cc)); - ASSIGN_OR_RETURN(auto op_resolver_packet, GetOpResolverAsPacket(cc)); + MP_ASSIGN_OR_RETURN(auto model_packet, GetModelAsPacket(cc)); + MP_ASSIGN_OR_RETURN(auto op_resolver_packet, GetOpResolverAsPacket(cc)); const int interpreter_num_threads = cc->Options().cpu_num_thread(); - ASSIGN_OR_RETURN(TfLiteDelegatePtr delegate, CreateDelegate(cc)); + MP_ASSIGN_OR_RETURN(TfLiteDelegatePtr delegate, CreateDelegate(cc)); return CreateInferenceInterpreterDelegateRunner( std::move(model_packet), std::move(op_resolver_packet), std::move(delegate), interpreter_num_threads); diff --git a/mediapipe/calculators/tensor/regex_preprocessor_calculator.cc b/mediapipe/calculators/tensor/regex_preprocessor_calculator.cc index 8276462ff..723c3a45a 100644 --- a/mediapipe/calculators/tensor/regex_preprocessor_calculator.cc +++ b/mediapipe/calculators/tensor/regex_preprocessor_calculator.cc @@ -106,7 +106,7 @@ absl::Status RegexPreprocessorCalculator::Open(CalculatorContext* cc) { return absl::InvalidArgumentError("No tensor metadata found"); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* tokenizer_metadata, metadata_extractor->FindFirstProcessUnit( *tensor_metadata, tflite::ProcessUnitOptions_RegexTokenizerOptions)); @@ -115,9 +115,9 @@ absl::Status RegexPreprocessorCalculator::Open(CalculatorContext* cc) { } const tflite::RegexTokenizerOptions* regex_tokenizer_options = tokenizer_metadata->options_as(); - ASSIGN_OR_RETURN(tokenizer_, - tasks::text::tokenizers::CreateRegexTokenizerFromOptions( - regex_tokenizer_options, metadata_extractor)); + MP_ASSIGN_OR_RETURN(tokenizer_, + tasks::text::tokenizers::CreateRegexTokenizerFromOptions( + regex_tokenizer_options, metadata_extractor)); const auto& options = cc->Options(); diff --git a/mediapipe/calculators/tensor/regex_preprocessor_calculator_test.cc b/mediapipe/calculators/tensor/regex_preprocessor_calculator_test.cc index ef14ef035..415291b83 100644 --- a/mediapipe/calculators/tensor/regex_preprocessor_calculator_test.cc +++ b/mediapipe/calculators/tensor/regex_preprocessor_calculator_test.cc @@ -67,9 +67,10 @@ absl::StatusOr> RunRegexPreprocessorCalculator( tool::AddVectorSink("tensors", &graph_config, &output_packets); std::string model_buffer = tasks::core::LoadBinaryContent(kTestModelPath); - ASSIGN_OR_RETURN(std::unique_ptr metadata_extractor, - ModelMetadataExtractor::CreateFromModelBuffer( - model_buffer.data(), model_buffer.size())); + MP_ASSIGN_OR_RETURN( + std::unique_ptr metadata_extractor, + ModelMetadataExtractor::CreateFromModelBuffer(model_buffer.data(), + model_buffer.size())); // Run the graph. CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize( diff --git a/mediapipe/calculators/tensor/tensor_converter_calculator.cc b/mediapipe/calculators/tensor/tensor_converter_calculator.cc index e86436589..b42cb0b17 100644 --- a/mediapipe/calculators/tensor/tensor_converter_calculator.cc +++ b/mediapipe/calculators/tensor/tensor_converter_calculator.cc @@ -656,7 +656,7 @@ absl::Status TensorConverterCalculator::LoadOptions(CalculatorContext* cc, } // Get y-flip mode. - ASSIGN_OR_RETURN(flip_vertically_, ShouldFlipVertically(options, use_gpu)); + MP_ASSIGN_OR_RETURN(flip_vertically_, ShouldFlipVertically(options, use_gpu)); // Get row_major_matrix mode. row_major_matrix_ = options.row_major_matrix(); diff --git a/mediapipe/calculators/tensor/tensors_to_classification_calculator.cc b/mediapipe/calculators/tensor/tensors_to_classification_calculator.cc index 7041c02e4..dc1f1017c 100644 --- a/mediapipe/calculators/tensor/tensors_to_classification_calculator.cc +++ b/mediapipe/calculators/tensor/tensors_to_classification_calculator.cc @@ -110,8 +110,8 @@ absl::Status TensorsToClassificationCalculator::Open(CalculatorContext* cc) { sort_by_descending_score_ = options.sort_by_descending_score(); if (options.has_label_map_path()) { std::string string_path; - ASSIGN_OR_RETURN(string_path, - PathToResourceAsFile(options.label_map_path())); + MP_ASSIGN_OR_RETURN(string_path, + PathToResourceAsFile(options.label_map_path())); std::string label_map_string; MP_RETURN_IF_ERROR( mediapipe::GetResourceContents(string_path, &label_map_string)); diff --git a/mediapipe/calculators/tensor/tensors_to_segmentation_calculator.cc b/mediapipe/calculators/tensor/tensors_to_segmentation_calculator.cc index bfe126097..6b77acee4 100644 --- a/mediapipe/calculators/tensor/tensors_to_segmentation_calculator.cc +++ b/mediapipe/calculators/tensor/tensors_to_segmentation_calculator.cc @@ -267,7 +267,8 @@ absl::Status TensorsToSegmentationCalculator::Process(CalculatorContext* cc) { { RET_CHECK(!input_tensors.empty()); RET_CHECK(input_tensors[0].element_type() == Tensor::ElementType::kFloat32); - ASSIGN_OR_RETURN(auto hwc, GetHwcFromDims(input_tensors[0].shape().dims)); + MP_ASSIGN_OR_RETURN(auto hwc, + GetHwcFromDims(input_tensors[0].shape().dims)); int tensor_channels = std::get<2>(hwc); typedef mediapipe::TensorsToSegmentationCalculatorOptions Options; switch (options_.activation()) { @@ -330,7 +331,7 @@ absl::Status TensorsToSegmentationCalculator::ProcessCpu( // Get input streams, and dimensions. const auto& input_tensors = cc->Inputs().Tag(kTensorsTag).Get>(); - ASSIGN_OR_RETURN(auto hwc, GetHwcFromDims(input_tensors[0].shape().dims)); + MP_ASSIGN_OR_RETURN(auto hwc, GetHwcFromDims(input_tensors[0].shape().dims)); auto [tensor_height, tensor_width, tensor_channels] = hwc; int output_width = tensor_width, output_height = tensor_height; if (cc->Inputs().HasTag(kOutputSizeTag)) { @@ -441,7 +442,7 @@ absl::Status TensorsToSegmentationCalculator::ProcessGpu( // Get input streams, and dimensions. const auto& input_tensors = cc->Inputs().Tag(kTensorsTag).Get>(); - ASSIGN_OR_RETURN(auto hwc, GetHwcFromDims(input_tensors[0].shape().dims)); + MP_ASSIGN_OR_RETURN(auto hwc, GetHwcFromDims(input_tensors[0].shape().dims)); auto [tensor_height, tensor_width, tensor_channels] = hwc; int output_width = tensor_width, output_height = tensor_height; if (cc->Inputs().HasTag(kOutputSizeTag)) { diff --git a/mediapipe/calculators/tensor/universal_sentence_encoder_preprocessor_calculator_test.cc b/mediapipe/calculators/tensor/universal_sentence_encoder_preprocessor_calculator_test.cc index 0f4744c90..fed47767a 100644 --- a/mediapipe/calculators/tensor/universal_sentence_encoder_preprocessor_calculator_test.cc +++ b/mediapipe/calculators/tensor/universal_sentence_encoder_preprocessor_calculator_test.cc @@ -61,9 +61,10 @@ RunUniversalSentenceEncoderPreprocessorCalculator(absl::string_view text) { std::string model_buffer = tasks::core::LoadBinaryContent(kTestModelPath.data()); - ASSIGN_OR_RETURN(std::unique_ptr metadata_extractor, - ModelMetadataExtractor::CreateFromModelBuffer( - model_buffer.data(), model_buffer.size())); + MP_ASSIGN_OR_RETURN( + std::unique_ptr metadata_extractor, + ModelMetadataExtractor::CreateFromModelBuffer(model_buffer.data(), + model_buffer.size())); // Run the graph. CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize( diff --git a/mediapipe/calculators/tensorflow/object_detection_tensors_to_detections_calculator.cc b/mediapipe/calculators/tensorflow/object_detection_tensors_to_detections_calculator.cc index f85c7bbb0..95a00a124 100644 --- a/mediapipe/calculators/tensorflow/object_detection_tensors_to_detections_calculator.cc +++ b/mediapipe/calculators/tensorflow/object_detection_tensors_to_detections_calculator.cc @@ -151,7 +151,7 @@ class ObjectDetectionTensorsToDetectionsCalculator : public CalculatorBase { tf::Tensor input_num_detections_tensor = tf::Tensor(tf::DT_FLOAT, tf::TensorShape({0})); if (cc->Inputs().HasTag(kClasses)) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( input_num_detections_tensor, MaybeSqueezeDims(kNumDetections, cc->Inputs().Tag(kNumDetections).Get())); @@ -160,12 +160,12 @@ class ObjectDetectionTensorsToDetectionsCalculator : public CalculatorBase { RET_CHECK_EQ(input_num_detections_tensor.dtype(), tf::DT_FLOAT); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto input_boxes_tensor, MaybeSqueezeDims(kBoxes, cc->Inputs().Tag(kBoxes).Get())); RET_CHECK_EQ(input_boxes_tensor.dtype(), tf::DT_FLOAT); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto input_scores_tensor, MaybeSqueezeDims(kScores, cc->Inputs().Tag(kScores).Get())); RET_CHECK_EQ(input_scores_tensor.dtype(), tf::DT_FLOAT); @@ -173,7 +173,7 @@ class ObjectDetectionTensorsToDetectionsCalculator : public CalculatorBase { tf::Tensor input_classes_tensor = tf::Tensor(tf::DT_FLOAT, tf::TensorShape({0})); if (cc->Inputs().HasTag(kClasses)) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( input_classes_tensor, MaybeSqueezeDims(kClasses, cc->Inputs().Tag(kClasses).Get())); diff --git a/mediapipe/calculators/tflite/tflite_inference_calculator.cc b/mediapipe/calculators/tflite/tflite_inference_calculator.cc index d875b6940..18066b719 100644 --- a/mediapipe/calculators/tflite/tflite_inference_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_inference_calculator.cc @@ -489,8 +489,8 @@ absl::Status TfLiteInferenceCalculator::WriteKernelsToFile() { #if MEDIAPIPE_TFLITE_GL_INFERENCE && defined(MEDIAPIPE_ANDROID) if (use_kernel_caching_) { // Save kernel file. - ASSIGN_OR_RETURN(std::vector kernel_cache, - tflite_gpu_runner_->GetSerializedBinaryCache()); + MP_ASSIGN_OR_RETURN(std::vector kernel_cache, + tflite_gpu_runner_->GetSerializedBinaryCache()); std::string cache_str(kernel_cache.begin(), kernel_cache.end()); MP_RETURN_IF_ERROR( mediapipe::file::SetContents(cached_kernel_filename_, cache_str)); @@ -733,7 +733,7 @@ absl::Status TfLiteInferenceCalculator::ReadKernelsFromFile() { absl::Status TfLiteInferenceCalculator::InitTFLiteGPURunner( CalculatorContext* cc) { #if MEDIAPIPE_TFLITE_GL_INFERENCE - ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(*cc)); + MP_ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(*cc)); const auto& model = *model_packet_.Get(); tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates @@ -817,8 +817,8 @@ absl::Status TfLiteInferenceCalculator::InitTFLiteGPURunner( gpu_data_out_.resize(tflite_gpu_runner_->outputs_size()); for (int i = 0; i < tflite_gpu_runner_->outputs_size(); ++i) { gpu_data_out_[i] = absl::make_unique(); - ASSIGN_OR_RETURN(gpu_data_out_[i]->elements, - tflite_gpu_runner_->GetOutputElements(i)); + MP_ASSIGN_OR_RETURN(gpu_data_out_[i]->elements, + tflite_gpu_runner_->GetOutputElements(i)); // Create and bind input buffer. MP_RETURN_IF_ERROR( ::tflite::gpu::gl::CreateReadWriteShaderStorageBuffer( @@ -839,7 +839,7 @@ absl::Status TfLiteInferenceCalculator::LoadModel(CalculatorContext* cc) { return absl::OkStatus(); } - ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(*cc)); + MP_ASSIGN_OR_RETURN(model_packet_, GetModelAsPacket(*cc)); const auto& model = *model_packet_.Get(); tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates diff --git a/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.cc b/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.cc index 98ab4b1da..3307e76cb 100644 --- a/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.cc @@ -101,8 +101,8 @@ absl::Status TfLiteTensorsToClassificationCalculator::Open( top_k_ = options_.top_k(); if (options_.has_label_map_path()) { std::string string_path; - ASSIGN_OR_RETURN(string_path, - PathToResourceAsFile(options_.label_map_path())); + MP_ASSIGN_OR_RETURN(string_path, + PathToResourceAsFile(options_.label_map_path())); std::string label_map_string; MP_RETURN_IF_ERROR(file::GetContents(string_path, &label_map_string)); diff --git a/mediapipe/calculators/util/association_calculator.h b/mediapipe/calculators/util/association_calculator.h index 1cec63c80..ed939b9db 100644 --- a/mediapipe/calculators/util/association_calculator.h +++ b/mediapipe/calculators/util/association_calculator.h @@ -171,13 +171,13 @@ class AssociationCalculator : public CalculatorBase { // Compare this element with elements of the input collection. If this // element has high overlap with elements of the collection, remove // those elements from the collection and add this element. - ASSIGN_OR_RETURN(auto cur_rect, GetRectangle(element)); + MP_ASSIGN_OR_RETURN(auto cur_rect, GetRectangle(element)); bool change_id = false; int new_elem_id = -1; for (auto uit = current->begin(); uit != current->end();) { - ASSIGN_OR_RETURN(auto prev_rect, GetRectangle(*uit)); + MP_ASSIGN_OR_RETURN(auto prev_rect, GetRectangle(*uit)); if (CalculateIou(cur_rect, prev_rect) > options_.min_similarity_threshold()) { std::pair prev_id = GetId(*uit); diff --git a/mediapipe/calculators/util/detection_label_id_to_text_calculator.cc b/mediapipe/calculators/util/detection_label_id_to_text_calculator.cc index 44b7a210f..2a11b58d9 100644 --- a/mediapipe/calculators/util/detection_label_id_to_text_calculator.cc +++ b/mediapipe/calculators/util/detection_label_id_to_text_calculator.cc @@ -83,8 +83,8 @@ absl::Status DetectionLabelIdToTextCalculator::Open(CalculatorContext* cc) { << "Only can set one of the following fields in the CalculatorOptions: " "label_map_path, label, and label_items."; std::string string_path; - ASSIGN_OR_RETURN(string_path, - PathToResourceAsFile(options.label_map_path())); + MP_ASSIGN_OR_RETURN(string_path, + PathToResourceAsFile(options.label_map_path())); std::string label_map_string; MP_RETURN_IF_ERROR( mediapipe::GetResourceContents(string_path, &label_map_string)); diff --git a/mediapipe/calculators/util/detection_transformation_calculator.cc b/mediapipe/calculators/util/detection_transformation_calculator.cc index 3eac315f7..6fa031e6c 100644 --- a/mediapipe/calculators/util/detection_transformation_calculator.cc +++ b/mediapipe/calculators/util/detection_transformation_calculator.cc @@ -96,10 +96,10 @@ absl::StatusOr GetLocationDataFormat( std::vector& detections) { RET_CHECK(!detections.empty()); LocationData::Format output_format; - ASSIGN_OR_RETURN(output_format, GetLocationDataFormat(detections[0])); + MP_ASSIGN_OR_RETURN(output_format, GetLocationDataFormat(detections[0])); for (int i = 1; i < detections.size(); ++i) { - ASSIGN_OR_RETURN(LocationData::Format format, - GetLocationDataFormat(detections[i])); + MP_ASSIGN_OR_RETURN(LocationData::Format format, + GetLocationDataFormat(detections[i])); if (output_format != format) { return absl::InvalidArgumentError( "Input detections have different location data formats."); @@ -243,8 +243,8 @@ class DetectionTransformationCalculator : public Node { OutputEmptyDetections(cc); return absl::OkStatus(); } - ASSIGN_OR_RETURN(input_location_data_format, - GetLocationDataFormat(transformed_detections)); + MP_ASSIGN_OR_RETURN(input_location_data_format, + GetLocationDataFormat(transformed_detections)); for (Detection& detection : transformed_detections) { MP_RETURN_IF_ERROR(ConvertBoundingBox(image_size, &detection)); } @@ -254,8 +254,8 @@ class DetectionTransformationCalculator : public Node { OutputEmptyDetections(cc); return absl::OkStatus(); } - ASSIGN_OR_RETURN(input_location_data_format, - GetLocationDataFormat(kInDetection(cc).Get())); + MP_ASSIGN_OR_RETURN(input_location_data_format, + GetLocationDataFormat(kInDetection(cc).Get())); MP_RETURN_IF_ERROR( ConvertBoundingBox(image_size, &transformed_detection)); transformed_detections.push_back(transformed_detection); diff --git a/mediapipe/calculators/util/landmarks_refinement_calculator.cc b/mediapipe/calculators/util/landmarks_refinement_calculator.cc index 87394c6c5..7d50e18b6 100644 --- a/mediapipe/calculators/util/landmarks_refinement_calculator.cc +++ b/mediapipe/calculators/util/landmarks_refinement_calculator.cc @@ -137,8 +137,8 @@ class LandmarksRefinementCalculatorImpl } // Validate indexes mapping and get total number of refined landmarks. - ASSIGN_OR_RETURN(n_refined_landmarks_, - GetNumberOfRefinedLandmarks(options_.refinement())); + MP_ASSIGN_OR_RETURN(n_refined_landmarks_, + GetNumberOfRefinedLandmarks(options_.refinement())); // Validate that number of refinements and landmark streams is the same. RET_CHECK_EQ(kLandmarks(cc).Count(), options_.refinement_size()) diff --git a/mediapipe/calculators/util/landmarks_smoothing_calculator.cc b/mediapipe/calculators/util/landmarks_smoothing_calculator.cc index bc7504485..0bbee7c4c 100644 --- a/mediapipe/calculators/util/landmarks_smoothing_calculator.cc +++ b/mediapipe/calculators/util/landmarks_smoothing_calculator.cc @@ -43,9 +43,10 @@ class LandmarksSmoothingCalculatorImpl : public NodeImpl { public: absl::Status Open(CalculatorContext* cc) override { - ASSIGN_OR_RETURN(landmarks_filter_, - InitializeLandmarksFilter( - cc->Options())); + MP_ASSIGN_OR_RETURN( + landmarks_filter_, + InitializeLandmarksFilter( + cc->Options())); return absl::OkStatus(); } diff --git a/mediapipe/calculators/util/landmarks_smoothing_calculator_utils.cc b/mediapipe/calculators/util/landmarks_smoothing_calculator_utils.cc index 32e282150..d5ed37f65 100644 --- a/mediapipe/calculators/util/landmarks_smoothing_calculator_utils.cc +++ b/mediapipe/calculators/util/landmarks_smoothing_calculator_utils.cc @@ -348,7 +348,8 @@ absl::StatusOr MultiLandmarkFilters::GetOrCreate( return it->second.get(); } - ASSIGN_OR_RETURN(auto landmarks_filter, InitializeLandmarksFilter(options)); + MP_ASSIGN_OR_RETURN(auto landmarks_filter, + InitializeLandmarksFilter(options)); filters_[tracking_id] = std::move(landmarks_filter); return filters_[tracking_id].get(); } diff --git a/mediapipe/calculators/util/landmarks_transformation_calculator.cc b/mediapipe/calculators/util/landmarks_transformation_calculator.cc index 96eaba541..e3ab45f81 100644 --- a/mediapipe/calculators/util/landmarks_transformation_calculator.cc +++ b/mediapipe/calculators/util/landmarks_transformation_calculator.cc @@ -119,10 +119,10 @@ class LandmarksTransformationCalculatorImpl for (auto& transformation : options.transformation()) { if (transformation.has_normalize_translation()) { - ASSIGN_OR_RETURN(landmarks, NormalizeTranslation(landmarks)); + MP_ASSIGN_OR_RETURN(landmarks, NormalizeTranslation(landmarks)); } else if (transformation.has_flip_axis()) { - ASSIGN_OR_RETURN(landmarks, - FlipAxis(landmarks, transformation.flip_axis())); + MP_ASSIGN_OR_RETURN(landmarks, + FlipAxis(landmarks, transformation.flip_axis())); } else { RET_CHECK_FAIL() << "Unknown landmarks transformation"; } diff --git a/mediapipe/calculators/util/local_file_contents_calculator.cc b/mediapipe/calculators/util/local_file_contents_calculator.cc index 4ad066f69..195c7da57 100644 --- a/mediapipe/calculators/util/local_file_contents_calculator.cc +++ b/mediapipe/calculators/util/local_file_contents_calculator.cc @@ -86,7 +86,7 @@ class LocalFileContentsCalculator : public CalculatorBase { ++input_id, ++output_id) { std::string file_path = cc->InputSidePackets().Get(input_id).Get(); - ASSIGN_OR_RETURN(file_path, PathToResourceAsFile(file_path)); + MP_ASSIGN_OR_RETURN(file_path, PathToResourceAsFile(file_path)); std::string contents; MP_RETURN_IF_ERROR(GetResourceContents( diff --git a/mediapipe/calculators/util/multi_landmarks_smoothing_calculator.cc b/mediapipe/calculators/util/multi_landmarks_smoothing_calculator.cc index 40098935c..6281187f2 100644 --- a/mediapipe/calculators/util/multi_landmarks_smoothing_calculator.cc +++ b/mediapipe/calculators/util/multi_landmarks_smoothing_calculator.cc @@ -83,10 +83,11 @@ class MultiLandmarksSmoothingCalculatorImpl image_width, image_height); } - ASSIGN_OR_RETURN(auto* landmarks_filter, - multi_filters_.GetOrCreate( - tracking_ids[i], - cc->Options())); + MP_ASSIGN_OR_RETURN( + auto* landmarks_filter, + multi_filters_.GetOrCreate( + tracking_ids[i], + cc->Options())); LandmarkList out_landmarks; MP_RETURN_IF_ERROR(landmarks_filter->Apply(in_landmarks, timestamp, diff --git a/mediapipe/calculators/util/multi_world_landmarks_smoothing_calculator.cc b/mediapipe/calculators/util/multi_world_landmarks_smoothing_calculator.cc index ddc16d296..44c56c6ad 100644 --- a/mediapipe/calculators/util/multi_world_landmarks_smoothing_calculator.cc +++ b/mediapipe/calculators/util/multi_world_landmarks_smoothing_calculator.cc @@ -74,10 +74,11 @@ class MultiWorldLandmarksSmoothingCalculatorImpl object_scale = GetObjectScale(object_scale_roi_vec.value()[i]); } - ASSIGN_OR_RETURN(auto* landmarks_filter, - multi_filters_.GetOrCreate( - tracking_ids[i], - cc->Options())); + MP_ASSIGN_OR_RETURN( + auto* landmarks_filter, + multi_filters_.GetOrCreate( + tracking_ids[i], + cc->Options())); LandmarkList out_landmarks; MP_RETURN_IF_ERROR(landmarks_filter->Apply(in_landmarks, timestamp, diff --git a/mediapipe/calculators/util/refine_landmarks_from_heatmap_calculator.cc b/mediapipe/calculators/util/refine_landmarks_from_heatmap_calculator.cc index 30dc11dbe..334705851 100644 --- a/mediapipe/calculators/util/refine_landmarks_from_heatmap_calculator.cc +++ b/mediapipe/calculators/util/refine_landmarks_from_heatmap_calculator.cc @@ -77,7 +77,7 @@ class RefineLandmarksFromHeatmapCalculatorImpl const auto& options = cc->Options(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto out_lms, RefineLandmarksFromHeatMap( in_lms, hm_raw, hm_tensor.shape().dims, options.kernel_size(), @@ -108,7 +108,7 @@ absl::StatusOr RefineLandmarksFromHeatMap( const float* heatmap_raw_data, const std::vector& heatmap_dims, int kernel_size, float min_confidence_to_refine, bool refine_presence, bool refine_visibility) { - ASSIGN_OR_RETURN(auto hm_dims, GetHwcFromDims(heatmap_dims)); + MP_ASSIGN_OR_RETURN(auto hm_dims, GetHwcFromDims(heatmap_dims)); auto [hm_height, hm_width, hm_channels] = hm_dims; RET_CHECK_EQ(in_lms.landmark_size(), hm_channels) diff --git a/mediapipe/calculators/util/timed_box_list_id_to_label_calculator.cc b/mediapipe/calculators/util/timed_box_list_id_to_label_calculator.cc index 790b426de..0c47c934f 100644 --- a/mediapipe/calculators/util/timed_box_list_id_to_label_calculator.cc +++ b/mediapipe/calculators/util/timed_box_list_id_to_label_calculator.cc @@ -73,7 +73,8 @@ absl::Status TimedBoxListIdToLabelCalculator::Open(CalculatorContext* cc) { cc->Options<::mediapipe::TimedBoxListIdToLabelCalculatorOptions>(); std::string string_path; - ASSIGN_OR_RETURN(string_path, PathToResourceAsFile(options.label_map_path())); + MP_ASSIGN_OR_RETURN(string_path, + PathToResourceAsFile(options.label_map_path())); std::string label_map_string; MP_RETURN_IF_ERROR(file::GetContents(string_path, &label_map_string)); diff --git a/mediapipe/calculators/util/to_image_calculator.cc b/mediapipe/calculators/util/to_image_calculator.cc index 22fedfdb1..067ede8e8 100644 --- a/mediapipe/calculators/util/to_image_calculator.cc +++ b/mediapipe/calculators/util/to_image_calculator.cc @@ -86,7 +86,7 @@ absl::Status ToImageCalculator::UpdateContract(CalculatorContract* cc) { } absl::Status ToImageCalculator::Process(CalculatorContext* cc) { - ASSIGN_OR_RETURN(auto output, GetInputImage(cc)); + MP_ASSIGN_OR_RETURN(auto output, GetInputImage(cc)); kOut(cc).Send(output.At(cc->InputTimestamp())); return absl::OkStatus(); } diff --git a/mediapipe/calculators/util/top_k_scores_calculator.cc b/mediapipe/calculators/util/top_k_scores_calculator.cc index b6bdf2f85..fe2d599d5 100644 --- a/mediapipe/calculators/util/top_k_scores_calculator.cc +++ b/mediapipe/calculators/util/top_k_scores_calculator.cc @@ -227,7 +227,7 @@ absl::Status TopKScoresCalculator::Process(CalculatorContext* cc) { absl::Status TopKScoresCalculator::LoadLabelmap(std::string label_map_path) { std::string string_path; - ASSIGN_OR_RETURN(string_path, PathToResourceAsFile(label_map_path)); + MP_ASSIGN_OR_RETURN(string_path, PathToResourceAsFile(label_map_path)); std::string label_map_string; MP_RETURN_IF_ERROR(file::GetContents(string_path, &label_map_string)); diff --git a/mediapipe/calculators/video/box_detector_calculator.cc b/mediapipe/calculators/video/box_detector_calculator.cc index 51f57b7eb..0c4be3d79 100644 --- a/mediapipe/calculators/video/box_detector_calculator.cc +++ b/mediapipe/calculators/video/box_detector_calculator.cc @@ -207,7 +207,7 @@ absl::Status BoxDetectorCalculator::Open(CalculatorContext* cc) { for (const auto& filename : options_.index_proto_filename()) { std::string string_path; - ASSIGN_OR_RETURN(string_path, PathToResourceAsFile(filename)); + MP_ASSIGN_OR_RETURN(string_path, PathToResourceAsFile(filename)); std::string index_string; MP_RETURN_IF_ERROR(file::GetContents(string_path, &index_string)); BoxDetectorIndex predefined_index; diff --git a/mediapipe/calculators/video/motion_analysis_calculator.cc b/mediapipe/calculators/video/motion_analysis_calculator.cc index 601b8b045..a3451bfa4 100644 --- a/mediapipe/calculators/video/motion_analysis_calculator.cc +++ b/mediapipe/calculators/video/motion_analysis_calculator.cc @@ -478,7 +478,7 @@ absl::Status MotionAnalysisCalculator::Process(CalculatorContext* cc) { // Fill in timestamps we process. if (!selection_stream->Value().IsEmpty()) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( frame_selection_result, selection_stream->Value().ConsumeOrCopy()); use_frame = true; diff --git a/mediapipe/examples/coral/demo_run_graph_main.cc b/mediapipe/examples/coral/demo_run_graph_main.cc index 692f26008..4b66b599c 100644 --- a/mediapipe/examples/coral/demo_run_graph_main.cc +++ b/mediapipe/examples/coral/demo_run_graph_main.cc @@ -87,8 +87,8 @@ absl::Status RunMPPGraph() { } ABSL_LOG(INFO) << "Start running the calculator graph."; - ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller, - graph.AddOutputStreamPoller(kOutputStream)); + MP_ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller, + graph.AddOutputStreamPoller(kOutputStream)); MP_RETURN_IF_ERROR(graph.StartRun({})); ABSL_LOG(INFO) << "Start grabbing and processing frames."; diff --git a/mediapipe/examples/desktop/demo_run_graph_main.cc b/mediapipe/examples/desktop/demo_run_graph_main.cc index ba36ba6c9..b2e5ae30c 100644 --- a/mediapipe/examples/desktop/demo_run_graph_main.cc +++ b/mediapipe/examples/desktop/demo_run_graph_main.cc @@ -79,8 +79,8 @@ absl::Status RunMPPGraph() { } ABSL_LOG(INFO) << "Start running the calculator graph."; - ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller, - graph.AddOutputStreamPoller(kOutputStream)); + MP_ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller, + graph.AddOutputStreamPoller(kOutputStream)); MP_RETURN_IF_ERROR(graph.StartRun({})); ABSL_LOG(INFO) << "Start grabbing and processing frames."; diff --git a/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc b/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc index 5702bca72..908db0bcc 100644 --- a/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc +++ b/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc @@ -62,7 +62,7 @@ absl::Status RunMPPGraph() { MP_RETURN_IF_ERROR(graph.Initialize(config)); ABSL_LOG(INFO) << "Initialize the GPU."; - ASSIGN_OR_RETURN(auto gpu_resources, mediapipe::GpuResources::Create()); + MP_ASSIGN_OR_RETURN(auto gpu_resources, mediapipe::GpuResources::Create()); MP_RETURN_IF_ERROR(graph.SetGpuResources(std::move(gpu_resources))); mediapipe::GlCalculatorHelper gpu_helper; gpu_helper.InitializeForTest(graph.GetGpuResources().get()); @@ -89,8 +89,8 @@ absl::Status RunMPPGraph() { } ABSL_LOG(INFO) << "Start running the calculator graph."; - ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller, - graph.AddOutputStreamPoller(kOutputStream)); + MP_ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller, + graph.AddOutputStreamPoller(kOutputStream)); MP_RETURN_IF_ERROR(graph.StartRun({})); ABSL_LOG(INFO) << "Start grabbing and processing frames."; diff --git a/mediapipe/examples/desktop/hello_world/hello_world.cc b/mediapipe/examples/desktop/hello_world/hello_world.cc index 85cf6c32a..50c49d4f5 100644 --- a/mediapipe/examples/desktop/hello_world/hello_world.cc +++ b/mediapipe/examples/desktop/hello_world/hello_world.cc @@ -42,8 +42,8 @@ absl::Status PrintHelloWorld() { CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize(config)); - ASSIGN_OR_RETURN(OutputStreamPoller poller, - graph.AddOutputStreamPoller("out")); + MP_ASSIGN_OR_RETURN(OutputStreamPoller poller, + graph.AddOutputStreamPoller("out")); MP_RETURN_IF_ERROR(graph.StartRun({})); // Give 10 input packets that contains the same string "Hello World!". for (int i = 0; i < 10; ++i) { diff --git a/mediapipe/examples/desktop/iris_tracking/iris_depth_from_image_desktop.cc b/mediapipe/examples/desktop/iris_tracking/iris_depth_from_image_desktop.cc index 37476b2b3..687f6968e 100644 --- a/mediapipe/examples/desktop/iris_tracking/iris_depth_from_image_desktop.cc +++ b/mediapipe/examples/desktop/iris_tracking/iris_depth_from_image_desktop.cc @@ -57,16 +57,16 @@ absl::StatusOr ReadFileToString(const std::string& file_path) { absl::Status ProcessImage(std::unique_ptr graph) { ABSL_LOG(INFO) << "Load the image."; - ASSIGN_OR_RETURN(const std::string raw_image, - ReadFileToString(absl::GetFlag(FLAGS_input_image_path))); + MP_ASSIGN_OR_RETURN(const std::string raw_image, + ReadFileToString(absl::GetFlag(FLAGS_input_image_path))); ABSL_LOG(INFO) << "Start running the calculator graph."; - ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller output_image_poller, - graph->AddOutputStreamPoller(kOutputImageStream)); - ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller left_iris_depth_poller, - graph->AddOutputStreamPoller(kLeftIrisDepthMmStream)); - ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller right_iris_depth_poller, - graph->AddOutputStreamPoller(kRightIrisDepthMmStream)); + MP_ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller output_image_poller, + graph->AddOutputStreamPoller(kOutputImageStream)); + MP_ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller left_iris_depth_poller, + graph->AddOutputStreamPoller(kLeftIrisDepthMmStream)); + MP_ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller right_iris_depth_poller, + graph->AddOutputStreamPoller(kRightIrisDepthMmStream)); MP_RETURN_IF_ERROR(graph->StartRun({})); // Send image packet into the graph. diff --git a/mediapipe/examples/desktop/simple_run_graph_main.cc b/mediapipe/examples/desktop/simple_run_graph_main.cc index e794902d8..e968a9bd3 100644 --- a/mediapipe/examples/desktop/simple_run_graph_main.cc +++ b/mediapipe/examples/desktop/simple_run_graph_main.cc @@ -83,8 +83,8 @@ absl::Status OutputSidePacketsToLocalFile(mediapipe::CalculatorGraph& graph) { std::vector side_packet_names = absl::StrSplit(absl::GetFlag(FLAGS_output_side_packets), ','); for (const std::string& side_packet_name : side_packet_names) { - ASSIGN_OR_RETURN(auto status_or_packet, - graph.GetOutputSidePacket(side_packet_name)); + MP_ASSIGN_OR_RETURN(auto status_or_packet, + graph.GetOutputSidePacket(side_packet_name)); file << absl::StrCat(side_packet_name, ":", status_or_packet.Get(), "\n"); } @@ -125,8 +125,8 @@ absl::Status RunMPPGraph() { MP_RETURN_IF_ERROR(graph.Initialize(config, input_side_packets)); if (!absl::GetFlag(FLAGS_output_stream).empty() && !absl::GetFlag(FLAGS_output_stream_file).empty()) { - ASSIGN_OR_RETURN(auto poller, graph.AddOutputStreamPoller( - absl::GetFlag(FLAGS_output_stream))); + MP_ASSIGN_OR_RETURN(auto poller, graph.AddOutputStreamPoller( + absl::GetFlag(FLAGS_output_stream))); ABSL_LOG(INFO) << "Start running the calculator graph."; MP_RETURN_IF_ERROR(graph.StartRun({})); MP_RETURN_IF_ERROR(OutputStreamToLocalFile(poller)); diff --git a/mediapipe/framework/api2/node_test.cc b/mediapipe/framework/api2/node_test.cc index ac1ca6015..cf6cda24a 100644 --- a/mediapipe/framework/api2/node_test.cc +++ b/mediapipe/framework/api2/node_test.cc @@ -530,9 +530,9 @@ struct ConsumerNode : public Node { MEDIAPIPE_NODE_CONTRACT(kInt, kGeneric, kOneOf); absl::Status Process(CalculatorContext* cc) override { - ASSIGN_OR_RETURN(auto maybe_int, kInt(cc).Consume()); - ASSIGN_OR_RETURN(auto maybe_float, kGeneric(cc).Consume()); - ASSIGN_OR_RETURN(auto maybe_int2, kOneOf(cc).Consume()); + MP_ASSIGN_OR_RETURN(auto maybe_int, kInt(cc).Consume()); + MP_ASSIGN_OR_RETURN(auto maybe_float, kGeneric(cc).Consume()); + MP_ASSIGN_OR_RETURN(auto maybe_int2, kOneOf(cc).Consume()); return {}; } }; diff --git a/mediapipe/framework/calculator_graph.cc b/mediapipe/framework/calculator_graph.cc index 03c5d2296..1890d799c 100644 --- a/mediapipe/framework/calculator_graph.cc +++ b/mediapipe/framework/calculator_graph.cc @@ -207,7 +207,7 @@ absl::Status CalculatorGraph::InitializeStreams() { // Initialize GraphInputStreams. int graph_input_stream_count = 0; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto input_tag_map, tool::TagMap::Create(validated_graph_->Config().input_stream())); for (const auto& stream_name : input_tag_map->Names()) { @@ -371,7 +371,7 @@ absl::Status CalculatorGraph::InitializeExecutors() { "CalculatorGraph::SetExecutor() call."; } // clang-format off - ASSIGN_OR_RETURN(Executor* executor, + MP_ASSIGN_OR_RETURN(Executor* executor, ExecutorRegistry::CreateByNameInNamespace( validated_graph_->Package(), executor_config.type(), executor_config.options())); @@ -1335,7 +1335,7 @@ absl::Status CalculatorGraph::CreateDefaultThreadPool( } options->set_num_threads(num_threads); // clang-format off - ASSIGN_OR_RETURN(Executor* executor, + MP_ASSIGN_OR_RETURN(Executor* executor, ThreadPoolExecutor::Create(extendable_options)); // clang-format on return SetExecutorInternal("", std::shared_ptr(executor)); diff --git a/mediapipe/framework/calculator_node.cc b/mediapipe/framework/calculator_node.cc index c0aff3b13..27661dc9d 100644 --- a/mediapipe/framework/calculator_node.cc +++ b/mediapipe/framework/calculator_node.cc @@ -303,14 +303,15 @@ absl::Status CalculatorNode::InitializeInputStreamHandler( const ProtoString& input_stream_handler_name = handler_config.input_stream_handler(); RET_CHECK(!input_stream_handler_name.empty()); - ASSIGN_OR_RETURN(input_stream_handler_, - InputStreamHandlerRegistry::CreateByNameInNamespace( - validated_graph_->Package(), input_stream_handler_name, - input_stream_types.TagMap(), - &calculator_context_manager_, handler_config.options(), - /*calculator_run_in_parallel=*/max_in_flight_ > 1), - _ << "\"" << input_stream_handler_name - << "\" is not a registered input stream handler."); + MP_ASSIGN_OR_RETURN( + input_stream_handler_, + InputStreamHandlerRegistry::CreateByNameInNamespace( + validated_graph_->Package(), input_stream_handler_name, + input_stream_types.TagMap(), &calculator_context_manager_, + handler_config.options(), + /*calculator_run_in_parallel=*/max_in_flight_ > 1), + _ << "\"" << input_stream_handler_name + << "\" is not a registered input stream handler."); return absl::OkStatus(); } @@ -321,14 +322,15 @@ absl::Status CalculatorNode::InitializeOutputStreamHandler( const ProtoString& output_stream_handler_name = handler_config.output_stream_handler(); RET_CHECK(!output_stream_handler_name.empty()); - ASSIGN_OR_RETURN(output_stream_handler_, - OutputStreamHandlerRegistry::CreateByNameInNamespace( - validated_graph_->Package(), output_stream_handler_name, - output_stream_types.TagMap(), - &calculator_context_manager_, handler_config.options(), - /*calculator_run_in_parallel=*/max_in_flight_ > 1), - _ << "\"" << output_stream_handler_name - << "\" is not a registered output stream handler."); + MP_ASSIGN_OR_RETURN( + output_stream_handler_, + OutputStreamHandlerRegistry::CreateByNameInNamespace( + validated_graph_->Package(), output_stream_handler_name, + output_stream_types.TagMap(), &calculator_context_manager_, + handler_config.options(), + /*calculator_run_in_parallel=*/max_in_flight_ > 1), + _ << "\"" << output_stream_handler_name + << "\" is not a registered output stream handler."); return absl::OkStatus(); } @@ -420,7 +422,7 @@ absl::Status CalculatorNode::PrepareForRun( MP_RETURN_IF_ERROR(calculator_context_manager_.PrepareForRun(std::bind( &CalculatorNode::ConnectShardsToStreams, this, std::placeholders::_1))); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto calculator_factory, CalculatorBaseRegistry::CreateByNameInNamespace( validated_graph_->Package(), calculator_state_->CalculatorType())); diff --git a/mediapipe/framework/calculator_runner.cc b/mediapipe/framework/calculator_runner.cc index 800f041cc..1066ecfe3 100644 --- a/mediapipe/framework/calculator_runner.cc +++ b/mediapipe/framework/calculator_runner.cc @@ -111,20 +111,20 @@ absl::Status CalculatorRunner::InitializeFromNodeConfig( node_config_.mutable_input_side_packet()); } - ASSIGN_OR_RETURN(auto input_map, - tool::TagMap::Create(node_config_.input_stream())); + MP_ASSIGN_OR_RETURN(auto input_map, + tool::TagMap::Create(node_config_.input_stream())); inputs_ = absl::make_unique(input_map); - ASSIGN_OR_RETURN(auto output_map, - tool::TagMap::Create(node_config_.output_stream())); + MP_ASSIGN_OR_RETURN(auto output_map, + tool::TagMap::Create(node_config_.output_stream())); outputs_ = absl::make_unique(output_map); - ASSIGN_OR_RETURN(auto input_side_map, - tool::TagMap::Create(node_config_.input_side_packet())); + MP_ASSIGN_OR_RETURN(auto input_side_map, + tool::TagMap::Create(node_config_.input_side_packet())); input_side_packets_ = absl::make_unique(input_side_map); - ASSIGN_OR_RETURN(auto output_side_map, - tool::TagMap::Create(node_config_.output_side_packet())); + MP_ASSIGN_OR_RETURN(auto output_side_map, + tool::TagMap::Create(node_config_.output_side_packet())); output_side_packets_ = absl::make_unique(output_side_map); return absl::OkStatus(); @@ -353,7 +353,7 @@ absl::Status CalculatorRunner::Run() { node_config_.output_side_packet(i), &tag, &index, &name)); Packet& contents = output_side_packets_->Get( tag, (index == -1) ? ++positional_index : index); - ASSIGN_OR_RETURN(contents, graph_->GetOutputSidePacket(name)); + MP_ASSIGN_OR_RETURN(contents, graph_->GetOutputSidePacket(name)); } return absl::OkStatus(); } diff --git a/mediapipe/framework/deps/status_macros.h b/mediapipe/framework/deps/status_macros.h index eceea01b6..02da280c2 100644 --- a/mediapipe/framework/deps/status_macros.h +++ b/mediapipe/framework/deps/status_macros.h @@ -97,27 +97,27 @@ // // Interface: // -// ASSIGN_OR_RETURN(lhs, rexpr) -// ASSIGN_OR_RETURN(lhs, rexpr, error_expression); +// MP_ASSIGN_OR_RETURN(lhs, rexpr) +// MP_ASSIGN_OR_RETURN(lhs, rexpr, error_expression); // // WARNING: expands into multiple statements; it cannot be used in a single // statement (e.g. as the body of an if statement without {})! // // Example: Declaring and initializing a new variable (ValueType can be anything // that can be initialized with assignment, including references): -// ASSIGN_OR_RETURN(ValueType value, MaybeGetValue(arg)); +// MP_ASSIGN_OR_RETURN(ValueType value, MaybeGetValue(arg)); // // Example: Assigning to an existing variable: // ValueType value; -// ASSIGN_OR_RETURN(value, MaybeGetValue(arg)); +// MP_ASSIGN_OR_RETURN(value, MaybeGetValue(arg)); // // Example: Assigning to an expression with side effects: // MyProto data; -// ASSIGN_OR_RETURN(*data.mutable_str(), MaybeGetValue(arg)); +// MP_ASSIGN_OR_RETURN(*data.mutable_str(), MaybeGetValue(arg)); // // No field "str" is added on error. // // Example: Assigning to a std::unique_ptr. -// ASSIGN_OR_RETURN(std::unique_ptr ptr, MaybeGetPtr(arg)); +// MP_ASSIGN_OR_RETURN(std::unique_ptr ptr, MaybeGetPtr(arg)); // // If passed, the `error_expression` is evaluated to produce the return // value. The expression may reference any variable visible in scope, as @@ -128,16 +128,16 @@ // returnable by the function, including (void). For example: // // Example: Adjusting the error message. -// ASSIGN_OR_RETURN(ValueType value, MaybeGetValue(query), +// MP_ASSIGN_OR_RETURN(ValueType value, MaybeGetValue(query), // _ << "while processing query " << query.DebugString()); // // Example: Logging the error on failure. -// ASSIGN_OR_RETURN(ValueType value, MaybeGetValue(query), _.LogError()); +// MP_ASSIGN_OR_RETURN(ValueType value, MaybeGetValue(query), _.LogError()); // -#define ASSIGN_OR_RETURN(...) \ - MP_STATUS_MACROS_IMPL_GET_VARIADIC_( \ - (__VA_ARGS__, MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_3_, \ - MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_2_)) \ +#define MP_ASSIGN_OR_RETURN(...) \ + MP_STATUS_MACROS_IMPL_GET_VARIADIC_( \ + (__VA_ARGS__, MP_STATUS_MACROS_IMPL_MP_ASSIGN_OR_RETURN_3_, \ + MP_STATUS_MACROS_IMPL_MP_ASSIGN_OR_RETURN_2_)) \ (__VA_ARGS__) // ================================================================= @@ -150,16 +150,16 @@ #define MP_STATUS_MACROS_IMPL_GET_VARIADIC_(args) \ MP_STATUS_MACROS_IMPL_GET_VARIADIC_HELPER_ args -#define MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_2_(lhs, rexpr) \ - MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_( \ +#define MP_STATUS_MACROS_IMPL_MP_ASSIGN_OR_RETURN_2_(lhs, rexpr) \ + MP_STATUS_MACROS_IMPL_MP_ASSIGN_OR_RETURN_( \ MP_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__), lhs, rexpr, \ return mediapipe::StatusBuilder( \ std::move(MP_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__)) \ .status(), \ MEDIAPIPE_LOC)) -#define MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_3_(lhs, rexpr, \ - error_expression) \ - MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_( \ +#define MP_STATUS_MACROS_IMPL_MP_ASSIGN_OR_RETURN_3_(lhs, rexpr, \ + error_expression) \ + MP_STATUS_MACROS_IMPL_MP_ASSIGN_OR_RETURN_( \ MP_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__), lhs, rexpr, \ mediapipe::StatusBuilder _( \ std::move(MP_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__)) \ @@ -167,12 +167,12 @@ MEDIAPIPE_LOC); \ (void)_; /* error_expression is allowed to not use this variable */ \ return (error_expression)) -#define MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_(statusor, lhs, rexpr, \ - error_expression) \ - auto statusor = (rexpr); \ - if (ABSL_PREDICT_FALSE(!statusor.ok())) { \ - error_expression; \ - } \ +#define MP_STATUS_MACROS_IMPL_MP_ASSIGN_OR_RETURN_(statusor, lhs, rexpr, \ + error_expression) \ + auto statusor = (rexpr); \ + if (ABSL_PREDICT_FALSE(!statusor.ok())) { \ + error_expression; \ + } \ lhs = std::move(statusor).value() // Internal helper for concatenating macro values. diff --git a/mediapipe/framework/input_side_packet_handler.cc b/mediapipe/framework/input_side_packet_handler.cc index b2eccf0db..9e292913c 100644 --- a/mediapipe/framework/input_side_packet_handler.cc +++ b/mediapipe/framework/input_side_packet_handler.cc @@ -29,7 +29,7 @@ absl::Status InputSidePacketHandler::PrepareForRun( std::function error_callback) { int missing_input_side_packet_count; prev_input_side_packets_ = std::move(input_side_packets_); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( input_side_packets_, tool::FillPacketSet(*input_side_packet_types, all_side_packets, &missing_input_side_packet_count)); diff --git a/mediapipe/framework/output_stream_poller.h b/mediapipe/framework/output_stream_poller.h index 98ebda313..d8c83b0d0 100644 --- a/mediapipe/framework/output_stream_poller.h +++ b/mediapipe/framework/output_stream_poller.h @@ -28,8 +28,8 @@ class OutputStreamPoller { OutputStreamPoller(const OutputStreamPoller&) = delete; OutputStreamPoller& operator=(const OutputStreamPoller&) = delete; OutputStreamPoller(OutputStreamPoller&&) = default; - // Move assignment needs to be explicitly defaulted to allow ASSIGN_OR_RETURN - // on `StatusOr`. + // Move assignment needs to be explicitly defaulted to allow + // MP_ASSIGN_OR_RETURN on `StatusOr`. OutputStreamPoller& operator=(OutputStreamPoller&&) = default; // Resets OutputStramPollerImpl and cleans the internal packet queue. diff --git a/mediapipe/framework/packet.cc b/mediapipe/framework/packet.cc index edcdaf19f..e0fa5a0bf 100644 --- a/mediapipe/framework/packet.cc +++ b/mediapipe/framework/packet.cc @@ -55,7 +55,7 @@ const HolderBase* GetHolder(const Packet& packet) { absl::StatusOr PacketFromDynamicProto(const std::string& type_name, const std::string& serialized) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto message_holder, packet_internal::MessageHolderRegistry::CreateByName(type_name)); auto* message = diff --git a/mediapipe/framework/packet.h b/mediapipe/framework/packet.h index 84ae94dc5..0b660f0d7 100644 --- a/mediapipe/framework/packet.h +++ b/mediapipe/framework/packet.h @@ -150,16 +150,16 @@ class Packet { // general recommendation is to avoid calling this function. // // Example usage: - // ASSIGN_OR_RETURN(std::unique_ptr detection, + // MP_ASSIGN_OR_RETURN(std::unique_ptr detection, // p.ConsumeOrCopy()); // // The unique_ptr type can be omitted with auto. - // ASSIGN_OR_RETURN(auto detection, p.ConsumeOrCopy()); - // If you would like to crash on failure (prefer ASSIGN_OR_RETURN): + // MP_ASSIGN_OR_RETURN(auto detection, p.ConsumeOrCopy()); + // If you would like to crash on failure (prefer MP_ASSIGN_OR_RETURN): // auto detection = p.ConsumeOrCopy().value(); // // In functions which do not return absl::Status use an adaptor - // // function as the third argument to ASSIGN_OR_RETURN. In tests, + // // function as the third argument to MP_ASSIGN_OR_RETURN. In tests, // // use an adaptor which returns void. - // ASSIGN_OR_RETURN(auto detection, p.ConsumeOrCopy(), + // MP_ASSIGN_OR_RETURN(auto detection, p.ConsumeOrCopy(), // _.With([](const absl::Status& status) { // MP_EXPECT_OK(status); // // Use CHECK_OK to crash and report a usable line diff --git a/mediapipe/framework/packet_generator_graph.cc b/mediapipe/framework/packet_generator_graph.cc index 31ec3ea3a..c59515e49 100644 --- a/mediapipe/framework/packet_generator_graph.cc +++ b/mediapipe/framework/packet_generator_graph.cc @@ -97,7 +97,7 @@ absl::Status Generate(const ValidatedGraphConfig& validated_graph, validated_graph.Config().packet_generator(generator_index); const auto& generator_name = generator_config.packet_generator(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto static_access, internal::StaticAccessToGeneratorRegistry::CreateByNameInNamespace( validated_graph.Package(), generator_name), diff --git a/mediapipe/framework/profiler/graph_profiler.cc b/mediapipe/framework/profiler/graph_profiler.cc index 949955111..f5ea01e7a 100644 --- a/mediapipe/framework/profiler/graph_profiler.cc +++ b/mediapipe/framework/profiler/graph_profiler.cc @@ -246,7 +246,7 @@ absl::Status GraphProfiler::Start(mediapipe::Executor* executor) { if (is_tracing_ && IsTraceIntervalEnabled(profiler_config_, tracer()) && executor != nullptr) { // Inform the user via logging the path to the trace logs. - ASSIGN_OR_RETURN(std::string trace_log_path, GetTraceLogPath()); + MP_ASSIGN_OR_RETURN(std::string trace_log_path, GetTraceLogPath()); // Check that we can actually write to it. auto status = file::SetContents(absl::StrCat(trace_log_path, "trace_writing_check"), @@ -655,7 +655,8 @@ absl::StatusOr GraphProfiler::GetTraceLogPath() { "Trace log writing is disabled, unable to get trace_log_path."); } if (profiler_config_.trace_log_path().empty()) { - ASSIGN_OR_RETURN(std::string directory_path, GetDefaultTraceLogDirectory()); + MP_ASSIGN_OR_RETURN(std::string directory_path, + GetDefaultTraceLogDirectory()); std::string trace_log_path = absl::StrCat(directory_path, "/", kDefaultLogFilePrefix); return trace_log_path; @@ -705,7 +706,7 @@ absl::Status GraphProfiler::WriteProfile() { // Logging is disabled, so we can exit writing without error. return absl::OkStatus(); } - ASSIGN_OR_RETURN(std::string trace_log_path, GetTraceLogPath()); + MP_ASSIGN_OR_RETURN(std::string trace_log_path, GetTraceLogPath()); int log_interval_count = GetLogIntervalCount(profiler_config_); int log_file_count = GetLogFileCount(profiler_config_); GraphProfile profile; diff --git a/mediapipe/framework/profiler/profiler_resource_util_common.cc b/mediapipe/framework/profiler/profiler_resource_util_common.cc index d75ea972e..cc573b703 100644 --- a/mediapipe/framework/profiler/profiler_resource_util_common.cc +++ b/mediapipe/framework/profiler/profiler_resource_util_common.cc @@ -33,7 +33,7 @@ absl::StatusOr GetLogDirectory() { } absl::StatusOr PathToLogFile(const std::string& path) { - ASSIGN_OR_RETURN(std::string log_dir, GetLogDirectory()); + MP_ASSIGN_OR_RETURN(std::string log_dir, GetLogDirectory()); std::string result = file::JoinPath(log_dir, path); MP_RETURN_IF_ERROR( mediapipe::file::RecursivelyCreateDir(file::Dirname(result))); diff --git a/mediapipe/framework/tool/options_field_util.cc b/mediapipe/framework/tool/options_field_util.cc index 248028c25..164da2c5c 100644 --- a/mediapipe/framework/tool/options_field_util.cc +++ b/mediapipe/framework/tool/options_field_util.cc @@ -175,7 +175,8 @@ StatusOr FindExtensionIndex(const FieldData& message_data, } std::string& extension_type = entry->extension_type; std::vector field_values; - ASSIGN_OR_RETURN(field_values, GetFieldValues(message_data, *entry->field)); + MP_ASSIGN_OR_RETURN(field_values, + GetFieldValues(message_data, *entry->field)); for (int i = 0; i < field_values.size(); ++i) { FieldData extension = ParseProtobufAny(field_values[i]); if (extension_type == "*" || @@ -275,7 +276,7 @@ absl::Status FindExtension(const FieldData& message_data, } // For repeated protobuf::Any, find the index for the extension_type. - ASSIGN_OR_RETURN(int index, FindExtensionIndex(message_data, entry)); + MP_ASSIGN_OR_RETURN(int index, FindExtensionIndex(message_data, entry)); if (index != -1) { entry->index = index; return absl::OkStatus(); @@ -367,7 +368,7 @@ absl::StatusOr> GetFieldValues( MP_RETURN_IF_ERROR(FindExtension(message_data, &head)); } RET_CHECK_NE(head.field, nullptr); - ASSIGN_OR_RETURN(results, GetFieldValues(message_data, *head.field)); + MP_ASSIGN_OR_RETURN(results, GetFieldValues(message_data, *head.field)); if (IsProtobufAny(head.field)) { for (int i = 0; i < results.size(); ++i) { results[i] = ParseProtobufAny(results[i]); @@ -381,7 +382,7 @@ absl::StatusOr> GetFieldValues( } if (!tail.empty()) { FieldData child = results.at(index); - ASSIGN_OR_RETURN(results, GetFieldValues(child, tail)); + MP_ASSIGN_OR_RETURN(results, GetFieldValues(child, tail)); } else if (index > -1) { FieldData child = results.at(index); results.clear(); @@ -394,7 +395,7 @@ absl::StatusOr> GetFieldValues( absl::StatusOr GetField(const FieldData& message_data, const FieldPath& field_path) { std::vector results; - ASSIGN_OR_RETURN(results, GetFieldValues(message_data, field_path)); + MP_ASSIGN_OR_RETURN(results, GetFieldValues(message_data, field_path)); if (results.empty()) { FieldPathEntry tail = field_path.back(); return absl::OutOfRangeError(absl::StrCat( @@ -452,12 +453,12 @@ absl::Status MergeFieldValues(FieldData& message_data, : field_path.back().field->type(); std::vector results = values; std::vector prevs; - ASSIGN_OR_RETURN(prevs, GetFieldValues(message_data, field_path)); + MP_ASSIGN_OR_RETURN(prevs, GetFieldValues(message_data, field_path)); if (field_type == FieldType::TYPE_MESSAGE) { for (int i = 0; i < std::min(values.size(), prevs.size()); ++i) { FieldData& v = results[i]; FieldData& b = prevs[i]; - ASSIGN_OR_RETURN(v, MergeMessages(b, v)); + MP_ASSIGN_OR_RETURN(v, MergeMessages(b, v)); } } status.Update(SetFieldValues(message_data, field_path, results)); diff --git a/mediapipe/framework/tool/options_util.cc b/mediapipe/framework/tool/options_util.cc index 80b2f9d15..f0c8c002e 100644 --- a/mediapipe/framework/tool/options_util.cc +++ b/mediapipe/framework/tool/options_util.cc @@ -88,11 +88,11 @@ absl::Status CopyLiteralOptions(CalculatorGraphConfig::Node parent_node, FieldData parent_options; ASSIGN_IF_OK(parent_options, GetNodeOptions(parent_data, graph_extension_type)); - ASSIGN_OR_RETURN(graph_options, - MergeMessages(graph_options, parent_options)); + MP_ASSIGN_OR_RETURN(graph_options, + MergeMessages(graph_options, parent_options)); FieldData node_options; - ASSIGN_OR_RETURN(node_options, - GetNodeOptions(node_data, node_extension_type)); + MP_ASSIGN_OR_RETURN(node_options, + GetNodeOptions(node_data, node_extension_type)); if (!node_options.has_message_value() || !graph_options.has_message_value()) { continue; @@ -100,7 +100,8 @@ absl::Status CopyLiteralOptions(CalculatorGraphConfig::Node parent_node, FieldPath graph_path = GetPath(graph_tag, MessageType(graph_options)); FieldPath node_path = GetPath(node_tag, MessageType(node_options)); std::vector packet_data; - ASSIGN_OR_RETURN(packet_data, GetFieldValues(graph_options, graph_path)); + MP_ASSIGN_OR_RETURN(packet_data, + GetFieldValues(graph_options, graph_path)); MP_RETURN_IF_ERROR( MergeFieldValues(node_options, node_path, packet_data)); options_field_util::SetOptionsMessage(node_options, &node); diff --git a/mediapipe/framework/tool/options_util_test.cc b/mediapipe/framework/tool/options_util_test.cc index b518d6d39..5c2a3f8c5 100644 --- a/mediapipe/framework/tool/options_util_test.cc +++ b/mediapipe/framework/tool/options_util_test.cc @@ -338,8 +338,8 @@ absl::Status Equals(std::vector b1, std::vector b2) { using tool::options_field_util::AsPacket; RET_CHECK_EQ(b1.size(), b2.size()); for (int i = 0; i < b1.size(); ++i) { - ASSIGN_OR_RETURN(Packet p1, AsPacket(b1.at(i))); - ASSIGN_OR_RETURN(Packet p2, AsPacket(b2.at(i))); + MP_ASSIGN_OR_RETURN(Packet p1, AsPacket(b1.at(i))); + MP_ASSIGN_OR_RETURN(Packet p2, AsPacket(b2.at(i))); MP_RETURN_IF_ERROR(Equals(p1.Get(), p2.Get())); } return absl::OkStatus(); diff --git a/mediapipe/framework/tool/packet_generator_wrapper_calculator.cc b/mediapipe/framework/tool/packet_generator_wrapper_calculator.cc index 07eae6f26..bbcf46737 100644 --- a/mediapipe/framework/tool/packet_generator_wrapper_calculator.cc +++ b/mediapipe/framework/tool/packet_generator_wrapper_calculator.cc @@ -15,10 +15,10 @@ absl::Status PacketGeneratorWrapperCalculator::GetContract( CalculatorContract* cc) { const auto& options = cc->Options<::mediapipe::PacketGeneratorWrapperCalculatorOptions>(); - ASSIGN_OR_RETURN(auto static_access, - mediapipe::internal::StaticAccessToGeneratorRegistry:: - CreateByNameInNamespace(options.package(), - options.packet_generator())); + MP_ASSIGN_OR_RETURN(auto static_access, + mediapipe::internal::StaticAccessToGeneratorRegistry:: + CreateByNameInNamespace(options.package(), + options.packet_generator())); MP_RETURN_IF_ERROR(static_access->FillExpectations(options.options(), &cc->InputSidePackets(), &cc->OutputSidePackets())) @@ -30,10 +30,10 @@ absl::Status PacketGeneratorWrapperCalculator::GetContract( absl::Status PacketGeneratorWrapperCalculator::Open(CalculatorContext* cc) { const auto& options = cc->Options<::mediapipe::PacketGeneratorWrapperCalculatorOptions>(); - ASSIGN_OR_RETURN(auto static_access, - mediapipe::internal::StaticAccessToGeneratorRegistry:: - CreateByNameInNamespace(options.package(), - options.packet_generator())); + MP_ASSIGN_OR_RETURN(auto static_access, + mediapipe::internal::StaticAccessToGeneratorRegistry:: + CreateByNameInNamespace(options.package(), + options.packet_generator())); mediapipe::PacketSet output_packets(cc->OutputSidePackets().TagMap()); MP_RETURN_IF_ERROR(static_access->Generate(options.options(), cc->InputSidePackets(), diff --git a/mediapipe/framework/tool/proto_util_lite.cc b/mediapipe/framework/tool/proto_util_lite.cc index 285aa2205..1cc6e1e34 100644 --- a/mediapipe/framework/tool/proto_util_lite.cc +++ b/mediapipe/framework/tool/proto_util_lite.cc @@ -196,7 +196,7 @@ absl::Status ProtoUtilLite::ReplaceFieldRange( proto_path.erase(proto_path.begin()); FieldType type = !proto_path.empty() ? WireFormatLite::TYPE_MESSAGE : field_type; - ASSIGN_OR_RETURN(auto r, AccessField(entry, type, *message)); + MP_ASSIGN_OR_RETURN(auto r, AccessField(entry, type, *message)); FieldAccess& access = r.first; int index = r.second; std::vector& v = *access.mutable_field_values(); @@ -223,7 +223,7 @@ absl::Status ProtoUtilLite::GetFieldRange( proto_path.erase(proto_path.begin()); FieldType type = !proto_path.empty() ? WireFormatLite::TYPE_MESSAGE : field_type; - ASSIGN_OR_RETURN(auto r, AccessField(entry, type, message)); + MP_ASSIGN_OR_RETURN(auto r, AccessField(entry, type, message)); FieldAccess& access = r.first; int index = r.second; std::vector& v = *access.mutable_field_values(); @@ -252,7 +252,7 @@ absl::Status ProtoUtilLite::GetFieldCount(const FieldValue& message, proto_path.erase(proto_path.begin()); FieldType type = !proto_path.empty() ? WireFormatLite::TYPE_MESSAGE : field_type; - ASSIGN_OR_RETURN(auto r, AccessField(entry, type, message)); + MP_ASSIGN_OR_RETURN(auto r, AccessField(entry, type, message)); FieldAccess& access = r.first; int index = r.second; std::vector& v = *access.mutable_field_values(); diff --git a/mediapipe/framework/tool/subgraph_expansion.cc b/mediapipe/framework/tool/subgraph_expansion.cc index dcd055f59..59373fd11 100644 --- a/mediapipe/framework/tool/subgraph_expansion.cc +++ b/mediapipe/framework/tool/subgraph_expansion.cc @@ -62,8 +62,8 @@ absl::Status FindIgnoredStreams( const proto_ns::RepeatedPtrField& src_streams, const proto_ns::RepeatedPtrField& dst_streams, std::set* result) { - ASSIGN_OR_RETURN(auto src_map, tool::TagMap::Create(src_streams)); - ASSIGN_OR_RETURN(auto dst_map, tool::TagMap::Create(dst_streams)); + MP_ASSIGN_OR_RETURN(auto src_map, tool::TagMap::Create(src_streams)); + MP_ASSIGN_OR_RETURN(auto dst_map, tool::TagMap::Create(dst_streams)); for (auto id = src_map->BeginId(); id < src_map->EndId(); ++id) { std::pair tag_index = src_map->TagAndIndexFromId(id); if (!dst_map->GetId(tag_index.first, tag_index.second).IsValid()) { @@ -149,8 +149,8 @@ absl::Status FindCorrespondingStreams( std::map* stream_map, const proto_ns::RepeatedPtrField& src_streams, const proto_ns::RepeatedPtrField& dst_streams) { - ASSIGN_OR_RETURN(auto src_map, tool::TagMap::Create(src_streams)); - ASSIGN_OR_RETURN(auto dst_map, tool::TagMap::Create(dst_streams)); + MP_ASSIGN_OR_RETURN(auto src_map, tool::TagMap::Create(src_streams)); + MP_ASSIGN_OR_RETURN(auto dst_map, tool::TagMap::Create(dst_streams)); for (const auto& it : dst_map->Mapping()) { const std::string& tag = it.first; const TagMap::TagData* src_tag_data = @@ -299,9 +299,10 @@ absl::Status ExpandSubgraphs(CalculatorGraphConfig* config, std::string node_name = CanonicalNodeName(*config, node_id); MP_RETURN_IF_ERROR(ValidateSubgraphFields(node)); SubgraphContext subgraph_context(&node, service_manager); - ASSIGN_OR_RETURN(auto subgraph, graph_registry->CreateByName( - config->package(), node.calculator(), - &subgraph_context)); + MP_ASSIGN_OR_RETURN( + auto subgraph, + graph_registry->CreateByName(config->package(), node.calculator(), + &subgraph_context)); MP_RETURN_IF_ERROR(mediapipe::tool::DefineGraphOptions(node, &subgraph)); MP_RETURN_IF_ERROR(PrefixNames(node_name, &subgraph)); MP_RETURN_IF_ERROR(ConnectSubgraphStreams(node, &subgraph)); diff --git a/mediapipe/framework/tool/switch/graph_processor.cc b/mediapipe/framework/tool/switch/graph_processor.cc index f35730761..34a10b99a 100644 --- a/mediapipe/framework/tool/switch/graph_processor.cc +++ b/mediapipe/framework/tool/switch/graph_processor.cc @@ -8,10 +8,10 @@ namespace mediapipe { absl::Status GraphProcessor::Initialize(CalculatorGraphConfig graph_config) { graph_config_ = graph_config; - ASSIGN_OR_RETURN(graph_input_map_, - tool::TagMap::Create(graph_config_.input_stream())); - ASSIGN_OR_RETURN(graph_output_map_, - tool::TagMap::Create(graph_config_.output_stream())); + MP_ASSIGN_OR_RETURN(graph_input_map_, + tool::TagMap::Create(graph_config_.input_stream())); + MP_ASSIGN_OR_RETURN(graph_output_map_, + tool::TagMap::Create(graph_config_.output_stream())); return absl::OkStatus(); } diff --git a/mediapipe/framework/tool/tag_map.h b/mediapipe/framework/tool/tag_map.h index 6ac23df08..e785acf7e 100644 --- a/mediapipe/framework/tool/tag_map.h +++ b/mediapipe/framework/tool/tag_map.h @@ -53,7 +53,7 @@ class TagMap { // Create a TagMap from a repeated string proto field of TAG::name. // This is the most common usage: - // ASSIGN_OR_RETURN(std::shared_ptr tag_map, + // MP_ASSIGN_OR_RETURN(std::shared_ptr tag_map, // tool::TagMap::Create(node.input_streams())); static absl::StatusOr> Create( const proto_ns::RepeatedPtrField& tag_index_names) { diff --git a/mediapipe/framework/tool/test_util.cc b/mediapipe/framework/tool/test_util.cc index e5fac11ae..4e9fb00bb 100644 --- a/mediapipe/framework/tool/test_util.cc +++ b/mediapipe/framework/tool/test_util.cc @@ -215,22 +215,24 @@ bool CompareImageFrames(const ImageFrame& image1, const ImageFrame& image2, absl::Status CompareAndSaveImageOutput( absl::string_view golden_image_path, const ImageFrame& actual, const ImageFrameComparisonOptions& options) { - ASSIGN_OR_RETURN(auto output_img_path, SavePngTestOutput(actual, "output")); + MP_ASSIGN_OR_RETURN(auto output_img_path, + SavePngTestOutput(actual, "output")); auto expected = LoadTestImage(GetTestFilePath(golden_image_path), ImageFormat::UNKNOWN); if (!expected.ok()) { return expected.status(); } - ASSIGN_OR_RETURN(auto expected_img_path, - SavePngTestOutput(**expected, "expected")); + MP_ASSIGN_OR_RETURN(auto expected_img_path, + SavePngTestOutput(**expected, "expected")); std::unique_ptr diff_img; auto status = CompareImageFrames(**expected, actual, options.max_color_diff, options.max_alpha_diff, options.max_avg_diff, diff_img); if (diff_img) { - ASSIGN_OR_RETURN(auto diff_img_path, SavePngTestOutput(*diff_img, "diff")); + MP_ASSIGN_OR_RETURN(auto diff_img_path, + SavePngTestOutput(*diff_img, "diff")); } return status; diff --git a/mediapipe/framework/tool/validate_type.cc b/mediapipe/framework/tool/validate_type.cc index 38c04fa87..29c871d28 100644 --- a/mediapipe/framework/tool/validate_type.cc +++ b/mediapipe/framework/tool/validate_type.cc @@ -46,7 +46,7 @@ absl::Status RunGeneratorFillExpectations( // side packet. PacketGeneratorConfig config = input_config; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto static_access, internal::StaticAccessToGeneratorRegistry::CreateByNameInNamespace( package, config.packet_generator()), @@ -81,7 +81,7 @@ absl::Status RunGenerateAndValidateTypes( const std::string& package) { ABSL_CHECK(output_side_packets); // Get static access to functions. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto static_access, internal::StaticAccessToGeneratorRegistry::CreateByNameInNamespace( package, packet_generator_name), diff --git a/mediapipe/framework/validated_graph_config.cc b/mediapipe/framework/validated_graph_config.cc index 4f9182474..293d68d26 100644 --- a/mediapipe/framework/validated_graph_config.cc +++ b/mediapipe/framework/validated_graph_config.cc @@ -216,10 +216,11 @@ absl::Status NodeTypeInfo::Initialize( LegacyCalculatorSupport::Scoped s(&contract_); // A number of calculators use the non-CC methods on GlCalculatorHelper // even though they are CalculatorBase-based. - ASSIGN_OR_RETURN(auto calculator_factory, - CalculatorBaseRegistry::CreateByNameInNamespace( - validated_graph.Package(), node_class), - _ << "Unable to find Calculator \"" << node_class << "\""); + MP_ASSIGN_OR_RETURN( + auto calculator_factory, + CalculatorBaseRegistry::CreateByNameInNamespace(validated_graph.Package(), + node_class), + _ << "Unable to find Calculator \"" << node_class << "\""); MP_RETURN_IF_ERROR(calculator_factory->GetContract(&contract_)).SetPrepend() << node_class << ": "; @@ -261,7 +262,7 @@ absl::Status NodeTypeInfo::Initialize( // Run FillExpectations. const std::string& node_class = node.packet_generator(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto static_access, internal::StaticAccessToGeneratorRegistry::CreateByNameInNamespace( validated_graph.Package(), node_class), @@ -302,7 +303,7 @@ absl::Status NodeTypeInfo::Initialize( // Run FillExpectations. const std::string& node_class = node.status_handler(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto static_access, internal::StaticAccessToStatusHandlerRegistry::CreateByNameInNamespace( validated_graph.Package(), node_class), @@ -602,8 +603,8 @@ absl::Status ValidatedGraphConfig::AddOutputSidePacketsForNode( absl::Status ValidatedGraphConfig::InitializeStreamInfo( bool* need_sorting_ptr) { // Define output streams for graph input streams. - ASSIGN_OR_RETURN(std::shared_ptr graph_input_streams, - tool::TagMap::Create(config_.input_stream())); + MP_ASSIGN_OR_RETURN(std::shared_ptr graph_input_streams, + tool::TagMap::Create(config_.input_stream())); for (int index = 0; index < graph_input_streams->Names().size(); ++index) { std::string name = graph_input_streams->Names()[index]; owned_packet_types_.emplace_back(new PacketType()); diff --git a/mediapipe/gpu/gl_context_egl.cc b/mediapipe/gpu/gl_context_egl.cc index d573b6978..48b6192b2 100644 --- a/mediapipe/gpu/gl_context_egl.cc +++ b/mediapipe/gpu/gl_context_egl.cc @@ -177,7 +177,7 @@ absl::Status GlContext::CreateContextInternal(EGLContext share_context, } absl::Status GlContext::CreateContext(EGLContext share_context) { - ASSIGN_OR_RETURN(display_, GetInitializedEglDisplay()); + MP_ASSIGN_OR_RETURN(display_, GetInitializedEglDisplay()); auto status = CreateContextInternal(share_context, 3); if (!status.ok()) { diff --git a/mediapipe/gpu/gpu_shared_data_internal.cc b/mediapipe/gpu/gpu_shared_data_internal.cc index b9b9c26f0..31bdf18b5 100644 --- a/mediapipe/gpu/gpu_shared_data_internal.cc +++ b/mediapipe/gpu/gpu_shared_data_internal.cc @@ -74,7 +74,7 @@ GpuResources::StatusOrGpuResources GpuResources::Create() { GpuResources::StatusOrGpuResources GpuResources::Create( PlatformGlContext external_context) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( std::shared_ptr context, GlContext::Create(external_context, kGlContextUseDedicatedThread)); std::shared_ptr gpu_resources( @@ -150,8 +150,8 @@ absl::Status GpuResources::PrepareGpuNode(CalculatorNode* node) { #endif // !__EMSCRIPTEN__ node_key_[node_id] = context_key; - ASSIGN_OR_RETURN(std::shared_ptr context, - GetOrCreateGlContext(context_key)); + MP_ASSIGN_OR_RETURN(std::shared_ptr context, + GetOrCreateGlContext(context_key)); if (kGlContextUseDedicatedThread) { std::string executor_name = @@ -186,9 +186,9 @@ GlContext::StatusOrGlContext GpuResources::GetOrCreateGlContext( const std::string& key) { auto it = gl_key_context_.find(key); if (it == gl_key_context_.end()) { - ASSIGN_OR_RETURN(std::shared_ptr new_context, - GlContext::Create(*gl_key_context_[SharedContextKey()], - kGlContextUseDedicatedThread)); + MP_ASSIGN_OR_RETURN(std::shared_ptr new_context, + GlContext::Create(*gl_key_context_[SharedContextKey()], + kGlContextUseDedicatedThread)); it = gl_key_context_.emplace(key, new_context).first; #if MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER texture_caches_->RegisterTextureCache(it->second->cv_texture_cache()); diff --git a/mediapipe/java/com/google/mediapipe/framework/jni/graph.cc b/mediapipe/java/com/google/mediapipe/framework/jni/graph.cc index f129b1a7c..d3a376842 100644 --- a/mediapipe/java/com/google/mediapipe/framework/jni/graph.cc +++ b/mediapipe/java/com/google/mediapipe/framework/jni/graph.cc @@ -589,9 +589,9 @@ absl::Status Graph::SetParentGlContext(int64_t java_gl_context) { "trying to set the parent GL context, but the gpu shared " "data has already been set up."); } - ASSIGN_OR_RETURN(gpu_resources_, - mediapipe::GpuResources::Create( - reinterpret_cast(java_gl_context))); + MP_ASSIGN_OR_RETURN(gpu_resources_, + mediapipe::GpuResources::Create( + reinterpret_cast(java_gl_context))); #endif // MEDIAPIPE_DISABLE_GPU return absl::OkStatus(); } diff --git a/mediapipe/modules/face_geometry/effect_renderer_calculator.cc b/mediapipe/modules/face_geometry/effect_renderer_calculator.cc index f353b8f96..ce839156d 100644 --- a/mediapipe/modules/face_geometry/effect_renderer_calculator.cc +++ b/mediapipe/modules/face_geometry/effect_renderer_calculator.cc @@ -119,22 +119,22 @@ class EffectRendererCalculator : public CalculatorBase { absl::optional effect_mesh_3d; if (options.has_effect_mesh_3d_path()) { - ASSIGN_OR_RETURN(effect_mesh_3d, - ReadMesh3dFromFile(options.effect_mesh_3d_path()), - _ << "Failed to read the effect 3D mesh from file!"); + MP_ASSIGN_OR_RETURN( + effect_mesh_3d, ReadMesh3dFromFile(options.effect_mesh_3d_path()), + _ << "Failed to read the effect 3D mesh from file!"); MP_RETURN_IF_ERROR(face_geometry::ValidateMesh3d(*effect_mesh_3d)) << "Invalid effect 3D mesh!"; } - ASSIGN_OR_RETURN(ImageFrame effect_texture, - ReadTextureFromFile(options.effect_texture_path()), - _ << "Failed to read the effect texture from file!"); + MP_ASSIGN_OR_RETURN(ImageFrame effect_texture, + ReadTextureFromFile(options.effect_texture_path()), + _ << "Failed to read the effect texture from file!"); - ASSIGN_OR_RETURN(effect_renderer_, - CreateEffectRenderer(environment, effect_mesh_3d, - std::move(effect_texture)), - _ << "Failed to create the effect renderer!"); + MP_ASSIGN_OR_RETURN(effect_renderer_, + CreateEffectRenderer(environment, effect_mesh_3d, + std::move(effect_texture)), + _ << "Failed to create the effect renderer!"); return absl::OkStatus(); }); @@ -202,9 +202,9 @@ class EffectRendererCalculator : public CalculatorBase { private: static absl::StatusOr ReadTextureFromFile( const std::string& texture_path) { - ASSIGN_OR_RETURN(std::string texture_blob, - ReadContentBlobFromFile(texture_path), - _ << "Failed to read texture blob from file!"); + MP_ASSIGN_OR_RETURN(std::string texture_blob, + ReadContentBlobFromFile(texture_path), + _ << "Failed to read texture blob from file!"); // Use OpenCV image decoding functionality to finish reading the texture. std::vector texture_blob_vector(texture_blob.begin(), @@ -246,9 +246,9 @@ class EffectRendererCalculator : public CalculatorBase { static absl::StatusOr ReadMesh3dFromFile( const std::string& mesh_3d_path) { - ASSIGN_OR_RETURN(std::string mesh_3d_blob, - ReadContentBlobFromFile(mesh_3d_path), - _ << "Failed to read mesh 3D blob from file!"); + MP_ASSIGN_OR_RETURN(std::string mesh_3d_blob, + ReadContentBlobFromFile(mesh_3d_path), + _ << "Failed to read mesh 3D blob from file!"); face_geometry::Mesh3d mesh_3d; RET_CHECK(mesh_3d.ParseFromString(mesh_3d_blob)) @@ -259,9 +259,10 @@ class EffectRendererCalculator : public CalculatorBase { static absl::StatusOr ReadContentBlobFromFile( const std::string& unresolved_path) { - ASSIGN_OR_RETURN(std::string resolved_path, - mediapipe::PathToResourceAsFile(unresolved_path), - _ << "Failed to resolve path! Path = " << unresolved_path); + MP_ASSIGN_OR_RETURN( + std::string resolved_path, + mediapipe::PathToResourceAsFile(unresolved_path), + _ << "Failed to resolve path! Path = " << unresolved_path); std::string content_blob; MP_RETURN_IF_ERROR( diff --git a/mediapipe/modules/face_geometry/geometry_pipeline_calculator.cc b/mediapipe/modules/face_geometry/geometry_pipeline_calculator.cc index 87e710e42..6aa98a5f3 100644 --- a/mediapipe/modules/face_geometry/geometry_pipeline_calculator.cc +++ b/mediapipe/modules/face_geometry/geometry_pipeline_calculator.cc @@ -92,7 +92,7 @@ class GeometryPipelineCalculator : public CalculatorBase { const auto& options = cc->Options(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( face_geometry::GeometryPipelineMetadata metadata, ReadMetadataFromFile(options.metadata_path()), _ << "Failed to read the geometry pipeline metadata from file!"); @@ -109,7 +109,7 @@ class GeometryPipelineCalculator : public CalculatorBase { MP_RETURN_IF_ERROR(face_geometry::ValidateEnvironment(environment)) << "Invalid environment!"; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( geometry_pipeline_, face_geometry::CreateGeometryPipeline(environment, metadata), _ << "Failed to create a geometry pipeline!"); @@ -136,7 +136,7 @@ class GeometryPipelineCalculator : public CalculatorBase { auto multi_face_geometry = absl::make_unique>(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( *multi_face_geometry, geometry_pipeline_->EstimateFaceGeometry( multi_face_landmarks, // @@ -160,9 +160,9 @@ class GeometryPipelineCalculator : public CalculatorBase { private: static absl::StatusOr ReadMetadataFromFile(const std::string& metadata_path) { - ASSIGN_OR_RETURN(std::string metadata_blob, - ReadContentBlobFromFile(metadata_path), - _ << "Failed to read a metadata blob from file!"); + MP_ASSIGN_OR_RETURN(std::string metadata_blob, + ReadContentBlobFromFile(metadata_path), + _ << "Failed to read a metadata blob from file!"); face_geometry::GeometryPipelineMetadata metadata; RET_CHECK(metadata.ParseFromString(metadata_blob)) @@ -173,9 +173,10 @@ class GeometryPipelineCalculator : public CalculatorBase { static absl::StatusOr ReadContentBlobFromFile( const std::string& unresolved_path) { - ASSIGN_OR_RETURN(std::string resolved_path, - mediapipe::PathToResourceAsFile(unresolved_path), - _ << "Failed to resolve path! Path = " << unresolved_path); + MP_ASSIGN_OR_RETURN( + std::string resolved_path, + mediapipe::PathToResourceAsFile(unresolved_path), + _ << "Failed to resolve path! Path = " << unresolved_path); std::string content_blob; MP_RETURN_IF_ERROR( diff --git a/mediapipe/modules/face_geometry/libs/effect_renderer.cc b/mediapipe/modules/face_geometry/libs/effect_renderer.cc index 73f473084..90e2c2f2b 100644 --- a/mediapipe/modules/face_geometry/libs/effect_renderer.cc +++ b/mediapipe/modules/face_geometry/libs/effect_renderer.cc @@ -48,19 +48,19 @@ struct RenderableMesh3d { RenderableMesh3d renderable_mesh_3d; renderable_mesh_3d.vertex_size = GetVertexSize(vertex_type); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( renderable_mesh_3d.vertex_position_size, GetVertexComponentSize(vertex_type, VertexComponent::POSITION), _ << "Failed to get the position vertex size!"); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( renderable_mesh_3d.tex_coord_position_size, GetVertexComponentSize(vertex_type, VertexComponent::TEX_COORD), _ << "Failed to get the tex coord vertex size!"); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( renderable_mesh_3d.vertex_position_offset, GetVertexComponentOffset(vertex_type, VertexComponent::POSITION), _ << "Failed to get the position vertex offset!"); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( renderable_mesh_3d.tex_coord_position_offset, GetVertexComponentOffset(vertex_type, VertexComponent::TEX_COORD), _ << "Failed to get the tex coord vertex offset!"); @@ -473,12 +473,12 @@ class EffectRendererImpl : public EffectRenderer { } // Wrap both source and destination textures. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( std::unique_ptr src_texture, Texture::WrapExternalTexture(src_texture_name, src_texture_target, frame_width, frame_height), _ << "Failed to wrap the external source texture"); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( std::unique_ptr dst_texture, Texture::WrapExternalTexture(dst_texture_name, dst_texture_target, frame_width, frame_height), @@ -506,14 +506,14 @@ class EffectRendererImpl : public EffectRenderer { const FaceGeometry& face_geometry = multi_face_geometry[i]; // Extract the face pose transformation matrix. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( face_pose_transform_matrices[i], Convert4x4MatrixDataToArrayFormat( face_geometry.pose_transform_matrix()), _ << "Failed to extract the face pose transformation matrix!"); // Extract the face mesh as a renderable. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( renderable_face_meshes[i], RenderableMesh3d::CreateFromProtoMesh3d(face_geometry.mesh()), _ << "Failed to extract a renderable face mesh!"); @@ -699,26 +699,28 @@ absl::StatusOr> CreateEffectRenderer( << "Invalid effect 3D mesh!"; } - ASSIGN_OR_RETURN(std::unique_ptr render_target, - RenderTarget::Create(), - _ << "Failed to create a render target!"); - ASSIGN_OR_RETURN(std::unique_ptr renderer, Renderer::Create(), - _ << "Failed to create a renderer!"); - ASSIGN_OR_RETURN(RenderableMesh3d renderable_quad_mesh_3d, - RenderableMesh3d::CreateFromProtoMesh3d(CreateQuadMesh3d()), - _ << "Failed to create a renderable quad mesh!"); + MP_ASSIGN_OR_RETURN(std::unique_ptr render_target, + RenderTarget::Create(), + _ << "Failed to create a render target!"); + MP_ASSIGN_OR_RETURN(std::unique_ptr renderer, Renderer::Create(), + _ << "Failed to create a renderer!"); + MP_ASSIGN_OR_RETURN( + RenderableMesh3d renderable_quad_mesh_3d, + RenderableMesh3d::CreateFromProtoMesh3d(CreateQuadMesh3d()), + _ << "Failed to create a renderable quad mesh!"); absl::optional renderable_effect_mesh_3d; if (effect_mesh_3d) { - ASSIGN_OR_RETURN(renderable_effect_mesh_3d, - RenderableMesh3d::CreateFromProtoMesh3d(*effect_mesh_3d), - _ << "Failed to create a renderable effect mesh!"); + MP_ASSIGN_OR_RETURN( + renderable_effect_mesh_3d, + RenderableMesh3d::CreateFromProtoMesh3d(*effect_mesh_3d), + _ << "Failed to create a renderable effect mesh!"); } - ASSIGN_OR_RETURN(std::unique_ptr empty_color_gl_texture, - Texture::CreateFromImageFrame(CreateEmptyColorTexture()), - _ << "Failed to create an empty color texture!"); - ASSIGN_OR_RETURN(std::unique_ptr effect_gl_texture, - Texture::CreateFromImageFrame(effect_texture), - _ << "Failed to create an effect texture!"); + MP_ASSIGN_OR_RETURN(std::unique_ptr empty_color_gl_texture, + Texture::CreateFromImageFrame(CreateEmptyColorTexture()), + _ << "Failed to create an empty color texture!"); + MP_ASSIGN_OR_RETURN(std::unique_ptr effect_gl_texture, + Texture::CreateFromImageFrame(effect_texture), + _ << "Failed to create an effect texture!"); std::unique_ptr result = absl::make_unique( diff --git a/mediapipe/modules/face_geometry/libs/geometry_pipeline.cc b/mediapipe/modules/face_geometry/libs/geometry_pipeline.cc index bcfce7cff..3d00f8adc 100644 --- a/mediapipe/modules/face_geometry/libs/geometry_pipeline.cc +++ b/mediapipe/modules/face_geometry/libs/geometry_pipeline.cc @@ -142,9 +142,9 @@ class ScreenToMetricSpaceConverter { Eigen::Matrix3Xf intermediate_landmarks(screen_landmarks); ChangeHandedness(intermediate_landmarks); - ASSIGN_OR_RETURN(const float first_iteration_scale, - EstimateScale(intermediate_landmarks), - _ << "Failed to estimate first iteration scale!"); + MP_ASSIGN_OR_RETURN(const float first_iteration_scale, + EstimateScale(intermediate_landmarks), + _ << "Failed to estimate first iteration scale!"); // 2nd iteration: unproject XY using the scale from the 1st iteration. intermediate_landmarks = screen_landmarks; @@ -167,9 +167,9 @@ class ScreenToMetricSpaceConverter { canonical_metric_landmarks_.colwise().homogeneous()) .row(2); } - ASSIGN_OR_RETURN(const float second_iteration_scale, - EstimateScale(intermediate_landmarks), - _ << "Failed to estimate second iteration scale!"); + MP_ASSIGN_OR_RETURN(const float second_iteration_scale, + EstimateScale(intermediate_landmarks), + _ << "Failed to estimate second iteration scale!"); // Use the total scale to unproject the screen landmarks. const float total_scale = first_iteration_scale * second_iteration_scale; diff --git a/mediapipe/modules/face_geometry/libs/procrustes_solver.cc b/mediapipe/modules/face_geometry/libs/procrustes_solver.cc index 2ffae0e6f..2a29519c2 100644 --- a/mediapipe/modules/face_geometry/libs/procrustes_solver.cc +++ b/mediapipe/modules/face_geometry/libs/procrustes_solver.cc @@ -172,7 +172,7 @@ class FloatPrecisionProcrustesSolver : public ProcrustesSolver { MP_RETURN_IF_ERROR(ComputeOptimalRotation( weighted_targets * centered_weighted_sources.transpose(), rotation)) << "Failed to compute the optimal rotation!"; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( float scale, ComputeOptimalScale(centered_weighted_sources, weighted_sources, weighted_targets, rotation), diff --git a/mediapipe/objc/util.cc b/mediapipe/objc/util.cc index 684dc181c..e5908f25a 100644 --- a/mediapipe/objc/util.cc +++ b/mediapipe/objc/util.cc @@ -315,8 +315,8 @@ absl::Status CreateCVPixelBufferForImageFramePacket( auto image_frame = std::const_pointer_cast( mediapipe::SharedPtrWithPacket( image_frame_packet)); - ASSIGN_OR_RETURN(*out_buffer, CreateCVPixelBufferForImageFrame( - image_frame, can_overwrite)); + MP_ASSIGN_OR_RETURN(*out_buffer, CreateCVPixelBufferForImageFrame( + image_frame, can_overwrite)); return absl::OkStatus(); } @@ -339,9 +339,9 @@ absl::StatusOr> CreateCVPixelBufferForImageFrame( if (can_overwrite) { v_dest = v_image; } else { - ASSIGN_OR_RETURN(pixel_buffer, - CreateCVPixelBufferWithoutPool( - frame.Width(), frame.Height(), pixel_format)); + MP_ASSIGN_OR_RETURN(pixel_buffer, + CreateCVPixelBufferWithoutPool( + frame.Width(), frame.Height(), pixel_format)); status = CVPixelBufferLockBaseAddress(*pixel_buffer, kCVPixelBufferLock_ReadOnly); RET_CHECK(status == kCVReturnSuccess) @@ -456,9 +456,9 @@ absl::StatusOr> CreateCVPixelBufferCopyingImageFrame( } CVReturn cv_err; - ASSIGN_OR_RETURN(pixel_buffer, CreateCVPixelBufferWithoutPool( - image_frame.Width(), image_frame.Height(), - pixel_format)); + MP_ASSIGN_OR_RETURN(pixel_buffer, CreateCVPixelBufferWithoutPool( + image_frame.Width(), + image_frame.Height(), pixel_format)); cv_err = CVPixelBufferLockBaseAddress(*pixel_buffer, kCVPixelBufferLock_ReadOnly); RET_CHECK(cv_err == kCVReturnSuccess) diff --git a/mediapipe/tasks/cc/audio/audio_classifier/audio_classifier_graph.cc b/mediapipe/tasks/cc/audio/audio_classifier/audio_classifier_graph.cc index b15a23f32..2e4f9a6e3 100644 --- a/mediapipe/tasks/cc/audio/audio_classifier/audio_classifier_graph.cc +++ b/mediapipe/tasks/cc/audio/audio_classifier/audio_classifier_graph.cc @@ -91,7 +91,7 @@ absl::StatusOr BuildPreprocessingSpecs( } const auto* input_tensor = (*primary_subgraph->tensors())[(*primary_subgraph->inputs())[0]]; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* audio_tensor_metadata, GetAudioTensorMetadataIfAny(*model_resources.GetMetadataExtractor(), 0)); return BuildInputAudioTensorSpecs(*input_tensor, audio_tensor_metadata); @@ -154,11 +154,11 @@ class AudioClassifierGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_resources, CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildAudioClassificationTask( sc->Options(), *model_resources, @@ -202,8 +202,8 @@ class AudioClassifierGraph : public core::ModelTaskGraph { } // Adds AudioToTensorCalculator and connects it to the graph input streams. - ASSIGN_OR_RETURN(auto audio_tensor_specs, - BuildPreprocessingSpecs(model_resources)); + MP_ASSIGN_OR_RETURN(auto audio_tensor_specs, + BuildPreprocessingSpecs(model_resources)); auto& audio_to_tensor = graph.AddNode("AudioToTensorCalculator"); ConfigureAudioToTensorCalculator( audio_tensor_specs, use_stream_mode, diff --git a/mediapipe/tasks/cc/audio/audio_embedder/audio_embedder_graph.cc b/mediapipe/tasks/cc/audio/audio_embedder/audio_embedder_graph.cc index a9654947c..784cdc121 100644 --- a/mediapipe/tasks/cc/audio/audio_embedder/audio_embedder_graph.cc +++ b/mediapipe/tasks/cc/audio/audio_embedder/audio_embedder_graph.cc @@ -83,7 +83,7 @@ absl::StatusOr BuildPreprocessingSpecs( } const auto* input_tensor = (*primary_subgraph->tensors())[(*primary_subgraph->inputs())[0]]; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* audio_tensor_metadata, GetAudioTensorMetadataIfAny(*model_resources.GetMetadataExtractor(), 0)); return BuildInputAudioTensorSpecs(*input_tensor, audio_tensor_metadata); @@ -144,11 +144,11 @@ class AudioEmbedderGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_resources, CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildAudioEmbeddingTask( sc->Options(), *model_resources, @@ -178,8 +178,8 @@ class AudioEmbedderGraph : public core::ModelTaskGraph { MediaPipeTasksStatus::kMetadataNotFoundError); } // Adds AudioToTensorCalculator and connects it to the graph input streams. - ASSIGN_OR_RETURN(auto audio_tensor_specs, - BuildPreprocessingSpecs(model_resources)); + MP_ASSIGN_OR_RETURN(auto audio_tensor_specs, + BuildPreprocessingSpecs(model_resources)); auto& audio_to_tensor = graph.AddNode("AudioToTensorCalculator"); ConfigureAudioToTensorCalculator( audio_tensor_specs, use_stream_mode, diff --git a/mediapipe/tasks/cc/audio/core/audio_task_api_factory.h b/mediapipe/tasks/cc/audio/core/audio_task_api_factory.h index 901419a57..e5817f904 100644 --- a/mediapipe/tasks/cc/audio/core/audio_task_api_factory.h +++ b/mediapipe/tasks/cc/audio/core/audio_task_api_factory.h @@ -81,10 +81,10 @@ class AudioTaskApiFactory { "callback shouldn't be provided.", MediaPipeTasksStatus::kInvalidTaskGraphConfigError); } - ASSIGN_OR_RETURN(auto runner, - tasks::core::TaskRunner::Create( - std::move(graph_config), std::move(resolver), - std::move(packets_callback))); + MP_ASSIGN_OR_RETURN(auto runner, + tasks::core::TaskRunner::Create( + std::move(graph_config), std::move(resolver), + std::move(packets_callback))); return std::make_unique(std::move(runner), running_mode); } }; diff --git a/mediapipe/tasks/cc/audio/utils/audio_tensor_specs.cc b/mediapipe/tasks/cc/audio/utils/audio_tensor_specs.cc index 6765bc63c..29daac176 100644 --- a/mediapipe/tasks/cc/audio/utils/audio_tensor_specs.cc +++ b/mediapipe/tasks/cc/audio/utils/audio_tensor_specs.cc @@ -107,8 +107,8 @@ absl::StatusOr BuildInputAudioTensorSpecs( MediaPipeTasksStatus::kMetadataNotFoundError); } - ASSIGN_OR_RETURN(const AudioProperties* props, - GetAudioPropertiesIfAny(*audio_tensor_metadata)); + MP_ASSIGN_OR_RETURN(const AudioProperties* props, + GetAudioPropertiesIfAny(*audio_tensor_metadata)); // Input-related specifications. int tensor_shape_size = audio_tensor.shape()->size(); if (tensor_shape_size > 2) { diff --git a/mediapipe/tasks/cc/components/calculators/classification_aggregation_calculator_test.cc b/mediapipe/tasks/cc/components/calculators/classification_aggregation_calculator_test.cc index 4fb9eead5..80372cf58 100644 --- a/mediapipe/tasks/cc/components/calculators/classification_aggregation_calculator_test.cc +++ b/mediapipe/tasks/cc/components/calculators/classification_aggregation_calculator_test.cc @@ -98,13 +98,13 @@ class ClassificationAggregationCalculatorTest : public tflite::testing::Test { MP_RETURN_IF_ERROR(calculator_graph_.Initialize(graph.GetConfig())); if (connect_timestamps) { - ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( - kTimestampedClassificationsName)); + MP_ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( + kTimestampedClassificationsName)); MP_RETURN_IF_ERROR(calculator_graph_.StartRun(/*extra_side_packets=*/{})); return poller; } - ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( - kClassificationsName)); + MP_ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( + kClassificationsName)); MP_RETURN_IF_ERROR(calculator_graph_.StartRun(/*extra_side_packets=*/{})); return poller; } diff --git a/mediapipe/tasks/cc/components/calculators/embedding_aggregation_calculator_test.cc b/mediapipe/tasks/cc/components/calculators/embedding_aggregation_calculator_test.cc index 040a803a1..a2de5a492 100644 --- a/mediapipe/tasks/cc/components/calculators/embedding_aggregation_calculator_test.cc +++ b/mediapipe/tasks/cc/components/calculators/embedding_aggregation_calculator_test.cc @@ -74,13 +74,13 @@ class EmbeddingAggregationCalculatorTest : public tflite::testing::Test { MP_RETURN_IF_ERROR(calculator_graph_.Initialize(graph.GetConfig())); if (connect_timestamps) { - ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( - kTimestampedEmbeddingsName)); + MP_ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( + kTimestampedEmbeddingsName)); MP_RETURN_IF_ERROR(calculator_graph_.StartRun(/*extra_side_packets=*/{})); return poller; } - ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( - kEmbeddingsOutName)); + MP_ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( + kEmbeddingsOutName)); MP_RETURN_IF_ERROR(calculator_graph_.StartRun(/*extra_side_packets=*/{})); return poller; } diff --git a/mediapipe/tasks/cc/components/calculators/score_calibration_calculator.cc b/mediapipe/tasks/cc/components/calculators/score_calibration_calculator.cc index c689cc255..24f1db7f6 100644 --- a/mediapipe/tasks/cc/components/calculators/score_calibration_calculator.cc +++ b/mediapipe/tasks/cc/components/calculators/score_calibration_calculator.cc @@ -178,9 +178,9 @@ absl::Status ScoreCalibrationCalculator::Process(CalculatorContext* cc) { for (int i = 0; i < num_scores; ++i) { // Use the "safe" flavor as we need to check that the externally provided // indices are not out-of-bounds. - ASSIGN_OR_RETURN(raw_calibrated_scores[i], - SafeComputeCalibratedScore( - static_cast(raw_indices[i]), raw_scores[i])); + MP_ASSIGN_OR_RETURN(raw_calibrated_scores[i], + SafeComputeCalibratedScore( + static_cast(raw_indices[i]), raw_scores[i])); } } else { if (num_scores != options_.sigmoids_size()) { diff --git a/mediapipe/tasks/cc/components/processors/classification_postprocessing_graph.cc b/mediapipe/tasks/cc/components/processors/classification_postprocessing_graph.cc index 525b3d4e5..20d2924cd 100644 --- a/mediapipe/tasks/cc/components/processors/classification_postprocessing_graph.cc +++ b/mediapipe/tasks/cc/components/processors/classification_postprocessing_graph.cc @@ -180,16 +180,17 @@ absl::StatusOr GetLabelItemsIfAny( LabelItems empty_label_items; return empty_label_items; } - ASSIGN_OR_RETURN(absl::string_view labels_file, - metadata_extractor.GetAssociatedFile(labels_filename)); + MP_ASSIGN_OR_RETURN(absl::string_view labels_file, + metadata_extractor.GetAssociatedFile(labels_filename)); const std::string display_names_filename = ModelMetadataExtractor::FindFirstAssociatedFileName( tensor_metadata, tflite::AssociatedFileType_TENSOR_AXIS_LABELS, locale); absl::string_view display_names_file; if (!display_names_filename.empty()) { - ASSIGN_OR_RETURN(display_names_file, metadata_extractor.GetAssociatedFile( - display_names_filename)); + MP_ASSIGN_OR_RETURN( + display_names_file, + metadata_extractor.GetAssociatedFile(display_names_filename)); } return mediapipe::BuildLabelMapFromFiles(labels_file, display_names_file); } @@ -199,10 +200,10 @@ absl::StatusOr GetLabelItemsIfAny( absl::StatusOr GetScoreThreshold( const ModelMetadataExtractor& metadata_extractor, const TensorMetadata& tensor_metadata) { - ASSIGN_OR_RETURN(const ProcessUnit* score_thresholding_process_unit, - metadata_extractor.FindFirstProcessUnit( - tensor_metadata, - tflite::ProcessUnitOptions_ScoreThresholdingOptions)); + MP_ASSIGN_OR_RETURN(const ProcessUnit* score_thresholding_process_unit, + metadata_extractor.FindFirstProcessUnit( + tensor_metadata, + tflite::ProcessUnitOptions_ScoreThresholdingOptions)); if (score_thresholding_process_unit == nullptr) { return kDefaultScoreThreshold; } @@ -255,10 +256,10 @@ absl::Status ConfigureScoreCalibrationIfAny( return absl::OkStatus(); } // Get ScoreCalibrationOptions, if any. - ASSIGN_OR_RETURN(const ProcessUnit* score_calibration_process_unit, - metadata_extractor.FindFirstProcessUnit( - *tensor_metadata, - tflite::ProcessUnitOptions_ScoreCalibrationOptions)); + MP_ASSIGN_OR_RETURN(const ProcessUnit* score_calibration_process_unit, + metadata_extractor.FindFirstProcessUnit( + *tensor_metadata, + tflite::ProcessUnitOptions_ScoreCalibrationOptions)); if (score_calibration_process_unit == nullptr) { return absl::OkStatus(); } @@ -276,7 +277,7 @@ absl::Status ConfigureScoreCalibrationIfAny( "parameters file with type TENSOR_AXIS_SCORE_CALIBRATION.", MediaPipeTasksStatus::kMetadataAssociatedFileNotFoundError); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( absl::string_view score_calibration_file, metadata_extractor.GetAssociatedFile(score_calibration_filename)); ScoreCalibrationCalculatorOptions calculator_options; @@ -317,15 +318,15 @@ absl::Status ConfigureTensorsToClassificationCalculator( LabelItems label_items; float score_threshold = kDefaultScoreThreshold; if (tensor_metadata != nullptr) { - ASSIGN_OR_RETURN(label_items, - GetLabelItemsIfAny(metadata_extractor, *tensor_metadata, - options.display_names_locale())); - ASSIGN_OR_RETURN(score_threshold, - GetScoreThreshold(metadata_extractor, *tensor_metadata)); + MP_ASSIGN_OR_RETURN(label_items, + GetLabelItemsIfAny(metadata_extractor, *tensor_metadata, + options.display_names_locale())); + MP_ASSIGN_OR_RETURN(score_threshold, GetScoreThreshold(metadata_extractor, + *tensor_metadata)); } // Allowlist / denylist. - ASSIGN_OR_RETURN(auto allow_or_deny_categories, - GetAllowOrDenyCategoryIndicesIfAny(options, label_items)); + MP_ASSIGN_OR_RETURN(auto allow_or_deny_categories, + GetAllowOrDenyCategoryIndicesIfAny(options, label_items)); if (!allow_or_deny_categories.empty()) { if (options.category_allowlist_size()) { calculator_options->mutable_allow_classes()->Assign( @@ -359,8 +360,8 @@ absl::Status ConfigureClassificationPostprocessingGraph( const proto::ClassifierOptions& classifier_options, proto::ClassificationPostprocessingGraphOptions* options) { MP_RETURN_IF_ERROR(SanityCheckClassifierOptions(classifier_options)); - ASSIGN_OR_RETURN(const auto heads_properties, - GetClassificationHeadsProperties(model_resources)); + MP_ASSIGN_OR_RETURN(const auto heads_properties, + GetClassificationHeadsProperties(model_resources)); for (int i = 0; i < heads_properties.num_heads; ++i) { MP_RETURN_IF_ERROR(ConfigureScoreCalibrationIfAny( *model_resources.GetMetadataExtractor(), i, options)); @@ -406,7 +407,7 @@ class ClassificationPostprocessingGraph : public mediapipe::Subgraph { absl::StatusOr GetConfig( mediapipe::SubgraphContext* sc) override { Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildClassificationPostprocessing( sc->Options(), diff --git a/mediapipe/tasks/cc/components/processors/classification_postprocessing_graph_test.cc b/mediapipe/tasks/cc/components/processors/classification_postprocessing_graph_test.cc index 014053fa0..47135d2a4 100644 --- a/mediapipe/tasks/cc/components/processors/classification_postprocessing_graph_test.cc +++ b/mediapipe/tasks/cc/components/processors/classification_postprocessing_graph_test.cc @@ -422,8 +422,8 @@ class PostprocessingTest : public tflite::testing::Test { absl::StatusOr BuildGraph( absl::string_view model_name, const proto::ClassifierOptions& options, bool connect_timestamps = false) { - ASSIGN_OR_RETURN(auto model_resources, - CreateModelResourcesForModel(model_name)); + MP_ASSIGN_OR_RETURN(auto model_resources, + CreateModelResourcesForModel(model_name)); Graph graph; auto& postprocessing = graph.AddNode( @@ -450,13 +450,13 @@ class PostprocessingTest : public tflite::testing::Test { MP_RETURN_IF_ERROR(calculator_graph_.Initialize(graph.GetConfig())); if (connect_timestamps) { - ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( - kTimestampedClassificationsName)); + MP_ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( + kTimestampedClassificationsName)); MP_RETURN_IF_ERROR(calculator_graph_.StartRun(/*extra_side_packets=*/{})); return poller; } - ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( - kClassificationsName)); + MP_ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( + kClassificationsName)); MP_RETURN_IF_ERROR(calculator_graph_.StartRun(/*extra_side_packets=*/{})); return poller; } diff --git a/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph.cc b/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph.cc index 813a23aeb..fe24070a2 100644 --- a/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph.cc +++ b/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph.cc @@ -221,15 +221,16 @@ absl::StatusOr GetLabelItemsIfAny( LabelItems empty_label_items; return empty_label_items; } - ASSIGN_OR_RETURN(absl::string_view labels_file, - metadata_extractor.GetAssociatedFile(labels_filename)); + MP_ASSIGN_OR_RETURN(absl::string_view labels_file, + metadata_extractor.GetAssociatedFile(labels_filename)); const std::string display_names_filename = ModelMetadataExtractor::FindFirstAssociatedFileName( tensor_metadata, associated_file_type, locale); absl::string_view display_names_file; if (!display_names_filename.empty()) { - ASSIGN_OR_RETURN(display_names_file, metadata_extractor.GetAssociatedFile( - display_names_filename)); + MP_ASSIGN_OR_RETURN( + display_names_file, + metadata_extractor.GetAssociatedFile(display_names_filename)); } return mediapipe::BuildLabelMapFromFiles(labels_file, display_names_file); } @@ -237,7 +238,7 @@ absl::StatusOr GetLabelItemsIfAny( absl::StatusOr GetScoreThreshold( const ModelMetadataExtractor& metadata_extractor, const TensorMetadata& tensor_metadata) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const ProcessUnit* score_thresholding_process_unit, metadata_extractor.FindFirstProcessUnit( tensor_metadata, ProcessUnitOptions_ScoreThresholdingOptions)); @@ -288,7 +289,7 @@ GetScoreCalibrationOptionsIfAny( const ModelMetadataExtractor& metadata_extractor, const TensorMetadata& tensor_metadata) { // Get ScoreCalibrationOptions, if any. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const ProcessUnit* score_calibration_process_unit, metadata_extractor.FindFirstProcessUnit( tensor_metadata, tflite::ProcessUnitOptions_ScoreCalibrationOptions)); @@ -309,7 +310,7 @@ GetScoreCalibrationOptionsIfAny( "parameters file with type TENSOR_AXIS_SCORE_CALIBRATION.", MediaPipeTasksStatus::kMetadataAssociatedFileNotFoundError); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( absl::string_view score_calibration_file, metadata_extractor.GetAssociatedFile(score_calibration_filename)); ScoreCalibrationCalculatorOptions score_calibration_calculator_options; @@ -393,13 +394,13 @@ absl::StatusOr BuildPostProcessingSpecs( metadata_extractor->GetOutputTensorMetadata(); PostProcessingSpecs specs; specs.max_results = options.max_results(); - ASSIGN_OR_RETURN(specs.output_tensor_indices, - GetOutputTensorIndices(output_tensors_metadata)); + MP_ASSIGN_OR_RETURN(specs.output_tensor_indices, + GetOutputTensorIndices(output_tensors_metadata)); // Extracts mandatory BoundingBoxProperties and performs sanity checks on the // fly. - ASSIGN_OR_RETURN(const BoundingBoxProperties* bounding_box_properties, - GetBoundingBoxProperties(*output_tensors_metadata->Get( - specs.output_tensor_indices[0]))); + MP_ASSIGN_OR_RETURN(const BoundingBoxProperties* bounding_box_properties, + GetBoundingBoxProperties(*output_tensors_metadata->Get( + specs.output_tensor_indices[0]))); if (bounding_box_properties->index() == nullptr) { specs.bounding_box_corners_order = {0, 1, 2, 3}; } else { @@ -415,7 +416,7 @@ absl::StatusOr BuildPostProcessingSpecs( // For models with in-model-nms, the label map is stored in the Category // tensor which use TENSOR_VALUE_LABELS. For models with out-of-model-nms, the // label map is stored in the Score tensor which use TENSOR_AXIS_LABELS. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( specs.label_items, GetLabelItemsIfAny( *metadata_extractor, @@ -425,7 +426,7 @@ absl::StatusOr BuildPostProcessingSpecs( options.display_names_locale())); // Obtains allow/deny categories. specs.is_allowlist = !options.category_allowlist().empty(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( specs.allow_or_deny_categories, GetAllowOrDenyCategoryIndicesIfAny(options, specs.label_items)); @@ -433,7 +434,7 @@ absl::StatusOr BuildPostProcessingSpecs( if (options.has_score_threshold()) { specs.score_threshold = options.score_threshold(); } else { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( specs.score_threshold, GetScoreThreshold( *metadata_extractor, @@ -444,7 +445,7 @@ absl::StatusOr BuildPostProcessingSpecs( } if (in_model_nms) { // Builds score calibration options (if available) from metadata. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( specs.score_calibration_options, GetScoreCalibrationOptionsIfAny( *metadata_extractor, @@ -741,9 +742,9 @@ absl::Status ConfigureDetectionPostprocessingGraph( const ModelMetadataExtractor* metadata_extractor = model_resources.GetMetadataExtractor(); if (in_model_nms) { - ASSIGN_OR_RETURN(auto post_processing_specs, - BuildInModelNmsPostProcessingSpecs(detector_options, - metadata_extractor)); + MP_ASSIGN_OR_RETURN(auto post_processing_specs, + BuildInModelNmsPostProcessingSpecs(detector_options, + metadata_extractor)); ConfigureInModelNmsTensorsToDetectionsCalculator( post_processing_specs, options.mutable_tensors_to_detections_options()); ConfigureDetectionLabelIdToTextCalculator( @@ -754,9 +755,9 @@ absl::Status ConfigureDetectionPostprocessingGraph( std::move(*post_processing_specs.score_calibration_options); } } else { - ASSIGN_OR_RETURN(auto post_processing_specs, - BuildOutModelNmsPostProcessingSpecs(detector_options, - metadata_extractor)); + MP_ASSIGN_OR_RETURN(auto post_processing_specs, + BuildOutModelNmsPostProcessingSpecs( + detector_options, metadata_extractor)); MP_RETURN_IF_ERROR(ConfigureOutModelNmsTensorsToDetectionsCalculator( metadata_extractor, post_processing_specs, options.mutable_tensors_to_detections_options())); @@ -795,7 +796,7 @@ class DetectionPostprocessingGraph : public mediapipe::Subgraph { absl::StatusOr GetConfig( mediapipe::SubgraphContext* sc) override { Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildDetectionPostprocessing( *sc->MutableOptions(), @@ -823,8 +824,8 @@ class DetectionPostprocessingGraph : public mediapipe::Subgraph { if (!graph_options.has_non_max_suppression_options()) { // Calculators to perform score calibration, if specified in the options. if (graph_options.has_score_calibration_options()) { - ASSIGN_OR_RETURN(tensors_in, - CalibrateScores(tensors_in, graph_options, graph)); + MP_ASSIGN_OR_RETURN(tensors_in, + CalibrateScores(tensors_in, graph_options, graph)); } // Calculator to convert output tensors to a detection proto vector. auto& tensors_to_detections = diff --git a/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph_test.cc b/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph_test.cc index 36aead0c1..5475182b7 100644 --- a/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph_test.cc +++ b/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph_test.cc @@ -318,8 +318,8 @@ class PostprocessingTest : public tflite::testing::Test { protected: absl::StatusOr BuildGraph( absl::string_view model_name, const proto::DetectorOptions& options) { - ASSIGN_OR_RETURN(auto model_resources, - CreateModelResourcesForModel(model_name)); + MP_ASSIGN_OR_RETURN(auto model_resources, + CreateModelResourcesForModel(model_name)); Graph graph; auto& postprocessing = graph.AddNode( @@ -335,8 +335,8 @@ class PostprocessingTest : public tflite::testing::Test { postprocessing.Out(kDetectionsTag).SetName(std::string(kDetectionsName)) >> graph[Output>(kDetectionsTag)]; MP_RETURN_IF_ERROR(calculator_graph_.Initialize(graph.GetConfig())); - ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( - std::string(kDetectionsName))); + MP_ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( + std::string(kDetectionsName))); MP_RETURN_IF_ERROR(calculator_graph_.StartRun(/*extra_side_packets=*/{})); return poller; } diff --git a/mediapipe/tasks/cc/components/processors/embedding_postprocessing_graph.cc b/mediapipe/tasks/cc/components/processors/embedding_postprocessing_graph.cc index ec28d6294..bfe253c27 100644 --- a/mediapipe/tasks/cc/components/processors/embedding_postprocessing_graph.cc +++ b/mediapipe/tasks/cc/components/processors/embedding_postprocessing_graph.cc @@ -151,13 +151,13 @@ absl::Status ConfigureEmbeddingPostprocessingGraph( const ModelResources& model_resources, const proto::EmbedderOptions& embedder_options, proto::EmbeddingPostprocessingGraphOptions* options) { - ASSIGN_OR_RETURN(bool has_quantized_outputs, - HasQuantizedOutputs(model_resources)); + MP_ASSIGN_OR_RETURN(bool has_quantized_outputs, + HasQuantizedOutputs(model_resources)); options->set_has_quantized_outputs(has_quantized_outputs); auto* tensors_to_embeddings_options = options->mutable_tensors_to_embeddings_options(); *tensors_to_embeddings_options->mutable_embedder_options() = embedder_options; - ASSIGN_OR_RETURN(auto head_names, GetHeadNames(model_resources)); + MP_ASSIGN_OR_RETURN(auto head_names, GetHeadNames(model_resources)); if (!head_names.empty()) { *tensors_to_embeddings_options->mutable_head_names() = {head_names.begin(), head_names.end()}; @@ -197,7 +197,7 @@ class EmbeddingPostprocessingGraph : public mediapipe::Subgraph { absl::StatusOr GetConfig( mediapipe::SubgraphContext* sc) override { Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildEmbeddingPostprocessing( sc->Options(), diff --git a/mediapipe/tasks/cc/components/processors/embedding_postprocessing_graph_test.cc b/mediapipe/tasks/cc/components/processors/embedding_postprocessing_graph_test.cc index 0f0710405..3de45a18f 100644 --- a/mediapipe/tasks/cc/components/processors/embedding_postprocessing_graph_test.cc +++ b/mediapipe/tasks/cc/components/processors/embedding_postprocessing_graph_test.cc @@ -159,8 +159,8 @@ class PostprocessingTest : public tflite::testing::Test { absl::string_view model_name, const proto::EmbedderOptions& options, bool connect_timestamps = false, const std::vector& ignored_head_names = {}) { - ASSIGN_OR_RETURN(auto model_resources, - CreateModelResourcesForModel(model_name)); + MP_ASSIGN_OR_RETURN(auto model_resources, + CreateModelResourcesForModel(model_name)); Graph graph; auto& postprocessing = graph.AddNode( @@ -192,13 +192,13 @@ class PostprocessingTest : public tflite::testing::Test { MP_RETURN_IF_ERROR(calculator_graph_.Initialize(graph.GetConfig())); if (connect_timestamps) { - ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( - kTimestampedEmbeddingsName)); + MP_ASSIGN_OR_RETURN(auto poller, calculator_graph_.AddOutputStreamPoller( + kTimestampedEmbeddingsName)); MP_RETURN_IF_ERROR(calculator_graph_.StartRun(/*extra_side_packets=*/{})); return poller; } - ASSIGN_OR_RETURN(auto poller, - calculator_graph_.AddOutputStreamPoller(kEmbeddingsName)); + MP_ASSIGN_OR_RETURN( + auto poller, calculator_graph_.AddOutputStreamPoller(kEmbeddingsName)); MP_RETURN_IF_ERROR(calculator_graph_.StartRun(/*extra_side_packets=*/{})); return poller; } diff --git a/mediapipe/tasks/cc/components/processors/image_preprocessing_graph.cc b/mediapipe/tasks/cc/components/processors/image_preprocessing_graph.cc index 1040701c4..645e14e77 100644 --- a/mediapipe/tasks/cc/components/processors/image_preprocessing_graph.cc +++ b/mediapipe/tasks/cc/components/processors/image_preprocessing_graph.cc @@ -125,8 +125,8 @@ bool DetermineImagePreprocessingGpuBackend( absl::Status ConfigureImagePreprocessingGraph( const ModelResources& model_resources, bool use_gpu, proto::ImagePreprocessingGraphOptions* options) { - ASSIGN_OR_RETURN(auto image_tensor_specs, - vision::BuildInputImageTensorSpecs(model_resources)); + MP_ASSIGN_OR_RETURN(auto image_tensor_specs, + vision::BuildInputImageTensorSpecs(model_resources)); MP_RETURN_IF_ERROR(ConfigureImageToTensorCalculator( image_tensor_specs, options->mutable_image_to_tensor_options())); // The GPU backend isn't able to process int data. If the input tensor is diff --git a/mediapipe/tasks/cc/components/processors/text_preprocessing_graph.cc b/mediapipe/tasks/cc/components/processors/text_preprocessing_graph.cc index ecf59e2d1..2b5fce5b0 100644 --- a/mediapipe/tasks/cc/components/processors/text_preprocessing_graph.cc +++ b/mediapipe/tasks/cc/components/processors/text_preprocessing_graph.cc @@ -180,8 +180,8 @@ absl::Status ConfigureTextPreprocessingGraph( MediaPipeTasksStatus::kInvalidArgumentError); } - ASSIGN_OR_RETURN(TextModelType::ModelType model_type, - GetModelType(model_resources)); + MP_ASSIGN_OR_RETURN(TextModelType::ModelType model_type, + GetModelType(model_resources)); const tflite::SubGraph& model_graph = *(*model_resources.GetTfLiteModel()->subgraphs())[0]; options.set_model_type(model_type); @@ -193,13 +193,13 @@ absl::Status ConfigureTextPreprocessingGraph( } case TextModelType::BERT_MODEL: case TextModelType::REGEX_MODEL: { - ASSIGN_OR_RETURN(int max_seq_len, GetMaxSeqLen(model_graph)); + MP_ASSIGN_OR_RETURN(int max_seq_len, GetMaxSeqLen(model_graph)); options.set_max_seq_len(max_seq_len); } } if (model_type == TextModelType::BERT_MODEL) { - ASSIGN_OR_RETURN(bool has_dynamic_input_tensors, - HasDynamicInputTensors(model_graph)); + MP_ASSIGN_OR_RETURN(bool has_dynamic_input_tensors, + HasDynamicInputTensors(model_graph)); options.set_has_dynamic_input_tensors(has_dynamic_input_tensors); } return absl::OkStatus(); @@ -227,7 +227,7 @@ class TextPreprocessingGraph : public mediapipe::Subgraph { absl::StatusOr GetConfig( mediapipe::SubgraphContext* sc) override { Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( Source> tensors_in, BuildTextPreprocessing( sc->Options(), @@ -242,8 +242,8 @@ class TextPreprocessingGraph : public mediapipe::Subgraph { absl::StatusOr>> BuildTextPreprocessing( const TextPreprocessingGraphOptions& options, Source text_in, SideSource metadata_extractor_in, Graph& graph) { - ASSIGN_OR_RETURN(std::string preprocessor_name, - GetCalculatorNameFromModelType(options.model_type())); + MP_ASSIGN_OR_RETURN(std::string preprocessor_name, + GetCalculatorNameFromModelType(options.model_type())); auto& text_preprocessor = graph.AddNode(preprocessor_name); switch (options.model_type()) { case TextModelType::UNSPECIFIED_MODEL: diff --git a/mediapipe/tasks/cc/core/external_file_handler.cc b/mediapipe/tasks/cc/core/external_file_handler.cc index af304c466..069b904e9 100644 --- a/mediapipe/tasks/cc/core/external_file_handler.cc +++ b/mediapipe/tasks/cc/core/external_file_handler.cc @@ -122,8 +122,8 @@ absl::Status ExternalFileHandler::MapExternalFile() { // Obtain file descriptor, offset and size. int fd = -1; if (!external_file_.file_name().empty()) { - ASSIGN_OR_RETURN(std::string file_name, - PathToResourceAsFile(external_file_.file_name())); + MP_ASSIGN_OR_RETURN(std::string file_name, + PathToResourceAsFile(external_file_.file_name())); owned_fd_ = open(file_name.c_str(), O_RDONLY | O_BINARY); if (owned_fd_ < 0) { const std::string error_message = absl::StrFormat( diff --git a/mediapipe/tasks/cc/core/model_asset_bundle_resources.cc b/mediapipe/tasks/cc/core/model_asset_bundle_resources.cc index 58b30630d..ae864632b 100644 --- a/mediapipe/tasks/cc/core/model_asset_bundle_resources.cc +++ b/mediapipe/tasks/cc/core/model_asset_bundle_resources.cc @@ -59,14 +59,14 @@ absl::Status ModelAssetBundleResources::ExtractFilesFromExternalFileProto() { if (model_asset_bundle_file_->has_file_name()) { // If the model asset bundle file name is a relative path, searches the file // in a platform-specific location and returns the absolute path on success. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( std::string path_to_resource, mediapipe::PathToResourceAsFile(model_asset_bundle_file_->file_name())); model_asset_bundle_file_->set_file_name(path_to_resource); } - ASSIGN_OR_RETURN(model_asset_bundle_file_handler_, - ExternalFileHandler::CreateFromExternalFile( - model_asset_bundle_file_.get())); + MP_ASSIGN_OR_RETURN(model_asset_bundle_file_handler_, + ExternalFileHandler::CreateFromExternalFile( + model_asset_bundle_file_.get())); const char* buffer_data = model_asset_bundle_file_handler_->GetFileContent().data(); size_t buffer_size = diff --git a/mediapipe/tasks/cc/core/model_resources.cc b/mediapipe/tasks/cc/core/model_resources.cc index 1a917f72f..4f1a9bb7c 100644 --- a/mediapipe/tasks/cc/core/model_resources.cc +++ b/mediapipe/tasks/cc/core/model_resources.cc @@ -110,12 +110,12 @@ absl::Status ModelResources::BuildModelFromExternalFileProto() { } else { // If the model file name is a relative path, searches the file in a // platform-specific location and returns the absolute path on success. - ASSIGN_OR_RETURN(std::string path_to_resource, - PathToResourceAsFile(model_file_->file_name())); + MP_ASSIGN_OR_RETURN(std::string path_to_resource, + PathToResourceAsFile(model_file_->file_name())); model_file_->set_file_name(path_to_resource); } } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( model_file_handler_, ExternalFileHandler::CreateFromExternalFile(model_file_.get())); const char* buffer_data = model_file_handler_->GetFileContent().data(); @@ -152,9 +152,9 @@ absl::Status ModelResources::BuildModelFromExternalFileProto() { model_packet_ = MakePacket( model.release(), [](tflite::FlatBufferModel* model) { delete model; }); - ASSIGN_OR_RETURN(auto model_metadata_extractor, - metadata::ModelMetadataExtractor::CreateFromModelBuffer( - buffer_data, buffer_size)); + MP_ASSIGN_OR_RETURN(auto model_metadata_extractor, + metadata::ModelMetadataExtractor::CreateFromModelBuffer( + buffer_data, buffer_size)); metadata_extractor_packet_ = PacketAdopting( std::move(model_metadata_extractor)); return absl::OkStatus(); diff --git a/mediapipe/tasks/cc/core/model_resources_calculator.cc b/mediapipe/tasks/cc/core/model_resources_calculator.cc index 8db35818c..39daa3b91 100644 --- a/mediapipe/tasks/cc/core/model_resources_calculator.cc +++ b/mediapipe/tasks/cc/core/model_resources_calculator.cc @@ -109,7 +109,7 @@ class ModelResourcesCalculator : public api2::Node { "ModelResourcesCacheService, and the CalculatorOptions has no " "'model_file' field to create a local ModelResources."); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( model_resources_, ModelResources::Create( "", std::make_unique(options.model_file()))); diff --git a/mediapipe/tasks/cc/core/model_task_graph.cc b/mediapipe/tasks/cc/core/model_task_graph.cc index a68d40ae0..b82a69718 100644 --- a/mediapipe/tasks/cc/core/model_task_graph.cc +++ b/mediapipe/tasks/cc/core/model_task_graph.cc @@ -92,8 +92,8 @@ class InferenceSubgraph : public Subgraph { absl::StatusOr GetConfig( SubgraphContext* sc) override { auto* subgraph_options = sc->MutableOptions(); - ASSIGN_OR_RETURN(auto inference_delegate, - DecideInferenceSettings(*subgraph_options)); + MP_ASSIGN_OR_RETURN(auto inference_delegate, + DecideInferenceSettings(*subgraph_options)); Graph graph; auto& model_resources_node = graph.AddNode("ModelResourcesCalculator"); auto& model_resources_opts = @@ -163,8 +163,8 @@ absl::StatusOr ModelTaskGraph::CreateModelResources( const std::string tag_suffix) { auto model_resources_cache_service = sc->Service(kModelResourcesCacheService); if (!model_resources_cache_service.IsAvailable()) { - ASSIGN_OR_RETURN(auto local_model_resource, - ModelResources::Create("", std::move(external_file))); + MP_ASSIGN_OR_RETURN(auto local_model_resource, + ModelResources::Create("", std::move(external_file))); ABSL_LOG(WARNING) << "A local ModelResources object is created. Please consider using " "ModelResourcesCacheService to cache the created ModelResources " @@ -172,14 +172,14 @@ absl::StatusOr ModelTaskGraph::CreateModelResources( local_model_resources_.push_back(std::move(local_model_resource)); return local_model_resources_.back().get(); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto op_resolver_packet, model_resources_cache_service.GetObject().GetGraphOpResolverPacket()); const std::string tag = absl::StrCat(CreateModelResourcesTag(sc->OriginalNode()), tag_suffix); - ASSIGN_OR_RETURN(auto model_resources, - ModelResources::Create(tag, std::move(external_file), - op_resolver_packet)); + MP_ASSIGN_OR_RETURN(auto model_resources, + ModelResources::Create(tag, std::move(external_file), + op_resolver_packet)); MP_RETURN_IF_ERROR( model_resources_cache_service.GetObject().AddModelResources( std::move(model_resources))); @@ -211,7 +211,7 @@ ModelTaskGraph::CreateModelAssetBundleResources( // bundle resources into the model resources service since the memory is // not owned by this model asset bundle resources. if (!model_resources_cache_service.IsAvailable() || has_file_pointer_meta) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto local_model_asset_bundle_resource, ModelAssetBundleResources::Create("", std::move(external_file))); if (!has_file_pointer_meta) { @@ -226,7 +226,7 @@ ModelTaskGraph::CreateModelAssetBundleResources( } const std::string tag = absl::StrCat( CreateModelAssetBundleResourcesTag(sc->OriginalNode()), tag_suffix); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto model_bundle_resources, ModelAssetBundleResources::Create(tag, std::move(external_file))); MP_RETURN_IF_ERROR( diff --git a/mediapipe/tasks/cc/core/task_api_factory.h b/mediapipe/tasks/cc/core/task_api_factory.h index 6f604dd4c..6291f361e 100644 --- a/mediapipe/tasks/cc/core/task_api_factory.h +++ b/mediapipe/tasks/cc/core/task_api_factory.h @@ -74,7 +74,7 @@ class TaskApiFactory { found_task_subgraph = true; } } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto runner, core::TaskRunner::Create(std::move(graph_config), std::move(resolver), std::move(packets_callback))); diff --git a/mediapipe/tasks/cc/core/task_runner.cc b/mediapipe/tasks/cc/core/task_runner.cc index d97c4e480..797dfa35f 100644 --- a/mediapipe/tasks/cc/core/task_runner.cc +++ b/mediapipe/tasks/cc/core/task_runner.cc @@ -202,7 +202,8 @@ absl::StatusOr TaskRunner::Process(PacketMap inputs) { "callback is provided.", MediaPipeTasksStatus::kRunnerApiCalledInWrongModeError); } - ASSIGN_OR_RETURN(auto input_timestamp, ValidateAndGetPacketTimestamp(inputs)); + MP_ASSIGN_OR_RETURN(auto input_timestamp, + ValidateAndGetPacketTimestamp(inputs)); // MediaPipe reports runtime errors through CalculatorGraph::WaitUntilIdle or // WaitUntilDone without indicating the exact packet timestamp. // To ensure that the TaskRunner::Process reports errors per invocation, @@ -264,7 +265,8 @@ absl::Status TaskRunner::Send(PacketMap inputs) { "callback is not provided.", MediaPipeTasksStatus::kRunnerApiCalledInWrongModeError); } - ASSIGN_OR_RETURN(auto input_timestamp, ValidateAndGetPacketTimestamp(inputs)); + MP_ASSIGN_OR_RETURN(auto input_timestamp, + ValidateAndGetPacketTimestamp(inputs)); if (!input_timestamp.IsAllowedInStream()) { return CreateStatusWithPayload( absl::StatusCode::kInvalidArgument, diff --git a/mediapipe/tasks/cc/metadata/utils/zip_utils.cc b/mediapipe/tasks/cc/metadata/utils/zip_utils.cc index b9dd784c4..f994d2826 100644 --- a/mediapipe/tasks/cc/metadata/utils/zip_utils.cc +++ b/mediapipe/tasks/cc/metadata/utils/zip_utils.cc @@ -141,7 +141,7 @@ absl::Status ExtractFilesfromZipFile( if (global_info.number_entry > 0) { int error = unzGoToFirstFile(zf); while (error == UNZ_OK) { - ASSIGN_OR_RETURN(auto zip_file_info, GetCurrentZipFileInfo(zf)); + MP_ASSIGN_OR_RETURN(auto zip_file_info, GetCurrentZipFileInfo(zf)); // Store result in map. (*files)[zip_file_info.name] = absl::string_view( buffer_data + zip_file_info.position, zip_file_info.size); diff --git a/mediapipe/tasks/cc/text/language_detector/language_detector.cc b/mediapipe/tasks/cc/text/language_detector/language_detector.cc index 476427729..fc4abfc89 100644 --- a/mediapipe/tasks/cc/text/language_detector/language_detector.cc +++ b/mediapipe/tasks/cc/text/language_detector/language_detector.cc @@ -112,7 +112,7 @@ absl::StatusOr> LanguageDetector::Create( absl::StatusOr LanguageDetector::Detect( absl::string_view text) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_packets, runner_->Process( {{kTextStreamName, MakePacket(std::string(text))}})); diff --git a/mediapipe/tasks/cc/text/text_classifier/text_classifier.cc b/mediapipe/tasks/cc/text/text_classifier/text_classifier.cc index 0ffd57ce8..bc1fb0455 100644 --- a/mediapipe/tasks/cc/text/text_classifier/text_classifier.cc +++ b/mediapipe/tasks/cc/text/text_classifier/text_classifier.cc @@ -91,7 +91,7 @@ absl::StatusOr> TextClassifier::Create( absl::StatusOr TextClassifier::Classify( absl::string_view text) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_packets, runner_->Process( {{kTextStreamName, MakePacket(std::string(text))}})); diff --git a/mediapipe/tasks/cc/text/text_classifier/text_classifier_graph.cc b/mediapipe/tasks/cc/text/text_classifier/text_classifier_graph.cc index bd032cdf2..4dbe7ec45 100644 --- a/mediapipe/tasks/cc/text/text_classifier/text_classifier_graph.cc +++ b/mediapipe/tasks/cc/text/text_classifier/text_classifier_graph.cc @@ -85,11 +85,11 @@ class TextClassifierGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const ModelResources* model_resources, CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto classifications, BuildTextClassifierTask( sc->Options(), *model_resources, diff --git a/mediapipe/tasks/cc/text/text_classifier/text_classifier_test_utils.cc b/mediapipe/tasks/cc/text/text_classifier/text_classifier_test_utils.cc index 0e3d8b895..57956d3bc 100644 --- a/mediapipe/tasks/cc/text/text_classifier/text_classifier_test_utils.cc +++ b/mediapipe/tasks/cc/text/text_classifier/text_classifier_test_utils.cc @@ -73,7 +73,7 @@ template >>> absl::Status PopulateTensor(const T* data, int num_elements, TfLiteTensor* tensor) { - ASSIGN_OR_RETURN(T * v, AssertAndReturnTypedTensor(tensor)); + MP_ASSIGN_OR_RETURN(T * v, AssertAndReturnTypedTensor(tensor)); size_t bytes = num_elements * sizeof(T); if (tensor->bytes != bytes) { return CreateStatusWithPayload( diff --git a/mediapipe/tasks/cc/text/text_embedder/text_embedder.cc b/mediapipe/tasks/cc/text/text_embedder/text_embedder.cc index aa98c1e27..a4560d6a2 100644 --- a/mediapipe/tasks/cc/text/text_embedder/text_embedder.cc +++ b/mediapipe/tasks/cc/text/text_embedder/text_embedder.cc @@ -87,7 +87,7 @@ absl::StatusOr> TextEmbedder::Create( } absl::StatusOr TextEmbedder::Embed(absl::string_view text) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_packets, runner_->Process( {{kTextInStreamName, MakePacket(std::string(text))}})); diff --git a/mediapipe/tasks/cc/text/text_embedder/text_embedder_graph.cc b/mediapipe/tasks/cc/text/text_embedder/text_embedder_graph.cc index d5bdda4ff..61cab6c92 100644 --- a/mediapipe/tasks/cc/text/text_embedder/text_embedder_graph.cc +++ b/mediapipe/tasks/cc/text/text_embedder/text_embedder_graph.cc @@ -88,10 +88,11 @@ class TextEmbedderGraph : public core::ModelTaskGraph { absl::StatusOr GetConfig( SubgraphContext* sc) override { ABSL_CHECK(sc != nullptr); - ASSIGN_OR_RETURN(const ModelResources* model_resources, - CreateModelResources(sc)); + MP_ASSIGN_OR_RETURN( + const ModelResources* model_resources, + CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( Source embedding_result_out, BuildTextEmbedderTask(sc->Options(), *model_resources, @@ -142,8 +143,8 @@ class TextEmbedderGraph : public core::ModelTaskGraph { // The UniversalSentenceEncoder model has an extraneous output head. std::vector filtered_head_names; - ASSIGN_OR_RETURN(TextModelType::ModelType model_type, - GetModelType(model_resources)); + MP_ASSIGN_OR_RETURN(TextModelType::ModelType model_type, + GetModelType(model_resources)); if (model_type == TextModelType::USE_MODEL) { postprocessing_options->mutable_tensors_to_embeddings_options() ->add_ignored_head_names(kUSEQueryTensorName); diff --git a/mediapipe/tasks/cc/text/tokenizers/tokenizer_utils.cc b/mediapipe/tasks/cc/text/tokenizers/tokenizer_utils.cc index 1c2faa677..0637ee93f 100644 --- a/mediapipe/tasks/cc/text/tokenizers/tokenizer_utils.cc +++ b/mediapipe/tasks/cc/text/tokenizers/tokenizer_utils.cc @@ -51,9 +51,9 @@ absl::StatusOr CheckAndLoadFirstAssociatedFile( "Invalid vocab_file from input process unit.", MediaPipeTasksStatus::kMetadataInvalidTokenizerError); } - ASSIGN_OR_RETURN(absl::string_view vocab_buffer, - metadata_extractor->GetAssociatedFile( - associated_files->Get(0)->name()->str())); + MP_ASSIGN_OR_RETURN(absl::string_view vocab_buffer, + metadata_extractor->GetAssociatedFile( + associated_files->Get(0)->name()->str())); return vocab_buffer; } } // namespace @@ -61,9 +61,9 @@ absl::StatusOr CheckAndLoadFirstAssociatedFile( absl::StatusOr> CreateRegexTokenizerFromOptions( const tflite::RegexTokenizerOptions* options, const metadata::ModelMetadataExtractor* metadata_extractor) { - ASSIGN_OR_RETURN(absl::string_view vocab_buffer, - CheckAndLoadFirstAssociatedFile(options->vocab_file(), - metadata_extractor)); + MP_ASSIGN_OR_RETURN(absl::string_view vocab_buffer, + CheckAndLoadFirstAssociatedFile(options->vocab_file(), + metadata_extractor)); if (options->delim_regex_pattern() == nullptr) { return CreateStatusWithPayload( absl::StatusCode::kInvalidArgument, @@ -108,9 +108,9 @@ absl::StatusOr> CreateTokenizerFromProcessUnit( case tflite::ProcessUnitOptions_BertTokenizerOptions: { const tflite::BertTokenizerOptions* options = tokenizer_process_unit->options_as(); - ASSIGN_OR_RETURN(absl::string_view vocab_buffer, - CheckAndLoadFirstAssociatedFile(options->vocab_file(), - metadata_extractor)); + MP_ASSIGN_OR_RETURN(absl::string_view vocab_buffer, + CheckAndLoadFirstAssociatedFile(options->vocab_file(), + metadata_extractor)); return std::make_unique(vocab_buffer.data(), vocab_buffer.size()); } @@ -118,9 +118,10 @@ absl::StatusOr> CreateTokenizerFromProcessUnit( const tflite::SentencePieceTokenizerOptions* options = tokenizer_process_unit ->options_as(); - ASSIGN_OR_RETURN(absl::string_view model_buffer, - CheckAndLoadFirstAssociatedFile( - options->sentencePiece_model(), metadata_extractor)); + MP_ASSIGN_OR_RETURN( + absl::string_view model_buffer, + CheckAndLoadFirstAssociatedFile(options->sentencePiece_model(), + metadata_extractor)); return std::make_unique(model_buffer.data(), model_buffer.size()); } diff --git a/mediapipe/tasks/cc/text/utils/text_model_utils_test.cc b/mediapipe/tasks/cc/text/utils/text_model_utils_test.cc index a0d9cf0c9..b290de75f 100644 --- a/mediapipe/tasks/cc/text/utils/text_model_utils_test.cc +++ b/mediapipe/tasks/cc/text/utils/text_model_utils_test.cc @@ -68,9 +68,10 @@ absl::StatusOr GetModelTypeFromFile( absl::string_view file_name) { auto model_file = std::make_unique(); model_file->set_file_name(GetFullPath(file_name)); - ASSIGN_OR_RETURN(auto model_resources, - ModelResources::Create(std::string(kTestModelResourcesTag), - std::move(model_file))); + MP_ASSIGN_OR_RETURN( + auto model_resources, + ModelResources::Create(std::string(kTestModelResourcesTag), + std::move(model_file))); return GetModelType(*model_resources); } diff --git a/mediapipe/tasks/cc/vision/core/vision_task_api_factory.h b/mediapipe/tasks/cc/vision/core/vision_task_api_factory.h index 48fc33848..a7e9465e7 100644 --- a/mediapipe/tasks/cc/vision/core/vision_task_api_factory.h +++ b/mediapipe/tasks/cc/vision/core/vision_task_api_factory.h @@ -81,10 +81,10 @@ class VisionTaskApiFactory { "callback shouldn't be provided.", MediaPipeTasksStatus::kInvalidTaskGraphConfigError); } - ASSIGN_OR_RETURN(auto runner, - tasks::core::TaskRunner::Create( - std::move(graph_config), std::move(resolver), - std::move(packets_callback))); + MP_ASSIGN_OR_RETURN(auto runner, + tasks::core::TaskRunner::Create( + std::move(graph_config), std::move(resolver), + std::move(packets_callback))); return std::make_unique(std::move(runner), running_mode); } }; diff --git a/mediapipe/tasks/cc/vision/face_detector/face_detector.cc b/mediapipe/tasks/cc/vision/face_detector/face_detector.cc index a21b6edcf..0fd58340d 100644 --- a/mediapipe/tasks/cc/vision/face_detector/face_detector.cc +++ b/mediapipe/tasks/cc/vision/face_detector/face_detector.cc @@ -136,10 +136,10 @@ absl::StatusOr> FaceDetector::Create( absl::StatusOr FaceDetector::Detect( mediapipe::Image image, std::optional image_processing_options) { - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, MakePacket(std::move(image))}, @@ -156,10 +156,10 @@ absl::StatusOr FaceDetector::Detect( absl::StatusOr FaceDetector::DetectForVideo( mediapipe::Image image, uint64_t timestamp_ms, std::optional image_processing_options) { - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessVideoData( {{kImageInStreamName, @@ -179,9 +179,9 @@ absl::StatusOr FaceDetector::DetectForVideo( absl::Status FaceDetector::DetectAsync( mediapipe::Image image, uint64_t timestamp_ms, std::optional image_processing_options) { - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); return SendLiveStreamData( {{kImageInStreamName, MakePacket(std::move(image)) diff --git a/mediapipe/tasks/cc/vision/face_detector/face_detector_graph.cc b/mediapipe/tasks/cc/vision/face_detector/face_detector_graph.cc index 2e5f7e416..9a36dec62 100644 --- a/mediapipe/tasks/cc/vision/face_detector/face_detector_graph.cc +++ b/mediapipe/tasks/cc/vision/face_detector/face_detector_graph.cc @@ -193,14 +193,14 @@ class FaceDetectorGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN(const auto* model_resources, - CreateModelResources(sc)); + MP_ASSIGN_OR_RETURN(const auto* model_resources, + CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN(auto outs, - BuildFaceDetectionSubgraph( - sc->Options(), - *model_resources, graph[Input(kImageTag)], - graph[Input(kNormRectTag)], graph)); + MP_ASSIGN_OR_RETURN(auto outs, + BuildFaceDetectionSubgraph( + sc->Options(), + *model_resources, graph[Input(kImageTag)], + graph[Input(kNormRectTag)], graph)); outs.face_detections >> graph.Out(kDetectionsTag).Cast>(); outs.face_rects >> diff --git a/mediapipe/tasks/cc/vision/face_geometry/calculators/geometry_pipeline_calculator.cc b/mediapipe/tasks/cc/vision/face_geometry/calculators/geometry_pipeline_calculator.cc index 9dead7289..5cbd6b011 100644 --- a/mediapipe/tasks/cc/vision/face_geometry/calculators/geometry_pipeline_calculator.cc +++ b/mediapipe/tasks/cc/vision/face_geometry/calculators/geometry_pipeline_calculator.cc @@ -148,7 +148,7 @@ class GeometryPipelineCalculator : public CalculatorBase { const auto& options = cc->Options(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( GeometryPipelineMetadata metadata, ReadMetadataFromFile(options.metadata_file()), _ << "Failed to read the geometry pipeline metadata from file!"); @@ -162,9 +162,9 @@ class GeometryPipelineCalculator : public CalculatorBase { MP_RETURN_IF_ERROR(ValidateEnvironment(environment)) << "Invalid environment!"; - ASSIGN_OR_RETURN(geometry_pipeline_, - CreateGeometryPipeline(environment, metadata), - _ << "Failed to create a geometry pipeline!"); + MP_ASSIGN_OR_RETURN(geometry_pipeline_, + CreateGeometryPipeline(environment, metadata), + _ << "Failed to create a geometry pipeline!"); return absl::OkStatus(); } @@ -192,7 +192,7 @@ class GeometryPipelineCalculator : public CalculatorBase { auto multi_face_geometry = absl::make_unique>(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( *multi_face_geometry, geometry_pipeline_->EstimateFaceGeometry( multi_face_landmarks, // @@ -215,7 +215,7 @@ class GeometryPipelineCalculator : public CalculatorBase { .Tag(kFaceLandmarksTag) .Get(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( std::vector multi_face_geometry, geometry_pipeline_->EstimateFaceGeometry( {face_landmarks}, // @@ -239,7 +239,7 @@ class GeometryPipelineCalculator : public CalculatorBase { private: static absl::StatusOr ReadMetadataFromFile( const core::proto::ExternalFile& metadata_file) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto file_handler, core::ExternalFileHandler::CreateFromExternalFile(&metadata_file)); diff --git a/mediapipe/tasks/cc/vision/face_geometry/face_geometry_from_landmarks_graph.cc b/mediapipe/tasks/cc/vision/face_geometry/face_geometry_from_landmarks_graph.cc index bf4006a94..af373c6e1 100644 --- a/mediapipe/tasks/cc/vision/face_geometry/face_geometry_from_landmarks_graph.cc +++ b/mediapipe/tasks/cc/vision/face_geometry/face_geometry_from_landmarks_graph.cc @@ -122,13 +122,13 @@ class FaceGeometryFromLandmarksGraph : public Subgraph { environment = std::make_optional<>( graph.SideIn(kEnvironmentTag).Cast()); } - ASSIGN_OR_RETURN(auto outs, - BuildFaceGeometryFromLandmarksGraph( - *sc->MutableOptions(), - graph.In(kFaceLandmarksTag) - .Cast>(), - graph.In(kImageSizeTag).Cast>(), - environment, graph)); + MP_ASSIGN_OR_RETURN( + auto outs, BuildFaceGeometryFromLandmarksGraph( + *sc->MutableOptions(), + graph.In(kFaceLandmarksTag) + .Cast>(), + graph.In(kImageSizeTag).Cast>(), + environment, graph)); outs.multi_face_geometry >> graph.Out(kFaceGeometryTag).Cast>(); return graph.GetConfig(); diff --git a/mediapipe/tasks/cc/vision/face_geometry/libs/geometry_pipeline.cc b/mediapipe/tasks/cc/vision/face_geometry/libs/geometry_pipeline.cc index 061f35f51..c092cc6af 100644 --- a/mediapipe/tasks/cc/vision/face_geometry/libs/geometry_pipeline.cc +++ b/mediapipe/tasks/cc/vision/face_geometry/libs/geometry_pipeline.cc @@ -143,9 +143,9 @@ class ScreenToMetricSpaceConverter { Eigen::Matrix3Xf intermediate_landmarks(screen_landmarks); ChangeHandedness(intermediate_landmarks); - ASSIGN_OR_RETURN(const float first_iteration_scale, - EstimateScale(intermediate_landmarks), - _ << "Failed to estimate first iteration scale!"); + MP_ASSIGN_OR_RETURN(const float first_iteration_scale, + EstimateScale(intermediate_landmarks), + _ << "Failed to estimate first iteration scale!"); // 2nd iteration: unproject XY using the scale from the 1st iteration. intermediate_landmarks = screen_landmarks; @@ -168,9 +168,9 @@ class ScreenToMetricSpaceConverter { canonical_metric_landmarks_.colwise().homogeneous()) .row(2); } - ASSIGN_OR_RETURN(const float second_iteration_scale, - EstimateScale(intermediate_landmarks), - _ << "Failed to estimate second iteration scale!"); + MP_ASSIGN_OR_RETURN(const float second_iteration_scale, + EstimateScale(intermediate_landmarks), + _ << "Failed to estimate second iteration scale!"); // Use the total scale to unproject the screen landmarks. const float total_scale = first_iteration_scale * second_iteration_scale; diff --git a/mediapipe/tasks/cc/vision/face_geometry/libs/procrustes_solver.cc b/mediapipe/tasks/cc/vision/face_geometry/libs/procrustes_solver.cc index f25507495..82ba4b8c5 100644 --- a/mediapipe/tasks/cc/vision/face_geometry/libs/procrustes_solver.cc +++ b/mediapipe/tasks/cc/vision/face_geometry/libs/procrustes_solver.cc @@ -171,7 +171,7 @@ class FloatPrecisionProcrustesSolver : public ProcrustesSolver { MP_RETURN_IF_ERROR(ComputeOptimalRotation( weighted_targets * centered_weighted_sources.transpose(), rotation)) << "Failed to compute the optimal rotation!"; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( float scale, ComputeOptimalScale(centered_weighted_sources, weighted_sources, weighted_targets, rotation), diff --git a/mediapipe/tasks/cc/vision/face_landmarker/face_blendshapes_graph.cc b/mediapipe/tasks/cc/vision/face_landmarker/face_blendshapes_graph.cc index 68b87bb6b..ead2c660c 100644 --- a/mediapipe/tasks/cc/vision/face_landmarker/face_blendshapes_graph.cc +++ b/mediapipe/tasks/cc/vision/face_landmarker/face_blendshapes_graph.cc @@ -264,10 +264,10 @@ Stream ConvertTensorToBlendshapes( class FaceBlendshapesGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig(SubgraphContext* sc) { - ASSIGN_OR_RETURN(const auto* model_resources, - CreateModelResources(sc)); + MP_ASSIGN_OR_RETURN(const auto* model_resources, + CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto face_blendshapes_outs, BuildFaceBlendshapesSubgraph( sc->Options(), *model_resources, diff --git a/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker.cc b/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker.cc index 88b0b5eb1..dba225f8f 100644 --- a/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker.cc +++ b/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker.cc @@ -193,10 +193,10 @@ absl::StatusOr> FaceLandmarker::Create( absl::StatusOr FaceLandmarker::Detect( mediapipe::Image image, std::optional image_processing_options) { - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, MakePacket(std::move(image))}, @@ -211,10 +211,10 @@ absl::StatusOr FaceLandmarker::Detect( absl::StatusOr FaceLandmarker::DetectForVideo( mediapipe::Image image, int64_t timestamp_ms, std::optional image_processing_options) { - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessVideoData( {{kImageInStreamName, @@ -232,9 +232,9 @@ absl::StatusOr FaceLandmarker::DetectForVideo( absl::Status FaceLandmarker::DetectAsync( mediapipe::Image image, int64_t timestamp_ms, std::optional image_processing_options) { - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); return SendLiveStreamData( {{kImageInStreamName, MakePacket(std::move(image)) diff --git a/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker_graph.cc b/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker_graph.cc index 57b56f4bb..20ead4de5 100644 --- a/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker_graph.cc +++ b/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker_graph.cc @@ -122,8 +122,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, auto* face_detector_graph_options = options->mutable_face_detector_graph_options(); if (!face_detector_graph_options->base_options().has_model_asset()) { - ASSIGN_OR_RETURN(const auto face_detector_file, - resources.GetFile(kFaceDetectorTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto face_detector_file, + resources.GetFile(kFaceDetectorTFLiteName)); SetExternalFile(face_detector_file, face_detector_graph_options->mutable_base_options() ->mutable_model_asset(), @@ -138,8 +138,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, options->mutable_face_landmarks_detector_graph_options(); if (!face_landmarks_detector_graph_options->base_options() .has_model_asset()) { - ASSIGN_OR_RETURN(const auto face_landmarks_detector_file, - resources.GetFile(kFaceLandmarksDetectorTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto face_landmarks_detector_file, + resources.GetFile(kFaceLandmarksDetectorTFLiteName)); SetExternalFile( face_landmarks_detector_file, face_landmarks_detector_graph_options->mutable_base_options() @@ -319,7 +319,7 @@ class FaceLandmarkerGraph : public core::ModelTaskGraph { if (sc->Options() .base_options() .has_model_asset()) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_asset_bundle_resources, CreateModelAssetBundleResources(sc)); // Copies the file content instead of passing the pointer of file in @@ -332,9 +332,9 @@ class FaceLandmarkerGraph : public core::ModelTaskGraph { if (output_geometry) { // Set the face geometry metadata file for // FaceGeometryFromLandmarksGraph. - ASSIGN_OR_RETURN(auto face_geometry_pipeline_metadata_file, - model_asset_bundle_resources->GetFile( - kFaceGeometryPipelineMetadataName)); + MP_ASSIGN_OR_RETURN(auto face_geometry_pipeline_metadata_file, + model_asset_bundle_resources->GetFile( + kFaceGeometryPipelineMetadataName)); SetExternalFile(face_geometry_pipeline_metadata_file, sc->MutableOptions() ->mutable_face_geometry_graph_options() @@ -365,7 +365,7 @@ class FaceLandmarkerGraph : public core::ModelTaskGraph { if (HasInput(sc->OriginalNode(), kNormRectTag)) { norm_rect_in = graph.In(kNormRectTag).Cast(); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto outs, BuildFaceLandmarkerGraph( *sc->MutableOptions(), diff --git a/mediapipe/tasks/cc/vision/face_landmarker/face_landmarks_detector_graph.cc b/mediapipe/tasks/cc/vision/face_landmarker/face_landmarks_detector_graph.cc index 20d241b97..50f482a4d 100644 --- a/mediapipe/tasks/cc/vision/face_landmarker/face_landmarks_detector_graph.cc +++ b/mediapipe/tasks/cc/vision/face_landmarker/face_landmarks_detector_graph.cc @@ -223,11 +223,11 @@ class SingleFaceLandmarksDetectorGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_resources, CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto outs, BuildSingleFaceLandmarksDetectorGraph( *sc->MutableOptions(), @@ -291,8 +291,8 @@ class SingleFaceLandmarksDetectorGraph : public core::ModelTaskGraph { // Decodes the landmark tensors into a list of landmarks, where the landmark // coordinates are normalized by the size of the input image to the model. - ASSIGN_OR_RETURN(auto image_tensor_specs, - vision::BuildInputImageTensorSpecs(model_resources)); + MP_ASSIGN_OR_RETURN(auto image_tensor_specs, + vision::BuildInputImageTensorSpecs(model_resources)); auto& tensors_to_face_landmarks = graph.AddNode( "mediapipe.tasks.vision.face_landmarker.TensorsToFaceLandmarksGraph"); ConfigureTensorsToFaceLandmarksGraph( @@ -497,7 +497,7 @@ class MultiFaceLandmarksDetectorGraph : public core::ModelTaskGraph { absl::StatusOr GetConfig( SubgraphContext* sc) override { Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto outs, BuildFaceLandmarksDetectorGraph( *sc->MutableOptions(), diff --git a/mediapipe/tasks/cc/vision/face_stylizer/calculators/tensors_to_image_calculator.cc b/mediapipe/tasks/cc/vision/face_stylizer/calculators/tensors_to_image_calculator.cc index 651b7efc3..6b67e43aa 100644 --- a/mediapipe/tasks/cc/vision/face_stylizer/calculators/tensors_to_image_calculator.cc +++ b/mediapipe/tasks/cc/vision/face_stylizer/calculators/tensors_to_image_calculator.cc @@ -232,10 +232,10 @@ absl::Status TensorsToImageCalculator::CpuProcess(CalculatorContext* cc) { CV_MAKETYPE(CV_32F, tensor_in_channels), const_cast(input_tensor.GetCpuReadView().buffer())); auto input_range = options_.input_tensor_float_range(); - ASSIGN_OR_RETURN(auto transform, - GetValueRangeTransformation( - input_range.min(), input_range.max(), - kOutputImageRangeMin, kOutputImageRangeMax)); + MP_ASSIGN_OR_RETURN(auto transform, + GetValueRangeTransformation( + input_range.min(), input_range.max(), + kOutputImageRangeMin, kOutputImageRangeMax)); tensor_matview.convertTo(output_matview, CV_MAKETYPE(CV_8U, tensor_in_channels), transform.scale, transform.offset); @@ -245,10 +245,10 @@ absl::Status TensorsToImageCalculator::CpuProcess(CalculatorContext* cc) { CV_MAKETYPE(CV_8U, tensor_in_channels), const_cast(input_tensor.GetCpuReadView().buffer())); auto input_range = options_.input_tensor_uint_range(); - ASSIGN_OR_RETURN(auto transform, - GetValueRangeTransformation( - input_range.min(), input_range.max(), - kOutputImageRangeMin, kOutputImageRangeMax)); + MP_ASSIGN_OR_RETURN(auto transform, + GetValueRangeTransformation( + input_range.min(), input_range.max(), + kOutputImageRangeMin, kOutputImageRangeMax)); tensor_matview.convertTo(output_matview, CV_MAKETYPE(CV_8U, tensor_in_channels), transform.scale, transform.offset); diff --git a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.cc b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.cc index 89ec8766b..7d4200b04 100644 --- a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.cc +++ b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer.cc @@ -137,9 +137,9 @@ absl::StatusOr> FaceStylizer::Stylize( 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( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, MakePacket(std::move(image))}, diff --git a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer_graph.cc b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer_graph.cc index 6a50dccc4..cc6d58581 100644 --- a/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer_graph.cc +++ b/mediapipe/tasks/cc/vision/face_stylizer/face_stylizer_graph.cc @@ -98,8 +98,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, options->mutable_face_landmarker_graph_options() ->mutable_face_detector_graph_options(); if (!face_detector_graph_options->base_options().has_model_asset()) { - ASSIGN_OR_RETURN(const auto face_detector_file, - resources.GetFile(kFaceDetectorTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto face_detector_file, + resources.GetFile(kFaceDetectorTFLiteName)); SetExternalFile(face_detector_file, face_detector_graph_options->mutable_base_options() ->mutable_model_asset(), @@ -113,8 +113,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, ->mutable_face_landmarks_detector_graph_options(); if (!face_landmarks_detector_graph_options->base_options() .has_model_asset()) { - ASSIGN_OR_RETURN(const auto face_landmarks_detector_file, - resources.GetFile(kFaceLandmarksDetectorTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto face_landmarks_detector_file, + resources.GetFile(kFaceLandmarksDetectorTFLiteName)); SetExternalFile( face_landmarks_detector_file, face_landmarks_detector_graph_options->mutable_base_options() @@ -128,8 +128,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, ->set_use_stream_mode(options->base_options().use_stream_mode()); if (face_stylizer_external_file) { - ASSIGN_OR_RETURN(const auto face_stylizer_file, - resources.GetFile(kFaceStylizerTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto face_stylizer_file, + resources.GetFile(kFaceStylizerTFLiteName)); SetExternalFile(face_stylizer_file, face_stylizer_external_file, is_copy); } return absl::OkStatus(); @@ -233,7 +233,7 @@ class FaceStylizerGraph : public core::ModelTaskGraph { bool output_alignment = HasOutput(sc->OriginalNode(), kFaceAlignmentTag); auto face_stylizer_external_file = absl::make_unique(); if (sc->Options().has_base_options()) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_asset_bundle_resources, CreateModelAssetBundleResources(sc)); // Copies the file content instead of passing the pointer of file in @@ -252,7 +252,7 @@ class FaceStylizerGraph : public core::ModelTaskGraph { MediaPipeTasksStatus::kInvalidArgumentError); } Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto face_landmark_lists, BuildFaceLandmarkerGraph( sc->MutableOptions() @@ -261,12 +261,12 @@ class FaceStylizerGraph : public core::ModelTaskGraph { graph[Input::Optional(kNormRectTag)], graph)); const ModelResources* face_stylizer_model_resources = nullptr; if (output_stylized) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_resources, CreateModelResources(sc, std::move(face_stylizer_external_file))); face_stylizer_model_resources = model_resources; } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildFaceStylizerGraph(sc->Options(), face_stylizer_model_resources, output_alignment, diff --git a/mediapipe/tasks/cc/vision/gesture_recognizer/calculators/handedness_to_matrix_calculator.cc b/mediapipe/tasks/cc/vision/gesture_recognizer/calculators/handedness_to_matrix_calculator.cc index c806d5895..1b0d282c8 100644 --- a/mediapipe/tasks/cc/vision/gesture_recognizer/calculators/handedness_to_matrix_calculator.cc +++ b/mediapipe/tasks/cc/vision/gesture_recognizer/calculators/handedness_to_matrix_calculator.cc @@ -42,7 +42,7 @@ constexpr char kHandednessMatrixTag[] = "HANDEDNESS_MATRIX"; absl::StatusOr> HandednessToMatrix( const mediapipe::ClassificationList& classification_list) { // Feature value is the probability that the hand is a right hand. - ASSIGN_OR_RETURN(float score, GetRightHandScore(classification_list)); + MP_ASSIGN_OR_RETURN(float score, GetRightHandScore(classification_list)); auto matrix = Matrix(1, 1); matrix(0, 0) = score; auto result = std::make_unique(); @@ -92,7 +92,7 @@ absl::Status HandednessToMatrixCalculator::Process(CalculatorContext* cc) { auto handedness = cc->Inputs().Tag(kHandednessTag).Get(); - ASSIGN_OR_RETURN(auto handedness_matrix, HandednessToMatrix(handedness)); + MP_ASSIGN_OR_RETURN(auto handedness_matrix, HandednessToMatrix(handedness)); cc->Outputs() .Tag(kHandednessMatrixTag) .Add(handedness_matrix.release(), cc->InputTimestamp()); diff --git a/mediapipe/tasks/cc/vision/gesture_recognizer/calculators/landmarks_to_matrix_calculator.cc b/mediapipe/tasks/cc/vision/gesture_recognizer/calculators/landmarks_to_matrix_calculator.cc index 624d8a822..ef2a5ef82 100644 --- a/mediapipe/tasks/cc/vision/gesture_recognizer/calculators/landmarks_to_matrix_calculator.cc +++ b/mediapipe/tasks/cc/vision/gesture_recognizer/calculators/landmarks_to_matrix_calculator.cc @@ -154,20 +154,20 @@ absl::Status ProcessLandmarks(LandmarkListT landmarks, CalculatorContext* cc) { !cc->Inputs().Tag(kImageSizeTag).IsEmpty()); const auto [width, height] = cc->Inputs().Tag(kImageSizeTag).Get>(); - ASSIGN_OR_RETURN(landmarks, - NormalizeLandmarkAspectRatio(landmarks, width, height)); + MP_ASSIGN_OR_RETURN(landmarks, + NormalizeLandmarkAspectRatio(landmarks, width, height)); } if (cc->Inputs().HasTag(kNormRectTag)) { RET_CHECK(!cc->Inputs().Tag(kNormRectTag).IsEmpty()); const auto rotation = cc->Inputs().Tag(kNormRectTag).Get().rotation(); - ASSIGN_OR_RETURN(landmarks, RotateLandmarks(landmarks, rotation)); + MP_ASSIGN_OR_RETURN(landmarks, RotateLandmarks(landmarks, rotation)); } const auto& options = cc->Options(); if (options.object_normalization()) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( landmarks, NormalizeObject(landmarks, options.object_normalization_origin_offset())); diff --git a/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer.cc b/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer.cc index f04d7d71a..76d558949 100644 --- a/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer.cc +++ b/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer.cc @@ -222,10 +222,10 @@ absl::StatusOr GestureRecognizer::Recognize( "GPU input images are currently not supported.", MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, MakePacket(std::move(image))}, @@ -258,10 +258,10 @@ absl::StatusOr GestureRecognizer::RecognizeForVideo( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessVideoData( {{kImageInStreamName, @@ -297,9 +297,9 @@ absl::Status GestureRecognizer::RecognizeAsync( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); return SendLiveStreamData( {{kImageInStreamName, MakePacket(std::move(image)) diff --git a/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer_graph.cc b/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer_graph.cc index 9550112bf..82074d8ac 100644 --- a/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer_graph.cc +++ b/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer_graph.cc @@ -92,8 +92,8 @@ struct GestureRecognizerOutputs { absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, GestureRecognizerGraphOptions* options, bool is_copy) { - ASSIGN_OR_RETURN(const auto hand_landmarker_file, - resources.GetFile(kHandLandmarkerBundleAssetName)); + MP_ASSIGN_OR_RETURN(const auto hand_landmarker_file, + resources.GetFile(kHandLandmarkerBundleAssetName)); auto* hand_landmarker_graph_options = options->mutable_hand_landmarker_graph_options(); SetExternalFile(hand_landmarker_file, @@ -106,8 +106,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, hand_landmarker_graph_options->mutable_base_options()->set_use_stream_mode( options->base_options().use_stream_mode()); - ASSIGN_OR_RETURN(const auto hand_gesture_recognizer_file, - resources.GetFile(kHandGestureRecognizerBundleAssetName)); + MP_ASSIGN_OR_RETURN(const auto hand_gesture_recognizer_file, + resources.GetFile(kHandGestureRecognizerBundleAssetName)); auto* hand_gesture_recognizer_graph_options = options->mutable_hand_gesture_recognizer_graph_options(); SetExternalFile(hand_gesture_recognizer_file, @@ -204,7 +204,7 @@ class GestureRecognizerGraph : public core::ModelTaskGraph { if (sc->Options() .base_options() .has_model_asset()) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_asset_bundle_resources, CreateModelAssetBundleResources(sc)); // When the model resources cache service is available, filling in @@ -216,7 +216,7 @@ class GestureRecognizerGraph : public core::ModelTaskGraph { !sc->Service(::mediapipe::tasks::core::kModelResourcesCacheService) .IsAvailable())); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto hand_gesture_recognition_output, BuildGestureRecognizerGraph( *sc->MutableOptions(), diff --git a/mediapipe/tasks/cc/vision/gesture_recognizer/hand_gesture_recognizer_graph.cc b/mediapipe/tasks/cc/vision/gesture_recognizer/hand_gesture_recognizer_graph.cc index fbe05b075..18d86f250 100644 --- a/mediapipe/tasks/cc/vision/gesture_recognizer/hand_gesture_recognizer_graph.cc +++ b/mediapipe/tasks/cc/vision/gesture_recognizer/hand_gesture_recognizer_graph.cc @@ -173,7 +173,7 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { if (sc->Options() .base_options() .has_model_asset()) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_asset_bundle_resources, CreateModelAssetBundleResources( sc)); @@ -186,18 +186,18 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { !sc->Service(::mediapipe::tasks::core::kModelResourcesCacheService) .IsAvailable())); } - ASSIGN_OR_RETURN(const auto sub_task_model_resources, - CreateSubTaskModelResources(sc)); + MP_ASSIGN_OR_RETURN(const auto sub_task_model_resources, + CreateSubTaskModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN(auto hand_gestures, - BuildGestureRecognizerGraph( - sc->Options(), - sub_task_model_resources, - graph[Input(kHandednessTag)], - graph[Input(kLandmarksTag)], - graph[Input(kWorldLandmarksTag)], - graph[Input>(kImageSizeTag)], - graph[Input(kNormRectTag)], graph)); + MP_ASSIGN_OR_RETURN(auto hand_gestures, + BuildGestureRecognizerGraph( + sc->Options(), + sub_task_model_resources, + graph[Input(kHandednessTag)], + graph[Input(kLandmarksTag)], + graph[Input(kWorldLandmarksTag)], + graph[Input>(kImageSizeTag)], + graph[Input(kNormRectTag)], graph)); hand_gestures >> graph[Output(kHandGesturesTag)]; return graph.GetConfig(); } @@ -207,8 +207,8 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, HandGestureRecognizerGraphOptions* options, bool is_copy) { - ASSIGN_OR_RETURN(const auto gesture_embedder_file, - resources.GetFile(kGestureEmbedderTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto gesture_embedder_file, + resources.GetFile(kGestureEmbedderTFLiteName)); auto* gesture_embedder_graph_options = options->mutable_gesture_embedder_graph_options(); SetExternalFile(gesture_embedder_file, @@ -219,8 +219,8 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { options->base_options(), gesture_embedder_graph_options->mutable_base_options()); - ASSIGN_OR_RETURN(const auto canned_gesture_classifier_file, - resources.GetFile(kCannedGestureClassifierTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto canned_gesture_classifier_file, + resources.GetFile(kCannedGestureClassifierTFLiteName)); auto* canned_gesture_classifier_graph_options = options->mutable_canned_gesture_classifier_graph_options(); SetExternalFile( @@ -260,7 +260,7 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { *options->mutable_gesture_embedder_graph_options() ->mutable_base_options() ->mutable_model_asset(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( sub_task_model_resources.gesture_embedder_model_resource, CreateModelResources(sc, std::make_unique( @@ -270,7 +270,7 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { *options->mutable_canned_gesture_classifier_graph_options() ->mutable_base_options() ->mutable_model_asset(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( sub_task_model_resources.canned_gesture_classifier_model_resource, CreateModelResources( sc, @@ -282,7 +282,7 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { *options->mutable_custom_gesture_classifier_graph_options() ->mutable_base_options() ->mutable_model_asset(); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( sub_task_model_resources.custom_gesture_classifier_model_resource, CreateModelResources( sc, @@ -374,7 +374,7 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { int classifier_nums = 0; // Inference for custom gesture classifier if it exists. if (has_custom_gesture_classifier) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto gesture_classification_list, GetGestureClassificationList( sub_task_model_resources.custom_gesture_classifier_model_resource, @@ -384,7 +384,7 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { } // Inference for canned gesture classifier. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto gesture_classification_list, GetGestureClassificationList( sub_task_model_resources.canned_gesture_classifier_model_resource, @@ -481,7 +481,7 @@ class MultipleHandGestureRecognizerGraph : public core::ModelTaskGraph { absl::StatusOr GetConfig( SubgraphContext* sc) override { Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto multi_hand_gestures, BuildMultiGestureRecognizerSubraph( sc->Options(), diff --git a/mediapipe/tasks/cc/vision/hand_detector/hand_detector_graph.cc b/mediapipe/tasks/cc/vision/hand_detector/hand_detector_graph.cc index 1b964c5d8..bed99856d 100644 --- a/mediapipe/tasks/cc/vision/hand_detector/hand_detector_graph.cc +++ b/mediapipe/tasks/cc/vision/hand_detector/hand_detector_graph.cc @@ -194,10 +194,10 @@ class HandDetectorGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN(const auto* model_resources, - CreateModelResources(sc)); + MP_ASSIGN_OR_RETURN(const auto* model_resources, + CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto hand_detection_outs, BuildHandDetectionSubgraph( sc->Options(), *model_resources, diff --git a/mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_association_calculator.cc b/mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_association_calculator.cc index 5cbd72c3b..53a359d22 100644 --- a/mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_association_calculator.cc +++ b/mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_association_calculator.cc @@ -97,7 +97,7 @@ class HandAssociationCalculator : public CalculatorBase { } absl::Status Process(CalculatorContext* cc) override { - ASSIGN_OR_RETURN(auto result, GetNonOverlappingElements(cc)); + MP_ASSIGN_OR_RETURN(auto result, GetNonOverlappingElements(cc)); auto output = std::make_unique>(std::move(result)); @@ -139,7 +139,7 @@ class HandAssociationCalculator : public CalculatorBase { } for (auto rect : input_stream.Get>()) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( bool is_overlapping, mediapipe::DoesRectOverlap(rect, result, options_.min_similarity_threshold())); diff --git a/mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_landmarks_deduplication_calculator.cc b/mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_landmarks_deduplication_calculator.cc index ced757546..78b06eec0 100644 --- a/mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_landmarks_deduplication_calculator.cc +++ b/mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_landmarks_deduplication_calculator.cc @@ -176,8 +176,9 @@ class HandDuplicatesFinder : public DuplicatesFinder { std::vector bounds; bounds.reserve(num); for (const NormalizedLandmarkList& list : multi_landmarks) { - ASSIGN_OR_RETURN(const float baseline_distance, - HandBaselineDistance(list, input_width, input_height)); + MP_ASSIGN_OR_RETURN( + const float baseline_distance, + HandBaselineDistance(list, input_width, input_height)); baseline_distances.push_back(baseline_distance); bounds.push_back(CalculateBound(list)); } @@ -194,9 +195,9 @@ class HandDuplicatesFinder : public DuplicatesFinder { std::max(stable_distance_i, stable_distance_j) * kAllowedBaselineDistanceRatio; - ASSIGN_OR_RETURN(const std::vector distances, - Distances(multi_landmarks[i], multi_landmarks[j], - input_width, input_height)); + MP_ASSIGN_OR_RETURN(const std::vector distances, + Distances(multi_landmarks[i], multi_landmarks[j], + input_width, input_height)); const int num_matched_landmarks = absl::c_count_if( distances, [&](float distance) { return distance < distance_threshold; }); @@ -254,9 +255,9 @@ absl::Status HandLandmarksDeduplicationCalculator::Process( std::unique_ptr duplicates_finder = CreateHandDuplicatesFinder(/*start_from_the_end=*/false); - ASSIGN_OR_RETURN(absl::flat_hash_set indices_to_remove, - duplicates_finder->FindDuplicates( - in_landmarks, image_size.first, image_size.second)); + MP_ASSIGN_OR_RETURN(absl::flat_hash_set indices_to_remove, + duplicates_finder->FindDuplicates( + in_landmarks, image_size.first, image_size.second)); if (indices_to_remove.empty()) { kOutLandmarks(cc).Send(kInLandmarks(cc)); @@ -267,12 +268,12 @@ absl::Status HandLandmarksDeduplicationCalculator::Process( std::vector out_landmarks; const int num = in_landmarks.size(); - ASSIGN_OR_RETURN(absl::optional> out_rois, - VerifyNumAndMaybeInitOutput(kInRois, cc, num)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(absl::optional> out_rois, + VerifyNumAndMaybeInitOutput(kInRois, cc, num)); + MP_ASSIGN_OR_RETURN( absl::optional> out_world_landmarks, VerifyNumAndMaybeInitOutput(kInWorldLandmarks, cc, num)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( absl::optional> out_classifications, VerifyNumAndMaybeInitOutput(kInClassifications, cc, num)); diff --git a/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarker.cc b/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarker.cc index 9190f4052..0124a0e54 100644 --- a/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarker.cc +++ b/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarker.cc @@ -185,10 +185,10 @@ absl::StatusOr HandLandmarker::Detect( "GPU input images are currently not supported.", MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, MakePacket(std::move(image))}, @@ -223,10 +223,10 @@ absl::StatusOr HandLandmarker::DetectForVideo( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessVideoData( {{kImageInStreamName, @@ -264,9 +264,9 @@ absl::Status HandLandmarker::DetectAsync( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); return SendLiveStreamData( {{kImageInStreamName, MakePacket(std::move(image)) diff --git a/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarker_graph.cc b/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarker_graph.cc index b051dc571..58a07b78f 100644 --- a/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarker_graph.cc +++ b/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarker_graph.cc @@ -96,8 +96,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, auto* hand_detector_graph_options = options->mutable_hand_detector_graph_options(); if (!hand_detector_graph_options->base_options().has_model_asset()) { - ASSIGN_OR_RETURN(const auto hand_detector_file, - resources.GetFile(kHandDetectorTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto hand_detector_file, + resources.GetFile(kHandDetectorTFLiteName)); SetExternalFile(hand_detector_file, hand_detector_graph_options->mutable_base_options() ->mutable_model_asset(), @@ -112,8 +112,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, options->mutable_hand_landmarks_detector_graph_options(); if (!hand_landmarks_detector_graph_options->base_options() .has_model_asset()) { - ASSIGN_OR_RETURN(const auto hand_landmarks_detector_file, - resources.GetFile(kHandLandmarksDetectorTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto hand_landmarks_detector_file, + resources.GetFile(kHandLandmarksDetectorTFLiteName)); SetExternalFile( hand_landmarks_detector_file, hand_landmarks_detector_graph_options->mutable_base_options() @@ -215,7 +215,7 @@ class HandLandmarkerGraph : public core::ModelTaskGraph { if (sc->Options() .base_options() .has_model_asset()) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_asset_bundle_resources, CreateModelAssetBundleResources(sc)); // Copies the file content instead of passing the pointer of file in @@ -231,7 +231,7 @@ class HandLandmarkerGraph : public core::ModelTaskGraph { if (HasInput(sc->OriginalNode(), kNormRectTag)) { norm_rect_in = graph.In(kNormRectTag).Cast(); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto hand_landmarker_outputs, BuildHandLandmarkerGraph(sc->Options(), image_in, norm_rect_in, graph)); diff --git a/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarks_detector_graph.cc b/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarks_detector_graph.cc index 51cbc9e89..1d4e1b2c1 100644 --- a/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarks_detector_graph.cc +++ b/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmarks_detector_graph.cc @@ -212,11 +212,11 @@ class SingleHandLandmarksDetectorGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_resources, CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto hand_landmark_detection_outs, BuildSingleHandLandmarksDetectorGraph( sc->Options(), *model_resources, @@ -269,8 +269,8 @@ class SingleHandLandmarksDetectorGraph : public core::ModelTaskGraph { hand_rect >> preprocessing.In("NORM_RECT"); auto image_size = preprocessing[Output>("IMAGE_SIZE")]; - ASSIGN_OR_RETURN(auto image_tensor_specs, - BuildInputImageTensorSpecs(model_resources)); + MP_ASSIGN_OR_RETURN(auto image_tensor_specs, + BuildInputImageTensorSpecs(model_resources)); auto& inference = AddInference( model_resources, subgraph_options.base_options().acceleration(), graph); @@ -462,7 +462,7 @@ class MultipleHandLandmarksDetectorGraph : public core::ModelTaskGraph { absl::StatusOr GetConfig( SubgraphContext* sc) override { Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto hand_landmark_detection_outputs, BuildHandLandmarksDetectorGraph( sc->Options(), diff --git a/mediapipe/tasks/cc/vision/image_classifier/image_classifier.cc b/mediapipe/tasks/cc/vision/image_classifier/image_classifier.cc index 5b885045b..c185af95c 100644 --- a/mediapipe/tasks/cc/vision/image_classifier/image_classifier.cc +++ b/mediapipe/tasks/cc/vision/image_classifier/image_classifier.cc @@ -155,9 +155,9 @@ absl::StatusOr ImageClassifier::Classify( "GPU input images are currently not supported.", MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, MakePacket(std::move(image))}, @@ -175,9 +175,9 @@ absl::StatusOr ImageClassifier::ClassifyForVideo( "GPU input images are currently not supported.", MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessVideoData( {{kImageInStreamName, @@ -199,8 +199,8 @@ absl::Status ImageClassifier::ClassifyAsync( "GPU input images are currently not supported.", MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image)); + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image)); return SendLiveStreamData( {{kImageInStreamName, MakePacket(std::move(image)) diff --git a/mediapipe/tasks/cc/vision/image_classifier/image_classifier_graph.cc b/mediapipe/tasks/cc/vision/image_classifier/image_classifier_graph.cc index 5e4363588..d05d91f4a 100644 --- a/mediapipe/tasks/cc/vision/image_classifier/image_classifier_graph.cc +++ b/mediapipe/tasks/cc/vision/image_classifier/image_classifier_graph.cc @@ -103,11 +103,11 @@ class ImageClassifierGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_resources, CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildImageClassificationTask( sc->Options(), *model_resources, diff --git a/mediapipe/tasks/cc/vision/image_embedder/image_embedder.cc b/mediapipe/tasks/cc/vision/image_embedder/image_embedder.cc index 53d7c7c9d..1528edfdc 100644 --- a/mediapipe/tasks/cc/vision/image_embedder/image_embedder.cc +++ b/mediapipe/tasks/cc/vision/image_embedder/image_embedder.cc @@ -150,9 +150,9 @@ absl::StatusOr ImageEmbedder::Embed( "GPU input images are currently not supported.", MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, MakePacket(std::move(image))}, @@ -171,9 +171,9 @@ absl::StatusOr ImageEmbedder::EmbedForVideo( "GPU input images are currently not supported.", MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessVideoData( {{kImageInStreamName, @@ -195,8 +195,8 @@ absl::Status ImageEmbedder::EmbedAsync( "GPU input images are currently not supported.", MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image)); + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image)); return SendLiveStreamData( {{kImageInStreamName, MakePacket(std::move(image)) diff --git a/mediapipe/tasks/cc/vision/image_embedder/image_embedder_graph.cc b/mediapipe/tasks/cc/vision/image_embedder/image_embedder_graph.cc index 61d546c7e..a2808830f 100644 --- a/mediapipe/tasks/cc/vision/image_embedder/image_embedder_graph.cc +++ b/mediapipe/tasks/cc/vision/image_embedder/image_embedder_graph.cc @@ -95,11 +95,11 @@ class ImageEmbedderGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_resources, CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildImageEmbedderTask( sc->Options(), *model_resources, diff --git a/mediapipe/tasks/cc/vision/image_generator/conditioned_image_graph.cc b/mediapipe/tasks/cc/vision/image_generator/conditioned_image_graph.cc index c85fe981c..7a0f69c2c 100644 --- a/mediapipe/tasks/cc/vision/image_generator/conditioned_image_graph.cc +++ b/mediapipe/tasks/cc/vision/image_generator/conditioned_image_graph.cc @@ -423,7 +423,7 @@ class ConditionedImageGraph : public core::ModelTaskGraph { "Conditioned type options is not set."); break; case proto::ConditionedImageGraphOptions::kFaceConditionTypeOptions: { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto face_landmarks_image, GetFaceLandmarksImage(conditioned_image, graph_options.face_condition_type_options(), @@ -431,14 +431,14 @@ class ConditionedImageGraph : public core::ModelTaskGraph { face_landmarks_image >> graph.Out(kImageTag); } break; case proto::ConditionedImageGraphOptions::kDepthConditionTypeOptions: { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto depth_image, GetDepthImage(conditioned_image, graph_options.depth_condition_type_options(), graph)); depth_image >> graph.Out(kImageTag); } break; case proto::ConditionedImageGraphOptions::kEdgeConditionTypeOptions: { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto edges_image, GetEdgeImage(conditioned_image, graph_options.edge_condition_type_options(), graph)); diff --git a/mediapipe/tasks/cc/vision/image_generator/image_generator.cc b/mediapipe/tasks/cc/vision/image_generator/image_generator.cc index e4464d84d..e10ccf0b1 100644 --- a/mediapipe/tasks/cc/vision/image_generator/image_generator.cc +++ b/mediapipe/tasks/cc/vision/image_generator/image_generator.cc @@ -278,9 +278,10 @@ absl::StatusOr> ImageGenerator::Create( std::unique_ptr image_generator_options, std::unique_ptr condition_options) { bool use_condition_image = condition_options != nullptr; - ASSIGN_OR_RETURN(auto options_proto_and_condition_index, - ConvertImageGeneratorGraphOptionsProto( - image_generator_options.get(), condition_options.get())); + MP_ASSIGN_OR_RETURN( + auto options_proto_and_condition_index, + ConvertImageGeneratorGraphOptionsProto(image_generator_options.get(), + condition_options.get())); std::unique_ptr options_proto_for_condition_image_graphs_container; if (use_condition_image) { @@ -289,7 +290,7 @@ absl::StatusOr> ImageGenerator::Create( options_proto_for_condition_image_graphs_container->CopyFrom( *options_proto_and_condition_index.options_proto); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto image_generator, (core::VisionTaskApiFactory::Create( @@ -303,7 +304,7 @@ absl::StatusOr> ImageGenerator::Create( if (use_condition_image) { image_generator->condition_type_index_ = std::move(options_proto_and_condition_index.condition_type_index); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( image_generator->condition_image_graphs_container_task_runner_, tasks::core::TaskRunner::Create( CreateConditionedImageGraphContainerConfig( @@ -322,7 +323,7 @@ absl::StatusOr ImageGenerator::CreateConditionImage( return absl::InvalidArgumentError( "The condition type is not created during initialization."); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_packets, condition_image_graphs_container_task_runner_->Process({ {std::string(kSourceConditionImageName), @@ -349,8 +350,8 @@ absl::StatusOr ImageGenerator::Generate( return absl::InvalidArgumentError( "ImageGenerator is created to use without conditioned image."); } - ASSIGN_OR_RETURN(auto plugin_model_image, - CreateConditionImage(condition_image, condition_type)); + MP_ASSIGN_OR_RETURN(auto plugin_model_image, + CreateConditionImage(condition_image, condition_type)); return RunIterations( prompt, iterations, seed, ConditionInputs{plugin_model_image, @@ -380,7 +381,7 @@ absl::StatusOr ImageGenerator::RunIterations( MakePacket(prompt).At(Timestamp(timestamp)); input_packets[std::string(kRandSeedName)] = MakePacket(rand_seed).At(Timestamp(timestamp)); - ASSIGN_OR_RETURN(output_packets, ProcessImageData(input_packets)); + MP_ASSIGN_OR_RETURN(output_packets, ProcessImageData(input_packets)); timestamp += 1; } result.generated_image = diff --git a/mediapipe/tasks/cc/vision/image_generator/image_generator_graph.cc b/mediapipe/tasks/cc/vision/image_generator/image_generator_graph.cc index efbfd86e9..0da31654d 100644 --- a/mediapipe/tasks/cc/vision/image_generator/image_generator_graph.cc +++ b/mediapipe/tasks/cc/vision/image_generator/image_generator_graph.cc @@ -167,7 +167,7 @@ class ControlPluginGraph : public core::ModelTaskGraph { image_frame >> image_to_tensor.In(kImageTag); // Create the plugin model resource. - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const core::ModelResources* plugin_model_resources, CreateModelResources( sc, @@ -238,8 +238,8 @@ class ImageGeneratorGraph : public core::ModelTaskGraph { if (subgraph_options->has_lora_weights_file()) { auto external_file = std::make_unique(); external_file->Swap(subgraph_options->mutable_lora_weights_file()); - ASSIGN_OR_RETURN(lora_resources, CreateModelAssetBundleResources( - sc, std::move(external_file))); + MP_ASSIGN_OR_RETURN(lora_resources, CreateModelAssetBundleResources( + sc, std::move(external_file))); } std::optional> condition_image; std::optional> select_condition_type; @@ -251,7 +251,7 @@ class ImageGeneratorGraph : public core::ModelTaskGraph { if (HasInput(sc->OriginalNode(), kShowResultTag)) { show_result = graph.In(kShowResultTag).Cast(); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto outputs, BuildImageGeneratorGraph( *sc->MutableOptions(), @@ -337,8 +337,8 @@ class ImageGeneratorGraph : public core::ModelTaskGraph { *options.mutable_lora_weights_layer_mapping(); for (const auto& file_path : (*lora_resources)->ListFiles()) { auto basename = file::Basename(file_path); - ASSIGN_OR_RETURN(auto file_content, - (*lora_resources)->GetFile(std::string(file_path))); + MP_ASSIGN_OR_RETURN(auto file_content, + (*lora_resources)->GetFile(std::string(file_path))); if (file_path == kMetadataFilename) { MP_RETURN_IF_ERROR( ParseLoraMetadataAndConfigOptions(file_content, options)); diff --git a/mediapipe/tasks/cc/vision/image_segmenter/calculators/segmentation_postprocessor_gl.cc b/mediapipe/tasks/cc/vision/image_segmenter/calculators/segmentation_postprocessor_gl.cc index b1791fc0a..1d76b74f8 100644 --- a/mediapipe/tasks/cc/vision/image_segmenter/calculators/segmentation_postprocessor_gl.cc +++ b/mediapipe/tasks/cc/vision/image_segmenter/calculators/segmentation_postprocessor_gl.cc @@ -500,9 +500,9 @@ SegmentationPostprocessorGl::GetSegmentationResultGpu( // If our Tensor is an SSBO, then it's also linearized, so we convert to a // kAligned 2d texture using a special converter and then proceed as before. GLuint ssbo_tex_id; - ASSIGN_OR_RETURN(ssbo_tex_id, - ssbo_to_texture_converter_.ConvertTensorToGlTexture( - tensor, width, height, num_outputs)); + MP_ASSIGN_OR_RETURN(ssbo_tex_id, + ssbo_to_texture_converter_.ConvertTensorToGlTexture( + tensor, width, height, num_outputs)); std::tie(input_width, input_height) = ssbo_to_texture_converter_.GetTextureSize(); #else diff --git a/mediapipe/tasks/cc/vision/image_segmenter/calculators/tensors_to_segmentation_calculator.cc b/mediapipe/tasks/cc/vision/image_segmenter/calculators/tensors_to_segmentation_calculator.cc index 810acd93a..d449bb123 100644 --- a/mediapipe/tasks/cc/vision/image_segmenter/calculators/tensors_to_segmentation_calculator.cc +++ b/mediapipe/tasks/cc/vision/image_segmenter/calculators/tensors_to_segmentation_calculator.cc @@ -363,8 +363,8 @@ absl::Status TensorsToSegmentationCalculator::Process( "Expect input tensor vector of size 1 or 2."); } const auto& input_tensor = *input_tensors.rbegin(); - ASSIGN_OR_RETURN(const Shape input_shape, - GetImageLikeTensorShape(input_tensor)); + MP_ASSIGN_OR_RETURN(const Shape input_shape, + GetImageLikeTensorShape(input_tensor)); // TODO: should use tensor signature to get the correct output // tensor. diff --git a/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter.cc b/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter.cc index 74d8047de..0657f93a0 100644 --- a/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter.cc +++ b/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter.cc @@ -209,7 +209,7 @@ absl::StatusOr> ImageSegmenter::Create( options->output_confidence_masks; image_segmenter.value()->output_category_mask_ = options->output_category_mask; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( (*image_segmenter)->labels_, GetLabelsFromGraphConfig((*image_segmenter)->runner_->GetGraphConfig())); return image_segmenter; @@ -234,11 +234,11 @@ absl::StatusOr ImageSegmenter::Segment( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect( - segmentation_options.image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect( + segmentation_options.image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, mediapipe::MakePacket(std::move(image))}, @@ -283,11 +283,11 @@ absl::StatusOr ImageSegmenter::SegmentForVideo( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect( - segmentation_options.image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect( + segmentation_options.image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessVideoData( {{kImageInStreamName, @@ -336,10 +336,10 @@ absl::Status ImageSegmenter::SegmentAsync( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect( - segmentation_options.image_processing_options, image, - /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect( + segmentation_options.image_processing_options, image, + /*roi_allowed=*/false)); return SendLiveStreamData( {{kImageInStreamName, MakePacket(std::move(image)) diff --git a/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter_graph.cc b/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter_graph.cc index b49f22ca0..a7af8e365 100644 --- a/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter_graph.cc +++ b/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter_graph.cc @@ -129,16 +129,17 @@ absl::StatusOr GetLabelItemsIfAny( LabelItems empty_label_items; return empty_label_items; } - ASSIGN_OR_RETURN(absl::string_view labels_file, - metadata_extractor.GetAssociatedFile(labels_filename)); + MP_ASSIGN_OR_RETURN(absl::string_view labels_file, + metadata_extractor.GetAssociatedFile(labels_filename)); const std::string display_names_filename = ModelMetadataExtractor::FindFirstAssociatedFileName( tensor_metadata, tflite::AssociatedFileType_TENSOR_AXIS_LABELS, locale); absl::string_view display_names_file; if (!display_names_filename.empty()) { - ASSIGN_OR_RETURN(display_names_file, metadata_extractor.GetAssociatedFile( - display_names_filename)); + MP_ASSIGN_OR_RETURN( + display_names_file, + metadata_extractor.GetAssociatedFile(display_names_filename)); } return mediapipe::BuildLabelMapFromFiles(labels_file, display_names_file); } @@ -196,7 +197,7 @@ absl::Status ConfigureTensorsToSegmentationCalculator( "Segmentation tflite models are assumed to have a single subgraph.", MediaPipeTasksStatus::kInvalidArgumentError); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( *options->mutable_label_items(), GetLabelItemsIfAny( *metadata_extractor, @@ -256,8 +257,8 @@ absl::StatusOr ConvertImageToTensors( Source image_in, Source norm_rect_in, bool use_gpu, bool is_hair_segmentation, const core::ModelResources& model_resources, Graph& graph) { - ASSIGN_OR_RETURN(const tflite::Tensor* tflite_input_tensor, - GetInputTensor(model_resources)); + MP_ASSIGN_OR_RETURN(const tflite::Tensor* tflite_input_tensor, + GetInputTensor(model_resources)); if (tflite_input_tensor->shape()->size() != 4) { return absl::InvalidArgumentError( absl::StrFormat("Expect segmentation model has input image tensor to " @@ -324,8 +325,8 @@ absl::StatusOr ConvertImageToTensors( // Convert image to mediapipe tensor. auto& tensor_converter = graph.AddNode("TensorConverterCalculator"); - ASSIGN_OR_RETURN(auto image_tensor_specs, - vision::BuildInputImageTensorSpecs(model_resources)); + MP_ASSIGN_OR_RETURN(auto image_tensor_specs, + vision::BuildInputImageTensorSpecs(model_resources)); ConfigureTensorConverterCalculator( image_tensor_specs, tensor_converter @@ -397,8 +398,8 @@ class ImageSegmenterGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( mediapipe::SubgraphContext* sc) override { - ASSIGN_OR_RETURN(const auto* model_resources, - CreateModelResources(sc)); + MP_ASSIGN_OR_RETURN(const auto* model_resources, + CreateModelResources(sc)); Graph graph; const auto& options = sc->Options(); // TODO: remove deprecated output type support. @@ -409,7 +410,7 @@ class ImageSegmenterGraph : public core::ModelTaskGraph { if (HasInput(sc->OriginalNode(), kOutputSizeTag)) { output_size = graph.In(kOutputSizeTag).Cast>(); } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildSegmentationTask( options, *model_resources, graph[Input(kImageTag)], @@ -514,7 +515,7 @@ class ImageSegmenterGraph : public core::ModelTaskGraph { is_hair_segmentation = true; } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto image_and_tensors, ConvertImageToTensors(image_in, norm_rect_in, use_gpu, is_hair_segmentation, model_resources, graph)); @@ -543,8 +544,8 @@ class ImageSegmenterGraph : public core::ModelTaskGraph { segmented_masks.push_back( Source(tensor_to_images[Output(kSegmentationTag)])); } else { - ASSIGN_OR_RETURN(const tflite::Tensor* output_tensor, - GetOutputTensor(model_resources)); + MP_ASSIGN_OR_RETURN(const tflite::Tensor* output_tensor, + GetOutputTensor(model_resources)); int segmentation_streams_num = *output_tensor->shape()->rbegin(); for (int i = 0; i < segmentation_streams_num; ++i) { segmented_masks.push_back(Source( @@ -561,8 +562,8 @@ class ImageSegmenterGraph : public core::ModelTaskGraph { } else { std::optional>> confidence_masks; if (output_confidence_masks_) { - ASSIGN_OR_RETURN(const tflite::Tensor* output_tensor, - GetOutputTensor(model_resources)); + MP_ASSIGN_OR_RETURN(const tflite::Tensor* output_tensor, + GetOutputTensor(model_resources)); int segmentation_streams_num = *output_tensor->shape()->rbegin(); confidence_masks = std::vector>(); confidence_masks->reserve(segmentation_streams_num); diff --git a/mediapipe/tasks/cc/vision/interactive_segmenter/interactive_segmenter.cc b/mediapipe/tasks/cc/vision/interactive_segmenter/interactive_segmenter.cc index 38bbf3baf..919087375 100644 --- a/mediapipe/tasks/cc/vision/interactive_segmenter/interactive_segmenter.cc +++ b/mediapipe/tasks/cc/vision/interactive_segmenter/interactive_segmenter.cc @@ -160,7 +160,7 @@ InteractiveSegmenter::Create( } std::unique_ptr options_proto = ConvertImageSegmenterOptionsToProto(options.get()); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( std::unique_ptr segmenter, (core::VisionTaskApiFactory::Create( @@ -184,11 +184,12 @@ absl::StatusOr InteractiveSegmenter::Segment( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN(RenderData roi_as_render_data, ConvertRoiToRenderData(roi)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN(RenderData roi_as_render_data, + ConvertRoiToRenderData(roi)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, mediapipe::MakePacket(std::move(image))}, diff --git a/mediapipe/tasks/cc/vision/object_detector/object_detector.cc b/mediapipe/tasks/cc/vision/object_detector/object_detector.cc index 152ee3273..5d0be785b 100644 --- a/mediapipe/tasks/cc/vision/object_detector/object_detector.cc +++ b/mediapipe/tasks/cc/vision/object_detector/object_detector.cc @@ -165,10 +165,10 @@ absl::StatusOr ObjectDetector::Detect( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, MakePacket(std::move(image))}, @@ -189,10 +189,10 @@ absl::StatusOr ObjectDetector::DetectForVideo( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessVideoData( {{kImageInStreamName, @@ -217,9 +217,9 @@ absl::Status ObjectDetector::DetectAsync( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); return SendLiveStreamData( {{kImageInStreamName, MakePacket(std::move(image)) diff --git a/mediapipe/tasks/cc/vision/object_detector/object_detector_graph.cc b/mediapipe/tasks/cc/vision/object_detector/object_detector_graph.cc index e2b374970..c7dfefa5c 100644 --- a/mediapipe/tasks/cc/vision/object_detector/object_detector_graph.cc +++ b/mediapipe/tasks/cc/vision/object_detector/object_detector_graph.cc @@ -131,10 +131,10 @@ class ObjectDetectorGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN(const auto* model_resources, - CreateModelResources(sc)); + MP_ASSIGN_OR_RETURN(const auto* model_resources, + CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto output_streams, BuildObjectDetectionTask( sc->Options(), *model_resources, diff --git a/mediapipe/tasks/cc/vision/pose_detector/pose_detector_graph.cc b/mediapipe/tasks/cc/vision/pose_detector/pose_detector_graph.cc index f1554f8df..08a2bebc1 100644 --- a/mediapipe/tasks/cc/vision/pose_detector/pose_detector_graph.cc +++ b/mediapipe/tasks/cc/vision/pose_detector/pose_detector_graph.cc @@ -207,14 +207,14 @@ class PoseDetectorGraph : public core::ModelTaskGraph { public: absl::StatusOr GetConfig( SubgraphContext* sc) override { - ASSIGN_OR_RETURN(const auto* model_resources, - CreateModelResources(sc)); + MP_ASSIGN_OR_RETURN(const auto* model_resources, + CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN(auto outs, - BuildPoseDetectionSubgraph( - sc->Options(), - *model_resources, graph[Input(kImageTag)], - graph[Input(kNormRectTag)], graph)); + MP_ASSIGN_OR_RETURN(auto outs, + BuildPoseDetectionSubgraph( + sc->Options(), + *model_resources, graph[Input(kImageTag)], + graph[Input(kNormRectTag)], graph)); outs.pose_detections >> graph.Out(kDetectionsTag).Cast>(); diff --git a/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker.cc b/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker.cc index 797e71488..f6726f22b 100644 --- a/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker.cc +++ b/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker.cc @@ -174,7 +174,7 @@ absl::StatusOr> PoseLandmarker::Create( kMicroSecondsPerMilliSecond); }; } - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( std::unique_ptr pose_landmarker, (core::VisionTaskApiFactory::Create( @@ -200,10 +200,10 @@ absl::StatusOr PoseLandmarker::Detect( "GPU input images are currently not supported.", MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessImageData( {{kImageInStreamName, MakePacket(std::move(image))}, @@ -237,10 +237,10 @@ absl::StatusOr PoseLandmarker::DetectForVideo( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN( auto output_packets, ProcessVideoData( {{kImageInStreamName, @@ -277,9 +277,9 @@ absl::Status PoseLandmarker::DetectAsync( absl::StrCat("GPU input images are currently not supported."), MediaPipeTasksStatus::kRunnerUnexpectedInputError); } - ASSIGN_OR_RETURN(NormalizedRect norm_rect, - ConvertToNormalizedRect(image_processing_options, image, - /*roi_allowed=*/false)); + MP_ASSIGN_OR_RETURN(NormalizedRect norm_rect, + ConvertToNormalizedRect(image_processing_options, image, + /*roi_allowed=*/false)); return SendLiveStreamData( {{kImageInStreamName, MakePacket(std::move(image)) diff --git a/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker_graph.cc b/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker_graph.cc index 413835b03..006d86642 100644 --- a/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker_graph.cc +++ b/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker_graph.cc @@ -95,8 +95,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, auto* pose_detector_graph_options = options->mutable_pose_detector_graph_options(); if (!pose_detector_graph_options->base_options().has_model_asset()) { - ASSIGN_OR_RETURN(const auto pose_detector_file, - resources.GetFile(kPoseDetectorTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto pose_detector_file, + resources.GetFile(kPoseDetectorTFLiteName)); SetExternalFile(pose_detector_file, pose_detector_graph_options->mutable_base_options() ->mutable_model_asset(), @@ -120,8 +120,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, options->mutable_pose_landmarks_detector_graph_options(); if (!pose_landmarks_detector_graph_options->base_options() .has_model_asset()) { - ASSIGN_OR_RETURN(const auto pose_landmarks_detector_file, - resources.GetFile(kPoseLandmarksDetectorTFLiteName)); + MP_ASSIGN_OR_RETURN(const auto pose_landmarks_detector_file, + resources.GetFile(kPoseLandmarksDetectorTFLiteName)); SetExternalFile( pose_landmarks_detector_file, pose_landmarks_detector_graph_options->mutable_base_options() @@ -220,7 +220,7 @@ class PoseLandmarkerGraph : public core::ModelTaskGraph { if (sc->Options() .base_options() .has_model_asset()) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_asset_bundle_resources, CreateModelAssetBundleResources(sc)); // Copies the file content instead of passing the pointer of file in @@ -231,12 +231,12 @@ class PoseLandmarkerGraph : public core::ModelTaskGraph { !sc->Service(::mediapipe::tasks::core::kModelResourcesCacheService) .IsAvailable())); } - ASSIGN_OR_RETURN(auto outs, - BuildPoseLandmarkerGraph( - *sc->MutableOptions(), - graph[Input(kImageTag)], - graph[Input::Optional(kNormRectTag)], - graph, output_segmentation_masks)); + MP_ASSIGN_OR_RETURN( + auto outs, BuildPoseLandmarkerGraph( + *sc->MutableOptions(), + graph[Input(kImageTag)], + graph[Input::Optional(kNormRectTag)], + graph, output_segmentation_masks)); outs.landmark_lists >> graph[Output>(kNormLandmarksTag)]; outs.world_landmark_lists >> diff --git a/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarks_detector_graph.cc b/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarks_detector_graph.cc index cc61aa212..547d06b1a 100644 --- a/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarks_detector_graph.cc +++ b/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarks_detector_graph.cc @@ -301,16 +301,17 @@ class SinglePoseLandmarksDetectorGraph : public core::ModelTaskGraph { SubgraphContext* sc) override { bool output_segmentation_mask = HasOutput(sc->OriginalNode(), kSegmentationMaskTag); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const auto* model_resources, CreateModelResources(sc)); Graph graph; - ASSIGN_OR_RETURN(auto pose_landmark_detection_outs, - BuildSinglePoseLandmarksDetectorGraph( - sc->Options(), - *model_resources, graph[Input(kImageTag)], - graph[Input::Optional(kNormRectTag)], - graph, output_segmentation_mask)); + MP_ASSIGN_OR_RETURN( + auto pose_landmark_detection_outs, + BuildSinglePoseLandmarksDetectorGraph( + sc->Options(), *model_resources, + graph[Input(kImageTag)], + graph[Input::Optional(kNormRectTag)], graph, + output_segmentation_mask)); pose_landmark_detection_outs.pose_landmarks >> graph[Output(kLandmarksTag)]; pose_landmark_detection_outs.world_pose_landmarks >> @@ -355,8 +356,8 @@ class SinglePoseLandmarksDetectorGraph : public core::ModelTaskGraph { auto matrix = preprocessing[Output>(kMatrixTag)]; auto letterbox_padding = preprocessing.Out(kLetterboxPaddingTag); - ASSIGN_OR_RETURN(auto image_tensor_specs, - BuildInputImageTensorSpecs(model_resources)); + MP_ASSIGN_OR_RETURN(auto image_tensor_specs, + BuildInputImageTensorSpecs(model_resources)); auto& inference = AddInference( model_resources, subgraph_options.base_options().acceleration(), graph); @@ -653,7 +654,7 @@ class MultiplePoseLandmarksDetectorGraph : public core::ModelTaskGraph { Graph graph; bool output_segmentation_masks = HasOutput(sc->OriginalNode(), kSegmentationMaskTag); - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( auto pose_landmark_detection_outputs, BuildPoseLandmarksDetectorGraph( sc->Options(), diff --git a/mediapipe/tasks/cc/vision/utils/image_tensor_specs.cc b/mediapipe/tasks/cc/vision/utils/image_tensor_specs.cc index 690cd6e5c..a13785493 100644 --- a/mediapipe/tasks/cc/vision/utils/image_tensor_specs.cc +++ b/mediapipe/tasks/cc/vision/utils/image_tensor_specs.cc @@ -72,7 +72,7 @@ absl::StatusOr GetImagePropertiesIfAny( absl::StatusOr> GetNormalizationOptionsIfAny(const TensorMetadata& tensor_metadata) { - ASSIGN_OR_RETURN( + MP_ASSIGN_OR_RETURN( const tflite::ProcessUnit* normalization_process_unit, ModelMetadataExtractor::FindFirstProcessUnit( tensor_metadata, tflite::ProcessUnitOptions_NormalizationOptions)); @@ -145,9 +145,9 @@ absl::StatusOr BuildInputImageTensorSpecs( const ImageProperties* props = nullptr; absl::optional normalization_options; if (image_tensor_metadata != nullptr) { - ASSIGN_OR_RETURN(props, GetImagePropertiesIfAny(*image_tensor_metadata)); - ASSIGN_OR_RETURN(normalization_options, - GetNormalizationOptionsIfAny(*image_tensor_metadata)); + MP_ASSIGN_OR_RETURN(props, GetImagePropertiesIfAny(*image_tensor_metadata)); + MP_ASSIGN_OR_RETURN(normalization_options, + GetNormalizationOptionsIfAny(*image_tensor_metadata)); } // Input-related specifications. @@ -258,9 +258,9 @@ absl::StatusOr BuildInputImageTensorSpecs( } const auto* input_tensor = (*primary_subgraph->tensors())[(*primary_subgraph->inputs())[0]]; - ASSIGN_OR_RETURN(const auto* image_tensor_metadata, - vision::GetImageTensorMetadataIfAny( - *model_resources.GetMetadataExtractor(), 0)); + MP_ASSIGN_OR_RETURN(const auto* image_tensor_metadata, + vision::GetImageTensorMetadataIfAny( + *model_resources.GetMetadataExtractor(), 0)); return vision::BuildInputImageTensorSpecs(*input_tensor, image_tensor_metadata); } diff --git a/mediapipe/util/frame_buffer/frame_buffer_util.cc b/mediapipe/util/frame_buffer/frame_buffer_util.cc index fa0ea9094..9e81d8582 100644 --- a/mediapipe/util/frame_buffer/frame_buffer_util.cc +++ b/mediapipe/util/frame_buffer/frame_buffer_util.cc @@ -244,7 +244,7 @@ absl::Status ValidateFloatTensorInputs(const FrameBuffer& buffer, if (shape.dims.size() != 4 || shape.dims[0] != 1) { return absl::InvalidArgumentError("Expected tensor with batch size of 1."); } - ASSIGN_OR_RETURN(int channels, NumberOfChannels(buffer)); + MP_ASSIGN_OR_RETURN(int channels, NumberOfChannels(buffer)); if (shape.dims[2] != buffer.dimension().width || shape.dims[1] != buffer.dimension().height || shape.dims[3] != channels) { return absl::InvalidArgumentError( @@ -260,8 +260,8 @@ absl::Status ValidateFloatTensorInputs(const FrameBuffer& buffer, // output YuvBuffer is agnostic to the YUV format since the YUV buffers are // managed individually. absl::StatusOr CreateYuvBuffer(const FrameBuffer& buffer) { - ASSIGN_OR_RETURN(FrameBuffer::YuvData yuv_data, - FrameBuffer::GetYuvDataFromFrameBuffer(buffer)); + MP_ASSIGN_OR_RETURN(FrameBuffer::YuvData yuv_data, + FrameBuffer::GetYuvDataFromFrameBuffer(buffer)); return YuvBuffer(const_cast(yuv_data.y_buffer), const_cast(yuv_data.u_buffer), const_cast(yuv_data.v_buffer), @@ -293,8 +293,8 @@ absl::StatusOr CreateRgbBuffer(const FrameBuffer& buffer) { absl::Status CropGrayscale(const FrameBuffer& buffer, int x0, int y0, int x1, int y1, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); bool success_crop = input.Crop(x0, y0, x1, y1); if (!success_crop) { return absl::UnknownError("Halide grayscale crop operation failed."); @@ -308,8 +308,8 @@ absl::Status CropGrayscale(const FrameBuffer& buffer, int x0, int y0, int x1, absl::Status ResizeGrayscale(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); return input.Resize(&output) ? absl::OkStatus() : absl::UnknownError("Halide grayscale resize operation failed."); @@ -317,8 +317,8 @@ absl::Status ResizeGrayscale(const FrameBuffer& buffer, absl::Status RotateGrayscale(const FrameBuffer& buffer, int angle_deg, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); return input.Rotate(angle_deg % 360, &output) ? absl::OkStatus() : absl::UnknownError("Halide grayscale rotate operation failed."); @@ -326,8 +326,8 @@ absl::Status RotateGrayscale(const FrameBuffer& buffer, int angle_deg, absl::Status FlipHorizontallyGrayscale(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); return input.FlipHorizontally(&output) ? absl::OkStatus() : absl::UnknownError( @@ -336,8 +336,8 @@ absl::Status FlipHorizontallyGrayscale(const FrameBuffer& buffer, absl::Status FlipVerticallyGrayscale(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateGrayBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); return input.FlipVertically(&output) ? absl::OkStatus() : absl::UnknownError( @@ -348,25 +348,25 @@ absl::Status FlipVerticallyGrayscale(const FrameBuffer& buffer, //------------------------------------------------------------------------------ absl::Status ResizeRgb(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); return input.Resize(&output) ? absl::OkStatus() : absl::UnknownError("Halide rgb[a] resize operation failed."); } absl::Status ConvertRgb(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); bool result = false; if (output_buffer->format() == FrameBuffer::Format::kGRAY) { - ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateGrayBuffer(*output_buffer)); result = input.Convert(&output); } else if (IsSupportedYuvBuffer(*output_buffer)) { - ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); result = input.Convert(&output); } else if (output_buffer->format() == FrameBuffer::Format::kRGBA || output_buffer->format() == FrameBuffer::Format::kRGB) { - ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); result = input.Convert(&output); } return result ? absl::OkStatus() @@ -375,8 +375,8 @@ absl::Status ConvertRgb(const FrameBuffer& buffer, FrameBuffer* output_buffer) { absl::Status CropRgb(const FrameBuffer& buffer, int x0, int y0, int x1, int y1, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); bool success_crop = input.Crop(x0, y0, x1, y1); if (!success_crop) { return absl::UnknownError("Halide rgb[a] crop operation failed."); @@ -390,8 +390,8 @@ absl::Status CropRgb(const FrameBuffer& buffer, int x0, int y0, int x1, int y1, absl::Status FlipHorizontallyRgb(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); return input.FlipHorizontally(&output) ? absl::OkStatus() : absl::UnknownError( @@ -400,8 +400,8 @@ absl::Status FlipHorizontallyRgb(const FrameBuffer& buffer, absl::Status FlipVerticallyRgb(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); return input.FlipVertically(&output) ? absl::OkStatus() : absl::UnknownError( @@ -410,8 +410,8 @@ absl::Status FlipVerticallyRgb(const FrameBuffer& buffer, absl::Status RotateRgb(const FrameBuffer& buffer, int angle, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); return input.Rotate(angle % 360, &output) ? absl::OkStatus() : absl::UnknownError("Halide rgb[a] rotate operation failed."); @@ -419,8 +419,8 @@ absl::Status RotateRgb(const FrameBuffer& buffer, int angle, absl::Status ToFloatTensorRgb(const FrameBuffer& buffer, float scale, float offset, Tensor& tensor) { - ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); - ASSIGN_OR_RETURN(int channels, NumberOfChannels(buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateRgbBuffer(buffer)); + MP_ASSIGN_OR_RETURN(int channels, NumberOfChannels(buffer)); auto view = tensor.GetCpuWriteView(); float* data = view.buffer(); FloatBuffer output(data, buffer.dimension().width, buffer.dimension().height, @@ -435,8 +435,8 @@ absl::Status ToFloatTensorRgb(const FrameBuffer& buffer, float scale, absl::Status CropYuv(const FrameBuffer& buffer, int x0, int y0, int x1, int y1, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); bool success_crop = input.Crop(x0, y0, x1, y1); if (!success_crop) { return absl::UnknownError("Halide YUV crop operation failed."); @@ -449,8 +449,8 @@ absl::Status CropYuv(const FrameBuffer& buffer, int x0, int y0, int x1, int y1, } absl::Status ResizeYuv(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); return input.Resize(&output) ? absl::OkStatus() : absl::UnknownError("Halide YUV resize operation failed."); @@ -458,8 +458,8 @@ absl::Status ResizeYuv(const FrameBuffer& buffer, FrameBuffer* output_buffer) { absl::Status RotateYuv(const FrameBuffer& buffer, int angle_deg, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); return input.Rotate(angle_deg % 360, &output) ? absl::OkStatus() : absl::UnknownError("Halide YUV rotate operation failed."); @@ -467,8 +467,8 @@ absl::Status RotateYuv(const FrameBuffer& buffer, int angle_deg, absl::Status FlipHorizontallyYuv(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); return input.FlipHorizontally(&output) ? absl::OkStatus() : absl::UnknownError( @@ -477,8 +477,8 @@ absl::Status FlipHorizontallyYuv(const FrameBuffer& buffer, absl::Status FlipVerticallyYuv(const FrameBuffer& buffer, FrameBuffer* output_buffer) { - ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); - ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); return input.FlipVertically(&output) ? absl::OkStatus() : absl::UnknownError("Halide YUV vertical flip operation failed."); @@ -488,10 +488,10 @@ absl::Status FlipVerticallyYuv(const FrameBuffer& buffer, // scale format. absl::Status ConvertYuv(const FrameBuffer& buffer, FrameBuffer* output_buffer) { bool success_convert = false; - ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); + MP_ASSIGN_OR_RETURN(auto input, CreateYuvBuffer(buffer)); if (output_buffer->format() == FrameBuffer::Format::kRGBA || output_buffer->format() == FrameBuffer::Format::kRGB) { - ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateRgbBuffer(*output_buffer)); bool half_sampling = false; if (buffer.dimension().width / 2 == output_buffer->dimension().width && buffer.dimension().height / 2 == output_buffer->dimension().height) { @@ -517,7 +517,7 @@ absl::Status ConvertYuv(const FrameBuffer& buffer, FrameBuffer* output_buffer) { } success_convert = true; } else if (IsSupportedYuvBuffer(*output_buffer)) { - ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); + MP_ASSIGN_OR_RETURN(auto output, CreateYuvBuffer(*output_buffer)); success_convert = input.Resize(&output); } return success_convert @@ -607,8 +607,8 @@ absl::StatusOr> CreateFromRawBuffer( return std::make_shared(planes, dimension, target_format); } case FrameBuffer::Format::kYV12: { - ASSIGN_OR_RETURN(const FrameBuffer::Dimension uv_dimension, - GetUvPlaneDimension(dimension, target_format)); + MP_ASSIGN_OR_RETURN(const FrameBuffer::Dimension uv_dimension, + GetUvPlaneDimension(dimension, target_format)); return CreateFromYuvRawBuffer( /*y_plane=*/buffer, /*u_plane=*/buffer + dimension.Size() + uv_dimension.Size(), @@ -617,8 +617,8 @@ absl::StatusOr> CreateFromRawBuffer( /*pixel_stride_uv=*/1); } case FrameBuffer::Format::kYV21: { - ASSIGN_OR_RETURN(const FrameBuffer::Dimension uv_dimension, - GetUvPlaneDimension(dimension, target_format)); + MP_ASSIGN_OR_RETURN(const FrameBuffer::Dimension uv_dimension, + GetUvPlaneDimension(dimension, target_format)); return CreateFromYuvRawBuffer( /*y_plane=*/buffer, /*u_plane=*/buffer + dimension.Size(), /*v_plane=*/buffer + dimension.Size() + uv_dimension.Size(), @@ -820,8 +820,8 @@ absl::StatusOr GetUvRawBuffer(const FrameBuffer& buffer) { return absl::InvalidArgumentError( "Only support getting biplanar UV buffer from NV12/NV21 frame buffer."); } - ASSIGN_OR_RETURN(FrameBuffer::YuvData yuv_data, - FrameBuffer::GetYuvDataFromFrameBuffer(buffer)); + MP_ASSIGN_OR_RETURN(FrameBuffer::YuvData yuv_data, + FrameBuffer::GetYuvDataFromFrameBuffer(buffer)); const uint8_t* uv_buffer = buffer.format() == FrameBuffer::Format::kNV12 ? yuv_data.u_buffer : yuv_data.v_buffer; diff --git a/mediapipe/util/frame_buffer/frame_buffer_util_test.cc b/mediapipe/util/frame_buffer/frame_buffer_util_test.cc index aed03962b..d839e8617 100644 --- a/mediapipe/util/frame_buffer/frame_buffer_util_test.cc +++ b/mediapipe/util/frame_buffer/frame_buffer_util_test.cc @@ -786,7 +786,8 @@ absl::StatusOr> CreateYuvBuffer( uint8_t* buffer, FrameBuffer::Dimension dimension, int plane_count, FrameBuffer::Format format) { ABSL_DCHECK(plane_count > 0 && plane_count < 4); - ASSIGN_OR_RETURN(auto uv_dimension, GetUvPlaneDimension(dimension, format)); + MP_ASSIGN_OR_RETURN(auto uv_dimension, + GetUvPlaneDimension(dimension, format)); if (plane_count == 1) { const std::vector planes = { diff --git a/mediapipe/util/rectangle_util.cc b/mediapipe/util/rectangle_util.cc index 938501404..ab46a9240 100644 --- a/mediapipe/util/rectangle_util.cc +++ b/mediapipe/util/rectangle_util.cc @@ -45,11 +45,11 @@ absl::StatusOr DoesRectOverlap( const mediapipe::NormalizedRect& new_rect, absl::Span existing_rects, float min_similarity_threshold) { - ASSIGN_OR_RETURN(Rectangle_f new_rectangle, ToRectangle(new_rect)); + MP_ASSIGN_OR_RETURN(Rectangle_f new_rectangle, ToRectangle(new_rect)); for (const mediapipe::NormalizedRect& existing_rect : existing_rects) { - ASSIGN_OR_RETURN(Rectangle_f existing_rectangle, - ToRectangle(existing_rect)); + MP_ASSIGN_OR_RETURN(Rectangle_f existing_rectangle, + ToRectangle(existing_rect)); if (CalculateIou(existing_rectangle, new_rectangle) > min_similarity_threshold) { return true; diff --git a/mediapipe/util/resource_util_apple.cc b/mediapipe/util/resource_util_apple.cc index d6ca2c36a..b78be3582 100644 --- a/mediapipe/util/resource_util_apple.cc +++ b/mediapipe/util/resource_util_apple.cc @@ -50,7 +50,7 @@ absl::Status DefaultGetResourceContents(const std::string& path, ABSL_LOG(WARNING) << "Setting \"read_as_binary\" to false is a no-op on ios."; } - ASSIGN_OR_RETURN(std::string full_path, PathToResourceAsFile(path)); + MP_ASSIGN_OR_RETURN(std::string full_path, PathToResourceAsFile(path)); return file::GetContents(full_path, output, read_as_binary); } } // namespace internal diff --git a/mediapipe/util/tflite/tflite_gpu_runner.cc b/mediapipe/util/tflite/tflite_gpu_runner.cc index 6a132ac6a..642fb71fb 100644 --- a/mediapipe/util/tflite/tflite_gpu_runner.cc +++ b/mediapipe/util/tflite/tflite_gpu_runner.cc @@ -237,7 +237,7 @@ absl::Status TFLiteGPURunner::InitializeOpenCL( if (serialized_model_.empty() && opencl_init_from_serialized_model_is_forced_) { - ASSIGN_OR_RETURN(serialized_model_, GetSerializedModel()); + MP_ASSIGN_OR_RETURN(serialized_model_, GetSerializedModel()); } // Try to initialize from serialized model first. diff --git a/mediapipe/util/tflite/tflite_model_loader.cc b/mediapipe/util/tflite/tflite_model_loader.cc index a2a3cc2be..766543f9c 100644 --- a/mediapipe/util/tflite/tflite_model_loader.cc +++ b/mediapipe/util/tflite/tflite_model_loader.cc @@ -31,8 +31,8 @@ absl::StatusOr> TfLiteModelLoader::LoadFromPath( // TODO: get rid of manual resolving with PathToResourceAsFile // as soon as it's incorporated into GetResourceContents. if (!status_or_content.ok()) { - ASSIGN_OR_RETURN(auto resolved_path, - mediapipe::PathToResourceAsFile(model_path)); + MP_ASSIGN_OR_RETURN(auto resolved_path, + mediapipe::PathToResourceAsFile(model_path)); VLOG(2) << "Loading the model from " << resolved_path; MP_RETURN_IF_ERROR( mediapipe::GetResourceContents(resolved_path, &model_blob));