From c92570f844a262bfdf4dca52416018fbc0c6d135 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Wed, 30 Aug 2023 13:41:21 -0700 Subject: [PATCH] Use ABSL_LOG in MediaPipe. This is needed in Chrome builds to avoid collisions with its own LOG. PiperOrigin-RevId: 561436864 --- docs/getting_started/hello_world_cpp.md | 4 +- mediapipe/calculators/audio/BUILD | 4 +- .../rational_factor_resample_calculator.cc | 3 +- .../rational_factor_resample_calculator.h | 1 - .../audio/spectrogram_calculator_test.cc | 11 +- .../time_series_framer_calculator_test.cc | 12 ++- mediapipe/calculators/core/BUILD | 6 +- .../calculators/core/gate_calculator_test.cc | 11 +- .../core/immediate_mux_calculator.cc | 3 +- .../calculators/core/merge_calculator.cc | 7 +- .../core/packet_resampler_calculator.cc | 42 +++++--- .../core/packet_resampler_calculator.h | 1 - .../core/sequence_shift_calculator.cc | 3 +- mediapipe/calculators/image/BUILD | 7 +- .../image/image_cropping_calculator.cc | 6 +- .../image/scale_image_calculator.cc | 12 ++- .../segmentation_smoothing_calculator.cc | 4 +- .../segmentation_smoothing_calculator_test.cc | 3 +- .../calculators/image/set_alpha_calculator.cc | 6 +- mediapipe/calculators/tensor/BUILD | 4 + .../tensor/image_to_tensor_calculator.cc | 7 +- .../image_to_tensor_converter_gl_texture.cc | 3 +- .../tensor/inference_calculator_metal.cc | 3 +- .../tensors_to_detections_calculator.cc | 5 +- mediapipe/calculators/tensorflow/BUILD | 14 ++- .../tensor_squeeze_dimensions_calculator.cc | 10 +- .../tensorflow_inference_calculator_test.cc | 9 +- ...ow_session_from_frozen_graph_calculator.cc | 6 +- ...low_session_from_frozen_graph_generator.cc | 6 +- ...low_session_from_saved_model_calculator.cc | 3 +- ...flow_session_from_saved_model_generator.cc | 3 +- .../unpack_media_sequence_calculator.cc | 16 +-- .../unpack_media_sequence_calculator_test.cc | 3 +- ...unpack_yt8m_sequence_example_calculator.cc | 6 +- .../vector_float_to_tensor_calculator.cc | 5 +- .../vector_int_to_tensor_calculator.cc | 11 +- .../vector_string_to_tensor_calculator.cc | 5 +- mediapipe/calculators/tflite/BUILD | 4 + .../tflite/ssd_anchors_calculator.cc | 3 +- .../tflite/tflite_inference_calculator.cc | 9 +- ...tflite_tensors_to_detections_calculator.cc | 3 +- mediapipe/calculators/util/BUILD | 7 +- .../util/annotation_overlay_calculator.cc | 5 +- .../local_file_pattern_contents_calculator.cc | 3 +- .../util/non_max_suppression_calculator.cc | 4 +- .../util/packet_latency_calculator.cc | 4 +- mediapipe/calculators/video/BUILD | 12 ++- .../video/box_detector_calculator.cc | 9 +- .../video/box_tracker_calculator.cc | 60 ++++++----- .../video/flow_packager_calculator.cc | 21 ++-- .../video/motion_analysis_calculator.cc | 31 +++--- .../video/opencv_video_decoder_calculator.cc | 14 +-- .../video/opencv_video_encoder_calculator.cc | 8 +- .../calculators/video/tracking_graph_test.cc | 5 +- mediapipe/examples/coral/BUILD | 1 + .../examples/coral/demo_run_graph_main.cc | 21 ++-- mediapipe/examples/desktop/BUILD | 3 + .../desktop/autoflip/calculators/BUILD | 1 + .../calculators/shot_boundary_calculator.cc | 5 +- .../examples/desktop/autoflip/quality/BUILD | 5 + .../quality/frame_crop_region_computer.cc | 6 +- .../quality/piecewise_linear_function.cc | 1 + .../scene_camera_motion_analyzer_test.cc | 1 + .../desktop/autoflip/quality/utils.cc | 5 +- .../desktop/autoflip/quality/visual_scorer.cc | 3 +- .../examples/desktop/demo_run_graph_main.cc | 25 ++--- .../desktop/demo_run_graph_main_gpu.cc | 27 ++--- mediapipe/examples/desktop/hello_world/BUILD | 2 +- .../desktop/hello_world/hello_world.cc | 4 +- .../examples/desktop/iris_tracking/BUILD | 1 + .../iris_depth_from_image_desktop.cc | 19 ++-- .../examples/desktop/media_sequence/BUILD | 1 + .../media_sequence/run_graph_file_io_main.cc | 15 +-- .../examples/desktop/simple_run_graph_main.cc | 15 +-- mediapipe/examples/desktop/youtube8m/BUILD | 1 + .../youtube8m/extract_yt8m_features.cc | 15 +-- mediapipe/framework/BUILD | 24 +++-- mediapipe/framework/api2/BUILD | 1 + mediapipe/framework/api2/node_test.cc | 3 +- mediapipe/framework/calculator_graph.cc | 36 ++++--- .../calculator_graph_side_packet_test.cc | 8 +- mediapipe/framework/calculator_graph_test.cc | 10 +- mediapipe/framework/calculator_node.cc | 7 +- mediapipe/framework/calculator_node_test.cc | 5 +- mediapipe/framework/calculator_runner.cc | 14 +-- mediapipe/framework/calculator_runner_test.cc | 4 +- mediapipe/framework/collection.h | 6 +- mediapipe/framework/counter_factory.cc | 5 +- mediapipe/framework/deps/BUILD | 15 ++- mediapipe/framework/deps/cleanup.h | 2 +- mediapipe/framework/deps/clock.cc | 4 +- mediapipe/framework/deps/monotonic_clock.cc | 5 +- .../framework/deps/monotonic_clock_test.cc | 12 +-- mediapipe/framework/deps/registration.h | 5 +- mediapipe/framework/deps/safe_int.h | 11 +- mediapipe/framework/deps/status.h | 6 +- mediapipe/framework/deps/strong_int.h | 3 +- .../framework/deps/threadpool_pthread_impl.cc | 25 ++--- .../deps/threadpool_std_thread_impl.cc | 7 +- mediapipe/framework/deps/topologicalsorter.h | 2 +- mediapipe/framework/formats/BUILD | 10 +- mediapipe/framework/formats/deleting_file.cc | 4 +- mediapipe/framework/formats/image_frame.cc | 9 +- mediapipe/framework/formats/location.cc | 17 +-- .../framework/formats/location_opencv.cc | 10 +- mediapipe/framework/formats/motion/BUILD | 4 +- .../formats/motion/optical_flow_field.cc | 4 +- .../formats/motion/optical_flow_field_test.cc | 2 +- mediapipe/framework/formats/tensor.cc | 36 +++---- mediapipe/framework/formats/tensor_ahwb.cc | 5 +- mediapipe/framework/graph_output_stream.h | 12 +-- mediapipe/framework/packet.h | 3 +- mediapipe/framework/packet_type.h | 5 +- mediapipe/framework/profiler/BUILD | 7 +- .../framework/profiler/gl_context_profiler.cc | 1 + .../framework/profiler/graph_profiler.cc | 16 +-- .../framework/profiler/graph_profiler_test.cc | 6 +- mediapipe/framework/profiler/reporter_test.cc | 7 +- .../framework/profiler/sharded_map_test.cc | 8 +- .../framework/profiler/test_context_builder.h | 4 +- mediapipe/framework/profiler/testing/BUILD | 1 + .../profiler/testing/simple_calculator.cc | 3 +- mediapipe/framework/stream_handler/BUILD | 3 +- .../fixed_size_input_stream_handler.cc | 4 +- .../sync_set_input_stream_handler_test.cc | 3 +- mediapipe/framework/timestamp.cc | 3 +- mediapipe/framework/tool/BUILD | 13 ++- mediapipe/framework/tool/sink.cc | 9 +- .../framework/tool/switch_container_test.cc | 4 +- mediapipe/framework/tool/tag_map_test.cc | 5 +- mediapipe/framework/tool/template_expander.cc | 4 +- mediapipe/framework/tool/template_parser.cc | 34 +++--- mediapipe/framework/tool/test_util.cc | 13 +-- .../framework/tool/text_to_binary_graph.cc | 10 +- mediapipe/framework/type_map.h | 24 +++-- mediapipe/framework/validated_graph_config.cc | 22 ++-- mediapipe/gpu/BUILD | 11 +- mediapipe/gpu/MPPMetalHelper.mm | 13 ++- mediapipe/gpu/gl_calculator_helper.cc | 3 +- mediapipe/gpu/gl_context.cc | 63 +++++------ mediapipe/gpu/gl_context_eagl.cc | 1 - mediapipe/gpu/gl_context_egl.cc | 32 +++--- mediapipe/gpu/gl_context_nsgl.cc | 7 +- mediapipe/gpu/gl_context_webgl.cc | 16 +-- mediapipe/gpu/gl_surface_sink_calculator.cc | 3 +- mediapipe/gpu/gl_texture_buffer.cc | 7 +- .../gpu/gpu_buffer_storage_cv_pixel_buffer.cc | 3 +- mediapipe/gpu/gpu_buffer_storage_yuv_image.cc | 8 +- mediapipe/gpu/shader_util.cc | 16 +-- .../instant_motion_tracking/calculators/BUILD | 1 + .../matrices_manager_calculator.cc | 18 ++-- .../object_detection_3d/calculators/BUILD | 1 + .../gl_animation_overlay_calculator.cc | 50 +++++---- .../com/google/mediapipe/framework/jni/BUILD | 6 +- .../jni/android_packet_creator_jni.cc | 33 +++--- .../google/mediapipe/framework/jni/graph.cc | 40 +++---- .../framework/jni/graph_texture_frame_jni.cc | 5 +- .../mediapipe/framework/jni/jni_util.cc | 14 +-- .../framework/jni/register_natives.cc | 11 +- .../framework/jni/surface_output_jni.cc | 3 +- mediapipe/modules/objectron/calculators/BUILD | 8 +- .../modules/objectron/calculators/decoder.cc | 4 +- .../filter_detection_calculator.cc | 6 +- .../calculators/frame_annotation_tracker.cc | 6 +- ...ft_2d_frame_annotation_to_3d_calculator.cc | 3 +- .../tensors_to_objects_calculator.cc | 3 +- .../tflite_tensors_to_objects_calculator.cc | 3 +- mediapipe/objc/BUILD | 1 + mediapipe/objc/util.cc | 5 +- .../tasks/cc/components/processors/BUILD | 1 + .../detection_postprocessing_graph.cc | 5 +- mediapipe/tasks/cc/core/BUILD | 4 +- mediapipe/tasks/cc/core/base_options.cc | 6 +- mediapipe/tasks/cc/core/model_task_graph.cc | 6 +- mediapipe/tasks/cc/metadata/utils/BUILD | 1 + .../tasks/cc/metadata/utils/zip_utils.cc | 5 +- .../tasks/cc/vision/face_landmarker/BUILD | 1 + .../face_landmarker/face_landmarker_graph.cc | 5 +- .../tasks/cc/vision/gesture_recognizer/BUILD | 2 + .../gesture_recognizer_graph.cc | 5 +- .../hand_gesture_recognizer_graph.cc | 3 +- .../cc/vision/image_generator/diffuser/BUILD | 4 +- .../diffusion_plugins_output_calculator.cc | 1 - .../stable_diffusion_iterate_calculator.cc | 2 +- .../tasks/cc/vision/image_segmenter/BUILD | 1 + .../segmentation_postprocessor_gl.cc | 18 ++-- .../image_segmenter/image_segmenter_graph.cc | 3 +- .../pose_landmarker/pose_landmarker_test.cc | 13 +-- mediapipe/tasks/cc/vision/utils/BUILD | 2 +- .../cc/vision/utils/image_tensor_specs.cc | 7 +- mediapipe/util/BUILD | 12 ++- mediapipe/util/android/BUILD | 2 + mediapipe/util/android/asset_manager_util.cc | 8 +- mediapipe/util/android/file/base/BUILD | 2 +- mediapipe/util/android/file/base/file.cc | 4 +- mediapipe/util/annotation_renderer.cc | 3 +- mediapipe/util/audio_decoder.cc | 63 +++++------ mediapipe/util/filtering/BUILD | 7 +- mediapipe/util/filtering/low_pass_filter.cc | 4 +- mediapipe/util/filtering/one_euro_filter.cc | 10 +- .../filtering/relative_velocity_filter.cc | 5 +- mediapipe/util/frame_buffer/BUILD | 6 +- .../util/frame_buffer/gray_buffer_test.cc | 4 +- .../util/frame_buffer/rgb_buffer_test.cc | 4 +- .../util/frame_buffer/yuv_buffer_test.cc | 4 +- mediapipe/util/image_frame_util.cc | 4 +- mediapipe/util/image_test_utils.cc | 4 +- mediapipe/util/log_fatal_to_breakpad.cc | 1 - mediapipe/util/pose_util.cc | 4 +- mediapipe/util/resource_util_android.cc | 7 +- mediapipe/util/resource_util_apple.cc | 10 +- mediapipe/util/tflite/BUILD | 1 + mediapipe/util/tflite/tflite_gpu_runner.cc | 1 + mediapipe/util/time_series_test_util.h | 4 +- mediapipe/util/time_series_util.cc | 8 +- mediapipe/util/time_series_util.h | 1 - mediapipe/util/tracking/BUILD | 34 ++++-- mediapipe/util/tracking/box_detector.cc | 12 ++- mediapipe/util/tracking/box_tracker.cc | 32 +++--- mediapipe/util/tracking/camera_motion.cc | 25 +++-- mediapipe/util/tracking/camera_motion.h | 5 +- mediapipe/util/tracking/flow_packager.cc | 7 +- mediapipe/util/tracking/image_util.cc | 4 +- mediapipe/util/tracking/measure_time.cc | 2 +- mediapipe/util/tracking/measure_time.h | 13 +-- mediapipe/util/tracking/motion_analysis.cc | 8 +- mediapipe/util/tracking/motion_estimation.cc | 77 ++++++------- mediapipe/util/tracking/motion_models.cc | 24 +++-- mediapipe/util/tracking/motion_models.h | 39 +++---- mediapipe/util/tracking/motion_saliency.cc | 6 +- mediapipe/util/tracking/parallel_invoker.h | 31 +++--- mediapipe/util/tracking/push_pull_filtering.h | 9 +- mediapipe/util/tracking/region_flow.cc | 27 ++--- mediapipe/util/tracking/region_flow.h | 4 +- .../util/tracking/region_flow_computation.cc | 102 +++++++++--------- .../tracking/region_flow_computation_test.cc | 4 +- mediapipe/util/tracking/streaming_buffer.cc | 13 +-- mediapipe/util/tracking/streaming_buffer.h | 19 ++-- mediapipe/util/tracking/tone_estimation.cc | 5 +- mediapipe/util/tracking/tone_models.h | 10 +- mediapipe/util/tracking/tracking.cc | 84 ++++++++------- mediapipe/util/tracking/tracking.h | 7 +- .../tracking_visualization_utilities.cc | 9 +- 243 files changed, 1396 insertions(+), 1087 deletions(-) diff --git a/docs/getting_started/hello_world_cpp.md b/docs/getting_started/hello_world_cpp.md index 7c8f9be3e..f0c7ff0f9 100644 --- a/docs/getting_started/hello_world_cpp.md +++ b/docs/getting_started/hello_world_cpp.md @@ -50,7 +50,7 @@ as the primary developer documentation site for MediaPipe as of April 3, 2023.* 3. The [`hello world`] example uses a simple MediaPipe graph in the `PrintHelloWorld()` function, defined in a [`CalculatorGraphConfig`] proto. - ```C++ + ```c++ absl::Status PrintHelloWorld() { // Configures a simple graph, which concatenates 2 PassThroughCalculators. CalculatorGraphConfig config = ParseTextProtoOrDie(R"( @@ -126,7 +126,7 @@ as the primary developer documentation site for MediaPipe as of April 3, 2023.* ```c++ mediapipe::Packet packet; while (poller.Next(&packet)) { - LOG(INFO) << packet.Get(); + ABSL_LOG(INFO) << packet.Get(); } ``` diff --git a/mediapipe/calculators/audio/BUILD b/mediapipe/calculators/audio/BUILD index c8c06e27f..f72e88199 100644 --- a/mediapipe/calculators/audio/BUILD +++ b/mediapipe/calculators/audio/BUILD @@ -164,8 +164,8 @@ cc_library( "//mediapipe/framework/formats:matrix", "//mediapipe/framework/formats:time_series_header_cc_proto", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/util:time_series_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_audio_tools//audio/dsp:resampler", "@com_google_audio_tools//audio/dsp:resampler_q", @@ -295,6 +295,7 @@ cc_test( "//mediapipe/framework/port:integral_types", "//mediapipe/framework/port:status", "//mediapipe/util:time_series_test_util", + "@com_google_absl//absl/log:absl_log", "@com_google_audio_tools//audio/dsp:number_util", "@eigen_archive//:eigen3", ], @@ -346,6 +347,7 @@ cc_test( "//mediapipe/framework/port:integral_types", "//mediapipe/framework/port:status", "//mediapipe/util:time_series_test_util", + "@com_google_absl//absl/log:absl_log", "@com_google_audio_tools//audio/dsp:window_functions", "@eigen_archive//:eigen3", ], diff --git a/mediapipe/calculators/audio/rational_factor_resample_calculator.cc b/mediapipe/calculators/audio/rational_factor_resample_calculator.cc index 1a4210c30..b5e2cca58 100644 --- a/mediapipe/calculators/audio/rational_factor_resample_calculator.cc +++ b/mediapipe/calculators/audio/rational_factor_resample_calculator.cc @@ -16,6 +16,7 @@ #include "mediapipe/calculators/audio/rational_factor_resample_calculator.h" +#include "absl/log/absl_log.h" #include "audio/dsp/resampler_q.h" using audio_dsp::Resampler; @@ -77,7 +78,7 @@ absl::Status RationalFactorResampleCalculator::Open(CalculatorContext* cc) { r = ResamplerFromOptions(source_sample_rate_, target_sample_rate_, resample_options); if (!r) { - LOG(ERROR) << "Failed to initialize resampler."; + ABSL_LOG(ERROR) << "Failed to initialize resampler."; return absl::UnknownError("Failed to initialize resampler."); } } diff --git a/mediapipe/calculators/audio/rational_factor_resample_calculator.h b/mediapipe/calculators/audio/rational_factor_resample_calculator.h index 325886dc7..2c9df30b4 100644 --- a/mediapipe/calculators/audio/rational_factor_resample_calculator.h +++ b/mediapipe/calculators/audio/rational_factor_resample_calculator.h @@ -27,7 +27,6 @@ #include "mediapipe/framework/formats/matrix.h" #include "mediapipe/framework/formats/time_series_header.pb.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/util/time_series_util.h" namespace mediapipe { diff --git a/mediapipe/calculators/audio/spectrogram_calculator_test.cc b/mediapipe/calculators/audio/spectrogram_calculator_test.cc index b35f30583..14cd74a3c 100644 --- a/mediapipe/calculators/audio/spectrogram_calculator_test.cc +++ b/mediapipe/calculators/audio/spectrogram_calculator_test.cc @@ -22,6 +22,7 @@ #include #include "Eigen/Core" +#include "absl/log/absl_log.h" #include "audio/dsp/number_util.h" #include "mediapipe/calculators/audio/spectrogram_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" @@ -882,11 +883,11 @@ void BM_ProcessDC(benchmark::State& state) { const CalculatorRunner::StreamContents& output = runner.Outputs().Index(0); const Matrix& output_matrix = output.packets[0].Get(); - LOG(INFO) << "Output matrix=" << output_matrix.rows() << "x" - << output_matrix.cols(); - LOG(INFO) << "First values=" << output_matrix(0, 0) << ", " - << output_matrix(1, 0) << ", " << output_matrix(2, 0) << ", " - << output_matrix(3, 0); + ABSL_LOG(INFO) << "Output matrix=" << output_matrix.rows() << "x" + << output_matrix.cols(); + ABSL_LOG(INFO) << "First values=" << output_matrix(0, 0) << ", " + << output_matrix(1, 0) << ", " << output_matrix(2, 0) << ", " + << output_matrix(3, 0); } BENCHMARK(BM_ProcessDC); diff --git a/mediapipe/calculators/audio/time_series_framer_calculator_test.cc b/mediapipe/calculators/audio/time_series_framer_calculator_test.cc index 72e9c88f7..fe42ecb12 100644 --- a/mediapipe/calculators/audio/time_series_framer_calculator_test.cc +++ b/mediapipe/calculators/audio/time_series_framer_calculator_test.cc @@ -19,6 +19,7 @@ #include #include "Eigen/Core" +#include "absl/log/absl_log.h" #include "audio/dsp/window_functions.h" #include "mediapipe/calculators/audio/time_series_framer_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" @@ -186,11 +187,12 @@ class TimeSeriesFramerCalculatorTest const int num_unique_output_samples = round((output().packets.size() - 1) * frame_step_samples) + frame_duration_samples; - LOG(INFO) << "packets.size()=" << output().packets.size() - << " frame_duration_samples=" << frame_duration_samples - << " frame_step_samples=" << frame_step_samples - << " num_input_samples_=" << num_input_samples_ - << " num_unique_output_samples=" << num_unique_output_samples; + ABSL_LOG(INFO) << "packets.size()=" << output().packets.size() + << " frame_duration_samples=" << frame_duration_samples + << " frame_step_samples=" << frame_step_samples + << " num_input_samples_=" << num_input_samples_ + << " num_unique_output_samples=" + << num_unique_output_samples; const int num_padding_samples = num_unique_output_samples - num_input_samples_; if (options_.pad_final_packet()) { diff --git a/mediapipe/calculators/core/BUILD b/mediapipe/calculators/core/BUILD index 7c5dfe81f..4722dcc1b 100644 --- a/mediapipe/calculators/core/BUILD +++ b/mediapipe/calculators/core/BUILD @@ -629,6 +629,7 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) @@ -776,10 +777,10 @@ cc_library( "//mediapipe/framework/deps:random", "//mediapipe/framework/formats:video_stream_header", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:options_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], alwayslink = 1, @@ -1022,6 +1023,7 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework/api2:node", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) @@ -1060,6 +1062,7 @@ cc_test( "//mediapipe/framework:calculator_runner", "//mediapipe/framework/port:gtest_main", "//mediapipe/framework/port:parse_text_proto", + "@com_google_absl//absl/log:absl_log", ], ) @@ -1106,6 +1109,7 @@ cc_library( "//mediapipe/framework/api2:node", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) diff --git a/mediapipe/calculators/core/gate_calculator_test.cc b/mediapipe/calculators/core/gate_calculator_test.cc index 8875bd7e3..0c49f1449 100644 --- a/mediapipe/calculators/core/gate_calculator_test.cc +++ b/mediapipe/calculators/core/gate_calculator_test.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/calculator_runner.h" #include "mediapipe/framework/port/gtest.h" @@ -356,18 +357,18 @@ TEST_F(GateCalculatorTest, AllowWithStateChangeNoDataStreams) { RunTimeStepWithoutDataStream(kTimestampValue2, "ALLOW", true); constexpr int64_t kTimestampValue3 = 45; RunTimeStepWithoutDataStream(kTimestampValue3, "ALLOW", false); - LOG(INFO) << "a"; + ABSL_LOG(INFO) << "a"; const std::vector& output = runner()->Outputs().Get("STATE_CHANGE", 0).packets; - LOG(INFO) << "s"; + ABSL_LOG(INFO) << "s"; ASSERT_EQ(2, output.size()); - LOG(INFO) << "d"; + ABSL_LOG(INFO) << "d"; EXPECT_EQ(kTimestampValue1, output[0].Timestamp().Value()); EXPECT_EQ(kTimestampValue3, output[1].Timestamp().Value()); - LOG(INFO) << "f"; + ABSL_LOG(INFO) << "f"; EXPECT_EQ(true, output[0].Get()); // Allow. EXPECT_EQ(false, output[1].Get()); // Disallow. - LOG(INFO) << "g"; + ABSL_LOG(INFO) << "g"; } TEST_F(GateCalculatorTest, DisallowWithStateChange) { diff --git a/mediapipe/calculators/core/immediate_mux_calculator.cc b/mediapipe/calculators/core/immediate_mux_calculator.cc index 0e51cda5e..05de05e40 100644 --- a/mediapipe/calculators/core/immediate_mux_calculator.cc +++ b/mediapipe/calculators/core/immediate_mux_calculator.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" @@ -78,7 +79,7 @@ absl::Status ImmediateMuxCalculator::Process(CalculatorContext* cc) { if (packet.Timestamp() >= cc->Outputs().Index(0).NextTimestampBound()) { cc->Outputs().Index(0).AddPacket(packet); } else { - LOG_FIRST_N(WARNING, 5) + ABSL_LOG_FIRST_N(WARNING, 5) << "Dropping a packet with timestamp " << packet.Timestamp(); } if (cc->Outputs().NumEntries() >= 2) { diff --git a/mediapipe/calculators/core/merge_calculator.cc b/mediapipe/calculators/core/merge_calculator.cc index a283842ae..43fc3b878 100644 --- a/mediapipe/calculators/core/merge_calculator.cc +++ b/mediapipe/calculators/core/merge_calculator.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/log/absl_log.h" #include "mediapipe/framework/api2/node.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/ret_check.h" @@ -53,7 +54,7 @@ class MergeCalculator : public Node { static absl::Status UpdateContract(CalculatorContract* cc) { RET_CHECK_GT(kIn(cc).Count(), 0) << "Needs at least one input stream"; if (kIn(cc).Count() == 1) { - LOG(WARNING) + ABSL_LOG(WARNING) << "MergeCalculator expects multiple input streams to merge but is " "receiving only one. Make sure the calculator is configured " "correctly or consider removing this calculator to reduce " @@ -72,8 +73,8 @@ class MergeCalculator : public Node { } } - LOG(WARNING) << "Empty input packets at timestamp " - << cc->InputTimestamp().Value(); + ABSL_LOG(WARNING) << "Empty input packets at timestamp " + << cc->InputTimestamp().Value(); return absl::OkStatus(); } diff --git a/mediapipe/calculators/core/packet_resampler_calculator.cc b/mediapipe/calculators/core/packet_resampler_calculator.cc index 60ec40537..49977444c 100644 --- a/mediapipe/calculators/core/packet_resampler_calculator.cc +++ b/mediapipe/calculators/core/packet_resampler_calculator.cc @@ -16,6 +16,8 @@ #include +#include "absl/log/absl_log.h" + namespace { // Reflect an integer against the lower and upper bound of an interval. int64_t ReflectBetween(int64_t ts, int64_t ts_min, int64_t ts_max) { @@ -177,7 +179,7 @@ PacketResamplerCalculator::GetSamplingStrategy( const PacketResamplerCalculatorOptions& options) { if (options.reproducible_sampling()) { if (!options.jitter_with_reflection()) { - LOG(WARNING) + ABSL_LOG(WARNING) << "reproducible_sampling enabled w/ jitter_with_reflection " "disabled. " << "reproducible_sampling always uses jitter with reflection, " @@ -229,13 +231,15 @@ absl::Status LegacyJitterWithReflectionStrategy::Open(CalculatorContext* cc) { if (resampler_options.output_header() != PacketResamplerCalculatorOptions::NONE) { - LOG(WARNING) << "VideoHeader::frame_rate holds the target value and not " - "the actual value."; + ABSL_LOG(WARNING) + << "VideoHeader::frame_rate holds the target value and not " + "the actual value."; } if (calculator_->flush_last_packet_) { - LOG(WARNING) << "PacketResamplerCalculatorOptions.flush_last_packet is " - "ignored, because we are adding jitter."; + ABSL_LOG(WARNING) + << "PacketResamplerCalculatorOptions.flush_last_packet is " + "ignored, because we are adding jitter."; } const auto& seed = cc->InputSidePackets().Tag(kSeedTag).Get(); @@ -254,7 +258,7 @@ absl::Status LegacyJitterWithReflectionStrategy::Open(CalculatorContext* cc) { } absl::Status LegacyJitterWithReflectionStrategy::Close(CalculatorContext* cc) { if (!packet_reservoir_->IsEmpty()) { - LOG(INFO) << "Emitting pack from reservoir."; + ABSL_LOG(INFO) << "Emitting pack from reservoir."; calculator_->OutputWithinLimits(cc, packet_reservoir_->GetSample()); } return absl::OkStatus(); @@ -285,7 +289,7 @@ absl::Status LegacyJitterWithReflectionStrategy::Process( if (calculator_->frame_time_usec_ < (cc->InputTimestamp() - calculator_->last_packet_.Timestamp()).Value()) { - LOG_FIRST_N(WARNING, 2) + ABSL_LOG_FIRST_N(WARNING, 2) << "Adding jitter is not very useful when upsampling."; } @@ -352,13 +356,15 @@ absl::Status ReproducibleJitterWithReflectionStrategy::Open( if (resampler_options.output_header() != PacketResamplerCalculatorOptions::NONE) { - LOG(WARNING) << "VideoHeader::frame_rate holds the target value and not " - "the actual value."; + ABSL_LOG(WARNING) + << "VideoHeader::frame_rate holds the target value and not " + "the actual value."; } if (calculator_->flush_last_packet_) { - LOG(WARNING) << "PacketResamplerCalculatorOptions.flush_last_packet is " - "ignored, because we are adding jitter."; + ABSL_LOG(WARNING) + << "PacketResamplerCalculatorOptions.flush_last_packet is " + "ignored, because we are adding jitter."; } const auto& seed = cc->InputSidePackets().Tag(kSeedTag).Get(); @@ -411,7 +417,7 @@ absl::Status ReproducibleJitterWithReflectionStrategy::Process( // Note, if the stream is upsampling, this could lead to the same packet // being emitted twice. Upsampling and jitter doesn't make much sense // but does technically work. - LOG_FIRST_N(WARNING, 2) + ABSL_LOG_FIRST_N(WARNING, 2) << "Adding jitter is not very useful when upsampling."; } @@ -499,13 +505,15 @@ absl::Status JitterWithoutReflectionStrategy::Open(CalculatorContext* cc) { if (resampler_options.output_header() != PacketResamplerCalculatorOptions::NONE) { - LOG(WARNING) << "VideoHeader::frame_rate holds the target value and not " - "the actual value."; + ABSL_LOG(WARNING) + << "VideoHeader::frame_rate holds the target value and not " + "the actual value."; } if (calculator_->flush_last_packet_) { - LOG(WARNING) << "PacketResamplerCalculatorOptions.flush_last_packet is " - "ignored, because we are adding jitter."; + ABSL_LOG(WARNING) + << "PacketResamplerCalculatorOptions.flush_last_packet is " + "ignored, because we are adding jitter."; } const auto& seed = cc->InputSidePackets().Tag(kSeedTag).Get(); @@ -555,7 +563,7 @@ absl::Status JitterWithoutReflectionStrategy::Process(CalculatorContext* cc) { if (calculator_->frame_time_usec_ < (cc->InputTimestamp() - calculator_->last_packet_.Timestamp()).Value()) { - LOG_FIRST_N(WARNING, 2) + ABSL_LOG_FIRST_N(WARNING, 2) << "Adding jitter is not very useful when upsampling."; } diff --git a/mediapipe/calculators/core/packet_resampler_calculator.h b/mediapipe/calculators/core/packet_resampler_calculator.h index fbecdb0e7..f26dc2ca4 100644 --- a/mediapipe/calculators/core/packet_resampler_calculator.h +++ b/mediapipe/calculators/core/packet_resampler_calculator.h @@ -13,7 +13,6 @@ #include "mediapipe/framework/deps/random_base.h" #include "mediapipe/framework/formats/video_stream_header.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status_macros.h" diff --git a/mediapipe/calculators/core/sequence_shift_calculator.cc b/mediapipe/calculators/core/sequence_shift_calculator.cc index 026048b79..5b2a73fd3 100644 --- a/mediapipe/calculators/core/sequence_shift_calculator.cc +++ b/mediapipe/calculators/core/sequence_shift_calculator.cc @@ -14,6 +14,7 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/core/sequence_shift_calculator.pb.h" #include "mediapipe/framework/api2/node.h" #include "mediapipe/framework/calculator_framework.h" @@ -101,7 +102,7 @@ void SequenceShiftCalculator::ProcessPositiveOffset(CalculatorContext* cc) { kOut(cc).Send(packet_cache_.front().At(cc->InputTimestamp())); packet_cache_.pop_front(); } else if (emit_empty_packets_before_first_packet_) { - LOG(FATAL) << "Not supported yet"; + ABSL_LOG(FATAL) << "Not supported yet"; } // Store current packet for later output. packet_cache_.push_back(kIn(cc).packet()); diff --git a/mediapipe/calculators/image/BUILD b/mediapipe/calculators/image/BUILD index 4f3059a51..ad6133181 100644 --- a/mediapipe/calculators/image/BUILD +++ b/mediapipe/calculators/image/BUILD @@ -151,11 +151,11 @@ cc_library( "//mediapipe/framework/formats:image_format_cc_proto", "//mediapipe/framework/formats:image_frame", "//mediapipe/framework/formats:image_frame_opencv", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:status", "//mediapipe/framework/port:vector", + "@com_google_absl//absl/log:absl_log", ] + select({ "//mediapipe/gpu:disable_gpu": [], "//conditions:default": [ @@ -300,6 +300,7 @@ cc_library( "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ] + select({ "//mediapipe/gpu:disable_gpu": [], "//conditions:default": [ @@ -420,6 +421,7 @@ cc_library( "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/util:image_frame_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@libyuv", ], @@ -625,9 +627,9 @@ cc_library( "//mediapipe/framework/formats:image", "//mediapipe/framework/formats:image_format_cc_proto", "//mediapipe/framework/formats:image_frame", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:status", "//mediapipe/framework/port:vector", + "@com_google_absl//absl/log:absl_log", ] + select({ "//mediapipe/gpu:disable_gpu": [], "//conditions:default": [ @@ -665,6 +667,7 @@ cc_test( "//mediapipe/framework/port:opencv_imgcodecs", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:parse_text_proto", + "@com_google_absl//absl/log:absl_log", ], ) diff --git a/mediapipe/calculators/image/image_cropping_calculator.cc b/mediapipe/calculators/image/image_cropping_calculator.cc index 6776da7c8..9eb3e6808 100644 --- a/mediapipe/calculators/image/image_cropping_calculator.cc +++ b/mediapipe/calculators/image/image_cropping_calculator.cc @@ -16,6 +16,7 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/framework/formats/image_frame_opencv.h" #include "mediapipe/framework/formats/rect.pb.h" @@ -202,8 +203,9 @@ absl::Status ImageCroppingCalculator::ValidateBorderModeForGPU( switch (options.border_mode()) { case mediapipe::ImageCroppingCalculatorOptions::BORDER_ZERO: - LOG(WARNING) << "BORDER_ZERO mode is not supported by GPU " - << "implementation and will fall back into BORDER_REPLICATE"; + ABSL_LOG(WARNING) + << "BORDER_ZERO mode is not supported by GPU " + << "implementation and will fall back into BORDER_REPLICATE"; break; case mediapipe::ImageCroppingCalculatorOptions::BORDER_REPLICATE: break; diff --git a/mediapipe/calculators/image/scale_image_calculator.cc b/mediapipe/calculators/image/scale_image_calculator.cc index d8a3cb93b..10b14116c 100644 --- a/mediapipe/calculators/image/scale_image_calculator.cc +++ b/mediapipe/calculators/image/scale_image_calculator.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/substitute.h" #include "libyuv/scale.h" @@ -293,7 +294,7 @@ absl::Status ScaleImageCalculator::InitializeFrameInfo(CalculatorContext* cc) { header->width = output_width_; header->height = output_height_; header->format = output_format_; - LOG(INFO) << "OUTPUTTING HEADER on stream"; + ABSL_LOG(INFO) << "OUTPUTTING HEADER on stream"; cc->Outputs() .Tag("VIDEO_HEADER") .Add(header.release(), Timestamp::PreStream()); @@ -393,10 +394,11 @@ absl::Status ScaleImageCalculator::Open(CalculatorContext* cc) { .SetHeader(Adopt(output_header.release())); has_header_ = true; } else { - LOG(WARNING) << "Stream had a VideoHeader which didn't have sufficient " - "information. " - "Dropping VideoHeader and trying to deduce needed " - "information."; + ABSL_LOG(WARNING) + << "Stream had a VideoHeader which didn't have sufficient " + "information. " + "Dropping VideoHeader and trying to deduce needed " + "information."; input_width_ = 0; input_height_ = 0; if (!options_.has_input_format()) { diff --git a/mediapipe/calculators/image/segmentation_smoothing_calculator.cc b/mediapipe/calculators/image/segmentation_smoothing_calculator.cc index db0d38325..1194412a6 100644 --- a/mediapipe/calculators/image/segmentation_smoothing_calculator.cc +++ b/mediapipe/calculators/image/segmentation_smoothing_calculator.cc @@ -15,13 +15,13 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/image/segmentation_smoothing_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/calculator_options.pb.h" #include "mediapipe/framework/formats/image.h" #include "mediapipe/framework/formats/image_format.pb.h" #include "mediapipe/framework/formats/image_frame.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/vector.h" @@ -273,7 +273,7 @@ absl::Status SegmentationSmoothingCalculator::RenderGpu(CalculatorContext* cc) { const auto& previous_frame = cc->Inputs().Tag(kPreviousMaskTag).Get(); if (previous_frame.format() != current_frame.format()) { - LOG(ERROR) << "Warning: mixing input format types. "; + ABSL_LOG(ERROR) << "Warning: mixing input format types. "; } auto previous_texture = gpu_helper_.CreateSourceTexture(previous_frame); diff --git a/mediapipe/calculators/image/segmentation_smoothing_calculator_test.cc b/mediapipe/calculators/image/segmentation_smoothing_calculator_test.cc index eeb812cb7..0f5152fc3 100644 --- a/mediapipe/calculators/image/segmentation_smoothing_calculator_test.cc +++ b/mediapipe/calculators/image/segmentation_smoothing_calculator_test.cc @@ -14,6 +14,7 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/image/segmentation_smoothing_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/calculator_runner.h" @@ -169,7 +170,7 @@ void RunTest(bool use_gpu, float mix_ratio, cv::Mat& test_result) { } } } else { - LOG(ERROR) << "invalid ratio"; + ABSL_LOG(ERROR) << "invalid ratio"; } } diff --git a/mediapipe/calculators/image/set_alpha_calculator.cc b/mediapipe/calculators/image/set_alpha_calculator.cc index 9c381f62d..d451cd21c 100644 --- a/mediapipe/calculators/image/set_alpha_calculator.cc +++ b/mediapipe/calculators/image/set_alpha_calculator.cc @@ -14,13 +14,13 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/image/set_alpha_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/calculator_options.pb.h" #include "mediapipe/framework/formats/image_format.pb.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/framework/formats/image_frame_opencv.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/opencv_core_inc.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" #include "mediapipe/framework/port/status.h" @@ -268,7 +268,7 @@ absl::Status SetAlphaCalculator::RenderCpu(CalculatorContext* cc) { const auto& input_frame = cc->Inputs().Tag(kInputFrameTag).Get(); const cv::Mat input_mat = formats::MatView(&input_frame); if (!(input_mat.type() == CV_8UC3 || input_mat.type() == CV_8UC4)) { - LOG(ERROR) << "Only 3 or 4 channel 8-bit input image supported"; + ABSL_LOG(ERROR) << "Only 3 or 4 channel 8-bit input image supported"; } // Setup destination image @@ -328,7 +328,7 @@ absl::Status SetAlphaCalculator::RenderGpu(CalculatorContext* cc) { cc->Inputs().Tag(kInputFrameTagGpu).Get(); if (!(input_frame.format() == mediapipe::GpuBufferFormat::kBGRA32 || input_frame.format() == mediapipe::GpuBufferFormat::kRGB24)) { - LOG(ERROR) << "Only RGB or RGBA input image supported"; + ABSL_LOG(ERROR) << "Only RGB or RGBA input image supported"; } auto input_texture = gpu_helper_.CreateSourceTexture(input_frame); diff --git a/mediapipe/calculators/tensor/BUILD b/mediapipe/calculators/tensor/BUILD index c3397b8d4..2d22e02db 100644 --- a/mediapipe/calculators/tensor/BUILD +++ b/mediapipe/calculators/tensor/BUILD @@ -474,6 +474,7 @@ cc_library( "//mediapipe/gpu:gpu_buffer", "//mediapipe/objc:mediapipe_framework_ios", "//mediapipe/util/tflite:config", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings:str_format", "@org_tensorflow//tensorflow/lite/delegates/gpu:metal_delegate", @@ -744,6 +745,7 @@ cc_library( "//mediapipe/framework/formats:tensor", "//mediapipe/framework/formats/object_detection:anchor_cc_proto", "//mediapipe/framework/port:ret_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/types:span", ] + selects.with_or({ @@ -992,6 +994,7 @@ cc_library( "//mediapipe/framework/port:status", "//mediapipe/framework/port:statusor", "//mediapipe/gpu:gpu_origin_cc_proto", + "@com_google_absl//absl/log:absl_log", ] + select({ "//mediapipe/gpu:disable_gpu": [], "//conditions:default": [":image_to_tensor_calculator_gpu_deps"], @@ -1211,6 +1214,7 @@ cc_library( "//mediapipe/gpu:gl_calculator_helper", "//mediapipe/gpu:gl_simple_shaders", "//mediapipe/gpu:shader_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], }), diff --git a/mediapipe/calculators/tensor/image_to_tensor_calculator.cc b/mediapipe/calculators/tensor/image_to_tensor_calculator.cc index 344e12da6..26fb1d868 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_calculator.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_calculator.cc @@ -16,6 +16,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensor/image_to_tensor_calculator.pb.h" #include "mediapipe/calculators/tensor/image_to_tensor_converter.h" #include "mediapipe/calculators/tensor/image_to_tensor_utils.h" @@ -284,9 +285,9 @@ class ImageToTensorCalculator : public Node { cc, GetBorderMode(options_.border_mode()), GetOutputTensorType(/*uses_gpu=*/false, params_))); #else - LOG(FATAL) << "Cannot create image to tensor CPU converter since " - "MEDIAPIPE_DISABLE_OPENCV is defined and " - "MEDIAPIPE_ENABLE_HALIDE is not defined."; + ABSL_LOG(FATAL) << "Cannot create image to tensor CPU converter since " + "MEDIAPIPE_DISABLE_OPENCV is defined and " + "MEDIAPIPE_ENABLE_HALIDE is not defined."; #endif // !MEDIAPIPE_DISABLE_HALIDE } } 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 165df8970..465e7e0bc 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_converter_gl_texture.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_converter_gl_texture.cc @@ -22,6 +22,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "mediapipe/calculators/tensor/image_to_tensor_converter.h" #include "mediapipe/calculators/tensor/image_to_tensor_converter_gl_utils.h" @@ -259,7 +260,7 @@ class GlProcessor : public ImageToTensorConverter { // error. So in that case, we'll grab the transpose of our original matrix // and send that instead. const auto gl_context = mediapipe::GlContext::GetCurrent(); - LOG_IF(FATAL, !gl_context) << "GlContext is not bound to the thread."; + ABSL_LOG_IF(FATAL, !gl_context) << "GlContext is not bound to the thread."; if (gl_context->GetGlVersion() == mediapipe::GlVersion::kGLES2) { GetTransposedRotatedSubRectToRectTransformMatrix( sub_rect, texture.width(), texture.height(), flip_horizontaly, diff --git a/mediapipe/calculators/tensor/inference_calculator_metal.cc b/mediapipe/calculators/tensor/inference_calculator_metal.cc index fba18a81c..253091a8a 100644 --- a/mediapipe/calculators/tensor/inference_calculator_metal.cc +++ b/mediapipe/calculators/tensor/inference_calculator_metal.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/str_format.h" #include "mediapipe/calculators/tensor/inference_calculator.h" @@ -74,7 +75,7 @@ tflite::gpu::BHWC BhwcFromTensorShape(const Tensor::Shape& shape) { break; default: // Handles 0 and >4. - LOG(FATAL) + ABSL_LOG(FATAL) << "Dimensions size must be in range [1,4] for GPU inference, but " << shape.dims.size() << " is provided"; } diff --git a/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc b/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc index 246269de1..51d2d229a 100644 --- a/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc +++ b/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" #include "mediapipe/calculators/tensor/tensors_to_detections_calculator.pb.h" @@ -329,7 +330,7 @@ absl::Status TensorsToDetectionsCalculator::Process(CalculatorContext* cc) { } else if (status.code() == absl::StatusCode::kFailedPrecondition) { // For initialization error because of hardware limitation, fallback to // CPU processing. - LOG(WARNING) << status.message(); + ABSL_LOG(WARNING) << status.message(); } else { // For other error, let the error propagates. return status; @@ -668,7 +669,7 @@ absl::Status TensorsToDetectionsCalculator::ProcessGPU( output_detections)); #else - LOG(ERROR) << "GPU input on non-Android not supported yet."; + ABSL_LOG(ERROR) << "GPU input on non-Android not supported yet."; #endif // !defined(MEDIAPIPE_DISABLE_GL_COMPUTE) return absl::OkStatus(); } diff --git a/mediapipe/calculators/tensorflow/BUILD b/mediapipe/calculators/tensorflow/BUILD index 4af094f13..21cc24e3a 100644 --- a/mediapipe/calculators/tensorflow/BUILD +++ b/mediapipe/calculators/tensorflow/BUILD @@ -488,10 +488,10 @@ cc_library( "//mediapipe/calculators/tensorflow:tensorflow_session_from_frozen_graph_calculator_cc_proto", "//mediapipe/framework:calculator_framework", "//mediapipe/framework/deps:clock", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:status_util", + "@com_google_absl//absl/log:absl_log", "@org_tensorflow//tensorflow/core:protos_all_cc", ] + select({ "//conditions:default": [ @@ -519,10 +519,10 @@ cc_library( ":tensorflow_session_from_frozen_graph_generator_cc_proto", "//mediapipe/framework:calculator_framework", "//mediapipe/framework/deps:clock", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:status_util", + "@com_google_absl//absl/log:absl_log", "@org_tensorflow//tensorflow/core:protos_all_cc", ] + select({ "//conditions:default": [ @@ -555,6 +555,7 @@ cc_library( "//mediapipe/framework/deps:file_path", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@org_tensorflow//tensorflow/cc/saved_model:constants", "@org_tensorflow//tensorflow/cc/saved_model:loader_lite", @@ -632,6 +633,7 @@ cc_library( "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:status_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@org_tensorflow//tensorflow/cc/saved_model:constants", @@ -653,6 +655,7 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@org_tensorflow//tensorflow/core:framework", ], alwayslink = 1, @@ -778,6 +781,7 @@ cc_library( "//mediapipe/framework/port:status", "//mediapipe/util:audio_decoder_cc_proto", "//mediapipe/util/sequence:media_sequence", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@org_tensorflow//tensorflow/core:protos_all_cc", ], @@ -792,6 +796,7 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@org_tensorflow//tensorflow/core:framework", ], alwayslink = 1, @@ -805,6 +810,7 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@org_tensorflow//tensorflow/core:framework", ], alwayslink = 1, @@ -818,6 +824,7 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@org_tensorflow//tensorflow/core:framework", ], alwayslink = 1, @@ -831,6 +838,7 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework:packet", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@org_tensorflow//tensorflow/core:protos_all_cc", ], alwayslink = 1, @@ -1167,6 +1175,7 @@ cc_test( "//mediapipe/framework/port:rectangle", "//mediapipe/util:audio_decoder_cc_proto", "//mediapipe/util/sequence:media_sequence", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", "@org_tensorflow//tensorflow/core:protos_all_cc", @@ -1248,6 +1257,7 @@ cc_test( "//mediapipe/framework/tool:sink", "//mediapipe/framework/tool:validate_type", "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/log:absl_log", ] + select({ "//conditions:default": [ "@org_tensorflow//tensorflow/core:direct_session", diff --git a/mediapipe/calculators/tensorflow/tensor_squeeze_dimensions_calculator.cc b/mediapipe/calculators/tensorflow/tensor_squeeze_dimensions_calculator.cc index ad87297a9..8b938a868 100644 --- a/mediapipe/calculators/tensorflow/tensor_squeeze_dimensions_calculator.cc +++ b/mediapipe/calculators/tensorflow/tensor_squeeze_dimensions_calculator.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensorflow/tensor_squeeze_dimensions_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/ret_check.h" @@ -99,10 +100,11 @@ class TensorSqueezeDimensionsCalculator : public CalculatorBase { } } if (remove_dims_.empty()) { - LOG(ERROR) << "TensorSqueezeDimensionsCalculator is squeezing input with " - "no single-dimensions. Calculator will be a no-op."; - LOG(ERROR) << "Input to TensorSqueezeDimensionsCalculator has shape " - << tensor_shape.DebugString(); + ABSL_LOG(ERROR) + << "TensorSqueezeDimensionsCalculator is squeezing input with " + "no single-dimensions. Calculator will be a no-op."; + ABSL_LOG(ERROR) << "Input to TensorSqueezeDimensionsCalculator has shape " + << tensor_shape.DebugString(); } } }; diff --git a/mediapipe/calculators/tensorflow/tensorflow_inference_calculator_test.cc b/mediapipe/calculators/tensorflow/tensorflow_inference_calculator_test.cc index c93008373..fa74c97c0 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_inference_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_inference_calculator_test.cc @@ -17,6 +17,7 @@ #include #include "absl/flags/flag.h" +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensorflow/tensorflow_inference_calculator.pb.h" #include "mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator.pb.h" #include "mediapipe/framework/calculator_framework.h" @@ -586,12 +587,12 @@ TEST_F(TensorflowInferenceCalculatorTest, TestRecurrentStates) { runner_->Outputs().Tag(kMultipliedTag).packets; ASSERT_EQ(2, output_packets_mult.size()); const tf::Tensor& tensor_mult = output_packets_mult[0].Get(); - LOG(INFO) << "timestamp: " << 0; + ABSL_LOG(INFO) << "timestamp: " << 0; auto expected_tensor = tf::test::AsTensor({3, 8, 15}); tf::test::ExpectTensorEqual(tensor_mult, expected_tensor); const tf::Tensor& tensor_mult1 = output_packets_mult[1].Get(); auto expected_tensor1 = tf::test::AsTensor({9, 32, 75}); - LOG(INFO) << "timestamp: " << 1; + ABSL_LOG(INFO) << "timestamp: " << 1; tf::test::ExpectTensorEqual(tensor_mult1, expected_tensor1); EXPECT_EQ(2, runner_ @@ -627,12 +628,12 @@ TEST_F(TensorflowInferenceCalculatorTest, TestRecurrentStateOverride) { runner_->Outputs().Tag(kMultipliedTag).packets; ASSERT_EQ(2, output_packets_mult.size()); const tf::Tensor& tensor_mult = output_packets_mult[0].Get(); - LOG(INFO) << "timestamp: " << 0; + ABSL_LOG(INFO) << "timestamp: " << 0; auto expected_tensor = tf::test::AsTensor({3, 4, 5}); tf::test::ExpectTensorEqual(tensor_mult, expected_tensor); const tf::Tensor& tensor_mult1 = output_packets_mult[1].Get(); auto expected_tensor1 = tf::test::AsTensor({3, 4, 5}); - LOG(INFO) << "timestamp: " << 1; + ABSL_LOG(INFO) << "timestamp: " << 1; tf::test::ExpectTensorEqual(tensor_mult1, expected_tensor1); EXPECT_EQ(2, runner_ diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_calculator.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_calculator.cc index 1bb2c41fc..358b50cd3 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_calculator.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_calculator.cc @@ -23,12 +23,12 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensorflow/tensorflow_session.h" #include "mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/deps/clock.h" #include "mediapipe/framework/deps/monotonic_clock.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/tool/status_util.h" @@ -156,8 +156,8 @@ class TensorFlowSessionFromFrozenGraphCalculator : public CalculatorBase { cc->OutputSidePackets().Tag(kSessionTag).Set(Adopt(session.release())); const uint64_t end_time = absl::ToUnixMicros(clock->TimeNow()); - LOG(INFO) << "Loaded frozen model in: " << end_time - start_time - << " microseconds."; + ABSL_LOG(INFO) << "Loaded frozen model in: " << end_time - start_time + << " microseconds."; return absl::OkStatus(); } diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator.cc index dc39458da..e340a098b 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator.cc @@ -24,13 +24,13 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensorflow/tensorflow_session.h" #include "mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/deps/clock.h" #include "mediapipe/framework/deps/monotonic_clock.h" #include "mediapipe/framework/port/file_helpers.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/tool/status_util.h" @@ -155,8 +155,8 @@ class TensorFlowSessionFromFrozenGraphGenerator : public PacketGenerator { output_side_packets->Tag(kSessionTag) = Adopt(session.release()); const uint64_t end_time = absl::ToUnixMicros(clock->TimeNow()); - LOG(INFO) << "Loaded frozen model in: " << end_time - start_time - << " microseconds."; + ABSL_LOG(INFO) << "Loaded frozen model in: " << end_time - start_time + << " microseconds."; return absl::OkStatus(); } }; diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator.cc index 18bddbbe3..4ca4cb8d6 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator.cc @@ -17,6 +17,7 @@ #if !defined(__ANDROID__) #include "mediapipe/framework/port/file_helpers.h" #endif +#include "absl/log/absl_log.h" #include "absl/strings/str_replace.h" #include "mediapipe/calculators/tensorflow/tensorflow_session.h" #include "mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator.pb.h" @@ -69,7 +70,7 @@ const std::string MaybeConvertSignatureToTag( [](unsigned char c) { return std::toupper(c); }); output = absl::StrReplaceAll( output, {{"/", "_"}, {"-", "_"}, {".", "_"}, {":", "_"}}); - LOG(INFO) << "Renamed TAG from: " << name << " to " << output; + ABSL_LOG(INFO) << "Renamed TAG from: " << name << " to " << output; return output; } else { return name; diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator.cc index ee69ec56a..959622447 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator.cc @@ -19,6 +19,7 @@ #if !defined(__ANDROID__) #include "mediapipe/framework/port/file_helpers.h" #endif +#include "absl/log/absl_log.h" #include "absl/strings/str_replace.h" #include "mediapipe/calculators/tensorflow/tensorflow_session.h" #include "mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator.pb.h" @@ -75,7 +76,7 @@ const std::string MaybeConvertSignatureToTag( [](unsigned char c) { return std::toupper(c); }); output = absl::StrReplaceAll( output, {{"/", "_"}, {"-", "_"}, {".", "_"}, {":", "_"}}); - LOG(INFO) << "Renamed TAG from: " << name << " to " << output; + ABSL_LOG(INFO) << "Renamed TAG from: " << name << " to " << output; return output; } else { return name; diff --git a/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator.cc b/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator.cc index a14c6bd95..c77c0f3f8 100644 --- a/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator.cc +++ b/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "absl/container/flat_hash_map.h" +#include "absl/log/absl_log.h" #include "absl/strings/match.h" #include "mediapipe/calculators/core/packet_resampler_calculator.pb.h" #include "mediapipe/calculators/tensorflow/unpack_media_sequence_calculator.pb.h" @@ -201,8 +202,8 @@ class UnpackMediaSequenceCalculator : public CalculatorBase { first_timestamp_seen_ = Timestamp::OneOverPostStream().Value(); for (const auto& map_kv : sequence_->feature_lists().feature_list()) { if (absl::StrContains(map_kv.first, "/timestamp")) { - LOG(INFO) << "Found feature timestamps: " << map_kv.first - << " with size: " << map_kv.second.feature_size(); + ABSL_LOG(INFO) << "Found feature timestamps: " << map_kv.first + << " with size: " << map_kv.second.feature_size(); int64_t recent_timestamp = Timestamp::PreStream().Value(); for (int i = 0; i < map_kv.second.feature_size(); ++i) { int64_t next_timestamp = @@ -309,8 +310,8 @@ class UnpackMediaSequenceCalculator : public CalculatorBase { audio_decoder_options->set_end_time( end_time + options.extra_padding_from_media_decoder()); } - LOG(INFO) << "Created AudioDecoderOptions:\n" - << audio_decoder_options->DebugString(); + ABSL_LOG(INFO) << "Created AudioDecoderOptions:\n" + << audio_decoder_options->DebugString(); cc->OutputSidePackets() .Tag(kAudioDecoderOptions) .Set(Adopt(audio_decoder_options.release())); @@ -331,8 +332,8 @@ class UnpackMediaSequenceCalculator : public CalculatorBase { ->set_end_time(Timestamp::FromSeconds(end_time).Value()); } - LOG(INFO) << "Created PacketResamplerOptions:\n" - << resampler_options->DebugString(); + ABSL_LOG(INFO) << "Created PacketResamplerOptions:\n" + << resampler_options->DebugString(); cc->OutputSidePackets() .Tag(kPacketResamplerOptions) .Set(Adopt(resampler_options.release())); @@ -351,7 +352,8 @@ class UnpackMediaSequenceCalculator : public CalculatorBase { absl::Status Process(CalculatorContext* cc) override { if (timestamps_.empty()) { // This occurs when we only have metadata to unpack. - LOG(INFO) << "only unpacking metadata because there are no timestamps."; + ABSL_LOG(INFO) + << "only unpacking metadata because there are no timestamps."; return tool::StatusStop(); } // In Process(), we loop through timestamps on a reference stream and emit diff --git a/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc b/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc index addb4a27a..2fa70de39 100644 --- a/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/numbers.h" #include "mediapipe/calculators/core/packet_resampler_calculator.pb.h" @@ -81,7 +82,7 @@ class UnpackMediaSequenceCalculatorTest : public ::testing::Test { if (options != nullptr) { *config.mutable_options() = *options; } - LOG(INFO) << config.DebugString(); + ABSL_LOG(INFO) << config.DebugString(); runner_ = absl::make_unique(config); } diff --git a/mediapipe/calculators/tensorflow/unpack_yt8m_sequence_example_calculator.cc b/mediapipe/calculators/tensorflow/unpack_yt8m_sequence_example_calculator.cc index efb3037f8..508112e52 100644 --- a/mediapipe/calculators/tensorflow/unpack_yt8m_sequence_example_calculator.cc +++ b/mediapipe/calculators/tensorflow/unpack_yt8m_sequence_example_calculator.cc @@ -14,6 +14,7 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensorflow/lapped_tensor_buffer_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/packet.h" @@ -149,8 +150,9 @@ class UnpackYt8mSequenceExampleCalculator : public CalculatorBase { .Set(MakePacket(segment_size)); } } - LOG(INFO) << "Reading the sequence example that contains yt8m id: " - << yt8m_id << ". Feature list length: " << feature_list_length_; + ABSL_LOG(INFO) << "Reading the sequence example that contains yt8m id: " + << yt8m_id + << ". Feature list length: " << feature_list_length_; return absl::OkStatus(); } diff --git a/mediapipe/calculators/tensorflow/vector_float_to_tensor_calculator.cc b/mediapipe/calculators/tensorflow/vector_float_to_tensor_calculator.cc index 28184a8ca..dd0991cbf 100644 --- a/mediapipe/calculators/tensorflow/vector_float_to_tensor_calculator.cc +++ b/mediapipe/calculators/tensorflow/vector_float_to_tensor_calculator.cc @@ -14,6 +14,7 @@ // // Converts vector (or vector>) to 1D (or 2D) tf::Tensor. +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensorflow/vector_float_to_tensor_calculator_options.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/ret_check.h" @@ -68,7 +69,7 @@ absl::Status VectorFloatToTensorCalculator::GetContract( // Output vector. ); } else { - LOG(FATAL) << "input size not supported"; + ABSL_LOG(FATAL) << "input size not supported"; } RET_CHECK_EQ(cc->Outputs().NumEntries(), 1) << "Only one output stream is supported."; @@ -125,7 +126,7 @@ absl::Status VectorFloatToTensorCalculator::Process(CalculatorContext* cc) { } cc->Outputs().Index(0).Add(output.release(), cc->InputTimestamp()); } else { - LOG(FATAL) << "input size not supported"; + ABSL_LOG(FATAL) << "input size not supported"; } return absl::OkStatus(); } diff --git a/mediapipe/calculators/tensorflow/vector_int_to_tensor_calculator.cc b/mediapipe/calculators/tensorflow/vector_int_to_tensor_calculator.cc index cb90276ae..482f8c606 100644 --- a/mediapipe/calculators/tensorflow/vector_int_to_tensor_calculator.cc +++ b/mediapipe/calculators/tensorflow/vector_int_to_tensor_calculator.cc @@ -15,6 +15,7 @@ // Converts a single int or vector or vector> to 1D (or 2D) // tf::Tensor. +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensorflow/vector_int_to_tensor_calculator_options.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/ret_check.h" @@ -86,7 +87,7 @@ absl::Status VectorIntToTensorCalculator::GetContract(CalculatorContract* cc) { cc->Inputs().Tag(kVectorInt).Set>(); } } else { - LOG(FATAL) << "input size not supported"; + ABSL_LOG(FATAL) << "input size not supported"; } RET_CHECK_EQ(cc->Outputs().NumEntries(), 1) << "Only one output stream is supported."; @@ -140,7 +141,7 @@ absl::Status VectorIntToTensorCalculator::Process(CalculatorContext* cc) { AssignMatrixValue(c, r, input[r][c], output.get()); break; default: - LOG(FATAL) << "tensor data type is not supported."; + ABSL_LOG(FATAL) << "tensor data type is not supported."; } } } @@ -158,7 +159,7 @@ absl::Status VectorIntToTensorCalculator::Process(CalculatorContext* cc) { AssignMatrixValue(r, c, input[r][c], output.get()); break; default: - LOG(FATAL) << "tensor data type is not supported."; + ABSL_LOG(FATAL) << "tensor data type is not supported."; } } } @@ -188,12 +189,12 @@ absl::Status VectorIntToTensorCalculator::Process(CalculatorContext* cc) { output->tensor()(i) = input.at(i); break; default: - LOG(FATAL) << "tensor data type is not supported."; + ABSL_LOG(FATAL) << "tensor data type is not supported."; } } cc->Outputs().Tag(kTensorOut).Add(output.release(), cc->InputTimestamp()); } else { - LOG(FATAL) << "input size not supported"; + ABSL_LOG(FATAL) << "input size not supported"; } return absl::OkStatus(); } diff --git a/mediapipe/calculators/tensorflow/vector_string_to_tensor_calculator.cc b/mediapipe/calculators/tensorflow/vector_string_to_tensor_calculator.cc index 139511271..57ee553c5 100644 --- a/mediapipe/calculators/tensorflow/vector_string_to_tensor_calculator.cc +++ b/mediapipe/calculators/tensorflow/vector_string_to_tensor_calculator.cc @@ -15,6 +15,7 @@ // Converts vector (or vector>) to 1D (or 2D) // tf::Tensor. +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensorflow/vector_string_to_tensor_calculator_options.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/ret_check.h" @@ -69,7 +70,7 @@ absl::Status VectorStringToTensorCalculator::GetContract( // Input vector. ); } else { - LOG(FATAL) << "input size not supported"; + ABSL_LOG(FATAL) << "input size not supported"; } RET_CHECK_EQ(cc->Outputs().NumEntries(), 1) << "Only one output stream is supported."; @@ -129,7 +130,7 @@ absl::Status VectorStringToTensorCalculator::Process(CalculatorContext* cc) { } cc->Outputs().Index(0).Add(output.release(), cc->InputTimestamp()); } else { - LOG(FATAL) << "input size not supported"; + ABSL_LOG(FATAL) << "input size not supported"; } return absl::OkStatus(); } diff --git a/mediapipe/calculators/tflite/BUILD b/mediapipe/calculators/tflite/BUILD index 333de2069..7b37d7f6b 100644 --- a/mediapipe/calculators/tflite/BUILD +++ b/mediapipe/calculators/tflite/BUILD @@ -103,6 +103,7 @@ cc_library( "//mediapipe/framework/formats/object_detection:anchor_cc_proto", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) @@ -196,10 +197,12 @@ cc_library( deps = [ ":tflite_inference_calculator_cc_proto", "//mediapipe/framework:calculator_framework", + "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/stream_handler:fixed_size_input_stream_handler", "//mediapipe/util/tflite:config", "//mediapipe/util/tflite:tflite_model_loader", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@org_tensorflow//tensorflow/lite:framework", "@org_tensorflow//tensorflow/lite/delegates/xnnpack:xnnpack_delegate", @@ -392,6 +395,7 @@ cc_library( "//mediapipe/framework/formats/object_detection:anchor_cc_proto", "//mediapipe/framework/port:ret_check", "//mediapipe/util/tflite:config", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/types:span", "@org_tensorflow//tensorflow/lite:framework", diff --git a/mediapipe/calculators/tflite/ssd_anchors_calculator.cc b/mediapipe/calculators/tflite/ssd_anchors_calculator.cc index 5ed5a95dc..9f2649dea 100644 --- a/mediapipe/calculators/tflite/ssd_anchors_calculator.cc +++ b/mediapipe/calculators/tflite/ssd_anchors_calculator.cc @@ -16,6 +16,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tflite/ssd_anchors_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/object_detection/anchor.pb.h" @@ -272,7 +273,7 @@ absl::Status SsdAnchorsCalculator::GenerateAnchors( if (options.feature_map_height_size()) { if (options.strides_size()) { - LOG(ERROR) << "Found feature map shapes. Strides will be ignored."; + ABSL_LOG(ERROR) << "Found feature map shapes. Strides will be ignored."; } CHECK_EQ(options.feature_map_height_size(), kNumLayers); CHECK_EQ(options.feature_map_height_size(), diff --git a/mediapipe/calculators/tflite/tflite_inference_calculator.cc b/mediapipe/calculators/tflite/tflite_inference_calculator.cc index add9bb1a8..69c7d608c 100644 --- a/mediapipe/calculators/tflite/tflite_inference_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_inference_calculator.cc @@ -17,9 +17,11 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/calculators/tflite/tflite_inference_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" +#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/util/tflite/config.h" @@ -406,8 +408,9 @@ absl::Status TfLiteInferenceCalculator::Open(CalculatorContext* cc) { } if (use_advanced_gpu_api_ && !gpu_input_) { - LOG(WARNING) << "Cannot use advanced GPU APIs, input must be GPU buffers." - "Falling back to the default TFLite API."; + ABSL_LOG(WARNING) + << "Cannot use advanced GPU APIs, input must be GPU buffers." + "Falling back to the default TFLite API."; use_advanced_gpu_api_ = false; } CHECK(!use_advanced_gpu_api_ || gpu_inference_); @@ -1053,7 +1056,7 @@ absl::Status TfLiteInferenceCalculator::LoadDelegate(CalculatorContext* cc) { gpu_data_in_[i]->shape.w * gpu_data_in_[i]->shape.c; // Input to model can be RGBA only. if (tensor->dims->data[3] != 4) { - LOG(WARNING) << "Please ensure input GPU tensor is 4 channels."; + ABSL_LOG(WARNING) << "Please ensure input GPU tensor is 4 channels."; } const std::string shader_source = absl::Substitute(R"(#include diff --git a/mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator.cc b/mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator.cc index 2ed62c46d..6213d50a0 100644 --- a/mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" #include "mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator.pb.h" @@ -541,7 +542,7 @@ absl::Status TfLiteTensorsToDetectionsCalculator::ProcessGPU( output_detections)); #else - LOG(ERROR) << "GPU input on non-Android not supported yet."; + ABSL_LOG(ERROR) << "GPU input on non-Android not supported yet."; #endif // MEDIAPIPE_TFLITE_GL_INFERENCE return absl::OkStatus(); } diff --git a/mediapipe/calculators/util/BUILD b/mediapipe/calculators/util/BUILD index 2177971d6..a5ad3a425 100644 --- a/mediapipe/calculators/util/BUILD +++ b/mediapipe/calculators/util/BUILD @@ -183,9 +183,9 @@ cc_library( "//mediapipe/framework:calculator_options_cc_proto", "//mediapipe/framework:timestamp", "//mediapipe/framework/deps:clock", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/time", ], @@ -254,7 +254,6 @@ cc_library( "//mediapipe/framework/formats:image_frame_opencv", "//mediapipe/framework/formats:image_opencv", "//mediapipe/framework/formats:video_stream_header", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:status", @@ -262,6 +261,7 @@ cc_library( "//mediapipe/util:annotation_renderer", "//mediapipe/util:color_cc_proto", "//mediapipe/util:render_data_cc_proto", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ] + select({ "//mediapipe/gpu:disable_gpu": [], @@ -376,9 +376,9 @@ cc_library( "//mediapipe/framework/formats:detection_cc_proto", "//mediapipe/framework/formats:image_frame", "//mediapipe/framework/formats:location", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:rectangle", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) @@ -1151,6 +1151,7 @@ cc_library( "//mediapipe/framework/port:file_helpers", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) diff --git a/mediapipe/calculators/util/annotation_overlay_calculator.cc b/mediapipe/calculators/util/annotation_overlay_calculator.cc index 0dfb3d03a..f31ce9159 100644 --- a/mediapipe/calculators/util/annotation_overlay_calculator.cc +++ b/mediapipe/calculators/util/annotation_overlay_calculator.cc @@ -14,6 +14,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "mediapipe/calculators/util/annotation_overlay_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" @@ -24,7 +25,6 @@ #include "mediapipe/framework/formats/image_frame_opencv.h" #include "mediapipe/framework/formats/image_opencv.h" #include "mediapipe/framework/formats/video_stream_header.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/opencv_core_inc.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" #include "mediapipe/framework/port/status.h" @@ -274,7 +274,8 @@ absl::Status AnnotationOverlayCalculator::Open(CalculatorContext* cc) { renderer_->SetFlipTextVertically(options_.flip_text_vertically()); if (use_gpu_) renderer_->SetScaleFactor(options_.gpu_scale_factor()); if (renderer_->GetScaleFactor() < 1.0 && HasImageTag(cc)) - LOG(WARNING) << "Annotation scale factor only supports GPU backed Image."; + ABSL_LOG(WARNING) + << "Annotation scale factor only supports GPU backed Image."; // Set the output header based on the input header (if present). const char* tag = HasImageTag(cc) ? kImageTag diff --git a/mediapipe/calculators/util/local_file_pattern_contents_calculator.cc b/mediapipe/calculators/util/local_file_pattern_contents_calculator.cc index a9bc51f66..d83ff67c0 100644 --- a/mediapipe/calculators/util/local_file_pattern_contents_calculator.cc +++ b/mediapipe/calculators/util/local_file_pattern_contents_calculator.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/file_helpers.h" #include "mediapipe/framework/port/status.h" @@ -58,7 +59,7 @@ class LocalFilePatternContentsCalculator : public CalculatorBase { absl::Status Process(CalculatorContext* cc) override { if (current_output_ < filenames_.size()) { auto contents = absl::make_unique(); - LOG(INFO) << filenames_[current_output_]; + ABSL_LOG(INFO) << filenames_[current_output_]; MP_RETURN_IF_ERROR(mediapipe::file::GetContents( filenames_[current_output_], contents.get())); ++current_output_; diff --git a/mediapipe/calculators/util/non_max_suppression_calculator.cc b/mediapipe/calculators/util/non_max_suppression_calculator.cc index 535e2a719..0aff4388b 100644 --- a/mediapipe/calculators/util/non_max_suppression_calculator.cc +++ b/mediapipe/calculators/util/non_max_suppression_calculator.cc @@ -18,12 +18,12 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/util/non_max_suppression_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/detection.pb.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/framework/formats/location.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/rectangle.h" #include "mediapipe/framework/port/status.h" @@ -92,7 +92,7 @@ float OverlapSimilarity( normalization = rect1.Area() + rect2.Area() - intersection_area; break; default: - LOG(FATAL) << "Unrecognized overlap type: " << overlap_type; + ABSL_LOG(FATAL) << "Unrecognized overlap type: " << overlap_type; } return normalization > 0.0f ? intersection_area / normalization : 0.0f; } diff --git a/mediapipe/calculators/util/packet_latency_calculator.cc b/mediapipe/calculators/util/packet_latency_calculator.cc index 6509f016f..39c98bdd0 100644 --- a/mediapipe/calculators/util/packet_latency_calculator.cc +++ b/mediapipe/calculators/util/packet_latency_calculator.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/time/time.h" #include "mediapipe/calculators/util/latency.pb.h" @@ -20,7 +21,6 @@ #include "mediapipe/framework/calculator_options.pb.h" #include "mediapipe/framework/deps/clock.h" #include "mediapipe/framework/deps/monotonic_clock.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/timestamp.h" @@ -237,7 +237,7 @@ absl::Status PacketLatencyCalculator::Process(CalculatorContext* cc) { } if (first_process_time_usec_ < 0) { - LOG(WARNING) << "No reference packet received."; + ABSL_LOG(WARNING) << "No reference packet received."; return absl::OkStatus(); } diff --git a/mediapipe/calculators/video/BUILD b/mediapipe/calculators/video/BUILD index 569fd8bad..baf5f11f4 100644 --- a/mediapipe/calculators/video/BUILD +++ b/mediapipe/calculators/video/BUILD @@ -132,6 +132,7 @@ cc_library( "//mediapipe/framework/port:opencv_video", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:status_util", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) @@ -153,6 +154,7 @@ cc_library( "//mediapipe/framework/port:source_location", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:status_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], alwayslink = 1, @@ -193,6 +195,7 @@ cc_library( "//mediapipe/util/tracking:motion_estimation", "//mediapipe/util/tracking:motion_models", "//mediapipe/util/tracking:region_flow_cc_proto", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], alwayslink = 1, @@ -205,10 +208,10 @@ cc_library( ":flow_packager_calculator_cc_proto", "//mediapipe/framework:calculator_framework", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/util/tracking:camera_motion_cc_proto", "//mediapipe/util/tracking:flow_packager", "//mediapipe/util/tracking:region_flow_cc_proto", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", ], @@ -225,7 +228,6 @@ cc_library( "//mediapipe/framework/formats:image_frame_opencv", "//mediapipe/framework/formats:video_stream_header", # fixdeps: keep -- required for exobazel build. "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", @@ -236,6 +238,7 @@ cc_library( "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/container:node_hash_map", "@com_google_absl//absl/container:node_hash_set", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], alwayslink = 1, @@ -251,7 +254,6 @@ cc_library( "//mediapipe/framework/formats:image_frame_opencv", "//mediapipe/framework/formats:video_stream_header", # fixdeps: keep -- required for exobazel build. "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_features2d", "//mediapipe/framework/port:ret_check", @@ -263,6 +265,7 @@ cc_library( "//mediapipe/util/tracking:box_tracker_cc_proto", "//mediapipe/util/tracking:flow_packager_cc_proto", "//mediapipe/util/tracking:tracking_visualization_utilities", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", ] + select({ @@ -359,12 +362,12 @@ cc_test( "//mediapipe/framework/formats:video_stream_header", "//mediapipe/framework/port:gtest_main", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_highgui", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:opencv_video", "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/tool:test_util", + "@com_google_absl//absl/log:absl_log", ], ) @@ -448,6 +451,7 @@ cc_test( "//mediapipe/framework/tool:test_util", "//mediapipe/util/tracking:box_tracker_cc_proto", "//mediapipe/util/tracking:tracking_cc_proto", + "@com_google_absl//absl/log:absl_log", ], ) diff --git a/mediapipe/calculators/video/box_detector_calculator.cc b/mediapipe/calculators/video/box_detector_calculator.cc index 14ac12e5e..edba9372a 100644 --- a/mediapipe/calculators/video/box_detector_calculator.cc +++ b/mediapipe/calculators/video/box_detector_calculator.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/numbers.h" #include "mediapipe/calculators/video/box_detector_calculator.pb.h" @@ -25,7 +26,6 @@ #include "mediapipe/framework/formats/image_frame_opencv.h" #include "mediapipe/framework/formats/video_stream_header.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/opencv_core_inc.h" #include "mediapipe/framework/port/opencv_features2d_inc.h" #include "mediapipe/framework/port/ret_check.h" @@ -198,7 +198,8 @@ absl::Status BoxDetectorCalculator::Open(CalculatorContext* cc) { if (!predefined_index.ParseFromString(cc->InputSidePackets() .Tag(kIndexProtoStringTag) .Get())) { - LOG(FATAL) << "failed to parse BoxDetectorIndex from INDEX_PROTO_STRING"; + ABSL_LOG(FATAL) + << "failed to parse BoxDetectorIndex from INDEX_PROTO_STRING"; } box_detector_->AddBoxDetectorIndex(predefined_index); } @@ -210,7 +211,7 @@ absl::Status BoxDetectorCalculator::Open(CalculatorContext* cc) { MP_RETURN_IF_ERROR(file::GetContents(string_path, &index_string)); BoxDetectorIndex predefined_index; if (!predefined_index.ParseFromString(index_string)) { - LOG(FATAL) + ABSL_LOG(FATAL) << "failed to parse BoxDetectorIndex from index_proto_filename"; } box_detector_->AddBoxDetectorIndex(predefined_index); @@ -248,7 +249,7 @@ absl::Status BoxDetectorCalculator::Process(CalculatorContext* cc) { BoxDetectorIndex predefined_index; if (!predefined_index.ParseFromString( add_index_stream->Get())) { - LOG(FATAL) << "failed to parse BoxDetectorIndex from ADD_INDEX"; + ABSL_LOG(FATAL) << "failed to parse BoxDetectorIndex from ADD_INDEX"; } box_detector_->AddBoxDetectorIndex(predefined_index); } diff --git a/mediapipe/calculators/video/box_tracker_calculator.cc b/mediapipe/calculators/video/box_tracker_calculator.cc index b5f3b5b0b..8241a155b 100644 --- a/mediapipe/calculators/video/box_tracker_calculator.cc +++ b/mediapipe/calculators/video/box_tracker_calculator.cc @@ -22,6 +22,7 @@ #include "absl/container/flat_hash_set.h" #include "absl/container/node_hash_map.h" #include "absl/container/node_hash_set.h" +#include "absl/log/absl_log.h" #include "absl/strings/numbers.h" #include "mediapipe/calculators/video/box_tracker_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" @@ -29,7 +30,6 @@ #include "mediapipe/framework/formats/image_frame_opencv.h" #include "mediapipe/framework/formats/video_stream_header.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/parse_text_proto.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" @@ -358,7 +358,7 @@ void ConvertCoordinateForRotation(float in_top, float in_left, float in_bottom, out_height = in_width; break; default: - LOG(ERROR) << "invalid rotation " << rotation; + ABSL_LOG(ERROR) << "invalid rotation " << rotation; out_center_x = in_center_x; out_center_y = in_center_y; out_width = in_width; @@ -384,7 +384,8 @@ void AddStateToPath(const MotionBoxState& state, int64_t time_msec, path->insert(insert_pos, InternalTimedBox(result, new MotionBoxState(state))); } else { - LOG(ERROR) << "Box at time " << time_msec << " already present; ignoring"; + ABSL_LOG(ERROR) << "Box at time " << time_msec + << " already present; ignoring"; } } @@ -486,8 +487,9 @@ absl::Status BoxTrackerCalculator::Open(CalculatorContext* cc) { #if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__) if (cc->InputSidePackets().HasTag(kInitialPosTag)) { - LOG(INFO) << "Parsing: " - << cc->InputSidePackets().Tag(kInitialPosTag).Get(); + ABSL_LOG(INFO) + << "Parsing: " + << cc->InputSidePackets().Tag(kInitialPosTag).Get(); initial_pos_ = ParseTextProtoOrDie( cc->InputSidePackets().Tag(kInitialPosTag).Get()); } @@ -624,7 +626,7 @@ absl::Status BoxTrackerCalculator::Process(CalculatorContext* cc) { if (cancel_object_id_stream && !cancel_object_id_stream->IsEmpty()) { const int cancel_object_id = cancel_object_id_stream->Get(); if (streaming_motion_boxes_.erase(cancel_object_id) == 0) { - LOG(WARNING) << "box id " << cancel_object_id << " does not exist."; + ABSL_LOG(WARNING) << "box id " << cancel_object_id << " does not exist."; } } @@ -944,7 +946,7 @@ void BoxTrackerCalculator::OutputRandomAccessTrack( const bool forward_track = start.time_msec() < end_time_msec; if (track_timestamps_.empty()) { - LOG(WARNING) << "No tracking data cached yet."; + ABSL_LOG(WARNING) << "No tracking data cached yet."; continue; } @@ -954,27 +956,27 @@ void BoxTrackerCalculator::OutputRandomAccessTrack( const int64_t tracking_end_timestamp_msec = track_timestamps_.back().Microseconds() / 1000; if (start.time_msec() < tracking_start_timestamp_msec) { - LOG(WARNING) << "Request start timestamp " << start.time_msec() - << " too old. First frame in the window: " - << tracking_start_timestamp_msec; + ABSL_LOG(WARNING) << "Request start timestamp " << start.time_msec() + << " too old. First frame in the window: " + << tracking_start_timestamp_msec; continue; } if (start.time_msec() > tracking_end_timestamp_msec) { - LOG(WARNING) << "Request start timestamp " << start.time_msec() - << " too new. Last frame in the window: " - << tracking_end_timestamp_msec; + ABSL_LOG(WARNING) << "Request start timestamp " << start.time_msec() + << " too new. Last frame in the window: " + << tracking_end_timestamp_msec; continue; } if (end_time_msec < tracking_start_timestamp_msec) { - LOG(WARNING) << "Request end timestamp " << end_time_msec - << " too old. First frame in the window: " - << tracking_start_timestamp_msec; + ABSL_LOG(WARNING) << "Request end timestamp " << end_time_msec + << " too old. First frame in the window: " + << tracking_start_timestamp_msec; continue; } if (end_time_msec > tracking_end_timestamp_msec) { - LOG(WARNING) << "Request end timestamp " << end_time_msec - << " too new. Last frame in the window: " - << tracking_end_timestamp_msec; + ABSL_LOG(WARNING) << "Request end timestamp " << end_time_msec + << " too new. Last frame in the window: " + << tracking_end_timestamp_msec; continue; } @@ -982,7 +984,7 @@ void BoxTrackerCalculator::OutputRandomAccessTrack( GetRandomAccessTimestampPos(start, forward_track); if (timestamp_pos == track_timestamps_.end()) { - LOG(ERROR) << "Random access outside cached range"; + ABSL_LOG(ERROR) << "Random access outside cached range"; continue; } @@ -993,7 +995,7 @@ void BoxTrackerCalculator::OutputRandomAccessTrack( // TODO: Interpolate random access tracking start_data instead // of dropping the request in the case of missing processed frame. if (start_data == tracking_data_cache_.end()) { - LOG(ERROR) << "Random access starts at unprocessed frame."; + ABSL_LOG(ERROR) << "Random access starts at unprocessed frame."; continue; } @@ -1010,7 +1012,7 @@ void BoxTrackerCalculator::OutputRandomAccessTrack( &single_map, end_time_msec); if (track_error) { - LOG(ERROR) << "Could not track box."; + ABSL_LOG(ERROR) << "Could not track box."; continue; } @@ -1197,7 +1199,7 @@ void BoxTrackerCalculator::StreamTrack(const TrackingData& data, if (!motion_box.second.box.TrackStep(from_frame, // from frame. mvf, forward)) { failed_ids->push_back(motion_box.first); - LOG(INFO) << "lost track. pushed failed id: " << motion_box.first; + ABSL_LOG(INFO) << "lost track. pushed failed id: " << motion_box.first; } else { // Store result. PathSegment& path = motion_box.second.path; @@ -1224,8 +1226,8 @@ void BoxTrackerCalculator::FastForwardStartPos( track_timestamps_.end(), timestamp); if (timestamp_pos == track_timestamps_.end()) { - LOG(WARNING) << "Received start pos beyond current timestamp, " - << "Starting to track once frame arrives."; + ABSL_LOG(WARNING) << "Received start pos beyond current timestamp, " + << "Starting to track once frame arrives."; *initial_pos_.add_box() = start_pos; continue; } @@ -1242,8 +1244,9 @@ void BoxTrackerCalculator::FastForwardStartPos( -> bool { return item.first == timestamp_pos[0]; }); if (start_data == tracking_data_cache_.end()) { - LOG(ERROR) << "Box to fast forward outside tracking data cache. Ignoring." - << " To avoid this error consider increasing the cache size."; + ABSL_LOG(ERROR) + << "Box to fast forward outside tracking data cache. Ignoring." + << " To avoid this error consider increasing the cache size."; continue; } @@ -1281,7 +1284,8 @@ void BoxTrackerCalculator::FastForwardStartPos( true, // forward &single_map, &failed_box); if (!failed_box.empty()) { - LOG(WARNING) << "Unable to fast forward box at frame " << curr_frame; + ABSL_LOG(WARNING) << "Unable to fast forward box at frame " + << curr_frame; track_error = true; break; } diff --git a/mediapipe/calculators/video/flow_packager_calculator.cc b/mediapipe/calculators/video/flow_packager_calculator.cc index 2965cd8e6..e84733ee6 100644 --- a/mediapipe/calculators/video/flow_packager_calculator.cc +++ b/mediapipe/calculators/video/flow_packager_calculator.cc @@ -17,12 +17,12 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "mediapipe/calculators/video/flow_packager_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/util/tracking/camera_motion.pb.h" #include "mediapipe/util/tracking/flow_packager.h" #include "mediapipe/util/tracking/region_flow.pb.h" @@ -227,10 +227,11 @@ absl::Status FlowPackagerCalculator::Close(CalculatorContext* cc) { void FlowPackagerCalculator::WriteChunk(const TrackingDataChunk& chunk) const { if (chunk.item_size() == 0) { - LOG(ERROR) << "Write chunk called with empty tracking data." - << "This can only occur if the spacing between frames " - << "is larger than the requested chunk size. Try increasing " - << "the chunk size"; + ABSL_LOG(ERROR) + << "Write chunk called with empty tracking data." + << "This can only occur if the spacing between frames " + << "is larger than the requested chunk size. Try increasing " + << "the chunk size"; return; } @@ -242,7 +243,7 @@ void FlowPackagerCalculator::WriteChunk(const TrackingDataChunk& chunk) const { chunk_file = cache_dir_ + "/" + absl::StrFormat(*format_runtime, chunk_idx_); } else { - LOG(ERROR) << "chache_file_format wrong. fall back to chunk_%04d."; + ABSL_LOG(ERROR) << "chache_file_format wrong. fall back to chunk_%04d."; chunk_file = cache_dir_ + "/" + absl::StrFormat("chunk_%04d", chunk_idx_); } @@ -252,23 +253,23 @@ void FlowPackagerCalculator::WriteChunk(const TrackingDataChunk& chunk) const { const char* temp_filename = tempnam(cache_dir_.c_str(), nullptr); std::ofstream out_file(temp_filename); if (!out_file) { - LOG(ERROR) << "Could not open " << temp_filename; + ABSL_LOG(ERROR) << "Could not open " << temp_filename; } else { out_file.write(data.data(), data.size()); } if (rename(temp_filename, chunk_file.c_str()) != 0) { - LOG(ERROR) << "Failed to rename to " << chunk_file; + ABSL_LOG(ERROR) << "Failed to rename to " << chunk_file; } - LOG(INFO) << "Wrote chunk : " << chunk_file; + ABSL_LOG(INFO) << "Wrote chunk : " << chunk_file; } void FlowPackagerCalculator::PrepareCurrentForNextChunk( TrackingDataChunk* chunk) { CHECK(chunk); if (chunk->item_size() == 0) { - LOG(ERROR) << "Called with empty chunk. Unexpected."; + ABSL_LOG(ERROR) << "Called with empty chunk. Unexpected."; return; } diff --git a/mediapipe/calculators/video/motion_analysis_calculator.cc b/mediapipe/calculators/video/motion_analysis_calculator.cc index 544439ae8..88e5ff96b 100644 --- a/mediapipe/calculators/video/motion_analysis_calculator.cc +++ b/mediapipe/calculators/video/motion_analysis_calculator.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/numbers.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" @@ -348,8 +349,8 @@ absl::Status MotionAnalysisCalculator::Open(CalculatorContext* cc) { video_header = &(cc->Inputs().Tag(kSelectionTag).Header().Get()); } else { - LOG(WARNING) << "No input video header found. Downstream calculators " - "expecting video headers are likely to fail."; + ABSL_LOG(WARNING) << "No input video header found. Downstream calculators " + "expecting video headers are likely to fail."; } with_saliency_ = options_.analysis_options().compute_motion_saliency(); @@ -357,9 +358,9 @@ absl::Status MotionAnalysisCalculator::Open(CalculatorContext* cc) { if (cc->Outputs().HasTag(kSaliencyTag)) { with_saliency_ = true; if (!options_.analysis_options().compute_motion_saliency()) { - LOG(WARNING) << "Enable saliency computation. Set " - << "compute_motion_saliency to true to silence this " - << "warning."; + ABSL_LOG(WARNING) << "Enable saliency computation. Set " + << "compute_motion_saliency to true to silence this " + << "warning."; options_.mutable_analysis_options()->set_compute_motion_saliency(true); } } @@ -603,8 +604,8 @@ absl::Status MotionAnalysisCalculator::Close(CalculatorContext* cc) { } if (csv_file_input_) { if (!meta_motions_.empty()) { - LOG(ERROR) << "More motions than frames. Unexpected! Remainder: " - << meta_motions_.size(); + ABSL_LOG(ERROR) << "More motions than frames. Unexpected! Remainder: " + << meta_motions_.size(); } } return absl::OkStatus(); @@ -741,8 +742,8 @@ absl::Status MotionAnalysisCalculator::InitOnProcess( } if (region_options->image_format() != image_format && region_options->image_format() != image_format2) { - LOG(WARNING) << "Requested image format in RegionFlowComputation " - << "does not match video stream format. Overriding."; + ABSL_LOG(WARNING) << "Requested image format in RegionFlowComputation " + << "does not match video stream format. Overriding."; region_options->set_image_format(image_format); } @@ -761,7 +762,7 @@ absl::Status MotionAnalysisCalculator::InitOnProcess( frame_width_ = camera_motion.frame_width(); frame_height_ = camera_motion.frame_height(); } else { - LOG(FATAL) << "Either VIDEO or SELECTION stream need to be specified."; + ABSL_LOG(FATAL) << "Either VIDEO or SELECTION stream need to be specified."; } // Filled by CSV file parsing. @@ -800,7 +801,7 @@ bool MotionAnalysisCalculator::ParseModelCSV( for (const auto& value : values) { double value_64f; if (!absl::SimpleAtod(value, &value_64f)) { - LOG(ERROR) << "Not a double, expected!"; + ABSL_LOG(ERROR) << "Not a double, expected!"; return false; } @@ -818,7 +819,7 @@ bool MotionAnalysisCalculator::HomographiesFromValues( // Obvious constants are obvious :D constexpr int kHomographyValues = 9; if (homog_values.size() % kHomographyValues != 0) { - LOG(ERROR) << "Contents not a multiple of " << kHomographyValues; + ABSL_LOG(ERROR) << "Contents not a multiple of " << kHomographyValues; return false; } @@ -830,7 +831,7 @@ bool MotionAnalysisCalculator::HomographiesFromValues( // Normalize last entry to 1. if (h_vals[kHomographyValues - 1] == 0) { - LOG(ERROR) << "Degenerate homography, last entry is zero"; + ABSL_LOG(ERROR) << "Degenerate homography, last entry is zero"; return false; } @@ -844,8 +845,8 @@ bool MotionAnalysisCalculator::HomographiesFromValues( } if (homographies->size() % options_.meta_models_per_frame() != 0) { - LOG(ERROR) << "Total homographies not a multiple of specified models " - << "per frame."; + ABSL_LOG(ERROR) << "Total homographies not a multiple of specified models " + << "per frame."; return false; } diff --git a/mediapipe/calculators/video/opencv_video_decoder_calculator.cc b/mediapipe/calculators/video/opencv_video_decoder_calculator.cc index 9e04f33cb..cda7085da 100644 --- a/mediapipe/calculators/video/opencv_video_decoder_calculator.cc +++ b/mediapipe/calculators/video/opencv_video_decoder_calculator.cc @@ -14,6 +14,7 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/image_format.pb.h" #include "mediapipe/framework/formats/image_frame.h" @@ -168,9 +169,10 @@ class OpenCvVideoDecoderCalculator : public CalculatorBase { .Tag(kSavedAudioPathTag) .Set(MakePacket(saved_audio_path)); } else { - LOG(WARNING) << "FFmpeg can't extract audio from " << input_file_path - << " by executing the following command: " - << ffmpeg_command; + ABSL_LOG(WARNING) << "FFmpeg can't extract audio from " + << input_file_path + << " by executing the following command: " + << ffmpeg_command; cc->OutputSidePackets() .Tag(kSavedAudioPathTag) .Set(MakePacket(std::string())); @@ -227,9 +229,9 @@ class OpenCvVideoDecoderCalculator : public CalculatorBase { cap_->release(); } if (decoded_frames_ != frame_count_) { - LOG(WARNING) << "Not all the frames are decoded (total frames: " - << frame_count_ << " vs decoded frames: " << decoded_frames_ - << ")."; + ABSL_LOG(WARNING) << "Not all the frames are decoded (total frames: " + << frame_count_ + << " vs decoded frames: " << decoded_frames_ << ")."; } return absl::OkStatus(); } diff --git a/mediapipe/calculators/video/opencv_video_encoder_calculator.cc b/mediapipe/calculators/video/opencv_video_encoder_calculator.cc index 4af8c5955..5979d57b0 100644 --- a/mediapipe/calculators/video/opencv_video_encoder_calculator.cc +++ b/mediapipe/calculators/video/opencv_video_encoder_calculator.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_split.h" #include "mediapipe/calculators/video/opencv_video_encoder_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" @@ -187,9 +188,10 @@ absl::Status OpenCvVideoEncoderCalculator::Close(CalculatorContext* cc) { const std::string& audio_file_path = cc->InputSidePackets().Tag(kAudioFilePathTag).Get(); if (audio_file_path.empty()) { - LOG(WARNING) << "OpenCvVideoEncoderCalculator isn't able to attach the " - "audio tracks to the generated video because the audio " - "file path is not specified."; + ABSL_LOG(WARNING) + << "OpenCvVideoEncoderCalculator isn't able to attach the " + "audio tracks to the generated video because the audio " + "file path is not specified."; } else { // A temp output file is needed because FFmpeg can't do in-place editing. const std::string temp_file_path = std::tmpnam(nullptr); diff --git a/mediapipe/calculators/video/tracking_graph_test.cc b/mediapipe/calculators/video/tracking_graph_test.cc index 8fd8806b7..d638d7ae2 100644 --- a/mediapipe/calculators/video/tracking_graph_test.cc +++ b/mediapipe/calculators/video/tracking_graph_test.cc @@ -19,6 +19,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/calculators/video/box_tracker_calculator.pb.h" #include "mediapipe/framework/calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" @@ -52,7 +53,7 @@ bool LoadBinaryTestGraph(const std::string& graph_path, bool success = config->ParseFromZeroCopyStream(&in_stream); ifs.close(); if (!success) { - LOG(ERROR) << "could not parse test graph: " << graph_path; + ABSL_LOG(ERROR) << "could not parse test graph: " << graph_path; } return success; } @@ -620,7 +621,7 @@ TEST_F(TrackingGraphTest, TestTransitionFramesForReacquisition) { // Add TRACK_TIME stream queries in between 2 frames. if (j > 0) { Timestamp track_time = Timestamp((j - 0.5f) * kFrameIntervalUs); - LOG(INFO) << track_time.Value(); + ABSL_LOG(INFO) << track_time.Value(); Packet track_time_packet = Adopt(new Timestamp).At(track_time); MP_EXPECT_OK( graph_.AddPacketToInputStream("track_time", track_time_packet)); diff --git a/mediapipe/examples/coral/BUILD b/mediapipe/examples/coral/BUILD index 68244d579..0c7c6b113 100644 --- a/mediapipe/examples/coral/BUILD +++ b/mediapipe/examples/coral/BUILD @@ -35,6 +35,7 @@ cc_library( "//mediapipe/framework/port:status", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:absl_log", ], ) diff --git a/mediapipe/examples/coral/demo_run_graph_main.cc b/mediapipe/examples/coral/demo_run_graph_main.cc index 6f1c56268..692f26008 100644 --- a/mediapipe/examples/coral/demo_run_graph_main.cc +++ b/mediapipe/examples/coral/demo_run_graph_main.cc @@ -17,6 +17,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/framework/formats/image_frame_opencv.h" @@ -45,17 +46,17 @@ absl::Status RunMPPGraph() { MP_RETURN_IF_ERROR(mediapipe::file::GetContents( absl::GetFlag(FLAGS_calculator_graph_config_file), &calculator_graph_config_contents)); - LOG(INFO) << "Get calculator graph config contents: " - << calculator_graph_config_contents; + ABSL_LOG(INFO) << "Get calculator graph config contents: " + << calculator_graph_config_contents; mediapipe::CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie( calculator_graph_config_contents); - LOG(INFO) << "Initialize the calculator graph."; + ABSL_LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize(config)); - LOG(INFO) << "Initialize the camera or load the video."; + ABSL_LOG(INFO) << "Initialize the camera or load the video."; cv::VideoCapture capture; const bool load_video = !absl::GetFlag(FLAGS_input_video_path).empty(); if (load_video) { @@ -68,7 +69,7 @@ absl::Status RunMPPGraph() { cv::VideoWriter writer; const bool save_video = !absl::GetFlag(FLAGS_output_video_path).empty(); if (save_video) { - LOG(INFO) << "Prepare video writer."; + ABSL_LOG(INFO) << "Prepare video writer."; cv::Mat test_frame; capture.read(test_frame); // Consume first frame. capture.set(cv::CAP_PROP_POS_AVI_RATIO, 0); // Rewind to beginning. @@ -85,12 +86,12 @@ absl::Status RunMPPGraph() { capture.set(cv::CAP_PROP_FPS, 30); } - LOG(INFO) << "Start running the calculator graph."; + ABSL_LOG(INFO) << "Start running the calculator graph."; ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller, graph.AddOutputStreamPoller(kOutputStream)); MP_RETURN_IF_ERROR(graph.StartRun({})); - LOG(INFO) << "Start grabbing and processing frames."; + ABSL_LOG(INFO) << "Start grabbing and processing frames."; bool grab_frames = true; while (grab_frames) { // Capture opencv camera or video frame. @@ -135,7 +136,7 @@ absl::Status RunMPPGraph() { } } - LOG(INFO) << "Shutting down."; + ABSL_LOG(INFO) << "Shutting down."; if (writer.isOpened()) writer.release(); MP_RETURN_IF_ERROR(graph.CloseInputStream(kInputStream)); return graph.WaitUntilDone(); @@ -146,10 +147,10 @@ int main(int argc, char** argv) { absl::ParseCommandLine(argc, argv); absl::Status run_status = RunMPPGraph(); if (!run_status.ok()) { - LOG(ERROR) << "Failed to run the graph: " << run_status.message(); + ABSL_LOG(ERROR) << "Failed to run the graph: " << run_status.message(); return EXIT_FAILURE; } else { - LOG(INFO) << "Success!"; + ABSL_LOG(INFO) << "Success!"; } return EXIT_SUCCESS; } diff --git a/mediapipe/examples/desktop/BUILD b/mediapipe/examples/desktop/BUILD index eec485ef0..3d59c059a 100644 --- a/mediapipe/examples/desktop/BUILD +++ b/mediapipe/examples/desktop/BUILD @@ -31,6 +31,7 @@ cc_library( "//mediapipe/framework/port:statusor", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) @@ -51,6 +52,7 @@ cc_library( "//mediapipe/util:resource_util", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:absl_log", ], ) @@ -77,5 +79,6 @@ cc_library( "//mediapipe/util:resource_util", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:absl_log", ], ) diff --git a/mediapipe/examples/desktop/autoflip/calculators/BUILD b/mediapipe/examples/desktop/autoflip/calculators/BUILD index a3b2ace2a..4ae45ac8f 100644 --- a/mediapipe/examples/desktop/autoflip/calculators/BUILD +++ b/mediapipe/examples/desktop/autoflip/calculators/BUILD @@ -306,6 +306,7 @@ cc_library( "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) diff --git a/mediapipe/examples/desktop/autoflip/calculators/shot_boundary_calculator.cc b/mediapipe/examples/desktop/autoflip/calculators/shot_boundary_calculator.cc index 299f60b10..da655cb65 100644 --- a/mediapipe/examples/desktop/autoflip/calculators/shot_boundary_calculator.cc +++ b/mediapipe/examples/desktop/autoflip/calculators/shot_boundary_calculator.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/examples/desktop/autoflip/calculators/shot_boundary_calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/image_frame.h" @@ -112,8 +113,8 @@ void ShotBoundaryCalculator::Transmit(mediapipe::CalculatorContext* cc, is_shot_change = false; } if (is_shot_change) { - LOG(INFO) << "Shot change at: " << cc->InputTimestamp().Seconds() - << " seconds."; + ABSL_LOG(INFO) << "Shot change at: " << cc->InputTimestamp().Seconds() + << " seconds."; cc->Outputs() .Tag(kShotChangeTag) .AddPacket(Adopt(std::make_unique(true).release()) diff --git a/mediapipe/examples/desktop/autoflip/quality/BUILD b/mediapipe/examples/desktop/autoflip/quality/BUILD index 20e286107..d01d41dc5 100644 --- a/mediapipe/examples/desktop/autoflip/quality/BUILD +++ b/mediapipe/examples/desktop/autoflip/quality/BUILD @@ -53,6 +53,7 @@ cc_library( "//mediapipe/examples/desktop/autoflip:autoflip_messages_cc_proto", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], ) @@ -67,6 +68,7 @@ cc_library( hdrs = ["piecewise_linear_function.h"], deps = [ "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:check", ], ) @@ -192,6 +194,7 @@ cc_library( "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", ], ) @@ -234,6 +237,7 @@ cc_test( "//mediapipe/framework/port:gtest_main", "//mediapipe/framework/port:status", "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", ], ) @@ -327,6 +331,7 @@ cc_library( "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], ) diff --git a/mediapipe/examples/desktop/autoflip/quality/frame_crop_region_computer.cc b/mediapipe/examples/desktop/autoflip/quality/frame_crop_region_computer.cc index 5916d1829..947676cd2 100644 --- a/mediapipe/examples/desktop/autoflip/quality/frame_crop_region_computer.cc +++ b/mediapipe/examples/desktop/autoflip/quality/frame_crop_region_computer.cc @@ -16,6 +16,7 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/examples/desktop/autoflip/quality/utils.h" #include "mediapipe/framework/port/ret_check.h" @@ -137,7 +138,7 @@ void FrameCropRegionComputer::UpdateCropRegionScore( const float feature_score, const bool is_required, float* crop_region_score) { if (feature_score < 0.0) { - LOG(WARNING) << "Ignoring negative score"; + ABSL_LOG(WARNING) << "Ignoring negative score"; return; } @@ -161,7 +162,8 @@ void FrameCropRegionComputer::UpdateCropRegionScore( break; } default: { - LOG(WARNING) << "Unknown CropRegionScoreType " << score_aggregation_type; + ABSL_LOG(WARNING) << "Unknown CropRegionScoreType " + << score_aggregation_type; break; } } diff --git a/mediapipe/examples/desktop/autoflip/quality/piecewise_linear_function.cc b/mediapipe/examples/desktop/autoflip/quality/piecewise_linear_function.cc index fb8f44f11..9cc78a32e 100644 --- a/mediapipe/examples/desktop/autoflip/quality/piecewise_linear_function.cc +++ b/mediapipe/examples/desktop/autoflip/quality/piecewise_linear_function.cc @@ -20,6 +20,7 @@ #include #include +#include "absl/log/check.h" #include "mediapipe/framework/port/status.h" namespace mediapipe { diff --git a/mediapipe/examples/desktop/autoflip/quality/scene_camera_motion_analyzer_test.cc b/mediapipe/examples/desktop/autoflip/quality/scene_camera_motion_analyzer_test.cc index aa3ba5c6e..35cafbbfa 100644 --- a/mediapipe/examples/desktop/autoflip/quality/scene_camera_motion_analyzer_test.cc +++ b/mediapipe/examples/desktop/autoflip/quality/scene_camera_motion_analyzer_test.cc @@ -20,6 +20,7 @@ #include #include "absl/flags/flag.h" +#include "absl/log/check.h" #include "absl/strings/str_split.h" #include "mediapipe/examples/desktop/autoflip/autoflip_messages.pb.h" #include "mediapipe/examples/desktop/autoflip/quality/focus_point.pb.h" diff --git a/mediapipe/examples/desktop/autoflip/quality/utils.cc b/mediapipe/examples/desktop/autoflip/quality/utils.cc index 919459263..0695ff759 100644 --- a/mediapipe/examples/desktop/autoflip/quality/utils.cc +++ b/mediapipe/examples/desktop/autoflip/quality/utils.cc @@ -19,6 +19,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/examples/desktop/autoflip/quality/math_utils.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" @@ -121,12 +122,12 @@ absl::Status PackKeyFrameInfo(const int64_t frame_timestamp_ms, ScaleRect(original_detection.location(), scale_x, scale_y, &location); } else { has_valid_location = false; - LOG(ERROR) << "Detection missing a bounding box, skipped."; + ABSL_LOG(ERROR) << "Detection missing a bounding box, skipped."; } if (has_valid_location) { if (!ClampRect(original_frame_width, original_frame_height, &location) .ok()) { - LOG(ERROR) << "Invalid detection bounding box, skipped."; + ABSL_LOG(ERROR) << "Invalid detection bounding box, skipped."; continue; } auto* detection = processed_detections->add_detections(); diff --git a/mediapipe/examples/desktop/autoflip/quality/visual_scorer.cc b/mediapipe/examples/desktop/autoflip/quality/visual_scorer.cc index 9ae612004..661922fd9 100644 --- a/mediapipe/examples/desktop/autoflip/quality/visual_scorer.cc +++ b/mediapipe/examples/desktop/autoflip/quality/visual_scorer.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/opencv_core_inc.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" #include "mediapipe/framework/port/ret_check.h" @@ -106,7 +107,7 @@ absl::Status VisualScorer::CalculateScore(const cv::Mat& image, *score = (area_score + sharpness_score + colorfulness_score) / weight_sum; if (*score > 1.0f || *score < 0.0f) { - LOG(WARNING) << "Score of region outside expected range: " << *score; + ABSL_LOG(WARNING) << "Score of region outside expected range: " << *score; } return absl::OkStatus(); } diff --git a/mediapipe/examples/desktop/demo_run_graph_main.cc b/mediapipe/examples/desktop/demo_run_graph_main.cc index bb70d3df7..ba36ba6c9 100644 --- a/mediapipe/examples/desktop/demo_run_graph_main.cc +++ b/mediapipe/examples/desktop/demo_run_graph_main.cc @@ -17,6 +17,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/framework/formats/image_frame_opencv.h" @@ -46,17 +47,17 @@ absl::Status RunMPPGraph() { MP_RETURN_IF_ERROR(mediapipe::file::GetContents( absl::GetFlag(FLAGS_calculator_graph_config_file), &calculator_graph_config_contents)); - LOG(INFO) << "Get calculator graph config contents: " - << calculator_graph_config_contents; + ABSL_LOG(INFO) << "Get calculator graph config contents: " + << calculator_graph_config_contents; mediapipe::CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie( calculator_graph_config_contents); - LOG(INFO) << "Initialize the calculator graph."; + ABSL_LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize(config)); - LOG(INFO) << "Initialize the camera or load the video."; + ABSL_LOG(INFO) << "Initialize the camera or load the video."; cv::VideoCapture capture; const bool load_video = !absl::GetFlag(FLAGS_input_video_path).empty(); if (load_video) { @@ -77,12 +78,12 @@ absl::Status RunMPPGraph() { #endif } - LOG(INFO) << "Start running the calculator graph."; + ABSL_LOG(INFO) << "Start running the calculator graph."; ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller, graph.AddOutputStreamPoller(kOutputStream)); MP_RETURN_IF_ERROR(graph.StartRun({})); - LOG(INFO) << "Start grabbing and processing frames."; + ABSL_LOG(INFO) << "Start grabbing and processing frames."; bool grab_frames = true; while (grab_frames) { // Capture opencv camera or video frame. @@ -90,10 +91,10 @@ absl::Status RunMPPGraph() { capture >> camera_frame_raw; if (camera_frame_raw.empty()) { if (!load_video) { - LOG(INFO) << "Ignore empty frames from camera."; + ABSL_LOG(INFO) << "Ignore empty frames from camera."; continue; } - LOG(INFO) << "Empty frame, end of video reached."; + ABSL_LOG(INFO) << "Empty frame, end of video reached."; break; } cv::Mat camera_frame; @@ -126,7 +127,7 @@ absl::Status RunMPPGraph() { cv::cvtColor(output_frame_mat, output_frame_mat, cv::COLOR_RGB2BGR); if (save_video) { if (!writer.isOpened()) { - LOG(INFO) << "Prepare video writer."; + ABSL_LOG(INFO) << "Prepare video writer."; writer.open(absl::GetFlag(FLAGS_output_video_path), mediapipe::fourcc('a', 'v', 'c', '1'), // .mp4 capture.get(cv::CAP_PROP_FPS), output_frame_mat.size()); @@ -141,7 +142,7 @@ absl::Status RunMPPGraph() { } } - LOG(INFO) << "Shutting down."; + ABSL_LOG(INFO) << "Shutting down."; if (writer.isOpened()) writer.release(); MP_RETURN_IF_ERROR(graph.CloseInputStream(kInputStream)); return graph.WaitUntilDone(); @@ -152,10 +153,10 @@ int main(int argc, char** argv) { absl::ParseCommandLine(argc, argv); absl::Status run_status = RunMPPGraph(); if (!run_status.ok()) { - LOG(ERROR) << "Failed to run the graph: " << run_status.message(); + ABSL_LOG(ERROR) << "Failed to run the graph: " << run_status.message(); return EXIT_FAILURE; } else { - LOG(INFO) << "Success!"; + ABSL_LOG(INFO) << "Success!"; } return EXIT_SUCCESS; } diff --git a/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc b/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc index 8336e5670..5702bca72 100644 --- a/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc +++ b/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc @@ -18,6 +18,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/framework/formats/image_frame_opencv.h" @@ -50,23 +51,23 @@ absl::Status RunMPPGraph() { MP_RETURN_IF_ERROR(mediapipe::file::GetContents( absl::GetFlag(FLAGS_calculator_graph_config_file), &calculator_graph_config_contents)); - LOG(INFO) << "Get calculator graph config contents: " - << calculator_graph_config_contents; + ABSL_LOG(INFO) << "Get calculator graph config contents: " + << calculator_graph_config_contents; mediapipe::CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie( calculator_graph_config_contents); - LOG(INFO) << "Initialize the calculator graph."; + ABSL_LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize(config)); - LOG(INFO) << "Initialize the GPU."; + ABSL_LOG(INFO) << "Initialize the GPU."; 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()); - LOG(INFO) << "Initialize the camera or load the video."; + ABSL_LOG(INFO) << "Initialize the camera or load the video."; cv::VideoCapture capture; const bool load_video = !absl::GetFlag(FLAGS_input_video_path).empty(); if (load_video) { @@ -87,12 +88,12 @@ absl::Status RunMPPGraph() { #endif } - LOG(INFO) << "Start running the calculator graph."; + ABSL_LOG(INFO) << "Start running the calculator graph."; ASSIGN_OR_RETURN(mediapipe::OutputStreamPoller poller, graph.AddOutputStreamPoller(kOutputStream)); MP_RETURN_IF_ERROR(graph.StartRun({})); - LOG(INFO) << "Start grabbing and processing frames."; + ABSL_LOG(INFO) << "Start grabbing and processing frames."; bool grab_frames = true; while (grab_frames) { // Capture opencv camera or video frame. @@ -100,10 +101,10 @@ absl::Status RunMPPGraph() { capture >> camera_frame_raw; if (camera_frame_raw.empty()) { if (!load_video) { - LOG(INFO) << "Ignore empty frames from camera."; + ABSL_LOG(INFO) << "Ignore empty frames from camera."; continue; } - LOG(INFO) << "Empty frame, end of video reached."; + ABSL_LOG(INFO) << "Empty frame, end of video reached."; break; } cv::Mat camera_frame; @@ -169,7 +170,7 @@ absl::Status RunMPPGraph() { cv::cvtColor(output_frame_mat, output_frame_mat, cv::COLOR_RGB2BGR); if (save_video) { if (!writer.isOpened()) { - LOG(INFO) << "Prepare video writer."; + ABSL_LOG(INFO) << "Prepare video writer."; writer.open(absl::GetFlag(FLAGS_output_video_path), mediapipe::fourcc('a', 'v', 'c', '1'), // .mp4 capture.get(cv::CAP_PROP_FPS), output_frame_mat.size()); @@ -184,7 +185,7 @@ absl::Status RunMPPGraph() { } } - LOG(INFO) << "Shutting down."; + ABSL_LOG(INFO) << "Shutting down."; if (writer.isOpened()) writer.release(); MP_RETURN_IF_ERROR(graph.CloseInputStream(kInputStream)); return graph.WaitUntilDone(); @@ -195,10 +196,10 @@ int main(int argc, char** argv) { absl::ParseCommandLine(argc, argv); absl::Status run_status = RunMPPGraph(); if (!run_status.ok()) { - LOG(ERROR) << "Failed to run the graph: " << run_status.message(); + ABSL_LOG(ERROR) << "Failed to run the graph: " << run_status.message(); return EXIT_FAILURE; } else { - LOG(INFO) << "Success!"; + ABSL_LOG(INFO) << "Success!"; } return EXIT_SUCCESS; } diff --git a/mediapipe/examples/desktop/hello_world/BUILD b/mediapipe/examples/desktop/hello_world/BUILD index 27aa088e7..a1ceae3fc 100644 --- a/mediapipe/examples/desktop/hello_world/BUILD +++ b/mediapipe/examples/desktop/hello_world/BUILD @@ -22,8 +22,8 @@ cc_binary( deps = [ "//mediapipe/calculators/core:pass_through_calculator", "//mediapipe/framework:calculator_graph", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], ) diff --git a/mediapipe/examples/desktop/hello_world/hello_world.cc b/mediapipe/examples/desktop/hello_world/hello_world.cc index fde821b51..5bd1319ac 100644 --- a/mediapipe/examples/desktop/hello_world/hello_world.cc +++ b/mediapipe/examples/desktop/hello_world/hello_world.cc @@ -14,8 +14,8 @@ // // A simple example to print out "Hello World!" from a MediaPipe graph. +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_graph.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/parse_text_proto.h" #include "mediapipe/framework/port/status.h" @@ -54,7 +54,7 @@ absl::Status PrintHelloWorld() { mediapipe::Packet packet; // Get the output packets string. while (poller.Next(&packet)) { - LOG(INFO) << packet.Get(); + ABSL_LOG(INFO) << packet.Get(); } return graph.WaitUntilDone(); } diff --git a/mediapipe/examples/desktop/iris_tracking/BUILD b/mediapipe/examples/desktop/iris_tracking/BUILD index b9f3f6f4e..147a0ac25 100644 --- a/mediapipe/examples/desktop/iris_tracking/BUILD +++ b/mediapipe/examples/desktop/iris_tracking/BUILD @@ -33,6 +33,7 @@ cc_binary( "//mediapipe/graphs/iris_tracking:iris_depth_cpu_deps", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:absl_log", ], ) 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 928ebb207..37476b2b3 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 @@ -19,6 +19,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/framework/formats/image_frame_opencv.h" @@ -55,11 +56,11 @@ absl::StatusOr ReadFileToString(const std::string& file_path) { } absl::Status ProcessImage(std::unique_ptr graph) { - LOG(INFO) << "Load the image."; + ABSL_LOG(INFO) << "Load the image."; ASSIGN_OR_RETURN(const std::string raw_image, ReadFileToString(absl::GetFlag(FLAGS_input_image_path))); - LOG(INFO) << "Start running the calculator graph."; + 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, @@ -108,7 +109,7 @@ absl::Status ProcessImage(std::unique_ptr graph) { cv::cvtColor(output_frame_mat, output_frame_mat, cv::COLOR_RGB2BGR); const bool save_image = !absl::GetFlag(FLAGS_output_image_path).empty(); if (save_image) { - LOG(INFO) << "Saving image to file..."; + ABSL_LOG(INFO) << "Saving image to file..."; cv::imwrite(absl::GetFlag(FLAGS_output_image_path), output_frame_mat); } else { cv::namedWindow(kWindowName, /*flags=WINDOW_AUTOSIZE*/ 1); @@ -117,7 +118,7 @@ absl::Status ProcessImage(std::unique_ptr graph) { cv::waitKey(0); } - LOG(INFO) << "Shutting down."; + ABSL_LOG(INFO) << "Shutting down."; MP_RETURN_IF_ERROR(graph->CloseInputStream(kInputStream)); return graph->WaitUntilDone(); } @@ -126,13 +127,13 @@ absl::Status RunMPPGraph() { std::string calculator_graph_config_contents; MP_RETURN_IF_ERROR(mediapipe::file::GetContents( kCalculatorGraphConfigFile, &calculator_graph_config_contents)); - LOG(INFO) << "Get calculator graph config contents: " - << calculator_graph_config_contents; + ABSL_LOG(INFO) << "Get calculator graph config contents: " + << calculator_graph_config_contents; mediapipe::CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie( calculator_graph_config_contents); - LOG(INFO) << "Initialize the calculator graph."; + ABSL_LOG(INFO) << "Initialize the calculator graph."; std::unique_ptr graph = absl::make_unique(); MP_RETURN_IF_ERROR(graph->Initialize(config)); @@ -152,10 +153,10 @@ int main(int argc, char** argv) { absl::ParseCommandLine(argc, argv); absl::Status run_status = RunMPPGraph(); if (!run_status.ok()) { - LOG(ERROR) << "Failed to run the graph: " << run_status.message(); + ABSL_LOG(ERROR) << "Failed to run the graph: " << run_status.message(); return EXIT_FAILURE; } else { - LOG(INFO) << "Success!"; + ABSL_LOG(INFO) << "Success!"; } return EXIT_SUCCESS; } diff --git a/mediapipe/examples/desktop/media_sequence/BUILD b/mediapipe/examples/desktop/media_sequence/BUILD index 31cae8a33..53f932948 100644 --- a/mediapipe/examples/desktop/media_sequence/BUILD +++ b/mediapipe/examples/desktop/media_sequence/BUILD @@ -30,6 +30,7 @@ cc_library( "//mediapipe/framework/port:status", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) diff --git a/mediapipe/examples/desktop/media_sequence/run_graph_file_io_main.cc b/mediapipe/examples/desktop/media_sequence/run_graph_file_io_main.cc index 06212b013..a14c7734d 100644 --- a/mediapipe/examples/desktop/media_sequence/run_graph_file_io_main.cc +++ b/mediapipe/examples/desktop/media_sequence/run_graph_file_io_main.cc @@ -19,6 +19,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_split.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/file_helpers.h" @@ -43,8 +44,8 @@ absl::Status RunMPPGraph() { MP_RETURN_IF_ERROR(mediapipe::file::GetContents( absl::GetFlag(FLAGS_calculator_graph_config_file), &calculator_graph_config_contents)); - LOG(INFO) << "Get calculator graph config contents: " - << calculator_graph_config_contents; + ABSL_LOG(INFO) << "Get calculator graph config contents: " + << calculator_graph_config_contents; mediapipe::CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie( calculator_graph_config_contents); @@ -61,12 +62,12 @@ absl::Status RunMPPGraph() { input_side_packets[name_and_value[0]] = mediapipe::MakePacket(input_side_packet_contents); } - LOG(INFO) << "Initialize the calculator graph."; + ABSL_LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize(config, input_side_packets)); - LOG(INFO) << "Start running the calculator graph."; + ABSL_LOG(INFO) << "Start running the calculator graph."; MP_RETURN_IF_ERROR(graph.Run()); - LOG(INFO) << "Gathering output side packets."; + ABSL_LOG(INFO) << "Gathering output side packets."; kv_pairs = absl::StrSplit(absl::GetFlag(FLAGS_output_side_packets), ','); for (const std::string& kv_pair : kv_pairs) { std::vector name_and_value = absl::StrSplit(kv_pair, '='); @@ -88,10 +89,10 @@ int main(int argc, char** argv) { absl::ParseCommandLine(argc, argv); absl::Status run_status = RunMPPGraph(); if (!run_status.ok()) { - LOG(ERROR) << "Failed to run the graph: " << run_status.message(); + ABSL_LOG(ERROR) << "Failed to run the graph: " << run_status.message(); return EXIT_FAILURE; } else { - LOG(INFO) << "Success!"; + ABSL_LOG(INFO) << "Success!"; } return EXIT_SUCCESS; } diff --git a/mediapipe/examples/desktop/simple_run_graph_main.cc b/mediapipe/examples/desktop/simple_run_graph_main.cc index 96d9839a8..e794902d8 100644 --- a/mediapipe/examples/desktop/simple_run_graph_main.cc +++ b/mediapipe/examples/desktop/simple_run_graph_main.cc @@ -22,6 +22,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" @@ -102,8 +103,8 @@ absl::Status RunMPPGraph() { MP_RETURN_IF_ERROR(mediapipe::file::GetContents( absl::GetFlag(FLAGS_calculator_graph_config_file), &calculator_graph_config_contents)); - LOG(INFO) << "Get calculator graph config contents: " - << calculator_graph_config_contents; + ABSL_LOG(INFO) << "Get calculator graph config contents: " + << calculator_graph_config_contents; mediapipe::CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie( calculator_graph_config_contents); @@ -119,14 +120,14 @@ absl::Status RunMPPGraph() { mediapipe::MakePacket(name_and_value[1]); } } - LOG(INFO) << "Initialize the calculator graph."; + ABSL_LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; 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))); - LOG(INFO) << "Start running the calculator graph."; + ABSL_LOG(INFO) << "Start running the calculator graph."; MP_RETURN_IF_ERROR(graph.StartRun({})); MP_RETURN_IF_ERROR(OutputStreamToLocalFile(poller)); } else { @@ -134,7 +135,7 @@ absl::Status RunMPPGraph() { absl::GetFlag(FLAGS_output_stream_file).empty()) << "--output_stream and --output_stream_file should be specified in " "pair."; - LOG(INFO) << "Start running the calculator graph."; + ABSL_LOG(INFO) << "Start running the calculator graph."; MP_RETURN_IF_ERROR(graph.StartRun({})); } MP_RETURN_IF_ERROR(graph.WaitUntilDone()); @@ -146,10 +147,10 @@ int main(int argc, char** argv) { absl::ParseCommandLine(argc, argv); absl::Status run_status = RunMPPGraph(); if (!run_status.ok()) { - LOG(ERROR) << "Failed to run the graph: " << run_status.message(); + ABSL_LOG(ERROR) << "Failed to run the graph: " << run_status.message(); return EXIT_FAILURE; } else { - LOG(INFO) << "Success!"; + ABSL_LOG(INFO) << "Success!"; } return EXIT_SUCCESS; } diff --git a/mediapipe/examples/desktop/youtube8m/BUILD b/mediapipe/examples/desktop/youtube8m/BUILD index 4194e2332..783c7a9dd 100644 --- a/mediapipe/examples/desktop/youtube8m/BUILD +++ b/mediapipe/examples/desktop/youtube8m/BUILD @@ -22,6 +22,7 @@ cc_binary( deps = [ "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "//mediapipe/framework:calculator_framework", "//mediapipe/framework/formats:matrix", diff --git a/mediapipe/examples/desktop/youtube8m/extract_yt8m_features.cc b/mediapipe/examples/desktop/youtube8m/extract_yt8m_features.cc index 9030e9255..dbabf84b1 100644 --- a/mediapipe/examples/desktop/youtube8m/extract_yt8m_features.cc +++ b/mediapipe/examples/desktop/youtube8m/extract_yt8m_features.cc @@ -19,6 +19,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_split.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/matrix.h" @@ -44,8 +45,8 @@ absl::Status RunMPPGraph() { MP_RETURN_IF_ERROR(mediapipe::file::GetContents( absl::GetFlag(FLAGS_calculator_graph_config_file), &calculator_graph_config_contents)); - LOG(INFO) << "Get calculator graph config contents: " - << calculator_graph_config_contents; + ABSL_LOG(INFO) << "Get calculator graph config contents: " + << calculator_graph_config_contents; mediapipe::CalculatorGraphConfig config = mediapipe::ParseTextProtoOrDie( calculator_graph_config_contents); @@ -102,12 +103,12 @@ absl::Status RunMPPGraph() { input_side_packets["vggish_pca_projection_matrix"] = mediapipe::MakePacket(vggish_pca_projection_matrix); - LOG(INFO) << "Initialize the calculator graph."; + ABSL_LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize(config, input_side_packets)); - LOG(INFO) << "Start running the calculator graph."; + ABSL_LOG(INFO) << "Start running the calculator graph."; MP_RETURN_IF_ERROR(graph.Run()); - LOG(INFO) << "Gathering output side packets."; + ABSL_LOG(INFO) << "Gathering output side packets."; kv_pairs = absl::StrSplit(absl::GetFlag(FLAGS_output_side_packets), ','); for (const std::string& kv_pair : kv_pairs) { std::vector name_and_value = absl::StrSplit(kv_pair, '='); @@ -129,10 +130,10 @@ int main(int argc, char** argv) { absl::ParseCommandLine(argc, argv); absl::Status run_status = RunMPPGraph(); if (!run_status.ok()) { - LOG(ERROR) << "Failed to run the graph: " << run_status.message(); + ABSL_LOG(ERROR) << "Failed to run the graph: " << run_status.message(); return EXIT_FAILURE; } else { - LOG(INFO) << "Success!"; + ABSL_LOG(INFO) << "Success!"; } return EXIT_SUCCESS; } diff --git a/mediapipe/framework/BUILD b/mediapipe/framework/BUILD index 3587d5dad..bc8a166d4 100644 --- a/mediapipe/framework/BUILD +++ b/mediapipe/framework/BUILD @@ -360,7 +360,7 @@ cc_library( "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", @@ -432,6 +432,7 @@ cc_library( "//mediapipe/framework/tool:tag_map", "//mediapipe/framework/tool:validate_name", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", @@ -458,11 +459,11 @@ cc_library( visibility = ["//visibility:public"], deps = [ ":calculator_framework", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:sink", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", ], @@ -505,11 +506,11 @@ cc_library( deps = [ ":collection_item_id", ":type_map", - "//mediapipe/framework/port:logging", "//mediapipe/framework/tool:tag_map", "//mediapipe/framework/tool:tag_map_helper", "//mediapipe/framework/tool:validate_name", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", ], @@ -543,6 +544,7 @@ cc_library( "//mediapipe/framework/port:integral_types", "//mediapipe/framework/port:map_util", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", @@ -613,10 +615,10 @@ cc_library( ":packet_set", ":packet_type", ":timestamp", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", ], @@ -871,6 +873,7 @@ cc_library( "//mediapipe/framework/port:statusor", "//mediapipe/framework/tool:type_util", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", @@ -951,6 +954,7 @@ cc_library( "//mediapipe/framework/tool:type_util", "//mediapipe/framework/tool:validate_name", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", @@ -1136,6 +1140,7 @@ cc_library( "//mediapipe/framework/port:integral_types", "//mediapipe/framework/port:logging", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) @@ -1156,6 +1161,8 @@ cc_library( "//mediapipe/framework/tool:status_util", "//mediapipe/framework/tool:type_util", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/synchronization", ], alwayslink = 1, @@ -1209,6 +1216,7 @@ cc_library( "//mediapipe/framework/tool:validate", "//mediapipe/framework/tool:validate_name", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", "@com_google_protobuf//:protobuf", @@ -1293,10 +1301,10 @@ cc_test( ":calculator_node", "//mediapipe/calculators/core:pass_through_calculator", "//mediapipe/framework/port:gtest_main", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:source", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", ], ) @@ -1390,8 +1398,8 @@ cc_test( ":packet_type", ":timestamp", "//mediapipe/framework/port:gtest_main", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) @@ -1453,7 +1461,6 @@ cc_test( "//mediapipe/calculators/core:mux_calculator", "//mediapipe/calculators/core:pass_through_calculator", "//mediapipe/framework/port:gtest_main", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", @@ -1468,6 +1475,7 @@ cc_test( "//mediapipe/framework/tool:status_util", "//mediapipe/gpu:gpu_service", "@com_google_absl//absl/container:fixed_array", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", @@ -1524,11 +1532,11 @@ cc_test( "//mediapipe/calculators/core:mux_calculator", "//mediapipe/calculators/core:pass_through_calculator", "//mediapipe/framework/port:gtest_main", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:sink", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/time", ], ) diff --git a/mediapipe/framework/api2/BUILD b/mediapipe/framework/api2/BUILD index 99afd824e..d344ff28f 100644 --- a/mediapipe/framework/api2/BUILD +++ b/mediapipe/framework/api2/BUILD @@ -114,6 +114,7 @@ cc_test( "//mediapipe/framework/port:gtest_main", "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], ) diff --git a/mediapipe/framework/api2/node_test.cc b/mediapipe/framework/api2/node_test.cc index 152cbb0e2..ac1ca6015 100644 --- a/mediapipe/framework/api2/node_test.cc +++ b/mediapipe/framework/api2/node_test.cc @@ -3,6 +3,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/framework/api2/packet.h" #include "mediapipe/framework/api2/port.h" #include "mediapipe/framework/api2/test_contracts.h" @@ -570,7 +571,7 @@ struct LogSinkNode : public Node { MEDIAPIPE_NODE_CONTRACT(kIn); absl::Status Process(CalculatorContext* cc) override { - LOG(INFO) << "LogSinkNode received: " << kIn(cc).Get(); + ABSL_LOG(INFO) << "LogSinkNode received: " << kIn(cc).Get(); return {}; } }; diff --git a/mediapipe/framework/calculator_graph.cc b/mediapipe/framework/calculator_graph.cc index 0811fcb7c..3be4fd798 100644 --- a/mediapipe/framework/calculator_graph.cc +++ b/mediapipe/framework/calculator_graph.cc @@ -26,7 +26,7 @@ #include #include "absl/container/flat_hash_set.h" -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" @@ -147,7 +147,7 @@ CalculatorGraph::~CalculatorGraph() { // Stop periodic profiler output to unblock Executor destructors. absl::Status status = profiler()->Stop(); if (!status.ok()) { - LOG(ERROR) << "During graph destruction: " << status; + ABSL_LOG(ERROR) << "During graph destruction: " << status; } } @@ -600,7 +600,7 @@ absl::Status CalculatorGraph::MaybeSetUpGpuServiceFromLegacySidePacket( if (legacy_sp.IsEmpty()) return absl::OkStatus(); auto gpu_resources = service_manager_.GetServiceObject(kGpuService); if (gpu_resources) { - LOG(WARNING) + ABSL_LOG(WARNING) << "::mediapipe::GpuSharedData provided as a side packet while the " << "graph already had one; ignoring side packet"; return absl::OkStatus(); @@ -728,7 +728,7 @@ absl::Status CalculatorGraph::PrepareForRun( absl::Status error_status; if (has_error_) { GetCombinedErrors(&error_status); - LOG(ERROR) << error_status.ToString(kStatusLogFlags); + ABSL_LOG(ERROR) << error_status.ToString(kStatusLogFlags); return error_status; } @@ -807,7 +807,7 @@ absl::Status CalculatorGraph::PrepareForRun( } if (GetCombinedErrors(&error_status)) { - LOG(ERROR) << error_status.ToString(kStatusLogFlags); + ABSL_LOG(ERROR) << error_status.ToString(kStatusLogFlags); CleanupAfterRun(&error_status); return error_status; } @@ -861,7 +861,7 @@ absl::Status CalculatorGraph::PrepareForRun( absl::Status CalculatorGraph::WaitUntilIdle() { if (has_sources_) { - LOG_FIRST_N(WARNING, 1) + ABSL_LOG_FIRST_N(WARNING, 1) << "WaitUntilIdle called on a graph with source nodes, which " "is not fully supported at the moment. Source nodes: " << ListSourceNodes(); @@ -871,7 +871,7 @@ absl::Status CalculatorGraph::WaitUntilIdle() { VLOG(2) << "Scheduler idle."; absl::Status status = absl::OkStatus(); if (GetCombinedErrors(&status)) { - LOG(ERROR) << status.ToString(kStatusLogFlags); + ABSL_LOG(ERROR) << status.ToString(kStatusLogFlags); } return status; } @@ -1064,10 +1064,11 @@ void CalculatorGraph::RecordError(const absl::Status& error) { } if (errors_.size() > kMaxNumAccumulatedErrors) { for (const absl::Status& error : errors_) { - LOG(ERROR) << error; + ABSL_LOG(ERROR) << error; } - LOG(FATAL) << "Forcefully aborting to prevent the framework running out " - "of memory."; + ABSL_LOG(FATAL) + << "Forcefully aborting to prevent the framework running out " + "of memory."; } } } @@ -1264,7 +1265,7 @@ bool CalculatorGraph::UnthrottleSources() { } int new_size = stream->QueueSize() + 1; stream->SetMaxQueueSize(new_size); - LOG_EVERY_N(WARNING, 100) << absl::StrCat( + ABSL_LOG_EVERY_N(WARNING, 100) << absl::StrCat( "Resolved a deadlock by increasing max_queue_size of input stream: \"", stream->Name(), "\" of a node \"", GetParentNodeDebugName(stream), "\" to ", new_size, @@ -1436,12 +1437,13 @@ void PrintTimingToInfo(const std::string& label, int64_t timer_value) { const int64_t minutes = (total_seconds / 60ll) % 60ll; const int64_t seconds = total_seconds % 60ll; const int64_t milliseconds = (timer_value / 1000ll) % 1000ll; - LOG(INFO) << label << " took " - << absl::StrFormat( - "%02lld days, %02lld:%02lld:%02lld.%03lld (total seconds: " - "%lld.%06lld)", - days, hours, minutes, seconds, milliseconds, total_seconds, - timer_value % int64_t{1000000}); + ABSL_LOG(INFO) + << label << " took " + << absl::StrFormat( + "%02lld days, %02lld:%02lld:%02lld.%03lld (total seconds: " + "%lld.%06lld)", + days, hours, minutes, seconds, milliseconds, total_seconds, + timer_value % int64_t{1000000}); } bool MetricElementComparator(const std::pair& e1, diff --git a/mediapipe/framework/calculator_graph_side_packet_test.cc b/mediapipe/framework/calculator_graph_side_packet_test.cc index a9567c805..6f42f585e 100644 --- a/mediapipe/framework/calculator_graph_side_packet_test.cc +++ b/mediapipe/framework/calculator_graph_side_packet_test.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/time/clock.h" #include "absl/time/time.h" #include "mediapipe/framework/calculator.pb.h" @@ -24,7 +25,6 @@ #include "mediapipe/framework/port/canonical_errors.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/parse_text_proto.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" @@ -128,7 +128,7 @@ class IntegerOutputSidePacketCalculator : public CalculatorBase { } absl::Status Process(CalculatorContext* cc) final { - LOG(FATAL) << "Not reached."; + ABSL_LOG(FATAL) << "Not reached."; return absl::OkStatus(); } }; @@ -153,7 +153,7 @@ class SidePacketAdderCalculator : public CalculatorBase { } absl::Status Process(CalculatorContext* cc) final { - LOG(FATAL) << "Not reached."; + ABSL_LOG(FATAL) << "Not reached."; return absl::OkStatus(); } }; @@ -778,7 +778,7 @@ class OutputSidePacketCachedCalculator : public CalculatorBase { } absl::Status Process(CalculatorContext* cc) final { - LOG(FATAL) << "Not reached."; + ABSL_LOG(FATAL) << "Not reached."; return absl::OkStatus(); } }; diff --git a/mediapipe/framework/calculator_graph_test.cc b/mediapipe/framework/calculator_graph_test.cc index 45522cab4..ba949e093 100644 --- a/mediapipe/framework/calculator_graph_test.cc +++ b/mediapipe/framework/calculator_graph_test.cc @@ -29,6 +29,7 @@ #include #include "absl/container/fixed_array.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/status/status.h" #include "absl/strings/escaping.h" @@ -51,7 +52,6 @@ #include "mediapipe/framework/port/canonical_errors.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/parse_text_proto.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" @@ -1410,7 +1410,7 @@ void RunComprehensiveTest(CalculatorGraph* graph, // Call graph->Run() several times, to make sure that the appropriate // cleanup happens between iterations. for (int iteration = 0; iteration < 2; ++iteration) { - LOG(INFO) << "Loop iteration " << iteration; + ABSL_LOG(INFO) << "Loop iteration " << iteration; dumped_final_sum_packet = Packet(); dumped_final_stddev_packet = Packet(); dumped_final_packet = Packet(); @@ -1452,7 +1452,7 @@ void RunComprehensiveTest(CalculatorGraph* graph, ->GetCounter("copy_range5-PassThrough") ->Get()); } - LOG(INFO) << "After Loop Runs."; + ABSL_LOG(INFO) << "After Loop Runs."; // Verify that the graph can still run (but not successfully) when // one of the nodes is caused to fail. extra_side_packets.clear(); @@ -1463,9 +1463,9 @@ void RunComprehensiveTest(CalculatorGraph* graph, dumped_final_sum_packet = Packet(); dumped_final_stddev_packet = Packet(); dumped_final_packet = Packet(); - LOG(INFO) << "Expect an error to be logged here."; + ABSL_LOG(INFO) << "Expect an error to be logged here."; ASSERT_FALSE(graph->Run(extra_side_packets).ok()); - LOG(INFO) << "Error should have been logged."; + ABSL_LOG(INFO) << "Error should have been logged."; } TEST(CalculatorGraph, BadInitialization) { diff --git a/mediapipe/framework/calculator_node.cc b/mediapipe/framework/calculator_node.cc index f6a1c7dbf..e6a28a30a 100644 --- a/mediapipe/framework/calculator_node.cc +++ b/mediapipe/framework/calculator_node.cc @@ -19,6 +19,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" @@ -506,7 +507,7 @@ absl::Status CalculatorNode::OpenNode() { Timestamp(0)); } - LOG_IF(FATAL, result == tool::StatusStop()) << absl::Substitute( + ABSL_LOG_IF(FATAL, result == tool::StatusStop()) << absl::Substitute( "Open() on node \"$0\" returned tool::StatusStop() which should only be " "used to signal that a source node is done producing data.", DebugName()); @@ -519,7 +520,7 @@ absl::Status CalculatorNode::OpenNode() { offset_enabled = offset_enabled || stream->Spec()->offset_enabled; } if (offset_enabled && input_stream_handler_->SyncSetCount() > 1) { - LOG(WARNING) << absl::Substitute( + ABSL_LOG(WARNING) << absl::Substitute( "Calculator node \"$0\" is configured with multiple input sync-sets " "and an output timestamp-offset, which will often conflict due to " "the order of packet arrival. With multiple input sync-sets, use " @@ -601,7 +602,7 @@ absl::Status CalculatorNode::CloseNode(const absl::Status& graph_status, } needs_to_close_ = false; - LOG_IF(FATAL, result == tool::StatusStop()) << absl::Substitute( + ABSL_LOG_IF(FATAL, result == tool::StatusStop()) << absl::Substitute( "Close() on node \"$0\" returned tool::StatusStop() which should only be " "used to signal that a source node is done producing data.", DebugName()); diff --git a/mediapipe/framework/calculator_node_test.cc b/mediapipe/framework/calculator_node_test.cc index 1c62a7141..5c358dce7 100644 --- a/mediapipe/framework/calculator_node_test.cc +++ b/mediapipe/framework/calculator_node_test.cc @@ -18,11 +18,11 @@ #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/parse_text_proto.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status_macros.h" @@ -95,7 +95,8 @@ int CountCalculator::num_destroyed_ = 0; void SourceNodeOpenedNoOp() {} void CheckFail(const absl::Status& status) { - LOG(FATAL) << "The test triggered the error callback with status: " << status; + ABSL_LOG(FATAL) << "The test triggered the error callback with status: " + << status; } class CalculatorNodeTest : public ::testing::Test { diff --git a/mediapipe/framework/calculator_runner.cc b/mediapipe/framework/calculator_runner.cc index 1bd3211ed..e89f98048 100644 --- a/mediapipe/framework/calculator_runner.cc +++ b/mediapipe/framework/calculator_runner.cc @@ -16,10 +16,10 @@ #include "mediapipe/framework/calculator_runner.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "mediapipe/framework/calculator_framework.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" @@ -262,16 +262,18 @@ absl::Status CalculatorRunner::BuildGraph() { if (log_calculator_proto_) { #if defined(MEDIAPIPE_PROTO_LITE) - LOG(INFO) << "Please initialize CalculatorRunner using the recommended " - "constructor:\n CalculatorRunner runner(node_config);"; + ABSL_LOG(INFO) + << "Please initialize CalculatorRunner using the recommended " + "constructor:\n CalculatorRunner runner(node_config);"; #else std::string config_string; proto_ns::TextFormat::Printer printer; printer.SetInitialIndentLevel(4); printer.PrintToString(node_config_, &config_string); - LOG(INFO) << "Please initialize CalculatorRunner using the recommended " - "constructor:\n CalculatorRunner runner(R\"(\n" - << config_string << "\n )\");"; + ABSL_LOG(INFO) + << "Please initialize CalculatorRunner using the recommended " + "constructor:\n CalculatorRunner runner(R\"(\n" + << config_string << "\n )\");"; #endif } diff --git a/mediapipe/framework/calculator_runner_test.cc b/mediapipe/framework/calculator_runner_test.cc index a7890badd..7fd118cc6 100644 --- a/mediapipe/framework/calculator_runner_test.cc +++ b/mediapipe/framework/calculator_runner_test.cc @@ -16,6 +16,7 @@ #include "mediapipe/framework/calculator_runner.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "mediapipe/framework/calculator_base.h" #include "mediapipe/framework/calculator_registry.h" @@ -24,7 +25,6 @@ #include "mediapipe/framework/packet_type.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status_matchers.h" #include "mediapipe/framework/timestamp.h" @@ -136,7 +136,7 @@ TEST(CalculatorRunner, RunsCalculator) { // Run CalculatorRunner::Run() several times, with different inputs. This // tests that a CalculatorRunner instance can be reused. for (int iter = 0; iter < 3; ++iter) { - LOG(INFO) << "iter: " << iter; + ABSL_LOG(INFO) << "iter: " << iter; const int length = iter; // Generate the inputs at timestamps 0 ... length-1, at timestamp t having // values t and t*2 for the two streams, respectively. diff --git a/mediapipe/framework/collection.h b/mediapipe/framework/collection.h index c7b6fb0de..7c55de8d5 100644 --- a/mediapipe/framework/collection.h +++ b/mediapipe/framework/collection.h @@ -24,11 +24,11 @@ #include #include "absl/base/macros.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "mediapipe/framework/collection_item_id.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/tool/tag_map.h" #include "mediapipe/framework/tool/tag_map_helper.h" #include "mediapipe/framework/tool/validate_name.h" @@ -52,7 +52,7 @@ struct CollectionErrorHandlerFatal { // get away with only one version of this function (which is const // but returns a non-const reference). T& GetFallback(const absl::string_view tag, int index) const { - LOG(FATAL) << "Failed to get tag \"" << tag << "\" index " << index; + ABSL_LOG(FATAL) << "Failed to get tag \"" << tag << "\" index " << index; std::abort(); } }; @@ -365,7 +365,7 @@ class Collection { std::unique_ptr data_; // A class which allows errors to be reported flexibly. The default - // instantiation performs a LOG(FATAL) and does not have any member + // instantiation performs a ABSL_LOG(FATAL) and does not have any member // variables (zero size). ErrorHandler error_handler_; }; diff --git a/mediapipe/framework/counter_factory.cc b/mediapipe/framework/counter_factory.cc index 895b44ea6..b4da1043e 100644 --- a/mediapipe/framework/counter_factory.cc +++ b/mediapipe/framework/counter_factory.cc @@ -16,6 +16,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" @@ -59,9 +60,9 @@ void CounterSet::PublishCounters() ABSL_LOCKS_EXCLUDED(mu_) {} void CounterSet::PrintCounters() ABSL_LOCKS_EXCLUDED(mu_) { absl::ReaderMutexLock lock(&mu_); - LOG_IF(INFO, !counters_.empty()) << "MediaPipe Counters:"; + ABSL_LOG_IF(INFO, !counters_.empty()) << "MediaPipe Counters:"; for (const auto& counter : counters_) { - LOG(INFO) << counter.first << ": " << counter.second->Get(); + ABSL_LOG(INFO) << counter.first << ": " << counter.second->Get(); } } diff --git a/mediapipe/framework/deps/BUILD b/mediapipe/framework/deps/BUILD index 7fe37bae6..80cf77e59 100644 --- a/mediapipe/framework/deps/BUILD +++ b/mediapipe/framework/deps/BUILD @@ -77,8 +77,9 @@ cc_library( ], visibility = ["//visibility:public"], deps = [ - "//mediapipe/framework/port:logging", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", ], @@ -130,8 +131,9 @@ cc_library( deps = [ "//mediapipe/framework/port", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", ], ) @@ -228,12 +230,13 @@ cc_library( ], deps = [ ":registration_token", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:status", "//mediapipe/framework/port:statusor", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/meta:type_traits", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", @@ -276,8 +279,8 @@ cc_library( visibility = ["//mediapipe/framework/port:__pkg__"], deps = [ ":source_location", - "//mediapipe/framework/port:logging", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", @@ -344,6 +347,7 @@ cc_library( deps = [ ":thread_options", "//mediapipe/framework/port:logging", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", ], @@ -358,6 +362,7 @@ cc_library( visibility = ["//mediapipe/framework/port:__pkg__"], deps = [ "//mediapipe/framework/port:logging", + "@com_google_absl//absl/log:absl_log", ], ) @@ -415,10 +420,10 @@ cc_test( ":clock", "//mediapipe/framework/port:gtest_main", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:threadpool", "//mediapipe/framework/tool:simulation_clock", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", diff --git a/mediapipe/framework/deps/cleanup.h b/mediapipe/framework/deps/cleanup.h index 125cc7400..0541e314f 100644 --- a/mediapipe/framework/deps/cleanup.h +++ b/mediapipe/framework/deps/cleanup.h @@ -26,7 +26,7 @@ // DataObject d; // while (ReadDataObject(fp, &d)) { // if (d.IsBad()) { -// LOG(ERROR) << "Bad Data"; +// ABSL_LOG(ERROR) << "Bad Data"; // return; // } // PushGoodData(d); diff --git a/mediapipe/framework/deps/clock.cc b/mediapipe/framework/deps/clock.cc index f68143862..418d82814 100644 --- a/mediapipe/framework/deps/clock.cc +++ b/mediapipe/framework/deps/clock.cc @@ -14,8 +14,8 @@ #include "mediapipe/framework/deps/clock.h" +#include "absl/log/absl_log.h" #include "absl/time/clock.h" -#include "mediapipe/framework/port/logging.h" namespace mediapipe { @@ -28,7 +28,7 @@ namespace { class RealTimeClock : public Clock { public: virtual ~RealTimeClock() { - LOG(FATAL) << "RealTimeClock should never be destroyed"; + ABSL_LOG(FATAL) << "RealTimeClock should never be destroyed"; } absl::Time TimeNow() override { return absl::Now(); } diff --git a/mediapipe/framework/deps/monotonic_clock.cc b/mediapipe/framework/deps/monotonic_clock.cc index 503ef5cfd..bf0dea758 100644 --- a/mediapipe/framework/deps/monotonic_clock.cc +++ b/mediapipe/framework/deps/monotonic_clock.cc @@ -16,9 +16,10 @@ #include "absl/base/macros.h" #include "absl/base/thread_annotations.h" +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/synchronization/mutex.h" #include "absl/time/time.h" -#include "mediapipe/framework/port/logging.h" namespace mediapipe { @@ -205,7 +206,7 @@ MonotonicClock* MonotonicClock::CreateSynchronizedMonotonicClock() { // Test access methods. void MonotonicClockAccess::SynchronizedMonotonicClockReset() { - LOG(INFO) << "Resetting SynchronizedMonotonicClock"; + ABSL_LOG(INFO) << "Resetting SynchronizedMonotonicClock"; State* sync_state = GlobalSyncState(); absl::MutexLock m(&sync_state->lock); sync_state->max_time = absl::UnixEpoch(); diff --git a/mediapipe/framework/deps/monotonic_clock_test.cc b/mediapipe/framework/deps/monotonic_clock_test.cc index 0a049392f..9b57ffe51 100644 --- a/mediapipe/framework/deps/monotonic_clock_test.cc +++ b/mediapipe/framework/deps/monotonic_clock_test.cc @@ -21,13 +21,13 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" #include "absl/time/time.h" #include "mediapipe/framework/port/gtest.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/threadpool.h" #include "mediapipe/framework/tool/simulation_clock.h" @@ -254,8 +254,8 @@ TEST_F(MonotonicClockTest, RealTime) { // Just out of curiousity -- did real clock go backwards? int clock_num_corrections; mono_clock->GetCorrectionMetrics(&clock_num_corrections, NULL); - LOG(INFO) << clock_num_corrections << " corrections in " << num_calls - << " calls to mono_clock->Now()"; + ABSL_LOG(INFO) << clock_num_corrections << " corrections in " << num_calls + << " calls to mono_clock->Now()"; delete mono_clock; } @@ -523,13 +523,13 @@ TEST_F(MonotonicClockTest, RealFrenzy) { // Just out of curiousity -- did real clock go backwards? int clock_num_corrections; m1->GetCorrectionMetrics(&clock_num_corrections, NULL); - LOG_IF(INFO, clock_num_corrections > 0) + ABSL_LOG_IF(INFO, clock_num_corrections > 0) << clock_num_corrections << " corrections"; m2->GetCorrectionMetrics(&clock_num_corrections, NULL); - LOG_IF(INFO, clock_num_corrections > 0) + ABSL_LOG_IF(INFO, clock_num_corrections > 0) << clock_num_corrections << " corrections"; m3->GetCorrectionMetrics(&clock_num_corrections, NULL); - LOG_IF(INFO, clock_num_corrections > 0) + ABSL_LOG_IF(INFO, clock_num_corrections > 0) << clock_num_corrections << " corrections"; delete m1; delete m2; diff --git a/mediapipe/framework/deps/registration.h b/mediapipe/framework/deps/registration.h index 735716fd4..aa199f02a 100644 --- a/mediapipe/framework/deps/registration.h +++ b/mediapipe/framework/deps/registration.h @@ -28,6 +28,8 @@ #include "absl/base/thread_annotations.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/meta/type_traits.h" #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" @@ -35,7 +37,6 @@ #include "absl/synchronization/mutex.h" #include "mediapipe/framework/deps/registration_token.h" #include "mediapipe/framework/port/canonical_errors.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/statusor.h" namespace mediapipe { @@ -191,7 +192,7 @@ class FunctionRegistry { return RegistrationToken( [this, normalized_name]() { Unregister(normalized_name); }); } - LOG(FATAL) << "Function with name " << name << " already registered."; + ABSL_LOG(FATAL) << "Function with name " << name << " already registered."; return RegistrationToken([]() {}); } diff --git a/mediapipe/framework/deps/safe_int.h b/mediapipe/framework/deps/safe_int.h index f6dbb931d..eb3e9318d 100644 --- a/mediapipe/framework/deps/safe_int.h +++ b/mediapipe/framework/deps/safe_int.h @@ -34,7 +34,7 @@ // define any custom policy they desire. // // PolicyTypes: -// LogFatalOnError: LOG(FATAL) when a error occurs. +// LogFatalOnError: ABSL_LOG(FATAL) when a error occurs. #ifndef MEDIAPIPE_DEPS_SAFE_INT_H_ #define MEDIAPIPE_DEPS_SAFE_INT_H_ @@ -44,8 +44,9 @@ #include #include +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "mediapipe/framework/deps/strong_int.h" -#include "mediapipe/framework/port/logging.h" namespace mediapipe { namespace intops { @@ -284,15 +285,15 @@ class SafeIntStrongIntValidator { } }; -// A SafeIntStrongIntValidator policy class to LOG(FATAL) on errors. +// A SafeIntStrongIntValidator policy class to ABSL_LOG(FATAL) on errors. struct LogFatalOnError { template static void Error(const char* error, Tlhs lhs, Trhs rhs, const char* op) { - LOG(FATAL) << error << ": (" << lhs << " " << op << " " << rhs << ")"; + ABSL_LOG(FATAL) << error << ": (" << lhs << " " << op << " " << rhs << ")"; } template static void Error(const char* error, Tval val, const char* op) { - LOG(FATAL) << error << ": (" << op << val << ")"; + ABSL_LOG(FATAL) << error << ": (" << op << val << ")"; } }; diff --git a/mediapipe/framework/deps/status.h b/mediapipe/framework/deps/status.h index 492e4d434..8ee38f32d 100644 --- a/mediapipe/framework/deps/status.h +++ b/mediapipe/framework/deps/status.h @@ -21,9 +21,9 @@ #include #include "absl/base/attributes.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/string_view.h" -#include "mediapipe/framework/port/logging.h" namespace mediapipe { @@ -44,7 +44,7 @@ inline std::string* MediaPipeCheckOpHelper(absl::Status v, const char* msg) { #define MEDIAPIPE_DO_CHECK_OK(val, level) \ while (auto _result = mediapipe::MediaPipeCheckOpHelper(val, #val)) \ - LOG(level) << *(_result) + ABSL_LOG(level) << *(_result) #define MEDIAPIPE_CHECK_OK(val) MEDIAPIPE_DO_CHECK_OK(val, FATAL) #define MEDIAPIPE_QCHECK_OK(val) MEDIAPIPE_DO_CHECK_OK(val, QFATAL) @@ -53,7 +53,7 @@ inline std::string* MediaPipeCheckOpHelper(absl::Status v, const char* msg) { #define MEDIAPIPE_DCHECK_OK(val) MEDIAPIPE_CHECK_OK(val) #else #define MEDIAPIPE_DCHECK_OK(val) \ - while (false && (absl::OkStatus() == (val))) LOG(FATAL) + while (false && (absl::OkStatus() == (val))) ABSL_LOG(FATAL) #endif #define CHECK_OK MEDIAPIPE_CHECK_OK diff --git a/mediapipe/framework/deps/strong_int.h b/mediapipe/framework/deps/strong_int.h index 3ddb6d0be..b4bfef770 100644 --- a/mediapipe/framework/deps/strong_int.h +++ b/mediapipe/framework/deps/strong_int.h @@ -103,6 +103,7 @@ #include #include "absl/base/macros.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/integral_types.h" #include "mediapipe/framework/port/port.h" @@ -134,7 +135,7 @@ struct NullStrongIntValidator { // // template // static void ValidateInit(U arg) { - // if (arg < 0) LOG(FATAL) << "arg < 0"; + // if (arg < 0) ABSL_LOG(FATAL) << "arg < 0"; // } // // template diff --git a/mediapipe/framework/deps/threadpool_pthread_impl.cc b/mediapipe/framework/deps/threadpool_pthread_impl.cc index d9c32d35e..98d558158 100644 --- a/mediapipe/framework/deps/threadpool_pthread_impl.cc +++ b/mediapipe/framework/deps/threadpool_pthread_impl.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "mediapipe/framework/deps/threadpool.h" @@ -67,9 +68,9 @@ void* ThreadPool::WorkerThread::ThreadBody(void* arg) { if (nice(nice_priority_level) != -1 || errno == 0) { VLOG(1) << "Changed the nice priority level by " << nice_priority_level; } else { - LOG(ERROR) << "Error : " << strerror(errno) << std::endl - << "Could not change the nice priority level by " - << nice_priority_level; + ABSL_LOG(ERROR) << "Error : " << strerror(errno) << std::endl + << "Could not change the nice priority level by " + << nice_priority_level; } } if (!selected_cpus.empty()) { @@ -84,27 +85,27 @@ void* ThreadPool::WorkerThread::ThreadBody(void* arg) { VLOG(1) << "Pinned the thread pool executor to processor " << absl::StrJoin(selected_cpus, ", processor ") << "."; } else { - LOG(ERROR) << "Error : " << strerror(errno) << std::endl - << "Failed to set processor affinity. Ignore processor " - "affinity setting for now."; + ABSL_LOG(ERROR) << "Error : " << strerror(errno) << std::endl + << "Failed to set processor affinity. Ignore processor " + "affinity setting for now."; } } int error = pthread_setname_np(pthread_self(), name.c_str()); if (error != 0) { - LOG(ERROR) << "Error : " << strerror(error) << std::endl - << "Failed to set name for thread: " << name; + ABSL_LOG(ERROR) << "Error : " << strerror(error) << std::endl + << "Failed to set name for thread: " << name; } #else const std::string name = internal::CreateThreadName(thread->name_prefix_, 0); if (nice_priority_level != 0 || !selected_cpus.empty()) { - LOG(ERROR) << "Thread priority and processor affinity feature aren't " - "supported on the current platform."; + ABSL_LOG(ERROR) << "Thread priority and processor affinity feature aren't " + "supported on the current platform."; } #if __APPLE__ int error = pthread_setname_np(name.c_str()); if (error != 0) { - LOG(ERROR) << "Error : " << strerror(error) << std::endl - << "Failed to set name for thread: " << name; + ABSL_LOG(ERROR) << "Error : " << strerror(error) << std::endl + << "Failed to set name for thread: " << name; } #endif // __APPLE__ #endif // __linux__ diff --git a/mediapipe/framework/deps/threadpool_std_thread_impl.cc b/mediapipe/framework/deps/threadpool_std_thread_impl.cc index 4a902495d..4ef959dc4 100644 --- a/mediapipe/framework/deps/threadpool_std_thread_impl.cc +++ b/mediapipe/framework/deps/threadpool_std_thread_impl.cc @@ -26,9 +26,9 @@ #include #endif +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "mediapipe/framework/port/logging.h" namespace mediapipe { @@ -67,8 +67,9 @@ void* ThreadPool::WorkerThread::ThreadBody(void* arg) { thread->pool_->thread_options().nice_priority_level(); const std::set selected_cpus = thread->pool_->thread_options().cpu_set(); if (nice_priority_level != 0 || !selected_cpus.empty()) { - LOG(ERROR) << "Thread priority and processor affinity feature aren't " - "supported by the std::thread threadpool implementation."; + ABSL_LOG(ERROR) + << "Thread priority and processor affinity feature aren't " + "supported by the std::thread threadpool implementation."; } thread->pool_->RunWorker(); return nullptr; diff --git a/mediapipe/framework/deps/topologicalsorter.h b/mediapipe/framework/deps/topologicalsorter.h index d5027477c..2270f2945 100644 --- a/mediapipe/framework/deps/topologicalsorter.h +++ b/mediapipe/framework/deps/topologicalsorter.h @@ -40,7 +40,7 @@ namespace mediapipe { // if (cyclic) { // PrintCycleNodes(cycle_nodes); // } else { -// LOG(INFO) << idx; +// ABSL_LOG(INFO) << idx; // } // } class TopologicalSorter { diff --git a/mediapipe/framework/formats/BUILD b/mediapipe/framework/formats/BUILD index 242de6ff9..3f440e868 100644 --- a/mediapipe/framework/formats/BUILD +++ b/mediapipe/framework/formats/BUILD @@ -104,7 +104,7 @@ cc_library( srcs = ["deleting_file.cc"], hdrs = ["deleting_file.h"], deps = [ - "//mediapipe/framework/port:logging", + "@com_google_absl//absl/log:absl_log", ], ) @@ -155,11 +155,12 @@ cc_library( "//mediapipe/framework/port:aligned_malloc_and_free", "//mediapipe/framework/port:core_proto", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:source_location", "//mediapipe/framework/tool:type_util", "@com_google_absl//absl/base", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", ] + select({ @@ -206,7 +207,6 @@ cc_library( "//mediapipe/framework/formats/annotation:locus_cc_proto", "//mediapipe/framework/formats/annotation:rasterization_cc_proto", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:point", "//mediapipe/framework/port:rectangle", "//mediapipe/framework/port:ret_check", @@ -214,6 +214,7 @@ cc_library( "//mediapipe/framework/port:statusor", "//mediapipe/framework/tool:status_util", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", "@com_google_protobuf//:protobuf", @@ -234,6 +235,7 @@ cc_library( ":location", "//mediapipe/framework/formats/annotation:rasterization_cc_proto", "//mediapipe/framework/port:opencv_imgproc", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) @@ -485,8 +487,8 @@ cc_library( }), deps = [ "//mediapipe/framework:port", - "//mediapipe/framework/port:logging", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/synchronization", ] + select({ diff --git a/mediapipe/framework/formats/deleting_file.cc b/mediapipe/framework/formats/deleting_file.cc index 977a78940..b759a5f64 100644 --- a/mediapipe/framework/formats/deleting_file.cc +++ b/mediapipe/framework/formats/deleting_file.cc @@ -17,7 +17,7 @@ #include -#include "mediapipe/framework/port/logging.h" +#include "absl/log/absl_log.h" namespace mediapipe { @@ -27,7 +27,7 @@ DeletingFile::DeletingFile(const std::string& path, bool delete_on_destruction) DeletingFile::~DeletingFile() { if (delete_on_destruction_) { if (remove(path_.c_str()) != 0) { - LOG(ERROR) << "Unable to delete file: " << path_; + ABSL_LOG(ERROR) << "Unable to delete file: " << path_; } } } diff --git a/mediapipe/framework/formats/image_frame.cc b/mediapipe/framework/formats/image_frame.cc index 2de819a35..8d570e1ce 100644 --- a/mediapipe/framework/formats/image_frame.cc +++ b/mediapipe/framework/formats/image_frame.cc @@ -23,10 +23,11 @@ #include #include +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "mediapipe/framework/formats/image_format.pb.h" #include "mediapipe/framework/port/aligned_malloc_and_free.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/proto_ns.h" namespace mediapipe { @@ -287,7 +288,7 @@ int ImageFrame::NumberOfChannelsForFormat(ImageFormat::Format format) { case ImageFormat::SBGRA: return 4; default: - LOG(FATAL) << InvalidFormatString(format); + ABSL_LOG(FATAL) << InvalidFormatString(format); } } @@ -318,7 +319,7 @@ int ImageFrame::ChannelSizeForFormat(ImageFormat::Format format) { case ImageFormat::SBGRA: return sizeof(uint8_t); default: - LOG(FATAL) << InvalidFormatString(format); + ABSL_LOG(FATAL) << InvalidFormatString(format); } } @@ -349,7 +350,7 @@ int ImageFrame::ByteDepthForFormat(ImageFormat::Format format) { case ImageFormat::SBGRA: return 1; default: - LOG(FATAL) << InvalidFormatString(format); + ABSL_LOG(FATAL) << InvalidFormatString(format); } } diff --git a/mediapipe/framework/formats/location.cc b/mediapipe/framework/formats/location.cc index 205edf191..d810a9cb8 100644 --- a/mediapipe/framework/formats/location.cc +++ b/mediapipe/framework/formats/location.cc @@ -18,13 +18,13 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/substitute.h" #include "mediapipe/framework/formats/annotation/locus.pb.h" #include "mediapipe/framework/formats/annotation/rasterization.pb.h" #include "mediapipe/framework/port/canonical_errors.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/point2.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" @@ -187,7 +187,8 @@ Location& Location::Scale(const float scale) { break; } case LocationData::MASK: { - LOG(FATAL) << "Scaling for location data of type MASK is not supported."; + ABSL_LOG(FATAL) + << "Scaling for location data of type MASK is not supported."; break; } } @@ -232,7 +233,8 @@ Location& Location::Square(int image_width, int image_height) { break; } case LocationData::MASK: { - LOG(FATAL) << "Squaring for location data of type MASK is not supported."; + ABSL_LOG(FATAL) + << "Squaring for location data of type MASK is not supported."; break; } } @@ -327,7 +329,7 @@ Location& Location::Crop(const Rectangle_i& crop_box) { break; } case LocationData::RELATIVE_BOUNDING_BOX: - LOG(FATAL) + ABSL_LOG(FATAL) << "Can't crop a relative bounding box using absolute coordinates. " "Use the 'Rectangle_f version of Crop() instead"; case LocationData::MASK: { @@ -361,7 +363,7 @@ Location& Location::Crop(const Rectangle_f& crop_box) { // Do nothing. break; case LocationData::BOUNDING_BOX: - LOG(FATAL) + ABSL_LOG(FATAL) << "Can't crop an absolute bounding box using relative coordinates. " "Use the 'Rectangle_i version of Crop() instead"; case LocationData::RELATIVE_BOUNDING_BOX: { @@ -377,8 +379,9 @@ Location& Location::Crop(const Rectangle_f& crop_box) { break; } case LocationData::MASK: - LOG(FATAL) << "Can't crop a mask using relative coordinates. Use the " - "'Rectangle_i' version of Crop() instead"; + ABSL_LOG(FATAL) + << "Can't crop a mask using relative coordinates. Use the " + "'Rectangle_i' version of Crop() instead"; } return *this; } diff --git a/mediapipe/framework/formats/location_opencv.cc b/mediapipe/framework/formats/location_opencv.cc index 6e15b299a..8f73faf5a 100644 --- a/mediapipe/framework/formats/location_opencv.cc +++ b/mediapipe/framework/formats/location_opencv.cc @@ -14,11 +14,11 @@ #include "mediapipe/framework/formats/location_opencv.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/substitute.h" #include "mediapipe/framework/formats/annotation/rasterization.pb.h" #include "mediapipe/framework/formats/location.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" #include "mediapipe/framework/port/statusor.h" @@ -108,7 +108,7 @@ std::unique_ptr ConvertToCvMask(const Location& location, image_width, image_height, location.ConvertToBBox(image_width, image_height)); if (!status_or_mat.ok()) { - LOG(ERROR) << status_or_mat.status().message(); + ABSL_LOG(ERROR) << status_or_mat.status().message(); return nullptr; } return std::move(status_or_mat).value(); @@ -120,9 +120,9 @@ std::unique_ptr ConvertToCvMask(const Location& location, // This should never happen; a new LocationData::Format enum was introduced // without updating this function's switch(...) to support it. #if !defined(MEDIAPIPE_MOBILE) && !defined(MEDIAPIPE_LITE) - LOG(ERROR) << "Location's LocationData has format not supported by " - "Location::ConvertToMask: " - << location_data.DebugString(); + ABSL_LOG(ERROR) << "Location's LocationData has format not supported by " + "Location::ConvertToMask: " + << location_data.DebugString(); #endif return nullptr; } diff --git a/mediapipe/framework/formats/motion/BUILD b/mediapipe/framework/formats/motion/BUILD index 919b82406..66a8a5213 100644 --- a/mediapipe/framework/formats/motion/BUILD +++ b/mediapipe/framework/formats/motion/BUILD @@ -39,11 +39,11 @@ cc_library( "//mediapipe/framework/formats:location_opencv", "//mediapipe/framework/port:file_helpers", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:point", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@org_tensorflow//tensorflow/core:framework", ], @@ -61,8 +61,8 @@ cc_test( "//mediapipe/framework/port:file_helpers", "//mediapipe/framework/port:gtest_main", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/log:absl_log", "@org_tensorflow//tensorflow/core:framework", ], ) diff --git a/mediapipe/framework/formats/motion/optical_flow_field.cc b/mediapipe/framework/formats/motion/optical_flow_field.cc index a96504192..d044e3540 100644 --- a/mediapipe/framework/formats/motion/optical_flow_field.cc +++ b/mediapipe/framework/formats/motion/optical_flow_field.cc @@ -18,6 +18,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "mediapipe/framework/deps/mathutil.h" @@ -25,7 +26,6 @@ #include "mediapipe/framework/formats/location_opencv.h" #include "mediapipe/framework/port/file_helpers.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/point2.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/type_map.h" @@ -253,7 +253,7 @@ bool OpticalFlowField::AllWithinMargin(const OpticalFlowField& other, const cv::Point2f& other_motion = other.flow_data().at(r, c); if (!MathUtil::WithinMargin(this_motion.x, other_motion.x, margin) || !MathUtil::WithinMargin(this_motion.y, other_motion.y, margin)) { - LOG(INFO) << "First failure at" << r << " " << c; + ABSL_LOG(INFO) << "First failure at" << r << " " << c; return false; } } diff --git a/mediapipe/framework/formats/motion/optical_flow_field_test.cc b/mediapipe/framework/formats/motion/optical_flow_field_test.cc index fdce418fa..4d9ee4861 100644 --- a/mediapipe/framework/formats/motion/optical_flow_field_test.cc +++ b/mediapipe/framework/formats/motion/optical_flow_field_test.cc @@ -19,12 +19,12 @@ #include #include "absl/flags/flag.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/deps/file_path.h" #include "mediapipe/framework/formats/location_opencv.h" #include "mediapipe/framework/port/file_helpers.h" #include "mediapipe/framework/port/gtest.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "tensorflow/core/framework/tensor.h" namespace mediapipe { diff --git a/mediapipe/framework/formats/tensor.cc b/mediapipe/framework/formats/tensor.cc index 0445712c5..a38f7652b 100644 --- a/mediapipe/framework/formats/tensor.cc +++ b/mediapipe/framework/formats/tensor.cc @@ -17,9 +17,9 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/synchronization/mutex.h" #include "mediapipe/framework/port.h" -#include "mediapipe/framework/port/logging.h" #if MEDIAPIPE_OPENGL_ES_VERSION >= MEDIAPIPE_OPENGL_ES_30 #include "mediapipe/gpu/gl_base.h" #endif // MEDIAPIPE_OPENGL_ES_VERSION >= MEDIAPIPE_OPENGL_ES_30 @@ -81,7 +81,7 @@ void* AllocateVirtualMemory(size_t size) { vm_address_t data; auto error = vm_allocate(mach_task_self(), &data, AlignToPageSize(size), VM_FLAGS_ANYWHERE); - LOG_IF(FATAL, error != KERN_SUCCESS) + ABSL_LOG_IF(FATAL, error != KERN_SUCCESS) << "Can't allocate virtual memory for Tensor."; return reinterpret_cast(data); } @@ -113,10 +113,10 @@ void MtlBufferView::AllocateMtlBuffer(const Tensor& tensor, MtlBufferView MtlBufferView::GetReadView(const Tensor& tensor, id command_buffer) { - LOG_IF(FATAL, tensor.valid_ == Tensor::kValidNone) + ABSL_LOG_IF(FATAL, tensor.valid_ == Tensor::kValidNone) << "Tensor must be written prior to read from."; - LOG_IF(FATAL, - !(tensor.valid_ & (Tensor::kValidCpu | Tensor::kValidMetalBuffer))) + ABSL_LOG_IF( + FATAL, !(tensor.valid_ & (Tensor::kValidCpu | Tensor::kValidMetalBuffer))) << "Tensor conversion between different GPU backing formats is not " "supported yet."; auto lock(absl::make_unique(&tensor.view_mutex_)); @@ -152,7 +152,7 @@ bool Tensor::NeedsHalfFloatRenderTarget() const { if (!has_color_buffer_float) { static bool has_color_buffer_half_float = gl_context_->HasGlExtension("EXT_color_buffer_half_float"); - LOG_IF(FATAL, !has_color_buffer_half_float) + ABSL_LOG_IF(FATAL, !has_color_buffer_half_float) << "EXT_color_buffer_half_float or WEBGL_color_buffer_float " << "required on web to use MP tensor"; return true; @@ -161,9 +161,9 @@ bool Tensor::NeedsHalfFloatRenderTarget() const { } Tensor::OpenGlTexture2dView Tensor::GetOpenGlTexture2dReadView() const { - LOG_IF(FATAL, valid_ == kValidNone) + ABSL_LOG_IF(FATAL, valid_ == kValidNone) << "Tensor must be written prior to read from."; - LOG_IF(FATAL, !(valid_ & (kValidCpu | kValidOpenGlTexture2d))) + ABSL_LOG_IF(FATAL, !(valid_ & (kValidCpu | kValidOpenGlTexture2d))) << "Tensor conversion between different GPU backing formats is not " "supported yet."; auto lock = absl::make_unique(&view_mutex_); @@ -266,7 +266,7 @@ Tensor::OpenGlTexture2dView::GetLayoutDimensions(const Tensor::Shape& shape, float power = std::log2(std::sqrt(static_cast(num_pixels))); w = 1 << static_cast(power); int h = (num_pixels + w - 1) / w; - LOG_IF(FATAL, w > max_size || h > max_size) + ABSL_LOG_IF(FATAL, w > max_size || h > max_size) << "The tensor can't fit into OpenGL Texture2D View."; *width = w; *height = h; @@ -276,7 +276,7 @@ Tensor::OpenGlTexture2dView::GetLayoutDimensions(const Tensor::Shape& shape, void Tensor::AllocateOpenGlTexture2d() const { if (opengl_texture2d_ == GL_INVALID_INDEX) { gl_context_ = mediapipe::GlContext::GetCurrent(); - LOG_IF(FATAL, !gl_context_) << "GlContext is not bound to the thread."; + ABSL_LOG_IF(FATAL, !gl_context_) << "GlContext is not bound to the thread."; glGenTextures(1, &opengl_texture2d_); glBindTexture(GL_TEXTURE_2D, opengl_texture2d_); // Texture2D represents a buffer with computable data so should be fetched @@ -302,7 +302,7 @@ void Tensor::AllocateOpenGlTexture2d() const { // once for OES_texture_float extension, to save time. static bool has_oes_extension = gl_context_->HasGlExtension("OES_texture_float"); - LOG_IF(FATAL, !has_oes_extension) + ABSL_LOG_IF(FATAL, !has_oes_extension) << "OES_texture_float extension required in order to use MP tensor " << "with GLES 2.0"; // Allocate the image data; note that it's no longer RGBA32F, so will be @@ -328,13 +328,13 @@ void Tensor::AllocateOpenGlTexture2d() const { #if MEDIAPIPE_OPENGL_ES_VERSION >= MEDIAPIPE_OPENGL_ES_31 Tensor::OpenGlBufferView Tensor::GetOpenGlBufferReadView() const { - LOG_IF(FATAL, valid_ == kValidNone) + ABSL_LOG_IF(FATAL, valid_ == kValidNone) << "Tensor must be written prior to read from."; - LOG_IF(FATAL, !(valid_ & (kValidCpu | + ABSL_LOG_IF(FATAL, !(valid_ & (kValidCpu | #ifdef MEDIAPIPE_TENSOR_USE_AHWB - kValidAHardwareBuffer | + kValidAHardwareBuffer | #endif // MEDIAPIPE_TENSOR_USE_AHWB - kValidOpenGlBuffer))) + kValidOpenGlBuffer))) << "Tensor conversion between different GPU backing formats is not " "supported yet."; auto lock(absl::make_unique(&view_mutex_)); @@ -374,7 +374,7 @@ Tensor::OpenGlBufferView Tensor::GetOpenGlBufferWriteView( void Tensor::AllocateOpenGlBuffer() const { if (opengl_buffer_ == GL_INVALID_INDEX) { gl_context_ = mediapipe::GlContext::GetCurrent(); - LOG_IF(FATAL, !gl_context_) << "GlContext is not bound to the thread."; + ABSL_LOG_IF(FATAL, !gl_context_) << "GlContext is not bound to the thread."; glGenBuffers(1, &opengl_buffer_); glBindBuffer(GL_SHADER_STORAGE_BUFFER, opengl_buffer_); if (!use_ahwb_ || !AllocateAhwbMapToSsbo()) { @@ -528,7 +528,7 @@ void Tensor::Invalidate() { Tensor::CpuReadView Tensor::GetCpuReadView() const { auto lock = absl::make_unique(&view_mutex_); - LOG_IF(FATAL, valid_ == kValidNone) + ABSL_LOG_IF(FATAL, valid_ == kValidNone) << "Tensor must be written prior to read from."; #ifdef MEDIAPIPE_TENSOR_USE_AHWB if (__builtin_available(android 26, *)) { @@ -548,7 +548,7 @@ Tensor::CpuReadView Tensor::GetCpuReadView() const { // GPU-to-CPU synchronization and read-back. #if MEDIAPIPE_METAL_ENABLED if (valid_ & kValidMetalBuffer) { - LOG_IF(FATAL, !mtl_resources_->command_buffer) + ABSL_LOG_IF(FATAL, !mtl_resources_->command_buffer) << "Metal -> CPU synchronization " "requires MTLCommandBuffer to be set."; if (mtl_resources_->command_buffer) { diff --git a/mediapipe/framework/formats/tensor_ahwb.cc b/mediapipe/framework/formats/tensor_ahwb.cc index 525f05f31..a72b481e0 100644 --- a/mediapipe/framework/formats/tensor_ahwb.cc +++ b/mediapipe/framework/formats/tensor_ahwb.cc @@ -7,9 +7,9 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/synchronization/mutex.h" #include "mediapipe/framework/port.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/gpu/gl_base.h" #endif // MEDIAPIPE_TENSOR_USE_AHWB @@ -342,7 +342,8 @@ void Tensor::MoveCpuOrSsboToAhwb() const { // of the Ahwb at the next request to the OpenGlBufferView. valid_ &= ~kValidOpenGlBuffer; } else { - LOG(FATAL) << "Can't convert tensor with mask " << valid_ << " into AHWB."; + ABSL_LOG(FATAL) << "Can't convert tensor with mask " << valid_ + << " into AHWB."; } if (__builtin_available(android 26, *)) { auto error = AHardwareBuffer_unlock(ahwb_, nullptr); diff --git a/mediapipe/framework/graph_output_stream.h b/mediapipe/framework/graph_output_stream.h index b541aec12..7308be111 100644 --- a/mediapipe/framework/graph_output_stream.h +++ b/mediapipe/framework/graph_output_stream.h @@ -22,6 +22,7 @@ #include "absl/base/attributes.h" #include "absl/base/thread_annotations.h" +#include "absl/log/absl_log.h" #include "absl/strings/substitute.h" #include "absl/synchronization/mutex.h" #include "mediapipe/framework/input_stream_handler.h" @@ -30,7 +31,6 @@ #include "mediapipe/framework/packet.h" #include "mediapipe/framework/packet_set.h" #include "mediapipe/framework/packet_type.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/timestamp.h" @@ -76,7 +76,7 @@ class GraphOutputStream { // TODO: Simplify this. We are forced to use an ISH just to // receive a packet, even though we do not need to do any of the things an ISH // normally does. The fact that we have to disable required overrides with - // LOG(FATAL) shows that this is the wrong interface. + // ABSL_LOG(FATAL) shows that this is the wrong interface. class GraphOutputStreamHandler : public InputStreamHandler { public: GraphOutputStreamHandler(std::shared_ptr tag_map, @@ -88,15 +88,15 @@ class GraphOutputStream { protected: NodeReadiness GetNodeReadiness(Timestamp* min_stream_timestamp) override { - LOG(FATAL) << "GraphOutputStreamHandler::GetNodeReadiness should " - "never be invoked."; + ABSL_LOG(FATAL) << "GraphOutputStreamHandler::GetNodeReadiness should " + "never be invoked."; return NodeReadiness::kNotReady; } void FillInputSet(Timestamp input_timestamp, InputStreamShardSet* input_set) override { - LOG(FATAL) << "GraphOutputStreamHandler::FillInputSet should " - "never be invoked."; + ABSL_LOG(FATAL) << "GraphOutputStreamHandler::FillInputSet should " + "never be invoked."; } }; diff --git a/mediapipe/framework/packet.h b/mediapipe/framework/packet.h index 4a3399f1c..f42164000 100644 --- a/mediapipe/framework/packet.h +++ b/mediapipe/framework/packet.h @@ -24,6 +24,7 @@ #include #include "absl/base/macros.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "absl/synchronization/mutex.h" @@ -734,7 +735,7 @@ inline const T& Packet::Get() const { if (holder == nullptr) { // Produce a good error message. absl::Status status = ValidateAsType(); - LOG(FATAL) << "Packet::Get() failed: " << status.message(); + ABSL_LOG(FATAL) << "Packet::Get() failed: " << status.message(); } return holder->data(); } diff --git a/mediapipe/framework/packet_type.h b/mediapipe/framework/packet_type.h index 9b4bbd36c..ee1074c34 100644 --- a/mediapipe/framework/packet_type.h +++ b/mediapipe/framework/packet_type.h @@ -23,6 +23,7 @@ #include #include "absl/base/macros.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" @@ -169,8 +170,8 @@ class PacketTypeSetErrorHandler { // In the const setting produce a FATAL error. const PacketType& GetFallback(const absl::string_view tag, int index) const { - LOG(FATAL) << "Failed to get tag \"" << tag << "\" index " << index - << ". Unable to defer error due to const specifier."; + ABSL_LOG(FATAL) << "Failed to get tag \"" << tag << "\" index " << index + << ". Unable to defer error due to const specifier."; std::abort(); } diff --git a/mediapipe/framework/profiler/BUILD b/mediapipe/framework/profiler/BUILD index 53aeb1eaf..434072f5b 100644 --- a/mediapipe/framework/profiler/BUILD +++ b/mediapipe/framework/profiler/BUILD @@ -116,13 +116,13 @@ cc_library( "//mediapipe/framework/port:advanced_proto_lite", "//mediapipe/framework/port:file_helpers", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:re2", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:name_util", "//mediapipe/framework/tool:tag_map", "//mediapipe/framework/tool:validate_name", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", @@ -218,11 +218,11 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework:calculator_options_cc_proto", "//mediapipe/framework:mediapipe_options_cc_proto", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:status", "//mediapipe/framework/port:statusor", "//mediapipe/framework/tool:tag_map", "//mediapipe/framework/tool:tag_map_helper", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", ], ) @@ -268,9 +268,9 @@ cc_test( ":sharded_map", "//mediapipe/framework/port:gtest_main", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:threadpool", "@com_google_absl//absl/container:node_hash_map", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", ], @@ -374,6 +374,7 @@ cc_test( "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/profiler/reporter:reporter_lib", "//mediapipe/framework/tool:test_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", ], diff --git a/mediapipe/framework/profiler/gl_context_profiler.cc b/mediapipe/framework/profiler/gl_context_profiler.cc index 59c9f01ff..ffd939f41 100644 --- a/mediapipe/framework/profiler/gl_context_profiler.cc +++ b/mediapipe/framework/profiler/gl_context_profiler.cc @@ -14,6 +14,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/time/clock.h" #include "absl/time/time.h" diff --git a/mediapipe/framework/profiler/graph_profiler.cc b/mediapipe/framework/profiler/graph_profiler.cc index 6aead5250..068da3a09 100644 --- a/mediapipe/framework/profiler/graph_profiler.cc +++ b/mediapipe/framework/profiler/graph_profiler.cc @@ -17,13 +17,13 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/substitute.h" #include "absl/synchronization/mutex.h" #include "absl/time/time.h" #include "mediapipe/framework/port/advanced_proto_lite_inc.h" #include "mediapipe/framework/port/canonical_errors.h" #include "mediapipe/framework/port/file_helpers.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/proto_ns.h" #include "mediapipe/framework/port/re2.h" #include "mediapipe/framework/port/ret_check.h" @@ -251,10 +251,10 @@ absl::Status GraphProfiler::Start(mediapipe::Executor* executor) { file::SetContents(absl::StrCat(trace_log_path, "trace_writing_check"), "can write trace logs to this location"); if (status.ok()) { - LOG(INFO) << "trace_log_path: " << trace_log_path; + ABSL_LOG(INFO) << "trace_log_path: " << trace_log_path; } else { - LOG(ERROR) << "cannot write to trace_log_path: " << trace_log_path << ": " - << status; + ABSL_LOG(ERROR) << "cannot write to trace_log_path: " << trace_log_path + << ": " << status; } is_running_ = true; @@ -315,7 +315,7 @@ void GraphProfiler::AddPacketInfo(const TraceEvent& packet_info) { return; } if (!packet_timestamp.IsRangeValue()) { - LOG(WARNING) << absl::Substitute( + ABSL_LOG(WARNING) << absl::Substitute( "Skipped adding packet info because the timestamp $0 for stream " "\"$1\" is not valid.", packet_timestamp.Value(), stream_name); @@ -482,7 +482,7 @@ void GraphProfiler::SetCloseRuntime(const CalculatorContext& calculator_context, void GraphProfiler::AddTimeSample(int64 start_time_usec, int64 end_time_usec, TimeHistogram* histogram) { if (end_time_usec < start_time_usec) { - LOG(ERROR) << absl::Substitute( + ABSL_LOG(ERROR) << absl::Substitute( "end_time_usec ($0) is < start_time_usec ($1)", end_time_usec, start_time_usec); return; @@ -519,8 +519,8 @@ int64 GraphProfiler::AddInputStreamTimeSamples( // This is a condition rather than a failure CHECK because // under certain conditions the consumer calculator's Process() // can start before the producer calculator's Process() is finished. - LOG_FIRST_N(WARNING, 10) << "Expected packet info is missing for: " - << PacketIdToString(packet_id); + ABSL_LOG_FIRST_N(WARNING, 10) << "Expected packet info is missing for: " + << PacketIdToString(packet_id); continue; } AddTimeSample( diff --git a/mediapipe/framework/profiler/graph_profiler_test.cc b/mediapipe/framework/profiler/graph_profiler_test.cc index e9badaa25..8a9bc141e 100644 --- a/mediapipe/framework/profiler/graph_profiler_test.cc +++ b/mediapipe/framework/profiler/graph_profiler_test.cc @@ -14,6 +14,7 @@ #include "mediapipe/framework/profiler/graph_profiler.h" +#include "absl/log/absl_log.h" #include "absl/status/statusor.h" #include "absl/synchronization/mutex.h" #include "absl/time/time.h" @@ -59,7 +60,8 @@ CalculatorProfile GetProfileWithName( return p; } } - LOG(FATAL) << "Cannot find calulator profile with name " << calculator_name; + ABSL_LOG(FATAL) << "Cannot find calulator profile with name " + << calculator_name; return CalculatorProfile::default_instance(); } @@ -1227,7 +1229,7 @@ TEST(GraphProfilerTest, ParallelReads) { EXPECT_EQ(1003, profiles[0].process_runtime().count(0)); EXPECT_EQ(1000, profiles[1].process_runtime().count(0)); } else { - LOG(FATAL) << "Unexpected profile name " << profiles[0].name(); + ABSL_LOG(FATAL) << "Unexpected profile name " << profiles[0].name(); } EXPECT_EQ(1001, out_1_packets.size()); } diff --git a/mediapipe/framework/profiler/reporter_test.cc b/mediapipe/framework/profiler/reporter_test.cc index e5bc541a7..6ca6c6424 100644 --- a/mediapipe/framework/profiler/reporter_test.cc +++ b/mediapipe/framework/profiler/reporter_test.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "mediapipe/framework/calculator.pb.h" @@ -43,15 +44,15 @@ using ::testing::IsSupersetOf; void LoadGraphProfile(const std::string& path, GraphProfile* proto) { int fd = open(path.c_str(), O_RDONLY); if (fd == -1) { - LOG(ERROR) << "could not open test graph: " << path - << ", error: " << strerror(errno); + ABSL_LOG(ERROR) << "could not open test graph: " << path + << ", error: " << strerror(errno); return; } proto_ns::io::FileInputStream input(fd); bool success = proto->ParseFromZeroCopyStream(&input); close(fd); if (!success) { - LOG(ERROR) << "could not parse test graph: " << path; + ABSL_LOG(ERROR) << "could not parse test graph: " << path; } } diff --git a/mediapipe/framework/profiler/sharded_map_test.cc b/mediapipe/framework/profiler/sharded_map_test.cc index e551b25c8..5a47b390b 100644 --- a/mediapipe/framework/profiler/sharded_map_test.cc +++ b/mediapipe/framework/profiler/sharded_map_test.cc @@ -17,13 +17,13 @@ #include #include "absl/container/node_hash_map.h" +#include "absl/log/absl_log.h" #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" #include "absl/time/time.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/threadpool.h" namespace { @@ -134,9 +134,9 @@ TEST(ShardedMapTest, TestParallelAccess) { ShardedMap sharded_map(4999); TestParallelAccess(sharded_map, 13); }); - LOG(INFO) << "Ellapsed time: simple_map: " << simple_time; - LOG(INFO) << "Ellapsed time: safe_map: " << safe_time; - LOG(INFO) << "Ellapsed time: sharded_map: " << sharded_time; + ABSL_LOG(INFO) << "Ellapsed time: simple_map: " << simple_time; + ABSL_LOG(INFO) << "Ellapsed time: safe_map: " << safe_time; + ABSL_LOG(INFO) << "Ellapsed time: sharded_map: " << sharded_time; } } // namespace diff --git a/mediapipe/framework/profiler/test_context_builder.h b/mediapipe/framework/profiler/test_context_builder.h index abf9ee749..4018a0349 100644 --- a/mediapipe/framework/profiler/test_context_builder.h +++ b/mediapipe/framework/profiler/test_context_builder.h @@ -21,11 +21,11 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/calculator_options.pb.h" #include "mediapipe/framework/mediapipe_options.pb.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/statusor.h" #include "mediapipe/framework/tool/tag_map.h" @@ -92,7 +92,7 @@ class TestContextBuilder { spec.name = output_map_->Names()[id.value()]; spec.packet_type = packet_type; spec.error_callback = [](const absl::Status& status) { - LOG(ERROR) << status; + ABSL_LOG(ERROR) << status; }; output_specs_[spec.name] = spec; } diff --git a/mediapipe/framework/profiler/testing/BUILD b/mediapipe/framework/profiler/testing/BUILD index 67668ef7d..55b3613f9 100644 --- a/mediapipe/framework/profiler/testing/BUILD +++ b/mediapipe/framework/profiler/testing/BUILD @@ -23,6 +23,7 @@ cc_library( deps = [ "//mediapipe/framework:calculator_framework", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) diff --git a/mediapipe/framework/profiler/testing/simple_calculator.cc b/mediapipe/framework/profiler/testing/simple_calculator.cc index 18ba67b9b..fa1123ee0 100644 --- a/mediapipe/framework/profiler/testing/simple_calculator.cc +++ b/mediapipe/framework/profiler/testing/simple_calculator.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/status.h" @@ -28,7 +29,7 @@ class SimpleCalculator : public CalculatorBase { } absl::Status Process(CalculatorContext* cc) final { - LOG(WARNING) << "Simple Calculator Process called, count_: " << count_; + ABSL_LOG(WARNING) << "Simple Calculator Process called, count_: " << count_; int max_count = 1; if (cc->InputSidePackets().HasTag("MAX_COUNT")) { max_count = cc->InputSidePackets().Tag("MAX_COUNT").Get(); diff --git a/mediapipe/framework/stream_handler/BUILD b/mediapipe/framework/stream_handler/BUILD index 6767a9579..1d0b237da 100644 --- a/mediapipe/framework/stream_handler/BUILD +++ b/mediapipe/framework/stream_handler/BUILD @@ -111,7 +111,7 @@ cc_library( "//mediapipe/framework:packet", "//mediapipe/framework/tool:tag_map", "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/synchronization", ], @@ -188,6 +188,7 @@ cc_library( "//mediapipe/framework/port:status", "//mediapipe/framework/tool:tag_map", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/status", "@com_google_absl//absl/synchronization", diff --git a/mediapipe/framework/stream_handler/fixed_size_input_stream_handler.cc b/mediapipe/framework/stream_handler/fixed_size_input_stream_handler.cc index a2e7be2ff..16119430b 100644 --- a/mediapipe/framework/stream_handler/fixed_size_input_stream_handler.cc +++ b/mediapipe/framework/stream_handler/fixed_size_input_stream_handler.cc @@ -19,8 +19,8 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/log/check.h" -#include "absl/log/log.h" #include "absl/synchronization/mutex.h" #include "mediapipe/framework/calculator_context_manager.h" #include "mediapipe/framework/calculator_framework.h" @@ -182,7 +182,7 @@ void FixedSizeInputStreamHandler::FillInputSet(Timestamp input_timestamp, CHECK(input_set); absl::MutexLock lock(&erase_mutex_); if (!pending_) { - LOG(ERROR) << "FillInputSet called without GetNodeReadiness."; + ABSL_LOG(ERROR) << "FillInputSet called without GetNodeReadiness."; } // input_timestamp is recalculated here to process the most recent packets. EraseSurplusPackets(true); diff --git a/mediapipe/framework/stream_handler/sync_set_input_stream_handler_test.cc b/mediapipe/framework/stream_handler/sync_set_input_stream_handler_test.cc index e93f806be..c8cc6a171 100644 --- a/mediapipe/framework/stream_handler/sync_set_input_stream_handler_test.cc +++ b/mediapipe/framework/stream_handler/sync_set_input_stream_handler_test.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/synchronization/mutex.h" #include "mediapipe/framework/calculator_framework.h" // TODO: Move protos in another CL after the C++ code migration. @@ -215,7 +216,7 @@ TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) { RandomEngine rng(testing::UnitTest::GetInstance()->random_seed()); for (int iter = 0; iter < 1000; ++iter) { - LOG(INFO) << "Starting command shuffling iteration " << iter; + ABSL_LOG(INFO) << "Starting command shuffling iteration " << iter; // Merge the commands for each sync set together into a serial list. // This is done by randomly choosing which list to grab from next. diff --git a/mediapipe/framework/timestamp.cc b/mediapipe/framework/timestamp.cc index 4ece74c99..0b4ff77ed 100644 --- a/mediapipe/framework/timestamp.cc +++ b/mediapipe/framework/timestamp.cc @@ -16,6 +16,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" namespace mediapipe { @@ -112,7 +113,7 @@ std::string Timestamp::DebugString() const { } else if (*this == Timestamp::Done()) { return "Timestamp::Done()"; } else { - LOG(FATAL) << "Unknown special type."; + ABSL_LOG(FATAL) << "Unknown special type."; } } return absl::StrCat(timestamp_.value()); diff --git a/mediapipe/framework/tool/BUILD b/mediapipe/framework/tool/BUILD index 8e1ef94a4..c086eee54 100644 --- a/mediapipe/framework/tool/BUILD +++ b/mediapipe/framework/tool/BUILD @@ -66,10 +66,12 @@ cc_library( deps = [ "//mediapipe/framework:calculator_cc_proto", "//mediapipe/framework/port:advanced_proto", + "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:absl_log", ], ) @@ -403,6 +405,7 @@ cc_library( "//mediapipe/framework/port:source_location", "//mediapipe/framework/port:status", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", @@ -509,6 +512,8 @@ cc_library( "//mediapipe/framework/port:numbers", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", ], ) @@ -529,12 +534,12 @@ cc_library( "//mediapipe/framework/deps:proto_descriptor_cc_proto", "//mediapipe/framework/port:advanced_proto", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:map_util", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", ], @@ -630,6 +635,7 @@ cc_test( ":tag_map_helper", "//mediapipe/framework/port:gtest_main", "//mediapipe/framework/port:map_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) @@ -787,11 +793,12 @@ cc_library( "//mediapipe/framework/formats:image_frame", "//mediapipe/framework/port:advanced_proto", "//mediapipe/framework/port:file_helpers", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "@com_google_absl//absl/cleanup", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", @@ -945,11 +952,11 @@ cc_test( "//mediapipe/framework:subgraph", "//mediapipe/framework:test_calculators", "//mediapipe/framework/port:gtest_main", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/framework/stream_handler:immediate_input_stream_handler", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) diff --git a/mediapipe/framework/tool/sink.cc b/mediapipe/framework/tool/sink.cc index 4111d884c..254c6063e 100644 --- a/mediapipe/framework/tool/sink.cc +++ b/mediapipe/framework/tool/sink.cc @@ -27,6 +27,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" @@ -166,7 +167,7 @@ void AddCallbackCalculator(const std::string& stream_name, sink_node->add_input_side_packet( absl::StrCat("CALLBACK:", input_side_packet_name)); } else { - LOG(FATAL) << "AddCallbackCalculator must use std::function"; + ABSL_LOG(FATAL) << "AddCallbackCalculator must use std::function"; } } @@ -241,7 +242,7 @@ void AddCallbackWithHeaderCalculator(const std::string& stream_name, sink_node->add_input_side_packet( absl::StrCat("CALLBACK:", input_side_packet_name)); } else { - LOG(FATAL) << "AddCallbackWithHeaderCalculator must use std::function"; + ABSL_LOG(FATAL) << "AddCallbackWithHeaderCalculator must use std::function"; } } @@ -290,7 +291,7 @@ absl::Status CallbackCalculator::Open(CalculatorContext* cc) { .Tag("VECTOR_CALLBACK") .Get&)>>(); } else { - LOG(FATAL) << "InputSidePackets must use tags."; + ABSL_LOG(FATAL) << "InputSidePackets must use tags."; } if (callback_ == nullptr && vector_callback_ == nullptr) { return mediapipe::InvalidArgumentErrorBuilder(MEDIAPIPE_LOC) @@ -347,7 +348,7 @@ absl::Status CallbackWithHeaderCalculator::Open(CalculatorContext* cc) { .Tag("CALLBACK") .Get>(); } else { - LOG(FATAL) << "InputSidePackets must use tags."; + ABSL_LOG(FATAL) << "InputSidePackets must use tags."; } if (callback_ == nullptr) { return mediapipe::InvalidArgumentErrorBuilder(MEDIAPIPE_LOC) diff --git a/mediapipe/framework/tool/switch_container_test.cc b/mediapipe/framework/tool/switch_container_test.cc index 08cc4ab5a..5ffd26e03 100644 --- a/mediapipe/framework/tool/switch_container_test.cc +++ b/mediapipe/framework/tool/switch_container_test.cc @@ -17,13 +17,13 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_replace.h" #include "absl/strings/string_view.h" #include "mediapipe/framework/calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/parse_text_proto.h" #include "mediapipe/framework/port/proto_ns.h" #include "mediapipe/framework/port/ret_check.h" @@ -385,7 +385,7 @@ TEST(SwitchContainerTest, RunsWithInputStreamHandler) { CalculatorGraphConfig supergraph = SubnodeContainerExample(R"pb(synchronize_io: true)pb"); MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph)); - LOG(INFO) << supergraph.DebugString(); + ABSL_LOG(INFO) << supergraph.DebugString(); RunTestContainer(supergraph, true); } diff --git a/mediapipe/framework/tool/tag_map_test.cc b/mediapipe/framework/tool/tag_map_test.cc index a93b94445..68ee94ae7 100644 --- a/mediapipe/framework/tool/tag_map_test.cc +++ b/mediapipe/framework/tool/tag_map_test.cc @@ -14,6 +14,7 @@ #include "mediapipe/framework/tool/tag_map.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_join.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" @@ -329,8 +330,8 @@ void TestDebugString( tool::TagMap& tag_map = *statusor_tag_map.value(); std::string debug_string = tag_map.DebugString(); std::string short_string = tag_map.ShortDebugString(); - LOG(INFO) << "ShortDebugString:\n" << short_string << "\n"; - LOG(INFO) << "DebugString:\n" << debug_string << "\n\n"; + ABSL_LOG(INFO) << "ShortDebugString:\n" << short_string << "\n"; + ABSL_LOG(INFO) << "DebugString:\n" << debug_string << "\n\n"; std::vector actual_entries; for (const auto& field : tag_map.CanonicalEntries()) { diff --git a/mediapipe/framework/tool/template_expander.cc b/mediapipe/framework/tool/template_expander.cc index a9af5c45b..9bbe2165d 100644 --- a/mediapipe/framework/tool/template_expander.cc +++ b/mediapipe/framework/tool/template_expander.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/strings/ascii.h" #include "absl/strings/match.h" #include "absl/strings/numbers.h" @@ -687,7 +689,7 @@ absl::Status TemplateExpander::ExpandTemplates( } absl::Status status; for (const absl::Status& error : errors_) { - LOG(ERROR) << error; + ABSL_LOG(ERROR) << error; status.Update(error); } return status; diff --git a/mediapipe/framework/tool/template_parser.cc b/mediapipe/framework/tool/template_parser.cc index 209def6ab..5bc42ba2c 100644 --- a/mediapipe/framework/tool/template_parser.cc +++ b/mediapipe/framework/tool/template_parser.cc @@ -21,6 +21,7 @@ #include #include "absl/container/flat_hash_set.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/ascii.h" #include "absl/strings/numbers.h" @@ -31,7 +32,6 @@ #include "mediapipe/framework/deps/proto_descriptor.pb.h" #include "mediapipe/framework/port/canonical_errors.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/map_util.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" @@ -181,11 +181,11 @@ void CheckFieldIndex(const FieldDescriptor* field, int index) { } if (field->is_repeated() && index == -1) { - LOG(DFATAL) << "Index must be in range of repeated field values. " - << "Field: " << field->name(); + ABSL_LOG(ERROR) << "Index must be in range of repeated field values. " + << "Field: " << field->name(); } else if (!field->is_repeated() && index != -1) { - LOG(DFATAL) << "Index must be -1 for singular fields." - << "Field: " << field->name(); + ABSL_LOG(ERROR) << "Index must be -1 for singular fields." + << "Field: " << field->name(); } } @@ -305,7 +305,7 @@ class TemplateParser::Parser::ParserImpl { // Parses the ASCII representation specified in input and saves the // information into the output pointer (a Message). Returns // false if an error occurs (an error will also be logged to - // LOG(ERROR)). + // ABSL_LOG(ERROR)). virtual bool Parse(Message* output) { // Consume fields until we cannot do so anymore. while (true) { @@ -335,12 +335,12 @@ class TemplateParser::Parser::ParserImpl { had_errors_ = true; if (error_collector_ == NULL) { if (line >= 0) { - LOG(ERROR) << "Error parsing text-format " - << root_message_type_->full_name() << ": " << (line + 1) - << ":" << (col + 1) << ": " << message; + ABSL_LOG(ERROR) << "Error parsing text-format " + << root_message_type_->full_name() << ": " << (line + 1) + << ":" << (col + 1) << ": " << message; } else { - LOG(ERROR) << "Error parsing text-format " - << root_message_type_->full_name() << ": " << message; + ABSL_LOG(ERROR) << "Error parsing text-format " + << root_message_type_->full_name() << ": " << message; } } else { error_collector_->AddError(line, col, std::string(message)); @@ -350,12 +350,12 @@ class TemplateParser::Parser::ParserImpl { void ReportWarning(int line, int col, absl::string_view message) { if (error_collector_ == NULL) { if (line >= 0) { - LOG(WARNING) << "Warning parsing text-format " - << root_message_type_->full_name() << ": " << (line + 1) - << ":" << (col + 1) << ": " << message; + ABSL_LOG(WARNING) << "Warning parsing text-format " + << root_message_type_->full_name() << ": " + << (line + 1) << ":" << (col + 1) << ": " << message; } else { - LOG(WARNING) << "Warning parsing text-format " - << root_message_type_->full_name() << ": " << message; + ABSL_LOG(WARNING) << "Warning parsing text-format " + << root_message_type_->full_name() << ": " << message; } } else { error_collector_->AddWarning(line, col, std::string(message)); @@ -884,7 +884,7 @@ class TemplateParser::Parser::ParserImpl { case FieldDescriptor::CPPTYPE_MESSAGE: { // We should never get here. Put here instead of a default // so that if new types are added, we get a nice compiler warning. - LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE"; + ABSL_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE"; break; } } diff --git a/mediapipe/framework/tool/test_util.cc b/mediapipe/framework/tool/test_util.cc index 5e712ecf5..d82a491da 100644 --- a/mediapipe/framework/tool/test_util.cc +++ b/mediapipe/framework/tool/test_util.cc @@ -22,6 +22,8 @@ #include "absl/cleanup/cleanup.h" #include "absl/container/flat_hash_set.h" +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/memory/memory.h" #include "absl/status/status.h" #include "absl/strings/match.h" @@ -35,7 +37,6 @@ #include "mediapipe/framework/formats/image_format.pb.h" #include "mediapipe/framework/port/advanced_proto_inc.h" #include "mediapipe/framework/port/file_helpers.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/proto_ns.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status_macros.h" @@ -196,7 +197,7 @@ absl::Status CompareImageFrames(const ImageFrame& image1, return CompareDiff(image1, image2, max_color_diff, max_alpha_diff, max_avg_diff, diff_image); default: - LOG(FATAL) << ImageFrame::InvalidFormatString(image1.Format()); + ABSL_LOG(FATAL) << ImageFrame::InvalidFormatString(image1.Format()); } } @@ -336,15 +337,15 @@ absl::StatusOr SavePngTestOutput( bool LoadTestGraph(CalculatorGraphConfig* proto, const std::string& path) { int fd = open(path.c_str(), O_RDONLY); if (fd == -1) { - LOG(ERROR) << "could not open test graph: " << path - << ", error: " << strerror(errno); + ABSL_LOG(ERROR) << "could not open test graph: " << path + << ", error: " << strerror(errno); return false; } proto_ns::io::FileInputStream input(fd); bool success = proto->ParseFromZeroCopyStream(&input); close(fd); if (!success) { - LOG(ERROR) << "could not parse test graph: " << path; + ABSL_LOG(ERROR) << "could not parse test graph: " << path; } return success; } @@ -355,7 +356,7 @@ std::unique_ptr GenerateLuminanceImage( const int height = original_image.Height(); const int channels = original_image.NumberOfChannels(); if (channels != 3 && channels != 4) { - LOG(ERROR) << "Invalid number of image channels: " << channels; + ABSL_LOG(ERROR) << "Invalid number of image channels: " << channels; return nullptr; } auto luminance_image = diff --git a/mediapipe/framework/tool/text_to_binary_graph.cc b/mediapipe/framework/tool/text_to_binary_graph.cc index b6b38dea7..046f07518 100644 --- a/mediapipe/framework/tool/text_to_binary_graph.cc +++ b/mediapipe/framework/tool/text_to_binary_graph.cc @@ -21,9 +21,11 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator.pb.h" #include "mediapipe/framework/port/advanced_proto_inc.h" #include "mediapipe/framework/port/canonical_errors.h" +#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" @@ -33,10 +35,10 @@ ABSL_FLAG(std::string, proto_source, "", ABSL_FLAG(std::string, proto_output, "", "An output template file in binary CalculatorGraphTemplate form."); -#define EXIT_IF_ERROR(status) \ - if (!status.ok()) { \ - LOG(ERROR) << status; \ - return EXIT_FAILURE; \ +#define EXIT_IF_ERROR(status) \ + if (!status.ok()) { \ + ABSL_LOG(ERROR) << status; \ + return EXIT_FAILURE; \ } namespace mediapipe { diff --git a/mediapipe/framework/type_map.h b/mediapipe/framework/type_map.h index 42f6fe6bf..9af3e895b 100644 --- a/mediapipe/framework/type_map.h +++ b/mediapipe/framework/type_map.h @@ -64,6 +64,8 @@ #include #include "absl/base/macros.h" +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/synchronization/mutex.h" #include "mediapipe/framework/demangle.h" #include "mediapipe/framework/port/status.h" @@ -178,22 +180,24 @@ class StaticMap { const std::string previous_file_and_line = it->second.first; it->second.first = file_and_line; it->second.second = value; - LOG(WARNING) << "Redo mediapipe type registration of type " - << value.type_string << " with serialization function at " - << file_and_line << ". It was registered at " - << previous_file_and_line; + ABSL_LOG(WARNING) << "Redo mediapipe type registration of type " + << value.type_string + << " with serialization function at " << file_and_line + << ". It was registered at " + << previous_file_and_line; } else if (!value.serialize_fn && !value.deserialize_fn) { // Prefers type registration with serialization functions. If type has // been registered with some serialization functions, the // non-serialization version will be ignored. - LOG(WARNING) << "Ignore mediapipe type registration of type " - << value.type_string << " at " << file_and_line - << ", since type has been registered with serialization " - "functions at " - << it->second.first; + ABSL_LOG(WARNING) + << "Ignore mediapipe type registration of type " + << value.type_string << " at " << file_and_line + << ", since type has been registered with serialization " + "functions at " + << it->second.first; } else { // Doesn't allow to only have one of serialize_fn and deserialize_fn. - LOG(FATAL) + ABSL_LOG(FATAL) << "Invalid mediapipe type registration at " << file_and_line << ". Serialization functions should be provided at the same time."; } diff --git a/mediapipe/framework/validated_graph_config.cc b/mediapipe/framework/validated_graph_config.cc index 10d47d874..2a718cfaa 100644 --- a/mediapipe/framework/validated_graph_config.cc +++ b/mediapipe/framework/validated_graph_config.cc @@ -18,6 +18,7 @@ #include #include "absl/container/flat_hash_set.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" @@ -110,8 +111,8 @@ std::string DebugName(const CalculatorGraphConfig& config, case NodeTypeInfo::NodeType::UNKNOWN: /* Fall through. */ {} } - LOG(FATAL) << "Unknown NodeTypeInfo::NodeType: " - << NodeTypeInfo::NodeTypeToString(node_type); + ABSL_LOG(FATAL) << "Unknown NodeTypeInfo::NodeType: " + << NodeTypeInfo::NodeTypeToString(node_type); } // Adds the ExecutorConfigs for predefined executors, if they are not in @@ -160,8 +161,8 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { case NodeTypeInfo::NodeType::UNKNOWN: return "Unknown Node"; } - LOG(FATAL) << "Unknown NodeTypeInfo::NodeType: " - << static_cast(node_type); + ABSL_LOG(FATAL) << "Unknown NodeTypeInfo::NodeType: " + << static_cast(node_type); } absl::Status NodeTypeInfo::Initialize( @@ -694,12 +695,13 @@ absl::Status ValidatedGraphConfig::AddInputStreamsForNode( if (edge_info.back_edge) { // A back edge was specified, but its output side was already seen. if (!need_sorting_ptr) { - LOG(WARNING) << "Input Stream \"" << name - << "\" for node with sorted index " << node_index - << " name " << node_type_info->Contract().GetNodeName() - << " is marked as a back edge, but its output stream is " - "already available. This means it was not necessary " - "to mark it as a back edge."; + ABSL_LOG(WARNING) + << "Input Stream \"" << name << "\" for node with sorted index " + << node_index << " name " + << node_type_info->Contract().GetNodeName() + << " is marked as a back edge, but its output stream is " + "already available. This means it was not necessary " + "to mark it as a back edge."; } } else { edge_info.upstream = iter->second; diff --git a/mediapipe/gpu/BUILD b/mediapipe/gpu/BUILD index bc5fb95fc..ebca543f8 100644 --- a/mediapipe/gpu/BUILD +++ b/mediapipe/gpu/BUILD @@ -204,6 +204,8 @@ cc_library( "//mediapipe/framework/port:threadpool", "@com_google_absl//absl/base:dynamic_annotations", "@com_google_absl//absl/debugging:leak_check", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", @@ -235,6 +237,7 @@ cc_library( ":gpu_buffer_format", ":gpu_buffer_storage", ":gpu_buffer_storage_image_frame", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", # TODO: remove this dependency. Some other teams' tests # depend on having an indirect image_frame dependency, need to be @@ -368,6 +371,7 @@ cc_library( ":image_frame_view", "//mediapipe/objc:CFHolder", "//mediapipe/objc:util", + "@com_google_absl//absl/log:absl_log", ], ) @@ -476,7 +480,7 @@ cc_library( "//mediapipe/framework/formats:yuv_image", "//mediapipe/util/frame_buffer:frame_buffer_util", "//third_party/libyuv", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/log:check", ], ) @@ -756,6 +760,7 @@ cc_library( deps = [ ":gl_base", "//mediapipe/framework/port:logging", + "@com_google_absl//absl/log:absl_log", ], ) @@ -818,11 +823,11 @@ cc_library( "//mediapipe/framework/deps:registration", "//mediapipe/framework/formats:image", "//mediapipe/framework/formats:image_frame", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:map_util", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/synchronization", ] + select({ @@ -848,6 +853,7 @@ objc_library( "//mediapipe/objc:mediapipe_framework_ios", "//third_party/apple_frameworks:CoreVideo", "//third_party/apple_frameworks:Metal", + "@com_google_absl//absl/log:absl_log", "@google_toolbox_for_mac//:GTM_Defines", ], ) @@ -990,6 +996,7 @@ cc_library( "//mediapipe/framework/api2:node", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/synchronization", ], alwayslink = 1, diff --git a/mediapipe/gpu/MPPMetalHelper.mm b/mediapipe/gpu/MPPMetalHelper.mm index c0703e6ee..e87b81a4e 100644 --- a/mediapipe/gpu/MPPMetalHelper.mm +++ b/mediapipe/gpu/MPPMetalHelper.mm @@ -14,9 +14,10 @@ #import "mediapipe/gpu/MPPMetalHelper.h" +#import "third_party/absl/log/absl_log.h" #import "mediapipe/gpu/gpu_buffer.h" -#import "mediapipe/gpu/graph_support.h" #import "mediapipe/gpu/gpu_service.h" +#import "mediapipe/gpu/graph_support.h" #import "mediapipe/gpu/metal_shared_resources.h" #import "GTMDefines.h" @@ -83,9 +84,8 @@ class MetalHelperLegacySupport { } // TODO: remove when we can. - LOG(WARNING) - << "CalculatorContext not available. If this calculator uses " - "CalculatorBase, call initWithCalculatorContext instead."; + ABSL_LOG(WARNING) << "CalculatorContext not available. If this calculator uses " + "CalculatorBase, call initWithCalculatorContext instead."; mediapipe::GpuSharedData* gpu_shared = inputSidePackets.Tag(mediapipe::kGpuSharedTagName).Get(); @@ -101,9 +101,8 @@ class MetalHelperLegacySupport { } // TODO: remove when we can. - LOG(WARNING) - << "CalculatorContract not available. If you're calling this " - "from a GetContract method, call updateContract instead."; + ABSL_LOG(WARNING) << "CalculatorContract not available. If you're calling this " + "from a GetContract method, call updateContract instead."; auto id = inputSidePackets->GetId(mediapipe::kGpuSharedTagName, 0); RET_CHECK(id.IsValid()) << "A " << mediapipe::kGpuSharedTagName diff --git a/mediapipe/gpu/gl_calculator_helper.cc b/mediapipe/gpu/gl_calculator_helper.cc index 783f4fc87..eff994dcb 100644 --- a/mediapipe/gpu/gl_calculator_helper.cc +++ b/mediapipe/gpu/gl_calculator_helper.cc @@ -14,6 +14,7 @@ #include "mediapipe/gpu/gl_calculator_helper.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/formats/image.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/framework/legacy_calculator_support.h" @@ -76,7 +77,7 @@ absl::Status GlCalculatorHelper::SetupInputSidePackets( } // TODO: remove when we can. - LOG(WARNING) + ABSL_LOG(WARNING) << "CalculatorContract not available. If you're calling this " "from a GetContract method, call GlCalculatorHelper::UpdateContract " "instead."; diff --git a/mediapipe/gpu/gl_context.cc b/mediapipe/gpu/gl_context.cc index d7381babd..1ab3fabb9 100644 --- a/mediapipe/gpu/gl_context.cc +++ b/mediapipe/gpu/gl_context.cc @@ -22,10 +22,10 @@ #include #include "absl/base/dynamic_annotations.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/status/status.h" #include "absl/synchronization/mutex.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status_builder.h" @@ -59,8 +59,8 @@ static void SetThreadName(const char* name) { thread_name[sizeof(thread_name) - 1] = '\0'; int res = pthread_setname_np(pthread_self(), thread_name); if (res != 0) { - LOG_FIRST_N(INFO, 1) << "Can't set pthread names: name: \"" << name - << "\"; error: " << res; + ABSL_LOG_FIRST_N(INFO, 1) + << "Can't set pthread names: name: \"" << name << "\"; error: " << res; } #elif __APPLE__ pthread_setname_np(name); @@ -236,9 +236,10 @@ absl::Status GlContext::GetGlExtensions() { // platforms to avoid possible undefined symbol or runtime errors. #if (GL_VERSION_3_0 || GL_ES_VERSION_3_0) && !defined(__EMSCRIPTEN__) if (!SymbolAvailable(&glGetStringi)) { - LOG(ERROR) << "GL major version > 3.0 indicated, but glGetStringi not " - << "defined. Falling back to deprecated GL extensions querying " - << "method."; + ABSL_LOG(ERROR) + << "GL major version > 3.0 indicated, but glGetStringi not " + << "defined. Falling back to deprecated GL extensions querying " + << "method."; return absl::InternalError("glGetStringi not defined, but queried"); } int num_extensions = 0; @@ -269,7 +270,7 @@ absl::Status GlContext::GetGlExtensionsCompat() { const GLubyte* res = glGetString(GL_EXTENSIONS); if (glGetError() != 0 || res == nullptr) { - LOG(ERROR) << "Error querying for GL extensions"; + ABSL_LOG(ERROR) << "Error querying for GL extensions"; return absl::InternalError("Error querying for GL extensions"); } const char* signed_res = reinterpret_cast(res); @@ -297,7 +298,7 @@ absl::Status GlContext::FinishInitialization(bool create_thread) { } else { // This may happen when using SwiftShader, but the numeric versions are // available and will be used instead. - LOG(WARNING) << "failed to get GL_VERSION string"; + ABSL_LOG(WARNING) << "failed to get GL_VERSION string"; } // We will decide later whether we want to use the version numbers we query @@ -315,8 +316,8 @@ absl::Status GlContext::FinishInitialization(bool create_thread) { // parse the version string. if (!ParseGlVersion(version_string, &gl_major_version_, &gl_minor_version_)) { - LOG(WARNING) << "invalid GL_VERSION format: '" << version_string - << "'; assuming 2.0"; + ABSL_LOG(WARNING) << "invalid GL_VERSION format: '" << version_string + << "'; assuming 2.0"; gl_major_version_ = 2; gl_minor_version_ = 0; } @@ -330,18 +331,18 @@ absl::Status GlContext::FinishInitialization(bool create_thread) { // for more details. if (gl_major_version_from_context_creation > 0 && gl_major_version_ != gl_major_version_from_context_creation) { - LOG(WARNING) << "Requested a context with major GL version " - << gl_major_version_from_context_creation - << " but context reports major version " << gl_major_version_ - << ". Setting to " << gl_major_version_from_context_creation - << ".0"; + ABSL_LOG(WARNING) << "Requested a context with major GL version " + << gl_major_version_from_context_creation + << " but context reports major version " + << gl_major_version_ << ". Setting to " + << gl_major_version_from_context_creation << ".0"; gl_major_version_ = gl_major_version_from_context_creation; gl_minor_version_ = 0; } - LOG(INFO) << "GL version: " << gl_major_version_ << "." << gl_minor_version_ - << " (" << version_string - << "), renderer: " << glGetString(GL_RENDERER); + ABSL_LOG(INFO) << "GL version: " << gl_major_version_ << "." + << gl_minor_version_ << " (" << version_string + << "), renderer: " << glGetString(GL_RENDERER); { auto status = GetGlExtensions(); @@ -389,7 +390,7 @@ GlContext::~GlContext() { clear_attachments(); return ExitContext(nullptr); }); - LOG_IF(ERROR, !status.ok()) + ABSL_LOG_IF(ERROR, !status.ok()) << "Failed to deactivate context on thread: " << status; if (thread_->IsCurrentThread()) { thread_.release()->SelfDestruct(); @@ -403,7 +404,7 @@ GlContext::~GlContext() { clear_attachments(); return absl::OkStatus(); }); - LOG_IF(ERROR, !status.ok()) << status; + ABSL_LOG_IF(ERROR, !status.ok()) << status; } } DestroyContext(); @@ -468,7 +469,7 @@ void GlContext::RunWithoutWaiting(GlVoidFunction gl_func) { return absl::OkStatus(); }); if (!status.ok()) { - LOG(ERROR) << "Error in RunWithoutWaiting: " << status; + ABSL_LOG(ERROR) << "Error in RunWithoutWaiting: " << status; } } } @@ -982,7 +983,7 @@ bool GlContext::CheckForGlErrors() { return CheckForGlErrors(false); } bool GlContext::CheckForGlErrors(bool force) { #if UNSAFE_EMSCRIPTEN_SKIP_GL_ERROR_HANDLING if (!force) { - LOG_FIRST_N(WARNING, 1) << "OpenGL error checking is disabled"; + ABSL_LOG_FIRST_N(WARNING, 1) << "OpenGL error checking is disabled"; return false; } #endif @@ -994,23 +995,23 @@ bool GlContext::CheckForGlErrors(bool force) { had_error = true; switch (error) { case GL_INVALID_ENUM: - LOG(INFO) << "Found unchecked GL error: GL_INVALID_ENUM"; + ABSL_LOG(INFO) << "Found unchecked GL error: GL_INVALID_ENUM"; break; case GL_INVALID_VALUE: - LOG(INFO) << "Found unchecked GL error: GL_INVALID_VALUE"; + ABSL_LOG(INFO) << "Found unchecked GL error: GL_INVALID_VALUE"; break; case GL_INVALID_OPERATION: - LOG(INFO) << "Found unchecked GL error: GL_INVALID_OPERATION"; + ABSL_LOG(INFO) << "Found unchecked GL error: GL_INVALID_OPERATION"; break; case GL_INVALID_FRAMEBUFFER_OPERATION: - LOG(INFO) + ABSL_LOG(INFO) << "Found unchecked GL error: GL_INVALID_FRAMEBUFFER_OPERATION"; break; case GL_OUT_OF_MEMORY: - LOG(INFO) << "Found unchecked GL error: GL_OUT_OF_MEMORY"; + ABSL_LOG(INFO) << "Found unchecked GL error: GL_OUT_OF_MEMORY"; break; default: - LOG(INFO) << "Found unchecked GL error: UNKNOWN ERROR"; + ABSL_LOG(INFO) << "Found unchecked GL error: UNKNOWN ERROR"; break; } } @@ -1022,9 +1023,9 @@ void GlContext::LogUncheckedGlErrors(bool had_gl_errors) { // TODO: ideally we would print a backtrace here, or at least // the name of the current calculator, to make it easier to find the // culprit. In practice, getting a backtrace from Android without crashing - // is nearly impossible, so screw it. Just change this to LOG(FATAL) when - // you want to debug. - LOG(WARNING) << "Ignoring unchecked GL error."; + // is nearly impossible, so screw it. Just change this to ABSL_LOG(FATAL) + // when you want to debug. + ABSL_LOG(WARNING) << "Ignoring unchecked GL error."; } } diff --git a/mediapipe/gpu/gl_context_eagl.cc b/mediapipe/gpu/gl_context_eagl.cc index 865813c21..5beb9d49f 100644 --- a/mediapipe/gpu/gl_context_eagl.cc +++ b/mediapipe/gpu/gl_context_eagl.cc @@ -15,7 +15,6 @@ #include #include "absl/memory/memory.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status_builder.h" diff --git a/mediapipe/gpu/gl_context_egl.cc b/mediapipe/gpu/gl_context_egl.cc index f8784bbbc..5d2592794 100644 --- a/mediapipe/gpu/gl_context_egl.cc +++ b/mediapipe/gpu/gl_context_egl.cc @@ -14,10 +14,11 @@ #include +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/memory/memory.h" #include "absl/status/status.h" #include "absl/status/statusor.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status_builder.h" @@ -58,7 +59,7 @@ static void EglThreadExitCallback(void* key_value) { static void MakeEglReleaseThreadKey() { int err = pthread_key_create(&egl_release_thread_key, EglThreadExitCallback); if (err) { - LOG(ERROR) << "cannot create pthread key: " << err; + ABSL_LOG(ERROR) << "cannot create pthread key: " << err; } } @@ -81,8 +82,8 @@ static absl::StatusOr GetInitializedDefaultEglDisplay() { EGLint minor = 0; EGLBoolean egl_initialized = eglInitialize(display, &major, &minor); RET_CHECK(egl_initialized) << "Unable to initialize EGL"; - LOG(INFO) << "Successfully initialized EGL. Major : " << major - << " Minor: " << minor; + ABSL_LOG(INFO) << "Successfully initialized EGL. Major : " << major + << " Minor: " << minor; return display; } @@ -180,8 +181,9 @@ absl::Status GlContext::CreateContext(EGLContext share_context) { auto status = CreateContextInternal(share_context, 3); if (!status.ok()) { - LOG(WARNING) << "Creating a context with OpenGL ES 3 failed: " << status; - LOG(WARNING) << "Fall back on OpenGL ES 2."; + ABSL_LOG(WARNING) << "Creating a context with OpenGL ES 3 failed: " + << status; + ABSL_LOG(WARNING) << "Fall back on OpenGL ES 2."; status = CreateContextInternal(share_context, 2); } MP_RETURN_IF_ERROR(status); @@ -208,13 +210,13 @@ void GlContext::DestroyContext() { if (eglMakeCurrent(display_, surface_, surface_, context_)) { glUseProgram(0); } else { - LOG(ERROR) << "eglMakeCurrent() returned error " << std::showbase - << std::hex << eglGetError(); + ABSL_LOG(ERROR) << "eglMakeCurrent() returned error " << std::showbase + << std::hex << eglGetError(); } return SetCurrentContextBinding(saved_context); }; auto status = thread_ ? thread_->Run(detach_program) : detach_program(); - LOG_IF(ERROR, !status.ok()) << status; + ABSL_LOG_IF(ERROR, !status.ok()) << status; } #endif // __ANDROID__ @@ -236,21 +238,21 @@ void GlContext::DestroyContext() { if (IsCurrent()) { if (!eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) { - LOG(ERROR) << "eglMakeCurrent() returned error " << std::showbase - << std::hex << eglGetError(); + ABSL_LOG(ERROR) << "eglMakeCurrent() returned error " << std::showbase + << std::hex << eglGetError(); } } if (surface_ != EGL_NO_SURFACE) { if (!eglDestroySurface(display_, surface_)) { - LOG(ERROR) << "eglDestroySurface() returned error " << std::showbase - << std::hex << eglGetError(); + ABSL_LOG(ERROR) << "eglDestroySurface() returned error " << std::showbase + << std::hex << eglGetError(); } surface_ = EGL_NO_SURFACE; } if (context_ != EGL_NO_CONTEXT) { if (!eglDestroyContext(display_, context_)) { - LOG(ERROR) << "eglDestroyContext() returned error " << std::showbase - << std::hex << eglGetError(); + ABSL_LOG(ERROR) << "eglDestroyContext() returned error " << std::showbase + << std::hex << eglGetError(); } context_ = EGL_NO_CONTEXT; } diff --git a/mediapipe/gpu/gl_context_nsgl.cc b/mediapipe/gpu/gl_context_nsgl.cc index 561474ad8..82d92a00a 100644 --- a/mediapipe/gpu/gl_context_nsgl.cc +++ b/mediapipe/gpu/gl_context_nsgl.cc @@ -14,8 +14,8 @@ #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status_builder.h" @@ -83,7 +83,7 @@ absl::Status GlContext::CreateContext(NSOpenGLContext* share_context) { if (!pixel_format_) { // On several Forge machines, the default config fails. For now let's do // this. - LOG(WARNING) + ABSL_LOG(WARNING) << "failed to create pixel format; trying without acceleration"; NSOpenGLPixelFormatAttribute attrs_no_accel[] = {NSOpenGLPFAColorSize, 24, @@ -102,7 +102,8 @@ absl::Status GlContext::CreateContext(NSOpenGLContext* share_context) { // Try to query pixel format from shared context. if (!context_) { - LOG(WARNING) << "Requested context not created, using queried context."; + ABSL_LOG(WARNING) + << "Requested context not created, using queried context."; CGLContextObj cgl_ctx = static_cast([share_context CGLContextObj]); CGLPixelFormatObj cgl_fmt = diff --git a/mediapipe/gpu/gl_context_webgl.cc b/mediapipe/gpu/gl_context_webgl.cc index 1bbb42c84..c81f35b93 100644 --- a/mediapipe/gpu/gl_context_webgl.cc +++ b/mediapipe/gpu/gl_context_webgl.cc @@ -14,6 +14,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" @@ -78,7 +79,7 @@ absl::Status GlContext::CreateContextInternal( // Check for failure if (context_handle <= 0) { - LOG(INFO) << "Couldn't create webGL " << webgl_version << " context."; + ABSL_LOG(INFO) << "Couldn't create webGL " << webgl_version << " context."; return ::mediapipe::UnknownErrorBuilder(MEDIAPIPE_LOC) << "emscripten_webgl_create_context() returned error " << context_handle; @@ -103,8 +104,8 @@ absl::Status GlContext::CreateContext( auto status = CreateContextInternal(external_context, 2); if (!status.ok()) { - LOG(WARNING) << "Creating a context with WebGL 2 failed: " << status; - LOG(WARNING) << "Fall back on WebGL 1."; + ABSL_LOG(WARNING) << "Creating a context with WebGL 2 failed: " << status; + ABSL_LOG(WARNING) << "Fall back on WebGL 1."; status = CreateContextInternal(external_context, 1); } MP_RETURN_IF_ERROR(status); @@ -117,17 +118,18 @@ absl::Status GlContext::CreateContext( void GlContext::DestroyContext() { if (thread_) { // For now, we force web MediaPipe to be single-threaded, so error here. - LOG(ERROR) << "thread_ should not exist in DestroyContext() on web."; + ABSL_LOG(ERROR) << "thread_ should not exist in DestroyContext() on web."; } // Destroy the context and surface. if (context_ != 0) { EMSCRIPTEN_RESULT res = emscripten_webgl_destroy_context(context_); if (res != EMSCRIPTEN_RESULT_SUCCESS) { - LOG(ERROR) << "emscripten_webgl_destroy_context() returned error " << res; + ABSL_LOG(ERROR) << "emscripten_webgl_destroy_context() returned error " + << res; } else { - LOG(INFO) << "Successfully destroyed WebGL context with handle " - << context_; + ABSL_LOG(INFO) << "Successfully destroyed WebGL context with handle " + << context_; } context_ = 0; } diff --git a/mediapipe/gpu/gl_surface_sink_calculator.cc b/mediapipe/gpu/gl_surface_sink_calculator.cc index ad867c2be..dbbf25268 100644 --- a/mediapipe/gpu/gl_surface_sink_calculator.cc +++ b/mediapipe/gpu/gl_surface_sink_calculator.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/log/absl_log.h" #include "absl/synchronization/mutex.h" #include "mediapipe/framework/api2/node.h" #include "mediapipe/framework/calculator_framework.h" @@ -95,7 +96,7 @@ absl::Status GlSurfaceSinkCalculator::Process(CalculatorContext* cc) { absl::MutexLock lock(&surface_holder_->mutex); EGLSurface surface = surface_holder_->surface; if (surface == EGL_NO_SURFACE) { - LOG_EVERY_N(INFO, 300) << "GlSurfaceSinkCalculator: no surface"; + ABSL_LOG_EVERY_N(INFO, 300) << "GlSurfaceSinkCalculator: no surface"; return absl::OkStatus(); } diff --git a/mediapipe/gpu/gl_texture_buffer.cc b/mediapipe/gpu/gl_texture_buffer.cc index 4e5ce4ee4..ffa8db6e0 100644 --- a/mediapipe/gpu/gl_texture_buffer.cc +++ b/mediapipe/gpu/gl_texture_buffer.cc @@ -14,6 +14,7 @@ #include "mediapipe/gpu/gl_texture_buffer.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/gpu/gl_context.h" #include "mediapipe/gpu/gl_texture_view.h" @@ -47,7 +48,7 @@ std::unique_ptr GlTextureBuffer::Create(int width, int height, auto buf = absl::make_unique(GL_TEXTURE_2D, 0, width, height, format, nullptr); if (!buf->CreateInternal(data, alignment)) { - LOG(WARNING) << "Failed to create a GL texture"; + ABSL_LOG(WARNING) << "Failed to create a GL texture"; return nullptr; } return buf; @@ -108,7 +109,7 @@ GlTextureBuffer::GlTextureBuffer(GLenum target, GLuint name, int width, bool GlTextureBuffer::CreateInternal(const void* data, int alignment) { auto context = GlContext::GetCurrent(); if (!context) { - LOG(WARNING) << "Cannot create a GL texture without a valid context"; + ABSL_LOG(WARNING) << "Cannot create a GL texture without a valid context"; return false; } @@ -216,7 +217,7 @@ void GlTextureBuffer::DidRead(std::shared_ptr cons_token) const { consumer_multi_sync_->Add(std::move(cons_token)); } else { // TODO: change to a CHECK. - LOG_FIRST_N(WARNING, 5) << "unexpected null sync in DidRead"; + ABSL_LOG_FIRST_N(WARNING, 5) << "unexpected null sync in DidRead"; } } diff --git a/mediapipe/gpu/gpu_buffer_storage_cv_pixel_buffer.cc b/mediapipe/gpu/gpu_buffer_storage_cv_pixel_buffer.cc index 7cac32b7f..7759cc789 100644 --- a/mediapipe/gpu/gpu_buffer_storage_cv_pixel_buffer.cc +++ b/mediapipe/gpu/gpu_buffer_storage_cv_pixel_buffer.cc @@ -2,6 +2,7 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/gpu/gl_context.h" #include "mediapipe/gpu/gpu_buffer_storage_image_frame.h" #include "mediapipe/objc/util.h" @@ -113,7 +114,7 @@ static void ViewDoneWritingSimulatorWorkaround(CVPixelBufferRef pixel_buffer, view.target(), 0, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0); } else { - LOG(ERROR) << "unsupported pixel format: " << pixel_format; + ABSL_LOG(ERROR) << "unsupported pixel format: " << pixel_format; } err = CVPixelBufferUnlockBaseAddress(pixel_buffer, 0); CHECK(err == kCVReturnSuccess) diff --git a/mediapipe/gpu/gpu_buffer_storage_yuv_image.cc b/mediapipe/gpu/gpu_buffer_storage_yuv_image.cc index 41905de74..1137154b2 100644 --- a/mediapipe/gpu/gpu_buffer_storage_yuv_image.cc +++ b/mediapipe/gpu/gpu_buffer_storage_yuv_image.cc @@ -19,8 +19,8 @@ limitations under the License. #include #include +#include "absl/log/absl_log.h" #include "absl/log/check.h" -#include "absl/log/log.h" #include "libyuv/video_common.h" #include "mediapipe/framework/formats/frame_buffer.h" #include "mediapipe/framework/formats/image_frame.h" @@ -123,7 +123,7 @@ std::shared_ptr YuvImageToFrameBuffer( break; } default: - LOG(FATAL) + ABSL_LOG(FATAL) << "Invalid format. Only FOURCC_NV12, FOURCC_NV21, FOURCC_YV12 and " "FOURCC_I420 are supported."; } @@ -195,7 +195,7 @@ GpuBufferStorageYuvImage::GpuBufferStorageYuvImage(int width, int height, break; } default: - LOG(FATAL) + ABSL_LOG(FATAL) << "Invalid format. Only kNV12, kNV21, kYV12 and kYV21 are supported"; } } @@ -223,6 +223,6 @@ std::shared_ptr GpuBufferStorageYuvImage::GetWriteView( internal::types) { // Not supported on purpose: writes into the resulting ImageFrame cannot // easily be ported back to the original YUV image. - LOG(FATAL) << "GetWriteView is not supported."; + ABSL_LOG(FATAL) << "GetWriteView is not supported."; } } // namespace mediapipe diff --git a/mediapipe/gpu/shader_util.cc b/mediapipe/gpu/shader_util.cc index 5de7e24f5..3e3eb462d 100644 --- a/mediapipe/gpu/shader_util.cc +++ b/mediapipe/gpu/shader_util.cc @@ -16,6 +16,7 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/logging.h" #if DEBUG @@ -26,7 +27,7 @@ if (log_length > 0) { \ GLchar* log = static_cast(malloc(log_length)); \ glGet##type##InfoLog(object, log_length, &log_length, log); \ - LOG(INFO) << #type " " action " log:\n" << log; \ + ABSL_LOG(INFO) << #type " " action " log:\n" << log; \ free(log); \ } \ } while (0) @@ -41,7 +42,7 @@ if (log_length > 0) { \ GLchar* log = static_cast(malloc(log_length)); \ glGet##type##InfoLog(object, log_length, &log_length, log); \ - LOG(ERROR) << #type " " action " log:\n" << log; \ + ABSL_LOG(ERROR) << #type " " action " log:\n" << log; \ free(log); \ } \ } while (0) @@ -70,13 +71,14 @@ GLint GlhCompileShader(GLenum target, const GLchar* source, GLuint* shader, GLint status; glGetShaderiv(*shader, GL_COMPILE_STATUS, &status); - LOG_IF(ERROR, status == GL_FALSE) << "Failed to compile shader:\n" << source; + ABSL_LOG_IF(ERROR, status == GL_FALSE) << "Failed to compile shader:\n" + << source; if (status == GL_FALSE) { int length = 0; GLchar cmessage[kMaxShaderInfoLength]; glGetShaderInfoLog(*shader, kMaxShaderInfoLength, &length, cmessage); - LOG(ERROR) << "Error message: " << std::string(cmessage, length); + ABSL_LOG(ERROR) << "Error message: " << std::string(cmessage, length); } return status; } @@ -95,7 +97,8 @@ GLint GlhLinkProgram(GLuint program, bool force_log_errors) { GL_DEBUG_LOG(Program, program, "link"); glGetProgramiv(program, GL_LINK_STATUS, &status); - LOG_IF(ERROR, status == GL_FALSE) << "Failed to link program " << program; + ABSL_LOG_IF(ERROR, status == GL_FALSE) + << "Failed to link program " << program; return status; } @@ -108,7 +111,8 @@ GLint GlhValidateProgram(GLuint program) { GL_DEBUG_LOG(Program, program, "validate"); glGetProgramiv(program, GL_VALIDATE_STATUS, &status); - LOG_IF(ERROR, status == GL_FALSE) << "Failed to validate program " << program; + ABSL_LOG_IF(ERROR, status == GL_FALSE) + << "Failed to validate program " << program; return status; } diff --git a/mediapipe/graphs/instant_motion_tracking/calculators/BUILD b/mediapipe/graphs/instant_motion_tracking/calculators/BUILD index 93af68c21..cdfd911d4 100644 --- a/mediapipe/graphs/instant_motion_tracking/calculators/BUILD +++ b/mediapipe/graphs/instant_motion_tracking/calculators/BUILD @@ -63,6 +63,7 @@ cc_library( "//mediapipe/framework/port:status", "//mediapipe/graphs/object_detection_3d/calculators:model_matrix_cc_proto", "//mediapipe/modules/objectron/calculators:box", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", "@eigen_archive//:eigen3", diff --git a/mediapipe/graphs/instant_motion_tracking/calculators/matrices_manager_calculator.cc b/mediapipe/graphs/instant_motion_tracking/calculators/matrices_manager_calculator.cc index c003135bd..a73589a8c 100644 --- a/mediapipe/graphs/instant_motion_tracking/calculators/matrices_manager_calculator.cc +++ b/mediapipe/graphs/instant_motion_tracking/calculators/matrices_manager_calculator.cc @@ -18,6 +18,7 @@ #include "Eigen/Core" #include "Eigen/Dense" #include "Eigen/Geometry" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" @@ -116,8 +117,8 @@ class MatricesManagerCalculator : public CalculatorBase { return user_scaling.scale_factor; } } - LOG(WARNING) << "Cannot find sticker_id: " << sticker_id - << ", returning 1.0f scaling"; + ABSL_LOG(WARNING) << "Cannot find sticker_id: " << sticker_id + << ", returning 1.0f scaling"; return 1.0f; } @@ -129,8 +130,8 @@ class MatricesManagerCalculator : public CalculatorBase { return rotation.rotation_radians; } } - LOG(WARNING) << "Cannot find sticker_id: " << sticker_id - << ", returning 0.0f rotation"; + ABSL_LOG(WARNING) << "Cannot find sticker_id: " << sticker_id + << ", returning 0.0f rotation"; return 0.0f; } }; @@ -221,8 +222,9 @@ absl::Status MatricesManagerCalculator::Process(CalculatorContext* cc) { model_matrix = asset_matrices_gif->add_model_matrix(); } else { // Asset 3D if (render_data[render_idx] != 1) { - LOG(ERROR) << "render id: " << render_data[render_idx] - << " is not supported. Fall back to using render_id = 1."; + ABSL_LOG(ERROR) + << "render id: " << render_data[render_idx] + << " is not supported. Fall back to using render_id = 1."; } model_matrix = asset_matrices_1->add_model_matrix(); } @@ -379,8 +381,8 @@ DiagonalMatrix3f MatricesManagerCalculator::GetDefaultRenderScaleDiagonal( break; } default: { - LOG(INFO) << "Unsupported render_id: " << render_id - << ", returning default render_scale"; + ABSL_LOG(INFO) << "Unsupported render_id: " << render_id + << ", returning default render_scale"; break; } } diff --git a/mediapipe/graphs/object_detection_3d/calculators/BUILD b/mediapipe/graphs/object_detection_3d/calculators/BUILD index d4c5c496b..39022af29 100644 --- a/mediapipe/graphs/object_detection_3d/calculators/BUILD +++ b/mediapipe/graphs/object_detection_3d/calculators/BUILD @@ -74,6 +74,7 @@ cc_library( "//mediapipe/gpu:shader_util", "//mediapipe/modules/objectron/calculators:camera_parameters_cc_proto", "//mediapipe/util/android:asset_manager_util", + "@com_google_absl//absl/log:absl_log", ], alwayslink = 1, ) diff --git a/mediapipe/graphs/object_detection_3d/calculators/gl_animation_overlay_calculator.cc b/mediapipe/graphs/object_detection_3d/calculators/gl_animation_overlay_calculator.cc index a92020ff0..a0a55301e 100644 --- a/mediapipe/graphs/object_detection_3d/calculators/gl_animation_overlay_calculator.cc +++ b/mediapipe/graphs/object_detection_3d/calculators/gl_animation_overlay_calculator.cc @@ -19,6 +19,7 @@ #include #endif +#include "absl/log/absl_log.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" @@ -35,7 +36,7 @@ namespace { #if defined(GL_DEBUG) #define GLCHECK(command) \ command; \ - if (int err = glGetError()) LOG(ERROR) << "GL error detected: " << err; + if (int err = glGetError()) ABSL_LOG(ERROR) << "GL error detected: " << err; #else #define GLCHECK(command) command #endif @@ -355,12 +356,13 @@ bool GlAnimationOverlayCalculator::ReadBytesFromAsset(AAsset *asset, } // At least log any I/O errors encountered. if (bytes_read < 0) { - LOG(ERROR) << "Error reading from AAsset: " << bytes_read; + ABSL_LOG(ERROR) << "Error reading from AAsset: " << bytes_read; return false; } if (bytes_left > 0) { // Reached EOF before reading in specified number of bytes. - LOG(WARNING) << "Reached EOF before reading in specified number of bytes."; + ABSL_LOG(WARNING) + << "Reached EOF before reading in specified number of bytes."; return false; } return true; @@ -374,7 +376,7 @@ bool GlAnimationOverlayCalculator::LoadAnimationAndroid( Singleton::get(); AAssetManager *asset_manager = mediapipe_asset_manager->GetAssetManager(); if (!asset_manager) { - LOG(ERROR) << "Failed to access Android asset manager."; + ABSL_LOG(ERROR) << "Failed to access Android asset manager."; return false; } @@ -382,7 +384,7 @@ bool GlAnimationOverlayCalculator::LoadAnimationAndroid( AAsset *asset = AAssetManager_open(asset_manager, filename.c_str(), AASSET_MODE_STREAMING); if (!asset) { - LOG(ERROR) << "Failed to open animation asset: " << filename; + ABSL_LOG(ERROR) << "Failed to open animation asset: " << filename; return false; } @@ -400,14 +402,14 @@ bool GlAnimationOverlayCalculator::LoadAnimationAndroid( triangle_mesh.vertices.reset(new float[lengths[0]]); if (!ReadBytesFromAsset(asset, (void *)triangle_mesh.vertices.get(), sizeof(float) * lengths[0])) { - LOG(ERROR) << "Failed to read vertices for frame " << frame_count_; + ABSL_LOG(ERROR) << "Failed to read vertices for frame " << frame_count_; return false; } // Try to read in texture coordinates (4-byte floats) triangle_mesh.texture_coords.reset(new float[lengths[1]]); if (!ReadBytesFromAsset(asset, (void *)triangle_mesh.texture_coords.get(), sizeof(float) * lengths[1])) { - LOG(ERROR) << "Failed to read tex-coords for frame " << frame_count_; + ABSL_LOG(ERROR) << "Failed to read tex-coords for frame " << frame_count_; return false; } // Try to read in indices (2-byte shorts) @@ -415,7 +417,7 @@ bool GlAnimationOverlayCalculator::LoadAnimationAndroid( triangle_mesh.triangle_indices.reset(new int16[lengths[2]]); if (!ReadBytesFromAsset(asset, (void *)triangle_mesh.triangle_indices.get(), sizeof(int16) * lengths[2])) { - LOG(ERROR) << "Failed to read indices for frame " << frame_count_; + ABSL_LOG(ERROR) << "Failed to read indices for frame " << frame_count_; return false; } @@ -426,9 +428,10 @@ bool GlAnimationOverlayCalculator::LoadAnimationAndroid( } AAsset_close(asset); - LOG(INFO) << "Finished parsing " << frame_count_ << " animation frames."; + ABSL_LOG(INFO) << "Finished parsing " << frame_count_ << " animation frames."; if (meshes->empty()) { - LOG(ERROR) << "No animation frames were parsed! Erroring out calculator."; + ABSL_LOG(ERROR) + << "No animation frames were parsed! Erroring out calculator."; return false; } return true; @@ -439,7 +442,7 @@ bool GlAnimationOverlayCalculator::LoadAnimationAndroid( bool GlAnimationOverlayCalculator::LoadAnimation(const std::string &filename) { std::ifstream infile(filename.c_str(), std::ifstream::binary); if (!infile) { - LOG(ERROR) << "Error opening asset with filename: " << filename; + ABSL_LOG(ERROR) << "Error opening asset with filename: " << filename; return false; } @@ -462,7 +465,7 @@ bool GlAnimationOverlayCalculator::LoadAnimation(const std::string &filename) { infile.read((char *)(triangle_mesh.vertices.get()), sizeof(float) * lengths[0]); if (!infile) { - LOG(ERROR) << "Failed to read vertices for frame " << frame_count_; + ABSL_LOG(ERROR) << "Failed to read vertices for frame " << frame_count_; return false; } @@ -471,8 +474,8 @@ bool GlAnimationOverlayCalculator::LoadAnimation(const std::string &filename) { infile.read((char *)(triangle_mesh.texture_coords.get()), sizeof(float) * lengths[1]); if (!infile) { - LOG(ERROR) << "Failed to read texture coordinates for frame " - << frame_count_; + ABSL_LOG(ERROR) << "Failed to read texture coordinates for frame " + << frame_count_; return false; } @@ -482,8 +485,8 @@ bool GlAnimationOverlayCalculator::LoadAnimation(const std::string &filename) { infile.read((char *)(triangle_mesh.triangle_indices.get()), sizeof(int16_t) * lengths[2]); if (!infile) { - LOG(ERROR) << "Failed to read triangle indices for frame " - << frame_count_; + ABSL_LOG(ERROR) << "Failed to read triangle indices for frame " + << frame_count_; return false; } @@ -493,9 +496,10 @@ bool GlAnimationOverlayCalculator::LoadAnimation(const std::string &filename) { frame_count_++; } - LOG(INFO) << "Finished parsing " << frame_count_ << " animation frames."; + ABSL_LOG(INFO) << "Finished parsing " << frame_count_ << " animation frames."; if (triangle_meshes_.empty()) { - LOG(ERROR) << "No animation frames were parsed! Erroring out calculator."; + ABSL_LOG(ERROR) + << "No animation frames were parsed! Erroring out calculator."; return false; } return true; @@ -560,7 +564,7 @@ absl::Status GlAnimationOverlayCalculator::Open(CalculatorContext *cc) { cc->InputSidePackets().Tag("MASK_ASSET").Get(); loaded_animation = LoadAnimationAndroid(mask_asset_name, &mask_meshes_); if (!loaded_animation) { - LOG(ERROR) << "Failed to load mask asset."; + ABSL_LOG(ERROR) << "Failed to load mask asset."; return absl::UnknownError("Failed to load mask asset."); } } @@ -569,7 +573,7 @@ absl::Status GlAnimationOverlayCalculator::Open(CalculatorContext *cc) { loaded_animation = LoadAnimation(asset_name); #endif if (!loaded_animation) { - LOG(ERROR) << "Failed to load animation asset."; + ABSL_LOG(ERROR) << "Failed to load animation asset."; return absl::UnknownError("Failed to load animation asset."); } @@ -669,8 +673,8 @@ absl::Status GlAnimationOverlayCalculator::Process(CalculatorContext *cc) { height = input_frame->height(); dst = helper_.CreateSourceTexture(*input_frame); } else { - LOG(ERROR) << "Unable to consume input video frame for overlay!"; - LOG(ERROR) << "Status returned was: " << result.status(); + ABSL_LOG(ERROR) << "Unable to consume input video frame for overlay!"; + ABSL_LOG(ERROR) << "Status returned was: " << result.status(); dst = helper_.CreateDestinationTexture(width, height); } } else if (!has_video_stream_) { @@ -699,7 +703,7 @@ absl::Status GlAnimationOverlayCalculator::Process(CalculatorContext *cc) { GL_RENDERBUFFER, renderbuffer_)); GLenum status = GLCHECK(glCheckFramebufferStatus(GL_FRAMEBUFFER)); if (status != GL_FRAMEBUFFER_COMPLETE) { - LOG(ERROR) << "Incomplete framebuffer with status: " << status; + ABSL_LOG(ERROR) << "Incomplete framebuffer with status: " << status; } GLCHECK(glClear(GL_DEPTH_BUFFER_BIT)); diff --git a/mediapipe/java/com/google/mediapipe/framework/jni/BUILD b/mediapipe/java/com/google/mediapipe/framework/jni/BUILD index 778790b1c..c675c64af 100644 --- a/mediapipe/java/com/google/mediapipe/framework/jni/BUILD +++ b/mediapipe/java/com/google/mediapipe/framework/jni/BUILD @@ -95,13 +95,13 @@ cc_library( "//mediapipe/framework/formats:time_series_header_cc_proto", "//mediapipe/framework/formats:video_stream_header", "//mediapipe/framework/port:core_proto", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:singleton", "//mediapipe/framework/port:status", "//mediapipe/framework/port:threadpool", "//mediapipe/framework/stream_handler:fixed_size_input_stream_handler", "//mediapipe/framework/tool:executor_util", "//mediapipe/framework/tool:name_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/synchronization", @@ -138,8 +138,8 @@ cc_library( hdrs = ["jni_util.h"], deps = [ ":class_registry", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/synchronization", ] + select({ "//conditions:default": [ @@ -173,8 +173,8 @@ cc_library( ":class_registry", ":loose_headers", ":mediapipe_framework_jni", - "//mediapipe/framework/port:logging", "@com_google_absl//absl/container:node_hash_map", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", ] + select({ diff --git a/mediapipe/java/com/google/mediapipe/framework/jni/android_packet_creator_jni.cc b/mediapipe/java/com/google/mediapipe/framework/jni/android_packet_creator_jni.cc index cda84ac16..a40112b2a 100644 --- a/mediapipe/java/com/google/mediapipe/framework/jni/android_packet_creator_jni.cc +++ b/mediapipe/java/com/google/mediapipe/framework/jni/android_packet_creator_jni.cc @@ -19,11 +19,11 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/framework/formats/image.h" #include "mediapipe/framework/formats/image_format.pb.h" #include "mediapipe/framework/formats/image_frame.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/java/com/google/mediapipe/framework/jni/colorspace.h" #include "mediapipe/java/com/google/mediapipe/framework/jni/graph.h" @@ -49,26 +49,26 @@ std::unique_ptr CreateImageFrameFromBitmap( void* pixel_addr = nullptr; int result = AndroidBitmap_lockPixels(env, bitmap, &pixel_addr); if (result != ANDROID_BITMAP_RESULT_SUCCESS) { - LOG(ERROR) << "AndroidBitmap_lockPixels() failed with result code " - << result; + ABSL_LOG(ERROR) << "AndroidBitmap_lockPixels() failed with result code " + << result; return nullptr; } if (format == mediapipe::ImageFormat::SRGBA) { const int64_t buffer_size = stride * height; if (buffer_size != image_frame->PixelDataSize()) { - LOG(ERROR) << "Bitmap stride: " << stride - << " times bitmap height: " << height - << " is not equal to the expected size: " - << image_frame->PixelDataSize(); + ABSL_LOG(ERROR) << "Bitmap stride: " << stride + << " times bitmap height: " << height + << " is not equal to the expected size: " + << image_frame->PixelDataSize(); return nullptr; } std::memcpy(image_frame->MutablePixelData(), pixel_addr, image_frame->PixelDataSize()); } else if (format == mediapipe::ImageFormat::SRGB) { if (stride != width * 4) { - LOG(ERROR) << "Bitmap stride: " << stride - << "is not equal to 4 times bitmap width: " << width; + ABSL_LOG(ERROR) << "Bitmap stride: " << stride + << "is not equal to 4 times bitmap width: " << width; return nullptr; } const uint8_t* rgba_data = static_cast(pixel_addr); @@ -76,14 +76,14 @@ std::unique_ptr CreateImageFrameFromBitmap( image_frame->MutablePixelData(), image_frame->WidthStep()); } else { - LOG(ERROR) << "unsupported image format: " << format; + ABSL_LOG(ERROR) << "unsupported image format: " << format; return nullptr; } result = AndroidBitmap_unlockPixels(env, bitmap); if (result != ANDROID_BITMAP_RESULT_SUCCESS) { - LOG(ERROR) << "AndroidBitmap_unlockPixels() failed with result code " - << result; + ABSL_LOG(ERROR) << "AndroidBitmap_unlockPixels() failed with result code " + << result; return nullptr; } @@ -98,7 +98,8 @@ JNIEXPORT jlong JNICALL ANDROID_PACKET_CREATOR_METHOD( AndroidBitmapInfo info; int result = AndroidBitmap_getInfo(env, bitmap, &info); if (result != ANDROID_BITMAP_RESULT_SUCCESS) { - LOG(ERROR) << "AndroidBitmap_getInfo() failed with result code " << result; + ABSL_LOG(ERROR) << "AndroidBitmap_getInfo() failed with result code " + << result; return 0L; } @@ -117,7 +118,8 @@ JNIEXPORT jlong JNICALL ANDROID_PACKET_CREATOR_METHOD( AndroidBitmapInfo info; int result = AndroidBitmap_getInfo(env, bitmap, &info); if (result != ANDROID_BITMAP_RESULT_SUCCESS) { - LOG(ERROR) << "AndroidBitmap_getInfo() failed with result code " << result; + ABSL_LOG(ERROR) << "AndroidBitmap_getInfo() failed with result code " + << result; return 0L; } @@ -135,7 +137,8 @@ JNIEXPORT jlong JNICALL ANDROID_PACKET_CREATOR_METHOD(nativeCreateRgbaImage)( AndroidBitmapInfo info; int result = AndroidBitmap_getInfo(env, bitmap, &info); if (result != ANDROID_BITMAP_RESULT_SUCCESS) { - LOG(ERROR) << "AndroidBitmap_getInfo() failed with result code " << result; + ABSL_LOG(ERROR) << "AndroidBitmap_getInfo() failed with result code " + << result; return 0L; } diff --git a/mediapipe/java/com/google/mediapipe/framework/jni/graph.cc b/mediapipe/java/com/google/mediapipe/framework/jni/graph.cc index d565187d9..f129b1a7c 100644 --- a/mediapipe/java/com/google/mediapipe/framework/jni/graph.cc +++ b/mediapipe/java/com/google/mediapipe/framework/jni/graph.cc @@ -18,6 +18,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/synchronization/mutex.h" @@ -75,7 +76,7 @@ class CallbackHandler { // The jobject global reference is managed by the Graph directly. // So no-op here. if (java_callback_) { - LOG(ERROR) << "Java callback global reference is not released."; + ABSL_LOG(ERROR) << "Java callback global reference is not released."; } } @@ -135,7 +136,8 @@ Graph::~Graph() { // Cleans up the jni objects. JNIEnv* env = mediapipe::java::GetJNIEnv(); if (env == nullptr) { - LOG(ERROR) << "Can't attach to java thread, no jni clean up performed."; + ABSL_LOG(ERROR) + << "Can't attach to java thread, no jni clean up performed."; return; } for (const auto& handler : callback_handlers_) { @@ -219,12 +221,12 @@ absl::Status Graph::AddMultiStreamCallbackHandler( int64_t Graph::AddSurfaceOutput(const std::string& output_stream_name) { if (!graph_config()) { - LOG(ERROR) << "Graph is not loaded!"; + ABSL_LOG(ERROR) << "Graph is not loaded!"; return 0; } #if MEDIAPIPE_DISABLE_GPU - LOG(FATAL) << "GPU support has been disabled in this build!"; + ABSL_LOG(FATAL) << "GPU support has been disabled in this build!"; #else CalculatorGraphConfig::Node* sink_node = graph_config()->add_node(); sink_node->set_name(mediapipe::tool::GetUnusedNodeName( @@ -291,7 +293,7 @@ CalculatorGraphConfig Graph::GetCalculatorGraphConfig() { CalculatorGraph temp_graph; absl::Status status = InitializeGraph(&temp_graph); if (!status.ok()) { - LOG(ERROR) << "GetCalculatorGraphConfig failed:\n" << status.message(); + ABSL_LOG(ERROR) << "GetCalculatorGraphConfig failed:\n" << status.message(); } return temp_graph.Config(); } @@ -416,13 +418,13 @@ absl::Status Graph::RunGraphUntilClose(JNIEnv* env) { CalculatorGraph calculator_graph; absl::Status status = InitializeGraph(&calculator_graph); if (!status.ok()) { - LOG(ERROR) << status.message(); + ABSL_LOG(ERROR) << status.message(); running_graph_.reset(nullptr); return status; } // TODO: gpu & services set up! status = calculator_graph.Run(CreateCombinedSidePackets()); - LOG(INFO) << "Graph run finished."; + ABSL_LOG(INFO) << "Graph run finished."; return status; } @@ -440,9 +442,9 @@ absl::Status Graph::StartRunningGraph(JNIEnv* env) { // Set the mode for adding packets to graph input streams. running_graph_->SetGraphInputStreamAddMode(graph_input_stream_add_mode_); if (VLOG_IS_ON(2)) { - LOG(INFO) << "input packet streams:"; + ABSL_LOG(INFO) << "input packet streams:"; for (auto& name : graph_config()->input_stream()) { - LOG(INFO) << name; + ABSL_LOG(INFO) << name; } } absl::Status status; @@ -450,7 +452,7 @@ absl::Status Graph::StartRunningGraph(JNIEnv* env) { if (gpu_resources_) { status = running_graph_->SetGpuResources(gpu_resources_); if (!status.ok()) { - LOG(ERROR) << status.message(); + ABSL_LOG(ERROR) << status.message(); running_graph_.reset(nullptr); return status; } @@ -461,7 +463,7 @@ absl::Status Graph::StartRunningGraph(JNIEnv* env) { status = running_graph_->SetServicePacket(*service_packet.first, service_packet.second); if (!status.ok()) { - LOG(ERROR) << status.message(); + ABSL_LOG(ERROR) << status.message(); running_graph_.reset(nullptr); return status; } @@ -469,15 +471,15 @@ absl::Status Graph::StartRunningGraph(JNIEnv* env) { status = InitializeGraph(running_graph_.get()); if (!status.ok()) { - LOG(ERROR) << status.message(); + ABSL_LOG(ERROR) << status.message(); running_graph_.reset(nullptr); return status; } - LOG(INFO) << "Start running the graph, waiting for inputs."; + ABSL_LOG(INFO) << "Start running the graph, waiting for inputs."; status = running_graph_->StartRun(CreateCombinedSidePackets(), stream_headers_); if (!status.ok()) { - LOG(ERROR) << status; + ABSL_LOG(ERROR) << status; running_graph_.reset(nullptr); return status; } @@ -520,12 +522,12 @@ absl::Status Graph::CloseInputStream(std::string stream_name) { if (!running_graph_) { return absl::FailedPreconditionError("Graph must be running."); } - LOG(INFO) << "Close input stream: " << stream_name; + ABSL_LOG(INFO) << "Close input stream: " << stream_name; return running_graph_->CloseInputStream(stream_name); } absl::Status Graph::CloseAllInputStreams() { - LOG(INFO) << "Close all input streams."; + ABSL_LOG(INFO) << "Close all input streams."; if (!running_graph_) { return absl::FailedPreconditionError("Graph must be running."); } @@ -533,7 +535,7 @@ absl::Status Graph::CloseAllInputStreams() { } absl::Status Graph::CloseAllPacketSources() { - LOG(INFO) << "Close all input streams."; + ABSL_LOG(INFO) << "Close all input streams."; if (!running_graph_) { return absl::FailedPreconditionError("Graph must be running."); } @@ -564,7 +566,7 @@ void Graph::SetInputSidePacket(const std::string& stream_name, void Graph::SetStreamHeader(const std::string& stream_name, const Packet& packet) { stream_headers_[stream_name] = packet; - LOG(INFO) << stream_name << " stream header being set."; + ABSL_LOG(INFO) << stream_name << " stream header being set."; } void Graph::SetGraphInputStreamAddMode( @@ -580,7 +582,7 @@ mediapipe::GpuResources* Graph::GetGpuResources() const { absl::Status Graph::SetParentGlContext(int64_t java_gl_context) { #if MEDIAPIPE_DISABLE_GPU - LOG(FATAL) << "GPU support has been disabled in this build!"; + ABSL_LOG(FATAL) << "GPU support has been disabled in this build!"; #else if (gpu_resources_) { return absl::AlreadyExistsError( diff --git a/mediapipe/java/com/google/mediapipe/framework/jni/graph_texture_frame_jni.cc b/mediapipe/java/com/google/mediapipe/framework/jni/graph_texture_frame_jni.cc index b3bcd14dd..a658d01cc 100644 --- a/mediapipe/java/com/google/mediapipe/framework/jni/graph_texture_frame_jni.cc +++ b/mediapipe/java/com/google/mediapipe/framework/jni/graph_texture_frame_jni.cc @@ -14,6 +14,7 @@ #include "mediapipe/java/com/google/mediapipe/framework/jni/graph_texture_frame_jni.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "mediapipe/gpu/gl_calculator_helper.h" #include "mediapipe/gpu/gl_context.h" @@ -101,8 +102,8 @@ JNIEXPORT void JNICALL GRAPH_TEXTURE_FRAME_METHOD(nativeDidRead)( // However, `DidRead` may succeed resulting in a later crash and masking the // actual problem.) if (token.use_count() == 0) { - LOG_FIRST_N(ERROR, 5) << absl::StrFormat("invalid sync token ref: %d", - consumerSyncToken); + ABSL_LOG_FIRST_N(ERROR, 5) + << absl::StrFormat("invalid sync token ref: %d", consumerSyncToken); return; } (*buffer)->DidRead(token); diff --git a/mediapipe/java/com/google/mediapipe/framework/jni/jni_util.cc b/mediapipe/java/com/google/mediapipe/framework/jni/jni_util.cc index 88a1366b9..6ccf8d7e9 100644 --- a/mediapipe/java/com/google/mediapipe/framework/jni/jni_util.cc +++ b/mediapipe/java/com/google/mediapipe/framework/jni/jni_util.cc @@ -16,8 +16,8 @@ #include +#include "absl/log/absl_log.h" #include "absl/synchronization/mutex.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/java/com/google/mediapipe/framework/jni/class_registry.h" namespace { @@ -38,7 +38,7 @@ class JvmThread { case JNI_OK: break; case JNI_EDETACHED: - LOG(INFO) << "GetEnv: not attached"; + ABSL_LOG(INFO) << "GetEnv: not attached"; if (jvm_->AttachCurrentThread( #ifdef __ANDROID__ &jni_env_, @@ -46,16 +46,16 @@ class JvmThread { reinterpret_cast(&jni_env_), #endif // __ANDROID__ nullptr) != 0) { - LOG(ERROR) << "Failed to attach to java thread."; + ABSL_LOG(ERROR) << "Failed to attach to java thread."; break; } attached_ = true; break; case JNI_EVERSION: - LOG(ERROR) << "GetEnv: jni version not supported."; + ABSL_LOG(ERROR) << "GetEnv: jni version not supported."; break; default: - LOG(ERROR) << "GetEnv: unknown status."; + ABSL_LOG(ERROR) << "GetEnv: unknown status."; break; } } @@ -83,7 +83,7 @@ static pthread_once_t key_once = PTHREAD_ONCE_INIT; static void ThreadExitCallback(void* key_value) { JvmThread* jvm_thread = reinterpret_cast(key_value); // Detach the thread when thread exits. - LOG(INFO) << "Exiting thread. Detach thread."; + ABSL_LOG(INFO) << "Exiting thread. Detach thread."; delete jvm_thread; } @@ -187,7 +187,7 @@ bool SetJavaVM(JNIEnv* env) { absl::MutexLock lock(&g_jvm_mutex); if (!g_jvm) { if (env->GetJavaVM(&g_jvm) != JNI_OK) { - LOG(ERROR) << "Can not get the Java VM instance!"; + ABSL_LOG(ERROR) << "Can not get the Java VM instance!"; g_jvm = nullptr; return false; } diff --git a/mediapipe/java/com/google/mediapipe/framework/jni/register_natives.cc b/mediapipe/java/com/google/mediapipe/framework/jni/register_natives.cc index bef275b40..3f96a404d 100644 --- a/mediapipe/java/com/google/mediapipe/framework/jni/register_natives.cc +++ b/mediapipe/java/com/google/mediapipe/framework/jni/register_natives.cc @@ -14,8 +14,8 @@ #include "mediapipe/java/com/google/mediapipe/framework/jni/register_natives.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/java/com/google/mediapipe/framework/jni/class_registry.h" #if defined(__ANDROID__) @@ -65,9 +65,10 @@ void RegisterNativesVector(JNIEnv *env, jclass cls, // in exchange for flexibility to list out all registrations without worrying // about usage subset by client Java projects. if (!cls || methods.empty()) { - LOG(INFO) << "Skipping registration and clearing exception. Class or " - "native methods not found, may be unused and/or trimmed by " - "Proguard."; + ABSL_LOG(INFO) + << "Skipping registration and clearing exception. Class or " + "native methods not found, may be unused and/or trimmed by " + "Proguard."; env->ExceptionClear(); return; } @@ -81,7 +82,7 @@ void RegisterNativesVector(JNIEnv *env, jclass cls, } // Fatal crash if registration fails. if (env->RegisterNatives(cls, methods_array, methods.size()) < 0) { - LOG(FATAL) + ABSL_LOG(FATAL) << "Failed during native method registration, so likely the " "signature of a method is incorrect. Make sure there are no typos " "and " diff --git a/mediapipe/java/com/google/mediapipe/framework/jni/surface_output_jni.cc b/mediapipe/java/com/google/mediapipe/framework/jni/surface_output_jni.cc index 51d693b20..5d9a087ee 100644 --- a/mediapipe/java/com/google/mediapipe/framework/jni/surface_output_jni.cc +++ b/mediapipe/java/com/google/mediapipe/framework/jni/surface_output_jni.cc @@ -17,6 +17,7 @@ #include #endif // __ANDROID__ +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/gpu/egl_surface_holder.h" @@ -99,7 +100,7 @@ JNIEXPORT void JNICALL MEDIAPIPE_SURFACE_OUTPUT_METHOD(nativeSetSurface)( ANativeWindow_release(window); } #else - LOG(FATAL) << "setSurface is only supported on Android"; + ABSL_LOG(FATAL) << "setSurface is only supported on Android"; #endif // __ANDROID__ } diff --git a/mediapipe/modules/objectron/calculators/BUILD b/mediapipe/modules/objectron/calculators/BUILD index 2e33ebf6c..e2b0a5ccf 100644 --- a/mediapipe/modules/objectron/calculators/BUILD +++ b/mediapipe/modules/objectron/calculators/BUILD @@ -146,10 +146,10 @@ cc_library( ":annotation_cc_proto", ":box_util", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/util/tracking:box_tracker_cc_proto", "@com_google_absl//absl/container:btree", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log:absl_log", ], ) @@ -182,10 +182,10 @@ cc_library( ":belief_decoder_config_cc_proto", ":box", ":epnp", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@eigen_archive//:eigen3", ], @@ -277,6 +277,7 @@ cc_library( "//mediapipe/framework/deps:file_path", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:ret_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/types:span", @@ -322,6 +323,7 @@ cc_library( "//mediapipe/framework/deps:file_path", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:ret_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/types:span", @@ -369,11 +371,11 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework/formats:detection_cc_proto", "//mediapipe/framework/formats:location_data_cc_proto", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:map_util", "//mediapipe/framework/port:re2", "//mediapipe/framework/port:status", "@com_google_absl//absl/container:node_hash_set", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], alwayslink = 1, diff --git a/mediapipe/modules/objectron/calculators/decoder.cc b/mediapipe/modules/objectron/calculators/decoder.cc index 0af34585b..82aeee599 100644 --- a/mediapipe/modules/objectron/calculators/decoder.cc +++ b/mediapipe/modules/objectron/calculators/decoder.cc @@ -19,9 +19,9 @@ #include "Eigen/Core" #include "Eigen/Dense" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "mediapipe/framework/port/canonical_errors.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/modules/objectron/calculators/annotation_data.pb.h" @@ -220,7 +220,7 @@ absl::Status Decoder::Lift2DTo3D( auto status = SolveEpnp(projection_matrix, portrait, input_points_2d, &output_points_3d); if (!status.ok()) { - LOG(ERROR) << status; + ABSL_LOG(ERROR) << status; return status; } diff --git a/mediapipe/modules/objectron/calculators/filter_detection_calculator.cc b/mediapipe/modules/objectron/calculators/filter_detection_calculator.cc index 29f4c79d2..3ac91c7c8 100644 --- a/mediapipe/modules/objectron/calculators/filter_detection_calculator.cc +++ b/mediapipe/modules/objectron/calculators/filter_detection_calculator.cc @@ -17,13 +17,13 @@ #include #include "absl/container/node_hash_set.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/detection.pb.h" #include "mediapipe/framework/formats/location_data.pb.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/map_util.h" #include "mediapipe/framework/port/re2.h" #include "mediapipe/framework/port/status.h" @@ -264,11 +264,11 @@ bool FilterDetectionCalculator::IsValidLabel(const std::string& label) { bool FilterDetectionCalculator::IsValidScore(float score) { if (options_.has_min_score() && score < options_.min_score()) { - LOG(ERROR) << "Filter out detection with low score " << score; + ABSL_LOG(ERROR) << "Filter out detection with low score " << score; return false; } if (options_.has_max_score() && score > options_.max_score()) { - LOG(ERROR) << "Filter out detection with high score " << score; + ABSL_LOG(ERROR) << "Filter out detection with high score " << score; return false; } return true; diff --git a/mediapipe/modules/objectron/calculators/frame_annotation_tracker.cc b/mediapipe/modules/objectron/calculators/frame_annotation_tracker.cc index 1685a4f68..39fe1f936 100644 --- a/mediapipe/modules/objectron/calculators/frame_annotation_tracker.cc +++ b/mediapipe/modules/objectron/calculators/frame_annotation_tracker.cc @@ -15,7 +15,7 @@ #include "mediapipe/modules/objectron/calculators/frame_annotation_tracker.h" #include "absl/container/flat_hash_set.h" -#include "mediapipe/framework/port/logging.h" +#include "absl/log/absl_log.h" #include "mediapipe/modules/objectron/calculators/annotation_data.pb.h" #include "mediapipe/modules/objectron/calculators/box_util.h" #include "mediapipe/util/tracking/box_tracker.pb.h" @@ -53,8 +53,8 @@ FrameAnnotation FrameAnnotationTracker::ConsolidateTrackingResult( } } if (!ref_box.has_id() || ref_box.id() < 0) { - LOG(ERROR) << "Can't find matching tracked box for object id: " - << object_id << ". Likely lost tracking of it."; + ABSL_LOG(ERROR) << "Can't find matching tracked box for object id: " + << object_id << ". Likely lost tracking of it."; keys_to_be_deleted.push_back(detected_obj.first); continue; } diff --git a/mediapipe/modules/objectron/calculators/lift_2d_frame_annotation_to_3d_calculator.cc b/mediapipe/modules/objectron/calculators/lift_2d_frame_annotation_to_3d_calculator.cc index 5e5df78b9..652c51030 100644 --- a/mediapipe/modules/objectron/calculators/lift_2d_frame_annotation_to_3d_calculator.cc +++ b/mediapipe/modules/objectron/calculators/lift_2d_frame_annotation_to_3d_calculator.cc @@ -17,6 +17,7 @@ #include #include "Eigen/Dense" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" @@ -137,7 +138,7 @@ absl::Status Lift2DFrameAnnotationTo3DCalculator::ProcessCPU( auto status = decoder_->Lift2DTo3D(projection_matrix_, /*portrait*/ false, output_objects); if (!status.ok()) { - LOG(ERROR) << status; + ABSL_LOG(ERROR) << status; return status; } AssignObjectIdAndTimestamp(cc->InputTimestamp().Microseconds(), diff --git a/mediapipe/modules/objectron/calculators/tensors_to_objects_calculator.cc b/mediapipe/modules/objectron/calculators/tensors_to_objects_calculator.cc index 6989c34ce..c1092c725 100644 --- a/mediapipe/modules/objectron/calculators/tensors_to_objects_calculator.cc +++ b/mediapipe/modules/objectron/calculators/tensors_to_objects_calculator.cc @@ -17,6 +17,7 @@ #include #include "Eigen/Dense" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" @@ -148,7 +149,7 @@ absl::Status TensorsToObjectsCalculator::ProcessCPU( auto status = decoder_->Lift2DTo3D(projection_matrix_, /*portrait*/ true, output_objects); if (!status.ok()) { - LOG(ERROR) << status; + ABSL_LOG(ERROR) << status; return status; } Project3DTo2D(/*portrait*/ true, output_objects); diff --git a/mediapipe/modules/objectron/calculators/tflite_tensors_to_objects_calculator.cc b/mediapipe/modules/objectron/calculators/tflite_tensors_to_objects_calculator.cc index d74b59a25..ebecfc093 100644 --- a/mediapipe/modules/objectron/calculators/tflite_tensors_to_objects_calculator.cc +++ b/mediapipe/modules/objectron/calculators/tflite_tensors_to_objects_calculator.cc @@ -17,6 +17,7 @@ #include #include "Eigen/Dense" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" @@ -154,7 +155,7 @@ absl::Status TfLiteTensorsToObjectsCalculator::ProcessCPU( auto status = decoder_->Lift2DTo3D(projection_matrix_, /*portrait*/ true, output_objects); if (!status.ok()) { - LOG(ERROR) << status; + ABSL_LOG(ERROR) << status; return status; } Project3DTo2D(/*portrait*/ true, output_objects); diff --git a/mediapipe/objc/BUILD b/mediapipe/objc/BUILD index 83567a4d8..81982cdd4 100644 --- a/mediapipe/objc/BUILD +++ b/mediapipe/objc/BUILD @@ -39,6 +39,7 @@ cc_library( "//mediapipe/framework/port:source_location", "//mediapipe/framework/port:status", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", ], ) diff --git a/mediapipe/objc/util.cc b/mediapipe/objc/util.cc index 36ad4e195..8cefab974 100644 --- a/mediapipe/objc/util.cc +++ b/mediapipe/objc/util.cc @@ -15,6 +15,7 @@ #include "mediapipe/objc/util.h" #include "absl/base/macros.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" @@ -504,7 +505,7 @@ absl::Status CreateCGImageFromCVPixelBuffer(CVPixelBufferRef image_buffer, break; default: - LOG(FATAL) << "Unsupported pixelFormat " << pixel_format; + ABSL_LOG(FATAL) << "Unsupported pixelFormat " << pixel_format; break; } @@ -623,7 +624,7 @@ std::unique_ptr CreateImageFrameForCVPixelBuffer( static_cast(pixel_format >> 16 & 0xFF), static_cast(pixel_format >> 8 & 0xFF), static_cast(pixel_format & 0xFF), 0}; - LOG(FATAL) << "unsupported pixel format: " << format_str; + ABSL_LOG(FATAL) << "unsupported pixel format: " << format_str; } break; } diff --git a/mediapipe/tasks/cc/components/processors/BUILD b/mediapipe/tasks/cc/components/processors/BUILD index e8f9f57ff..dc5aca48a 100644 --- a/mediapipe/tasks/cc/components/processors/BUILD +++ b/mediapipe/tasks/cc/components/processors/BUILD @@ -199,6 +199,7 @@ cc_library( "//mediapipe/util:label_map_cc_proto", "//mediapipe/util:label_map_util", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", diff --git a/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph.cc b/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph.cc index d7fc1892c..813a23aeb 100644 --- a/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph.cc +++ b/mediapipe/tasks/cc/components/processors/detection_postprocessing_graph.cc @@ -20,6 +20,7 @@ limitations under the License. #include #include "absl/container/flat_hash_set.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_format.h" @@ -336,7 +337,7 @@ absl::StatusOr> GetOutputTensorIndices( int output_index = output_indices[i]; // If tensor name is not found, set the default output indices. if (output_index == -1) { - LOG(WARNING) << absl::StrFormat( + ABSL_LOG(WARNING) << absl::StrFormat( "You don't seem to be matching tensor names in metadata list. The " "tensor name \"%s\" at index %d in the model metadata doesn't " "match " @@ -360,7 +361,7 @@ absl::StatusOr> GetOutputTensorIndices( int output_index = output_indices[i]; // If tensor name is not found, set the default output indices. if (output_index == -1) { - LOG(WARNING) << absl::StrFormat( + ABSL_LOG(WARNING) << absl::StrFormat( "You don't seem to be matching tensor names in metadata list. The " "tensor name \"%s\" at index %d in the model metadata doesn't " "match " diff --git a/mediapipe/tasks/cc/core/BUILD b/mediapipe/tasks/cc/core/BUILD index 84dcda260..ce9181d51 100644 --- a/mediapipe/tasks/cc/core/BUILD +++ b/mediapipe/tasks/cc/core/BUILD @@ -29,7 +29,7 @@ cc_library( "//mediapipe/tasks/cc/core/proto:acceleration_cc_proto", "//mediapipe/tasks/cc/core/proto:base_options_cc_proto", "//mediapipe/tasks/cc/core/proto:external_file_cc_proto", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@org_tensorflow//tensorflow/lite/core/api:op_resolver", "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", @@ -108,13 +108,13 @@ cc_library( "//mediapipe/framework:subgraph", "//mediapipe/framework/api2:builder", "//mediapipe/framework/api2:port", - "//mediapipe/framework/port:logging", "//mediapipe/tasks/cc:common", "//mediapipe/tasks/cc/core/proto:acceleration_cc_proto", "//mediapipe/tasks/cc/core/proto:base_options_cc_proto", "//mediapipe/tasks/cc/core/proto:external_file_cc_proto", "//mediapipe/tasks/cc/core/proto:inference_subgraph_cc_proto", "//mediapipe/tasks/cc/core/proto:model_resources_calculator_cc_proto", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", diff --git a/mediapipe/tasks/cc/core/base_options.cc b/mediapipe/tasks/cc/core/base_options.cc index 863338fe5..7f7db525c 100644 --- a/mediapipe/tasks/cc/core/base_options.cc +++ b/mediapipe/tasks/cc/core/base_options.cc @@ -19,7 +19,7 @@ limitations under the License. #include #include -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "mediapipe/calculators/tensor/inference_calculator.pb.h" #include "mediapipe/tasks/cc/core/proto/acceleration.pb.h" #include "mediapipe/tasks/cc/core/proto/base_options.pb.h" @@ -58,8 +58,8 @@ void SetDelegateOptionsOrDie(const BaseOptions* base_options, proto::BaseOptions& base_options_proto) { if (base_options->delegate_options.has_value()) { if (!std::holds_alternative(*base_options->delegate_options)) { - LOG(FATAL) << "Specified Delegate type does not match the provided " - "delegate options."; + ABSL_LOG(FATAL) << "Specified Delegate type does not match the provided " + "delegate options."; } else { std::visit( [&base_options_proto](const auto& delegate_options) { diff --git a/mediapipe/tasks/cc/core/model_task_graph.cc b/mediapipe/tasks/cc/core/model_task_graph.cc index 225fad418..a68d40ae0 100644 --- a/mediapipe/tasks/cc/core/model_task_graph.cc +++ b/mediapipe/tasks/cc/core/model_task_graph.cc @@ -21,6 +21,7 @@ limitations under the License. #include #include +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/ascii.h" @@ -30,7 +31,6 @@ limitations under the License. #include "mediapipe/framework/api2/builder.h" #include "mediapipe/framework/api2/port.h" #include "mediapipe/framework/calculator.pb.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/tasks/cc/common.h" #include "mediapipe/tasks/cc/core/model_asset_bundle_resources.h" #include "mediapipe/tasks/cc/core/model_resources.h" @@ -165,7 +165,7 @@ absl::StatusOr ModelTaskGraph::CreateModelResources( if (!model_resources_cache_service.IsAvailable()) { ASSIGN_OR_RETURN(auto local_model_resource, ModelResources::Create("", std::move(external_file))); - LOG(WARNING) + ABSL_LOG(WARNING) << "A local ModelResources object is created. Please consider using " "ModelResourcesCacheService to cache the created ModelResources " "object in the CalculatorGraph."; @@ -215,7 +215,7 @@ ModelTaskGraph::CreateModelAssetBundleResources( auto local_model_asset_bundle_resource, ModelAssetBundleResources::Create("", std::move(external_file))); if (!has_file_pointer_meta) { - LOG(WARNING) + ABSL_LOG(WARNING) << "A local ModelResources object is created. Please consider using " "ModelResourcesCacheService to cache the created ModelResources " "object in the CalculatorGraph."; diff --git a/mediapipe/tasks/cc/metadata/utils/BUILD b/mediapipe/tasks/cc/metadata/utils/BUILD index 881b88962..9e912c925 100644 --- a/mediapipe/tasks/cc/metadata/utils/BUILD +++ b/mediapipe/tasks/cc/metadata/utils/BUILD @@ -36,6 +36,7 @@ cc_library( "//mediapipe/tasks/cc/core/proto:external_file_cc_proto", "@com_google_absl//absl/cleanup", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@zlib//:zlib_minizip", diff --git a/mediapipe/tasks/cc/metadata/utils/zip_utils.cc b/mediapipe/tasks/cc/metadata/utils/zip_utils.cc index e0cc3d773..b9dd784c4 100644 --- a/mediapipe/tasks/cc/metadata/utils/zip_utils.cc +++ b/mediapipe/tasks/cc/metadata/utils/zip_utils.cc @@ -19,6 +19,7 @@ limitations under the License. #include "absl/cleanup/cleanup.h" #include "absl/container/flat_hash_map.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "contrib/minizip/ioapi.h" @@ -63,7 +64,7 @@ absl::StatusOr GetCurrentZipFileInfo(const unzFile& zf) { absl::Cleanup unzipper_closer = [zf]() { auto status = UnzipErrorToStatus(unzCloseCurrentFile(zf)); if (!status.ok()) { - LOG(ERROR) << "Failed to close the current zip file: " << status; + ABSL_LOG(ERROR) << "Failed to close the current zip file: " << status; } }; if (method != Z_NO_COMPRESSION) { @@ -125,7 +126,7 @@ absl::Status ExtractFilesfromZipFile( } absl::Cleanup unzipper_closer = [zf]() { if (unzClose(zf) != UNZ_OK) { - LOG(ERROR) << "Unable to close zip archive."; + ABSL_LOG(ERROR) << "Unable to close zip archive."; } }; // Get number of files. diff --git a/mediapipe/tasks/cc/vision/face_landmarker/BUILD b/mediapipe/tasks/cc/vision/face_landmarker/BUILD index 36c4bf551..04e33c141 100644 --- a/mediapipe/tasks/cc/vision/face_landmarker/BUILD +++ b/mediapipe/tasks/cc/vision/face_landmarker/BUILD @@ -213,6 +213,7 @@ cc_library( "//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarker_graph_options_cc_proto", "//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarks_detector_graph_options_cc_proto", "//mediapipe/util:graph_builder_utils", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", ], alwayslink = 1, 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 643f40624..54092b73c 100644 --- a/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker_graph.cc +++ b/mediapipe/tasks/cc/vision/face_landmarker/face_landmarker_graph.cc @@ -18,6 +18,7 @@ limitations under the License. #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "mediapipe/calculators/core/clip_vector_size_calculator.pb.h" #include "mediapipe/calculators/core/concatenate_vector_calculator.h" @@ -165,8 +166,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, ->mutable_base_options() ->mutable_acceleration() ->mutable_xnnpack(); - LOG(WARNING) << "Face blendshape model contains CPU only ops. Sets " - << "FaceBlendshapesGraph acceleration to Xnnpack."; + ABSL_LOG(WARNING) << "Face blendshape model contains CPU only ops. Sets " + << "FaceBlendshapesGraph acceleration to Xnnpack."; } return absl::OkStatus(); diff --git a/mediapipe/tasks/cc/vision/gesture_recognizer/BUILD b/mediapipe/tasks/cc/vision/gesture_recognizer/BUILD index fe925db57..11e484e9a 100644 --- a/mediapipe/tasks/cc/vision/gesture_recognizer/BUILD +++ b/mediapipe/tasks/cc/vision/gesture_recognizer/BUILD @@ -124,6 +124,7 @@ cc_library( "//mediapipe/tasks/cc/vision/gesture_recognizer/proto:hand_gesture_recognizer_graph_options_cc_proto", "//mediapipe/tasks/cc/vision/hand_landmarker:hand_landmarks_detector_graph", "//mediapipe/tasks/metadata:metadata_schema_cc", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", ], @@ -161,6 +162,7 @@ cc_library( "//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarker_graph_options_cc_proto", "//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarks_detector_graph_options_cc_proto", "//mediapipe/tasks/metadata:metadata_schema_cc", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", ], 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 0f4c88f5c..9550112bf 100644 --- a/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer_graph.cc +++ b/mediapipe/tasks/cc/vision/gesture_recognizer/gesture_recognizer_graph.cc @@ -17,6 +17,7 @@ limitations under the License. #include #include +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "mediapipe/framework/api2/builder.h" @@ -125,8 +126,8 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources, hand_gesture_recognizer_graph_options->mutable_base_options() ->mutable_acceleration() ->mutable_xnnpack(); - LOG(WARNING) << "Hand Gesture Recognizer contains CPU only ops. Sets " - << "HandGestureRecognizerGraph acceleration to Xnnpack."; + ABSL_LOG(WARNING) << "Hand Gesture Recognizer contains CPU only ops. Sets " + << "HandGestureRecognizerGraph acceleration to Xnnpack."; } hand_gesture_recognizer_graph_options->mutable_base_options() ->set_use_stream_mode(options->base_options().use_stream_mode()); 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 097318be6..fbe05b075 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 @@ -17,6 +17,7 @@ limitations under the License. #include #include +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "mediapipe/calculators/tensor/tensors_to_classification_calculator.pb.h" @@ -246,7 +247,7 @@ class SingleHandGestureRecognizerGraph : public core::ModelTaskGraph { options->base_options(), custom_gesture_classifier_graph_options->mutable_base_options()); } else { - LOG(INFO) << "Custom gesture classifier is not defined."; + ABSL_LOG(INFO) << "Custom gesture classifier is not defined."; } return absl::OkStatus(); } diff --git a/mediapipe/tasks/cc/vision/image_generator/diffuser/BUILD b/mediapipe/tasks/cc/vision/image_generator/diffuser/BUILD index e4fd9b5bc..1dc24200b 100644 --- a/mediapipe/tasks/cc/vision/image_generator/diffuser/BUILD +++ b/mediapipe/tasks/cc/vision/image_generator/diffuser/BUILD @@ -48,7 +48,7 @@ cc_library( "//mediapipe/framework/deps:file_helpers", "//mediapipe/framework/formats:image_frame", "//mediapipe/framework/formats:tensor", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", ], alwayslink = 1, @@ -61,7 +61,7 @@ cc_library( "//mediapipe/framework:calculator_framework", "//mediapipe/framework/api2:node", "//mediapipe/framework/formats:tensor", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", diff --git a/mediapipe/tasks/cc/vision/image_generator/diffuser/diffusion_plugins_output_calculator.cc b/mediapipe/tasks/cc/vision/image_generator/diffuser/diffusion_plugins_output_calculator.cc index 98fefe8c5..a52c9afb9 100644 --- a/mediapipe/tasks/cc/vision/image_generator/diffuser/diffusion_plugins_output_calculator.cc +++ b/mediapipe/tasks/cc/vision/image_generator/diffuser/diffusion_plugins_output_calculator.cc @@ -18,7 +18,6 @@ limitations under the License. #include #include "absl/log/check.h" -#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "mediapipe/framework/api2/node.h" diff --git a/mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iterate_calculator.cc b/mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iterate_calculator.cc index 2df731611..91c64450f 100644 --- a/mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iterate_calculator.cc +++ b/mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iterate_calculator.cc @@ -23,7 +23,7 @@ limitations under the License. #include #include -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "mediapipe/framework/api2/node.h" #include "mediapipe/framework/api2/port.h" diff --git a/mediapipe/tasks/cc/vision/image_segmenter/BUILD b/mediapipe/tasks/cc/vision/image_segmenter/BUILD index a430ae7b8..fa67d9af3 100644 --- a/mediapipe/tasks/cc/vision/image_segmenter/BUILD +++ b/mediapipe/tasks/cc/vision/image_segmenter/BUILD @@ -96,6 +96,7 @@ cc_library( "//mediapipe/util:graph_builder_utils", "//mediapipe/util:label_map_cc_proto", "//mediapipe/util:label_map_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings:str_format", 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 3c0861836..b1791fc0a 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 @@ -5,6 +5,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "mediapipe/framework/port/status_macros.h" @@ -367,19 +368,20 @@ absl::Status SegmentationPostprocessorGl::GlInit( // TODO: We could skip this entirely if no confidence masks // are being produced AND num_classes > 1, but num_classes is only // known at runtime, so this would take a little extra refactoring. - LOG(INFO) << "SIGMOID activation function chosen on GPU"; + ABSL_LOG(INFO) << "SIGMOID activation function chosen on GPU"; activation_fn = "vec4 out_value = 1.0 / (exp(-in_value) + 1.0);"; break; case SegmenterOptions::SOFTMAX: if (produce_confidence_masks) { - LOG(INFO) << "SOFTMAX activation function chosen on GPU"; + ABSL_LOG(INFO) << "SOFTMAX activation function chosen on GPU"; } else { - LOG(INFO) << "SOFTMAX activation function chosen on GPU, but only " - << "category mask produced, so not applying."; + ABSL_LOG(INFO) + << "SOFTMAX activation function chosen on GPU, but only " + << "category mask produced, so not applying."; } break; case SegmenterOptions::NONE: - LOG(INFO) << "NONE activation function chosen on GPU"; + ABSL_LOG(INFO) << "NONE activation function chosen on GPU"; break; } @@ -490,7 +492,7 @@ SegmentationPostprocessorGl::GetSegmentationResultGpu( int input_width, input_height; if (!tensor.ready_on_gpu()) { - LOG(WARNING) << "Tensor wasn't ready on GPU; using slow workaround."; + ABSL_LOG(WARNING) << "Tensor wasn't ready on GPU; using slow workaround."; (void)tensor.GetCpuReadView(); } @@ -507,7 +509,7 @@ SegmentationPostprocessorGl::GetSegmentationResultGpu( const auto layout = tensor.GetOpenGlTexture2dReadView().GetLayoutDimensions( tensor.shape(), &input_width, &input_height); if (layout != Tensor::OpenGlTexture2dView::Layout::kAligned) { - LOG(ERROR) << "Tensor layout not kAligned! Cannot handle."; + ABSL_LOG(ERROR) << "Tensor layout not kAligned! Cannot handle."; } #endif // TASK_SEGMENTATION_USE_GLES_31_POSTPROCESSING @@ -853,7 +855,7 @@ SegmentationPostprocessorGl::GetSegmentationResultGpu( }); if (!status.ok()) { - LOG(ERROR) << "Error with rendering: " << status; + ABSL_LOG(ERROR) << "Error with rendering: " << status; } return image_outputs; 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 e80da0123..b49f22ca0 100644 --- a/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter_graph.cc +++ b/mediapipe/tasks/cc/vision/image_segmenter/image_segmenter_graph.cc @@ -19,6 +19,7 @@ limitations under the License. #include #include +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_format.h" @@ -184,7 +185,7 @@ absl::Status ConfigureTensorsToSegmentationCalculator( } } if (!found_activation_in_metadata) { - LOG(WARNING) + ABSL_LOG(WARNING) << "No activation type is found in model metadata. Use NONE for " "ImageSegmenterGraph."; } diff --git a/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker_test.cc b/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker_test.cc index afc58b1dc..239851b5f 100644 --- a/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker_test.cc +++ b/mediapipe/tasks/cc/vision/pose_landmarker/pose_landmarker_test.cc @@ -21,6 +21,7 @@ limitations under the License. #include #include "absl/flags/flag.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" @@ -105,17 +106,17 @@ MATCHER_P2(LandmarksMatches, expected_landmarks, toleration, "") { for (int i = 0; i < arg.size(); i++) { for (int j = 0; j < arg[i].landmarks.size(); j++) { if (arg[i].landmarks.size() != expected_landmarks[i].landmarks.size()) { - LOG(INFO) << "sizes not equal"; + ABSL_LOG(INFO) << "sizes not equal"; return false; } if (std::abs(arg[i].landmarks[j].x - expected_landmarks[i].landmarks[j].x) > toleration || std::abs(arg[i].landmarks[j].y - expected_landmarks[i].landmarks[j].y) > toleration) { - LOG(INFO) << DUMP_VARS(arg[i].landmarks[j].x, - expected_landmarks[i].landmarks[j].x); - LOG(INFO) << DUMP_VARS(arg[i].landmarks[j].y, - expected_landmarks[i].landmarks[j].y); + ABSL_LOG(INFO) << DUMP_VARS(arg[i].landmarks[j].x, + expected_landmarks[i].landmarks[j].x); + ABSL_LOG(INFO) << DUMP_VARS(arg[i].landmarks[j].y, + expected_landmarks[i].landmarks[j].y); return false; } } @@ -316,7 +317,7 @@ TEST_P(VideoModeTest, Succeeds) { MP_ASSERT_OK_AND_ASSIGN(pose_landmarker_results, pose_landmarker->DetectForVideo(image, i)); } - LOG(INFO) << i; + ABSL_LOG(INFO) << i; ExpectPoseLandmarkerResultsCorrect( pose_landmarker_results, expected_results, kLandmarksOnVideoAbsMargin); } diff --git a/mediapipe/tasks/cc/vision/utils/BUILD b/mediapipe/tasks/cc/vision/utils/BUILD index 0eb5ba75c..22bcdec4c 100644 --- a/mediapipe/tasks/cc/vision/utils/BUILD +++ b/mediapipe/tasks/cc/vision/utils/BUILD @@ -28,12 +28,12 @@ cc_library_with_tflite( visibility = ["//visibility:public"], deps = [ "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:status", "//mediapipe/tasks/cc:common", "//mediapipe/tasks/cc/metadata:metadata_extractor", "//mediapipe/tasks/metadata:metadata_schema_cc", "@com_google_absl//absl/algorithm:container", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", diff --git a/mediapipe/tasks/cc/vision/utils/image_tensor_specs.cc b/mediapipe/tasks/cc/vision/utils/image_tensor_specs.cc index 7d48c6282..690cd6e5c 100644 --- a/mediapipe/tasks/cc/vision/utils/image_tensor_specs.cc +++ b/mediapipe/tasks/cc/vision/utils/image_tensor_specs.cc @@ -21,13 +21,13 @@ limitations under the License. #include #include "absl/algorithm/container.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/types/optional.h" #include "flatbuffers/flatbuffers.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/status_macros.h" #include "mediapipe/tasks/cc/common.h" #include "mediapipe/tasks/cc/metadata/metadata_extractor.h" @@ -245,8 +245,9 @@ absl::StatusOr BuildInputImageTensorSpecs( // TODO: Investigate if there is any better solutions support // running inference with multiple subgraphs. if (model.subgraphs()->size() != 1) { - LOG(WARNING) << "TFLite model has more than 1 subgraphs. Use subrgaph 0 as " - "the primary subgraph for inference"; + ABSL_LOG(WARNING) + << "TFLite model has more than 1 subgraphs. Use subrgaph 0 as " + "the primary subgraph for inference"; } const auto* primary_subgraph = (*model.subgraphs())[0]; if (primary_subgraph->inputs()->size() != 1) { diff --git a/mediapipe/util/BUILD b/mediapipe/util/BUILD index 9c655952a..e123d5641 100644 --- a/mediapipe/util/BUILD +++ b/mediapipe/util/BUILD @@ -69,6 +69,7 @@ cc_library( "//third_party:libffmpeg", "@com_google_absl//absl/base:endian", "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/time", "@eigen_archive//:eigen3", @@ -122,10 +123,10 @@ cc_library( "//mediapipe/framework/port", "//mediapipe/framework/port:aligned_malloc_and_free", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:status", "//mediapipe/framework/tool:status_util", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@libyuv", ], @@ -153,9 +154,9 @@ cc_library( visibility = ["//visibility:public"], deps = [ "//mediapipe/framework/formats:landmark_cc_proto", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgproc", + "@com_google_absl//absl/log:absl_log", ], ) @@ -171,6 +172,7 @@ cc_library( "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:vector", + "@com_google_absl//absl/log:absl_log", ], ) @@ -220,6 +222,7 @@ cc_library( "//mediapipe/framework/port:singleton", "//mediapipe/framework/port:status", "//mediapipe/framework/port:statusor", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", ] + select({ @@ -299,8 +302,8 @@ cc_library( "//mediapipe/framework/formats:matrix", "//mediapipe/framework/formats:time_series_header_cc_proto", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) @@ -321,6 +324,7 @@ cc_library( "//mediapipe/framework/port:logging", "//mediapipe/framework/port:parse_text_proto", "//mediapipe/framework/port:status", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@eigen_archive//:eigen3", ], @@ -405,7 +409,7 @@ cc_library( "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgcodecs", "//mediapipe/framework/port:opencv_imgproc", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", ], ) diff --git a/mediapipe/util/android/BUILD b/mediapipe/util/android/BUILD index 726732ed1..d104e123a 100644 --- a/mediapipe/util/android/BUILD +++ b/mediapipe/util/android/BUILD @@ -39,6 +39,8 @@ cc_library( "//mediapipe/framework/port:status", "//mediapipe/framework/port:statusor", "//mediapipe/util/android/file/base", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", ] + select({ "//conditions:default": [], diff --git a/mediapipe/util/android/asset_manager_util.cc b/mediapipe/util/android/asset_manager_util.cc index 8b5803d64..754f7fdfb 100644 --- a/mediapipe/util/android/asset_manager_util.cc +++ b/mediapipe/util/android/asset_manager_util.cc @@ -16,6 +16,8 @@ #include +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/java/com/google/mediapipe/framework/jni/jni_util.h" @@ -56,7 +58,7 @@ bool AssetManager::InitializeFromAssetManager( // Finally get the pointer to the AAssetManager using native code. asset_manager_ = AAssetManager_fromJava(env, global_asset_manager); if (asset_manager_) { - LOG(INFO) << "Created global reference to asset manager."; + ABSL_LOG(INFO) << "Created global reference to asset manager."; return true; } return false; @@ -97,7 +99,7 @@ bool AssetManager::InitializeFromActivity(JNIEnv* env, jobject activity, bool AssetManager::FileExists(const std::string& filename, bool* is_dir) { if (!asset_manager_) { - LOG(ERROR) << "Asset manager was not initialized from JNI"; + ABSL_LOG(ERROR) << "Asset manager was not initialized from JNI"; return false; } @@ -134,7 +136,7 @@ bool AssetManager::FileExists(const std::string& filename, bool* is_dir) { bool AssetManager::ReadFile(const std::string& filename, std::string* output) { CHECK(output); if (!asset_manager_) { - LOG(ERROR) << "Asset manager was not initialized from JNI"; + ABSL_LOG(ERROR) << "Asset manager was not initialized from JNI"; return false; } diff --git a/mediapipe/util/android/file/base/BUILD b/mediapipe/util/android/file/base/BUILD index f97bf2710..9d014b2aa 100644 --- a/mediapipe/util/android/file/base/BUILD +++ b/mediapipe/util/android/file/base/BUILD @@ -29,9 +29,9 @@ cc_library( visibility = ["//visibility:public"], deps = [ "//mediapipe/framework/port:file_helpers", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:status", "@com_google_absl//absl/base", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) diff --git a/mediapipe/util/android/file/base/file.cc b/mediapipe/util/android/file/base/file.cc index 83a34f15f..ff58f9c3a 100644 --- a/mediapipe/util/android/file/base/file.cc +++ b/mediapipe/util/android/file/base/file.cc @@ -19,11 +19,11 @@ #include #include "absl/base/call_once.h" +#include "absl/log/absl_log.h" #include "absl/strings/match.h" #include "absl/strings/str_replace.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h" -#include "mediapipe/framework/port/logging.h" #ifdef __APPLE__ static_assert(sizeof(off_t) == 8, "Large file support is required"); @@ -95,7 +95,7 @@ void LocalHostInit() { buf[sizeof(buf) - 1] = '\0'; localhost_name_str = new std::string(buf); } else { - LOG(ERROR) << "Could not get local host name"; + ABSL_LOG(ERROR) << "Could not get local host name"; localhost_name_str = new std::string("localhost"); } } diff --git a/mediapipe/util/annotation_renderer.cc b/mediapipe/util/annotation_renderer.cc index d8516f9bc..d6540c67e 100644 --- a/mediapipe/util/annotation_renderer.cc +++ b/mediapipe/util/annotation_renderer.cc @@ -19,6 +19,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/vector.h" #include "mediapipe/util/color.pb.h" @@ -116,7 +117,7 @@ void AnnotationRenderer::RenderDataOnImage(const RenderData& render_data) { } else if (annotation.data_case() == RenderAnnotation::kScribble) { DrawScribble(annotation); } else { - LOG(FATAL) << "Unknown annotation type: " << annotation.data_case(); + ABSL_LOG(FATAL) << "Unknown annotation type: " << annotation.data_case(); } } } diff --git a/mediapipe/util/audio_decoder.cc b/mediapipe/util/audio_decoder.cc index 569e8015a..51cd12a0e 100644 --- a/mediapipe/util/audio_decoder.cc +++ b/mediapipe/util/audio_decoder.cc @@ -22,6 +22,7 @@ #include "Eigen/Core" #include "absl/base/internal/endian.h" +#include "absl/log/absl_log.h" #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/substitute.h" @@ -196,7 +197,7 @@ absl::Status LogStatus(const absl::Status& status, << (packet.flags & AV_PKT_FLAG_KEY ? " Key Frame." : ""); if (always_return_ok_status) { - LOG(WARNING) << status.message(); + ABSL_LOG(WARNING) << status.message(); return absl::OkStatus(); } else { return status; @@ -450,17 +451,18 @@ absl::Status AudioPacketProcessor::ProcessDecodedFrame(const AVPacket& packet) { if (absl::Microseconds(std::abs(expected_us - actual_us)) > absl::Seconds( absl::GetFlag(FLAGS_media_decoder_allowed_audio_gap_merge))) { - LOG(ERROR) << "The expected time based on how many samples we have seen (" - << expected_us - << " microseconds) no longer matches the time based " - "on what the audio stream is telling us (" - << actual_us - << " microseconds). The difference is more than " - "--media_decoder_allowed_audio_gap_merge (" - << absl::FormatDuration(absl::Seconds(absl::GetFlag( - FLAGS_media_decoder_allowed_audio_gap_merge))) - << " microseconds). Resetting the timestamps to track what " - "the audio stream is telling us."; + ABSL_LOG(ERROR) + << "The expected time based on how many samples we have seen (" + << expected_us + << " microseconds) no longer matches the time based " + "on what the audio stream is telling us (" + << actual_us + << " microseconds). The difference is more than " + "--media_decoder_allowed_audio_gap_merge (" + << absl::FormatDuration(absl::Seconds( + absl::GetFlag(FLAGS_media_decoder_allowed_audio_gap_merge))) + << " microseconds). Resetting the timestamps to track what " + "the audio stream is telling us."; expected_sample_number_ = TimestampToSampleNumber(pts); } } @@ -560,14 +562,15 @@ absl::Status AudioPacketProcessor::AddAudioDataToBuffer( last_timestamp_ = output_timestamp; if (last_frame_time_regression_detected_) { last_frame_time_regression_detected_ = false; - LOG(INFO) << "Processor " << this << " resumed audio packet processing."; + ABSL_LOG(INFO) << "Processor " << this + << " resumed audio packet processing."; } } else if (!last_frame_time_regression_detected_) { last_frame_time_regression_detected_ = true; - LOG(ERROR) << "Processor " << this - << " is dropping an audio packet because the timestamps " - "regressed. Was " - << last_timestamp_ << " but got " << output_timestamp; + ABSL_LOG(ERROR) << "Processor " << this + << " is dropping an audio packet because the timestamps " + "regressed. Was " + << last_timestamp_ << " but got " << output_timestamp; } expected_sample_number_ += num_samples; @@ -592,8 +595,8 @@ AudioDecoder::AudioDecoder() { av_register_all(); } AudioDecoder::~AudioDecoder() { absl::Status status = Close(); if (!status.ok()) { - LOG(ERROR) << "Encountered error while closing media file: " - << status.message(); + ABSL_LOG(ERROR) << "Encountered error while closing media file: " + << status.message(); } } @@ -615,8 +618,8 @@ absl::Status AudioDecoder::Initialize( Cleanup> decoder_closer([this]() { absl::Status status = Close(); if (!status.ok()) { - LOG(ERROR) << "Encountered error while closing media file: " - << status.message(); + ABSL_LOG(ERROR) << "Encountered error while closing media file: " + << status.message(); } }); @@ -645,12 +648,12 @@ absl::Status AudioDecoder::Initialize( absl::make_unique( options.audio_stream(*options_index_ptr)); if (!ContainsKey(audio_processor_, stream_id)) { - LOG(INFO) << "Created audio processor " << processor.get() - << " for file \"" << input_file << "\""; + ABSL_LOG(INFO) << "Created audio processor " << processor.get() + << " for file \"" << input_file << "\""; } else { - LOG(ERROR) << "Stream " << stream_id - << " already mapped to audio processor " - << audio_processor_[stream_id].get(); + ABSL_LOG(ERROR) << "Stream " << stream_id + << " already mapped to audio processor " + << audio_processor_[stream_id].get(); } MP_RETURN_IF_ERROR(processor->Open(stream_id, stream)); @@ -703,10 +706,10 @@ absl::Status AudioDecoder::GetData(int* options_index, Packet* data) { // Ignore packets which are out of the requested timestamp range. if (start_time_ != Timestamp::Unset()) { if (is_first_packet && data->Timestamp() > start_time_) { - LOG(ERROR) << "First packet in audio stream " << *options_index - << " has timestamp " << data->Timestamp() - << " which is after start time of " << start_time_ - << "."; + ABSL_LOG(ERROR) + << "First packet in audio stream " << *options_index + << " has timestamp " << data->Timestamp() + << " which is after start time of " << start_time_ << "."; } if (data->Timestamp() < start_time_) { VLOG(1) << "Skipping audio frame with timestamp " diff --git a/mediapipe/util/filtering/BUILD b/mediapipe/util/filtering/BUILD index 6bd6bc363..17feab2d5 100644 --- a/mediapipe/util/filtering/BUILD +++ b/mediapipe/util/filtering/BUILD @@ -23,7 +23,7 @@ cc_library( srcs = ["low_pass_filter.cc"], hdrs = ["low_pass_filter.h"], deps = [ - "//mediapipe/framework/port:logging", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", ], ) @@ -45,7 +45,7 @@ cc_library( deps = [ ":low_pass_filter", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/time", ], @@ -57,7 +57,8 @@ cc_library( hdrs = ["relative_velocity_filter.h"], deps = [ ":low_pass_filter", - "//mediapipe/framework/port:logging", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/memory", "@com_google_absl//absl/time", ], diff --git a/mediapipe/util/filtering/low_pass_filter.cc b/mediapipe/util/filtering/low_pass_filter.cc index 91ef15600..670fab57f 100644 --- a/mediapipe/util/filtering/low_pass_filter.cc +++ b/mediapipe/util/filtering/low_pass_filter.cc @@ -14,8 +14,8 @@ #include "mediapipe/util/filtering/low_pass_filter.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" -#include "mediapipe/framework/port/logging.h" namespace mediapipe { @@ -49,7 +49,7 @@ float LowPassFilter::LastValue() { return stored_value_; } void LowPassFilter::SetAlpha(float alpha) { if (alpha < 0.0f || alpha > 1.0f) { - LOG(ERROR) << "alpha: " << alpha << " should be in [0.0, 1.0] range"; + ABSL_LOG(ERROR) << "alpha: " << alpha << " should be in [0.0, 1.0] range"; return; } alpha_ = alpha; diff --git a/mediapipe/util/filtering/one_euro_filter.cc b/mediapipe/util/filtering/one_euro_filter.cc index e7893edfe..954477bce 100644 --- a/mediapipe/util/filtering/one_euro_filter.cc +++ b/mediapipe/util/filtering/one_euro_filter.cc @@ -2,9 +2,9 @@ #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/util/filtering/low_pass_filter.h" namespace mediapipe { @@ -28,7 +28,7 @@ double OneEuroFilter::Apply(absl::Duration timestamp, double value_scale, if (last_time_ >= new_timestamp) { // Results are unpredictable in this case, so nothing to do but // return same value - LOG(WARNING) << "New timestamp is equal or less than the last one."; + ABSL_LOG(WARNING) << "New timestamp is equal or less than the last one."; return value; } @@ -59,7 +59,7 @@ double OneEuroFilter::GetAlpha(double cutoff) { void OneEuroFilter::SetFrequency(double frequency) { if (frequency <= kEpsilon) { - LOG(ERROR) << "frequency should be > 0"; + ABSL_LOG(ERROR) << "frequency should be > 0"; return; } frequency_ = frequency; @@ -67,7 +67,7 @@ void OneEuroFilter::SetFrequency(double frequency) { void OneEuroFilter::SetMinCutoff(double min_cutoff) { if (min_cutoff <= kEpsilon) { - LOG(ERROR) << "min_cutoff should be > 0"; + ABSL_LOG(ERROR) << "min_cutoff should be > 0"; return; } min_cutoff_ = min_cutoff; @@ -77,7 +77,7 @@ void OneEuroFilter::SetBeta(double beta) { beta_ = beta; } void OneEuroFilter::SetDerivateCutoff(double derivate_cutoff) { if (derivate_cutoff <= kEpsilon) { - LOG(ERROR) << "derivate_cutoff should be > 0"; + ABSL_LOG(ERROR) << "derivate_cutoff should be > 0"; return; } derivate_cutoff_ = derivate_cutoff; diff --git a/mediapipe/util/filtering/relative_velocity_filter.cc b/mediapipe/util/filtering/relative_velocity_filter.cc index ab88ad59b..f074d7db2 100644 --- a/mediapipe/util/filtering/relative_velocity_filter.cc +++ b/mediapipe/util/filtering/relative_velocity_filter.cc @@ -17,8 +17,9 @@ #include #include +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/memory/memory.h" -#include "mediapipe/framework/port/logging.h" namespace mediapipe { @@ -28,7 +29,7 @@ float RelativeVelocityFilter::Apply(absl::Duration timestamp, float value_scale, if (last_timestamp_ >= new_timestamp) { // Results are unpredictable in this case, so nothing to do but // return same value - LOG(WARNING) << "New timestamp is equal or less than the last one."; + ABSL_LOG(WARNING) << "New timestamp is equal or less than the last one."; return value; } diff --git a/mediapipe/util/frame_buffer/BUILD b/mediapipe/util/frame_buffer/BUILD index 5dfffbac7..f0eda2943 100644 --- a/mediapipe/util/frame_buffer/BUILD +++ b/mediapipe/util/frame_buffer/BUILD @@ -86,7 +86,7 @@ cc_test( deps = [ ":buffer", "//mediapipe/framework/port:gtest_main", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", ], ) @@ -96,7 +96,7 @@ cc_test( deps = [ ":buffer", "//mediapipe/framework/port:gtest_main", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", ], ) @@ -106,6 +106,6 @@ cc_test( deps = [ ":buffer", "//mediapipe/framework/port:gtest_main", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", ], ) diff --git a/mediapipe/util/frame_buffer/gray_buffer_test.cc b/mediapipe/util/frame_buffer/gray_buffer_test.cc index f6f9e9e34..43719d262 100644 --- a/mediapipe/util/frame_buffer/gray_buffer_test.cc +++ b/mediapipe/util/frame_buffer/gray_buffer_test.cc @@ -16,14 +16,14 @@ #include -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" // The default implementation of halide_error calls abort(), which we don't // want. Instead, log the error and let the filter invocation fail. extern "C" void halide_error(void*, const char* message) { - LOG(ERROR) << "Halide Error: " << message; + ABSL_LOG(ERROR) << "Halide Error: " << message; } namespace mediapipe { diff --git a/mediapipe/util/frame_buffer/rgb_buffer_test.cc b/mediapipe/util/frame_buffer/rgb_buffer_test.cc index 8ade0b927..88043e472 100644 --- a/mediapipe/util/frame_buffer/rgb_buffer_test.cc +++ b/mediapipe/util/frame_buffer/rgb_buffer_test.cc @@ -17,7 +17,7 @@ #include #include -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" #include "mediapipe/util/frame_buffer/float_buffer.h" @@ -27,7 +27,7 @@ // The default implementation of halide_error calls abort(), which we don't // want. Instead, log the error and let the filter invocation fail. extern "C" void halide_error(void*, const char* message) { - LOG(ERROR) << "Halide Error: " << message; + ABSL_LOG(ERROR) << "Halide Error: " << message; } namespace mediapipe { diff --git a/mediapipe/util/frame_buffer/yuv_buffer_test.cc b/mediapipe/util/frame_buffer/yuv_buffer_test.cc index a18b19a92..b1e7b68db 100644 --- a/mediapipe/util/frame_buffer/yuv_buffer_test.cc +++ b/mediapipe/util/frame_buffer/yuv_buffer_test.cc @@ -16,7 +16,7 @@ #include -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gtest.h" #include "mediapipe/util/frame_buffer/rgb_buffer.h" @@ -24,7 +24,7 @@ // The default implementation of halide_error calls abort(), which we don't // want. Instead, log the error and let the filter invocation fail. extern "C" void halide_error(void*, const char* message) { - LOG(ERROR) << "Halide Error: " << message; + ABSL_LOG(ERROR) << "Halide Error: " << message; } namespace mediapipe { diff --git a/mediapipe/util/image_frame_util.cc b/mediapipe/util/image_frame_util.cc index bf2773fdc..ecc0de717 100644 --- a/mediapipe/util/image_frame_util.cc +++ b/mediapipe/util/image_frame_util.cc @@ -20,6 +20,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" @@ -34,7 +35,6 @@ #include "mediapipe/framework/formats/yuv_image.h" #include "mediapipe/framework/port/aligned_malloc_and_free.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/port.h" #include "mediapipe/framework/port/status_macros.h" @@ -207,7 +207,7 @@ void YUVImageToImageFrameFromFormat(const YUVImage& yuv_image, yuv_image.width(), yuv_image.height()); break; default: - LOG(FATAL) << "Unsupported YUVImage format."; + ABSL_LOG(FATAL) << "Unsupported YUVImage format."; } } diff --git a/mediapipe/util/image_test_utils.cc b/mediapipe/util/image_test_utils.cc index c2966c567..9e10f40c1 100644 --- a/mediapipe/util/image_test_utils.cc +++ b/mediapipe/util/image_test_utils.cc @@ -4,7 +4,7 @@ #include #include -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/formats/image.h" #include "mediapipe/framework/formats/image_format.pb.h" #include "mediapipe/framework/formats/image_frame.h" @@ -46,7 +46,7 @@ mediapipe::ImageFormat::Format GetImageFormat(int image_channels) { } else if (image_channels == 1) { return ImageFormat::GRAY8; } - LOG(FATAL) << "Unsupported input image channles: " << image_channels; + ABSL_LOG(FATAL) << "Unsupported input image channles: " << image_channels; } Packet MakeImageFramePacket(cv::Mat input, int timestamp) { diff --git a/mediapipe/util/log_fatal_to_breakpad.cc b/mediapipe/util/log_fatal_to_breakpad.cc index 45087f2e3..555b13df0 100644 --- a/mediapipe/util/log_fatal_to_breakpad.cc +++ b/mediapipe/util/log_fatal_to_breakpad.cc @@ -2,7 +2,6 @@ #import -#include "absl/log/log.h" #include "absl/log/log_sink.h" #include "absl/log/log_sink_registry.h" #import "googlemac/iPhone/Shared/GoogleIOSBreakpad/Classes/GoogleBreakpadController.h" diff --git a/mediapipe/util/pose_util.cc b/mediapipe/util/pose_util.cc index 92a8290e9..6c9af9bf1 100644 --- a/mediapipe/util/pose_util.cc +++ b/mediapipe/util/pose_util.cc @@ -1,6 +1,6 @@ #include "mediapipe/util/pose_util.h" -#include "mediapipe/framework/port/logging.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" namespace { @@ -254,7 +254,7 @@ void DrawFace(const mediapipe::NormalizedLandmarkList& face, kRightEyeIrisColor = kCyanColor2; kNoseColor = kOrangeColor; } else { - LOG(ERROR) << "color_style not supported."; + ABSL_LOG(ERROR) << "color_style not supported."; } if (reverse_color) { diff --git a/mediapipe/util/resource_util_android.cc b/mediapipe/util/resource_util_android.cc index 1e970f212..8678b9731 100644 --- a/mediapipe/util/resource_util_android.cc +++ b/mediapipe/util/resource_util_android.cc @@ -14,6 +14,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/strings/match.h" #include "mediapipe/framework/port/file_helpers.h" #include "mediapipe/framework/port/ret_check.h" @@ -36,7 +37,7 @@ absl::Status DefaultGetResourceContents(const std::string& path, std::string* output, bool read_as_binary) { if (!read_as_binary) { - LOG(WARNING) + ABSL_LOG(WARNING) << "Setting \"read_as_binary\" to false is a no-op on Android."; } if (absl::StartsWith(path, "/")) { @@ -74,7 +75,7 @@ absl::StatusOr PathToResourceAsFile(const std::string& path) { { auto status_or_path = PathToResourceAsFileInternal(path); if (status_or_path.ok()) { - LOG(INFO) << "Successfully loaded: " << path; + ABSL_LOG(INFO) << "Successfully loaded: " << path; return status_or_path; } } @@ -87,7 +88,7 @@ absl::StatusOr PathToResourceAsFile(const std::string& path) { auto base_name = path.substr(last_slash_idx + 1); auto status_or_path = PathToResourceAsFileInternal(base_name); if (status_or_path.ok()) { - LOG(INFO) << "Successfully loaded: " << base_name; + ABSL_LOG(INFO) << "Successfully loaded: " << base_name; return status_or_path; } } diff --git a/mediapipe/util/resource_util_apple.cc b/mediapipe/util/resource_util_apple.cc index f64718348..d6ca2c36a 100644 --- a/mediapipe/util/resource_util_apple.cc +++ b/mediapipe/util/resource_util_apple.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/match.h" #include "mediapipe/framework/port/file_helpers.h" #include "mediapipe/framework/port/ret_check.h" @@ -46,7 +47,8 @@ absl::Status DefaultGetResourceContents(const std::string& path, std::string* output, bool read_as_binary) { if (!read_as_binary) { - LOG(WARNING) << "Setting \"read_as_binary\" to false is a no-op on ios."; + ABSL_LOG(WARNING) + << "Setting \"read_as_binary\" to false is a no-op on ios."; } ASSIGN_OR_RETURN(std::string full_path, PathToResourceAsFile(path)); return file::GetContents(full_path, output, read_as_binary); @@ -63,7 +65,7 @@ absl::StatusOr PathToResourceAsFile(const std::string& path) { { auto status_or_path = PathToResourceAsFileInternal(path); if (status_or_path.ok()) { - LOG(INFO) << "Successfully loaded: " << path; + ABSL_LOG(INFO) << "Successfully loaded: " << path; return status_or_path; } } @@ -76,7 +78,7 @@ absl::StatusOr PathToResourceAsFile(const std::string& path) { auto base_name = path.substr(last_slash_idx + 1); auto status_or_path = PathToResourceAsFileInternal(base_name); if (status_or_path.ok()) { - LOG(INFO) << "Successfully loaded: " << base_name; + ABSL_LOG(INFO) << "Successfully loaded: " << base_name; return status_or_path; } } @@ -90,7 +92,7 @@ absl::StatusOr PathToResourceAsFile(const std::string& path) { if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithUTF8String:test_path.c_str()]]) { - LOG(INFO) << "Successfully loaded: " << test_path; + ABSL_LOG(INFO) << "Successfully loaded: " << test_path; return test_path; } } diff --git a/mediapipe/util/tflite/BUILD b/mediapipe/util/tflite/BUILD index f31c23696..97ee1cddb 100644 --- a/mediapipe/util/tflite/BUILD +++ b/mediapipe/util/tflite/BUILD @@ -100,6 +100,7 @@ cc_library( "//mediapipe:ios": [], "//mediapipe:macos": [], "//conditions:default": [ + "//mediapipe/framework/port:logging", "//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:status", "//mediapipe/framework/port:statusor", diff --git a/mediapipe/util/tflite/tflite_gpu_runner.cc b/mediapipe/util/tflite/tflite_gpu_runner.cc index c1b272b67..6a132ac6a 100644 --- a/mediapipe/util/tflite/tflite_gpu_runner.cc +++ b/mediapipe/util/tflite/tflite_gpu_runner.cc @@ -21,6 +21,7 @@ #include "absl/status/status.h" #include "absl/strings/substitute.h" #include "mediapipe/framework/port/canonical_errors.h" +#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status_macros.h" diff --git a/mediapipe/util/time_series_test_util.h b/mediapipe/util/time_series_test_util.h index 7e31aeff5..f44a0bdb3 100644 --- a/mediapipe/util/time_series_test_util.h +++ b/mediapipe/util/time_series_test_util.h @@ -20,6 +20,7 @@ #include #include "Eigen/Core" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/strings/substitute.h" @@ -186,7 +187,8 @@ class TimeSeriesCalculatorTest : public ::testing::Test { void InitializeGraph(const CalculatorOptions& options) { if (num_external_inputs_ != -1) { - LOG(WARNING) << "Use num_side_packets_ instead of num_external_inputs_."; + ABSL_LOG(WARNING) + << "Use num_side_packets_ instead of num_external_inputs_."; num_side_packets_ = num_external_inputs_; } diff --git a/mediapipe/util/time_series_util.cc b/mediapipe/util/time_series_util.cc index 87f69475a..e74350333 100644 --- a/mediapipe/util/time_series_util.cc +++ b/mediapipe/util/time_series_util.cc @@ -19,10 +19,10 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/time_series_header.pb.h" -#include "mediapipe/framework/port/logging.h" namespace mediapipe { namespace time_series_util { @@ -36,8 +36,8 @@ bool LogWarningIfTimestampIsInconsistent(const Timestamp& current_timestamp, // Don't accept other special timestamp values. We may need to change this // depending on how they're used in practice. if (!current_timestamp.IsRangeValue()) { - LOG(WARNING) << "Unexpected special timestamp: " - << current_timestamp.DebugString(); + ABSL_LOG(WARNING) << "Unexpected special timestamp: " + << current_timestamp.DebugString(); return false; } @@ -48,7 +48,7 @@ bool LogWarningIfTimestampIsInconsistent(const Timestamp& current_timestamp, initial_timestamp.Seconds() + cumulative_samples / sample_rate; if (fabs(current_timestamp.Seconds() - expected_timestamp_seconds) > 0.5 / sample_rate) { - LOG_EVERY_N(WARNING, 20) + ABSL_LOG_EVERY_N(WARNING, 20) << std::fixed << "Timestamp " << current_timestamp.Seconds() << " not consistent with number of samples " << cumulative_samples << " and initial timestamp " << initial_timestamp diff --git a/mediapipe/util/time_series_util.h b/mediapipe/util/time_series_util.h index afa66acc6..be5838df8 100644 --- a/mediapipe/util/time_series_util.h +++ b/mediapipe/util/time_series_util.h @@ -25,7 +25,6 @@ #include "mediapipe/framework/formats/matrix.h" #include "mediapipe/framework/formats/time_series_header.pb.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/status.h" namespace mediapipe { diff --git a/mediapipe/util/tracking/BUILD b/mediapipe/util/tracking/BUILD index 5a271ffac..d845f6a45 100644 --- a/mediapipe/util/tracking/BUILD +++ b/mediapipe/util/tracking/BUILD @@ -143,6 +143,7 @@ cc_library( "//mediapipe/framework/port:singleton", "//mediapipe/framework/port:vector", "@com_google_absl//absl/container:node_hash_map", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", "@eigen_archive//:eigen3", ], @@ -169,10 +170,10 @@ cc_library( ":parallel_invoker", ":region_flow_cc_proto", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:vector", "@com_google_absl//absl/container:node_hash_map", "@com_google_absl//absl/container:node_hash_set", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) @@ -186,6 +187,7 @@ cc_library( ":motion_models", ":region_flow", ":region_flow_cc_proto", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", ], ) @@ -204,7 +206,8 @@ cc_library( hdrs = ["measure_time.h"], deps = [ "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", @@ -219,8 +222,9 @@ cc_library( linkopts = PARALLEL_LINKOPTS, deps = [ ":parallel_invoker_forbid_mixed_active", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:threadpool", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/synchronization", ], ) @@ -241,10 +245,10 @@ cc_library( ":motion_models_cc_proto", ":region_flow", ":region_flow_cc_proto", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:vector", + "@com_google_absl//absl/log:absl_log", ], ) @@ -253,9 +257,10 @@ cc_library( srcs = ["streaming_buffer.cc"], hdrs = ["streaming_buffer.h"], deps = [ - "//mediapipe/framework/port:logging", "//mediapipe/framework/tool:type_util", "@com_google_absl//absl/container:node_hash_map", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:any", ], @@ -278,10 +283,10 @@ cc_library( ":region_flow", ":region_flow_cc_proto", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:vector", "@com_google_absl//absl/container:node_hash_map", "@com_google_absl//absl/container:node_hash_set", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@eigen_archive//:eigen3", ], @@ -297,8 +302,8 @@ cc_library( ":motion_saliency_cc_proto", ":region_flow", ":region_flow_cc_proto", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:vector", + "@com_google_absl//absl/log:absl_log", ], ) @@ -309,8 +314,8 @@ cc_library( ":image_util", ":push_pull_filtering_cc_proto", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", + "@com_google_absl//absl/log:absl_log", ], ) @@ -321,9 +326,9 @@ cc_library( deps = [ ":tone_models_cc_proto", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:vector", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", ], ) @@ -344,6 +349,7 @@ cc_library( "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:vector", + "@com_google_absl//absl/log:absl_log", ], ) @@ -378,6 +384,7 @@ cc_library( "//mediapipe/framework/port:vector", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:node_hash_set", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@eigen_archive//:eigen3", ], @@ -424,10 +431,10 @@ cc_library( ":region_flow_visualization", ":streaming_buffer", "//mediapipe/framework/port:integral_types", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:vector", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", ], ) @@ -450,6 +457,7 @@ cc_library( "//mediapipe/framework/port:logging", "//mediapipe/framework/port:vector", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) @@ -476,6 +484,7 @@ cc_library( "//mediapipe/framework/port:vector", "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@eigen_archive//:eigen3", ], @@ -495,6 +504,7 @@ cc_library( "//mediapipe/framework/port:integral_types", "//mediapipe/framework/port:logging", "//mediapipe/framework/port:threadpool", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/synchronization", @@ -519,6 +529,7 @@ cc_library( "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:opencv_video", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/synchronization", ], @@ -536,6 +547,7 @@ cc_library( ":tracking_cc_proto", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgproc", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", ], ) @@ -589,13 +601,13 @@ cc_test( "//mediapipe/framework/deps:file_path", "//mediapipe/framework/port:file_helpers", "//mediapipe/framework/port:gtest_main", - "//mediapipe/framework/port:logging", "//mediapipe/framework/port:opencv_core", "//mediapipe/framework/port:opencv_imgcodecs", "//mediapipe/framework/port:opencv_imgproc", "//mediapipe/framework/port:status", "//mediapipe/framework/port:vector", "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/time", ], ) diff --git a/mediapipe/util/tracking/box_detector.cc b/mediapipe/util/tracking/box_detector.cc index 58d855537..81947f9cf 100644 --- a/mediapipe/util/tracking/box_detector.cc +++ b/mediapipe/util/tracking/box_detector.cc @@ -16,6 +16,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/framework/port/opencv_calib3d_inc.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" @@ -97,7 +98,7 @@ std::unique_ptr BoxDetectorInterface::Create( if (options.index_type() == BoxDetectorOptions::OPENCV_BF) { return absl::make_unique(options); } else { - LOG(FATAL) << "index type undefined."; + ABSL_LOG(FATAL) << "index type undefined."; } } @@ -186,7 +187,8 @@ void BoxDetectorInterface::DetectAndAddBox( if (features_from_tracking_data.empty() || descriptors_from_tracking_data.empty()) { - LOG(WARNING) << "Detection skipped due to empty features or descriptors."; + ABSL_LOG(WARNING) + << "Detection skipped due to empty features or descriptors."; return; } @@ -395,9 +397,9 @@ TimedBoxProtoList BoxDetectorInterface::FindQuadFromFeatureCorrespondence( TimedBoxProtoList result_list; if (matches.points_frame.size() != matches.points_index.size()) { - LOG(ERROR) << matches.points_frame.size() << " vs " - << matches.points_index.size() - << ". Correpondence size doesn't match."; + ABSL_LOG(ERROR) << matches.points_frame.size() << " vs " + << matches.points_index.size() + << ". Correpondence size doesn't match."; return result_list; } diff --git a/mediapipe/util/tracking/box_tracker.cc b/mediapipe/util/tracking/box_tracker.cc index 2d1af779e..d74445141 100644 --- a/mediapipe/util/tracking/box_tracker.cc +++ b/mediapipe/util/tracking/box_tracker.cc @@ -19,6 +19,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" @@ -250,7 +251,7 @@ void BoxTracker::AddTrackingDataChunk(const TrackingDataChunk* chunk, int chunk_idx = ChunkIdxFromTime(chunk_time_msec); CHECK_GE(chunk_idx, tracking_data_.size()) << "Chunk is out of order."; if (chunk_idx > tracking_data_.size()) { - LOG(INFO) << "Resize tracking_data_ to " << chunk_idx; + ABSL_LOG(INFO) << "Resize tracking_data_ to " << chunk_idx; tracking_data_.resize(chunk_idx); } if (copy_data) { @@ -278,7 +279,7 @@ void BoxTracker::NewBoxTrack(const TimedBox& initial_pos, int id, absl::MutexLock lock(&status_mutex_); if (canceling_) { - LOG(WARNING) << "Box Tracker is in cancel state. Refusing request."; + ABSL_LOG(WARNING) << "Box Tracker is in cancel state. Refusing request."; return; } ++track_status_[id][kInitCheckpoint].tracks_ongoing; @@ -319,8 +320,8 @@ void BoxTracker::NewBoxTrackAsync(const TimedBox& initial_pos, int id, if (!tracking_chunk.first) { absl::MutexLock lock(&status_mutex_); --track_status_[id][kInitCheckpoint].tracks_ongoing; - LOG(ERROR) << "Could not read tracking chunk from file: " << chunk_idx - << " for start position: " << initial_pos.ToString(); + ABSL_LOG(ERROR) << "Could not read tracking chunk from file: " << chunk_idx + << " for start position: " << initial_pos.ToString(); return; } @@ -502,7 +503,7 @@ bool BoxTracker::GetTimedPosition(int id, int64_t time_msec, TimedBox* result, absl::MutexLock lock(&path_mutex_); const Path& path = paths_[id]; if (path.empty()) { - LOG(ERROR) << "Empty path!"; + ABSL_LOG(ERROR) << "Empty path!"; return false; } @@ -586,7 +587,7 @@ BoxTracker::AugmentedChunkPtr BoxTracker::ReadChunk(int id, int checkpoint, if (chunk_idx < tracking_data_.size()) { return std::make_pair(tracking_data_[chunk_idx], false); } else { - LOG(ERROR) << "chunk_idx >= tracking_data_.size()"; + ABSL_LOG(ERROR) << "chunk_idx >= tracking_data_.size()"; return std::make_pair(nullptr, false); } } else { @@ -607,7 +608,7 @@ std::unique_ptr BoxTracker::ReadChunkFromCache( if (format_runtime) { chunk_file = cache_dir_ + "/" + absl::StrFormat(*format_runtime, chunk_idx); } else { - LOG(ERROR) << "chache_file_format wrong. fall back to chunk_%04d."; + ABSL_LOG(ERROR) << "chache_file_format wrong. fall back to chunk_%04d."; chunk_file = cache_dir_ + "/" + absl::StrFormat("chunk_%04d", chunk_idx); } @@ -625,7 +626,7 @@ std::unique_ptr BoxTracker::ReadChunkFromCache( std::ifstream in(chunk_file, std::ios::in | std::ios::binary); if (!in) { - LOG(ERROR) << "Could not read chunk file: " << chunk_file; + ABSL_LOG(ERROR) << "Could not read chunk file: " << chunk_file; return nullptr; } @@ -712,7 +713,8 @@ int BoxTracker::ClosestFrameIndex(int64_t msec, const int64_t rhs_diff = chunk.item(pos).timestamp_usec() / 1000 - msec; if (std::min(lhs_diff, rhs_diff) >= 67) { - LOG(ERROR) << "No frame found within 67ms, probably using wrong chunk."; + ABSL_LOG(ERROR) + << "No frame found within 67ms, probably using wrong chunk."; } if (lhs_diff < rhs_diff) { @@ -831,7 +833,7 @@ void BoxTracker::TrackingImpl(const TrackingImplArgs& a) { TrackingImpl(next_args); } else { cleanup_func(); - LOG(ERROR) << "Can't read expected chunk file!"; + ABSL_LOG(ERROR) << "Can't read expected chunk file!"; } } } @@ -892,10 +894,10 @@ void BoxTracker::TrackingImpl(const TrackingImplArgs& a) { TrackingImpl(prev_args); } else { cleanup_func(); - LOG(ERROR) << "Can't read expected chunk file! " << a.chunk_idx - 1 - << " while tracking @" - << a.chunk_data->item(f).timestamp_usec() / 1000 - << " with cutoff " << a.min_msec; + ABSL_LOG(ERROR) << "Can't read expected chunk file! " + << a.chunk_idx - 1 << " while tracking @" + << a.chunk_data->item(f).timestamp_usec() / 1000 + << " with cutoff " << a.min_msec; return; } } @@ -1039,7 +1041,7 @@ bool BoxTracker::GetTrackingData(int id, int64_t request_time_msec, if (!tracking_chunk.first) { absl::MutexLock lock(&status_mutex_); --track_status_[id][kInitCheckpoint].tracks_ongoing; - LOG(ERROR) << "Could not read tracking chunk from file."; + ABSL_LOG(ERROR) << "Could not read tracking chunk from file."; return false; } diff --git a/mediapipe/util/tracking/camera_motion.cc b/mediapipe/util/tracking/camera_motion.cc index e753be712..8e8e238d3 100644 --- a/mediapipe/util/tracking/camera_motion.cc +++ b/mediapipe/util/tracking/camera_motion.cc @@ -16,6 +16,7 @@ #include +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "mediapipe/util/tracking/region_flow.h" @@ -106,9 +107,10 @@ CameraMotion ComposeCameraMotion(const CameraMotion& lhs, if (rhs.has_mixture_homography()) { if (lhs.has_mixture_homography()) { - LOG(ERROR) << "Mixture homographies are not closed under composition, " - << "Only rhs mixtures composed with lhs homographies " - << "are supported."; + ABSL_LOG(ERROR) + << "Mixture homographies are not closed under composition, " + << "Only rhs mixtures composed with lhs homographies " + << "are supported."; } else if (lhs.type() <= CameraMotion::UNSTABLE_SIM) { // We only composit base model when stability is sufficient. *result.mutable_mixture_homography() = @@ -116,7 +118,7 @@ CameraMotion ComposeCameraMotion(const CameraMotion& lhs, lhs.homography()); } } else if (lhs.has_mixture_homography()) { - LOG(ERROR) << "Only rhs mixtures supported."; + ABSL_LOG(ERROR) << "Only rhs mixtures supported."; } // Select max unstable type. @@ -175,7 +177,7 @@ CameraMotion InvertCameraMotion(const CameraMotion& motion) { } if (motion.has_mixture_homography()) { - LOG(ERROR) << "Mixture homographies are not closed under inversion."; + ABSL_LOG(ERROR) << "Mixture homographies are not closed under inversion."; } return inverted; @@ -227,8 +229,9 @@ void SubtractCameraMotionFromFeatures( float ForegroundMotion(const CameraMotion& camera_motion, const RegionFlowFeatureList& feature_list) { if (camera_motion.has_mixture_homography()) { - LOG(WARNING) << "Mixture homographies are present but function is only " - << "using homographies. Truncation error likely."; + ABSL_LOG(WARNING) + << "Mixture homographies are present but function is only " + << "using homographies. Truncation error likely."; } Homography background_motion; @@ -327,7 +330,7 @@ template CameraMotion FirstCameraMotionForLooping( const CameraMotionContainer& camera_motions) { if (camera_motions.size() < 2) { - LOG(ERROR) << "Not enough camera motions for refinement."; + ABSL_LOG(ERROR) << "Not enough camera motions for refinement."; return CameraMotion(); } @@ -346,8 +349,8 @@ CameraMotion FirstCameraMotionForLooping( const CameraMotion& motion = camera_motions[i]; if (motion.has_mixture_homography()) { // TODO: Implement - LOG(WARNING) << "This function does not validly apply mixtures; " - << "which are currently not closed under composition. "; + ABSL_LOG(WARNING) << "This function does not validly apply mixtures; " + << "which are currently not closed under composition. "; } switch (motion.type()) { @@ -367,7 +370,7 @@ CameraMotion FirstCameraMotionForLooping( case CameraMotion::UNSTABLE_HOMOG: break; default: - LOG(FATAL) << "Unknown CameraMotion::type."; + ABSL_LOG(FATAL) << "Unknown CameraMotion::type."; } // Only accumulate motions which are valid for the entire chain, otherwise diff --git a/mediapipe/util/tracking/camera_motion.h b/mediapipe/util/tracking/camera_motion.h index cadee78cb..b37fd482f 100644 --- a/mediapipe/util/tracking/camera_motion.h +++ b/mediapipe/util/tracking/camera_motion.h @@ -17,6 +17,7 @@ #include +#include "absl/log/absl_log.h" #include "mediapipe/util/tracking/camera_motion.pb.h" #include "mediapipe/util/tracking/motion_models.h" #include "mediapipe/util/tracking/region_flow.pb.h" @@ -165,7 +166,7 @@ Model UnstableCameraMotionToModel(const CameraMotion& camera_motion, } case CameraMotion::VALID: - LOG(FATAL) << "Specify a type != VALID"; + ABSL_LOG(FATAL) << "Specify a type != VALID"; return Model(); } } @@ -225,7 +226,7 @@ Model ProjectToTypeModel(const Model& model, float frame_width, template <> inline MixtureHomography ProjectToTypeModel(const MixtureHomography&, float, float, CameraMotion::Type) { - LOG(FATAL) << "Projection not supported for mixtures."; + ABSL_LOG(FATAL) << "Projection not supported for mixtures."; return MixtureHomography(); } diff --git a/mediapipe/util/tracking/flow_packager.cc b/mediapipe/util/tracking/flow_packager.cc index dceacbcd9..8f990cd05 100644 --- a/mediapipe/util/tracking/flow_packager.cc +++ b/mediapipe/util/tracking/flow_packager.cc @@ -20,6 +20,7 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "mediapipe/framework/port/logging.h" @@ -321,9 +322,9 @@ void FlowPackager::EncodeTrackingData(const TrackingData& tracking_data, const float max_vector_threshold = hypot(domain_width, domain_height) * 0.2f; // Warn if too much truncation. if (max_vector_value > max_vector_threshold * 1.5f) { - LOG(WARNING) << "A lot of truncation will occur during encoding. " - << "Vector magnitudes are larger than 20% of the " - << "frame diameter."; + ABSL_LOG(WARNING) << "A lot of truncation will occur during encoding. " + << "Vector magnitudes are larger than 20% of the " + << "frame diameter."; } max_vector_value = diff --git a/mediapipe/util/tracking/image_util.cc b/mediapipe/util/tracking/image_util.cc index a44c00b01..391ba15e1 100644 --- a/mediapipe/util/tracking/image_util.cc +++ b/mediapipe/util/tracking/image_util.cc @@ -17,7 +17,7 @@ #include #include -#include "mediapipe/framework/port/logging.h" +#include "absl/log/absl_log.h" #include "mediapipe/util/tracking/motion_models.h" #include "mediapipe/util/tracking/region_flow.h" @@ -71,7 +71,7 @@ void JetColoring(int steps, std::vector* color_map) { (*color_map)[i] = Vector3_f(1.0f + (frac - 0.8f) * -2.0f, 0.0f, 0.0f) * 255.0f; } else { - LOG(ERROR) << "Out of bound value. Should not occur."; + ABSL_LOG(ERROR) << "Out of bound value. Should not occur."; } } } diff --git a/mediapipe/util/tracking/measure_time.cc b/mediapipe/util/tracking/measure_time.cc index e628dff0f..f4c9b2902 100644 --- a/mediapipe/util/tracking/measure_time.cc +++ b/mediapipe/util/tracking/measure_time.cc @@ -15,7 +15,7 @@ #include "mediapipe/util/tracking/measure_time.h" #ifdef SET_FLAG_MEASURE_TIME -// If set to true, outputs time measurements to LOG(INFO). +// If set to true, outputs time measurements to ABSL_LOG(INFO). bool flags_measure_time = true; #else bool flags_measure_time = false; diff --git a/mediapipe/util/tracking/measure_time.h b/mediapipe/util/tracking/measure_time.h index 0351f4652..7890da7e9 100644 --- a/mediapipe/util/tracking/measure_time.h +++ b/mediapipe/util/tracking/measure_time.h @@ -13,7 +13,7 @@ // limitations under the License. // // Helper class and macro to take time measurements within current scope. -// Takes time measurement within current scope. Outputs to LOG(INFO) if +// Takes time measurement within current scope. Outputs to ABSL_LOG(INFO) if // flag --measure_time is set or if build flag SET_FLAG_MEASURE_TIME is // defined (add --copt=-DSET_FLAG_MEASURE_TIME to your build command). // Additionally you can limit time measurements to specific files, @@ -31,12 +31,13 @@ #include #include +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" extern bool flags_measure_time; @@ -115,10 +116,10 @@ class ScopedWallTimer { double accum_time = 0.0; int count = 0; accumulator_->Accumulate(passed_time, &accum_time, &count); - LOG(INFO) << stream_.str() << " TIMES: [Curr: " << passed_time * 1e-6 - << " ms, " - << "Avg: " << accum_time * 1e-6 / std::max(1, count) << " ms, " - << count << " calls]"; + ABSL_LOG(INFO) << stream_.str() << " TIMES: [Curr: " << passed_time * 1e-6 + << " ms, " + << "Avg: " << accum_time * 1e-6 / std::max(1, count) + << " ms, " << count << " calls]"; } } diff --git a/mediapipe/util/tracking/motion_analysis.cc b/mediapipe/util/tracking/motion_analysis.cc index 67973cbcf..67baa602f 100644 --- a/mediapipe/util/tracking/motion_analysis.cc +++ b/mediapipe/util/tracking/motion_analysis.cc @@ -20,9 +20,9 @@ #include #include +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/vector.h" #include "mediapipe/util/tracking/camera_motion.h" #include "mediapipe/util/tracking/camera_motion.pb.h" @@ -370,7 +370,7 @@ bool MotionAnalysis::AddFrameGeneric( MEASURE_TIME << "CALL RegionFlowComputation::AddImage"; if (!region_flow_computation_->AddImageWithSeed(frame, timestamp_usec, initial_transform)) { - LOG(ERROR) << "Error while computing region flow."; + ABSL_LOG(ERROR) << "Error while computing region flow."; return false; } } @@ -401,7 +401,7 @@ bool MotionAnalysis::AddFrameGeneric( compute_feature_match_descriptors ? prev_frame_.get() : nullptr)); if (feature_list == nullptr) { - LOG(ERROR) << "Error retrieving feature list."; + ABSL_LOG(ERROR) << "Error retrieving feature list."; return false; } } @@ -670,7 +670,7 @@ void MotionAnalysis::RenderResults(const RegionFlowFeatureList& feature_list, text_scale * 3, cv::LINE_AA); } #else - LOG(FATAL) << "Code stripped out because of NO_RENDERING"; + ABSL_LOG(FATAL) << "Code stripped out because of NO_RENDERING"; #endif } diff --git a/mediapipe/util/tracking/motion_estimation.cc b/mediapipe/util/tracking/motion_estimation.cc index b608b4705..07515cbc5 100644 --- a/mediapipe/util/tracking/motion_estimation.cc +++ b/mediapipe/util/tracking/motion_estimation.cc @@ -31,8 +31,8 @@ #include "Eigen/SVD" #include "absl/container/node_hash_map.h" #include "absl/container/node_hash_set.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/util/tracking/camera_motion.h" #include "mediapipe/util/tracking/measure_time.h" #include "mediapipe/util/tracking/motion_models.h" @@ -486,17 +486,19 @@ void MotionEstimation::InitializeWithOptions( MotionEstimationOptions::ESTIMATION_HOMOG_NONE && options.linear_similarity_estimation() == MotionEstimationOptions::ESTIMATION_LS_NONE) { - LOG(FATAL) << "Invalid MotionEstimationOptions. " - << "Homography estimation requires similarity to be estimated"; + ABSL_LOG(FATAL) + << "Invalid MotionEstimationOptions. " + << "Homography estimation requires similarity to be estimated"; } if (options.mix_homography_estimation() != MotionEstimationOptions::ESTIMATION_HOMOG_MIX_NONE && options.homography_estimation() == MotionEstimationOptions::ESTIMATION_HOMOG_NONE) { - LOG(FATAL) << "Invalid MotionEstimationOptions. " - << "Mixture homography estimation requires homography to be " - << "estimated."; + ABSL_LOG(FATAL) + << "Invalid MotionEstimationOptions. " + << "Mixture homography estimation requires homography to be " + << "estimated."; } // Check for deprecated options. @@ -796,7 +798,7 @@ class EstimateMotionIRLSInvoker { break; case MotionEstimation::MODEL_NUM_VALUES: - LOG(FATAL) << "Function should not be called with this value"; + ABSL_LOG(FATAL) << "Function should not be called with this value"; break; } } @@ -941,8 +943,8 @@ void MotionEstimation::EstimateMotionsParallelImpl( if (options_.long_feature_initialization().activated()) { if (!feature_list.long_tracks()) { - LOG(ERROR) << "Requesting long feature initialization but " - << "input is not computed with long features."; + ABSL_LOG(ERROR) << "Requesting long feature initialization but " + << "input is not computed with long features."; } else { LongFeatureInitialization(feature_list, long_feature_info, track_length_importance, &irls_weight_input); @@ -1943,11 +1945,11 @@ void MotionEstimation::BiasLongFeatures( // Bias along long tracks. if (!prior_weights->use_full_prior) { - LOG_IF(WARNING, - []() { - static int k = 0; - return k++ < 2; - }()) + ABSL_LOG_IF(WARNING, + []() { + static int k = 0; + return k++ < 2; + }()) << "Use full prior overridden to true, no initialization used. " << "Atypical usage."; prior_weights->use_full_prior = true; @@ -1955,8 +1957,9 @@ void MotionEstimation::BiasLongFeatures( const int num_features = feature_list->feature_size(); if (prior_weights->priors.empty() && num_features > 0) { - LOG(WARNING) << "BiasLongFeatures without using IrlsOutlierInitialization " - << "or LongFeatureInitialization."; + ABSL_LOG(WARNING) + << "BiasLongFeatures without using IrlsOutlierInitialization " + << "or LongFeatureInitialization."; prior_weights->priors.resize(num_features, 1.0f); } @@ -2316,7 +2319,7 @@ int MotionEstimation::IRLSRoundsFromSettings(const MotionType& type) const { const int irls_rounds = options_.irls_rounds(); switch (type) { case MODEL_AVERAGE_MAGNITUDE: - LOG(WARNING) << "Called with irls free motion type. Returning zero."; + ABSL_LOG(WARNING) << "Called with irls free motion type. Returning zero."; return 0; case MODEL_TRANSLATION: @@ -2340,7 +2343,8 @@ int MotionEstimation::IRLSRoundsFromSettings(const MotionType& type) const { case MotionEstimationOptions::ESTIMATION_LS_L2_RANSAC: case MotionEstimationOptions::ESTIMATION_LS_L1: - LOG(FATAL) << "Deprecated options, use ESTIMATION_LS_IRLS instead."; + ABSL_LOG(FATAL) + << "Deprecated options, use ESTIMATION_LS_IRLS instead."; return -1; } break; @@ -2385,11 +2389,12 @@ int MotionEstimation::IRLSRoundsFromSettings(const MotionType& type) const { break; case MODEL_NUM_VALUES: - LOG(FATAL) << "Function should never be called with this value"; + ABSL_LOG(FATAL) << "Function should never be called with this value"; break; } - LOG(FATAL) << "All branches above return, execution can not reach this point"; + ABSL_LOG(FATAL) + << "All branches above return, execution can not reach this point"; return -1; } @@ -2462,7 +2467,7 @@ void MotionEstimation::CheckSingleModelStability( switch (type) { case MODEL_AVERAGE_MAGNITUDE: - LOG(WARNING) << "Nothing to check for requested model type."; + ABSL_LOG(WARNING) << "Nothing to check for requested model type."; return; case MODEL_TRANSLATION: @@ -2551,8 +2556,8 @@ void MotionEstimation::CheckSingleModelStability( case CameraMotion::INVALID: case CameraMotion::UNSTABLE_HOMOG: - LOG(FATAL) << "Unexpected CameraMotion::Type: " - << camera_motion->type(); + ABSL_LOG(FATAL) + << "Unexpected CameraMotion::Type: " << camera_motion->type(); break; } @@ -2575,7 +2580,7 @@ void MotionEstimation::CheckSingleModelStability( } case MODEL_NUM_VALUES: - LOG(FATAL) << "Function should not be called with this value"; + ABSL_LOG(FATAL) << "Function should not be called with this value"; break; } } @@ -2589,7 +2594,7 @@ void MotionEstimation::ProjectMotionsDown( case MODEL_TRANSLATION: case MODEL_MIXTURE_HOMOGRAPHY: case MODEL_AFFINE: - LOG(WARNING) << "Nothing to project for requested model type"; + ABSL_LOG(WARNING) << "Nothing to project for requested model type"; return; case MODEL_HOMOGRAPHY: @@ -2620,7 +2625,7 @@ void MotionEstimation::ProjectMotionsDown( break; case MODEL_NUM_VALUES: - LOG(FATAL) << "Function should not be called with this value"; + ABSL_LOG(FATAL) << "Function should not be called with this value"; break; } } @@ -3163,7 +3168,7 @@ void MotionEstimation::EstimateTranslationModelIRLS( CameraMotion* camera_motion) const { if (prior_weights && !prior_weights->HasCorrectDimension( irls_rounds, flow_feature_list->feature_size())) { - LOG(ERROR) << "Prior weights incorrectly initialized, ignoring."; + ABSL_LOG(ERROR) << "Prior weights incorrectly initialized, ignoring."; prior_weights = nullptr; } @@ -3524,7 +3529,7 @@ bool MotionEstimation::EstimateLinearSimilarityModelIRLS( CameraMotion* camera_motion) const { if (prior_weights && !prior_weights->HasCorrectDimension( irls_rounds, flow_feature_list->feature_size())) { - LOG(ERROR) << "Prior weights incorrectly initialized, ignoring."; + ABSL_LOG(ERROR) << "Prior weights incorrectly initialized, ignoring."; prior_weights = nullptr; } @@ -4382,7 +4387,7 @@ void MotionEstimation::GetHomographyIRLSCenterWeights( weights->push_back(1.0f - weight * 0.5f); break; default: - LOG(INFO) << "Unsupported IRLS weighting."; + ABSL_LOG(INFO) << "Unsupported IRLS weighting."; } } } @@ -4863,7 +4868,7 @@ bool MotionEstimation::EstimateHomographyIRLS( RegionFlowFeatureList* feature_list, CameraMotion* camera_motion) const { if (prior_weights && !prior_weights->HasCorrectDimension( irls_rounds, feature_list->feature_size())) { - LOG(ERROR) << "Prior weights incorrectly initialized, ignoring."; + ABSL_LOG(ERROR) << "Prior weights incorrectly initialized, ignoring."; prior_weights = nullptr; } @@ -5079,7 +5084,7 @@ bool MotionEstimation::MixtureHomographyFromFeature( MixtureHomography* mix_homography) const { if (prior_weights && !prior_weights->HasCorrectDimension( irls_rounds, feature_list->feature_size())) { - LOG(ERROR) << "Prior weights incorrectly initialized, ignoring."; + ABSL_LOG(ERROR) << "Prior weights incorrectly initialized, ignoring."; prior_weights = nullptr; } @@ -5109,7 +5114,7 @@ bool MotionEstimation::MixtureHomographyFromFeature( adjacency_constraints = 4 * (num_mixtures - 1); break; default: - LOG(FATAL) << "Unknown MixtureModelMode specified."; + ABSL_LOG(FATAL) << "Unknown MixtureModelMode specified."; } Eigen::MatrixXf matrix( @@ -5195,7 +5200,7 @@ bool MotionEstimation::MixtureHomographyFromFeature( break; default: - LOG(FATAL) << "Unknown MixtureModelMode specified."; + ABSL_LOG(FATAL) << "Unknown MixtureModelMode specified."; } norm_model = MixtureHomographyAdapter::FromFloatPointer( @@ -5264,7 +5269,7 @@ bool MotionEstimation::MixtureHomographyFromFeature( mix_homography->set_dof(MixtureHomography::SKEW_ROTATION_DOF); break; default: - LOG(FATAL) << "Unknown MixtureModelMode specified."; + ABSL_LOG(FATAL) << "Unknown MixtureModelMode specified."; } return true; } @@ -5363,8 +5368,8 @@ bool MotionEstimation::EstimateMixtureHomographyIRLS( // Cap rolling shutter analysis level to be valid level. if (options_.mixture_rs_analysis_level() >= options_.mixture_regularizer_levels()) { - LOG(WARNING) << "Resetting mixture_rs_analysis_level to " - << options_.mixture_regularizer_levels() - 1; + ABSL_LOG(WARNING) << "Resetting mixture_rs_analysis_level to " + << options_.mixture_regularizer_levels() - 1; } const int rs_analysis_level = diff --git a/mediapipe/util/tracking/motion_models.cc b/mediapipe/util/tracking/motion_models.cc index eb6a8b314..46e77f9b6 100644 --- a/mediapipe/util/tracking/motion_models.cc +++ b/mediapipe/util/tracking/motion_models.cc @@ -22,6 +22,7 @@ #include "Eigen/Core" #include "Eigen/Dense" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" // Set to true to use catmull rom mixture weights instead of Gaussian weights @@ -151,7 +152,7 @@ SimilarityModel ModelAdapter::Invert( bool success = true; const SimilarityModel result = InvertChecked(model, &success); if (!success) { - LOG(ERROR) << "Model not invertible. Returning identity."; + ABSL_LOG(ERROR) << "Model not invertible. Returning identity."; return SimilarityModel(); } else { return result; @@ -218,7 +219,7 @@ float ModelAdapter::GetParameter(const SimilarityModel& model, case 3: return model.rotation(); default: - LOG(FATAL) << "Parameter id is out of bounds"; + ABSL_LOG(FATAL) << "Parameter id is out of bounds"; } return 0; @@ -550,7 +551,7 @@ Homography ModelAdapter::InvertChecked(const Homography& model, Eigen::Matrix3d inv_model_mat = model_mat.inverse(); if (inv_model_mat(2, 2) == 0) { - LOG(ERROR) << "Degenerate homography. See proto."; + ABSL_LOG(ERROR) << "Degenerate homography. See proto."; *success = false; return Homography(); } @@ -730,7 +731,7 @@ float ModelMethods::NormalizedIntersectionArea(const Model& model_1, const Vector2_f& rect) { const float rect_area = rect.x() * rect.y(); if (rect_area <= 0) { - LOG(WARNING) << "Empty rectangle passed -> empty intersection."; + ABSL_LOG(WARNING) << "Empty rectangle passed -> empty intersection."; return 0.0f; } @@ -756,7 +757,7 @@ float ModelMethods::NormalizedIntersectionArea(const Model& model_1, const float average_area = 0.5f * (model_1_area + model_2_area); if (average_area <= 0) { - LOG(WARNING) << "Degenerative models passed -> empty intersection."; + ABSL_LOG(WARNING) << "Degenerative models passed -> empty intersection."; return 0.0f; } @@ -764,7 +765,7 @@ float ModelMethods::NormalizedIntersectionArea(const Model& model_1, bool success = true; Model diff = ModelDiffChecked(model_2, model_1, &success); if (!success) { - LOG(WARNING) << "Model difference is singular -> empty intersection."; + ABSL_LOG(WARNING) << "Model difference is singular -> empty intersection."; return 0.0f; } @@ -786,7 +787,7 @@ float ModelMethods::NormalizedIntersectionArea(const Model& model_1, // Second, clip transformed rectangle against origin defined by model_2. Model inv_diff = Adapter::InvertChecked(diff, &success); if (!success) { - LOG(WARNING) << "Model difference is singular -> empty intersection."; + ABSL_LOG(WARNING) << "Model difference is singular -> empty intersection."; return 0.0f; } @@ -829,10 +830,11 @@ MixtureRowWeights::MixtureRowWeights(int frame_height, int margin, float sigma, // No margin support for splines. if (margin_ > 0) { - LOG(WARNING) << "No margin support when flag catmull_rom_mixture_weights " - << "is set. Margin is reset to zero, it is recommended " - << "that RowWeightsBoundChecked is used to prevent " - << "segfaults."; + ABSL_LOG(WARNING) + << "No margin support when flag catmull_rom_mixture_weights " + << "is set. Margin is reset to zero, it is recommended " + << "that RowWeightsBoundChecked is used to prevent " + << "segfaults."; margin_ = 0; } diff --git a/mediapipe/util/tracking/motion_models.h b/mediapipe/util/tracking/motion_models.h index 567831ad5..020e3f68b 100644 --- a/mediapipe/util/tracking/motion_models.h +++ b/mediapipe/util/tracking/motion_models.h @@ -21,6 +21,7 @@ #include #include "absl/container/node_hash_map.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/singleton.h" #include "mediapipe/framework/port/vector.h" @@ -50,7 +51,7 @@ class ModelAdapter { static Model InvertChecked(const Model& model, bool* success); // Returns model^(-1), returns identity model if inversion is not possible, - // and warns via LOG(ERROR). It is recommended that InvertChecked is used + // and warns via ABSL_LOG(ERROR). It is recommended that InvertChecked is used // instead. // Note: Default implementation, motion models only need to supply above // function. @@ -704,8 +705,8 @@ bool ModelDiffWithinBounds(const Model& ground_truth, const Model& predicted, ModelAdapter::GetParameter(identity, p)); if (diff_p > bound) { - LOG(WARNING) << "Param diff " << p << " out of bounds: " << diff_p - << " > " << bound << " bound"; + ABSL_LOG(WARNING) << "Param diff " << p << " out of bounds: " << diff_p + << " > " << bound << " bound"; return false; } } @@ -992,7 +993,7 @@ inline TranslationModel ModelAdapter::Invert( bool success = true; TranslationModel result = InvertChecked(model, &success); if (!success) { - LOG(ERROR) << "Model not invertible. Returning identity."; + ABSL_LOG(ERROR) << "Model not invertible. Returning identity."; return TranslationModel(); } @@ -1024,7 +1025,7 @@ inline float ModelAdapter::GetParameter( case 1: return model.dy(); default: - LOG(FATAL) << "Parameter id is out of bounds"; + ABSL_LOG(FATAL) << "Parameter id is out of bounds"; } return 0; } @@ -1037,7 +1038,7 @@ inline void ModelAdapter::SetParameter( case 1: return model->set_dy(value); default: - LOG(FATAL) << "Parameter id is out of bounds"; + ABSL_LOG(FATAL) << "Parameter id is out of bounds"; } } @@ -1089,7 +1090,7 @@ inline LinearSimilarityModel ModelAdapter::Invert( bool success = true; LinearSimilarityModel result = InvertChecked(model, &success); if (!success) { - LOG(ERROR) << "Model not invertible. Returning identity."; + ABSL_LOG(ERROR) << "Model not invertible. Returning identity."; return LinearSimilarityModel(); } else { return result; @@ -1143,7 +1144,7 @@ inline float ModelAdapter::GetParameter( case 3: return model.b(); default: - LOG(FATAL) << "Parameter id is out of bounds"; + ABSL_LOG(FATAL) << "Parameter id is out of bounds"; } return 0; @@ -1161,7 +1162,7 @@ inline void ModelAdapter::SetParameter( case 3: return model->set_b(value); default: - LOG(FATAL) << "Parameter id is out of bounds"; + ABSL_LOG(FATAL) << "Parameter id is out of bounds"; } } @@ -1218,7 +1219,7 @@ inline AffineModel ModelAdapter::Invert(const AffineModel& model) { bool success = true; AffineModel result = InvertChecked(model, &success); if (!success) { - LOG(ERROR) << "Model not invertible. Returning identity."; + ABSL_LOG(ERROR) << "Model not invertible. Returning identity."; return AffineModel(); } else { return result; @@ -1279,7 +1280,7 @@ inline float ModelAdapter::GetParameter(const AffineModel& model, case 5: return model.d(); default: - LOG(FATAL) << "Parameter id is out of bounds"; + ABSL_LOG(FATAL) << "Parameter id is out of bounds"; } return 0; @@ -1301,7 +1302,7 @@ inline void ModelAdapter::SetParameter(int id, float value, case 5: return model->set_d(value); default: - LOG(FATAL) << "Parameter id is out of bounds"; + ABSL_LOG(FATAL) << "Parameter id is out of bounds"; } } @@ -1364,8 +1365,8 @@ inline Vector2_f ModelAdapter::TransformPoint( // Enforce z can not assume very small values. constexpr float eps = 1e-12f; if (fabs(z) < eps) { - LOG(ERROR) << "Point mapped to infinity. " - << "Degenerate homography. See proto."; + ABSL_LOG(ERROR) << "Point mapped to infinity. " + << "Degenerate homography. See proto."; z = z >= 0 ? eps : -eps; } return Vector2_f(x / z, y / z); @@ -1386,7 +1387,7 @@ inline Homography ModelAdapter::Invert(const Homography& model) { bool success = true; Homography result = InvertChecked(model, &success); if (!success) { - LOG(ERROR) << "Model not invertible. Returning identity."; + ABSL_LOG(ERROR) << "Model not invertible. Returning identity."; return Homography(); } else { return result; @@ -1450,7 +1451,7 @@ inline float ModelAdapter::GetParameter(const Homography& model, case 7: return model.h_21(); default: - LOG(FATAL) << "Parameter id is out of bounds"; + ABSL_LOG(FATAL) << "Parameter id is out of bounds"; } return 0; @@ -1476,7 +1477,7 @@ inline void ModelAdapter::SetParameter(int id, float value, case 7: return model->set_h_21(value); default: - LOG(FATAL) << "Parameter id is out of bounds"; + ABSL_LOG(FATAL) << "Parameter id is out of bounds"; } } @@ -1767,7 +1768,7 @@ inline Homography MixtureModelAdapter::ToBaseModel( case MixtureHomography::CONST_DOF: return const_homog; default: - LOG(FATAL) << "Unknown type."; + ABSL_LOG(FATAL) << "Unknown type."; } return HomographyAdapter::FromFloatPointer(params, false); @@ -1815,7 +1816,7 @@ inline Vector2_f MixtureModelAdapter::TransformPoint( case MixtureHomography::CONST_DOF: return HomographyAdapter::TransformPoint(model.model(0), pt); default: - LOG(FATAL) << "Unknown type."; + ABSL_LOG(FATAL) << "Unknown type."; } DCHECK_NE(result.z(), 0) << "Degenerate mapping."; diff --git a/mediapipe/util/tracking/motion_saliency.cc b/mediapipe/util/tracking/motion_saliency.cc index 5adafca4c..ec40dfa30 100644 --- a/mediapipe/util/tracking/motion_saliency.cc +++ b/mediapipe/util/tracking/motion_saliency.cc @@ -24,7 +24,7 @@ #include #include -#include "mediapipe/framework/port/logging.h" +#include "absl/log/absl_log.h" #include "mediapipe/util/tracking/camera_motion.h" #include "mediapipe/util/tracking/measure_time.h" #include "mediapipe/util/tracking/region_flow.h" @@ -417,8 +417,8 @@ void DetermineFeatureModes( center = new_center; } } else { - LOG(WARNING) << "No features found in band_width radius, " - << "should not happen. "; + ABSL_LOG(WARNING) << "No features found in band_width radius, " + << "should not happen. "; break; } } diff --git a/mediapipe/util/tracking/parallel_invoker.h b/mediapipe/util/tracking/parallel_invoker.h index 823522310..c9d236a7d 100644 --- a/mediapipe/util/tracking/parallel_invoker.h +++ b/mediapipe/util/tracking/parallel_invoker.h @@ -71,8 +71,9 @@ #include +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/synchronization/mutex.h" -#include "mediapipe/framework/port/logging.h" #ifdef PARALLEL_INVOKER_ACTIVE #include "mediapipe/framework/port/threadpool.h" @@ -233,13 +234,13 @@ inline void CheckAndSetInvokerOptions() { flags_parallel_invoker_mode != PARALLEL_INVOKER_THREAD_POOL && flags_parallel_invoker_mode != PARALLEL_INVOKER_OPENMP) { #if defined(_OPENMP) - LOG(WARNING) << "Unsupported invoker mode selected on Android. " - << "OpenMP linkage detected, so falling back to OpenMP"; + ABSL_LOG(WARNING) << "Unsupported invoker mode selected on Android. " + << "OpenMP linkage detected, so falling back to OpenMP"; flags_parallel_invoker_mode = PARALLEL_INVOKER_OPENMP; #else // _OPENMP // Fallback mode for active parallel invoker without OpenMP is ThreadPool. - LOG(WARNING) << "Unsupported invoker mode selected on Android. " - << "Falling back to ThreadPool"; + ABSL_LOG(WARNING) << "Unsupported invoker mode selected on Android. " + << "Falling back to ThreadPool"; flags_parallel_invoker_mode = PARALLEL_INVOKER_THREAD_POOL; #endif // _OPENMP } @@ -253,8 +254,8 @@ inline void CheckAndSetInvokerOptions() { flags_parallel_invoker_mode != PARALLEL_INVOKER_GCD && #endif // USE_PARALLEL_INVOKER_GCD flags_parallel_invoker_mode != PARALLEL_INVOKER_THREAD_POOL) { - LOG(WARNING) << "Unsupported invoker mode selected on iOS. " - << "Falling back to ThreadPool mode"; + ABSL_LOG(WARNING) << "Unsupported invoker mode selected on iOS. " + << "Falling back to ThreadPool mode"; flags_parallel_invoker_mode = PARALLEL_INVOKER_THREAD_POOL; } #endif // __APPLE__ || __EMSCRIPTEN__ @@ -267,17 +268,19 @@ inline void CheckAndSetInvokerOptions() { // to ThreadPool if not. if (flags_parallel_invoker_mode == PARALLEL_INVOKER_OPENMP) { #if !defined(_OPENMP) - LOG(ERROR) << "OpenMP invoker mode selected but not compiling with OpenMP " - << "enabled. Falling back to ThreadPool"; + ABSL_LOG(ERROR) + << "OpenMP invoker mode selected but not compiling with OpenMP " + << "enabled. Falling back to ThreadPool"; flags_parallel_invoker_mode = PARALLEL_INVOKER_THREAD_POOL; #endif // _OPENMP } #else // PARALLEL_INVOKER_ACTIVE if (flags_parallel_invoker_mode != PARALLEL_INVOKER_NONE) { - LOG(ERROR) << "Parallel execution requested but PARALLEL_INVOKER_ACTIVE " - << "compile flag is not set. Falling back to single threaded " - << "execution."; + ABSL_LOG(ERROR) + << "Parallel execution requested but PARALLEL_INVOKER_ACTIVE " + << "compile flag is not set. Falling back to single threaded " + << "execution."; flags_parallel_invoker_mode = PARALLEL_INVOKER_NONE; } #endif // PARALLEL_INVOKER_ACTIVE @@ -385,7 +388,7 @@ void ParallelFor(size_t start, size_t end, size_t grain_size, } case PARALLEL_INVOKER_MAX_VALUE: { - LOG(FATAL) << "Impossible."; + ABSL_LOG(FATAL) << "Impossible."; break; } } @@ -493,7 +496,7 @@ void ParallelFor2D(size_t start_row, size_t end_row, size_t start_col, } case PARALLEL_INVOKER_MAX_VALUE: { - LOG(FATAL) << "Impossible."; + ABSL_LOG(FATAL) << "Impossible."; break; } } diff --git a/mediapipe/util/tracking/push_pull_filtering.h b/mediapipe/util/tracking/push_pull_filtering.h index f9b2c6c3c..32010c947 100644 --- a/mediapipe/util/tracking/push_pull_filtering.h +++ b/mediapipe/util/tracking/push_pull_filtering.h @@ -33,6 +33,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/opencv_core_inc.h" #include "mediapipe/util/tracking/image_util.h" #include "mediapipe/util/tracking/push_pull_filtering.pb.h" @@ -309,7 +310,7 @@ PushPullFiltering::PushPullFiltering( weight_adjuster_(weight_adjuster) { border_ = BorderFromFilterType(filter_type); if (border_ < 0) { - LOG(FATAL) << "Unknown filter requested."; + ABSL_LOG(FATAL) << "Unknown filter requested."; } SetupFilters(); @@ -507,7 +508,7 @@ void PushPullFiltering::CopyNecessaryBorder( CopyMatBorder(mat); break; default: - LOG(FATAL) << "Unknown filter"; + ABSL_LOG(FATAL) << "Unknown filter"; } } @@ -867,7 +868,7 @@ void PushPullFiltering::PerformPushPullImpl( filter_weights = gaussian5_weights_.data(); break; default: - LOG(FATAL) << "Unknown filter requested."; + ABSL_LOG(FATAL) << "Unknown filter requested."; } const std::vector& mip_map = *mip_map_ptr; @@ -1131,7 +1132,7 @@ void PushPullFiltering::PushUpSampling( tap_weights, tap_offsets, tap_space_offsets); break; default: - LOG(FATAL) << "Filter unknown"; + ABSL_LOG(FATAL) << "Filter unknown"; } // Local copy for faster access. diff --git a/mediapipe/util/tracking/region_flow.cc b/mediapipe/util/tracking/region_flow.cc index cdd6bcd88..7ee7ba4a1 100644 --- a/mediapipe/util/tracking/region_flow.cc +++ b/mediapipe/util/tracking/region_flow.cc @@ -22,6 +22,7 @@ #include "absl/container/node_hash_map.h" #include "absl/container/node_hash_set.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "mediapipe/framework/port/integral_types.h" #include "mediapipe/util/tracking/measure_time.h" @@ -128,11 +129,11 @@ void ComputeRegionFlowFeatureTexturedness( PatchDescriptorColorStdevL1(feature->feature_descriptor()); if (feature_stdev_l1 < 0.0f) { - LOG_IF(WARNING, - []() { - static int k = 0; - return k++ < 2; - }()) + ABSL_LOG_IF(WARNING, + []() { + static int k = 0; + return k++ < 2; + }()) << "Feature descriptor does not contain variance information. Was " << "ComputeRegionFlowFeatureDescriptors called?"; continue; @@ -563,9 +564,10 @@ void LongFeatureStream::AddFeatures(const RegionFlowFeatureList& feature_list, bool check_connectivity, bool purge_non_present_features) { if (!feature_list.long_tracks()) { - LOG(ERROR) << "Feature stream should be used only used with long feature " - << "tracks. Ensure POLICY_LONG_FEATURE was used for " - << "RegionFlowComputation."; + ABSL_LOG(ERROR) + << "Feature stream should be used only used with long feature " + << "tracks. Ensure POLICY_LONG_FEATURE was used for " + << "RegionFlowComputation."; return; } @@ -575,8 +577,8 @@ void LongFeatureStream::AddFeatures(const RegionFlowFeatureList& feature_list, } if (std::abs(feature_list.match_frame()) != 1) { - LOG(ERROR) << "Only matching frames one frame from current one are " - << "supported"; + ABSL_LOG(ERROR) << "Only matching frames one frame from current one are " + << "supported"; return; } @@ -584,7 +586,7 @@ void LongFeatureStream::AddFeatures(const RegionFlowFeatureList& feature_list, absl::node_hash_set present_tracks; for (auto feature : feature_list.feature()) { // Copy feature. if (feature.track_id() < 0) { - LOG_IF(WARNING, []() { + ABSL_LOG_IF(WARNING, []() { static int k = 0; return k++ < 2; }()) << "Feature does not have a valid track id assigned. Ignoring."; @@ -700,7 +702,8 @@ std::vector LongFeatureStream::FlattenedTrackById(int id) const { void LongFeatureInfo::AddFeatures(const RegionFlowFeatureList& feature_list) { if (!feature_list.long_tracks()) { - LOG(ERROR) << "Passed feature list was not computed with long tracks. "; + ABSL_LOG(ERROR) + << "Passed feature list was not computed with long tracks. "; return; } diff --git a/mediapipe/util/tracking/region_flow.h b/mediapipe/util/tracking/region_flow.h index 2f9b34227..55aceee65 100644 --- a/mediapipe/util/tracking/region_flow.h +++ b/mediapipe/util/tracking/region_flow.h @@ -24,7 +24,7 @@ #include #include -#include "mediapipe/framework/port/logging.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/vector.h" #include "mediapipe/util/tracking/motion_models.h" #include "mediapipe/util/tracking/region_flow.pb.h" @@ -118,7 +118,7 @@ double RegionFlowFeatureIRLSSum(const RegionFlowFeatureList& feature_list); // Computes per region flow feature texturedness score. Score is within [0, 1], // where 0 means low texture and 1 high texture. Requires for each feature // descriptor to be computed (via ComputeRegionFlowFeatureDescriptors). If -// missing, LOG(WARNING) is issued and value defaults to 1. +// missing, ABSL_LOG(WARNING) is issued and value defaults to 1. // If use_15percent_as_max is set, score is scaled and threshold back to [0, 1] // such that 1 is assumed at 15% of maximum PER channel variance. void ComputeRegionFlowFeatureTexturedness( diff --git a/mediapipe/util/tracking/region_flow_computation.cc b/mediapipe/util/tracking/region_flow_computation.cc index b6704cc61..dde17048e 100644 --- a/mediapipe/util/tracking/region_flow_computation.cc +++ b/mediapipe/util/tracking/region_flow_computation.cc @@ -28,6 +28,7 @@ #include "Eigen/Core" #include "absl/container/flat_hash_map.h" #include "absl/container/node_hash_set.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/opencv_core_inc.h" @@ -490,9 +491,10 @@ struct RegionFlowComputation::LongTrackData { // Advance. ++next_track_id; if (next_track_id < 0) { - LOG(ERROR) << "Exhausted maximum possible ids. RegionFlowComputation " - << "instance lifetime is likely to be too long. Consider " - << "chunking the input."; + ABSL_LOG(ERROR) + << "Exhausted maximum possible ids. RegionFlowComputation " + << "instance lifetime is likely to be too long. Consider " + << "chunking the input."; next_track_id = 0; } @@ -683,7 +685,7 @@ RegionFlowComputation::RegionFlowComputation( frame_width_ += frame_width_ % 2; frame_height_ += frame_height_ % 2; - LOG(INFO) << "Using a downsampling scale of " << downsample_scale_; + ABSL_LOG(INFO) << "Using a downsampling scale of " << downsample_scale_; } // Make sure value is equal to local variable, in case someone uses that on @@ -720,9 +722,9 @@ RegionFlowComputation::RegionFlowComputation( switch (options_.tracking_options().tracking_policy()) { case TrackingOptions::POLICY_SINGLE_FRAME: if (options_.tracking_options().multi_frames_to_track() > 1) { - LOG(ERROR) << "TrackingOptions::multi_frames_to_track is > 1, " - << "but tracking_policy is set to POLICY_SINGLE_FRAME. " - << "Consider using POLICY_MULTI_FRAME instead."; + ABSL_LOG(ERROR) << "TrackingOptions::multi_frames_to_track is > 1, " + << "but tracking_policy is set to POLICY_SINGLE_FRAME. " + << "Consider using POLICY_MULTI_FRAME instead."; } frames_to_track_ = 1; @@ -733,18 +735,19 @@ RegionFlowComputation::RegionFlowComputation( break; case TrackingOptions::POLICY_LONG_TRACKS: if (options_.tracking_options().multi_frames_to_track() > 1) { - LOG(ERROR) << "TrackingOptions::multi_frames_to_track is > 1, " - << "but tracking_policy is set to POLICY_LONG_TRACKS. " - << "Use TrackingOptions::long_tracks_max_frames to set " - << "length of long feature tracks."; + ABSL_LOG(ERROR) << "TrackingOptions::multi_frames_to_track is > 1, " + << "but tracking_policy is set to POLICY_LONG_TRACKS. " + << "Use TrackingOptions::long_tracks_max_frames to set " + << "length of long feature tracks."; } if (options_.tracking_options().internal_tracking_direction() != TrackingOptions::FORWARD) { - LOG(ERROR) << "Long tracks are only supported if tracking direction " - << "is set to FORWARD. Adjusting direction to FORWARD. " - << "This does not affect the expected " - << "output_flow_direction"; + ABSL_LOG(ERROR) + << "Long tracks are only supported if tracking direction " + << "is set to FORWARD. Adjusting direction to FORWARD. " + << "This does not affect the expected " + << "output_flow_direction"; options_.mutable_tracking_options()->set_internal_tracking_direction( TrackingOptions::FORWARD); } @@ -764,8 +767,9 @@ RegionFlowComputation::RegionFlowComputation( use_cv_tracking_ = options_.tracking_options().use_cv_tracking_algorithm(); #if CV_MAJOR_VERSION < 3 if (use_cv_tracking_) { - LOG(WARNING) << "Compiled without OpenCV 3.0 but cv_tracking_algorithm " - << "was requested. Falling back to older algorithm"; + ABSL_LOG(WARNING) + << "Compiled without OpenCV 3.0 but cv_tracking_algorithm " + << "was requested. Falling back to older algorithm"; use_cv_tracking_ = false; } #endif @@ -963,15 +967,15 @@ bool RegionFlowComputation::InitFrame(const cv::Mat& source, options_.image_format() != RegionFlowComputationOptions::FORMAT_GRAYSCALE) { options_.set_image_format(RegionFlowComputationOptions::FORMAT_GRAYSCALE); - LOG(WARNING) << "#channels = 1, but image_format was not set to " - "FORMAT_GRAYSCALE. Assuming GRAYSCALE input."; + ABSL_LOG(WARNING) << "#channels = 1, but image_format was not set to " + "FORMAT_GRAYSCALE. Assuming GRAYSCALE input."; } // Convert image to grayscale. switch (options_.image_format()) { case RegionFlowComputationOptions::FORMAT_RGB: if (3 != source_ptr->channels()) { - LOG(ERROR) << "Expecting 3 channel input for RGB."; + ABSL_LOG(ERROR) << "Expecting 3 channel input for RGB."; return false; } cv::cvtColor(*source_ptr, dest_frame, cv::COLOR_RGB2GRAY); @@ -979,7 +983,7 @@ bool RegionFlowComputation::InitFrame(const cv::Mat& source, case RegionFlowComputationOptions::FORMAT_BGR: if (3 != source_ptr->channels()) { - LOG(ERROR) << "Expecting 3 channel input for BGR."; + ABSL_LOG(ERROR) << "Expecting 3 channel input for BGR."; return false; } cv::cvtColor(*source_ptr, dest_frame, cv::COLOR_BGR2GRAY); @@ -987,7 +991,7 @@ bool RegionFlowComputation::InitFrame(const cv::Mat& source, case RegionFlowComputationOptions::FORMAT_RGBA: if (4 != source_ptr->channels()) { - LOG(ERROR) << "Expecting 4 channel input for RGBA."; + ABSL_LOG(ERROR) << "Expecting 4 channel input for RGBA."; return false; } cv::cvtColor(*source_ptr, dest_frame, cv::COLOR_RGBA2GRAY); @@ -995,7 +999,7 @@ bool RegionFlowComputation::InitFrame(const cv::Mat& source, case RegionFlowComputationOptions::FORMAT_BGRA: if (4 != source_ptr->channels()) { - LOG(ERROR) << "Expecting 4 channel input for BGRA."; + ABSL_LOG(ERROR) << "Expecting 4 channel input for BGRA."; return false; } cv::cvtColor(*source_ptr, dest_frame, cv::COLOR_BGRA2GRAY); @@ -1003,7 +1007,7 @@ bool RegionFlowComputation::InitFrame(const cv::Mat& source, case RegionFlowComputationOptions::FORMAT_GRAYSCALE: if (1 != source_ptr->channels()) { - LOG(ERROR) << "Expecting 1 channel input for GRAYSCALE."; + ABSL_LOG(ERROR) << "Expecting 1 channel input for GRAYSCALE."; return false; } CHECK_EQ(1, source_ptr->channels()); @@ -1043,33 +1047,33 @@ bool RegionFlowComputation::AddImageAndTrack( if (options_.downsample_mode() == RegionFlowComputationOptions::DOWNSAMPLE_TO_INPUT_SIZE) { if (frame_width_ != source.cols || frame_height_ != source.rows) { - LOG(ERROR) << "Source input dimensions incompatible with " - << "DOWNSAMPLE_TO_INPUT_SIZE. frame_width_: " << frame_width_ - << ", source.cols: " << source.cols - << ", frame_height_: " << frame_height_ - << ", source.rows: " << source.rows; + ABSL_LOG(ERROR) << "Source input dimensions incompatible with " + << "DOWNSAMPLE_TO_INPUT_SIZE. frame_width_: " + << frame_width_ << ", source.cols: " << source.cols + << ", frame_height_: " << frame_height_ + << ", source.rows: " << source.rows; return false; } if (!source_mask.empty()) { if (frame_width_ != source_mask.cols || frame_height_ != source_mask.rows) { - LOG(ERROR) << "Input mask dimensions incompatible with " - << "DOWNSAMPLE_TO_INPUT_SIZE"; + ABSL_LOG(ERROR) << "Input mask dimensions incompatible with " + << "DOWNSAMPLE_TO_INPUT_SIZE"; return false; } } } else { if (original_width_ != source.cols || original_height_ != source.rows) { - LOG(ERROR) << "Source input dimensions differ from those specified " - << "in the constructor"; + ABSL_LOG(ERROR) << "Source input dimensions differ from those specified " + << "in the constructor"; return false; } if (!source_mask.empty()) { if (original_width_ != source_mask.cols || original_height_ != source_mask.rows) { - LOG(ERROR) << "Input mask dimensions incompatible with those " - << "specified in the constructor"; + ABSL_LOG(ERROR) << "Input mask dimensions incompatible with those " + << "specified in the constructor"; return false; } } @@ -1100,7 +1104,7 @@ bool RegionFlowComputation::AddImageAndTrack( } if (!InitFrame(source, source_mask, curr_data)) { - LOG(ERROR) << "Could not init frame."; + ABSL_LOG(ERROR) << "Could not init frame."; return false; } @@ -2098,8 +2102,8 @@ void RegionFlowComputation::WideBaselineMatchFeatures( TrackedFeatureList* results) { #if (defined(__ANDROID__) || defined(__APPLE__) || defined(__EMSCRIPTEN__)) && \ !defined(CV_WRAPPER_3X) - LOG(FATAL) << "Supported on only with OpenCV 3.0. " - << "Use bazel build flag : --define CV_WRAPPER=3X"; + ABSL_LOG(FATAL) << "Supported on only with OpenCV 3.0. " + << "Use bazel build flag : --define CV_WRAPPER=3X"; #else // (defined(__ANDROID__) || defined(__APPLE__) || // defined(__EMSCRIPTEN__)) && !defined(CV_WRAPPER_3X) results->clear(); @@ -2218,8 +2222,8 @@ void RegionFlowComputation::ExtractFeatures( const TrackedFeatureList* prev_result, FrameTrackingData* data) { MEASURE_TIME << "ExtractFeatures"; if (!options_.tracking_options().adaptive_good_features_to_track()) { - LOG(FATAL) << "Deprecated! Activate adaptive_good_features_to_track " - << "in TrackingOptions"; + ABSL_LOG(FATAL) << "Deprecated! Activate adaptive_good_features_to_track " + << "in TrackingOptions"; } // Check if features can simply be re-used. @@ -2373,11 +2377,11 @@ void RegionFlowComputation::ExtractFeatures( const int track_id = feature.track_id; if (track_id < 0) { // TODO: Use LOG_FIRST_N here. - LOG_IF(WARNING, - []() { - static int k = 0; - return k++ < 2; - }()) + ABSL_LOG_IF(WARNING, + []() { + static int k = 0; + return k++ < 2; + }()) << "Expecting an assigned track id, " << "skipping feature."; continue; @@ -2386,7 +2390,7 @@ void RegionFlowComputation::ExtractFeatures( // Skip features for which the track would get too long. const int start_frame = long_track_data_->StartFrameForId(track_id); if (start_frame < 0) { - LOG(ERROR) << "Id is not present, skipping feature."; + ABSL_LOG(ERROR) << "Id is not present, skipping feature."; continue; } @@ -2611,12 +2615,12 @@ void RegionFlowComputation::TrackFeatures(FrameTrackingData* from_data_ptr, cv_window_size, pyramid_levels_, cv_criteria, tracking_flags); } else { - LOG(ERROR) << "Tracking method unspecified."; + ABSL_LOG(ERROR) << "Tracking method unspecified."; return; } #endif } else { - LOG(ERROR) << "only cv tracking is supported."; + ABSL_LOG(ERROR) << "only cv tracking is supported."; return; } @@ -2791,7 +2795,7 @@ void RegionFlowComputation::TrackFeatures(FrameTrackingData* from_data_ptr, pyramid_levels_, cv_criteria, tracking_flags); #endif } else { - LOG(ERROR) << "only cv tracking is supported."; + ABSL_LOG(ERROR) << "only cv tracking is supported."; return; } diff --git a/mediapipe/util/tracking/region_flow_computation_test.cc b/mediapipe/util/tracking/region_flow_computation_test.cc index 435a8e200..e707356fc 100644 --- a/mediapipe/util/tracking/region_flow_computation_test.cc +++ b/mediapipe/util/tracking/region_flow_computation_test.cc @@ -22,11 +22,11 @@ #include #include "absl/flags/flag.h" +#include "absl/log/absl_log.h" #include "absl/time/clock.h" #include "mediapipe/framework/deps/file_path.h" #include "mediapipe/framework/port/file_helpers.h" #include "mediapipe/framework/port/gtest.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/opencv_core_inc.h" #include "mediapipe/framework/port/opencv_imgcodecs_inc.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" @@ -117,7 +117,7 @@ void RegionFlowComputationTest::MakeMovie( int seed = 900913; // google. if (absl::GetFlag(FLAGS_time_seed)) { seed = ToUnixMillis(absl::Now()) % (1 << 16); - LOG(INFO) << "Using time seed: " << seed; + ABSL_LOG(INFO) << "Using time seed: " << seed; } RandomEngine random(seed); diff --git a/mediapipe/util/tracking/streaming_buffer.cc b/mediapipe/util/tracking/streaming_buffer.cc index 2e5b0ac2f..169c76a04 100644 --- a/mediapipe/util/tracking/streaming_buffer.cc +++ b/mediapipe/util/tracking/streaming_buffer.cc @@ -14,6 +14,7 @@ #include "mediapipe/util/tracking/streaming_buffer.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" namespace mediapipe { @@ -94,9 +95,9 @@ bool StreamingBuffer::TruncateBuffer(bool flush) { const int buffer_elems_to_clear = std::min(elems_to_clear, buffer.size()); if (buffer_elems_to_clear < elems_to_clear) { - LOG(WARNING) << "For tag " << item.first << " got " - << elems_to_clear - buffer_elems_to_clear - << "fewer elements than buffer can hold."; + ABSL_LOG(WARNING) << "For tag " << item.first << " got " + << elems_to_clear - buffer_elems_to_clear + << "fewer elements than buffer can hold."; is_consistent = false; } buffer.erase(buffer.begin(), buffer.begin() + buffer_elems_to_clear); @@ -108,9 +109,9 @@ bool StreamingBuffer::TruncateBuffer(bool flush) { for (const auto& item : data_) { const auto& buffer = item.second; if (buffer.size() != remaining_elems) { - LOG(WARNING) << "After trunctation, for tag " << item.first << "got " - << buffer.size() << " elements, " - << "expected " << remaining_elems; + ABSL_LOG(WARNING) << "After trunctation, for tag " << item.first << "got " + << buffer.size() << " elements, " + << "expected " << remaining_elems; is_consistent = false; } } diff --git a/mediapipe/util/tracking/streaming_buffer.h b/mediapipe/util/tracking/streaming_buffer.h index 41aadbbb5..f7cbaa875 100644 --- a/mediapipe/util/tracking/streaming_buffer.h +++ b/mediapipe/util/tracking/streaming_buffer.h @@ -23,8 +23,9 @@ #include #include "absl/container/node_hash_map.h" +#include "absl/log/absl_log.h" +#include "absl/log/check.h" #include "absl/types/any.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/tool/type_util.h" namespace mediapipe { @@ -395,8 +396,8 @@ T* StreamingBuffer::GetMutableDatum(const std::string& tag, } else { const absl::any& packet = buffer[frame_index]; if (absl::any_cast>(&packet) == nullptr) { - LOG(ERROR) << "Stored item is not of requested type. " - << "Check data configuration."; + ABSL_LOG(ERROR) << "Stored item is not of requested type. " + << "Check data configuration."; return nullptr; } @@ -447,8 +448,8 @@ bool StreamingBuffer::IsInitialized(const std::string& tag) const { const PointerType* pointer = absl::any_cast>(&item); CHECK(pointer != nullptr); if (*pointer == nullptr) { - LOG(ERROR) << "Data for " << tag << " at frame " << idx - << " is not initialized."; + ABSL_LOG(ERROR) << "Data for " << tag << " at frame " << idx + << " is not initialized."; return false; } } @@ -463,8 +464,8 @@ std::vector StreamingBuffer::GetMutableDatumVector( std::vector result; for (const auto& packet : buffer) { if (absl::any_cast>(&packet) == nullptr) { - LOG(ERROR) << "Stored item is not of requested type. " - << "Check data configuration."; + ABSL_LOG(ERROR) << "Stored item is not of requested type. " + << "Check data configuration."; result.push_back(nullptr); } else { result.push_back( @@ -496,8 +497,8 @@ std::unique_ptr StreamingBuffer::ReleaseDatum(const std::string& tag, } else { const absl::any& packet = buffer[frame_index]; if (absl::any_cast>(&packet) == nullptr) { - LOG(ERROR) << "Stored item is not of requested type. " - << "Check data configuration."; + ABSL_LOG(ERROR) << "Stored item is not of requested type. " + << "Check data configuration."; return nullptr; } diff --git a/mediapipe/util/tracking/tone_estimation.cc b/mediapipe/util/tracking/tone_estimation.cc index 587fe96f2..2e83ced0a 100644 --- a/mediapipe/util/tracking/tone_estimation.cc +++ b/mediapipe/util/tracking/tone_estimation.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/util/tracking/motion_models.pb.h" #include "mediapipe/util/tracking/tone_models.pb.h" @@ -303,8 +304,8 @@ void ToneEstimation::EstimateGainBiasModel(int irls_iterations, const float det = gain_bias_model->gain_c1() * gain_bias_model->gain_c2() * gain_bias_model->gain_c3(); if (fabs(det) < 1e-6f) { - LOG(WARNING) << "Estimated gain bias model is not invertible. " - << "Falling back to identity model."; + ABSL_LOG(WARNING) << "Estimated gain bias model is not invertible. " + << "Falling back to identity model."; gain_bias_model->CopyFrom(GainBiasModel()); } } diff --git a/mediapipe/util/tracking/tone_models.h b/mediapipe/util/tracking/tone_models.h index 266257e1f..8d2d3c152 100644 --- a/mediapipe/util/tracking/tone_models.h +++ b/mediapipe/util/tracking/tone_models.h @@ -23,8 +23,8 @@ #include #include +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/integral_types.h" -#include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/opencv_core_inc.h" #include "mediapipe/framework/port/vector.h" #include "mediapipe/util/tracking/tone_models.pb.h" @@ -292,7 +292,7 @@ inline GainBiasModel ToneModelAdapter::InvertChecked( const float det = GainBiasModelAdapter::Determinant(model); if (fabs(det) < 1e-10f) { *success = false; - LOG(ERROR) << "Model not invertible."; + ABSL_LOG(ERROR) << "Model not invertible."; return GainBiasModel(); } @@ -338,7 +338,7 @@ inline float ToneModelAdapter::GetParameter( case 5: return model.bias_c3(); default: - LOG(FATAL) << "Unknown parameter requested."; + ABSL_LOG(FATAL) << "Unknown parameter requested."; } return 0.0f; @@ -413,7 +413,7 @@ inline AffineToneModel ToneModelAdapter::InvertChecked( cv::Mat inv_model_mat(4, 4, CV_64F, inv_data); if (cv::invert(model_mat, inv_model_mat) < 1e-10) { - LOG(ERROR) << "AffineToneModel not invertible, det is zero."; + ABSL_LOG(ERROR) << "AffineToneModel not invertible, det is zero."; *success = false; return AffineToneModel(); } @@ -467,7 +467,7 @@ inline float ToneModelAdapter::GetParameter( case 11: return model.g_23(); default: - LOG(FATAL) << "Unknown parameter requested."; + ABSL_LOG(FATAL) << "Unknown parameter requested."; } return 0.0f; diff --git a/mediapipe/util/tracking/tracking.cc b/mediapipe/util/tracking/tracking.cc index 50aaa940c..9c6b36507 100644 --- a/mediapipe/util/tracking/tracking.cc +++ b/mediapipe/util/tracking/tracking.cc @@ -25,6 +25,7 @@ #include "Eigen/Dense" #include "Eigen/SVD" #include "absl/algorithm/container.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "mediapipe/framework/port/logging.h" #include "mediapipe/framework/port/opencv_calib3d_inc.h" @@ -98,7 +99,7 @@ std::string TrackStatusToString(MotionBoxState::TrackStatus status) { case MotionBoxState::BOX_TRACKED_OUT_OF_BOUND: return "BOX_TRACKED_OUT_OF_BOUND"; } - LOG(FATAL) << "Should not happen."; + ABSL_LOG(FATAL) << "Should not happen."; return "UNKNOWN"; } @@ -160,7 +161,8 @@ bool LinearSimilarityL2Solve( const std::vector& weights, LinearSimilarityModel* model) { CHECK(model); if (motion_vectors.size() < 4) { - LOG(ERROR) << "Requiring at least 4 input vectors for sufficient solve."; + ABSL_LOG(ERROR) + << "Requiring at least 4 input vectors for sufficient solve."; return false; } @@ -377,7 +379,7 @@ void TransformQuadInMotionBoxState(const MotionBoxState& curr_pos, CHECK(next_pos != nullptr); if (!curr_pos.has_pos_x() || !curr_pos.has_pos_y() || !curr_pos.has_width() || !curr_pos.has_height()) { - LOG(ERROR) << "Previous box does not exist, cannot transform!"; + ABSL_LOG(ERROR) << "Previous box does not exist, cannot transform!"; return; } const int kQuadVerticesSize = 8; @@ -574,11 +576,11 @@ bool IsBoxValid(const MotionBoxState& state) { const float kMaxBoxWidth = 10000.0f; // as relative to normalized [0, 1] space if (state.width() > kMaxBoxWidth) { - LOG(ERROR) << "box width " << state.width() << " too big"; + ABSL_LOG(ERROR) << "box width " << state.width() << " too big"; return false; } if (state.height() > kMaxBoxHeight) { - LOG(ERROR) << "box height " << state.height() << " too big"; + ABSL_LOG(ERROR) << "box height " << state.height() << " too big"; return false; } @@ -656,7 +658,8 @@ bool MotionBoxLines(const MotionBoxState& state, const Vector2_f& scaling, if (box_lines->at(k).DotProd(Vector3_f(corners[(k + 1) % 4].x(), corners[(k + 1) % 4].y(), 1.0f)) >= 0.02f) { - LOG(ERROR) << "box is abnormal. Line equations don't satisfy constraint"; + ABSL_LOG(ERROR) + << "box is abnormal. Line equations don't satisfy constraint"; return false; } } @@ -758,7 +761,7 @@ void InitializeInliersOutliersInMotionBoxState(const TrackingData& tracking, std::array box_lines; if (!MotionBoxLines(*state, Vector2_f(1.0f, 1.0f), &box_lines)) { - LOG(ERROR) << "Error in computing MotionBoxLines."; + ABSL_LOG(ERROR) << "Error in computing MotionBoxLines."; return; } @@ -865,7 +868,7 @@ void InitializePnpHomographyInMotionBoxState( constexpr float kEpsilon = 1e-6f; const float denominator = u2_u0 * v3_v1 - v2_v0 * u3_u1; if (std::abs(denominator) < kEpsilon) { - LOG(WARNING) << "Zero denominator. Failed calculating aspect ratio."; + ABSL_LOG(WARNING) << "Zero denominator. Failed calculating aspect ratio."; return; } @@ -882,7 +885,7 @@ void InitializePnpHomographyInMotionBoxState( std::vector corners(kQuadCornersSize); for (int i = 0; i < kQuadCornersSize; ++i) { if (s[0] <= 0) { - LOG(WARNING) << "Negative scale. Failed calculating aspect ratio."; + ABSL_LOG(WARNING) << "Negative scale. Failed calculating aspect ratio."; return; } corners[i] = @@ -894,7 +897,7 @@ void InitializePnpHomographyInMotionBoxState( const float height_norm = height_edge.Norm(); const float width_norm = width_edge.Norm(); if (height_norm < kEpsilon || width_norm < kEpsilon) { - LOG(WARNING) + ABSL_LOG(WARNING) << "abnormal 3d quadrangle. Failed calculating aspect ratio."; return; } @@ -902,7 +905,7 @@ void InitializePnpHomographyInMotionBoxState( constexpr float kMaxCosAngle = 0.258819; // which is cos(75 deg) if (width_edge.DotProd(height_edge) / height_norm / width_norm > kMaxCosAngle) { - LOG(WARNING) + ABSL_LOG(WARNING) << "abnormal 3d quadrangle. Failed calculating aspect ratio."; return; } @@ -1003,8 +1006,8 @@ bool MotionBox::TrackStep(int from_frame, const MotionVectorFrame& motion_vectors, bool forward) { if (!TrackableFromFrame(from_frame)) { - LOG(WARNING) << "Tracking requested for initial position that is not " - << "trackable."; + ABSL_LOG(WARNING) << "Tracking requested for initial position that is not " + << "trackable."; return false; } const int queue_pos = from_frame - queue_start_; @@ -1072,7 +1075,7 @@ bool MotionBox::TrackStep(int from_frame, } if (num_track_errors >= options_.max_track_failures()) { - LOG_IF(INFO, print_motion_box_warnings_) + ABSL_LOG_IF(INFO, print_motion_box_warnings_) << "Tracking failed during max track failure " << "verification."; states_[new_pos].set_track_status(MotionBoxState::BOX_UNTRACKED); @@ -1105,7 +1108,7 @@ bool MotionBox::TrackStep(int from_frame, } if (num_track_errors >= options_.max_track_failures()) { - LOG_IF(INFO, print_motion_box_warnings_) + ABSL_LOG_IF(INFO, print_motion_box_warnings_) << "Tracking failed during max track failure " << "verification."; states_[new_pos].set_track_status(MotionBoxState::BOX_UNTRACKED); @@ -1117,7 +1120,7 @@ bool MotionBox::TrackStep(int from_frame, // Signal track success. return true; } else { - LOG_IF(WARNING, print_motion_box_warnings_) + ABSL_LOG_IF(WARNING, print_motion_box_warnings_) << "Tracking error at " << from_frame << " status : " << TrackStatusToString(new_state.track_status()); return false; @@ -1582,8 +1585,9 @@ bool MotionBox::GetVectorsAndWeights( // The four lines of the rotated and scaled box. std::array box_lines; if (!MotionBoxLines(box_state, Vector2_f(1.0f, 1.0f), &box_lines)) { - LOG(ERROR) << "Error in computing MotionBoxLines. Return 0 good inits and " - "continued inliers"; + ABSL_LOG(ERROR) + << "Error in computing MotionBoxLines. Return 0 good inits and " + "continued inliers"; return false; } @@ -1965,8 +1969,8 @@ void MotionBox::EstimateObjectMotion( if (!ObjectMotionValidator::IsValidSimilarity( *object_similarity, options_.box_similarity_max_scale(), options_.box_similarity_max_rotation())) { - LOG(WARNING) << "Unstable similarity model - falling back to " - << "translation."; + ABSL_LOG(WARNING) << "Unstable similarity model - falling back to " + << "translation."; *object_similarity = LinearSimilarityAdapter::Embed(translation_model); } else { @@ -1985,8 +1989,8 @@ void MotionBox::EstimateObjectMotion( if (!ObjectMotionValidator::IsValidHomography( *object_homography, options_.quad_homography_max_scale(), options_.quad_homography_max_rotation())) { - LOG(WARNING) << "Unstable homography model - falling back to " - << "translation."; + ABSL_LOG(WARNING) << "Unstable homography model - falling back to " + << "translation."; *object_homography = HomographyAdapter::Embed(translation_model); } else { weights->swap(similarity_weights); @@ -2663,7 +2667,7 @@ void MotionBox::TrackStepImplDeNormalized( *next_pos = curr_pos; if (!IsBoxValid(curr_pos)) { - LOG(ERROR) << "curr_pos is not a valid box. Stop tracking!"; + ABSL_LOG(ERROR) << "curr_pos is not a valid box. Stop tracking!"; next_pos->set_track_status(MotionBoxState::BOX_UNTRACKED); return; } @@ -2725,7 +2729,7 @@ void MotionBox::TrackStepImplDeNormalized( (ObjectMotionValidator::IsQuadOutOfFov( next_pos->quad(), Vector2_f(domain_x, domain_y)) || !ObjectMotionValidator::IsValidQuad(next_pos->quad()))) { - LOG(ERROR) << "Quad is out of fov or not convex. Cancel tracking."; + ABSL_LOG(ERROR) << "Quad is out of fov or not convex. Cancel tracking."; next_pos->set_track_status(MotionBoxState::BOX_UNTRACKED); return; } @@ -2763,7 +2767,7 @@ void MotionBox::TrackStepImplDeNormalized( temporal_scale, expand_mag, history, &vectors, &prior_weights, &num_good_inits, &num_cont_inliers); if (!get_vec_weights_status) { - LOG(ERROR) << "error in GetVectorsAndWeights. Terminate tracking."; + ABSL_LOG(ERROR) << "error in GetVectorsAndWeights. Terminate tracking."; next_pos->set_track_status(MotionBoxState::BOX_UNTRACKED); return; } @@ -2783,7 +2787,7 @@ void MotionBox::TrackStepImplDeNormalized( if (next_pos->has_quad() && !ObjectMotionValidator::IsValidQuad(next_pos->quad())) { - LOG(ERROR) << "Quad is not convex. Cancel tracking."; + ABSL_LOG(ERROR) << "Quad is not convex. Cancel tracking."; next_pos->set_track_status(MotionBoxState::BOX_UNTRACKED); return; } @@ -2952,8 +2956,8 @@ void MotionBox::TrackStepImplDeNormalized( options_.cancel_tracking_with_occlusion_options() .min_motion_continuity()) { next_pos->set_track_status(MotionBoxState::BOX_UNTRACKED); - LOG(INFO) << "Occlusion detected. continued_inlier_fraction: " - << continued_inlier_fraction << " too low. Stop tracking"; + ABSL_LOG(INFO) << "Occlusion detected. continued_inlier_fraction: " + << continued_inlier_fraction << " too low. Stop tracking"; return; } @@ -2981,7 +2985,7 @@ void MotionBox::TrackStepImplDeNormalized( // Assign full confidence on first frame, otherwise all other stats // are zero and there is no way to compute. next_pos->set_tracking_confidence(1.0f); - LOG(INFO) << "no history. confidence : 1.0"; + ABSL_LOG(INFO) << "no history. confidence : 1.0"; } else { next_pos->set_tracking_confidence(ComputeTrackingConfidence(*next_pos)); VLOG(1) << "confidence: " << next_pos->tracking_confidence(); @@ -3018,9 +3022,9 @@ void MotionBox::TrackStepImplDeNormalized( inlier_ratio < options_.cancel_tracking_with_occlusion_options() .min_inlier_ratio()) { next_pos->set_track_status(MotionBoxState::BOX_UNTRACKED); - LOG(INFO) << "inlier_ratio: " << inlier_ratio - << " too small. Stop tracking. inlier_max: " << inlier_max - << ". length in history: " << history.size(); + ABSL_LOG(INFO) << "inlier_ratio: " << inlier_ratio + << " too small. Stop tracking. inlier_max: " << inlier_max + << ". length in history: " << history.size(); return; } @@ -3052,7 +3056,7 @@ void MotionBox::TrackStepImplDeNormalized( if (next_pos->has_quad() && !ObjectMotionValidator::IsValidQuad(next_pos->quad())) { - LOG(ERROR) << "Quad is not convex. Cancel tracking."; + ABSL_LOG(ERROR) << "Quad is not convex. Cancel tracking."; next_pos->set_track_status(MotionBoxState::BOX_UNTRACKED); return; } @@ -3167,8 +3171,9 @@ void MotionVectorFrameFromTrackingData(const TrackingData& tracking_data, const auto& motion_data = tracking_data.motion_data(); float aspect_ratio = tracking_data.frame_aspect(); if (aspect_ratio < 0.1 || aspect_ratio > 10.0f) { - LOG(ERROR) << "Aspect ratio : " << aspect_ratio << " is out of bounds. " - << "Resetting to 1.0."; + ABSL_LOG(ERROR) << "Aspect ratio : " << aspect_ratio + << " is out of bounds. " + << "Resetting to 1.0."; aspect_ratio = 1.0f; } @@ -3245,13 +3250,14 @@ void FeatureAndDescriptorFromTrackingData( const auto& motion_data = tracking_data.motion_data(); float aspect_ratio = tracking_data.frame_aspect(); if (aspect_ratio < 0.1 || aspect_ratio > 10.0f) { - LOG(ERROR) << "Aspect ratio : " << aspect_ratio << " is out of bounds. " - << "Resetting to 1.0."; + ABSL_LOG(ERROR) << "Aspect ratio : " << aspect_ratio + << " is out of bounds. " + << "Resetting to 1.0."; aspect_ratio = 1.0f; } if (motion_data.feature_descriptors_size() == 0) { - LOG(WARNING) << "Feature descriptors not exist"; + ABSL_LOG(WARNING) << "Feature descriptors not exist"; return; } @@ -3347,7 +3353,7 @@ void GetFeatureIndicesWithinBox(const std::vector& features, if (features.empty()) return; std::array box_lines; if (!MotionBoxLines(box_state, box_scaling, &box_lines)) { - LOG(ERROR) << "Error in computing MotionBoxLines."; + ABSL_LOG(ERROR) << "Error in computing MotionBoxLines."; return; } diff --git a/mediapipe/util/tracking/tracking.h b/mediapipe/util/tracking/tracking.h index 4d3343f58..5f2d01038 100644 --- a/mediapipe/util/tracking/tracking.h +++ b/mediapipe/util/tracking/tracking.h @@ -26,6 +26,7 @@ #include #include "absl/container/flat_hash_set.h" +#include "absl/log/absl_log.h" #include "mediapipe/framework/port/vector.h" #include "mediapipe/util/tracking/flow_packager.pb.h" #include "mediapipe/util/tracking/motion_models.h" @@ -314,8 +315,8 @@ class MotionBox { MotionBoxState StateAtFrame(int frame) const { if (frame < queue_start_ || frame >= queue_start_ + static_cast(states_.size())) { - LOG(ERROR) << "Requesting state at unknown frame " << frame - << ". Returning UNTRACKED."; + ABSL_LOG(ERROR) << "Requesting state at unknown frame " << frame + << ". Returning UNTRACKED."; MotionBoxState invalid; invalid.set_track_status(MotionBoxState::BOX_UNTRACKED); return invalid; @@ -560,7 +561,7 @@ class MotionBox { // Filter out abnormal homography. Otherwise the determinant of // projected affine matrix will be negative. if (!IsInverseStable(homography)) { - LOG(WARNING) << "Homography matrix is not stable."; + ABSL_LOG(WARNING) << "Homography matrix is not stable."; return false; } diff --git a/mediapipe/util/tracking/tracking_visualization_utilities.cc b/mediapipe/util/tracking/tracking_visualization_utilities.cc index 0b5860879..be3572d62 100644 --- a/mediapipe/util/tracking/tracking_visualization_utilities.cc +++ b/mediapipe/util/tracking/tracking_visualization_utilities.cc @@ -14,6 +14,7 @@ #include "mediapipe/util/tracking/tracking_visualization_utilities.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" #include "mediapipe/util/tracking/box_tracker.h" @@ -129,7 +130,7 @@ void RenderState(const MotionBoxState& box_state, bool print_stats, cv::putText(*frame, lock_text, cv::Point(top_left.x(), top_left.y() - 5), cv::FONT_HERSHEY_PLAIN, 0.8, lock_color); #else - LOG(FATAL) << "Code stripped out because of NO_RENDERING"; + ABSL_LOG(FATAL) << "Code stripped out because of NO_RENDERING"; #endif } @@ -169,7 +170,7 @@ void RenderInternalState(const MotionBoxInternalState& internal, cv::circle(*frame, p1, 2.0, color_scaled, 1); } #else - LOG(FATAL) << "Code stripped out because of NO_RENDERING"; + ABSL_LOG(FATAL) << "Code stripped out because of NO_RENDERING"; #endif } @@ -199,7 +200,7 @@ void RenderTrackingData(const TrackingData& data, cv::Mat* mat, antialiasing ? cv::LINE_AA : 8); } #else - LOG(FATAL) << "Code stripped out because of NO_RENDERING"; + ABSL_LOG(FATAL) << "Code stripped out because of NO_RENDERING"; #endif } @@ -217,7 +218,7 @@ void RenderBox(const TimedBoxProto& box_proto, cv::Mat* mat) { 4); } #else - LOG(FATAL) << "Code stripped out because of NO_RENDERING"; + ABSL_LOG(FATAL) << "Code stripped out because of NO_RENDERING"; #endif }