Convert CHECK macro to ABSL_CHECK.
Chrome can't use Absl's CHECK because of collisions with its own version. PiperOrigin-RevId: 561740965
This commit is contained in:
parent
30802b80cd
commit
7c2d654d67
|
@ -146,6 +146,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/util:time_series_util",
|
"//mediapipe/util:time_series_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_audio_tools//audio/dsp/mfcc",
|
"@com_google_audio_tools//audio/dsp/mfcc",
|
||||||
"@eigen_archive//:eigen3",
|
"@eigen_archive//:eigen3",
|
||||||
|
@ -165,6 +166,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
"//mediapipe/util:time_series_util",
|
"//mediapipe/util:time_series_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_audio_tools//audio/dsp:resampler",
|
"@com_google_audio_tools//audio/dsp:resampler",
|
||||||
|
@ -186,6 +188,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:core_proto",
|
"//mediapipe/framework/port:core_proto",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/util:time_series_util",
|
"//mediapipe/util:time_series_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
)
|
)
|
||||||
|
@ -225,6 +228,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/util:time_series_util",
|
"//mediapipe/util:time_series_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_audio_tools//audio/dsp:window_functions",
|
"@com_google_audio_tools//audio/dsp:window_functions",
|
||||||
"@eigen_archive//:eigen3",
|
"@eigen_archive//:eigen3",
|
||||||
],
|
],
|
||||||
|
@ -329,6 +333,7 @@ cc_binary(
|
||||||
"//mediapipe/framework:packet",
|
"//mediapipe/framework:packet",
|
||||||
"//mediapipe/framework/formats:matrix",
|
"//mediapipe/framework/formats:matrix",
|
||||||
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_benchmark//:benchmark",
|
"@com_google_benchmark//:benchmark",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Eigen/Core"
|
#include "Eigen/Core"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "absl/strings/substitute.h"
|
#include "absl/strings/substitute.h"
|
||||||
|
@ -138,7 +139,7 @@ absl::Status FramewiseTransformCalculatorBase::Process(CalculatorContext* cc) {
|
||||||
TransformFrame(input_frame, &output_frame);
|
TransformFrame(input_frame, &output_frame);
|
||||||
|
|
||||||
// Copy output from vector<float> to Eigen::Vector.
|
// Copy output from vector<float> to Eigen::Vector.
|
||||||
CHECK_EQ(output_frame.size(), num_output_channels_);
|
ABSL_CHECK_EQ(output_frame.size(), num_output_channels_);
|
||||||
Eigen::Map<const Eigen::MatrixXd> output_frame_map(&output_frame[0],
|
Eigen::Map<const Eigen::MatrixXd> output_frame_map(&output_frame[0],
|
||||||
output_frame.size(), 1);
|
output_frame.size(), 1);
|
||||||
output->col(frame) = output_frame_map.cast<float>();
|
output->col(frame) = output_frame_map.cast<float>();
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "mediapipe/calculators/audio/rational_factor_resample_calculator.h"
|
#include "mediapipe/calculators/audio/rational_factor_resample_calculator.h"
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "audio/dsp/resampler_q.h"
|
#include "audio/dsp/resampler_q.h"
|
||||||
|
|
||||||
|
@ -46,9 +47,9 @@ void CopyVectorToChannel(const std::vector<float>& vec, Matrix* matrix,
|
||||||
if (matrix->cols() == 0) {
|
if (matrix->cols() == 0) {
|
||||||
matrix->resize(matrix->rows(), vec.size());
|
matrix->resize(matrix->rows(), vec.size());
|
||||||
} else {
|
} else {
|
||||||
CHECK_EQ(vec.size(), matrix->cols());
|
ABSL_CHECK_EQ(vec.size(), matrix->cols());
|
||||||
}
|
}
|
||||||
CHECK_LT(channel, matrix->rows());
|
ABSL_CHECK_LT(channel, matrix->rows());
|
||||||
matrix->row(channel) =
|
matrix->row(channel) =
|
||||||
Eigen::Map<const Eigen::ArrayXf>(vec.data(), vec.size());
|
Eigen::Map<const Eigen::ArrayXf>(vec.data(), vec.size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/audio/stabilized_log_calculator.pb.h"
|
#include "mediapipe/calculators/audio/stabilized_log_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/matrix.h"
|
#include "mediapipe/framework/formats/matrix.h"
|
||||||
|
@ -59,7 +60,7 @@ class StabilizedLogCalculator : public CalculatorBase {
|
||||||
output_scale_ = stabilized_log_calculator_options.output_scale();
|
output_scale_ = stabilized_log_calculator_options.output_scale();
|
||||||
check_nonnegativity_ =
|
check_nonnegativity_ =
|
||||||
stabilized_log_calculator_options.check_nonnegativity();
|
stabilized_log_calculator_options.check_nonnegativity();
|
||||||
CHECK_GE(stabilizer_, 0.0)
|
ABSL_CHECK_GE(stabilizer_, 0.0)
|
||||||
<< "stabilizer must be >= 0.0, received a value of " << stabilizer_;
|
<< "stabilizer must be >= 0.0, received a value of " << stabilizer_;
|
||||||
|
|
||||||
// If the input packets have a header, propagate the header to the output.
|
// If the input packets have a header, propagate the header to the output.
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Eigen/Core"
|
#include "Eigen/Core"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "audio/dsp/window_functions.h"
|
#include "audio/dsp/window_functions.h"
|
||||||
#include "mediapipe/calculators/audio/time_series_framer_calculator.pb.h"
|
#include "mediapipe/calculators/audio/time_series_framer_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -104,7 +105,7 @@ class TimeSeriesFramerCalculator : public CalculatorBase {
|
||||||
// All numbers are in input samples.
|
// All numbers are in input samples.
|
||||||
const int64_t current_output_frame_start = static_cast<int64_t>(
|
const int64_t current_output_frame_start = static_cast<int64_t>(
|
||||||
round(cumulative_output_frames_ * average_frame_step_samples_));
|
round(cumulative_output_frames_ * average_frame_step_samples_));
|
||||||
CHECK_EQ(current_output_frame_start, cumulative_completed_samples_);
|
ABSL_CHECK_EQ(current_output_frame_start, cumulative_completed_samples_);
|
||||||
const int64_t next_output_frame_start = static_cast<int64_t>(
|
const int64_t next_output_frame_start = static_cast<int64_t>(
|
||||||
round((cumulative_output_frames_ + 1) * average_frame_step_samples_));
|
round((cumulative_output_frames_ + 1) * average_frame_step_samples_));
|
||||||
return next_output_frame_start - current_output_frame_start;
|
return next_output_frame_start - current_output_frame_start;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "benchmark/benchmark.h"
|
#include "benchmark/benchmark.h"
|
||||||
#include "mediapipe/calculators/audio/time_series_framer_calculator.pb.h"
|
#include "mediapipe/calculators/audio/time_series_framer_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -70,7 +71,7 @@ void BM_TimeSeriesFramerCalculator(benchmark::State& state) {
|
||||||
}
|
}
|
||||||
// Initialize graph.
|
// Initialize graph.
|
||||||
mediapipe::CalculatorGraph graph;
|
mediapipe::CalculatorGraph graph;
|
||||||
CHECK_OK(graph.Initialize(config));
|
ABSL_CHECK_OK(graph.Initialize(config));
|
||||||
// Prepare input header.
|
// Prepare input header.
|
||||||
auto header = std::make_unique<mediapipe::TimeSeriesHeader>();
|
auto header = std::make_unique<mediapipe::TimeSeriesHeader>();
|
||||||
header->set_sample_rate(kSampleRate);
|
header->set_sample_rate(kSampleRate);
|
||||||
|
@ -78,13 +79,13 @@ void BM_TimeSeriesFramerCalculator(benchmark::State& state) {
|
||||||
|
|
||||||
state.ResumeTiming(); // Resume benchmark timing.
|
state.ResumeTiming(); // Resume benchmark timing.
|
||||||
|
|
||||||
CHECK_OK(graph.StartRun({}, {{"input", Adopt(header.release())}}));
|
ABSL_CHECK_OK(graph.StartRun({}, {{"input", Adopt(header.release())}}));
|
||||||
for (auto& packet : input_packets) {
|
for (auto& packet : input_packets) {
|
||||||
CHECK_OK(graph.AddPacketToInputStream("input", packet));
|
ABSL_CHECK_OK(graph.AddPacketToInputStream("input", packet));
|
||||||
}
|
}
|
||||||
CHECK(!graph.HasError());
|
ABSL_CHECK(!graph.HasError());
|
||||||
CHECK_OK(graph.CloseAllInputStreams());
|
ABSL_CHECK_OK(graph.CloseAllInputStreams());
|
||||||
CHECK_OK(graph.WaitUntilIdle());
|
ABSL_CHECK_OK(graph.WaitUntilIdle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BENCHMARK(BM_TimeSeriesFramerCalculator);
|
BENCHMARK(BM_TimeSeriesFramerCalculator);
|
||||||
|
|
|
@ -582,6 +582,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:options_util",
|
"//mediapipe/framework/tool:options_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
)
|
)
|
||||||
|
@ -597,6 +598,7 @@ cc_test(
|
||||||
"//mediapipe/framework/formats:video_stream_header",
|
"//mediapipe/framework/formats:video_stream_header",
|
||||||
"//mediapipe/framework/port:gtest_main",
|
"//mediapipe/framework/port:gtest_main",
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -780,6 +782,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:options_util",
|
"//mediapipe/framework/tool:options_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
|
@ -836,6 +839,7 @@ cc_test(
|
||||||
"//mediapipe/framework/port:gtest_main",
|
"//mediapipe/framework/port:gtest_main",
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/framework/tool:validate_type",
|
"//mediapipe/framework/tool:validate_type",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@eigen_archive//:eigen3",
|
"@eigen_archive//:eigen3",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Eigen/Core"
|
#include "Eigen/Core"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/calculator_runner.h"
|
#include "mediapipe/framework/calculator_runner.h"
|
||||||
#include "mediapipe/framework/formats/matrix.h"
|
#include "mediapipe/framework/formats/matrix.h"
|
||||||
|
@ -209,7 +210,7 @@ TEST(MatrixMultiplyCalculatorTest, Multiply) {
|
||||||
MatrixFromTextProto(kSamplesText, &samples);
|
MatrixFromTextProto(kSamplesText, &samples);
|
||||||
Matrix expected;
|
Matrix expected;
|
||||||
MatrixFromTextProto(kExpectedText, &expected);
|
MatrixFromTextProto(kExpectedText, &expected);
|
||||||
CHECK_EQ(samples.cols(), expected.cols());
|
ABSL_CHECK_EQ(samples.cols(), expected.cols());
|
||||||
|
|
||||||
for (int i = 0; i < samples.cols(); ++i) {
|
for (int i = 0; i < samples.cols(); ++i) {
|
||||||
// Take a column from samples and produce a packet with just that
|
// Take a column from samples and produce a packet with just that
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -202,15 +203,15 @@ PacketResamplerCalculator::GetSamplingStrategy(
|
||||||
|
|
||||||
Timestamp PacketResamplerCalculator::PeriodIndexToTimestamp(
|
Timestamp PacketResamplerCalculator::PeriodIndexToTimestamp(
|
||||||
int64_t index) const {
|
int64_t index) const {
|
||||||
CHECK_EQ(jitter_, 0.0);
|
ABSL_CHECK_EQ(jitter_, 0.0);
|
||||||
CHECK_NE(first_timestamp_, Timestamp::Unset());
|
ABSL_CHECK_NE(first_timestamp_, Timestamp::Unset());
|
||||||
return first_timestamp_ + TimestampDiffFromSeconds(index / frame_rate_);
|
return first_timestamp_ + TimestampDiffFromSeconds(index / frame_rate_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t PacketResamplerCalculator::TimestampToPeriodIndex(
|
int64_t PacketResamplerCalculator::TimestampToPeriodIndex(
|
||||||
Timestamp timestamp) const {
|
Timestamp timestamp) const {
|
||||||
CHECK_EQ(jitter_, 0.0);
|
ABSL_CHECK_EQ(jitter_, 0.0);
|
||||||
CHECK_NE(first_timestamp_, Timestamp::Unset());
|
ABSL_CHECK_NE(first_timestamp_, Timestamp::Unset());
|
||||||
return MathUtil::SafeRound<int64_t, double>(
|
return MathUtil::SafeRound<int64_t, double>(
|
||||||
(timestamp - first_timestamp_).Seconds() * frame_rate_);
|
(timestamp - first_timestamp_).Seconds() * frame_rate_);
|
||||||
}
|
}
|
||||||
|
@ -344,8 +345,8 @@ void LegacyJitterWithReflectionStrategy::UpdateNextOutputTimestampWithJitter() {
|
||||||
next_output_timestamp_ = Timestamp(ReflectBetween(
|
next_output_timestamp_ = Timestamp(ReflectBetween(
|
||||||
next_output_timestamp_.Value(), next_output_timestamp_min_.Value(),
|
next_output_timestamp_.Value(), next_output_timestamp_min_.Value(),
|
||||||
next_output_timestamp_max_.Value()));
|
next_output_timestamp_max_.Value()));
|
||||||
CHECK_GE(next_output_timestamp_, next_output_timestamp_min_);
|
ABSL_CHECK_GE(next_output_timestamp_, next_output_timestamp_min_);
|
||||||
CHECK_LT(next_output_timestamp_, next_output_timestamp_max_);
|
ABSL_CHECK_LT(next_output_timestamp_, next_output_timestamp_max_);
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status ReproducibleJitterWithReflectionStrategy::Open(
|
absl::Status ReproducibleJitterWithReflectionStrategy::Open(
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <cmath> // for ceil
|
#include <cmath> // for ceil
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/core/packet_thinner_calculator.pb.h"
|
#include "mediapipe/calculators/core/packet_thinner_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_context.h"
|
#include "mediapipe/framework/calculator_context.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -160,8 +161,8 @@ absl::Status PacketThinnerCalculator::Open(CalculatorContext* cc) {
|
||||||
|
|
||||||
thinner_type_ = options.thinner_type();
|
thinner_type_ = options.thinner_type();
|
||||||
// This check enables us to assume only two thinner types exist in Process()
|
// This check enables us to assume only two thinner types exist in Process()
|
||||||
CHECK(thinner_type_ == PacketThinnerCalculatorOptions::ASYNC ||
|
ABSL_CHECK(thinner_type_ == PacketThinnerCalculatorOptions::ASYNC ||
|
||||||
thinner_type_ == PacketThinnerCalculatorOptions::SYNC)
|
thinner_type_ == PacketThinnerCalculatorOptions::SYNC)
|
||||||
<< "Unsupported thinner type.";
|
<< "Unsupported thinner type.";
|
||||||
|
|
||||||
if (thinner_type_ == PacketThinnerCalculatorOptions::ASYNC) {
|
if (thinner_type_ == PacketThinnerCalculatorOptions::ASYNC) {
|
||||||
|
@ -177,7 +178,8 @@ absl::Status PacketThinnerCalculator::Open(CalculatorContext* cc) {
|
||||||
} else {
|
} else {
|
||||||
period_ = TimestampDiff(options.period());
|
period_ = TimestampDiff(options.period());
|
||||||
}
|
}
|
||||||
CHECK_LT(TimestampDiff(0), period_) << "Specified period must be positive.";
|
ABSL_CHECK_LT(TimestampDiff(0), period_)
|
||||||
|
<< "Specified period must be positive.";
|
||||||
|
|
||||||
if (options.has_start_time()) {
|
if (options.has_start_time()) {
|
||||||
start_time_ = Timestamp(options.start_time());
|
start_time_ = Timestamp(options.start_time());
|
||||||
|
@ -189,7 +191,7 @@ absl::Status PacketThinnerCalculator::Open(CalculatorContext* cc) {
|
||||||
|
|
||||||
end_time_ =
|
end_time_ =
|
||||||
options.has_end_time() ? Timestamp(options.end_time()) : Timestamp::Max();
|
options.has_end_time() ? Timestamp(options.end_time()) : Timestamp::Max();
|
||||||
CHECK_LT(start_time_, end_time_)
|
ABSL_CHECK_LT(start_time_, end_time_)
|
||||||
<< "Invalid PacketThinner: start_time must be earlier than end_time";
|
<< "Invalid PacketThinner: start_time must be earlier than end_time";
|
||||||
|
|
||||||
sync_output_timestamps_ = options.sync_output_timestamps();
|
sync_output_timestamps_ = options.sync_output_timestamps();
|
||||||
|
@ -232,7 +234,7 @@ absl::Status PacketThinnerCalculator::Close(CalculatorContext* cc) {
|
||||||
// Emit any saved packets before quitting.
|
// Emit any saved packets before quitting.
|
||||||
if (!saved_packet_.IsEmpty()) {
|
if (!saved_packet_.IsEmpty()) {
|
||||||
// Only sync thinner should have saved packets.
|
// Only sync thinner should have saved packets.
|
||||||
CHECK_EQ(PacketThinnerCalculatorOptions::SYNC, thinner_type_);
|
ABSL_CHECK_EQ(PacketThinnerCalculatorOptions::SYNC, thinner_type_);
|
||||||
if (sync_output_timestamps_) {
|
if (sync_output_timestamps_) {
|
||||||
cc->Outputs().Index(0).AddPacket(
|
cc->Outputs().Index(0).AddPacket(
|
||||||
saved_packet_.At(NearestSyncTimestamp(saved_packet_.Timestamp())));
|
saved_packet_.At(NearestSyncTimestamp(saved_packet_.Timestamp())));
|
||||||
|
@ -269,7 +271,7 @@ absl::Status PacketThinnerCalculator::SyncThinnerProcess(
|
||||||
const Timestamp saved_sync = NearestSyncTimestamp(saved);
|
const Timestamp saved_sync = NearestSyncTimestamp(saved);
|
||||||
const Timestamp now = cc->InputTimestamp();
|
const Timestamp now = cc->InputTimestamp();
|
||||||
const Timestamp now_sync = NearestSyncTimestamp(now);
|
const Timestamp now_sync = NearestSyncTimestamp(now);
|
||||||
CHECK_LE(saved_sync, now_sync);
|
ABSL_CHECK_LE(saved_sync, now_sync);
|
||||||
if (saved_sync == now_sync) {
|
if (saved_sync == now_sync) {
|
||||||
// Saved Packet is in same interval as current packet.
|
// Saved Packet is in same interval as current packet.
|
||||||
// Replace saved packet with current if it is at least as
|
// Replace saved packet with current if it is at least as
|
||||||
|
@ -295,7 +297,7 @@ absl::Status PacketThinnerCalculator::SyncThinnerProcess(
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestamp PacketThinnerCalculator::NearestSyncTimestamp(Timestamp now) const {
|
Timestamp PacketThinnerCalculator::NearestSyncTimestamp(Timestamp now) const {
|
||||||
CHECK_NE(start_time_, Timestamp::Unset())
|
ABSL_CHECK_NE(start_time_, Timestamp::Unset())
|
||||||
<< "Method only valid for sync thinner calculator.";
|
<< "Method only valid for sync thinner calculator.";
|
||||||
|
|
||||||
// Computation is done using int64 arithmetic. No easy way to avoid
|
// Computation is done using int64 arithmetic. No easy way to avoid
|
||||||
|
@ -303,12 +305,12 @@ Timestamp PacketThinnerCalculator::NearestSyncTimestamp(Timestamp now) const {
|
||||||
const int64_t now64 = now.Value();
|
const int64_t now64 = now.Value();
|
||||||
const int64_t start64 = start_time_.Value();
|
const int64_t start64 = start_time_.Value();
|
||||||
const int64_t period64 = period_.Value();
|
const int64_t period64 = period_.Value();
|
||||||
CHECK_LE(0, period64);
|
ABSL_CHECK_LE(0, period64);
|
||||||
|
|
||||||
// Round now64 to its closest interval (units of period64).
|
// Round now64 to its closest interval (units of period64).
|
||||||
int64_t sync64 =
|
int64_t sync64 =
|
||||||
(now64 - start64 + period64 / 2) / period64 * period64 + start64;
|
(now64 - start64 + period64 / 2) / period64 * period64 + start64;
|
||||||
CHECK_LE(abs(now64 - sync64), period64 / 2)
|
ABSL_CHECK_LE(abs(now64 - sync64), period64 / 2)
|
||||||
<< "start64: " << start64 << "; now64: " << now64
|
<< "start64: " << start64 << "; now64: " << now64
|
||||||
<< "; sync64: " << sync64;
|
<< "; sync64: " << sync64;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "mediapipe/calculators/core/packet_thinner_calculator.pb.h"
|
#include "mediapipe/calculators/core/packet_thinner_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -70,7 +71,7 @@ class SimpleRunner : public CalculatorRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
double GetFrameRate() const {
|
double GetFrameRate() const {
|
||||||
CHECK(!Outputs().Index(0).header.IsEmpty());
|
ABSL_CHECK(!Outputs().Index(0).header.IsEmpty());
|
||||||
return Outputs().Index(0).header.Get<VideoHeader>().frame_rate;
|
return Outputs().Index(0).header.Get<VideoHeader>().frame_rate;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -97,6 +97,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:source_location",
|
"//mediapipe/framework/port:source_location",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
)
|
)
|
||||||
|
@ -125,6 +126,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:opencv_imgcodecs",
|
"//mediapipe/framework/port:opencv_imgcodecs",
|
||||||
"//mediapipe/framework/port:opencv_imgproc",
|
"//mediapipe/framework/port:opencv_imgproc",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
)
|
)
|
||||||
|
@ -202,6 +204,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:opencv_imgproc",
|
"//mediapipe/framework/port:opencv_imgproc",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/port:vector",
|
"//mediapipe/framework/port:vector",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
] + select({
|
] + select({
|
||||||
"//mediapipe/gpu:disable_gpu": [],
|
"//mediapipe/gpu:disable_gpu": [],
|
||||||
|
@ -397,6 +400,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -421,6 +425,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/util:image_frame_util",
|
"//mediapipe/util:image_frame_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@libyuv",
|
"@libyuv",
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_replace.h"
|
#include "absl/strings/str_replace.h"
|
||||||
#include "mediapipe/calculators/image/bilateral_filter_calculator.pb.h"
|
#include "mediapipe/calculators/image/bilateral_filter_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -183,8 +184,8 @@ absl::Status BilateralFilterCalculator::Open(CalculatorContext* cc) {
|
||||||
|
|
||||||
sigma_color_ = options_.sigma_color();
|
sigma_color_ = options_.sigma_color();
|
||||||
sigma_space_ = options_.sigma_space();
|
sigma_space_ = options_.sigma_space();
|
||||||
CHECK_GE(sigma_color_, 0.0);
|
ABSL_CHECK_GE(sigma_color_, 0.0);
|
||||||
CHECK_GE(sigma_space_, 0.0);
|
ABSL_CHECK_GE(sigma_space_, 0.0);
|
||||||
if (!use_gpu_) sigma_color_ *= 255.0;
|
if (!use_gpu_) sigma_color_ *= 255.0;
|
||||||
|
|
||||||
if (use_gpu_) {
|
if (use_gpu_) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/image_frame.h"
|
#include "mediapipe/framework/formats/image_frame.h"
|
||||||
#include "mediapipe/framework/formats/image_frame_opencv.h"
|
#include "mediapipe/framework/formats/image_frame_opencv.h"
|
||||||
|
@ -25,8 +26,8 @@
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
namespace {
|
namespace {
|
||||||
void SetColorChannel(int channel, uint8 value, cv::Mat* mat) {
|
void SetColorChannel(int channel, uint8 value, cv::Mat* mat) {
|
||||||
CHECK(mat->depth() == CV_8U);
|
ABSL_CHECK(mat->depth() == CV_8U);
|
||||||
CHECK(channel < mat->channels());
|
ABSL_CHECK(channel < mat->channels());
|
||||||
const int step = mat->channels();
|
const int step = mat->channels();
|
||||||
for (int r = 0; r < mat->rows; ++r) {
|
for (int r = 0; r < mat->rows; ++r) {
|
||||||
uint8* row_ptr = mat->ptr<uint8>(r);
|
uint8* row_ptr = mat->ptr<uint8>(r);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/image/opencv_image_encoder_calculator.pb.h"
|
#include "mediapipe/calculators/image/opencv_image_encoder_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/image_frame_opencv.h"
|
#include "mediapipe/framework/formats/image_frame_opencv.h"
|
||||||
|
@ -61,7 +62,7 @@ absl::Status OpenCvImageEncoderCalculator::Open(CalculatorContext* cc) {
|
||||||
|
|
||||||
absl::Status OpenCvImageEncoderCalculator::Process(CalculatorContext* cc) {
|
absl::Status OpenCvImageEncoderCalculator::Process(CalculatorContext* cc) {
|
||||||
const ImageFrame& image_frame = cc->Inputs().Index(0).Get<ImageFrame>();
|
const ImageFrame& image_frame = cc->Inputs().Index(0).Get<ImageFrame>();
|
||||||
CHECK_EQ(1, image_frame.ByteDepth());
|
ABSL_CHECK_EQ(1, image_frame.ByteDepth());
|
||||||
|
|
||||||
std::unique_ptr<OpenCvImageEncoderCalculatorResults> encoded_result =
|
std::unique_ptr<OpenCvImageEncoderCalculatorResults> encoded_result =
|
||||||
absl::make_unique<OpenCvImageEncoderCalculatorResults>();
|
absl::make_unique<OpenCvImageEncoderCalculatorResults>();
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/substitute.h"
|
#include "absl/strings/substitute.h"
|
||||||
|
@ -509,7 +510,7 @@ absl::Status ScaleImageCalculator::ValidateImageFrame(
|
||||||
|
|
||||||
absl::Status ScaleImageCalculator::ValidateYUVImage(CalculatorContext* cc,
|
absl::Status ScaleImageCalculator::ValidateYUVImage(CalculatorContext* cc,
|
||||||
const YUVImage& yuv_image) {
|
const YUVImage& yuv_image) {
|
||||||
CHECK_EQ(input_format_, ImageFormat::YCBCR420P);
|
ABSL_CHECK_EQ(input_format_, ImageFormat::YCBCR420P);
|
||||||
if (!has_header_) {
|
if (!has_header_) {
|
||||||
if (input_width_ != yuv_image.width() ||
|
if (input_width_ != yuv_image.width() ||
|
||||||
input_height_ != yuv_image.height()) {
|
input_height_ != yuv_image.height()) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_split.h"
|
#include "absl/strings/str_split.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
#include "mediapipe/framework/port/logging.h"
|
||||||
#include "mediapipe/framework/port/ret_check.h"
|
#include "mediapipe/framework/port/ret_check.h"
|
||||||
|
@ -40,10 +41,10 @@ absl::Status FindCropDimensions(int input_width, int input_height, //
|
||||||
const std::string& max_aspect_ratio, //
|
const std::string& max_aspect_ratio, //
|
||||||
int* crop_width, int* crop_height, //
|
int* crop_width, int* crop_height, //
|
||||||
int* col_start, int* row_start) {
|
int* col_start, int* row_start) {
|
||||||
CHECK(crop_width);
|
ABSL_CHECK(crop_width);
|
||||||
CHECK(crop_height);
|
ABSL_CHECK(crop_height);
|
||||||
CHECK(col_start);
|
ABSL_CHECK(col_start);
|
||||||
CHECK(row_start);
|
ABSL_CHECK(row_start);
|
||||||
|
|
||||||
double min_aspect_ratio_q = 0.0;
|
double min_aspect_ratio_q = 0.0;
|
||||||
double max_aspect_ratio_q = 0.0;
|
double max_aspect_ratio_q = 0.0;
|
||||||
|
@ -83,8 +84,8 @@ absl::Status FindCropDimensions(int input_width, int input_height, //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_LE(*crop_width, input_width);
|
ABSL_CHECK_LE(*crop_width, input_width);
|
||||||
CHECK_LE(*crop_height, input_height);
|
ABSL_CHECK_LE(*crop_height, input_height);
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +97,8 @@ absl::Status FindOutputDimensions(int input_width, //
|
||||||
bool preserve_aspect_ratio, //
|
bool preserve_aspect_ratio, //
|
||||||
int scale_to_multiple_of, //
|
int scale_to_multiple_of, //
|
||||||
int* output_width, int* output_height) {
|
int* output_width, int* output_height) {
|
||||||
CHECK(output_width);
|
ABSL_CHECK(output_width);
|
||||||
CHECK(output_height);
|
ABSL_CHECK(output_height);
|
||||||
|
|
||||||
if (target_max_area > 0 && input_width * input_height > target_max_area) {
|
if (target_max_area > 0 && input_width * input_height > target_max_area) {
|
||||||
preserve_aspect_ratio = true;
|
preserve_aspect_ratio = true;
|
||||||
|
|
|
@ -87,6 +87,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/util:time_series_util",
|
"//mediapipe/util:time_series_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
"@com_google_absl//absl/status:statusor",
|
"@com_google_absl//absl/status:statusor",
|
||||||
|
@ -181,6 +182,7 @@ cc_library(
|
||||||
"//mediapipe/framework:calculator_framework",
|
"//mediapipe/framework:calculator_framework",
|
||||||
"//mediapipe/framework/api2:node",
|
"//mediapipe/framework/api2:node",
|
||||||
"//mediapipe/framework/formats:tensor",
|
"//mediapipe/framework/formats:tensor",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
@ -198,6 +200,7 @@ cc_test(
|
||||||
"//mediapipe/framework/formats:tensor",
|
"//mediapipe/framework/formats:tensor",
|
||||||
"//mediapipe/framework/port:gtest_main",
|
"//mediapipe/framework/port:gtest_main",
|
||||||
"//mediapipe/framework/port:parse_text_proto",
|
"//mediapipe/framework/port:parse_text_proto",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@org_tensorflow//tensorflow/lite/c:common",
|
"@org_tensorflow//tensorflow/lite/c:common",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -656,6 +659,7 @@ cc_library(
|
||||||
"//mediapipe/gpu:gpu_buffer_format",
|
"//mediapipe/gpu:gpu_buffer_format",
|
||||||
"//mediapipe/gpu:gpu_origin_cc_proto",
|
"//mediapipe/gpu:gpu_origin_cc_proto",
|
||||||
"//mediapipe/util:resource_util",
|
"//mediapipe/util:resource_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings:str_format",
|
"@com_google_absl//absl/strings:str_format",
|
||||||
] + select({
|
] + select({
|
||||||
"//mediapipe/gpu:disable_gpu": [],
|
"//mediapipe/gpu:disable_gpu": [],
|
||||||
|
@ -745,6 +749,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:tensor",
|
"//mediapipe/framework/formats:tensor",
|
||||||
"//mediapipe/framework/formats/object_detection:anchor_cc_proto",
|
"//mediapipe/framework/formats/object_detection:anchor_cc_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings:str_format",
|
"@com_google_absl//absl/strings:str_format",
|
||||||
"@com_google_absl//absl/types:span",
|
"@com_google_absl//absl/types:span",
|
||||||
|
@ -802,6 +807,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:landmark_cc_proto",
|
"//mediapipe/framework/formats:landmark_cc_proto",
|
||||||
"//mediapipe/framework/formats:tensor",
|
"//mediapipe/framework/formats:tensor",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
)
|
)
|
||||||
|
@ -994,6 +1000,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/port:statusor",
|
"//mediapipe/framework/port:statusor",
|
||||||
"//mediapipe/gpu:gpu_origin_cc_proto",
|
"//mediapipe/gpu:gpu_origin_cc_proto",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
] + select({
|
] + select({
|
||||||
"//mediapipe/gpu:disable_gpu": [],
|
"//mediapipe/gpu:disable_gpu": [],
|
||||||
|
@ -1087,6 +1094,7 @@ cc_test(
|
||||||
"//mediapipe/framework/port:parse_text_proto",
|
"//mediapipe/framework/port:parse_text_proto",
|
||||||
"//mediapipe/util:image_test_utils",
|
"//mediapipe/util:image_test_utils",
|
||||||
"@com_google_absl//absl/flags:flag",
|
"@com_google_absl//absl/flags:flag",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/strings:str_format",
|
"@com_google_absl//absl/strings:str_format",
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
|
@ -348,7 +349,7 @@ absl::Status AudioToTensorCalculator::Process(CalculatorContext* cc) {
|
||||||
return absl::InvalidArgumentError(
|
return absl::InvalidArgumentError(
|
||||||
"The audio data should be stored in column-major.");
|
"The audio data should be stored in column-major.");
|
||||||
}
|
}
|
||||||
CHECK(channels_match || mono_output);
|
ABSL_CHECK(channels_match || mono_output);
|
||||||
const Matrix& input = channels_match ? input_frame
|
const Matrix& input = channels_match ? input_frame
|
||||||
// Mono mixdown.
|
// Mono mixdown.
|
||||||
: input_frame.colwise().mean();
|
: input_frame.colwise().mean();
|
||||||
|
@ -457,7 +458,7 @@ absl::Status AudioToTensorCalculator::SetupStreamingResampler(
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioToTensorCalculator::AppendZerosToSampleBuffer(int num_samples) {
|
void AudioToTensorCalculator::AppendZerosToSampleBuffer(int num_samples) {
|
||||||
CHECK_GE(num_samples, 0); // Ensured by `UpdateContract`.
|
ABSL_CHECK_GE(num_samples, 0); // Ensured by `UpdateContract`.
|
||||||
if (num_samples == 0) {
|
if (num_samples == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/tensor/feedback_tensors_calculator.pb.h"
|
#include "mediapipe/calculators/tensor/feedback_tensors_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator.pb.h"
|
#include "mediapipe/framework/calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -65,7 +66,7 @@ template <typename T>
|
||||||
Tensor MakeTensor(std::initializer_list<int> shape,
|
Tensor MakeTensor(std::initializer_list<int> shape,
|
||||||
std::initializer_list<T> values) {
|
std::initializer_list<T> values) {
|
||||||
Tensor tensor(TensorElementType<T>::value, shape);
|
Tensor tensor(TensorElementType<T>::value, shape);
|
||||||
CHECK_EQ(values.size(), tensor.shape().num_elements())
|
ABSL_CHECK_EQ(values.size(), tensor.shape().num_elements())
|
||||||
<< "The size of `values` is incompatible with `shape`";
|
<< "The size of `values` is incompatible with `shape`";
|
||||||
absl::c_copy(values, tensor.GetCpuWriteView().buffer<T>());
|
absl::c_copy(values, tensor.GetCpuWriteView().buffer<T>());
|
||||||
return tensor;
|
return tensor;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/flags/flag.h"
|
#include "absl/flags/flag.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "absl/strings/substitute.h"
|
#include "absl/strings/substitute.h"
|
||||||
|
@ -205,7 +206,7 @@ mediapipe::ImageFormat::Format GetImageFormat(int image_channels) {
|
||||||
} else if (image_channels == 1) {
|
} else if (image_channels == 1) {
|
||||||
return ImageFormat::GRAY8;
|
return ImageFormat::GRAY8;
|
||||||
}
|
}
|
||||||
CHECK(false) << "Unsupported input image channles: " << image_channels;
|
ABSL_CHECK(false) << "Unsupported input image channles: " << image_channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet MakeImageFramePacket(cv::Mat input) {
|
Packet MakeImageFramePacket(cv::Mat input) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/log/check.h"
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/str_replace.h"
|
#include "absl/strings/str_replace.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
|
@ -623,7 +624,7 @@ absl::Status TensorConverterCalculator::LoadOptions(CalculatorContext* cc) {
|
||||||
if (options.has_output_tensor_float_range()) {
|
if (options.has_output_tensor_float_range()) {
|
||||||
output_range_.emplace(options.output_tensor_float_range().min(),
|
output_range_.emplace(options.output_tensor_float_range().min(),
|
||||||
options.output_tensor_float_range().max());
|
options.output_tensor_float_range().max());
|
||||||
CHECK_GT(output_range_->second, output_range_->first);
|
ABSL_CHECK_GT(output_range_->second, output_range_->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom div and sub values.
|
// Custom div and sub values.
|
||||||
|
@ -641,9 +642,9 @@ absl::Status TensorConverterCalculator::LoadOptions(CalculatorContext* cc) {
|
||||||
|
|
||||||
// Get desired way to handle input channels.
|
// Get desired way to handle input channels.
|
||||||
max_num_channels_ = options.max_num_channels();
|
max_num_channels_ = options.max_num_channels();
|
||||||
CHECK_GE(max_num_channels_, 1);
|
ABSL_CHECK_GE(max_num_channels_, 1);
|
||||||
CHECK_LE(max_num_channels_, 4);
|
ABSL_CHECK_LE(max_num_channels_, 4);
|
||||||
CHECK_NE(max_num_channels_, 2);
|
ABSL_CHECK_NE(max_num_channels_, 2);
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ void ConvertRawValuesToAnchors(const float* raw_anchors, int num_boxes,
|
||||||
|
|
||||||
void ConvertAnchorsToRawValues(const std::vector<Anchor>& anchors,
|
void ConvertAnchorsToRawValues(const std::vector<Anchor>& anchors,
|
||||||
int num_boxes, float* raw_anchors) {
|
int num_boxes, float* raw_anchors) {
|
||||||
CHECK_EQ(anchors.size(), num_boxes);
|
ABSL_CHECK_EQ(anchors.size(), num_boxes);
|
||||||
int box = 0;
|
int box = 0;
|
||||||
for (const auto& anchor : anchors) {
|
for (const auto& anchor : anchors) {
|
||||||
raw_anchors[box * kNumCoordsPerBox + 0] = anchor.y_center();
|
raw_anchors[box * kNumCoordsPerBox + 0] = anchor.y_center();
|
||||||
|
@ -704,18 +704,18 @@ absl::Status TensorsToDetectionsCalculator::LoadOptions(CalculatorContext* cc) {
|
||||||
num_boxes_ = options_.num_boxes();
|
num_boxes_ = options_.num_boxes();
|
||||||
num_coords_ = options_.num_coords();
|
num_coords_ = options_.num_coords();
|
||||||
box_output_format_ = GetBoxFormat(options_);
|
box_output_format_ = GetBoxFormat(options_);
|
||||||
CHECK_NE(options_.max_results(), 0)
|
ABSL_CHECK_NE(options_.max_results(), 0)
|
||||||
<< "The maximum number of the top-scored detection results must be "
|
<< "The maximum number of the top-scored detection results must be "
|
||||||
"non-zero.";
|
"non-zero.";
|
||||||
max_results_ = options_.max_results();
|
max_results_ = options_.max_results();
|
||||||
|
|
||||||
// Currently only support 2D when num_values_per_keypoint equals to 2.
|
// Currently only support 2D when num_values_per_keypoint equals to 2.
|
||||||
CHECK_EQ(options_.num_values_per_keypoint(), 2);
|
ABSL_CHECK_EQ(options_.num_values_per_keypoint(), 2);
|
||||||
|
|
||||||
// Check if the output size is equal to the requested boxes and keypoints.
|
// Check if the output size is equal to the requested boxes and keypoints.
|
||||||
CHECK_EQ(options_.num_keypoints() * options_.num_values_per_keypoint() +
|
ABSL_CHECK_EQ(options_.num_keypoints() * options_.num_values_per_keypoint() +
|
||||||
kNumCoordsPerBox,
|
kNumCoordsPerBox,
|
||||||
num_coords_);
|
num_coords_);
|
||||||
|
|
||||||
if (kSideInIgnoreClasses(cc).IsConnected()) {
|
if (kSideInIgnoreClasses(cc).IsConnected()) {
|
||||||
RET_CHECK(!kSideInIgnoreClasses(cc).IsEmpty());
|
RET_CHECK(!kSideInIgnoreClasses(cc).IsEmpty());
|
||||||
|
@ -1155,11 +1155,12 @@ void main() {
|
||||||
}
|
}
|
||||||
// TODO support better filtering.
|
// TODO support better filtering.
|
||||||
if (class_index_set_.is_allowlist) {
|
if (class_index_set_.is_allowlist) {
|
||||||
CHECK_EQ(class_index_set_.values.size(),
|
ABSL_CHECK_EQ(class_index_set_.values.size(),
|
||||||
IsClassIndexAllowed(0) ? num_classes_ : num_classes_ - 1)
|
IsClassIndexAllowed(0) ? num_classes_ : num_classes_ - 1)
|
||||||
<< "Only all classes >= class 0 or >= class 1";
|
<< "Only all classes >= class 0 or >= class 1";
|
||||||
} else {
|
} else {
|
||||||
CHECK_EQ(class_index_set_.values.size(), IsClassIndexAllowed(0) ? 0 : 1)
|
ABSL_CHECK_EQ(class_index_set_.values.size(),
|
||||||
|
IsClassIndexAllowed(0) ? 0 : 1)
|
||||||
<< "Only ignore class 0 is allowed";
|
<< "Only ignore class 0 is allowed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,11 +1381,12 @@ kernel void scoreKernel(
|
||||||
|
|
||||||
// TODO support better filtering.
|
// TODO support better filtering.
|
||||||
if (class_index_set_.is_allowlist) {
|
if (class_index_set_.is_allowlist) {
|
||||||
CHECK_EQ(class_index_set_.values.size(),
|
ABSL_CHECK_EQ(class_index_set_.values.size(),
|
||||||
IsClassIndexAllowed(0) ? num_classes_ : num_classes_ - 1)
|
IsClassIndexAllowed(0) ? num_classes_ : num_classes_ - 1)
|
||||||
<< "Only all classes >= class 0 or >= class 1";
|
<< "Only all classes >= class 0 or >= class 1";
|
||||||
} else {
|
} else {
|
||||||
CHECK_EQ(class_index_set_.values.size(), IsClassIndexAllowed(0) ? 0 : 1)
|
ABSL_CHECK_EQ(class_index_set_.values.size(),
|
||||||
|
IsClassIndexAllowed(0) ? 0 : 1)
|
||||||
<< "Only ignore class 0 is allowed";
|
<< "Only ignore class 0 is allowed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ absl::Status TensorsToLandmarksCalculator::Process(CalculatorContext* cc) {
|
||||||
RET_CHECK(input_tensors[0].element_type() == Tensor::ElementType::kFloat32);
|
RET_CHECK(input_tensors[0].element_type() == Tensor::ElementType::kFloat32);
|
||||||
int num_values = input_tensors[0].shape().num_elements();
|
int num_values = input_tensors[0].shape().num_elements();
|
||||||
const int num_dimensions = num_values / num_landmarks_;
|
const int num_dimensions = num_values / num_landmarks_;
|
||||||
CHECK_GT(num_dimensions, 0);
|
ABSL_CHECK_GT(num_dimensions, 0);
|
||||||
|
|
||||||
auto view = input_tensors[0].GetCpuReadView();
|
auto view = input_tensors[0].GetCpuReadView();
|
||||||
auto raw_landmarks = view.buffer<float>();
|
auto raw_landmarks = view.buffer<float>();
|
||||||
|
|
|
@ -315,6 +315,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
] + select({
|
] + select({
|
||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
"@org_tensorflow//tensorflow/core:framework",
|
"@org_tensorflow//tensorflow/core:framework",
|
||||||
|
@ -429,7 +430,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:status_util",
|
"//mediapipe/framework/tool:status_util",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
"@com_google_absl//absl/log:check",
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
|
@ -670,6 +671,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:image_frame",
|
"//mediapipe/framework/formats:image_frame",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@org_tensorflow//tensorflow/core:framework",
|
"@org_tensorflow//tensorflow/core:framework",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
@ -685,6 +687,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
"//mediapipe/framework/formats:time_series_header_cc_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
] + select({
|
] + select({
|
||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
"@org_tensorflow//tensorflow/core:framework",
|
"@org_tensorflow//tensorflow/core:framework",
|
||||||
|
@ -796,6 +799,7 @@ cc_library(
|
||||||
"//mediapipe/framework:calculator_framework",
|
"//mediapipe/framework:calculator_framework",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@org_tensorflow//tensorflow/core:framework",
|
"@org_tensorflow//tensorflow/core:framework",
|
||||||
],
|
],
|
||||||
|
@ -838,6 +842,7 @@ cc_library(
|
||||||
"//mediapipe/framework:calculator_framework",
|
"//mediapipe/framework:calculator_framework",
|
||||||
"//mediapipe/framework:packet",
|
"//mediapipe/framework:packet",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@org_tensorflow//tensorflow/core:protos_all_cc",
|
"@org_tensorflow//tensorflow/core:protos_all_cc",
|
||||||
],
|
],
|
||||||
|
@ -945,6 +950,7 @@ cc_test(
|
||||||
"//mediapipe/framework/port:gtest_main",
|
"//mediapipe/framework/port:gtest_main",
|
||||||
"//mediapipe/framework/port:opencv_imgcodecs",
|
"//mediapipe/framework/port:opencv_imgcodecs",
|
||||||
"//mediapipe/util/sequence:media_sequence",
|
"//mediapipe/util/sequence:media_sequence",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_googletest//:gtest_main",
|
"@com_google_googletest//:gtest_main",
|
||||||
|
@ -1257,6 +1263,7 @@ cc_test(
|
||||||
"//mediapipe/framework/tool:sink",
|
"//mediapipe/framework/tool:sink",
|
||||||
"//mediapipe/framework/tool:validate_type",
|
"//mediapipe/framework/tool:validate_type",
|
||||||
"@com_google_absl//absl/flags:flag",
|
"@com_google_absl//absl/flags:flag",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
] + select({
|
] + select({
|
||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/tensorflow/matrix_to_tensor_calculator_options.pb.h"
|
#include "mediapipe/calculators/tensorflow/matrix_to_tensor_calculator_options.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/matrix.h"
|
#include "mediapipe/framework/formats/matrix.h"
|
||||||
|
@ -28,7 +29,7 @@ namespace mediapipe {
|
||||||
namespace {
|
namespace {
|
||||||
absl::Status FillTimeSeriesHeaderIfValid(const Packet& header_packet,
|
absl::Status FillTimeSeriesHeaderIfValid(const Packet& header_packet,
|
||||||
TimeSeriesHeader* header) {
|
TimeSeriesHeader* header) {
|
||||||
CHECK(header);
|
ABSL_CHECK(header);
|
||||||
if (header_packet.IsEmpty()) {
|
if (header_packet.IsEmpty()) {
|
||||||
return absl::UnknownError("No header found.");
|
return absl::UnknownError("No header found.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "mediapipe/calculators/image/opencv_image_encoder_calculator.pb.h"
|
#include "mediapipe/calculators/image/opencv_image_encoder_calculator.pb.h"
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/tensorflow/tensor_to_image_frame_calculator.pb.h"
|
#include "mediapipe/calculators/tensorflow/tensor_to_image_frame_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/image_frame.h"
|
#include "mediapipe/framework/formats/image_frame.h"
|
||||||
|
@ -99,7 +100,7 @@ absl::Status TensorToImageFrameCalculator::Process(CalculatorContext* cc) {
|
||||||
const tf::Tensor& input_tensor = cc->Inputs().Tag(kTensor).Get<tf::Tensor>();
|
const tf::Tensor& input_tensor = cc->Inputs().Tag(kTensor).Get<tf::Tensor>();
|
||||||
int32_t depth = 1;
|
int32_t depth = 1;
|
||||||
if (input_tensor.dims() != 2) { // Depth is 1 for 2D tensors.
|
if (input_tensor.dims() != 2) { // Depth is 1 for 2D tensors.
|
||||||
CHECK(3 == input_tensor.dims())
|
ABSL_CHECK(3 == input_tensor.dims())
|
||||||
<< "Only 2 or 3-D Tensors can be converted to frames. Instead got: "
|
<< "Only 2 or 3-D Tensors can be converted to frames. Instead got: "
|
||||||
<< input_tensor.dims();
|
<< input_tensor.dims();
|
||||||
depth = input_tensor.dim_size(2);
|
depth = input_tensor.dim_size(2);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
// Calculator converts from one-dimensional Tensor of DT_FLOAT to Matrix
|
// Calculator converts from one-dimensional Tensor of DT_FLOAT to Matrix
|
||||||
// OR from (batched) two-dimensional Tensor of DT_FLOAT to Matrix.
|
// OR from (batched) two-dimensional Tensor of DT_FLOAT to Matrix.
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/tensorflow/tensor_to_matrix_calculator.pb.h"
|
#include "mediapipe/calculators/tensorflow/tensor_to_matrix_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/matrix.h"
|
#include "mediapipe/framework/formats/matrix.h"
|
||||||
|
@ -36,7 +37,7 @@ constexpr char kReference[] = "REFERENCE";
|
||||||
|
|
||||||
absl::Status FillTimeSeriesHeaderIfValid(const Packet& header_packet,
|
absl::Status FillTimeSeriesHeaderIfValid(const Packet& header_packet,
|
||||||
TimeSeriesHeader* header) {
|
TimeSeriesHeader* header) {
|
||||||
CHECK(header);
|
ABSL_CHECK(header);
|
||||||
if (header_packet.IsEmpty()) {
|
if (header_packet.IsEmpty()) {
|
||||||
return absl::UnknownError("No header found.");
|
return absl::UnknownError("No header found.");
|
||||||
}
|
}
|
||||||
|
@ -191,7 +192,7 @@ absl::Status TensorToMatrixCalculator::Process(CalculatorContext* cc) {
|
||||||
<< "Tensor stream packet does not contain a Tensor.";
|
<< "Tensor stream packet does not contain a Tensor.";
|
||||||
|
|
||||||
const tf::Tensor& input_tensor = cc->Inputs().Tag(kTensor).Get<tf::Tensor>();
|
const tf::Tensor& input_tensor = cc->Inputs().Tag(kTensor).Get<tf::Tensor>();
|
||||||
CHECK(1 == input_tensor.dims() || 2 == input_tensor.dims())
|
ABSL_CHECK(1 == input_tensor.dims() || 2 == input_tensor.dims())
|
||||||
<< "Only 1-D or 2-D Tensors can be converted to matrices.";
|
<< "Only 1-D or 2-D Tensors can be converted to matrices.";
|
||||||
const int32_t length = input_tensor.dim_size(input_tensor.dims() - 1);
|
const int32_t length = input_tensor.dim_size(input_tensor.dims() - 1);
|
||||||
const int32_t width =
|
const int32_t width =
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/base/thread_annotations.h"
|
#include "absl/base/thread_annotations.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/str_split.h"
|
#include "absl/strings/str_split.h"
|
||||||
#include "absl/synchronization/mutex.h"
|
#include "absl/synchronization/mutex.h"
|
||||||
|
@ -515,7 +516,7 @@ class TensorFlowInferenceCalculator : public CalculatorBase {
|
||||||
tf::Tensor concated;
|
tf::Tensor concated;
|
||||||
const tf::Status concat_status =
|
const tf::Status concat_status =
|
||||||
tf::tensor::Concat(keyed_tensors.second, &concated);
|
tf::tensor::Concat(keyed_tensors.second, &concated);
|
||||||
CHECK(concat_status.ok()) << concat_status.ToString();
|
ABSL_CHECK(concat_status.ok()) << concat_status.ToString();
|
||||||
input_tensors.emplace_back(tag_to_tensor_map_[keyed_tensors.first],
|
input_tensors.emplace_back(tag_to_tensor_map_[keyed_tensors.first],
|
||||||
concated);
|
concated);
|
||||||
}
|
}
|
||||||
|
@ -597,7 +598,7 @@ class TensorFlowInferenceCalculator : public CalculatorBase {
|
||||||
std::vector<tf::Tensor> split_tensors;
|
std::vector<tf::Tensor> split_tensors;
|
||||||
const tf::Status split_status =
|
const tf::Status split_status =
|
||||||
tf::tensor::Split(outputs[i], split_vector, &split_tensors);
|
tf::tensor::Split(outputs[i], split_vector, &split_tensors);
|
||||||
CHECK(split_status.ok()) << split_status.ToString();
|
ABSL_CHECK(split_status.ok()) << split_status.ToString();
|
||||||
// Loop over timestamps so that we don't copy the padding.
|
// Loop over timestamps so that we don't copy the padding.
|
||||||
for (int j = 0; j < inference_state->batch_timestamps_.size(); ++j) {
|
for (int j = 0; j < inference_state->batch_timestamps_.size(); ++j) {
|
||||||
tf::Tensor output_tensor(split_tensors[j]);
|
tf::Tensor output_tensor(split_tensors[j]);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/flags/flag.h"
|
#include "absl/flags/flag.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "mediapipe/calculators/tensorflow/tensorflow_inference_calculator.pb.h"
|
#include "mediapipe/calculators/tensorflow/tensorflow_inference_calculator.pb.h"
|
||||||
#include "mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator.pb.h"
|
#include "mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator.pb.h"
|
||||||
|
@ -119,7 +120,7 @@ class TensorflowInferenceCalculatorTest : public ::testing::Test {
|
||||||
// Create tensor from Vector and add as a Packet to the provided tag as input.
|
// Create tensor from Vector and add as a Packet to the provided tag as input.
|
||||||
void AddVectorToInputsAsPacket(const std::vector<Packet>& packets,
|
void AddVectorToInputsAsPacket(const std::vector<Packet>& packets,
|
||||||
const std::string& tag) {
|
const std::string& tag) {
|
||||||
CHECK(!packets.empty())
|
ABSL_CHECK(!packets.empty())
|
||||||
<< "Please specify at least some data in the packet";
|
<< "Please specify at least some data in the packet";
|
||||||
auto packets_ptr = absl::make_unique<std::vector<Packet>>(packets);
|
auto packets_ptr = absl::make_unique<std::vector<Packet>>(packets);
|
||||||
runner_->MutableInputs()->Tag(tag).packets.push_back(
|
runner_->MutableInputs()->Tag(tag).packets.push_back(
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "mediapipe/calculators/tensorflow/lapped_tensor_buffer_calculator.pb.h"
|
#include "mediapipe/calculators/tensorflow/lapped_tensor_buffer_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -47,7 +48,7 @@ std::string GetQuantizedFeature(
|
||||||
.Get(index)
|
.Get(index)
|
||||||
.bytes_list()
|
.bytes_list()
|
||||||
.value();
|
.value();
|
||||||
CHECK_EQ(1, bytes_list.size());
|
ABSL_CHECK_EQ(1, bytes_list.size());
|
||||||
return bytes_list.Get(0);
|
return bytes_list.Get(0);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
// Converts a single int or vector<int> or vector<vector<int>> to 1D (or 2D)
|
// Converts a single int or vector<int> or vector<vector<int>> to 1D (or 2D)
|
||||||
// tf::Tensor.
|
// tf::Tensor.
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "mediapipe/calculators/tensorflow/vector_int_to_tensor_calculator_options.pb.h"
|
#include "mediapipe/calculators/tensorflow/vector_int_to_tensor_calculator_options.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -114,11 +115,11 @@ absl::Status VectorIntToTensorCalculator::Process(CalculatorContext* cc) {
|
||||||
.Get<std::vector<std::vector<int>>>();
|
.Get<std::vector<std::vector<int>>>();
|
||||||
|
|
||||||
const int32_t rows = input.size();
|
const int32_t rows = input.size();
|
||||||
CHECK_GE(rows, 1);
|
ABSL_CHECK_GE(rows, 1);
|
||||||
const int32_t cols = input[0].size();
|
const int32_t cols = input[0].size();
|
||||||
CHECK_GE(cols, 1);
|
ABSL_CHECK_GE(cols, 1);
|
||||||
for (int i = 1; i < rows; ++i) {
|
for (int i = 1; i < rows; ++i) {
|
||||||
CHECK_EQ(input[i].size(), cols);
|
ABSL_CHECK_EQ(input[i].size(), cols);
|
||||||
}
|
}
|
||||||
if (options_.transpose()) {
|
if (options_.transpose()) {
|
||||||
tensor_shape = tf::TensorShape({cols, rows});
|
tensor_shape = tf::TensorShape({cols, rows});
|
||||||
|
@ -172,7 +173,7 @@ absl::Status VectorIntToTensorCalculator::Process(CalculatorContext* cc) {
|
||||||
} else {
|
} else {
|
||||||
input = cc->Inputs().Tag(kVectorInt).Value().Get<std::vector<int>>();
|
input = cc->Inputs().Tag(kVectorInt).Value().Get<std::vector<int>>();
|
||||||
}
|
}
|
||||||
CHECK_GE(input.size(), 1);
|
ABSL_CHECK_GE(input.size(), 1);
|
||||||
const int32_t length = input.size();
|
const int32_t length = input.size();
|
||||||
tensor_shape = tf::TensorShape({length});
|
tensor_shape = tf::TensorShape({length});
|
||||||
auto output = ::absl::make_unique<tf::Tensor>(options_.tensor_data_type(),
|
auto output = ::absl::make_unique<tf::Tensor>(options_.tensor_data_type(),
|
||||||
|
|
|
@ -103,6 +103,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats/object_detection:anchor_cc_proto",
|
"//mediapipe/framework/formats/object_detection:anchor_cc_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
@ -202,6 +203,7 @@ cc_library(
|
||||||
"//mediapipe/framework/stream_handler:fixed_size_input_stream_handler",
|
"//mediapipe/framework/stream_handler:fixed_size_input_stream_handler",
|
||||||
"//mediapipe/util/tflite:config",
|
"//mediapipe/util/tflite:config",
|
||||||
"//mediapipe/util/tflite:tflite_model_loader",
|
"//mediapipe/util/tflite:tflite_model_loader",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@org_tensorflow//tensorflow/lite:framework",
|
"@org_tensorflow//tensorflow/lite:framework",
|
||||||
|
@ -278,6 +280,7 @@ cc_library(
|
||||||
"//mediapipe/framework/stream_handler:fixed_size_input_stream_handler",
|
"//mediapipe/framework/stream_handler:fixed_size_input_stream_handler",
|
||||||
"//mediapipe/util:resource_util",
|
"//mediapipe/util:resource_util",
|
||||||
"//mediapipe/util/tflite:config",
|
"//mediapipe/util/tflite:config",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@org_tensorflow//tensorflow/lite:framework",
|
"@org_tensorflow//tensorflow/lite:framework",
|
||||||
"@org_tensorflow//tensorflow/lite/kernels:builtin_ops",
|
"@org_tensorflow//tensorflow/lite/kernels:builtin_ops",
|
||||||
] + selects.with_or({
|
] + selects.with_or({
|
||||||
|
@ -395,6 +398,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats/object_detection:anchor_cc_proto",
|
"//mediapipe/framework/formats/object_detection:anchor_cc_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/util/tflite:config",
|
"//mediapipe/util/tflite:config",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings:str_format",
|
"@com_google_absl//absl/strings:str_format",
|
||||||
"@com_google_absl//absl/types:span",
|
"@com_google_absl//absl/types:span",
|
||||||
|
@ -432,6 +436,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/util:resource_util",
|
"//mediapipe/util:resource_util",
|
||||||
"@com_google_absl//absl/container:node_hash_map",
|
"@com_google_absl//absl/container:node_hash_map",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings:str_format",
|
"@com_google_absl//absl/strings:str_format",
|
||||||
"@com_google_absl//absl/types:span",
|
"@com_google_absl//absl/types:span",
|
||||||
"@org_tensorflow//tensorflow/lite:framework",
|
"@org_tensorflow//tensorflow/lite:framework",
|
||||||
|
@ -460,6 +465,7 @@ cc_library(
|
||||||
"//mediapipe/framework:calculator_framework",
|
"//mediapipe/framework:calculator_framework",
|
||||||
"//mediapipe/framework/formats:landmark_cc_proto",
|
"//mediapipe/framework/formats:landmark_cc_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@org_tensorflow//tensorflow/lite:framework",
|
"@org_tensorflow//tensorflow/lite:framework",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "mediapipe/calculators/tflite/ssd_anchors_calculator.pb.h"
|
#include "mediapipe/calculators/tflite/ssd_anchors_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -275,11 +276,11 @@ absl::Status SsdAnchorsCalculator::GenerateAnchors(
|
||||||
if (options.strides_size()) {
|
if (options.strides_size()) {
|
||||||
ABSL_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);
|
ABSL_CHECK_EQ(options.feature_map_height_size(), kNumLayers);
|
||||||
CHECK_EQ(options.feature_map_height_size(),
|
ABSL_CHECK_EQ(options.feature_map_height_size(),
|
||||||
options.feature_map_width_size());
|
options.feature_map_width_size());
|
||||||
} else {
|
} else {
|
||||||
CHECK_EQ(options.strides_size(), kNumLayers);
|
ABSL_CHECK_EQ(options.strides_size(), kNumLayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.multiscale_anchor_generation()) {
|
if (options.multiscale_anchor_generation()) {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/tflite/tflite_converter_calculator.pb.h"
|
#include "mediapipe/calculators/tflite/tflite_converter_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/image_frame.h"
|
#include "mediapipe/framework/formats/image_frame.h"
|
||||||
|
@ -643,7 +644,7 @@ absl::Status TfLiteConverterCalculator::LoadOptions(CalculatorContext* cc) {
|
||||||
if (options.has_output_tensor_float_range()) {
|
if (options.has_output_tensor_float_range()) {
|
||||||
output_range_.emplace(options.output_tensor_float_range().min(),
|
output_range_.emplace(options.output_tensor_float_range().min(),
|
||||||
options.output_tensor_float_range().max());
|
options.output_tensor_float_range().max());
|
||||||
CHECK_GT(output_range_->second, output_range_->first);
|
ABSL_CHECK_GT(output_range_->second, output_range_->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom div and sub values.
|
// Custom div and sub values.
|
||||||
|
@ -661,9 +662,9 @@ absl::Status TfLiteConverterCalculator::LoadOptions(CalculatorContext* cc) {
|
||||||
|
|
||||||
// Get desired way to handle input channels.
|
// Get desired way to handle input channels.
|
||||||
max_num_channels_ = options.max_num_channels();
|
max_num_channels_ = options.max_num_channels();
|
||||||
CHECK_GE(max_num_channels_, 1);
|
ABSL_CHECK_GE(max_num_channels_, 1);
|
||||||
CHECK_LE(max_num_channels_, 4);
|
ABSL_CHECK_LE(max_num_channels_, 4);
|
||||||
CHECK_NE(max_num_channels_, 2);
|
ABSL_CHECK_NE(max_num_channels_, 2);
|
||||||
#if defined(MEDIAPIPE_IOS)
|
#if defined(MEDIAPIPE_IOS)
|
||||||
if (cc->Inputs().HasTag(kGpuBufferTag))
|
if (cc->Inputs().HasTag(kGpuBufferTag))
|
||||||
// Currently on iOS, tflite gpu input tensor must be 4 channels,
|
// Currently on iOS, tflite gpu input tensor must be 4 channels,
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "mediapipe/calculators/tflite/tflite_inference_calculator.pb.h"
|
#include "mediapipe/calculators/tflite/tflite_inference_calculator.pb.h"
|
||||||
|
@ -111,8 +112,8 @@ std::unique_ptr<tflite::Interpreter> BuildEdgeTpuInterpreter(
|
||||||
edgetpu::EdgeTpuContext* edgetpu_context) {
|
edgetpu::EdgeTpuContext* edgetpu_context) {
|
||||||
resolver->AddCustom(edgetpu::kCustomOp, edgetpu::RegisterCustomOp());
|
resolver->AddCustom(edgetpu::kCustomOp, edgetpu::RegisterCustomOp());
|
||||||
std::unique_ptr<tflite::Interpreter> interpreter;
|
std::unique_ptr<tflite::Interpreter> interpreter;
|
||||||
CHECK_EQ(tflite::InterpreterBuilder(model, *resolver)(&interpreter),
|
ABSL_CHECK_EQ(tflite::InterpreterBuilder(model, *resolver)(&interpreter),
|
||||||
kTfLiteOk);
|
kTfLiteOk);
|
||||||
interpreter->SetExternalContext(kTfLiteEdgeTpuContext, edgetpu_context);
|
interpreter->SetExternalContext(kTfLiteEdgeTpuContext, edgetpu_context);
|
||||||
return interpreter;
|
return interpreter;
|
||||||
}
|
}
|
||||||
|
@ -413,7 +414,7 @@ absl::Status TfLiteInferenceCalculator::Open(CalculatorContext* cc) {
|
||||||
"Falling back to the default TFLite API.";
|
"Falling back to the default TFLite API.";
|
||||||
use_advanced_gpu_api_ = false;
|
use_advanced_gpu_api_ = false;
|
||||||
}
|
}
|
||||||
CHECK(!use_advanced_gpu_api_ || gpu_inference_);
|
ABSL_CHECK(!use_advanced_gpu_api_ || gpu_inference_);
|
||||||
|
|
||||||
MP_RETURN_IF_ERROR(LoadModel(cc));
|
MP_RETURN_IF_ERROR(LoadModel(cc));
|
||||||
|
|
||||||
|
@ -805,9 +806,10 @@ absl::Status TfLiteInferenceCalculator::InitTFLiteGPURunner(
|
||||||
const int tensor_idx = interpreter_->inputs()[i];
|
const int tensor_idx = interpreter_->inputs()[i];
|
||||||
interpreter_->SetTensorParametersReadWrite(tensor_idx, kTfLiteFloat32, "",
|
interpreter_->SetTensorParametersReadWrite(tensor_idx, kTfLiteFloat32, "",
|
||||||
shape, quant);
|
shape, quant);
|
||||||
CHECK(interpreter_->ResizeInputTensor(tensor_idx, shape) == kTfLiteOk);
|
ABSL_CHECK(interpreter_->ResizeInputTensor(tensor_idx, shape) ==
|
||||||
|
kTfLiteOk);
|
||||||
}
|
}
|
||||||
CHECK(interpreter_->AllocateTensors() == kTfLiteOk);
|
ABSL_CHECK(interpreter_->AllocateTensors() == kTfLiteOk);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and bind OpenGL buffers for outputs.
|
// Create and bind OpenGL buffers for outputs.
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/container/node_hash_map.h"
|
#include "absl/container/node_hash_map.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
#include "mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.pb.h"
|
#include "mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.pb.h"
|
||||||
|
@ -172,7 +173,7 @@ absl::Status TfLiteTensorsToClassificationCalculator::Process(
|
||||||
|
|
||||||
// Note that partial_sort will raise error when top_k_ >
|
// Note that partial_sort will raise error when top_k_ >
|
||||||
// classification_list->classification_size().
|
// classification_list->classification_size().
|
||||||
CHECK_GE(classification_list->classification_size(), top_k_);
|
ABSL_CHECK_GE(classification_list->classification_size(), top_k_);
|
||||||
auto raw_classification_list = classification_list->mutable_classification();
|
auto raw_classification_list = classification_list->mutable_classification();
|
||||||
if (top_k_ > 0 && classification_list->classification_size() >= top_k_) {
|
if (top_k_ > 0 && classification_list->classification_size() >= top_k_) {
|
||||||
std::partial_sort(raw_classification_list->begin(),
|
std::partial_sort(raw_classification_list->begin(),
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
|
@ -94,7 +95,7 @@ void ConvertRawValuesToAnchors(const float* raw_anchors, int num_boxes,
|
||||||
|
|
||||||
void ConvertAnchorsToRawValues(const std::vector<Anchor>& anchors,
|
void ConvertAnchorsToRawValues(const std::vector<Anchor>& anchors,
|
||||||
int num_boxes, float* raw_anchors) {
|
int num_boxes, float* raw_anchors) {
|
||||||
CHECK_EQ(anchors.size(), num_boxes);
|
ABSL_CHECK_EQ(anchors.size(), num_boxes);
|
||||||
int box = 0;
|
int box = 0;
|
||||||
for (const auto& anchor : anchors) {
|
for (const auto& anchor : anchors) {
|
||||||
raw_anchors[box * kNumCoordsPerBox + 0] = anchor.y_center();
|
raw_anchors[box * kNumCoordsPerBox + 0] = anchor.y_center();
|
||||||
|
@ -289,14 +290,14 @@ absl::Status TfLiteTensorsToDetectionsCalculator::ProcessCPU(
|
||||||
const TfLiteTensor* raw_score_tensor = &input_tensors[1];
|
const TfLiteTensor* raw_score_tensor = &input_tensors[1];
|
||||||
|
|
||||||
// TODO: Add flexible input tensor size handling.
|
// TODO: Add flexible input tensor size handling.
|
||||||
CHECK_EQ(raw_box_tensor->dims->size, 3);
|
ABSL_CHECK_EQ(raw_box_tensor->dims->size, 3);
|
||||||
CHECK_EQ(raw_box_tensor->dims->data[0], 1);
|
ABSL_CHECK_EQ(raw_box_tensor->dims->data[0], 1);
|
||||||
CHECK_EQ(raw_box_tensor->dims->data[1], num_boxes_);
|
ABSL_CHECK_EQ(raw_box_tensor->dims->data[1], num_boxes_);
|
||||||
CHECK_EQ(raw_box_tensor->dims->data[2], num_coords_);
|
ABSL_CHECK_EQ(raw_box_tensor->dims->data[2], num_coords_);
|
||||||
CHECK_EQ(raw_score_tensor->dims->size, 3);
|
ABSL_CHECK_EQ(raw_score_tensor->dims->size, 3);
|
||||||
CHECK_EQ(raw_score_tensor->dims->data[0], 1);
|
ABSL_CHECK_EQ(raw_score_tensor->dims->data[0], 1);
|
||||||
CHECK_EQ(raw_score_tensor->dims->data[1], num_boxes_);
|
ABSL_CHECK_EQ(raw_score_tensor->dims->data[1], num_boxes_);
|
||||||
CHECK_EQ(raw_score_tensor->dims->data[2], num_classes_);
|
ABSL_CHECK_EQ(raw_score_tensor->dims->data[2], num_classes_);
|
||||||
const float* raw_boxes = raw_box_tensor->data.f;
|
const float* raw_boxes = raw_box_tensor->data.f;
|
||||||
const float* raw_scores = raw_score_tensor->data.f;
|
const float* raw_scores = raw_score_tensor->data.f;
|
||||||
|
|
||||||
|
@ -304,13 +305,13 @@ absl::Status TfLiteTensorsToDetectionsCalculator::ProcessCPU(
|
||||||
if (!anchors_init_) {
|
if (!anchors_init_) {
|
||||||
if (input_tensors.size() == kNumInputTensorsWithAnchors) {
|
if (input_tensors.size() == kNumInputTensorsWithAnchors) {
|
||||||
const TfLiteTensor* anchor_tensor = &input_tensors[2];
|
const TfLiteTensor* anchor_tensor = &input_tensors[2];
|
||||||
CHECK_EQ(anchor_tensor->dims->size, 2);
|
ABSL_CHECK_EQ(anchor_tensor->dims->size, 2);
|
||||||
CHECK_EQ(anchor_tensor->dims->data[0], num_boxes_);
|
ABSL_CHECK_EQ(anchor_tensor->dims->data[0], num_boxes_);
|
||||||
CHECK_EQ(anchor_tensor->dims->data[1], kNumCoordsPerBox);
|
ABSL_CHECK_EQ(anchor_tensor->dims->data[1], kNumCoordsPerBox);
|
||||||
const float* raw_anchors = anchor_tensor->data.f;
|
const float* raw_anchors = anchor_tensor->data.f;
|
||||||
ConvertRawValuesToAnchors(raw_anchors, num_boxes_, &anchors_);
|
ConvertRawValuesToAnchors(raw_anchors, num_boxes_, &anchors_);
|
||||||
} else if (side_packet_anchors_) {
|
} else if (side_packet_anchors_) {
|
||||||
CHECK(!cc->InputSidePackets().Tag("ANCHORS").IsEmpty());
|
ABSL_CHECK(!cc->InputSidePackets().Tag("ANCHORS").IsEmpty());
|
||||||
anchors_ =
|
anchors_ =
|
||||||
cc->InputSidePackets().Tag("ANCHORS").Get<std::vector<Anchor>>();
|
cc->InputSidePackets().Tag("ANCHORS").Get<std::vector<Anchor>>();
|
||||||
} else {
|
} else {
|
||||||
|
@ -410,7 +411,7 @@ absl::Status TfLiteTensorsToDetectionsCalculator::ProcessGPU(
|
||||||
CopyBuffer(input_tensors[1], gpu_data_->raw_scores_buffer));
|
CopyBuffer(input_tensors[1], gpu_data_->raw_scores_buffer));
|
||||||
if (!anchors_init_) {
|
if (!anchors_init_) {
|
||||||
if (side_packet_anchors_) {
|
if (side_packet_anchors_) {
|
||||||
CHECK(!cc->InputSidePackets().Tag("ANCHORS").IsEmpty());
|
ABSL_CHECK(!cc->InputSidePackets().Tag("ANCHORS").IsEmpty());
|
||||||
const auto& anchors =
|
const auto& anchors =
|
||||||
cc->InputSidePackets().Tag("ANCHORS").Get<std::vector<Anchor>>();
|
cc->InputSidePackets().Tag("ANCHORS").Get<std::vector<Anchor>>();
|
||||||
std::vector<float> raw_anchors(num_boxes_ * kNumCoordsPerBox);
|
std::vector<float> raw_anchors(num_boxes_ * kNumCoordsPerBox);
|
||||||
|
@ -418,7 +419,7 @@ absl::Status TfLiteTensorsToDetectionsCalculator::ProcessGPU(
|
||||||
MP_RETURN_IF_ERROR(gpu_data_->raw_anchors_buffer.Write<float>(
|
MP_RETURN_IF_ERROR(gpu_data_->raw_anchors_buffer.Write<float>(
|
||||||
absl::MakeSpan(raw_anchors)));
|
absl::MakeSpan(raw_anchors)));
|
||||||
} else {
|
} else {
|
||||||
CHECK_EQ(input_tensors.size(), kNumInputTensorsWithAnchors);
|
ABSL_CHECK_EQ(input_tensors.size(), kNumInputTensorsWithAnchors);
|
||||||
MP_RETURN_IF_ERROR(
|
MP_RETURN_IF_ERROR(
|
||||||
CopyBuffer(input_tensors[2], gpu_data_->raw_anchors_buffer));
|
CopyBuffer(input_tensors[2], gpu_data_->raw_anchors_buffer));
|
||||||
}
|
}
|
||||||
|
@ -478,7 +479,7 @@ absl::Status TfLiteTensorsToDetectionsCalculator::ProcessGPU(
|
||||||
commandBuffer:[gpu_helper_ commandBuffer]];
|
commandBuffer:[gpu_helper_ commandBuffer]];
|
||||||
if (!anchors_init_) {
|
if (!anchors_init_) {
|
||||||
if (side_packet_anchors_) {
|
if (side_packet_anchors_) {
|
||||||
CHECK(!cc->InputSidePackets().Tag("ANCHORS").IsEmpty());
|
ABSL_CHECK(!cc->InputSidePackets().Tag("ANCHORS").IsEmpty());
|
||||||
const auto& anchors =
|
const auto& anchors =
|
||||||
cc->InputSidePackets().Tag("ANCHORS").Get<std::vector<Anchor>>();
|
cc->InputSidePackets().Tag("ANCHORS").Get<std::vector<Anchor>>();
|
||||||
std::vector<float> raw_anchors(num_boxes_ * kNumCoordsPerBox);
|
std::vector<float> raw_anchors(num_boxes_ * kNumCoordsPerBox);
|
||||||
|
@ -568,12 +569,12 @@ absl::Status TfLiteTensorsToDetectionsCalculator::LoadOptions(
|
||||||
num_coords_ = options_.num_coords();
|
num_coords_ = options_.num_coords();
|
||||||
|
|
||||||
// Currently only support 2D when num_values_per_keypoint equals to 2.
|
// Currently only support 2D when num_values_per_keypoint equals to 2.
|
||||||
CHECK_EQ(options_.num_values_per_keypoint(), 2);
|
ABSL_CHECK_EQ(options_.num_values_per_keypoint(), 2);
|
||||||
|
|
||||||
// Check if the output size is equal to the requested boxes and keypoints.
|
// Check if the output size is equal to the requested boxes and keypoints.
|
||||||
CHECK_EQ(options_.num_keypoints() * options_.num_values_per_keypoint() +
|
ABSL_CHECK_EQ(options_.num_keypoints() * options_.num_values_per_keypoint() +
|
||||||
kNumCoordsPerBox,
|
kNumCoordsPerBox,
|
||||||
num_coords_);
|
num_coords_);
|
||||||
|
|
||||||
for (int i = 0; i < options_.ignore_classes_size(); ++i) {
|
for (int i = 0; i < options_.ignore_classes_size(); ++i) {
|
||||||
ignore_classes_.insert(options_.ignore_classes(i));
|
ignore_classes_.insert(options_.ignore_classes(i));
|
||||||
|
@ -898,10 +899,11 @@ void main() {
|
||||||
int max_wg_size; // typically <= 1024
|
int max_wg_size; // typically <= 1024
|
||||||
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1,
|
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1,
|
||||||
&max_wg_size); // y-dim
|
&max_wg_size); // y-dim
|
||||||
CHECK_LT(num_classes_, max_wg_size)
|
ABSL_CHECK_LT(num_classes_, max_wg_size)
|
||||||
<< "# classes must be < " << max_wg_size;
|
<< "# classes must be < " << max_wg_size;
|
||||||
// TODO support better filtering.
|
// TODO support better filtering.
|
||||||
CHECK_LE(ignore_classes_.size(), 1) << "Only ignore class 0 is allowed";
|
ABSL_CHECK_LE(ignore_classes_.size(), 1)
|
||||||
|
<< "Only ignore class 0 is allowed";
|
||||||
|
|
||||||
// Shader program
|
// Shader program
|
||||||
GlShader score_shader;
|
GlShader score_shader;
|
||||||
|
@ -1116,7 +1118,7 @@ kernel void scoreKernel(
|
||||||
ignore_classes_.size() ? 1 : 0);
|
ignore_classes_.size() ? 1 : 0);
|
||||||
|
|
||||||
// TODO support better filtering.
|
// TODO support better filtering.
|
||||||
CHECK_LE(ignore_classes_.size(), 1) << "Only ignore class 0 is allowed";
|
ABSL_CHECK_LE(ignore_classes_.size(), 1) << "Only ignore class 0 is allowed";
|
||||||
|
|
||||||
{
|
{
|
||||||
// Shader program
|
// Shader program
|
||||||
|
@ -1148,7 +1150,8 @@ kernel void scoreKernel(
|
||||||
options:MTLResourceStorageModeShared];
|
options:MTLResourceStorageModeShared];
|
||||||
// # filter classes supported is hardware dependent.
|
// # filter classes supported is hardware dependent.
|
||||||
int max_wg_size = gpu_data_->score_program.maxTotalThreadsPerThreadgroup;
|
int max_wg_size = gpu_data_->score_program.maxTotalThreadsPerThreadgroup;
|
||||||
CHECK_LT(num_classes_, max_wg_size) << "# classes must be <" << max_wg_size;
|
ABSL_CHECK_LT(num_classes_, max_wg_size)
|
||||||
|
<< "# classes must be <" << max_wg_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MEDIAPIPE_TFLITE_GL_INFERENCE
|
#endif // MEDIAPIPE_TFLITE_GL_INFERENCE
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/tflite/tflite_tensors_to_landmarks_calculator.pb.h"
|
#include "mediapipe/calculators/tflite/tflite_tensors_to_landmarks_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/landmark.pb.h"
|
#include "mediapipe/framework/formats/landmark.pb.h"
|
||||||
|
@ -199,7 +200,7 @@ absl::Status TfLiteTensorsToLandmarksCalculator::Process(
|
||||||
num_values *= raw_tensor->dims->data[i];
|
num_values *= raw_tensor->dims->data[i];
|
||||||
}
|
}
|
||||||
const int num_dimensions = num_values / num_landmarks_;
|
const int num_dimensions = num_values / num_landmarks_;
|
||||||
CHECK_GT(num_dimensions, 0);
|
ABSL_CHECK_GT(num_dimensions, 0);
|
||||||
|
|
||||||
const float* raw_landmarks = raw_tensor->data.f;
|
const float* raw_landmarks = raw_tensor->data.f;
|
||||||
|
|
||||||
|
|
|
@ -378,6 +378,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:location",
|
"//mediapipe/framework/formats:location",
|
||||||
"//mediapipe/framework/port:rectangle",
|
"//mediapipe/framework/port:rectangle",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
@ -677,6 +678,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/util:color_cc_proto",
|
"//mediapipe/util:color_cc_proto",
|
||||||
"//mediapipe/util:render_data_cc_proto",
|
"//mediapipe/util:render_data_cc_proto",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
|
@ -733,6 +735,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:statusor",
|
"//mediapipe/framework/port:statusor",
|
||||||
"//mediapipe/util:color_cc_proto",
|
"//mediapipe/util:color_cc_proto",
|
||||||
"//mediapipe/util:render_data_cc_proto",
|
"//mediapipe/util:render_data_cc_proto",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
@ -748,6 +751,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/util:color_cc_proto",
|
"//mediapipe/util:color_cc_proto",
|
||||||
"//mediapipe/util:render_data_cc_proto",
|
"//mediapipe/util:render_data_cc_proto",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
)
|
)
|
||||||
|
@ -1212,6 +1216,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:rectangle",
|
"//mediapipe/framework/port:rectangle",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/util:rectangle_util",
|
"//mediapipe/util:rectangle_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
@ -1483,6 +1488,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats:landmark_cc_proto",
|
"//mediapipe/framework/formats:landmark_cc_proto",
|
||||||
"//mediapipe/framework/port:core_proto",
|
"//mediapipe/framework/port:core_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "mediapipe/calculators/util/association_calculator.pb.h"
|
#include "mediapipe/calculators/util/association_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_context.h"
|
#include "mediapipe/framework/calculator_context.h"
|
||||||
|
@ -72,7 +73,7 @@ class AssociationCalculator : public CalculatorBase {
|
||||||
prev_input_stream_id_ = cc->Inputs().GetId("PREV", 0);
|
prev_input_stream_id_ = cc->Inputs().GetId("PREV", 0);
|
||||||
}
|
}
|
||||||
options_ = cc->Options<::mediapipe::AssociationCalculatorOptions>();
|
options_ = cc->Options<::mediapipe::AssociationCalculatorOptions>();
|
||||||
CHECK_GE(options_.min_similarity_threshold(), 0);
|
ABSL_CHECK_GE(options_.min_similarity_threshold(), 0);
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/str_join.h"
|
#include "absl/strings/str_join.h"
|
||||||
|
@ -233,13 +234,13 @@ void DetectionsToRenderDataCalculator::AddLabels(
|
||||||
const Detection& detection,
|
const Detection& detection,
|
||||||
const DetectionsToRenderDataCalculatorOptions& options,
|
const DetectionsToRenderDataCalculatorOptions& options,
|
||||||
float text_line_height, RenderData* render_data) {
|
float text_line_height, RenderData* render_data) {
|
||||||
CHECK(detection.label().empty() || detection.label_id().empty() ||
|
ABSL_CHECK(detection.label().empty() || detection.label_id().empty() ||
|
||||||
detection.label_size() == detection.label_id_size())
|
detection.label_size() == detection.label_id_size())
|
||||||
<< "String or integer labels should be of same size. Or only one of them "
|
<< "String or integer labels should be of same size. Or only one of them "
|
||||||
"is present.";
|
"is present.";
|
||||||
const auto num_labels =
|
const auto num_labels =
|
||||||
std::max(detection.label_size(), detection.label_id_size());
|
std::max(detection.label_size(), detection.label_id_size());
|
||||||
CHECK_EQ(detection.score_size(), num_labels)
|
ABSL_CHECK_EQ(detection.score_size(), num_labels)
|
||||||
<< "Number of scores and labels should match for detection.";
|
<< "Number of scores and labels should match for detection.";
|
||||||
|
|
||||||
// Extracts all "label(_id),score" for the detection.
|
// Extracts all "label(_id),score" for the detection.
|
||||||
|
@ -361,9 +362,9 @@ void DetectionsToRenderDataCalculator::AddDetectionToRenderData(
|
||||||
const Detection& detection,
|
const Detection& detection,
|
||||||
const DetectionsToRenderDataCalculatorOptions& options,
|
const DetectionsToRenderDataCalculatorOptions& options,
|
||||||
RenderData* render_data) {
|
RenderData* render_data) {
|
||||||
CHECK(detection.location_data().format() == LocationData::BOUNDING_BOX ||
|
ABSL_CHECK(detection.location_data().format() == LocationData::BOUNDING_BOX ||
|
||||||
detection.location_data().format() ==
|
detection.location_data().format() ==
|
||||||
LocationData::RELATIVE_BOUNDING_BOX)
|
LocationData::RELATIVE_BOUNDING_BOX)
|
||||||
<< "Only Detection with formats of BOUNDING_BOX or RELATIVE_BOUNDING_BOX "
|
<< "Only Detection with formats of BOUNDING_BOX or RELATIVE_BOUNDING_BOX "
|
||||||
"are supported.";
|
"are supported.";
|
||||||
double text_line_height;
|
double text_line_height;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "mediapipe/calculators/util/labels_to_render_data_calculator.pb.h"
|
#include "mediapipe/calculators/util/labels_to_render_data_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -114,7 +115,8 @@ absl::Status LabelsToRenderDataCalculator::Process(CalculatorContext* cc) {
|
||||||
video_height_ = video_header.height;
|
video_height_ = video_header.height;
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
} else {
|
} else {
|
||||||
CHECK_EQ(options_.location(), LabelsToRenderDataCalculatorOptions::TOP_LEFT)
|
ABSL_CHECK_EQ(options_.location(),
|
||||||
|
LabelsToRenderDataCalculatorOptions::TOP_LEFT)
|
||||||
<< "Only TOP_LEFT is supported without VIDEO_PRESTREAM.";
|
<< "Only TOP_LEFT is supported without VIDEO_PRESTREAM.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +146,7 @@ absl::Status LabelsToRenderDataCalculator::Process(CalculatorContext* cc) {
|
||||||
if (cc->Inputs().HasTag(kScoresTag)) {
|
if (cc->Inputs().HasTag(kScoresTag)) {
|
||||||
std::vector<float> score_vector =
|
std::vector<float> score_vector =
|
||||||
cc->Inputs().Tag(kScoresTag).Get<std::vector<float>>();
|
cc->Inputs().Tag(kScoresTag).Get<std::vector<float>>();
|
||||||
CHECK_EQ(label_vector.size(), score_vector.size());
|
ABSL_CHECK_EQ(label_vector.size(), score_vector.size());
|
||||||
scores.resize(label_vector.size());
|
scores.resize(label_vector.size());
|
||||||
for (int i = 0; i < label_vector.size(); ++i) {
|
for (int i = 0; i < label_vector.size(); ++i) {
|
||||||
scores[i] = score_vector[i];
|
scores[i] = score_vector[i];
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "mediapipe/calculators/util/landmarks_refinement_calculator.pb.h"
|
#include "mediapipe/calculators/util/landmarks_refinement_calculator.pb.h"
|
||||||
#include "mediapipe/framework/api2/node.h"
|
#include "mediapipe/framework/api2/node.h"
|
||||||
|
@ -102,7 +103,8 @@ void RefineZ(
|
||||||
->set_z(z_average);
|
->set_z(z_average);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CHECK(false) << "Z refinement is either not specified or not supported";
|
ABSL_CHECK(false)
|
||||||
|
<< "Z refinement is either not specified or not supported";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "mediapipe/calculators/util/non_max_suppression_calculator.pb.h"
|
#include "mediapipe/calculators/util/non_max_suppression_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -47,8 +48,8 @@ bool RetainMaxScoringLabelOnly(Detection* detection) {
|
||||||
if (detection->label_id_size() == 0 && detection->label_size() == 0) {
|
if (detection->label_id_size() == 0 && detection->label_size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CHECK(detection->label_id_size() == detection->score_size() ||
|
ABSL_CHECK(detection->label_id_size() == detection->score_size() ||
|
||||||
detection->label_size() == detection->score_size())
|
detection->label_size() == detection->score_size())
|
||||||
<< "Number of scores must be equal to number of detections.";
|
<< "Number of scores must be equal to number of detections.";
|
||||||
|
|
||||||
std::vector<std::pair<int, float>> indexed_scores;
|
std::vector<std::pair<int, float>> indexed_scores;
|
||||||
|
@ -171,9 +172,9 @@ class NonMaxSuppressionCalculator : public CalculatorBase {
|
||||||
cc->SetOffset(TimestampDiff(0));
|
cc->SetOffset(TimestampDiff(0));
|
||||||
|
|
||||||
options_ = cc->Options<NonMaxSuppressionCalculatorOptions>();
|
options_ = cc->Options<NonMaxSuppressionCalculatorOptions>();
|
||||||
CHECK_GT(options_.num_detection_streams(), 0)
|
ABSL_CHECK_GT(options_.num_detection_streams(), 0)
|
||||||
<< "At least one detection stream need to be specified.";
|
<< "At least one detection stream need to be specified.";
|
||||||
CHECK_NE(options_.max_num_detections(), 0)
|
ABSL_CHECK_NE(options_.max_num_detections(), 0)
|
||||||
<< "max_num_detections=0 is not a valid value. Please choose a "
|
<< "max_num_detections=0 is not a valid value. Please choose a "
|
||||||
<< "positive number of you want to limit the number of output "
|
<< "positive number of you want to limit the number of output "
|
||||||
<< "detections, or set -1 if you do not want any limit.";
|
<< "detections, or set -1 if you do not want any limit.";
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/calculators/util/rect_to_render_data_calculator.pb.h"
|
#include "mediapipe/calculators/util/rect_to_render_data_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/rect.pb.h"
|
#include "mediapipe/framework/formats/rect.pb.h"
|
||||||
|
@ -41,8 +42,8 @@ RenderAnnotation::Rectangle* NewRect(
|
||||||
annotation->set_thickness(options.thickness());
|
annotation->set_thickness(options.thickness());
|
||||||
|
|
||||||
if (options.has_top_left_thickness()) {
|
if (options.has_top_left_thickness()) {
|
||||||
CHECK(!options.oval());
|
ABSL_CHECK(!options.oval());
|
||||||
CHECK(!options.filled());
|
ABSL_CHECK(!options.filled());
|
||||||
annotation->mutable_rectangle()->set_top_left_thickness(
|
annotation->mutable_rectangle()->set_top_left_thickness(
|
||||||
options.top_left_thickness());
|
options.top_left_thickness());
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,6 +170,7 @@ cc_library(
|
||||||
"//mediapipe/framework/formats/motion:optical_flow_field",
|
"//mediapipe/framework/formats/motion:optical_flow_field",
|
||||||
"//mediapipe/framework/port:opencv_video",
|
"//mediapipe/framework/port:opencv_video",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
@ -195,6 +196,7 @@ cc_library(
|
||||||
"//mediapipe/util/tracking:motion_estimation",
|
"//mediapipe/util/tracking:motion_estimation",
|
||||||
"//mediapipe/util/tracking:motion_models",
|
"//mediapipe/util/tracking:motion_models",
|
||||||
"//mediapipe/util/tracking:region_flow_cc_proto",
|
"//mediapipe/util/tracking:region_flow_cc_proto",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
|
@ -211,6 +213,7 @@ cc_library(
|
||||||
"//mediapipe/util/tracking:camera_motion_cc_proto",
|
"//mediapipe/util/tracking:camera_motion_cc_proto",
|
||||||
"//mediapipe/util/tracking:flow_packager",
|
"//mediapipe/util/tracking:flow_packager",
|
||||||
"//mediapipe/util/tracking:region_flow_cc_proto",
|
"//mediapipe/util/tracking:region_flow_cc_proto",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/strings:str_format",
|
"@com_google_absl//absl/strings:str_format",
|
||||||
|
@ -238,6 +241,7 @@ cc_library(
|
||||||
"@com_google_absl//absl/container:flat_hash_set",
|
"@com_google_absl//absl/container:flat_hash_set",
|
||||||
"@com_google_absl//absl/container:node_hash_map",
|
"@com_google_absl//absl/container:node_hash_map",
|
||||||
"@com_google_absl//absl/container:node_hash_set",
|
"@com_google_absl//absl/container:node_hash_set",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
|
@ -265,6 +269,7 @@ cc_library(
|
||||||
"//mediapipe/util/tracking:box_tracker_cc_proto",
|
"//mediapipe/util/tracking:box_tracker_cc_proto",
|
||||||
"//mediapipe/util/tracking:flow_packager_cc_proto",
|
"//mediapipe/util/tracking:flow_packager_cc_proto",
|
||||||
"//mediapipe/util/tracking:tracking_visualization_utilities",
|
"//mediapipe/util/tracking:tracking_visualization_utilities",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
@ -451,6 +456,7 @@ cc_test(
|
||||||
"//mediapipe/framework/tool:test_util",
|
"//mediapipe/framework/tool:test_util",
|
||||||
"//mediapipe/util/tracking:box_tracker_cc_proto",
|
"//mediapipe/util/tracking:box_tracker_cc_proto",
|
||||||
"//mediapipe/util/tracking:tracking_cc_proto",
|
"//mediapipe/util/tracking:tracking_cc_proto",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/numbers.h"
|
#include "absl/strings/numbers.h"
|
||||||
|
@ -277,8 +278,8 @@ absl::Status BoxDetectorCalculator::Process(CalculatorContext* cc) {
|
||||||
? &(cc->Inputs().Tag(kDescriptorsTag))
|
? &(cc->Inputs().Tag(kDescriptorsTag))
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
CHECK(track_stream != nullptr || video_stream != nullptr ||
|
ABSL_CHECK(track_stream != nullptr || video_stream != nullptr ||
|
||||||
(feature_stream != nullptr && descriptor_stream != nullptr))
|
(feature_stream != nullptr && descriptor_stream != nullptr))
|
||||||
<< "One and only one of {tracking_data, input image frame, "
|
<< "One and only one of {tracking_data, input image frame, "
|
||||||
"feature/descriptor} need to be valid.";
|
"feature/descriptor} need to be valid.";
|
||||||
|
|
||||||
|
@ -296,7 +297,7 @@ absl::Status BoxDetectorCalculator::Process(CalculatorContext* cc) {
|
||||||
|
|
||||||
const TrackingData& tracking_data = track_stream->Get<TrackingData>();
|
const TrackingData& tracking_data = track_stream->Get<TrackingData>();
|
||||||
|
|
||||||
CHECK(tracked_boxes_stream != nullptr) << "tracked_boxes needed.";
|
ABSL_CHECK(tracked_boxes_stream != nullptr) << "tracked_boxes needed.";
|
||||||
|
|
||||||
const TimedBoxProtoList tracked_boxes =
|
const TimedBoxProtoList tracked_boxes =
|
||||||
tracked_boxes_stream->Get<TimedBoxProtoList>();
|
tracked_boxes_stream->Get<TimedBoxProtoList>();
|
||||||
|
@ -360,7 +361,7 @@ absl::Status BoxDetectorCalculator::Process(CalculatorContext* cc) {
|
||||||
|
|
||||||
const auto& descriptors = descriptor_stream->Get<std::vector<float>>();
|
const auto& descriptors = descriptor_stream->Get<std::vector<float>>();
|
||||||
const int dims = options_.detector_options().descriptor_dims();
|
const int dims = options_.detector_options().descriptor_dims();
|
||||||
CHECK_GE(descriptors.size(), feature_size * dims);
|
ABSL_CHECK_GE(descriptors.size(), feature_size * dims);
|
||||||
cv::Mat descriptors_mat(feature_size, dims, CV_32F);
|
cv::Mat descriptors_mat(feature_size, dims, CV_32F);
|
||||||
for (int j = 0; j < feature_size; ++j) {
|
for (int j = 0; j < feature_size; ++j) {
|
||||||
features_vec[j].Set(features[j].pt.x * inv_scale,
|
features_vec[j].Set(features[j].pt.x * inv_scale,
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "absl/container/flat_hash_set.h"
|
#include "absl/container/flat_hash_set.h"
|
||||||
#include "absl/container/node_hash_map.h"
|
#include "absl/container/node_hash_map.h"
|
||||||
#include "absl/container/node_hash_set.h"
|
#include "absl/container/node_hash_set.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/strings/numbers.h"
|
#include "absl/strings/numbers.h"
|
||||||
#include "mediapipe/calculators/video/box_tracker_calculator.pb.h"
|
#include "mediapipe/calculators/video/box_tracker_calculator.pb.h"
|
||||||
|
@ -315,16 +316,16 @@ void ConvertCoordinateForRotation(float in_top, float in_left, float in_bottom,
|
||||||
float in_right, int rotation, float* out_top,
|
float in_right, int rotation, float* out_top,
|
||||||
float* out_left, float* out_bottom,
|
float* out_left, float* out_bottom,
|
||||||
float* out_right) {
|
float* out_right) {
|
||||||
CHECK(out_top != nullptr);
|
ABSL_CHECK(out_top != nullptr);
|
||||||
CHECK(out_left != nullptr);
|
ABSL_CHECK(out_left != nullptr);
|
||||||
CHECK(out_bottom != nullptr);
|
ABSL_CHECK(out_bottom != nullptr);
|
||||||
CHECK(out_right != nullptr);
|
ABSL_CHECK(out_right != nullptr);
|
||||||
const float in_center_x = (in_left + in_right) * 0.5f;
|
const float in_center_x = (in_left + in_right) * 0.5f;
|
||||||
const float in_center_y = (in_top + in_bottom) * 0.5f;
|
const float in_center_y = (in_top + in_bottom) * 0.5f;
|
||||||
const float in_width = in_right - in_left;
|
const float in_width = in_right - in_left;
|
||||||
const float in_height = in_bottom - in_top;
|
const float in_height = in_bottom - in_top;
|
||||||
CHECK_GT(in_width, 0);
|
ABSL_CHECK_GT(in_width, 0);
|
||||||
CHECK_GT(in_height, 0);
|
ABSL_CHECK_GT(in_height, 0);
|
||||||
float out_center_x;
|
float out_center_x;
|
||||||
float out_center_y;
|
float out_center_y;
|
||||||
float out_width;
|
float out_width;
|
||||||
|
@ -373,7 +374,7 @@ void ConvertCoordinateForRotation(float in_top, float in_left, float in_bottom,
|
||||||
|
|
||||||
void AddStateToPath(const MotionBoxState& state, int64_t time_msec,
|
void AddStateToPath(const MotionBoxState& state, int64_t time_msec,
|
||||||
PathSegment* path) {
|
PathSegment* path) {
|
||||||
CHECK(path);
|
ABSL_CHECK(path);
|
||||||
TimedBox result;
|
TimedBox result;
|
||||||
TimedBoxFromMotionBoxState(state, &result);
|
TimedBoxFromMotionBoxState(state, &result);
|
||||||
result.time_msec = time_msec;
|
result.time_msec = time_msec;
|
||||||
|
@ -651,7 +652,7 @@ absl::Status BoxTrackerCalculator::Process(CalculatorContext* cc) {
|
||||||
// present at this frame.
|
// present at this frame.
|
||||||
TimedBoxProtoList box_track_list;
|
TimedBoxProtoList box_track_list;
|
||||||
|
|
||||||
CHECK(box_tracker_ || track_stream)
|
ABSL_CHECK(box_tracker_ || track_stream)
|
||||||
<< "Expected either batch or streaming mode";
|
<< "Expected either batch or streaming mode";
|
||||||
|
|
||||||
// Corresponding list of box states for rendering. For each id present at
|
// Corresponding list of box states for rendering. For each id present at
|
||||||
|
@ -1001,7 +1002,7 @@ void BoxTrackerCalculator::OutputRandomAccessTrack(
|
||||||
|
|
||||||
const int init_frame = timestamp_pos - track_timestamps_.begin() +
|
const int init_frame = timestamp_pos - track_timestamps_.begin() +
|
||||||
track_timestamps_base_index_;
|
track_timestamps_base_index_;
|
||||||
CHECK_GE(init_frame, 0);
|
ABSL_CHECK_GE(init_frame, 0);
|
||||||
|
|
||||||
MotionBoxMap single_map =
|
MotionBoxMap single_map =
|
||||||
PrepareRandomAccessTrack(start, init_frame, forward_track, start_data);
|
PrepareRandomAccessTrack(start, init_frame, forward_track, start_data);
|
||||||
|
@ -1168,8 +1169,8 @@ void BoxTrackerCalculator::StreamTrack(const TrackingData& data,
|
||||||
int64_t duration_ms, bool forward,
|
int64_t duration_ms, bool forward,
|
||||||
MotionBoxMap* box_map,
|
MotionBoxMap* box_map,
|
||||||
std::vector<int>* failed_ids) {
|
std::vector<int>* failed_ids) {
|
||||||
CHECK(box_map);
|
ABSL_CHECK(box_map);
|
||||||
CHECK(failed_ids);
|
ABSL_CHECK(failed_ids);
|
||||||
|
|
||||||
// Cache the actively discarded tracked ids from the new tracking data.
|
// Cache the actively discarded tracked ids from the new tracking data.
|
||||||
for (const int discarded_id :
|
for (const int discarded_id :
|
||||||
|
@ -1235,7 +1236,7 @@ void BoxTrackerCalculator::FastForwardStartPos(
|
||||||
// Start at previous frame.
|
// Start at previous frame.
|
||||||
const int init_frame = timestamp_pos - track_timestamps_.begin() +
|
const int init_frame = timestamp_pos - track_timestamps_.begin() +
|
||||||
track_timestamps_base_index_;
|
track_timestamps_base_index_;
|
||||||
CHECK_GE(init_frame, 0);
|
ABSL_CHECK_GE(init_frame, 0);
|
||||||
|
|
||||||
// Locate corresponding tracking data.
|
// Locate corresponding tracking data.
|
||||||
auto start_data = std::find_if(
|
auto start_data = std::find_if(
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
|
@ -160,7 +161,7 @@ absl::Status FlowPackagerCalculator::Process(CalculatorContext* cc) {
|
||||||
timestamp.Value() / 1000 / options_.caching_chunk_size_msec();
|
timestamp.Value() / 1000 / options_.caching_chunk_size_msec();
|
||||||
tracking_chunk_.set_first_chunk(true);
|
tracking_chunk_.set_first_chunk(true);
|
||||||
}
|
}
|
||||||
CHECK_GE(chunk_idx_, 0);
|
ABSL_CHECK_GE(chunk_idx_, 0);
|
||||||
|
|
||||||
TrackingDataChunk::Item* item = tracking_chunk_.add_item();
|
TrackingDataChunk::Item* item = tracking_chunk_.add_item();
|
||||||
item->set_frame_idx(frame_idx_);
|
item->set_frame_idx(frame_idx_);
|
||||||
|
@ -267,7 +268,7 @@ void FlowPackagerCalculator::WriteChunk(const TrackingDataChunk& chunk) const {
|
||||||
|
|
||||||
void FlowPackagerCalculator::PrepareCurrentForNextChunk(
|
void FlowPackagerCalculator::PrepareCurrentForNextChunk(
|
||||||
TrackingDataChunk* chunk) {
|
TrackingDataChunk* chunk) {
|
||||||
CHECK(chunk);
|
ABSL_CHECK(chunk);
|
||||||
if (chunk->item_size() == 0) {
|
if (chunk->item_size() == 0) {
|
||||||
ABSL_LOG(ERROR) << "Called with empty chunk. Unexpected.";
|
ABSL_LOG(ERROR) << "Called with empty chunk. Unexpected.";
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/strings/numbers.h"
|
#include "absl/strings/numbers.h"
|
||||||
#include "absl/strings/str_split.h"
|
#include "absl/strings/str_split.h"
|
||||||
|
@ -429,7 +430,7 @@ absl::Status MotionAnalysisCalculator::Process(CalculatorContext* cc) {
|
||||||
selection_input_ ? &(cc->Inputs().Tag(kSelectionTag)) : nullptr;
|
selection_input_ ? &(cc->Inputs().Tag(kSelectionTag)) : nullptr;
|
||||||
|
|
||||||
// Checked on Open.
|
// Checked on Open.
|
||||||
CHECK(video_stream || selection_stream);
|
ABSL_CHECK(video_stream || selection_stream);
|
||||||
|
|
||||||
// Lazy init.
|
// Lazy init.
|
||||||
if (frame_width_ < 0 || frame_height_ < 0) {
|
if (frame_width_ < 0 || frame_height_ < 0) {
|
||||||
|
@ -473,7 +474,7 @@ absl::Status MotionAnalysisCalculator::Process(CalculatorContext* cc) {
|
||||||
// Always use frame if selection is not activated.
|
// Always use frame if selection is not activated.
|
||||||
bool use_frame = !selection_input_;
|
bool use_frame = !selection_input_;
|
||||||
if (selection_input_) {
|
if (selection_input_) {
|
||||||
CHECK(selection_stream);
|
ABSL_CHECK(selection_stream);
|
||||||
|
|
||||||
// Fill in timestamps we process.
|
// Fill in timestamps we process.
|
||||||
if (!selection_stream->Value().IsEmpty()) {
|
if (!selection_stream->Value().IsEmpty()) {
|
||||||
|
@ -621,7 +622,7 @@ void MotionAnalysisCalculator::OutputMotionAnalyzedFrames(
|
||||||
const int num_results = motion_analysis_->GetResults(
|
const int num_results = motion_analysis_->GetResults(
|
||||||
flush, &features, &camera_motions, with_saliency_ ? &saliency : nullptr);
|
flush, &features, &camera_motions, with_saliency_ ? &saliency : nullptr);
|
||||||
|
|
||||||
CHECK_LE(num_results, buffer_size);
|
ABSL_CHECK_LE(num_results, buffer_size);
|
||||||
|
|
||||||
if (num_results == 0) {
|
if (num_results == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -696,7 +697,7 @@ void MotionAnalysisCalculator::OutputMotionAnalyzedFrames(
|
||||||
|
|
||||||
if (hybrid_meta_analysis_) {
|
if (hybrid_meta_analysis_) {
|
||||||
hybrid_meta_offset_ -= num_results;
|
hybrid_meta_offset_ -= num_results;
|
||||||
CHECK_GE(hybrid_meta_offset_, 0);
|
ABSL_CHECK_GE(hybrid_meta_offset_, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp_buffer_.erase(timestamp_buffer_.begin(),
|
timestamp_buffer_.erase(timestamp_buffer_.begin(),
|
||||||
|
@ -767,7 +768,7 @@ absl::Status MotionAnalysisCalculator::InitOnProcess(
|
||||||
|
|
||||||
// Filled by CSV file parsing.
|
// Filled by CSV file parsing.
|
||||||
if (!meta_homographies_.empty()) {
|
if (!meta_homographies_.empty()) {
|
||||||
CHECK(csv_file_input_);
|
ABSL_CHECK(csv_file_input_);
|
||||||
AppendCameraMotionsFromHomographies(meta_homographies_,
|
AppendCameraMotionsFromHomographies(meta_homographies_,
|
||||||
true, // append identity.
|
true, // append identity.
|
||||||
&meta_motions_, &meta_features_);
|
&meta_motions_, &meta_features_);
|
||||||
|
@ -814,7 +815,7 @@ bool MotionAnalysisCalculator::ParseModelCSV(
|
||||||
bool MotionAnalysisCalculator::HomographiesFromValues(
|
bool MotionAnalysisCalculator::HomographiesFromValues(
|
||||||
const std::vector<float>& homog_values,
|
const std::vector<float>& homog_values,
|
||||||
std::deque<Homography>* homographies) {
|
std::deque<Homography>* homographies) {
|
||||||
CHECK(homographies);
|
ABSL_CHECK(homographies);
|
||||||
|
|
||||||
// Obvious constants are obvious :D
|
// Obvious constants are obvious :D
|
||||||
constexpr int kHomographyValues = 9;
|
constexpr int kHomographyValues = 9;
|
||||||
|
@ -856,7 +857,7 @@ bool MotionAnalysisCalculator::HomographiesFromValues(
|
||||||
void MotionAnalysisCalculator::SubtractMetaMotion(
|
void MotionAnalysisCalculator::SubtractMetaMotion(
|
||||||
const CameraMotion& meta_motion, RegionFlowFeatureList* features) {
|
const CameraMotion& meta_motion, RegionFlowFeatureList* features) {
|
||||||
if (meta_motion.mixture_homography().model_size() > 0) {
|
if (meta_motion.mixture_homography().model_size() > 0) {
|
||||||
CHECK(row_weights_ != nullptr);
|
ABSL_CHECK(row_weights_ != nullptr);
|
||||||
RegionFlowFeatureListViaTransform(meta_motion.mixture_homography(),
|
RegionFlowFeatureListViaTransform(meta_motion.mixture_homography(),
|
||||||
features, -1.0f,
|
features, -1.0f,
|
||||||
1.0f, // subtract transformed.
|
1.0f, // subtract transformed.
|
||||||
|
@ -902,7 +903,7 @@ void MotionAnalysisCalculator::AddMetaMotion(
|
||||||
const CameraMotion& meta_motion, const RegionFlowFeatureList& meta_features,
|
const CameraMotion& meta_motion, const RegionFlowFeatureList& meta_features,
|
||||||
RegionFlowFeatureList* features, CameraMotion* motion) {
|
RegionFlowFeatureList* features, CameraMotion* motion) {
|
||||||
// Restore old feature location.
|
// Restore old feature location.
|
||||||
CHECK_EQ(meta_features.feature_size(), features->feature_size());
|
ABSL_CHECK_EQ(meta_features.feature_size(), features->feature_size());
|
||||||
for (int k = 0; k < meta_features.feature_size(); ++k) {
|
for (int k = 0; k < meta_features.feature_size(); ++k) {
|
||||||
auto feature = features->mutable_feature(k);
|
auto feature = features->mutable_feature(k);
|
||||||
const auto& meta_feature = meta_features.feature(k);
|
const auto& meta_feature = meta_features.feature(k);
|
||||||
|
@ -923,8 +924,8 @@ void MotionAnalysisCalculator::AppendCameraMotionsFromHomographies(
|
||||||
const std::deque<Homography>& homographies, bool append_identity,
|
const std::deque<Homography>& homographies, bool append_identity,
|
||||||
std::deque<CameraMotion>* camera_motions,
|
std::deque<CameraMotion>* camera_motions,
|
||||||
std::deque<RegionFlowFeatureList>* features) {
|
std::deque<RegionFlowFeatureList>* features) {
|
||||||
CHECK(camera_motions);
|
ABSL_CHECK(camera_motions);
|
||||||
CHECK(features);
|
ABSL_CHECK(features);
|
||||||
|
|
||||||
CameraMotion identity;
|
CameraMotion identity;
|
||||||
identity.set_frame_width(frame_width_);
|
identity.set_frame_width(frame_width_);
|
||||||
|
@ -948,8 +949,9 @@ void MotionAnalysisCalculator::AppendCameraMotionsFromHomographies(
|
||||||
}
|
}
|
||||||
|
|
||||||
const int models_per_frame = options_.meta_models_per_frame();
|
const int models_per_frame = options_.meta_models_per_frame();
|
||||||
CHECK_GT(models_per_frame, 0) << "At least one model per frame is needed";
|
ABSL_CHECK_GT(models_per_frame, 0)
|
||||||
CHECK_EQ(0, homographies.size() % models_per_frame);
|
<< "At least one model per frame is needed";
|
||||||
|
ABSL_CHECK_EQ(0, homographies.size() % models_per_frame);
|
||||||
const int num_frames = homographies.size() / models_per_frame;
|
const int num_frames = homographies.size() / models_per_frame;
|
||||||
|
|
||||||
// Heuristic sigma, similar to what we use for rolling shutter removal.
|
// Heuristic sigma, similar to what we use for rolling shutter removal.
|
||||||
|
|
|
@ -44,6 +44,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/tool:status_util",
|
"//mediapipe/framework/tool:status_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "mediapipe/calculators/video/tool/flow_quantizer_model.h"
|
#include "mediapipe/calculators/video/tool/flow_quantizer_model.h"
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/port/ret_check.h"
|
#include "mediapipe/framework/port/ret_check.h"
|
||||||
#include "mediapipe/framework/type_map.h"
|
#include "mediapipe/framework/type_map.h"
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ namespace mediapipe {
|
||||||
|
|
||||||
// Uniform normalization to 0-255.
|
// Uniform normalization to 0-255.
|
||||||
uint8_t FlowQuantizerModel::Apply(const float val, const int channel) const {
|
uint8_t FlowQuantizerModel::Apply(const float val, const int channel) const {
|
||||||
CHECK_LT(channel, model_.min_value_size());
|
ABSL_CHECK_LT(channel, model_.min_value_size());
|
||||||
const auto& min_value = model_.min_value(channel);
|
const auto& min_value = model_.min_value(channel);
|
||||||
const auto& max_value = model_.max_value(channel);
|
const auto& max_value = model_.max_value(channel);
|
||||||
QCHECK_GT(max_value, min_value);
|
QCHECK_GT(max_value, min_value);
|
||||||
|
@ -51,7 +52,7 @@ const QuantizerModelData& FlowQuantizerModel::GetModelData() const {
|
||||||
// TODO: Taking the min and max over all training flow fields might be
|
// TODO: Taking the min and max over all training flow fields might be
|
||||||
// sensitive to noise. We should use more robust statistics.
|
// sensitive to noise. We should use more robust statistics.
|
||||||
void FlowQuantizerModel::AddSampleFlowField(const OpticalFlowField& flow) {
|
void FlowQuantizerModel::AddSampleFlowField(const OpticalFlowField& flow) {
|
||||||
CHECK_EQ(model_.min_value_size(), 2);
|
ABSL_CHECK_EQ(model_.min_value_size(), 2);
|
||||||
const cv::Mat_<cv::Point2f>& flow_mat = flow.flow_data();
|
const cv::Mat_<cv::Point2f>& flow_mat = flow.flow_data();
|
||||||
for (int i = 0; i != flow.width(); ++i) {
|
for (int i = 0; i != flow.width(); ++i) {
|
||||||
for (int j = 0; j != flow.height(); ++j) {
|
for (int j = 0; j != flow.height(); ++j) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "mediapipe/calculators/video/box_tracker_calculator.pb.h"
|
#include "mediapipe/calculators/video/box_tracker_calculator.pb.h"
|
||||||
#include "mediapipe/framework/calculator.pb.h"
|
#include "mediapipe/framework/calculator.pb.h"
|
||||||
|
@ -298,7 +299,7 @@ std::unique_ptr<TimedBoxProtoList>
|
||||||
TrackingGraphTest::CreateRandomAccessTrackingBoxList(
|
TrackingGraphTest::CreateRandomAccessTrackingBoxList(
|
||||||
const std::vector<Timestamp>& start_timestamps,
|
const std::vector<Timestamp>& start_timestamps,
|
||||||
const std::vector<Timestamp>& end_timestamps) const {
|
const std::vector<Timestamp>& end_timestamps) const {
|
||||||
CHECK_EQ(start_timestamps.size(), end_timestamps.size());
|
ABSL_CHECK_EQ(start_timestamps.size(), end_timestamps.size());
|
||||||
auto ra_boxes = absl::make_unique<TimedBoxProtoList>();
|
auto ra_boxes = absl::make_unique<TimedBoxProtoList>();
|
||||||
for (int i = 0; i < start_timestamps.size(); ++i) {
|
for (int i = 0; i < start_timestamps.size(); ++i) {
|
||||||
auto start_box_list =
|
auto start_box_list =
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "absl/base/macros.h"
|
#include "absl/base/macros.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/synchronization/mutex.h"
|
#include "absl/synchronization/mutex.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
#include "mediapipe/framework/formats/image_frame.h"
|
#include "mediapipe/framework/formats/image_frame.h"
|
||||||
|
@ -158,7 +159,7 @@ absl::Status Tvl1OpticalFlowCalculator::Process(CalculatorContext* cc) {
|
||||||
absl::Status Tvl1OpticalFlowCalculator::CalculateOpticalFlow(
|
absl::Status Tvl1OpticalFlowCalculator::CalculateOpticalFlow(
|
||||||
const ImageFrame& current_frame, const ImageFrame& next_frame,
|
const ImageFrame& current_frame, const ImageFrame& next_frame,
|
||||||
OpticalFlowField* flow) {
|
OpticalFlowField* flow) {
|
||||||
CHECK(flow);
|
ABSL_CHECK(flow);
|
||||||
if (!ImageSizesMatch(current_frame, next_frame)) {
|
if (!ImageSizesMatch(current_frame, next_frame)) {
|
||||||
return tool::StatusInvalid("Images are different sizes.");
|
return tool::StatusInvalid("Images are different sizes.");
|
||||||
}
|
}
|
||||||
|
@ -182,7 +183,7 @@ absl::Status Tvl1OpticalFlowCalculator::CalculateOpticalFlow(
|
||||||
flow->Allocate(first.cols, first.rows);
|
flow->Allocate(first.cols, first.rows);
|
||||||
cv::Mat cv_flow(flow->mutable_flow_data());
|
cv::Mat cv_flow(flow->mutable_flow_data());
|
||||||
tvl1_computer->calc(first, second, cv_flow);
|
tvl1_computer->calc(first, second, cv_flow);
|
||||||
CHECK_EQ(flow->mutable_flow_data().data, cv_flow.data);
|
ABSL_CHECK_EQ(flow->mutable_flow_data().data, cv_flow.data);
|
||||||
// Inserts the idle DenseOpticalFlow object back to the cache for reuse.
|
// Inserts the idle DenseOpticalFlow object back to the cache for reuse.
|
||||||
{
|
{
|
||||||
absl::MutexLock lock(&mutex_);
|
absl::MutexLock lock(&mutex_);
|
||||||
|
|
|
@ -68,7 +68,7 @@ cc_library(
|
||||||
hdrs = ["piecewise_linear_function.h"],
|
hdrs = ["piecewise_linear_function.h"],
|
||||||
deps = [
|
deps = [
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"@com_google_absl//absl/log:check",
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ cc_test(
|
||||||
"//mediapipe/framework/port:gtest_main",
|
"//mediapipe/framework/port:gtest_main",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"@com_google_absl//absl/flags:flag",
|
"@com_google_absl//absl/flags:flag",
|
||||||
"@com_google_absl//absl/log:check",
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -285,6 +285,7 @@ cc_test(
|
||||||
"//mediapipe/framework/port:gtest_main",
|
"//mediapipe/framework/port:gtest_main",
|
||||||
"//mediapipe/framework/port:opencv_core",
|
"//mediapipe/framework/port:opencv_core",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/log/check.h"
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/port/status.h"
|
#include "mediapipe/framework/port/status.h"
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
@ -28,7 +28,7 @@ namespace autoflip {
|
||||||
|
|
||||||
void PiecewiseLinearFunction::AddPoint(double x, double y) {
|
void PiecewiseLinearFunction::AddPoint(double x, double y) {
|
||||||
if (!points_.empty()) {
|
if (!points_.empty()) {
|
||||||
CHECK_GE(x, points_.back().x)
|
ABSL_CHECK_GE(x, points_.back().x)
|
||||||
<< "Points must be provided in non-decreasing x order.";
|
<< "Points must be provided in non-decreasing x order.";
|
||||||
}
|
}
|
||||||
points_.push_back(PiecewiseLinearFunction::Point(x, y));
|
points_.push_back(PiecewiseLinearFunction::Point(x, y));
|
||||||
|
@ -46,8 +46,8 @@ PiecewiseLinearFunction::GetIntervalIterator(double input) const {
|
||||||
double PiecewiseLinearFunction::Interpolate(
|
double PiecewiseLinearFunction::Interpolate(
|
||||||
const PiecewiseLinearFunction::Point& p1,
|
const PiecewiseLinearFunction::Point& p1,
|
||||||
const PiecewiseLinearFunction::Point& p2, double input) const {
|
const PiecewiseLinearFunction::Point& p2, double input) const {
|
||||||
CHECK_LT(p1.x, input);
|
ABSL_CHECK_LT(p1.x, input);
|
||||||
CHECK_GE(p2.x, input);
|
ABSL_CHECK_GE(p2.x, input);
|
||||||
|
|
||||||
return p2.y - (p2.x - input) / (p2.x - p1.x) * (p2.y - p1.y);
|
return p2.y - (p2.x - input) / (p2.x - p1.x) * (p2.y - p1.y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "mediapipe/examples/desktop/autoflip/quality/polynomial_regression_path_solver.h"
|
#include "mediapipe/examples/desktop/autoflip/quality/polynomial_regression_path_solver.h"
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/examples/desktop/autoflip/quality/focus_point.pb.h"
|
#include "mediapipe/examples/desktop/autoflip/quality/focus_point.pb.h"
|
||||||
#include "mediapipe/framework/port/gmock.h"
|
#include "mediapipe/framework/port/gmock.h"
|
||||||
#include "mediapipe/framework/port/gtest.h"
|
#include "mediapipe/framework/port/gtest.h"
|
||||||
|
@ -145,8 +146,8 @@ void GenerateDataPointsFromRealVideo(
|
||||||
const int prior_focus_point_frames_length,
|
const int prior_focus_point_frames_length,
|
||||||
std::vector<FocusPointFrame>* focus_point_frames,
|
std::vector<FocusPointFrame>* focus_point_frames,
|
||||||
std::vector<FocusPointFrame>* prior_focus_point_frames) {
|
std::vector<FocusPointFrame>* prior_focus_point_frames) {
|
||||||
CHECK(focus_point_frames_length + prior_focus_point_frames_length <=
|
ABSL_CHECK(focus_point_frames_length + prior_focus_point_frames_length <=
|
||||||
kNumObservations);
|
kNumObservations);
|
||||||
for (int i = 0; i < prior_focus_point_frames_length; i++) {
|
for (int i = 0; i < prior_focus_point_frames_length; i++) {
|
||||||
FocusPoint sp;
|
FocusPoint sp;
|
||||||
sp.set_norm_point_x(data[i]);
|
sp.set_norm_point_x(data[i]);
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace autoflip {
|
||||||
// SceneCameraMotionAnalyzer analyzer(options);
|
// SceneCameraMotionAnalyzer analyzer(options);
|
||||||
// SceneKeyFrameCropSummary scene_summary;
|
// SceneKeyFrameCropSummary scene_summary;
|
||||||
// std::vector<FocusPointFrame> focus_point_frames;
|
// std::vector<FocusPointFrame> focus_point_frames;
|
||||||
// CHECK_OK(analyzer.AnalyzeScenePopulateFocusPointFrames(
|
// ABSL_CHECK_OK(analyzer.AnalyzeScenePopulateFocusPointFrames(
|
||||||
// key_frame_crop_infos, key_frame_crop_options, key_frame_crop_results,
|
// key_frame_crop_infos, key_frame_crop_options, key_frame_crop_results,
|
||||||
// scene_frame_width, scene_frame_height, scene_frame_timestamps,
|
// scene_frame_width, scene_frame_height, scene_frame_timestamps,
|
||||||
// &scene_summary, &focus_point_frames));
|
// &scene_summary, &focus_point_frames));
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/flags/flag.h"
|
#include "absl/flags/flag.h"
|
||||||
#include "absl/log/check.h"
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_split.h"
|
#include "absl/strings/str_split.h"
|
||||||
#include "mediapipe/examples/desktop/autoflip/autoflip_messages.pb.h"
|
#include "mediapipe/examples/desktop/autoflip/autoflip_messages.pb.h"
|
||||||
#include "mediapipe/examples/desktop/autoflip/quality/focus_point.pb.h"
|
#include "mediapipe/examples/desktop/autoflip/quality/focus_point.pb.h"
|
||||||
|
@ -745,7 +745,7 @@ TEST(SceneCameraMotionAnalyzerTest,
|
||||||
std::vector<std::string> r = absl::StrSplit(line, ',');
|
std::vector<std::string> r = absl::StrSplit(line, ',');
|
||||||
records.insert(records.end(), r.begin(), r.end());
|
records.insert(records.end(), r.begin(), r.end());
|
||||||
}
|
}
|
||||||
CHECK_EQ(records.size(), kNumSceneFrames * 3 + 1);
|
ABSL_CHECK_EQ(records.size(), kNumSceneFrames * 3 + 1);
|
||||||
|
|
||||||
std::vector<FocusPointFrame> focus_point_frames;
|
std::vector<FocusPointFrame> focus_point_frames;
|
||||||
MP_EXPECT_OK(analyzer.PopulateFocusPointFrames(
|
MP_EXPECT_OK(analyzer.PopulateFocusPointFrames(
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace autoflip {
|
||||||
// SceneCropperOptions scene_cropper_options;
|
// SceneCropperOptions scene_cropper_options;
|
||||||
// SceneCropper scene_cropper(scene_cropper_options);
|
// SceneCropper scene_cropper(scene_cropper_options);
|
||||||
// std::vector<cv::Mat> cropped_frames;
|
// std::vector<cv::Mat> cropped_frames;
|
||||||
// CHECK_OK(scene_cropper.CropFrames(
|
// ABSL_CHECK_OK(scene_cropper.CropFrames(
|
||||||
// scene_summary, scene_frames, focus_point_frames,
|
// scene_summary, scene_frames, focus_point_frames,
|
||||||
// prior_focus_point_frames, &cropped_frames));
|
// prior_focus_point_frames, &cropped_frames));
|
||||||
class SceneCropper {
|
class SceneCropper {
|
||||||
|
|
|
@ -24,6 +24,7 @@ cc_binary(
|
||||||
"//mediapipe/framework:calculator_graph",
|
"//mediapipe/framework:calculator_graph",
|
||||||
"//mediapipe/framework/port:parse_text_proto",
|
"//mediapipe/framework/port:parse_text_proto",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
//
|
//
|
||||||
// A simple example to print out "Hello World!" from a MediaPipe graph.
|
// A simple example to print out "Hello World!" from a MediaPipe graph.
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "mediapipe/framework/calculator_graph.h"
|
#include "mediapipe/framework/calculator_graph.h"
|
||||||
#include "mediapipe/framework/port/parse_text_proto.h"
|
#include "mediapipe/framework/port/parse_text_proto.h"
|
||||||
|
@ -62,6 +63,6 @@ absl::Status PrintHelloWorld() {
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
google::InitGoogleLogging(argv[0]);
|
google::InitGoogleLogging(argv[0]);
|
||||||
CHECK(mediapipe::PrintHelloWorld().ok());
|
ABSL_CHECK(mediapipe::PrintHelloWorld().ok());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,6 +204,7 @@ cc_library(
|
||||||
":timestamp",
|
":timestamp",
|
||||||
"//mediapipe/framework/port:any_proto",
|
"//mediapipe/framework/port:any_proto",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -220,6 +221,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:tag_map",
|
"//mediapipe/framework/tool:tag_map",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
],
|
],
|
||||||
|
@ -360,6 +362,7 @@ cc_library(
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
"@com_google_absl//absl/container:flat_hash_map",
|
"@com_google_absl//absl/container:flat_hash_map",
|
||||||
"@com_google_absl//absl/container:flat_hash_set",
|
"@com_google_absl//absl/container:flat_hash_set",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
|
@ -432,6 +435,7 @@ cc_library(
|
||||||
"//mediapipe/framework/tool:tag_map",
|
"//mediapipe/framework/tool:tag_map",
|
||||||
"//mediapipe/framework/tool:validate_name",
|
"//mediapipe/framework/tool:validate_name",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
|
@ -463,6 +467,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:sink",
|
"//mediapipe/framework/tool:sink",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
@ -489,6 +494,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/framework/tool:options_map",
|
"//mediapipe/framework/tool:options_map",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -510,6 +516,7 @@ cc_library(
|
||||||
"//mediapipe/framework/tool:tag_map_helper",
|
"//mediapipe/framework/tool:tag_map_helper",
|
||||||
"//mediapipe/framework/tool:validate_name",
|
"//mediapipe/framework/tool:validate_name",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
@ -544,6 +551,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
"//mediapipe/framework/port:map_util",
|
"//mediapipe/framework/port:map_util",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
|
@ -618,6 +626,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
|
@ -633,6 +642,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/port:statusor",
|
"//mediapipe/framework/port:statusor",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -651,6 +661,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:fill_packet_set",
|
"//mediapipe/framework/tool:fill_packet_set",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -689,6 +700,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:tag_map",
|
"//mediapipe/framework/tool:tag_map",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -709,6 +721,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:status_util",
|
"//mediapipe/framework/tool:status_util",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
],
|
],
|
||||||
|
@ -728,6 +741,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:source_location",
|
"//mediapipe/framework/port:source_location",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:status_util",
|
"//mediapipe/framework/tool:status_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -767,6 +781,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/framework/port:source_location",
|
"//mediapipe/framework/port:source_location",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -805,6 +820,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:tag_map",
|
"//mediapipe/framework/tool:tag_map",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -823,6 +839,7 @@ cc_library(
|
||||||
":timestamp",
|
":timestamp",
|
||||||
"//mediapipe/framework/port:source_location",
|
"//mediapipe/framework/port:source_location",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -833,6 +850,7 @@ cc_library(
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
":graph_output_stream",
|
":graph_output_stream",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -849,6 +867,7 @@ cc_library(
|
||||||
":timestamp",
|
":timestamp",
|
||||||
"//mediapipe/framework/port:source_location",
|
"//mediapipe/framework/port:source_location",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -873,6 +892,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:statusor",
|
"//mediapipe/framework/port:statusor",
|
||||||
"//mediapipe/framework/tool:type_util",
|
"//mediapipe/framework/tool:type_util",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
@ -954,6 +974,7 @@ cc_library(
|
||||||
"//mediapipe/framework/tool:type_util",
|
"//mediapipe/framework/tool:type_util",
|
||||||
"//mediapipe/framework/tool:validate_name",
|
"//mediapipe/framework/tool:validate_name",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
@ -1031,6 +1052,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -1090,6 +1112,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@eigen_archive//:eigen3",
|
"@eigen_archive//:eigen3",
|
||||||
],
|
],
|
||||||
|
@ -1140,6 +1163,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
|
@ -1161,8 +1185,8 @@ cc_library(
|
||||||
"//mediapipe/framework/tool:status_util",
|
"//mediapipe/framework/tool:status_util",
|
||||||
"//mediapipe/framework/tool:type_util",
|
"//mediapipe/framework/tool:type_util",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/log:check",
|
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
],
|
],
|
||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
|
@ -1216,6 +1240,7 @@ cc_library(
|
||||||
"//mediapipe/framework/tool:validate",
|
"//mediapipe/framework/tool:validate",
|
||||||
"//mediapipe/framework/tool:validate_name",
|
"//mediapipe/framework/tool:validate_name",
|
||||||
"@com_google_absl//absl/container:flat_hash_set",
|
"@com_google_absl//absl/container:flat_hash_set",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
@ -1304,6 +1329,7 @@ cc_test(
|
||||||
"//mediapipe/framework/port:parse_text_proto",
|
"//mediapipe/framework/port:parse_text_proto",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
"//mediapipe/framework/tool:source",
|
"//mediapipe/framework/tool:source",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
],
|
],
|
||||||
|
@ -1475,6 +1501,7 @@ cc_test(
|
||||||
"//mediapipe/framework/tool:status_util",
|
"//mediapipe/framework/tool:status_util",
|
||||||
"//mediapipe/gpu:gpu_service",
|
"//mediapipe/gpu:gpu_service",
|
||||||
"@com_google_absl//absl/container:fixed_array",
|
"@com_google_absl//absl/container:fixed_array",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
|
@ -1708,6 +1735,7 @@ cc_test(
|
||||||
"//mediapipe/framework/port:gtest_main",
|
"//mediapipe/framework/port:gtest_main",
|
||||||
"//mediapipe/framework/port:parse_text_proto",
|
"//mediapipe/framework/port:parse_text_proto",
|
||||||
"//mediapipe/framework/tool:template_parser",
|
"//mediapipe/framework/tool:template_parser",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:any_proto",
|
"//mediapipe/framework/port:any_proto",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"@com_google_absl//absl/container:btree",
|
"@com_google_absl//absl/container:btree",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_protobuf//:protobuf",
|
"@com_google_protobuf//:protobuf",
|
||||||
],
|
],
|
||||||
|
@ -126,6 +127,7 @@ cc_library(
|
||||||
":tuple",
|
":tuple",
|
||||||
"//mediapipe/framework:packet",
|
"//mediapipe/framework:packet",
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/meta:type_traits",
|
"@com_google_absl//absl/meta:type_traits",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -155,6 +157,7 @@ cc_library(
|
||||||
"//mediapipe/framework:output_side_packet",
|
"//mediapipe/framework:output_side_packet",
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/framework/tool:type_util",
|
"//mediapipe/framework/tool:type_util",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/container/btree_map.h"
|
#include "absl/container/btree_map.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "google/protobuf/message_lite.h"
|
#include "google/protobuf/message_lite.h"
|
||||||
#include "mediapipe/framework/api2/port.h"
|
#include "mediapipe/framework/api2/port.h"
|
||||||
|
@ -109,7 +110,7 @@ class MultiPort : public Single {
|
||||||
: Single(vec), vec_(*vec) {}
|
: Single(vec), vec_(*vec) {}
|
||||||
|
|
||||||
Single operator[](int index) {
|
Single operator[](int index) {
|
||||||
CHECK_GE(index, 0);
|
ABSL_CHECK_GE(index, 0);
|
||||||
return Single{&GetWithAutoGrow(&vec_, index)};
|
return Single{&GetWithAutoGrow(&vec_, index)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +194,7 @@ class SourceImpl {
|
||||||
template <typename U,
|
template <typename U,
|
||||||
typename std::enable_if<AllowConnection<U>{}, int>::type = 0>
|
typename std::enable_if<AllowConnection<U>{}, int>::type = 0>
|
||||||
Src& ConnectTo(const Dst<U>& dest) {
|
Src& ConnectTo(const Dst<U>& dest) {
|
||||||
CHECK(dest.base_.source == nullptr);
|
ABSL_CHECK(dest.base_.source == nullptr);
|
||||||
dest.base_.source = base_;
|
dest.base_.source = base_;
|
||||||
base_->dests_.emplace_back(&dest.base_);
|
base_->dests_.emplace_back(&dest.base_);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -721,14 +722,14 @@ class Graph {
|
||||||
config.set_type(type_);
|
config.set_type(type_);
|
||||||
}
|
}
|
||||||
FixUnnamedConnections();
|
FixUnnamedConnections();
|
||||||
CHECK_OK(UpdateBoundaryConfig(&config));
|
ABSL_CHECK_OK(UpdateBoundaryConfig(&config));
|
||||||
for (const std::unique_ptr<NodeBase>& node : nodes_) {
|
for (const std::unique_ptr<NodeBase>& node : nodes_) {
|
||||||
auto* out_node = config.add_node();
|
auto* out_node = config.add_node();
|
||||||
CHECK_OK(UpdateNodeConfig(*node, out_node));
|
ABSL_CHECK_OK(UpdateNodeConfig(*node, out_node));
|
||||||
}
|
}
|
||||||
for (const std::unique_ptr<PacketGenerator>& node : packet_gens_) {
|
for (const std::unique_ptr<PacketGenerator>& node : packet_gens_) {
|
||||||
auto* out_node = config.add_packet_generator();
|
auto* out_node = config.add_packet_generator();
|
||||||
CHECK_OK(UpdateNodeConfig(*node, out_node));
|
ABSL_CHECK_OK(UpdateNodeConfig(*node, out_node));
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -782,7 +783,7 @@ class Graph {
|
||||||
config->set_calculator(node.type_);
|
config->set_calculator(node.type_);
|
||||||
node.in_streams_.Visit(
|
node.in_streams_.Visit(
|
||||||
[&](const TagIndexLocation& loc, const DestinationBase& endpoint) {
|
[&](const TagIndexLocation& loc, const DestinationBase& endpoint) {
|
||||||
CHECK(endpoint.source != nullptr);
|
ABSL_CHECK(endpoint.source != nullptr);
|
||||||
config->add_input_stream(TaggedName(loc, endpoint.source->name_));
|
config->add_input_stream(TaggedName(loc, endpoint.source->name_));
|
||||||
});
|
});
|
||||||
node.out_streams_.Visit(
|
node.out_streams_.Visit(
|
||||||
|
@ -791,7 +792,7 @@ class Graph {
|
||||||
});
|
});
|
||||||
node.in_sides_.Visit([&](const TagIndexLocation& loc,
|
node.in_sides_.Visit([&](const TagIndexLocation& loc,
|
||||||
const DestinationBase& endpoint) {
|
const DestinationBase& endpoint) {
|
||||||
CHECK(endpoint.source != nullptr);
|
ABSL_CHECK(endpoint.source != nullptr);
|
||||||
config->add_input_side_packet(TaggedName(loc, endpoint.source->name_));
|
config->add_input_side_packet(TaggedName(loc, endpoint.source->name_));
|
||||||
});
|
});
|
||||||
node.out_sides_.Visit(
|
node.out_sides_.Visit(
|
||||||
|
@ -812,7 +813,7 @@ class Graph {
|
||||||
config->set_packet_generator(node.type_);
|
config->set_packet_generator(node.type_);
|
||||||
node.in_sides_.Visit([&](const TagIndexLocation& loc,
|
node.in_sides_.Visit([&](const TagIndexLocation& loc,
|
||||||
const DestinationBase& endpoint) {
|
const DestinationBase& endpoint) {
|
||||||
CHECK(endpoint.source != nullptr);
|
ABSL_CHECK(endpoint.source != nullptr);
|
||||||
config->add_input_side_packet(TaggedName(loc, endpoint.source->name_));
|
config->add_input_side_packet(TaggedName(loc, endpoint.source->name_));
|
||||||
});
|
});
|
||||||
node.out_sides_.Visit(
|
node.out_sides_.Visit(
|
||||||
|
@ -829,7 +830,7 @@ class Graph {
|
||||||
absl::Status UpdateBoundaryConfig(CalculatorGraphConfig* config) {
|
absl::Status UpdateBoundaryConfig(CalculatorGraphConfig* config) {
|
||||||
graph_boundary_.in_streams_.Visit(
|
graph_boundary_.in_streams_.Visit(
|
||||||
[&](const TagIndexLocation& loc, const DestinationBase& endpoint) {
|
[&](const TagIndexLocation& loc, const DestinationBase& endpoint) {
|
||||||
CHECK(endpoint.source != nullptr);
|
ABSL_CHECK(endpoint.source != nullptr);
|
||||||
config->add_output_stream(TaggedName(loc, endpoint.source->name_));
|
config->add_output_stream(TaggedName(loc, endpoint.source->name_));
|
||||||
});
|
});
|
||||||
graph_boundary_.out_streams_.Visit(
|
graph_boundary_.out_streams_.Visit(
|
||||||
|
@ -838,7 +839,7 @@ class Graph {
|
||||||
});
|
});
|
||||||
graph_boundary_.in_sides_.Visit([&](const TagIndexLocation& loc,
|
graph_boundary_.in_sides_.Visit([&](const TagIndexLocation& loc,
|
||||||
const DestinationBase& endpoint) {
|
const DestinationBase& endpoint) {
|
||||||
CHECK(endpoint.source != nullptr);
|
ABSL_CHECK(endpoint.source != nullptr);
|
||||||
config->add_output_side_packet(TaggedName(loc, endpoint.source->name_));
|
config->add_output_side_packet(TaggedName(loc, endpoint.source->name_));
|
||||||
});
|
});
|
||||||
graph_boundary_.out_sides_.Visit(
|
graph_boundary_.out_sides_.Visit(
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/meta/type_traits.h"
|
#include "absl/meta/type_traits.h"
|
||||||
#include "mediapipe/framework/api2/tuple.h"
|
#include "mediapipe/framework/api2/tuple.h"
|
||||||
#include "mediapipe/framework/packet.h"
|
#include "mediapipe/framework/packet.h"
|
||||||
|
@ -102,9 +103,9 @@ mediapipe::Packet ToOldPacket(PacketBase&& p);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline const T& PacketBase::Get() const {
|
inline const T& PacketBase::Get() const {
|
||||||
CHECK(payload_);
|
ABSL_CHECK(payload_);
|
||||||
packet_internal::Holder<T>* typed_payload = payload_->As<T>();
|
packet_internal::Holder<T>* typed_payload = payload_->As<T>();
|
||||||
CHECK(typed_payload) << absl::StrCat(
|
ABSL_CHECK(typed_payload) << absl::StrCat(
|
||||||
"The Packet stores \"", payload_->DebugTypeName(), "\", but \"",
|
"The Packet stores \"", payload_->DebugTypeName(), "\", but \"",
|
||||||
MediaPipeTypeStringOrDemangled<T>(), "\" was requested.");
|
MediaPipeTypeStringOrDemangled<T>(), "\" was requested.");
|
||||||
return typed_payload->data();
|
return typed_payload->data();
|
||||||
|
@ -134,17 +135,17 @@ namespace internal {
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void CheckCompatibleType(const HolderBase& holder, internal::Wrap<T>) {
|
inline void CheckCompatibleType(const HolderBase& holder, internal::Wrap<T>) {
|
||||||
const packet_internal::Holder<T>* typed_payload = holder.As<T>();
|
const packet_internal::Holder<T>* typed_payload = holder.As<T>();
|
||||||
CHECK(typed_payload) << absl::StrCat(
|
ABSL_CHECK(typed_payload) << absl::StrCat(
|
||||||
"The Packet stores \"", holder.DebugTypeName(), "\", but \"",
|
"The Packet stores \"", holder.DebugTypeName(), "\", but \"",
|
||||||
MediaPipeTypeStringOrDemangled<T>(), "\" was requested.");
|
MediaPipeTypeStringOrDemangled<T>(), "\" was requested.");
|
||||||
// CHECK(payload_->has_type<T>());
|
// ABSL_CHECK(payload_->has_type<T>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... T>
|
template <class... T>
|
||||||
inline void CheckCompatibleType(const HolderBase& holder,
|
inline void CheckCompatibleType(const HolderBase& holder,
|
||||||
internal::Wrap<OneOf<T...>>) {
|
internal::Wrap<OneOf<T...>>) {
|
||||||
bool compatible = (holder.As<T>() || ...);
|
bool compatible = (holder.As<T>() || ...);
|
||||||
CHECK(compatible)
|
ABSL_CHECK(compatible)
|
||||||
<< "The Packet stores \"" << holder.DebugTypeName() << "\", but one of "
|
<< "The Packet stores \"" << holder.DebugTypeName() << "\", but one of "
|
||||||
<< absl::StrJoin(
|
<< absl::StrJoin(
|
||||||
{absl::StrCat("\"", MediaPipeTypeStringOrDemangled<T>(), "\"")...},
|
{absl::StrCat("\"", MediaPipeTypeStringOrDemangled<T>(), "\"")...},
|
||||||
|
@ -211,9 +212,9 @@ class Packet : public Packet<internal::Generic> {
|
||||||
Packet<T> At(Timestamp timestamp) &&;
|
Packet<T> At(Timestamp timestamp) &&;
|
||||||
|
|
||||||
const T& Get() const {
|
const T& Get() const {
|
||||||
CHECK(payload_);
|
ABSL_CHECK(payload_);
|
||||||
packet_internal::Holder<T>* typed_payload = payload_->As<T>();
|
packet_internal::Holder<T>* typed_payload = payload_->As<T>();
|
||||||
CHECK(typed_payload);
|
ABSL_CHECK(typed_payload);
|
||||||
return typed_payload->data();
|
return typed_payload->data();
|
||||||
}
|
}
|
||||||
const T& operator*() const { return Get(); }
|
const T& operator*() const { return Get(); }
|
||||||
|
@ -330,9 +331,9 @@ class Packet<OneOf<T...>> : public PacketBase {
|
||||||
|
|
||||||
template <class U, class = AllowedType<U>>
|
template <class U, class = AllowedType<U>>
|
||||||
const U& Get() const {
|
const U& Get() const {
|
||||||
CHECK(payload_);
|
ABSL_CHECK(payload_);
|
||||||
packet_internal::Holder<U>* typed_payload = payload_->As<U>();
|
packet_internal::Holder<U>* typed_payload = payload_->As<U>();
|
||||||
CHECK(typed_payload);
|
ABSL_CHECK(typed_payload);
|
||||||
return typed_payload->data();
|
return typed_payload->data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +344,7 @@ class Packet<OneOf<T...>> : public PacketBase {
|
||||||
|
|
||||||
template <class... F>
|
template <class... F>
|
||||||
auto Visit(const F&... args) const {
|
auto Visit(const F&... args) const {
|
||||||
CHECK(payload_);
|
ABSL_CHECK(payload_);
|
||||||
auto f = internal::Overload{args...};
|
auto f = internal::Overload{args...};
|
||||||
using FirstT = typename internal::First<T...>::type;
|
using FirstT = typename internal::First<T...>::type;
|
||||||
using ResultType = absl::result_of_t<decltype(f)(const FirstT&)>;
|
using ResultType = absl::result_of_t<decltype(f)(const FirstT&)>;
|
||||||
|
@ -364,7 +365,7 @@ class Packet<OneOf<T...>> : public PacketBase {
|
||||||
|
|
||||||
template <class... F>
|
template <class... F>
|
||||||
auto ConsumeAndVisit(const F&... args) {
|
auto ConsumeAndVisit(const F&... args) {
|
||||||
CHECK(payload_);
|
ABSL_CHECK(payload_);
|
||||||
auto f = internal::Overload{args...};
|
auto f = internal::Overload{args...};
|
||||||
using FirstT = typename internal::First<T...>::type;
|
using FirstT = typename internal::First<T...>::type;
|
||||||
using VisitorResultType =
|
using VisitorResultType =
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "mediapipe/framework/api2/const_str.h"
|
#include "mediapipe/framework/api2/const_str.h"
|
||||||
|
@ -243,8 +244,8 @@ class MultiplePortAccess {
|
||||||
// container?
|
// container?
|
||||||
int Count() { return count_; }
|
int Count() { return count_; }
|
||||||
AccessT operator[](int pos) {
|
AccessT operator[](int pos) {
|
||||||
CHECK_GE(pos, 0);
|
ABSL_CHECK_GE(pos, 0);
|
||||||
CHECK_LT(pos, count_);
|
ABSL_CHECK_LT(pos, count_);
|
||||||
return SinglePortAccess<ValueT>(cc_, &first_[pos]);
|
return SinglePortAccess<ValueT>(cc_, &first_[pos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,35 +14,37 @@
|
||||||
|
|
||||||
#include "mediapipe/framework/calculator_context.h"
|
#include "mediapipe/framework/calculator_context.h"
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
|
||||||
const std::string& CalculatorContext::CalculatorType() const {
|
const std::string& CalculatorContext::CalculatorType() const {
|
||||||
CHECK(calculator_state_);
|
ABSL_CHECK(calculator_state_);
|
||||||
return calculator_state_->CalculatorType();
|
return calculator_state_->CalculatorType();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CalculatorOptions& CalculatorContext::Options() const {
|
const CalculatorOptions& CalculatorContext::Options() const {
|
||||||
CHECK(calculator_state_);
|
ABSL_CHECK(calculator_state_);
|
||||||
return calculator_state_->Options();
|
return calculator_state_->Options();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& CalculatorContext::NodeName() const {
|
const std::string& CalculatorContext::NodeName() const {
|
||||||
CHECK(calculator_state_);
|
ABSL_CHECK(calculator_state_);
|
||||||
return calculator_state_->NodeName();
|
return calculator_state_->NodeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CalculatorContext::NodeId() const {
|
int CalculatorContext::NodeId() const {
|
||||||
CHECK(calculator_state_);
|
ABSL_CHECK(calculator_state_);
|
||||||
return calculator_state_->NodeId();
|
return calculator_state_->NodeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter* CalculatorContext::GetCounter(const std::string& name) {
|
Counter* CalculatorContext::GetCounter(const std::string& name) {
|
||||||
CHECK(calculator_state_);
|
ABSL_CHECK(calculator_state_);
|
||||||
return calculator_state_->GetCounter(name);
|
return calculator_state_->GetCounter(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CounterFactory* CalculatorContext::GetCounterFactory() {
|
CounterFactory* CalculatorContext::GetCounterFactory() {
|
||||||
CHECK(calculator_state_);
|
ABSL_CHECK(calculator_state_);
|
||||||
return calculator_state_->GetCounterFactory();
|
return calculator_state_->GetCounterFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/calculator_state.h"
|
#include "mediapipe/framework/calculator_state.h"
|
||||||
#include "mediapipe/framework/counter.h"
|
#include "mediapipe/framework/counter.h"
|
||||||
#include "mediapipe/framework/graph_service.h"
|
#include "mediapipe/framework/graph_service.h"
|
||||||
|
@ -147,7 +148,7 @@ class CalculatorContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopInputTimestamp() {
|
void PopInputTimestamp() {
|
||||||
CHECK(!input_timestamps_.empty());
|
ABSL_CHECK(!input_timestamps_.empty());
|
||||||
input_timestamps_.pop();
|
input_timestamps_.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/synchronization/mutex.h"
|
#include "absl/synchronization/mutex.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
#include "mediapipe/framework/port/logging.h"
|
||||||
|
@ -27,7 +28,7 @@ void CalculatorContextManager::Initialize(
|
||||||
std::shared_ptr<tool::TagMap> input_tag_map,
|
std::shared_ptr<tool::TagMap> input_tag_map,
|
||||||
std::shared_ptr<tool::TagMap> output_tag_map,
|
std::shared_ptr<tool::TagMap> output_tag_map,
|
||||||
bool calculator_run_in_parallel) {
|
bool calculator_run_in_parallel) {
|
||||||
CHECK(calculator_state);
|
ABSL_CHECK(calculator_state);
|
||||||
calculator_state_ = calculator_state;
|
calculator_state_ = calculator_state;
|
||||||
input_tag_map_ = std::move(input_tag_map);
|
input_tag_map_ = std::move(input_tag_map);
|
||||||
output_tag_map_ = std::move(output_tag_map);
|
output_tag_map_ = std::move(output_tag_map);
|
||||||
|
@ -51,15 +52,15 @@ void CalculatorContextManager::CleanupAfterRun() {
|
||||||
|
|
||||||
CalculatorContext* CalculatorContextManager::GetDefaultCalculatorContext()
|
CalculatorContext* CalculatorContextManager::GetDefaultCalculatorContext()
|
||||||
const {
|
const {
|
||||||
CHECK(default_context_.get());
|
ABSL_CHECK(default_context_.get());
|
||||||
return default_context_.get();
|
return default_context_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CalculatorContext* CalculatorContextManager::GetFrontCalculatorContext(
|
CalculatorContext* CalculatorContextManager::GetFrontCalculatorContext(
|
||||||
Timestamp* context_input_timestamp) {
|
Timestamp* context_input_timestamp) {
|
||||||
CHECK(calculator_run_in_parallel_);
|
ABSL_CHECK(calculator_run_in_parallel_);
|
||||||
absl::MutexLock lock(&contexts_mutex_);
|
absl::MutexLock lock(&contexts_mutex_);
|
||||||
CHECK(!active_contexts_.empty());
|
ABSL_CHECK(!active_contexts_.empty());
|
||||||
*context_input_timestamp = active_contexts_.begin()->first;
|
*context_input_timestamp = active_contexts_.begin()->first;
|
||||||
return active_contexts_.begin()->second.get();
|
return active_contexts_.begin()->second.get();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +71,7 @@ CalculatorContext* CalculatorContextManager::PrepareCalculatorContext(
|
||||||
return GetDefaultCalculatorContext();
|
return GetDefaultCalculatorContext();
|
||||||
}
|
}
|
||||||
absl::MutexLock lock(&contexts_mutex_);
|
absl::MutexLock lock(&contexts_mutex_);
|
||||||
CHECK(!mediapipe::ContainsKey(active_contexts_, input_timestamp))
|
ABSL_CHECK(!mediapipe::ContainsKey(active_contexts_, input_timestamp))
|
||||||
<< "Multiple invocations with the same timestamps are not allowed with "
|
<< "Multiple invocations with the same timestamps are not allowed with "
|
||||||
"parallel execution, input_timestamp = "
|
"parallel execution, input_timestamp = "
|
||||||
<< input_timestamp;
|
<< input_timestamp;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "absl/base/thread_annotations.h"
|
#include "absl/base/thread_annotations.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/synchronization/mutex.h"
|
#include "absl/synchronization/mutex.h"
|
||||||
#include "mediapipe/framework/calculator_context.h"
|
#include "mediapipe/framework/calculator_context.h"
|
||||||
#include "mediapipe/framework/calculator_state.h"
|
#include "mediapipe/framework/calculator_state.h"
|
||||||
|
@ -97,18 +98,18 @@ class CalculatorContextManager {
|
||||||
|
|
||||||
void PushInputTimestampToContext(CalculatorContext* calculator_context,
|
void PushInputTimestampToContext(CalculatorContext* calculator_context,
|
||||||
Timestamp input_timestamp) {
|
Timestamp input_timestamp) {
|
||||||
CHECK(calculator_context);
|
ABSL_CHECK(calculator_context);
|
||||||
calculator_context->PushInputTimestamp(input_timestamp);
|
calculator_context->PushInputTimestamp(input_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopInputTimestampFromContext(CalculatorContext* calculator_context) {
|
void PopInputTimestampFromContext(CalculatorContext* calculator_context) {
|
||||||
CHECK(calculator_context);
|
ABSL_CHECK(calculator_context);
|
||||||
calculator_context->PopInputTimestamp();
|
calculator_context->PopInputTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetGraphStatusInContext(CalculatorContext* calculator_context,
|
void SetGraphStatusInContext(CalculatorContext* calculator_context,
|
||||||
const absl::Status& status) {
|
const absl::Status& status) {
|
||||||
CHECK(calculator_context);
|
ABSL_CHECK(calculator_context);
|
||||||
calculator_context->SetGraphStatus(status);
|
calculator_context->SetGraphStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/container/flat_hash_set.h"
|
#include "absl/container/flat_hash_set.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
|
@ -172,7 +173,7 @@ absl::Status CalculatorGraph::InitializePacketGeneratorGraph(
|
||||||
Executor* default_executor = nullptr;
|
Executor* default_executor = nullptr;
|
||||||
if (!use_application_thread_) {
|
if (!use_application_thread_) {
|
||||||
default_executor = executors_[""].get();
|
default_executor = executors_[""].get();
|
||||||
CHECK(default_executor);
|
ABSL_CHECK(default_executor);
|
||||||
}
|
}
|
||||||
// If default_executor is nullptr, then packet_generator_graph_ will create
|
// If default_executor is nullptr, then packet_generator_graph_ will create
|
||||||
// its own DelegatingExecutor to use the application thread.
|
// its own DelegatingExecutor to use the application thread.
|
||||||
|
@ -925,7 +926,7 @@ absl::Status CalculatorGraph::AddPacketToInputStreamInternal(
|
||||||
"graph input stream.",
|
"graph input stream.",
|
||||||
stream_name);
|
stream_name);
|
||||||
int node_id = mediapipe::FindOrDie(graph_input_stream_node_ids_, stream_name);
|
int node_id = mediapipe::FindOrDie(graph_input_stream_node_ids_, stream_name);
|
||||||
CHECK_GE(node_id, validated_graph_->CalculatorInfos().size());
|
ABSL_CHECK_GE(node_id, validated_graph_->CalculatorInfos().size());
|
||||||
{
|
{
|
||||||
absl::MutexLock lock(&full_input_streams_mutex_);
|
absl::MutexLock lock(&full_input_streams_mutex_);
|
||||||
if (full_input_streams_.empty()) {
|
if (full_input_streams_.empty()) {
|
||||||
|
@ -1113,7 +1114,8 @@ void CalculatorGraph::CallStatusHandlers(GraphRunState graph_run_state,
|
||||||
absl::StatusOr<std::unique_ptr<internal::StaticAccessToStatusHandler>>
|
absl::StatusOr<std::unique_ptr<internal::StaticAccessToStatusHandler>>
|
||||||
static_access_statusor = internal::StaticAccessToStatusHandlerRegistry::
|
static_access_statusor = internal::StaticAccessToStatusHandlerRegistry::
|
||||||
CreateByNameInNamespace(validated_graph_->Package(), handler_type);
|
CreateByNameInNamespace(validated_graph_->Package(), handler_type);
|
||||||
CHECK(static_access_statusor.ok()) << handler_type << " is not registered.";
|
ABSL_CHECK(static_access_statusor.ok())
|
||||||
|
<< handler_type << " is not registered.";
|
||||||
auto static_access = std::move(static_access_statusor).value();
|
auto static_access = std::move(static_access_statusor).value();
|
||||||
absl::Status handler_result;
|
absl::Status handler_result;
|
||||||
if (graph_run_state == GraphRunState::PRE_RUN) {
|
if (graph_run_state == GraphRunState::PRE_RUN) {
|
||||||
|
@ -1154,7 +1156,7 @@ void CalculatorGraph::UpdateThrottledNodes(InputStreamManager* stream,
|
||||||
upstream_nodes =
|
upstream_nodes =
|
||||||
&validated_graph_->CalculatorInfos()[node_index].AncestorSources();
|
&validated_graph_->CalculatorInfos()[node_index].AncestorSources();
|
||||||
}
|
}
|
||||||
CHECK(upstream_nodes);
|
ABSL_CHECK(upstream_nodes);
|
||||||
std::vector<CalculatorNode*> nodes_to_schedule;
|
std::vector<CalculatorNode*> nodes_to_schedule;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1176,10 +1178,10 @@ void CalculatorGraph::UpdateThrottledNodes(InputStreamManager* stream,
|
||||||
.set_stream_id(&stream->Name()));
|
.set_stream_id(&stream->Name()));
|
||||||
bool was_throttled = !full_input_streams_[node_id].empty();
|
bool was_throttled = !full_input_streams_[node_id].empty();
|
||||||
if (stream_is_full) {
|
if (stream_is_full) {
|
||||||
DCHECK_EQ(full_input_streams_[node_id].count(stream), 0);
|
ABSL_DCHECK_EQ(full_input_streams_[node_id].count(stream), 0);
|
||||||
full_input_streams_[node_id].insert(stream);
|
full_input_streams_[node_id].insert(stream);
|
||||||
} else {
|
} else {
|
||||||
DCHECK_EQ(full_input_streams_[node_id].count(stream), 1);
|
ABSL_DCHECK_EQ(full_input_streams_[node_id].count(stream), 1);
|
||||||
full_input_streams_[node_id].erase(stream);
|
full_input_streams_[node_id].erase(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1363,7 +1365,7 @@ void CalculatorGraph::CleanupAfterRun(absl::Status* status) {
|
||||||
// Obtain the combined status again, so that it includes the new errors
|
// Obtain the combined status again, so that it includes the new errors
|
||||||
// added by CallStatusHandlers.
|
// added by CallStatusHandlers.
|
||||||
GetCombinedErrors(status);
|
GetCombinedErrors(status);
|
||||||
CHECK(!status->ok());
|
ABSL_CHECK(!status->ok());
|
||||||
} else {
|
} else {
|
||||||
MEDIAPIPE_CHECK_OK(*status);
|
MEDIAPIPE_CHECK_OK(*status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/container/fixed_array.h"
|
#include "absl/container/fixed_array.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
|
@ -729,13 +730,13 @@ class SlowCountingSinkCalculator : public CalculatorBase {
|
||||||
absl::Status Process(CalculatorContext* cc) override {
|
absl::Status Process(CalculatorContext* cc) override {
|
||||||
absl::SleepFor(absl::Milliseconds(10));
|
absl::SleepFor(absl::Milliseconds(10));
|
||||||
int value = cc->Inputs().Index(0).Get<int>();
|
int value = cc->Inputs().Index(0).Get<int>();
|
||||||
CHECK_EQ(value, counter_);
|
ABSL_CHECK_EQ(value, counter_);
|
||||||
++counter_;
|
++counter_;
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status Close(CalculatorContext* cc) override {
|
absl::Status Close(CalculatorContext* cc) override {
|
||||||
CHECK_EQ(10, counter_);
|
ABSL_CHECK_EQ(10, counter_);
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,7 +1019,7 @@ class CheckInputTimestampSourceCalculator : public CalculatorBase {
|
||||||
absl::Status Close(CalculatorContext* cc) final {
|
absl::Status Close(CalculatorContext* cc) final {
|
||||||
// Must use CHECK instead of RET_CHECK in Close(), because the framework
|
// Must use CHECK instead of RET_CHECK in Close(), because the framework
|
||||||
// may call the Close() method of a source node with .IgnoreError().
|
// may call the Close() method of a source node with .IgnoreError().
|
||||||
CHECK_EQ(cc->InputTimestamp(), Timestamp::Done());
|
ABSL_CHECK_EQ(cc->InputTimestamp(), Timestamp::Done());
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1096,7 +1097,7 @@ class CheckInputTimestamp2SourceCalculator : public CalculatorBase {
|
||||||
absl::Status Close(CalculatorContext* cc) final {
|
absl::Status Close(CalculatorContext* cc) final {
|
||||||
// Must use CHECK instead of RET_CHECK in Close(), because the framework
|
// Must use CHECK instead of RET_CHECK in Close(), because the framework
|
||||||
// may call the Close() method of a source node with .IgnoreError().
|
// may call the Close() method of a source node with .IgnoreError().
|
||||||
CHECK_EQ(cc->InputTimestamp(), Timestamp::Done());
|
ABSL_CHECK_EQ(cc->InputTimestamp(), Timestamp::Done());
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1246,8 +1247,8 @@ REGISTER_STATUS_HANDLER(IncrementingStatusHandler);
|
||||||
class CurrentThreadExecutor : public Executor {
|
class CurrentThreadExecutor : public Executor {
|
||||||
public:
|
public:
|
||||||
~CurrentThreadExecutor() override {
|
~CurrentThreadExecutor() override {
|
||||||
CHECK(!executing_);
|
ABSL_CHECK(!executing_);
|
||||||
CHECK(tasks_.empty());
|
ABSL_CHECK(tasks_.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Schedule(std::function<void()> task) override {
|
void Schedule(std::function<void()> task) override {
|
||||||
|
@ -1258,7 +1259,7 @@ class CurrentThreadExecutor : public Executor {
|
||||||
// running) to avoid an indefinitely-deep call stack.
|
// running) to avoid an indefinitely-deep call stack.
|
||||||
tasks_.emplace_back(std::move(task));
|
tasks_.emplace_back(std::move(task));
|
||||||
} else {
|
} else {
|
||||||
CHECK(tasks_.empty());
|
ABSL_CHECK(tasks_.empty());
|
||||||
executing_ = true;
|
executing_ = true;
|
||||||
task();
|
task();
|
||||||
while (!tasks_.empty()) {
|
while (!tasks_.empty()) {
|
||||||
|
@ -3594,7 +3595,7 @@ REGISTER_CALCULATOR(::mediapipe::nested_ns::ProcessCallbackCalculator);
|
||||||
|
|
||||||
TEST(CalculatorGraph, CalculatorInNamepsace) {
|
TEST(CalculatorGraph, CalculatorInNamepsace) {
|
||||||
CalculatorGraphConfig config;
|
CalculatorGraphConfig config;
|
||||||
CHECK(proto_ns::TextFormat::ParseFromString(R"(
|
ABSL_CHECK(proto_ns::TextFormat::ParseFromString(R"(
|
||||||
input_stream: 'in_a'
|
input_stream: 'in_a'
|
||||||
node {
|
node {
|
||||||
calculator: 'mediapipe.nested_ns.ProcessCallbackCalculator'
|
calculator: 'mediapipe.nested_ns.ProcessCallbackCalculator'
|
||||||
|
@ -3603,7 +3604,7 @@ TEST(CalculatorGraph, CalculatorInNamepsace) {
|
||||||
input_side_packet: 'callback_1'
|
input_side_packet: 'callback_1'
|
||||||
}
|
}
|
||||||
)",
|
)",
|
||||||
&config));
|
&config));
|
||||||
CalculatorGraph graph;
|
CalculatorGraph graph;
|
||||||
MP_ASSERT_OK(graph.Initialize(config));
|
MP_ASSERT_OK(graph.Initialize(config));
|
||||||
nested_ns::ProcessFunction callback_1;
|
nested_ns::ProcessFunction callback_1;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
|
@ -60,7 +61,7 @@ const PacketType* GetPacketType(const PacketTypeSet& packet_type_set,
|
||||||
} else {
|
} else {
|
||||||
id = packet_type_set.GetId(tag, 0);
|
id = packet_type_set.GetId(tag, 0);
|
||||||
}
|
}
|
||||||
CHECK(id.IsValid()) << "Internal mediapipe error.";
|
ABSL_CHECK(id.IsValid()) << "Internal mediapipe error.";
|
||||||
return &packet_type_set.Get(id);
|
return &packet_type_set.Get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +343,7 @@ absl::Status CalculatorNode::ConnectShardsToStreams(
|
||||||
|
|
||||||
void CalculatorNode::SetExecutor(const std::string& executor) {
|
void CalculatorNode::SetExecutor(const std::string& executor) {
|
||||||
absl::MutexLock status_lock(&status_mutex_);
|
absl::MutexLock status_lock(&status_mutex_);
|
||||||
CHECK_LT(status_, kStateOpened);
|
ABSL_CHECK_LT(status_, kStateOpened);
|
||||||
executor_ = executor;
|
executor_ = executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +368,7 @@ bool CalculatorNode::Closed() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculatorNode::SetMaxInputStreamQueueSize(int max_queue_size) {
|
void CalculatorNode::SetMaxInputStreamQueueSize(int max_queue_size) {
|
||||||
CHECK(input_stream_handler_);
|
ABSL_CHECK(input_stream_handler_);
|
||||||
input_stream_handler_->SetMaxQueueSize(max_queue_size);
|
input_stream_handler_->SetMaxQueueSize(max_queue_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +541,7 @@ absl::Status CalculatorNode::OpenNode() {
|
||||||
|
|
||||||
void CalculatorNode::ActivateNode() {
|
void CalculatorNode::ActivateNode() {
|
||||||
absl::MutexLock status_lock(&status_mutex_);
|
absl::MutexLock status_lock(&status_mutex_);
|
||||||
CHECK_EQ(status_, kStateOpened) << DebugName();
|
ABSL_CHECK_EQ(status_, kStateOpened) << DebugName();
|
||||||
status_ = kStateActive;
|
status_ = kStateActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,8 +696,8 @@ void CalculatorNode::InputStreamHeadersReady() {
|
||||||
bool ready_for_open = false;
|
bool ready_for_open = false;
|
||||||
{
|
{
|
||||||
absl::MutexLock lock(&status_mutex_);
|
absl::MutexLock lock(&status_mutex_);
|
||||||
CHECK_EQ(status_, kStatePrepared) << DebugName();
|
ABSL_CHECK_EQ(status_, kStatePrepared) << DebugName();
|
||||||
CHECK(!input_stream_headers_ready_called_);
|
ABSL_CHECK(!input_stream_headers_ready_called_);
|
||||||
input_stream_headers_ready_called_ = true;
|
input_stream_headers_ready_called_ = true;
|
||||||
input_stream_headers_ready_ = true;
|
input_stream_headers_ready_ = true;
|
||||||
ready_for_open = input_side_packets_ready_;
|
ready_for_open = input_side_packets_ready_;
|
||||||
|
@ -710,8 +711,8 @@ void CalculatorNode::InputSidePacketsReady() {
|
||||||
bool ready_for_open = false;
|
bool ready_for_open = false;
|
||||||
{
|
{
|
||||||
absl::MutexLock lock(&status_mutex_);
|
absl::MutexLock lock(&status_mutex_);
|
||||||
CHECK_EQ(status_, kStatePrepared) << DebugName();
|
ABSL_CHECK_EQ(status_, kStatePrepared) << DebugName();
|
||||||
CHECK(!input_side_packets_ready_called_);
|
ABSL_CHECK(!input_side_packets_ready_called_);
|
||||||
input_side_packets_ready_called_ = true;
|
input_side_packets_ready_called_ = true;
|
||||||
input_side_packets_ready_ = true;
|
input_side_packets_ready_ = true;
|
||||||
ready_for_open = input_stream_headers_ready_;
|
ready_for_open = input_stream_headers_ready_;
|
||||||
|
@ -761,7 +762,7 @@ void CalculatorNode::EndScheduling() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
--current_in_flight_;
|
--current_in_flight_;
|
||||||
CHECK_GE(current_in_flight_, 0);
|
ABSL_CHECK_GE(current_in_flight_, 0);
|
||||||
|
|
||||||
if (scheduling_state_ == kScheduling) {
|
if (scheduling_state_ == kScheduling) {
|
||||||
// Changes the state to scheduling pending if another thread is doing the
|
// Changes the state to scheduling pending if another thread is doing the
|
||||||
|
@ -791,7 +792,7 @@ std::string CalculatorNode::DebugInputStreamNames() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CalculatorNode::DebugName() const {
|
std::string CalculatorNode::DebugName() const {
|
||||||
DCHECK(calculator_state_);
|
ABSL_DCHECK(calculator_state_);
|
||||||
return calculator_state_->NodeName();
|
return calculator_state_->NodeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,9 +895,9 @@ absl::Status CalculatorNode::ProcessNode(
|
||||||
// open input streams for Process(). So this node needs to be closed
|
// open input streams for Process(). So this node needs to be closed
|
||||||
// too.
|
// too.
|
||||||
// If the streams are closed, there shouldn't be more input.
|
// If the streams are closed, there shouldn't be more input.
|
||||||
CHECK_EQ(calculator_context_manager_.NumberOfContextTimestamps(
|
ABSL_CHECK_EQ(calculator_context_manager_.NumberOfContextTimestamps(
|
||||||
*calculator_context),
|
*calculator_context),
|
||||||
1);
|
1);
|
||||||
return CloseNode(absl::OkStatus(), /*graph_run_ended=*/false);
|
return CloseNode(absl::OkStatus(), /*graph_run_ended=*/false);
|
||||||
} else {
|
} else {
|
||||||
RET_CHECK_FAIL()
|
RET_CHECK_FAIL()
|
||||||
|
@ -911,7 +912,7 @@ absl::Status CalculatorNode::ProcessNode(
|
||||||
void CalculatorNode::SetQueueSizeCallbacks(
|
void CalculatorNode::SetQueueSizeCallbacks(
|
||||||
InputStreamManager::QueueSizeCallback becomes_full_callback,
|
InputStreamManager::QueueSizeCallback becomes_full_callback,
|
||||||
InputStreamManager::QueueSizeCallback becomes_not_full_callback) {
|
InputStreamManager::QueueSizeCallback becomes_not_full_callback) {
|
||||||
CHECK(input_stream_handler_);
|
ABSL_CHECK(input_stream_handler_);
|
||||||
input_stream_handler_->SetQueueSizeCallbacks(
|
input_stream_handler_->SetQueueSizeCallbacks(
|
||||||
std::move(becomes_full_callback), std::move(becomes_not_full_callback));
|
std::move(becomes_full_callback), std::move(becomes_not_full_callback));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "mediapipe/framework/calculator_framework.h"
|
#include "mediapipe/framework/calculator_framework.h"
|
||||||
|
@ -104,7 +105,7 @@ class CalculatorNodeTest : public ::testing::Test {
|
||||||
void ReadyForOpen(int* count) { ++(*count); }
|
void ReadyForOpen(int* count) { ++(*count); }
|
||||||
|
|
||||||
void Notification(CalculatorContext* cc, int* count) {
|
void Notification(CalculatorContext* cc, int* count) {
|
||||||
CHECK(cc);
|
ABSL_CHECK(cc);
|
||||||
cc_ = cc;
|
cc_ = cc;
|
||||||
++(*count);
|
++(*count);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "mediapipe/framework/calculator_runner.h"
|
#include "mediapipe/framework/calculator_runner.h"
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
|
@ -139,7 +140,7 @@ CalculatorRunner::CalculatorRunner(const std::string& calculator_type,
|
||||||
#if !defined(MEDIAPIPE_PROTO_LITE)
|
#if !defined(MEDIAPIPE_PROTO_LITE)
|
||||||
CalculatorRunner::CalculatorRunner(const std::string& node_config_string) {
|
CalculatorRunner::CalculatorRunner(const std::string& node_config_string) {
|
||||||
CalculatorGraphConfig::Node node_config;
|
CalculatorGraphConfig::Node node_config;
|
||||||
CHECK(
|
ABSL_CHECK(
|
||||||
proto_ns::TextFormat::ParseFromString(node_config_string, &node_config));
|
proto_ns::TextFormat::ParseFromString(node_config_string, &node_config));
|
||||||
MEDIAPIPE_CHECK_OK(InitializeFromNodeConfig(node_config));
|
MEDIAPIPE_CHECK_OK(InitializeFromNodeConfig(node_config));
|
||||||
}
|
}
|
||||||
|
@ -149,8 +150,8 @@ CalculatorRunner::CalculatorRunner(const std::string& calculator_type,
|
||||||
int num_inputs, int num_outputs,
|
int num_inputs, int num_outputs,
|
||||||
int num_side_packets) {
|
int num_side_packets) {
|
||||||
node_config_.set_calculator(calculator_type);
|
node_config_.set_calculator(calculator_type);
|
||||||
CHECK(proto_ns::TextFormat::ParseFromString(options_string,
|
ABSL_CHECK(proto_ns::TextFormat::ParseFromString(
|
||||||
node_config_.mutable_options()));
|
options_string, node_config_.mutable_options()));
|
||||||
SetNumInputs(num_inputs);
|
SetNumInputs(num_inputs);
|
||||||
SetNumOutputs(num_outputs);
|
SetNumOutputs(num_outputs);
|
||||||
SetNumInputSidePackets(num_side_packets);
|
SetNumInputSidePackets(num_side_packets);
|
||||||
|
@ -188,7 +189,7 @@ void CalculatorRunner::SetNumInputSidePackets(int n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculatorRunner::InitializeInputs(const tool::TagAndNameInfo& info) {
|
void CalculatorRunner::InitializeInputs(const tool::TagAndNameInfo& info) {
|
||||||
CHECK(graph_ == nullptr);
|
ABSL_CHECK(graph_ == nullptr);
|
||||||
MEDIAPIPE_CHECK_OK(
|
MEDIAPIPE_CHECK_OK(
|
||||||
tool::SetFromTagAndNameInfo(info, node_config_.mutable_input_stream()));
|
tool::SetFromTagAndNameInfo(info, node_config_.mutable_input_stream()));
|
||||||
inputs_.reset(new StreamContentsSet(info));
|
inputs_.reset(new StreamContentsSet(info));
|
||||||
|
@ -196,7 +197,7 @@ void CalculatorRunner::InitializeInputs(const tool::TagAndNameInfo& info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculatorRunner::InitializeOutputs(const tool::TagAndNameInfo& info) {
|
void CalculatorRunner::InitializeOutputs(const tool::TagAndNameInfo& info) {
|
||||||
CHECK(graph_ == nullptr);
|
ABSL_CHECK(graph_ == nullptr);
|
||||||
MEDIAPIPE_CHECK_OK(
|
MEDIAPIPE_CHECK_OK(
|
||||||
tool::SetFromTagAndNameInfo(info, node_config_.mutable_output_stream()));
|
tool::SetFromTagAndNameInfo(info, node_config_.mutable_output_stream()));
|
||||||
outputs_.reset(new StreamContentsSet(info));
|
outputs_.reset(new StreamContentsSet(info));
|
||||||
|
@ -205,7 +206,7 @@ void CalculatorRunner::InitializeOutputs(const tool::TagAndNameInfo& info) {
|
||||||
|
|
||||||
void CalculatorRunner::InitializeInputSidePackets(
|
void CalculatorRunner::InitializeInputSidePackets(
|
||||||
const tool::TagAndNameInfo& info) {
|
const tool::TagAndNameInfo& info) {
|
||||||
CHECK(graph_ == nullptr);
|
ABSL_CHECK(graph_ == nullptr);
|
||||||
MEDIAPIPE_CHECK_OK(tool::SetFromTagAndNameInfo(
|
MEDIAPIPE_CHECK_OK(tool::SetFromTagAndNameInfo(
|
||||||
info, node_config_.mutable_input_side_packet()));
|
info, node_config_.mutable_input_side_packet()));
|
||||||
input_side_packets_.reset(new PacketSet(info));
|
input_side_packets_.reset(new PacketSet(info));
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
#include "mediapipe/framework/port/logging.h"
|
||||||
|
|
||||||
|
@ -46,23 +47,23 @@ void CalculatorState::ResetBetweenRuns() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculatorState::SetInputSidePackets(const PacketSet* input_side_packets) {
|
void CalculatorState::SetInputSidePackets(const PacketSet* input_side_packets) {
|
||||||
CHECK(input_side_packets);
|
ABSL_CHECK(input_side_packets);
|
||||||
input_side_packets_ = input_side_packets;
|
input_side_packets_ = input_side_packets;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculatorState::SetOutputSidePackets(
|
void CalculatorState::SetOutputSidePackets(
|
||||||
OutputSidePacketSet* output_side_packets) {
|
OutputSidePacketSet* output_side_packets) {
|
||||||
CHECK(output_side_packets);
|
ABSL_CHECK(output_side_packets);
|
||||||
output_side_packets_ = output_side_packets;
|
output_side_packets_ = output_side_packets;
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter* CalculatorState::GetCounter(const std::string& name) {
|
Counter* CalculatorState::GetCounter(const std::string& name) {
|
||||||
CHECK(counter_factory_);
|
ABSL_CHECK(counter_factory_);
|
||||||
return counter_factory_->GetCounter(absl::StrCat(NodeName(), "-", name));
|
return counter_factory_->GetCounter(absl::StrCat(NodeName(), "-", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
CounterFactory* CalculatorState::GetCounterFactory() {
|
CounterFactory* CalculatorState::GetCounterFactory() {
|
||||||
CHECK(counter_factory_);
|
ABSL_CHECK(counter_factory_);
|
||||||
return counter_factory_;
|
return counter_factory_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/base/macros.h"
|
#include "absl/base/macros.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
|
@ -413,16 +414,16 @@ bool Collection<T, storage, ErrorHandler>::UsesTags() const {
|
||||||
template <typename T, CollectionStorage storage, typename ErrorHandler>
|
template <typename T, CollectionStorage storage, typename ErrorHandler>
|
||||||
typename Collection<T, storage, ErrorHandler>::value_type&
|
typename Collection<T, storage, ErrorHandler>::value_type&
|
||||||
Collection<T, storage, ErrorHandler>::Get(CollectionItemId id) {
|
Collection<T, storage, ErrorHandler>::Get(CollectionItemId id) {
|
||||||
CHECK_LE(BeginId(), id);
|
ABSL_CHECK_LE(BeginId(), id);
|
||||||
CHECK_LT(id, EndId());
|
ABSL_CHECK_LT(id, EndId());
|
||||||
return begin()[id.value()];
|
return begin()[id.value()];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, CollectionStorage storage, typename ErrorHandler>
|
template <typename T, CollectionStorage storage, typename ErrorHandler>
|
||||||
const typename Collection<T, storage, ErrorHandler>::value_type&
|
const typename Collection<T, storage, ErrorHandler>::value_type&
|
||||||
Collection<T, storage, ErrorHandler>::Get(CollectionItemId id) const {
|
Collection<T, storage, ErrorHandler>::Get(CollectionItemId id) const {
|
||||||
CHECK_LE(BeginId(), id);
|
ABSL_CHECK_LE(BeginId(), id);
|
||||||
CHECK_LT(id, EndId());
|
ABSL_CHECK_LT(id, EndId());
|
||||||
return begin()[id.value()];
|
return begin()[id.value()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,8 +434,8 @@ Collection<T, storage, ErrorHandler>::GetPtr(CollectionItemId id) {
|
||||||
"mediapipe::internal::Collection<T>::GetPtr() is only "
|
"mediapipe::internal::Collection<T>::GetPtr() is only "
|
||||||
"available for collections that were defined with template "
|
"available for collections that were defined with template "
|
||||||
"argument storage == CollectionStorage::kStorePointer.");
|
"argument storage == CollectionStorage::kStorePointer.");
|
||||||
CHECK_LE(BeginId(), id);
|
ABSL_CHECK_LE(BeginId(), id);
|
||||||
CHECK_LT(id, EndId());
|
ABSL_CHECK_LT(id, EndId());
|
||||||
return data_[id.value()];
|
return data_[id.value()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,8 +446,8 @@ Collection<T, storage, ErrorHandler>::GetPtr(CollectionItemId id) const {
|
||||||
"mediapipe::internal::Collection<T>::GetPtr() is only "
|
"mediapipe::internal::Collection<T>::GetPtr() is only "
|
||||||
"available for collections that were defined with template "
|
"available for collections that were defined with template "
|
||||||
"argument storage == CollectionStorage::kStorePointer.");
|
"argument storage == CollectionStorage::kStorePointer.");
|
||||||
CHECK_LE(BeginId(), id);
|
ABSL_CHECK_LE(BeginId(), id);
|
||||||
CHECK_LT(id, EndId());
|
ABSL_CHECK_LT(id, EndId());
|
||||||
return data_[id.value()];
|
return data_[id.value()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,8 @@ cc_library(
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/log:check",
|
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
"@com_google_absl//absl/time",
|
"@com_google_absl//absl/time",
|
||||||
],
|
],
|
||||||
|
@ -132,8 +132,8 @@ cc_library(
|
||||||
"//mediapipe/framework/port",
|
"//mediapipe/framework/port",
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/log:check",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -151,7 +151,10 @@ cc_library(
|
||||||
|
|
||||||
# Use this library through "mediapipe/framework/port:map_util".
|
# Use this library through "mediapipe/framework/port:map_util".
|
||||||
visibility = ["//mediapipe/framework/port:__pkg__"],
|
visibility = ["//mediapipe/framework/port:__pkg__"],
|
||||||
deps = ["//mediapipe/framework/port:logging"],
|
deps = [
|
||||||
|
"//mediapipe/framework/port:logging",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
|
@ -162,7 +165,7 @@ cc_library(
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
"//mediapipe/framework/port:logging",
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -235,8 +238,8 @@ cc_library(
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
"@com_google_absl//absl/container:flat_hash_map",
|
"@com_google_absl//absl/container:flat_hash_map",
|
||||||
"@com_google_absl//absl/container:flat_hash_set",
|
"@com_google_absl//absl/container:flat_hash_set",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/log:check",
|
|
||||||
"@com_google_absl//absl/meta:type_traits",
|
"@com_google_absl//absl/meta:type_traits",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
|
@ -347,6 +350,7 @@ cc_library(
|
||||||
deps = [
|
deps = [
|
||||||
":thread_options",
|
":thread_options",
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
|
@ -362,6 +366,7 @@ cc_library(
|
||||||
visibility = ["//mediapipe/framework/port:__pkg__"],
|
visibility = ["//mediapipe/framework/port:__pkg__"],
|
||||||
deps = [
|
deps = [
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -374,7 +379,7 @@ cc_library(
|
||||||
visibility = ["//mediapipe/framework/port:__pkg__"],
|
visibility = ["//mediapipe/framework/port:__pkg__"],
|
||||||
deps = [
|
deps = [
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
"//mediapipe/framework/port:logging",
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/utility",
|
"@com_google_absl//absl/utility",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
#include "mediapipe/framework/port/logging.h"
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
@ -53,7 +54,7 @@ template <typename M>
|
||||||
const typename M::value_type::second_type& FindOrDie(
|
const typename M::value_type::second_type& FindOrDie(
|
||||||
const M& m, const typename M::value_type::first_type& key) {
|
const M& m, const typename M::value_type::first_type& key) {
|
||||||
auto it = m.find(key);
|
auto it = m.find(key);
|
||||||
CHECK(it != m.end()) << "Map key not found: " << key;
|
ABSL_CHECK(it != m.end()) << "Map key not found: " << key;
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ typename M::value_type::second_type& FindOrDie(
|
||||||
M& m, // NOLINT
|
M& m, // NOLINT
|
||||||
const typename M::value_type::first_type& key) {
|
const typename M::value_type::first_type& key) {
|
||||||
auto it = m.find(key);
|
auto it = m.find(key);
|
||||||
CHECK(it != m.end()) << "Map key not found: " << key;
|
ABSL_CHECK(it != m.end()) << "Map key not found: " << key;
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ bool InsertIfNotPresent(M* m, const typename M::value_type::first_type& key,
|
||||||
// inserted.
|
// inserted.
|
||||||
template <typename M, typename ReverseM>
|
template <typename M, typename ReverseM>
|
||||||
bool ReverseMap(const M& m, ReverseM* reverse) {
|
bool ReverseMap(const M& m, ReverseM* reverse) {
|
||||||
CHECK(reverse != nullptr);
|
ABSL_CHECK(reverse != nullptr);
|
||||||
for (const auto& kv : m) {
|
for (const auto& kv : m) {
|
||||||
if (!InsertIfNotPresent(reverse, kv.second, kv.first)) {
|
if (!InsertIfNotPresent(reverse, kv.second, kv.first)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/port/integral_types.h"
|
#include "mediapipe/framework/port/integral_types.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ class MathUtil {
|
||||||
template <typename T> // T models LessThanComparable.
|
template <typename T> // T models LessThanComparable.
|
||||||
static const T& Clamp(const T& low, const T& high, const T& value) {
|
static const T& Clamp(const T& low, const T& high, const T& value) {
|
||||||
// Prevents errors in ordering the arguments.
|
// Prevents errors in ordering the arguments.
|
||||||
DCHECK(!(high < low));
|
ABSL_DCHECK(!(high < low));
|
||||||
if (high < value) return high;
|
if (high < value) return high;
|
||||||
if (value < low) return low;
|
if (value < low) return low;
|
||||||
return value;
|
return value;
|
||||||
|
@ -364,7 +364,7 @@ class MathUtil {
|
||||||
// absolute margin of error.
|
// absolute margin of error.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static bool WithinMargin(const T x, const T y, const T margin) {
|
static bool WithinMargin(const T x, const T y, const T margin) {
|
||||||
DCHECK_GE(margin, 0);
|
ABSL_DCHECK_GE(margin, 0);
|
||||||
return (std::abs(x) <= std::abs(y) + margin) &&
|
return (std::abs(x) <= std::abs(y) + margin) &&
|
||||||
(std::abs(x) >= std::abs(y) - margin);
|
(std::abs(x) >= std::abs(y) - margin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
#include "absl/base/macros.h"
|
#include "absl/base/macros.h"
|
||||||
#include "absl/base/thread_annotations.h"
|
#include "absl/base/thread_annotations.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/log/check.h"
|
|
||||||
#include "absl/synchronization/mutex.h"
|
#include "absl/synchronization/mutex.h"
|
||||||
#include "absl/time/time.h"
|
#include "absl/time/time.h"
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class MonotonicClockImpl : public MonotonicClock {
|
||||||
|
|
||||||
// Absolve this object of responsibility for state_.
|
// Absolve this object of responsibility for state_.
|
||||||
void ReleaseState() {
|
void ReleaseState() {
|
||||||
CHECK(state_owned_);
|
ABSL_CHECK(state_owned_);
|
||||||
state_owned_ = false;
|
state_owned_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class MonotonicClockImpl : public MonotonicClock {
|
||||||
absl::MutexLock m(&state_->lock);
|
absl::MutexLock m(&state_->lock);
|
||||||
|
|
||||||
// Check consistency of internal data with state_.
|
// Check consistency of internal data with state_.
|
||||||
CHECK_LE(last_raw_time_, state_->max_time)
|
ABSL_CHECK_LE(last_raw_time_, state_->max_time)
|
||||||
<< "non-monotonic behavior: last_raw_time_=" << last_raw_time_
|
<< "non-monotonic behavior: last_raw_time_=" << last_raw_time_
|
||||||
<< ", max_time=" << state_->max_time;
|
<< ", max_time=" << state_->max_time;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class MonotonicClockImpl : public MonotonicClock {
|
||||||
// First, update correction metrics.
|
// First, update correction metrics.
|
||||||
++correction_count_;
|
++correction_count_;
|
||||||
absl::Duration delta = state_->max_time - raw_time;
|
absl::Duration delta = state_->max_time - raw_time;
|
||||||
CHECK_LT(absl::ZeroDuration(), delta);
|
ABSL_CHECK_LT(absl::ZeroDuration(), delta);
|
||||||
if (delta > max_correction_) {
|
if (delta > max_correction_) {
|
||||||
max_correction_ = delta;
|
max_correction_ = delta;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
#include "absl/base/thread_annotations.h"
|
#include "absl/base/thread_annotations.h"
|
||||||
#include "absl/container/flat_hash_map.h"
|
#include "absl/container/flat_hash_map.h"
|
||||||
#include "absl/container/flat_hash_set.h"
|
#include "absl/container/flat_hash_set.h"
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/log/check.h"
|
|
||||||
#include "absl/meta/type_traits.h"
|
#include "absl/meta/type_traits.h"
|
||||||
#include "absl/strings/str_join.h"
|
#include "absl/strings/str_join.h"
|
||||||
#include "absl/strings/str_split.h"
|
#include "absl/strings/str_split.h"
|
||||||
|
@ -271,7 +271,7 @@ class FunctionRegistry {
|
||||||
if (names[0].empty()) {
|
if (names[0].empty()) {
|
||||||
names.erase(names.begin());
|
names.erase(names.begin());
|
||||||
} else {
|
} else {
|
||||||
CHECK_EQ(1u, names.size())
|
ABSL_CHECK_EQ(1u, names.size())
|
||||||
<< "A registered class name must be either fully qualified "
|
<< "A registered class name must be either fully qualified "
|
||||||
<< "with a leading :: or unqualified, got: " << name << ".";
|
<< "with a leading :: or unqualified, got: " << name << ".";
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/log/check.h"
|
|
||||||
#include "mediapipe/framework/deps/strong_int.h"
|
#include "mediapipe/framework/deps/strong_int.h"
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
@ -68,17 +68,17 @@ class SafeIntStrongIntValidator {
|
||||||
// Check that the underlying integral type provides a range that is
|
// Check that the underlying integral type provides a range that is
|
||||||
// compatible with two's complement.
|
// compatible with two's complement.
|
||||||
if (std::numeric_limits<T>::is_signed) {
|
if (std::numeric_limits<T>::is_signed) {
|
||||||
CHECK_EQ(-1,
|
ABSL_CHECK_EQ(
|
||||||
std::numeric_limits<T>::min() + std::numeric_limits<T>::max())
|
-1, std::numeric_limits<T>::min() + std::numeric_limits<T>::max())
|
||||||
<< "unexpected integral bounds";
|
<< "unexpected integral bounds";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that division truncates towards 0 (implementation defined in
|
// Check that division truncates towards 0 (implementation defined in
|
||||||
// C++'03, but standard in C++'11).
|
// C++'03, but standard in C++'11).
|
||||||
CHECK_EQ(12, 127 / 10) << "division does not truncate towards 0";
|
ABSL_CHECK_EQ(12, 127 / 10) << "division does not truncate towards 0";
|
||||||
CHECK_EQ(-12, -127 / 10) << "division does not truncate towards 0";
|
ABSL_CHECK_EQ(-12, -127 / 10) << "division does not truncate towards 0";
|
||||||
CHECK_EQ(-12, 127 / -10) << "division does not truncate towards 0";
|
ABSL_CHECK_EQ(-12, 127 / -10) << "division does not truncate towards 0";
|
||||||
CHECK_EQ(12, -127 / -10) << "division does not truncate towards 0";
|
ABSL_CHECK_EQ(12, -127 / -10) << "division does not truncate towards 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/str_join.h"
|
#include "absl/strings/str_join.h"
|
||||||
|
@ -49,7 +50,7 @@ ThreadPool::WorkerThread::WorkerThread(ThreadPool* pool,
|
||||||
const std::string& name_prefix)
|
const std::string& name_prefix)
|
||||||
: pool_(pool), name_prefix_(name_prefix) {
|
: pool_(pool), name_prefix_(name_prefix) {
|
||||||
int res = pthread_create(&thread_, nullptr, ThreadBody, this);
|
int res = pthread_create(&thread_, nullptr, ThreadBody, this);
|
||||||
CHECK_EQ(res, 0) << "pthread_create failed";
|
ABSL_CHECK_EQ(res, 0) << "pthread_create failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadPool::WorkerThread::~WorkerThread() {}
|
ThreadPool::WorkerThread::~WorkerThread() {}
|
||||||
|
|
|
@ -16,18 +16,19 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
#include "mediapipe/framework/port/logging.h"
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
|
||||||
TopologicalSorter::TopologicalSorter(int num_nodes) : num_nodes_(num_nodes) {
|
TopologicalSorter::TopologicalSorter(int num_nodes) : num_nodes_(num_nodes) {
|
||||||
CHECK_GE(num_nodes_, 0);
|
ABSL_CHECK_GE(num_nodes_, 0);
|
||||||
adjacency_lists_.resize(num_nodes_);
|
adjacency_lists_.resize(num_nodes_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopologicalSorter::AddEdge(int from, int to) {
|
void TopologicalSorter::AddEdge(int from, int to) {
|
||||||
CHECK(!traversal_started_ && from < num_nodes_ && to < num_nodes_ &&
|
ABSL_CHECK(!traversal_started_ && from < num_nodes_ && to < num_nodes_ &&
|
||||||
from >= 0 && to >= 0);
|
from >= 0 && to >= 0);
|
||||||
adjacency_lists_[from].push_back(to);
|
adjacency_lists_[from].push_back(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/utility/utility.h"
|
#include "absl/utility/utility.h"
|
||||||
#include "mediapipe/framework/port/integral_types.h"
|
#include "mediapipe/framework/port/integral_types.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class Vector2;
|
class Vector2;
|
||||||
|
@ -78,13 +78,13 @@ class BasicVector {
|
||||||
void Clear() { AsD() = D(); }
|
void Clear() { AsD() = D(); }
|
||||||
|
|
||||||
T& operator[](int b) {
|
T& operator[](int b) {
|
||||||
DCHECK_GE(b, 0);
|
ABSL_DCHECK_GE(b, 0);
|
||||||
DCHECK_LT(b, SIZE);
|
ABSL_DCHECK_LT(b, SIZE);
|
||||||
return static_cast<D&>(*this).Data()[b];
|
return static_cast<D&>(*this).Data()[b];
|
||||||
}
|
}
|
||||||
T operator[](int b) const {
|
T operator[](int b) const {
|
||||||
DCHECK_GE(b, 0);
|
ABSL_DCHECK_GE(b, 0);
|
||||||
DCHECK_LT(b, SIZE);
|
ABSL_DCHECK_LT(b, SIZE);
|
||||||
return static_cast<const D&>(*this).Data()[b];
|
return static_cast<const D&>(*this).Data()[b];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@eigen_archive//:eigen3",
|
"@eigen_archive//:eigen3",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -159,8 +160,8 @@ cc_library(
|
||||||
"//mediapipe/framework/tool:type_util",
|
"//mediapipe/framework/tool:type_util",
|
||||||
"@com_google_absl//absl/base",
|
"@com_google_absl//absl/base",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/log:check",
|
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
] + select({
|
] + select({
|
||||||
|
@ -214,6 +215,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:statusor",
|
"//mediapipe/framework/port:statusor",
|
||||||
"//mediapipe/framework/tool:status_util",
|
"//mediapipe/framework/tool:status_util",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
@ -341,6 +343,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/gpu:gpu_buffer",
|
"//mediapipe/gpu:gpu_buffer",
|
||||||
"//mediapipe/gpu:gpu_buffer_format",
|
"//mediapipe/gpu:gpu_buffer_format",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
] + select({
|
] + select({
|
||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
|
@ -365,6 +368,7 @@ cc_library(
|
||||||
":image_frame_pool",
|
":image_frame_pool",
|
||||||
"//mediapipe/framework:port",
|
"//mediapipe/framework:port",
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
] + select({
|
] + select({
|
||||||
|
@ -402,6 +406,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:logging",
|
"//mediapipe/framework/port:logging",
|
||||||
"//mediapipe/framework/port:opencv_core",
|
"//mediapipe/framework/port:opencv_core",
|
||||||
"//mediapipe/framework/port:statusor",
|
"//mediapipe/framework/port:statusor",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -488,6 +493,7 @@ cc_library(
|
||||||
deps = [
|
deps = [
|
||||||
"//mediapipe/framework:port",
|
"//mediapipe/framework:port",
|
||||||
"@com_google_absl//absl/container:flat_hash_map",
|
"@com_google_absl//absl/container:flat_hash_map",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
|
@ -522,7 +528,7 @@ cc_library(
|
||||||
hdrs = ["frame_buffer.h"],
|
hdrs = ["frame_buffer.h"],
|
||||||
deps = [
|
deps = [
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
"@com_google_absl//absl/log:check",
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
"@com_google_absl//absl/status:statusor",
|
"@com_google_absl//absl/status:statusor",
|
||||||
],
|
],
|
||||||
|
|
|
@ -18,7 +18,7 @@ limitations under the License.
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/log/check.h"
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "mediapipe/framework/port/integral_types.h"
|
#include "mediapipe/framework/port/integral_types.h"
|
||||||
|
|
||||||
|
@ -147,15 +147,15 @@ class FrameBuffer {
|
||||||
|
|
||||||
// Returns plane indexed by the input `index`.
|
// Returns plane indexed by the input `index`.
|
||||||
const Plane& plane(int index) const {
|
const Plane& plane(int index) const {
|
||||||
CHECK_GE(index, 0);
|
ABSL_CHECK_GE(index, 0);
|
||||||
CHECK_LT(static_cast<size_t>(index), planes_.size());
|
ABSL_CHECK_LT(static_cast<size_t>(index), planes_.size());
|
||||||
return planes_[index];
|
return planes_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns mutable plane indexed by the input `index`.
|
// Returns mutable plane indexed by the input `index`.
|
||||||
Plane mutable_plane(int index) {
|
Plane mutable_plane(int index) {
|
||||||
CHECK_GE(index, 0);
|
ABSL_CHECK_GE(index, 0);
|
||||||
CHECK_LT(static_cast<size_t>(index), planes_.size());
|
ABSL_CHECK_LT(static_cast<size_t>(index), planes_.size());
|
||||||
return planes_[index];
|
return planes_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "mediapipe/framework/formats/image.h"
|
#include "mediapipe/framework/formats/image.h"
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/type_map.h"
|
#include "mediapipe/framework/type_map.h"
|
||||||
|
|
||||||
#if !MEDIAPIPE_DISABLE_GPU
|
#if !MEDIAPIPE_DISABLE_GPU
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/log/check.h"
|
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "mediapipe/framework/formats/image_format.pb.h"
|
#include "mediapipe/framework/formats/image_format.pb.h"
|
||||||
#include "mediapipe/framework/port/aligned_malloc_and_free.h"
|
#include "mediapipe/framework/port/aligned_malloc_and_free.h"
|
||||||
|
@ -99,8 +99,8 @@ void ImageFrame::Reset(ImageFormat::Format format, int width, int height,
|
||||||
format_ = format;
|
format_ = format;
|
||||||
width_ = width;
|
width_ = width;
|
||||||
height_ = height;
|
height_ = height;
|
||||||
CHECK_NE(ImageFormat::UNKNOWN, format_);
|
ABSL_CHECK_NE(ImageFormat::UNKNOWN, format_);
|
||||||
CHECK(IsValidAlignmentNumber(alignment_boundary));
|
ABSL_CHECK(IsValidAlignmentNumber(alignment_boundary));
|
||||||
width_step_ = width * NumberOfChannels() * ByteDepth();
|
width_step_ = width * NumberOfChannels() * ByteDepth();
|
||||||
if (alignment_boundary == 1) {
|
if (alignment_boundary == 1) {
|
||||||
pixel_data_ = {new uint8_t[height * width_step_],
|
pixel_data_ = {new uint8_t[height * width_step_],
|
||||||
|
@ -125,8 +125,8 @@ void ImageFrame::AdoptPixelData(ImageFormat::Format format, int width,
|
||||||
height_ = height;
|
height_ = height;
|
||||||
width_step_ = width_step;
|
width_step_ = width_step;
|
||||||
|
|
||||||
CHECK_NE(ImageFormat::UNKNOWN, format_);
|
ABSL_CHECK_NE(ImageFormat::UNKNOWN, format_);
|
||||||
CHECK_GE(width_step_, width * NumberOfChannels() * ByteDepth());
|
ABSL_CHECK_GE(width_step_, width * NumberOfChannels() * ByteDepth());
|
||||||
|
|
||||||
pixel_data_ = {pixel_data, deleter};
|
pixel_data_ = {pixel_data, deleter};
|
||||||
}
|
}
|
||||||
|
@ -137,8 +137,8 @@ std::unique_ptr<uint8_t[], ImageFrame::Deleter> ImageFrame::Release() {
|
||||||
|
|
||||||
void ImageFrame::InternalCopyFrom(int width, int height, int width_step,
|
void ImageFrame::InternalCopyFrom(int width, int height, int width_step,
|
||||||
int channel_size, const uint8_t* pixel_data) {
|
int channel_size, const uint8_t* pixel_data) {
|
||||||
CHECK_EQ(width_, width);
|
ABSL_CHECK_EQ(width_, width);
|
||||||
CHECK_EQ(height_, height);
|
ABSL_CHECK_EQ(height_, height);
|
||||||
// row_bytes = channel_size * num_channels * width
|
// row_bytes = channel_size * num_channels * width
|
||||||
const int row_bytes = channel_size * NumberOfChannels() * width;
|
const int row_bytes = channel_size * NumberOfChannels() * width;
|
||||||
if (width_step == 0) {
|
if (width_step == 0) {
|
||||||
|
@ -188,8 +188,8 @@ void ImageFrame::SetAlignmentPaddingAreas() {
|
||||||
if (!pixel_data_) {
|
if (!pixel_data_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CHECK_GE(width_, 1);
|
ABSL_CHECK_GE(width_, 1);
|
||||||
CHECK_GE(height_, 1);
|
ABSL_CHECK_GE(height_, 1);
|
||||||
|
|
||||||
const int pixel_size = ByteDepth() * NumberOfChannels();
|
const int pixel_size = ByteDepth() * NumberOfChannels();
|
||||||
const int padding_size = width_step_ - width_ * pixel_size;
|
const int padding_size = width_step_ - width_ * pixel_size;
|
||||||
|
@ -223,7 +223,7 @@ bool ImageFrame::IsContiguous() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageFrame::IsAligned(uint32_t alignment_boundary) const {
|
bool ImageFrame::IsAligned(uint32_t alignment_boundary) const {
|
||||||
CHECK(IsValidAlignmentNumber(alignment_boundary));
|
ABSL_CHECK(IsValidAlignmentNumber(alignment_boundary));
|
||||||
if (!pixel_data_) {
|
if (!pixel_data_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ void ImageFrame::CopyFrom(const ImageFrame& image_frame,
|
||||||
Reset(image_frame.Format(), image_frame.Width(), image_frame.Height(),
|
Reset(image_frame.Format(), image_frame.Width(), image_frame.Height(),
|
||||||
alignment_boundary);
|
alignment_boundary);
|
||||||
|
|
||||||
CHECK_EQ(format_, image_frame.Format());
|
ABSL_CHECK_EQ(format_, image_frame.Format());
|
||||||
InternalCopyFrom(image_frame.Width(), image_frame.Height(),
|
InternalCopyFrom(image_frame.Width(), image_frame.Height(),
|
||||||
image_frame.WidthStep(), image_frame.ChannelSize(),
|
image_frame.WidthStep(), image_frame.ChannelSize(),
|
||||||
image_frame.PixelData());
|
image_frame.PixelData());
|
||||||
|
@ -383,10 +383,10 @@ void ImageFrame::CopyPixelData(ImageFormat::Format format, int width,
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageFrame::CopyToBuffer(uint8_t* buffer, int buffer_size) const {
|
void ImageFrame::CopyToBuffer(uint8_t* buffer, int buffer_size) const {
|
||||||
CHECK(buffer);
|
ABSL_CHECK(buffer);
|
||||||
CHECK_EQ(1, ByteDepth());
|
ABSL_CHECK_EQ(1, ByteDepth());
|
||||||
const int data_size = width_ * height_ * NumberOfChannels();
|
const int data_size = width_ * height_ * NumberOfChannels();
|
||||||
CHECK_LE(data_size, buffer_size);
|
ABSL_CHECK_LE(data_size, buffer_size);
|
||||||
if (IsContiguous()) {
|
if (IsContiguous()) {
|
||||||
// The data is stored contiguously, we can just copy.
|
// The data is stored contiguously, we can just copy.
|
||||||
const uint8_t* src = reinterpret_cast<const uint8_t*>(pixel_data_.get());
|
const uint8_t* src = reinterpret_cast<const uint8_t*>(pixel_data_.get());
|
||||||
|
@ -398,10 +398,10 @@ void ImageFrame::CopyToBuffer(uint8_t* buffer, int buffer_size) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageFrame::CopyToBuffer(uint16_t* buffer, int buffer_size) const {
|
void ImageFrame::CopyToBuffer(uint16_t* buffer, int buffer_size) const {
|
||||||
CHECK(buffer);
|
ABSL_CHECK(buffer);
|
||||||
CHECK_EQ(2, ByteDepth());
|
ABSL_CHECK_EQ(2, ByteDepth());
|
||||||
const int data_size = width_ * height_ * NumberOfChannels();
|
const int data_size = width_ * height_ * NumberOfChannels();
|
||||||
CHECK_LE(data_size, buffer_size);
|
ABSL_CHECK_LE(data_size, buffer_size);
|
||||||
if (IsContiguous()) {
|
if (IsContiguous()) {
|
||||||
// The data is stored contiguously, we can just copy.
|
// The data is stored contiguously, we can just copy.
|
||||||
const uint16_t* src = reinterpret_cast<const uint16_t*>(pixel_data_.get());
|
const uint16_t* src = reinterpret_cast<const uint16_t*>(pixel_data_.get());
|
||||||
|
@ -413,10 +413,10 @@ void ImageFrame::CopyToBuffer(uint16_t* buffer, int buffer_size) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageFrame::CopyToBuffer(float* buffer, int buffer_size) const {
|
void ImageFrame::CopyToBuffer(float* buffer, int buffer_size) const {
|
||||||
CHECK(buffer);
|
ABSL_CHECK(buffer);
|
||||||
CHECK_EQ(4, ByteDepth());
|
ABSL_CHECK_EQ(4, ByteDepth());
|
||||||
const int data_size = width_ * height_ * NumberOfChannels();
|
const int data_size = width_ * height_ * NumberOfChannels();
|
||||||
CHECK_LE(data_size, buffer_size);
|
ABSL_CHECK_LE(data_size, buffer_size);
|
||||||
if (IsContiguous()) {
|
if (IsContiguous()) {
|
||||||
// The data is stored contiguously, we can just copy.
|
// The data is stored contiguously, we can just copy.
|
||||||
const float* src = reinterpret_cast<float*>(pixel_data_.get());
|
const float* src = reinterpret_cast<float*>(pixel_data_.get());
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/synchronization/mutex.h"
|
#include "absl/synchronization/mutex.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
#include "mediapipe/framework/port/logging.h"
|
||||||
|
@ -43,7 +44,7 @@ ImageMultiPool::SimplePoolGpu ImageMultiPool::MakeSimplePoolGpu(
|
||||||
IBufferSpec spec) {
|
IBufferSpec spec) {
|
||||||
OSType cv_format = mediapipe::CVPixelFormatForGpuBufferFormat(
|
OSType cv_format = mediapipe::CVPixelFormatForGpuBufferFormat(
|
||||||
GpuBufferFormatForImageFormat(spec.format));
|
GpuBufferFormatForImageFormat(spec.format));
|
||||||
CHECK_NE(cv_format, -1) << "unsupported pixel format";
|
ABSL_CHECK_NE(cv_format, -1) << "unsupported pixel format";
|
||||||
return MakeCFHolderAdopting(mediapipe::CreateCVPixelBufferPool(
|
return MakeCFHolderAdopting(mediapipe::CreateCVPixelBufferPool(
|
||||||
spec.width, spec.height, cv_format, kKeepCount,
|
spec.width, spec.height, cv_format, kKeepCount,
|
||||||
0.1 /* max age in seconds */));
|
0.1 /* max age in seconds */));
|
||||||
|
@ -61,11 +62,11 @@ Image ImageMultiPool::GetBufferFromSimplePool(
|
||||||
// pool to give us contiguous data.
|
// pool to give us contiguous data.
|
||||||
OSType cv_format = mediapipe::CVPixelFormatForGpuBufferFormat(
|
OSType cv_format = mediapipe::CVPixelFormatForGpuBufferFormat(
|
||||||
mediapipe::GpuBufferFormatForImageFormat(spec.format));
|
mediapipe::GpuBufferFormatForImageFormat(spec.format));
|
||||||
CHECK_NE(cv_format, -1) << "unsupported pixel format";
|
ABSL_CHECK_NE(cv_format, -1) << "unsupported pixel format";
|
||||||
CVPixelBufferRef buffer;
|
CVPixelBufferRef buffer;
|
||||||
CVReturn err = mediapipe::CreateCVPixelBufferWithoutPool(
|
CVReturn err = mediapipe::CreateCVPixelBufferWithoutPool(
|
||||||
spec.width, spec.height, cv_format, &buffer);
|
spec.width, spec.height, cv_format, &buffer);
|
||||||
CHECK(!err) << "Error creating pixel buffer: " << err;
|
ABSL_CHECK(!err) << "Error creating pixel buffer: " << err;
|
||||||
return Image(MakeCFHolderAdopting(buffer));
|
return Image(MakeCFHolderAdopting(buffer));
|
||||||
#else
|
#else
|
||||||
CVPixelBufferRef buffer;
|
CVPixelBufferRef buffer;
|
||||||
|
@ -87,7 +88,7 @@ Image ImageMultiPool::GetBufferFromSimplePool(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
&buffer);
|
&buffer);
|
||||||
CHECK(!err) << "Error creating pixel buffer: " << err;
|
ABSL_CHECK(!err) << "Error creating pixel buffer: " << err;
|
||||||
return Image(MakeCFHolderAdopting(buffer));
|
return Image(MakeCFHolderAdopting(buffer));
|
||||||
#endif // TARGET_IPHONE_SIMULATOR
|
#endif // TARGET_IPHONE_SIMULATOR
|
||||||
}
|
}
|
||||||
|
@ -188,7 +189,7 @@ Image ImageMultiPool::GetBuffer(int width, int height, bool use_gpu,
|
||||||
ImageMultiPool::~ImageMultiPool() {
|
ImageMultiPool::~ImageMultiPool() {
|
||||||
#if !MEDIAPIPE_DISABLE_GPU
|
#if !MEDIAPIPE_DISABLE_GPU
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
CHECK_EQ(texture_caches_.size(), 0)
|
ABSL_CHECK_EQ(texture_caches_.size(), 0)
|
||||||
<< "Failed to unregister texture caches before deleting pool";
|
<< "Failed to unregister texture caches before deleting pool";
|
||||||
#endif // defined(__APPLE__)
|
#endif // defined(__APPLE__)
|
||||||
#endif // !MEDIAPIPE_DISABLE_GPU
|
#endif // !MEDIAPIPE_DISABLE_GPU
|
||||||
|
@ -199,8 +200,8 @@ ImageMultiPool::~ImageMultiPool() {
|
||||||
void ImageMultiPool::RegisterTextureCache(mediapipe::CVTextureCacheType cache) {
|
void ImageMultiPool::RegisterTextureCache(mediapipe::CVTextureCacheType cache) {
|
||||||
absl::MutexLock lock(&mutex_gpu_);
|
absl::MutexLock lock(&mutex_gpu_);
|
||||||
|
|
||||||
CHECK(std::find(texture_caches_.begin(), texture_caches_.end(), cache) ==
|
ABSL_CHECK(std::find(texture_caches_.begin(), texture_caches_.end(), cache) ==
|
||||||
texture_caches_.end())
|
texture_caches_.end())
|
||||||
<< "Attempting to register a texture cache twice";
|
<< "Attempting to register a texture cache twice";
|
||||||
texture_caches_.emplace_back(cache);
|
texture_caches_.emplace_back(cache);
|
||||||
}
|
}
|
||||||
|
@ -210,7 +211,7 @@ void ImageMultiPool::UnregisterTextureCache(
|
||||||
absl::MutexLock lock(&mutex_gpu_);
|
absl::MutexLock lock(&mutex_gpu_);
|
||||||
|
|
||||||
auto it = std::find(texture_caches_.begin(), texture_caches_.end(), cache);
|
auto it = std::find(texture_caches_.begin(), texture_caches_.end(), cache);
|
||||||
CHECK(it != texture_caches_.end())
|
ABSL_CHECK(it != texture_caches_.end())
|
||||||
<< "Attempting to unregister an unknown texture cache";
|
<< "Attempting to unregister an unknown texture cache";
|
||||||
texture_caches_.erase(it);
|
texture_caches_.erase(it);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "mediapipe/framework/formats/image_opencv.h"
|
#include "mediapipe/framework/formats/image_opencv.h"
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/formats/image_format.pb.h"
|
#include "mediapipe/framework/formats/image_format.pb.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
#include "mediapipe/framework/port/logging.h"
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ std::shared_ptr<cv::Mat> MatView(const mediapipe::Image* image) {
|
||||||
auto owner =
|
auto owner =
|
||||||
std::make_shared<MatWithPixelLock>(const_cast<mediapipe::Image*>(image));
|
std::make_shared<MatWithPixelLock>(const_cast<mediapipe::Image*>(image));
|
||||||
uint8_t* data_ptr = owner->lock.Pixels();
|
uint8_t* data_ptr = owner->lock.Pixels();
|
||||||
CHECK(data_ptr != nullptr);
|
ABSL_CHECK(data_ptr != nullptr);
|
||||||
// Use Image to initialize in-place. Image still owns memory.
|
// Use Image to initialize in-place. Image still owns memory.
|
||||||
if (steps[0] == sizes[1] * image->channels() *
|
if (steps[0] == sizes[1] * image->channels() *
|
||||||
ImageFrame::ByteDepthForFormat(image->image_format())) {
|
ImageFrame::ByteDepthForFormat(image->image_format())) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/substitute.h"
|
#include "absl/strings/substitute.h"
|
||||||
|
@ -39,7 +40,7 @@ namespace {
|
||||||
// the location_data, the tightest bounding box, that contains all pixels
|
// the location_data, the tightest bounding box, that contains all pixels
|
||||||
// encoded in the rasterizations.
|
// encoded in the rasterizations.
|
||||||
Rectangle_i MaskToRectangle(const LocationData& location_data) {
|
Rectangle_i MaskToRectangle(const LocationData& location_data) {
|
||||||
CHECK(location_data.mask().has_rasterization());
|
ABSL_CHECK(location_data.mask().has_rasterization());
|
||||||
const auto& rasterization = location_data.mask().rasterization();
|
const auto& rasterization = location_data.mask().rasterization();
|
||||||
if (rasterization.interval_size() == 0) {
|
if (rasterization.interval_size() == 0) {
|
||||||
return Rectangle_i(0, 0, 0, 0);
|
return Rectangle_i(0, 0, 0, 0);
|
||||||
|
@ -63,7 +64,7 @@ Location::Location() {}
|
||||||
|
|
||||||
Location::Location(const LocationData& location_data)
|
Location::Location(const LocationData& location_data)
|
||||||
: location_data_(location_data) {
|
: location_data_(location_data) {
|
||||||
CHECK(IsValidLocationData(location_data_));
|
ABSL_CHECK(IsValidLocationData(location_data_));
|
||||||
}
|
}
|
||||||
|
|
||||||
Location Location::CreateGlobalLocation() {
|
Location Location::CreateGlobalLocation() {
|
||||||
|
@ -152,15 +153,15 @@ bool Location::IsValidLocationData(const LocationData& location_data) {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
Rectangle_i Location::GetBBox<Rectangle_i>() const {
|
Rectangle_i Location::GetBBox<Rectangle_i>() const {
|
||||||
CHECK_EQ(LocationData::BOUNDING_BOX, location_data_.format());
|
ABSL_CHECK_EQ(LocationData::BOUNDING_BOX, location_data_.format());
|
||||||
const auto& box = location_data_.bounding_box();
|
const auto& box = location_data_.bounding_box();
|
||||||
return Rectangle_i(box.xmin(), box.ymin(), box.width(), box.height());
|
return Rectangle_i(box.xmin(), box.ymin(), box.width(), box.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
Location& Location::Scale(const float scale) {
|
Location& Location::Scale(const float scale) {
|
||||||
CHECK(!location_data_.has_mask())
|
ABSL_CHECK(!location_data_.has_mask())
|
||||||
<< "Location mask scaling is not implemented.";
|
<< "Location mask scaling is not implemented.";
|
||||||
CHECK_GT(scale, 0.0f);
|
ABSL_CHECK_GT(scale, 0.0f);
|
||||||
switch (location_data_.format()) {
|
switch (location_data_.format()) {
|
||||||
case LocationData::GLOBAL: {
|
case LocationData::GLOBAL: {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
|
@ -249,7 +250,7 @@ namespace {
|
||||||
// This function is inteded to shift boundaries of intervals such that they
|
// This function is inteded to shift boundaries of intervals such that they
|
||||||
// best fit within an image.
|
// best fit within an image.
|
||||||
float BestShift(float min_value, float max_value, float range) {
|
float BestShift(float min_value, float max_value, float range) {
|
||||||
CHECK_LE(min_value, max_value);
|
ABSL_CHECK_LE(min_value, max_value);
|
||||||
const float value_range = max_value - min_value;
|
const float value_range = max_value - min_value;
|
||||||
if (value_range > range) {
|
if (value_range > range) {
|
||||||
return 0.5f * (range - min_value - max_value);
|
return 0.5f * (range - min_value - max_value);
|
||||||
|
@ -296,8 +297,8 @@ Location& Location::ShiftToFitBestIntoImage(int image_width, int image_height) {
|
||||||
const float y_shift = BestShift(mask_bounding_box.xmin(),
|
const float y_shift = BestShift(mask_bounding_box.xmin(),
|
||||||
mask_bounding_box.xmax(), image_height);
|
mask_bounding_box.xmax(), image_height);
|
||||||
auto* mask = location_data_.mutable_mask();
|
auto* mask = location_data_.mutable_mask();
|
||||||
CHECK_EQ(image_width, mask->width());
|
ABSL_CHECK_EQ(image_width, mask->width());
|
||||||
CHECK_EQ(image_height, mask->height());
|
ABSL_CHECK_EQ(image_height, mask->height());
|
||||||
for (auto& interval :
|
for (auto& interval :
|
||||||
*mask->mutable_rasterization()->mutable_interval()) {
|
*mask->mutable_rasterization()->mutable_interval()) {
|
||||||
interval.set_y(interval.y() + y_shift);
|
interval.set_y(interval.y() + y_shift);
|
||||||
|
@ -421,7 +422,7 @@ Rectangle_i Location::ConvertToBBox<Rectangle_i>(int image_width,
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle_f Location::GetRelativeBBox() const {
|
Rectangle_f Location::GetRelativeBBox() const {
|
||||||
CHECK_EQ(LocationData::RELATIVE_BOUNDING_BOX, location_data_.format());
|
ABSL_CHECK_EQ(LocationData::RELATIVE_BOUNDING_BOX, location_data_.format());
|
||||||
const auto& box = location_data_.relative_bounding_box();
|
const auto& box = location_data_.relative_bounding_box();
|
||||||
return Rectangle_f(box.xmin(), box.ymin(), box.width(), box.height());
|
return Rectangle_f(box.xmin(), box.ymin(), box.width(), box.height());
|
||||||
}
|
}
|
||||||
|
@ -460,7 +461,7 @@ Rectangle_f Location::ConvertToRelativeBBox(int image_width,
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
::mediapipe::BoundingBox Location::GetBBox<::mediapipe::BoundingBox>() const {
|
::mediapipe::BoundingBox Location::GetBBox<::mediapipe::BoundingBox>() const {
|
||||||
CHECK_EQ(LocationData::BOUNDING_BOX, location_data_.format());
|
ABSL_CHECK_EQ(LocationData::BOUNDING_BOX, location_data_.format());
|
||||||
const auto& box = location_data_.bounding_box();
|
const auto& box = location_data_.bounding_box();
|
||||||
::mediapipe::BoundingBox bounding_box;
|
::mediapipe::BoundingBox bounding_box;
|
||||||
bounding_box.set_left_x(box.xmin());
|
bounding_box.set_left_x(box.xmin());
|
||||||
|
@ -483,7 +484,7 @@ template <>
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Point2_f> Location::GetRelativeKeypoints() const {
|
std::vector<Point2_f> Location::GetRelativeKeypoints() const {
|
||||||
CHECK_EQ(LocationData::RELATIVE_BOUNDING_BOX, location_data_.format());
|
ABSL_CHECK_EQ(LocationData::RELATIVE_BOUNDING_BOX, location_data_.format());
|
||||||
std::vector<Point2_f> keypoints;
|
std::vector<Point2_f> keypoints;
|
||||||
for (const auto& keypoint : location_data_.relative_keypoints()) {
|
for (const auto& keypoint : location_data_.relative_keypoints()) {
|
||||||
keypoints.emplace_back(Point2_f(keypoint.x(), keypoint.y()));
|
keypoints.emplace_back(Point2_f(keypoint.x(), keypoint.y()));
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "mediapipe/framework/formats/location_opencv.h"
|
#include "mediapipe/framework/formats/location_opencv.h"
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "absl/log/absl_log.h"
|
#include "absl/log/absl_log.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/substitute.h"
|
#include "absl/strings/substitute.h"
|
||||||
|
@ -26,7 +27,7 @@ namespace mediapipe {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Rectangle_i MaskToRectangle(const LocationData& location_data) {
|
Rectangle_i MaskToRectangle(const LocationData& location_data) {
|
||||||
CHECK(location_data.mask().has_rasterization());
|
ABSL_CHECK(location_data.mask().has_rasterization());
|
||||||
const auto& rasterization = location_data.mask().rasterization();
|
const auto& rasterization = location_data.mask().rasterization();
|
||||||
if (rasterization.interval_size() == 0) {
|
if (rasterization.interval_size() == 0) {
|
||||||
return Rectangle_i(0, 0, 0, 0);
|
return Rectangle_i(0, 0, 0, 0);
|
||||||
|
@ -85,7 +86,7 @@ Location CreateBBoxLocation(const cv::Rect& rect) {
|
||||||
|
|
||||||
std::unique_ptr<cv::Mat> GetCvMask(const Location& location) {
|
std::unique_ptr<cv::Mat> GetCvMask(const Location& location) {
|
||||||
const auto location_data = location.ConvertToProto();
|
const auto location_data = location.ConvertToProto();
|
||||||
CHECK_EQ(LocationData::MASK, location_data.format());
|
ABSL_CHECK_EQ(LocationData::MASK, location_data.format());
|
||||||
const auto& mask = location_data.mask();
|
const auto& mask = location_data.mask();
|
||||||
std::unique_ptr<cv::Mat> mat(
|
std::unique_ptr<cv::Mat> mat(
|
||||||
new cv::Mat(mask.height(), mask.width(), CV_8UC1, cv::Scalar(0)));
|
new cv::Mat(mask.height(), mask.width(), CV_8UC1, cv::Scalar(0)));
|
||||||
|
@ -128,7 +129,7 @@ std::unique_ptr<cv::Mat> ConvertToCvMask(const Location& location,
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnlargeLocation(Location& location, const float factor) {
|
void EnlargeLocation(Location& location, const float factor) {
|
||||||
CHECK_GT(factor, 0.0f);
|
ABSL_CHECK_GT(factor, 0.0f);
|
||||||
if (factor == 1.0f) return;
|
if (factor == 1.0f) return;
|
||||||
auto location_data = location.ConvertToProto();
|
auto location_data = location.ConvertToProto();
|
||||||
switch (location_data.format()) {
|
switch (location_data.format()) {
|
||||||
|
@ -183,7 +184,7 @@ void EnlargeLocation(Location& location, const float factor) {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Location CreateCvMaskLocation(const cv::Mat_<T>& mask) {
|
Location CreateCvMaskLocation(const cv::Mat_<T>& mask) {
|
||||||
CHECK_EQ(1, mask.channels())
|
ABSL_CHECK_EQ(1, mask.channels())
|
||||||
<< "The specified cv::Mat mask should be single-channel.";
|
<< "The specified cv::Mat mask should be single-channel.";
|
||||||
|
|
||||||
LocationData location_data;
|
LocationData location_data;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "absl/log/absl_check.h"
|
||||||
#include "mediapipe/framework/port/core_proto_inc.h"
|
#include "mediapipe/framework/port/core_proto_inc.h"
|
||||||
#include "mediapipe/framework/port/logging.h"
|
#include "mediapipe/framework/port/logging.h"
|
||||||
#include "mediapipe/framework/port/proto_ns.h"
|
#include "mediapipe/framework/port/proto_ns.h"
|
||||||
|
@ -33,8 +34,8 @@ void MatrixDataProtoFromMatrix(const Matrix& matrix, MatrixData* matrix_data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixFromMatrixDataProto(const MatrixData& matrix_data, Matrix* matrix) {
|
void MatrixFromMatrixDataProto(const MatrixData& matrix_data, Matrix* matrix) {
|
||||||
CHECK_EQ(matrix_data.rows() * matrix_data.cols(),
|
ABSL_CHECK_EQ(matrix_data.rows() * matrix_data.cols(),
|
||||||
matrix_data.packed_data_size());
|
matrix_data.packed_data_size());
|
||||||
if (matrix_data.layout() == MatrixData::ROW_MAJOR) {
|
if (matrix_data.layout() == MatrixData::ROW_MAJOR) {
|
||||||
matrix->resize(matrix_data.cols(), matrix_data.rows());
|
matrix->resize(matrix_data.cols(), matrix_data.rows());
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,9 +57,9 @@ std::string MatrixAsTextProto(const Matrix& matrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixFromTextProto(const std::string& text_proto, Matrix* matrix) {
|
void MatrixFromTextProto(const std::string& text_proto, Matrix* matrix) {
|
||||||
CHECK(matrix);
|
ABSL_CHECK(matrix);
|
||||||
MatrixData matrix_data;
|
MatrixData matrix_data;
|
||||||
CHECK(proto_ns::TextFormat::ParseFromString(text_proto, &matrix_data));
|
ABSL_CHECK(proto_ns::TextFormat::ParseFromString(text_proto, &matrix_data));
|
||||||
MatrixFromMatrixDataProto(matrix_data, matrix);
|
MatrixFromMatrixDataProto(matrix_data, matrix);
|
||||||
}
|
}
|
||||||
#endif // !defined(MEDIAPIPE_MOBILE) && !defined(MEDIAPIPE_LITE)
|
#endif // !defined(MEDIAPIPE_MOBILE) && !defined(MEDIAPIPE_LITE)
|
||||||
|
|
|
@ -43,6 +43,7 @@ cc_library(
|
||||||
"//mediapipe/framework/port:point",
|
"//mediapipe/framework/port:point",
|
||||||
"//mediapipe/framework/port:ret_check",
|
"//mediapipe/framework/port:ret_check",
|
||||||
"//mediapipe/framework/port:status",
|
"//mediapipe/framework/port:status",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@org_tensorflow//tensorflow/core:framework",
|
"@org_tensorflow//tensorflow/core:framework",
|
||||||
|
@ -62,6 +63,7 @@ cc_test(
|
||||||
"//mediapipe/framework/port:gtest_main",
|
"//mediapipe/framework/port:gtest_main",
|
||||||
"//mediapipe/framework/port:integral_types",
|
"//mediapipe/framework/port:integral_types",
|
||||||
"@com_google_absl//absl/flags:flag",
|
"@com_google_absl//absl/flags:flag",
|
||||||
|
"@com_google_absl//absl/log:absl_check",
|
||||||
"@com_google_absl//absl/log:absl_log",
|
"@com_google_absl//absl/log:absl_log",
|
||||||
"@org_tensorflow//tensorflow/core:framework",
|
"@org_tensorflow//tensorflow/core:framework",
|
||||||
],
|
],
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user