Use ABSL_LOG in MediaPipe.
This is needed in Chrome builds to avoid collisions with its own LOG. PiperOrigin-RevId: 561436864
This commit is contained in:
committed by
Copybara-Service
parent
f60da2120d
commit
c92570f844
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#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<bool>(true).release())
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
#include "mediapipe/framework/port/status.h"
|
||||
|
||||
namespace mediapipe {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
|
||||
#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"
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#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();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -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<mediapipe::CalculatorGraphConfig>(
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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<mediapipe::CalculatorGraphConfig>(
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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<std::string>();
|
||||
ABSL_LOG(INFO) << packet.Get<std::string>();
|
||||
}
|
||||
return graph.WaitUntilDone();
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -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<std::string> ReadFileToString(const std::string& file_path) {
|
||||
}
|
||||
|
||||
absl::Status ProcessImage(std::unique_ptr<mediapipe::CalculatorGraph> 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<mediapipe::CalculatorGraph> 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<mediapipe::CalculatorGraph> 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<mediapipe::CalculatorGraphConfig>(
|
||||
calculator_graph_config_contents);
|
||||
|
||||
LOG(INFO) << "Initialize the calculator graph.";
|
||||
ABSL_LOG(INFO) << "Initialize the calculator graph.";
|
||||
std::unique_ptr<mediapipe::CalculatorGraph> graph =
|
||||
absl::make_unique<mediapipe::CalculatorGraph>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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<mediapipe::CalculatorGraphConfig>(
|
||||
calculator_graph_config_contents);
|
||||
@@ -61,12 +62,12 @@ absl::Status RunMPPGraph() {
|
||||
input_side_packets[name_and_value[0]] =
|
||||
mediapipe::MakePacket<std::string>(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<std::string> 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;
|
||||
}
|
||||
|
||||
@@ -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<mediapipe::CalculatorGraphConfig>(
|
||||
calculator_graph_config_contents);
|
||||
@@ -119,14 +120,14 @@ absl::Status RunMPPGraph() {
|
||||
mediapipe::MakePacket<std::string>(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;
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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<mediapipe::CalculatorGraphConfig>(
|
||||
calculator_graph_config_contents);
|
||||
@@ -102,12 +103,12 @@ absl::Status RunMPPGraph() {
|
||||
input_side_packets["vggish_pca_projection_matrix"] =
|
||||
mediapipe::MakePacket<mediapipe::Matrix>(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<std::string> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user