Project import generated by Copybara.

GitOrigin-RevId: 6a704ded0bf489614797082e7e7cda1068477ef5
This commit is contained in:
MediaPipe Team 2021-03-31 16:20:27 -07:00 committed by chuoling
parent 7c331ad58b
commit ecb5b5f44a
84 changed files with 1015 additions and 968 deletions

View File

@ -120,7 +120,8 @@ http_archive(
# libyuv
http_archive(
name = "libyuv",
urls = ["https://chromium.googlesource.com/libyuv/libyuv/+archive/refs/heads/master.tar.gz"],
# Error: operand type mismatch for `vbroadcastss' caused by commit 8a13626e42f7fdcf3a6acbb0316760ee54cda7d8.
urls = ["https://chromium.googlesource.com/libyuv/libyuv/+archive/2525698acba9bf9b701ba6b4d9584291a1f62257.tar.gz"],
build_file = "@//third_party:libyuv.BUILD",
)

View File

@ -72,9 +72,9 @@ affecting your work, restrict your request to a `<minor>` number. e.g.,
[Fd-npm]: https://www.npmjs.com/package/@mediapipe/face_detection
[H-npm]: https://www.npmjs.com/package/@mediapipe/hands
[P-npm]: https://www.npmjs.com/package/@mediapipe/pose
[draw-npm]: https://www.npmjs.com/package/@mediapipe/pose
[cam-npm]: https://www.npmjs.com/package/@mediapipe/pose
[ctrl-npm]: https://www.npmjs.com/package/@mediapipe/pose
[draw-npm]: https://www.npmjs.com/package/@mediapipe/drawing_utils
[cam-npm]: https://www.npmjs.com/package/@mediapipe/camera_utils
[ctrl-npm]: https://www.npmjs.com/package/@mediapipe/control_utils
[Ho-jsd]: https://www.jsdelivr.com/package/npm/@mediapipe/holistic
[F-jsd]: https://www.jsdelivr.com/package/npm/@mediapipe/face_mesh
[Fd-jsd]: https://www.jsdelivr.com/package/npm/@mediapipe/face_detection

View File

@ -78,6 +78,7 @@ Supported configuration options:
import cv2
import mediapipe as mp
mp_face_detction = mp.solutions.face_detection
mp_drawing = mp.solutions.drawing_utils
# For static images:
with mp_face_detection.FaceDetection(

View File

@ -25,7 +25,7 @@ namespace mediapipe {
TEST(AudioDecoderCalculatorTest, TestWAV) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AudioDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
output_stream: "AUDIO:audio"
@ -34,7 +34,7 @@ TEST(AudioDecoderCalculatorTest, TestWAV) {
[type.googleapis.com/mediapipe.AudioDecoderOptions]: {
audio_stream { stream_index: 0 }
}
})");
})pb");
CalculatorRunner runner(node_config);
runner.MutableSidePackets()->Tag("INPUT_FILE_PATH") = MakePacket<std::string>(
file::JoinPath("./",
@ -56,7 +56,7 @@ TEST(AudioDecoderCalculatorTest, TestWAV) {
TEST(AudioDecoderCalculatorTest, Test48KWAV) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AudioDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
output_stream: "AUDIO:audio"
@ -65,7 +65,7 @@ TEST(AudioDecoderCalculatorTest, Test48KWAV) {
[type.googleapis.com/mediapipe.AudioDecoderOptions]: {
audio_stream { stream_index: 0 }
}
})");
})pb");
CalculatorRunner runner(node_config);
runner.MutableSidePackets()->Tag("INPUT_FILE_PATH") = MakePacket<std::string>(
file::JoinPath("./",
@ -87,7 +87,7 @@ TEST(AudioDecoderCalculatorTest, Test48KWAV) {
TEST(AudioDecoderCalculatorTest, TestMP3) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AudioDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
output_stream: "AUDIO:audio"
@ -96,7 +96,7 @@ TEST(AudioDecoderCalculatorTest, TestMP3) {
[type.googleapis.com/mediapipe.AudioDecoderOptions]: {
audio_stream { stream_index: 0 }
}
})");
})pb");
CalculatorRunner runner(node_config);
runner.MutableSidePackets()->Tag("INPUT_FILE_PATH") = MakePacket<std::string>(
file::JoinPath("./",
@ -118,7 +118,7 @@ TEST(AudioDecoderCalculatorTest, TestMP3) {
TEST(AudioDecoderCalculatorTest, TestAAC) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AudioDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
output_stream: "AUDIO:audio"
@ -127,7 +127,7 @@ TEST(AudioDecoderCalculatorTest, TestAAC) {
[type.googleapis.com/mediapipe.AudioDecoderOptions]: {
audio_stream { stream_index: 0 }
}
})");
})pb");
CalculatorRunner runner(node_config);
runner.MutableSidePackets()->Tag("INPUT_FILE_PATH") = MakePacket<std::string>(
file::JoinPath("./",

View File

@ -70,7 +70,7 @@ class BeginEndLoopCalculatorGraphTest : public ::testing::Test {
protected:
void SetUp() override {
auto graph_config = ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
num_threads: 4
input_stream: "ints"
node {
@ -90,7 +90,7 @@ class BeginEndLoopCalculatorGraphTest : public ::testing::Test {
input_stream: "BATCH_END:timestamp"
output_stream: "ITERABLE:ints_plus_one"
}
)");
)pb");
tool::AddVectorSink("ints_plus_one", &graph_config, &output_packets_);
MP_ASSERT_OK(graph_.Initialize(graph_config));
MP_ASSERT_OK(graph_.StartRun({}));
@ -197,7 +197,7 @@ class BeginEndLoopCalculatorGraphProcessingEmptyPacketsTest
protected:
void SetUp() override {
auto graph_config = ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
num_threads: 4
input_stream: "ints"
input_stream: "force_ints_to_be_timestamp_bound_update"
@ -229,7 +229,7 @@ class BeginEndLoopCalculatorGraphProcessingEmptyPacketsTest
input_stream: "ints_plus_one"
output_stream: "ints_plus_one_passed_through"
}
)");
)pb");
tool::AddVectorSink("ints_plus_one_passed_through", &graph_config,
&output_packets_);
MP_ASSERT_OK(graph_.Initialize(graph_config));
@ -338,7 +338,7 @@ class BeginEndLoopCalculatorGraphWithClonedInputsTest : public ::testing::Test {
protected:
void SetUp() override {
auto graph_config = ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
num_threads: 4
input_stream: "ints"
input_stream: "multiplier"
@ -362,7 +362,7 @@ class BeginEndLoopCalculatorGraphWithClonedInputsTest : public ::testing::Test {
input_stream: "BATCH_END:timestamp"
output_stream: "ITERABLE:multiplied_ints"
}
)");
)pb");
tool::AddVectorSink("multiplied_ints", &graph_config, &output_packets_);
MP_ASSERT_OK(graph_.Initialize(graph_config));
MP_ASSERT_OK(graph_.StartRun({}));

View File

@ -38,14 +38,14 @@ void AddInputVector(const std::vector<int>& input, int64 timestamp,
TEST(TestClipIntVectorSizeCalculatorTest, EmptyVectorInput) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TestClipIntVectorSizeCalculator"
input_stream: "input_vector"
output_stream: "output_vector"
options {
[mediapipe.ClipVectorSizeCalculatorOptions.ext] { max_vec_size: 1 }
}
)");
)pb");
CalculatorRunner runner(node_config);
std::vector<int> input = {};
@ -60,14 +60,14 @@ TEST(TestClipIntVectorSizeCalculatorTest, EmptyVectorInput) {
TEST(TestClipIntVectorSizeCalculatorTest, OneTimestamp) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TestClipIntVectorSizeCalculator"
input_stream: "input_vector"
output_stream: "output_vector"
options {
[mediapipe.ClipVectorSizeCalculatorOptions.ext] { max_vec_size: 2 }
}
)");
)pb");
CalculatorRunner runner(node_config);
std::vector<int> input = {0, 1, 2, 3};
@ -85,14 +85,14 @@ TEST(TestClipIntVectorSizeCalculatorTest, OneTimestamp) {
TEST(TestClipIntVectorSizeCalculatorTest, TwoInputsAtTwoTimestamps) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TestClipIntVectorSizeCalculator"
input_stream: "input_vector"
output_stream: "output_vector"
options {
[mediapipe.ClipVectorSizeCalculatorOptions.ext] { max_vec_size: 3 }
}
)");
)pb");
CalculatorRunner runner(node_config);
{
@ -133,7 +133,7 @@ TEST(TestClipUniqueIntPtrVectorSizeCalculatorTest, ConsumeOneTimestamp) {
* The test needs to send packets that own the data.
*/
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_vector"
node {
calculator: "TestClipUniqueIntPtrVectorSizeCalculator"
@ -143,7 +143,7 @@ TEST(TestClipUniqueIntPtrVectorSizeCalculatorTest, ConsumeOneTimestamp) {
[mediapipe.ClipVectorSizeCalculatorOptions.ext] { max_vec_size: 3 }
}
}
)");
)pb");
std::vector<Packet> outputs;
tool::AddVectorSink("output_vector", &graph_config, &outputs);
@ -178,7 +178,7 @@ TEST(TestClipUniqueIntPtrVectorSizeCalculatorTest, ConsumeOneTimestamp) {
TEST(TestClipIntVectorSizeCalculatorTest, SidePacket) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TestClipIntVectorSizeCalculator"
input_stream: "input_vector"
input_side_packet: "max_vec_size"
@ -186,7 +186,7 @@ TEST(TestClipIntVectorSizeCalculatorTest, SidePacket) {
options {
[mediapipe.ClipVectorSizeCalculatorOptions.ext] { max_vec_size: 1 }
}
)");
)pb");
CalculatorRunner runner(node_config);
// This should override the default of 1 set in the options.
runner.MutableSidePackets()->Index(0) = Adopt(new int(2));

View File

@ -392,7 +392,7 @@ TEST(TestConcatenateUniqueIntVectorCalculatorTest, ConsumeOneTimestamp) {
* The test needs to send packets that own the data.
*/
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in_1"
input_stream: "in_2"
input_stream: "in_3"
@ -403,7 +403,7 @@ TEST(TestConcatenateUniqueIntVectorCalculatorTest, ConsumeOneTimestamp) {
input_stream: "in_3"
output_stream: "out"
}
)");
)pb");
std::vector<Packet> outputs;
tool::AddVectorSink("out", &graph_config, &outputs);
@ -456,7 +456,7 @@ TEST(TestConcatenateUniqueIntVectorCalculatorTest, OneEmptyStreamStillOutput) {
* The test needs to send packets that own the data.
*/
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in_1"
input_stream: "in_2"
node {
@ -465,7 +465,7 @@ TEST(TestConcatenateUniqueIntVectorCalculatorTest, OneEmptyStreamStillOutput) {
input_stream: "in_2"
output_stream: "out"
}
)");
)pb");
std::vector<Packet> outputs;
tool::AddVectorSink("out", &graph_config, &outputs);
@ -505,7 +505,7 @@ TEST(TestConcatenateUniqueIntVectorCalculatorTest, OneEmptyStreamNoOutput) {
* The test needs to send packets that own the data.
*/
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in_1"
input_stream: "in_2"
node {
@ -519,7 +519,7 @@ TEST(TestConcatenateUniqueIntVectorCalculatorTest, OneEmptyStreamNoOutput) {
}
}
}
)");
)pb");
std::vector<Packet> outputs;
tool::AddVectorSink("out", &graph_config, &outputs);

View File

@ -62,7 +62,7 @@ TEST(ConstantSidePacketCalculatorTest, EveryPossibleType) {
TEST(ConstantSidePacketCalculatorTest, MultiplePackets) {
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "ConstantSidePacketCalculator"
output_side_packet: "PACKET:0:int_packet"
@ -82,7 +82,7 @@ TEST(ConstantSidePacketCalculatorTest, MultiplePackets) {
}
}
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(graph_config));
MP_ASSERT_OK(graph.StartRun({}));
@ -111,7 +111,7 @@ TEST(ConstantSidePacketCalculatorTest, MultiplePackets) {
TEST(ConstantSidePacketCalculatorTest, ProcessingPacketsWithCorrectTagOnly) {
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "ConstantSidePacketCalculator"
output_side_packet: "PACKET:0:int_packet"
@ -131,7 +131,7 @@ TEST(ConstantSidePacketCalculatorTest, ProcessingPacketsWithCorrectTagOnly) {
}
}
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(graph_config));
MP_ASSERT_OK(graph.StartRun({}));
@ -152,7 +152,7 @@ TEST(ConstantSidePacketCalculatorTest, ProcessingPacketsWithCorrectTagOnly) {
TEST(ConstantSidePacketCalculatorTest, IncorrectConfig_MoreOptionsThanPackets) {
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "ConstantSidePacketCalculator"
output_side_packet: "PACKET:int_packet"
@ -163,14 +163,14 @@ TEST(ConstantSidePacketCalculatorTest, IncorrectConfig_MoreOptionsThanPackets) {
}
}
}
)");
)pb");
CalculatorGraph graph;
EXPECT_FALSE(graph.Initialize(graph_config).ok());
}
TEST(ConstantSidePacketCalculatorTest, IncorrectConfig_MorePacketsThanOptions) {
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "ConstantSidePacketCalculator"
output_side_packet: "PACKET:0:int_packet"
@ -181,7 +181,7 @@ TEST(ConstantSidePacketCalculatorTest, IncorrectConfig_MorePacketsThanOptions) {
}
}
}
)");
)pb");
CalculatorGraph graph;
EXPECT_FALSE(graph.Initialize(graph_config).ok());
}

View File

@ -27,7 +27,7 @@ namespace mediapipe {
TEST(QuantizeFloatVectorCalculatorTest, WrongConfig) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DequantizeByteArrayCalculator"
input_stream: "ENCODED:encoded"
output_stream: "FLOAT_VECTOR:float_vector"
@ -36,7 +36,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig) {
max_quantized_value: 2
}
}
)");
)pb");
CalculatorRunner runner(node_config);
std::string empty_string;
runner.MutableInputs()->Tag("ENCODED").packets.push_back(
@ -51,7 +51,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig) {
TEST(QuantizeFloatVectorCalculatorTest, WrongConfig2) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DequantizeByteArrayCalculator"
input_stream: "ENCODED:encoded"
output_stream: "FLOAT_VECTOR:float_vector"
@ -61,7 +61,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig2) {
min_quantized_value: 2
}
}
)");
)pb");
CalculatorRunner runner(node_config);
std::string empty_string;
runner.MutableInputs()->Tag("ENCODED").packets.push_back(
@ -76,7 +76,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig2) {
TEST(QuantizeFloatVectorCalculatorTest, WrongConfig3) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DequantizeByteArrayCalculator"
input_stream: "ENCODED:encoded"
output_stream: "FLOAT_VECTOR:float_vector"
@ -86,7 +86,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig3) {
min_quantized_value: 1
}
}
)");
)pb");
CalculatorRunner runner(node_config);
std::string empty_string;
runner.MutableInputs()->Tag("ENCODED").packets.push_back(
@ -101,7 +101,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig3) {
TEST(DequantizeByteArrayCalculatorTest, TestDequantization) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DequantizeByteArrayCalculator"
input_stream: "ENCODED:encoded"
output_stream: "FLOAT_VECTOR:float_vector"
@ -111,7 +111,7 @@ TEST(DequantizeByteArrayCalculatorTest, TestDequantization) {
min_quantized_value: -2
}
}
)");
)pb");
CalculatorRunner runner(node_config);
unsigned char input[4] = {0x7F, 0xFF, 0x00, 0x01};
runner.MutableInputs()->Tag("ENCODED").packets.push_back(

View File

@ -126,7 +126,7 @@ class FlowLimiterCalculatorSemaphoreTest : public testing::Test {
// Back-edge "finished" limits processing to one frame in-flight.
// The LambdaCalculator is used to keep certain frames in flight.
CalculatorGraphConfig InflightGraphConfig() {
return ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
return ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in_1'
node {
calculator: 'FlowLimiterCalculator'
@ -143,7 +143,7 @@ class FlowLimiterCalculatorSemaphoreTest : public testing::Test {
input_stream: 'in_1_sampled'
output_stream: 'out_1'
}
)");
)pb");
}
protected:
@ -271,7 +271,7 @@ REGISTER_CALCULATOR(DropCalculator);
class FlowLimiterCalculatorTest : public testing::Test {
protected:
CalculatorGraphConfig InflightGraphConfig() {
return ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
return ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in_1'
node {
calculator: 'FlowLimiterCalculator'
@ -296,7 +296,7 @@ class FlowLimiterCalculatorTest : public testing::Test {
input_stream: 'PACKET:out_1_sampled'
output_stream: 'PACKET:out_1'
}
)");
)pb");
}
// Parse an absl::Time from RFC3339 format.
@ -348,10 +348,10 @@ TEST_F(FlowLimiterCalculatorTest, FinishedTimestamps) {
SetUpInputData();
SetUpSimulationClock();
CalculatorGraphConfig graph_config = InflightGraphConfig();
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"(
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"pb(
max_in_flight: 1
max_in_queue: 1
)");
)pb");
std::map<std::string, Packet> side_packets = {
{"limiter_options",
MakePacket<FlowLimiterCalculatorOptions>(limiter_options)},
@ -419,11 +419,11 @@ TEST_F(FlowLimiterCalculatorTest, FinishedLost) {
SetUpInputData();
SetUpSimulationClock();
CalculatorGraphConfig graph_config = InflightGraphConfig();
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"(
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"pb(
max_in_flight: 1
max_in_queue: 1
in_flight_timeout: 100000 # 100 ms
)");
)pb");
std::map<std::string, Packet> side_packets = {
{"limiter_options",
MakePacket<FlowLimiterCalculatorOptions>(limiter_options)},
@ -483,11 +483,11 @@ TEST_F(FlowLimiterCalculatorTest, FinishedDelayed) {
SetUpInputData();
SetUpSimulationClock();
CalculatorGraphConfig graph_config = InflightGraphConfig();
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"(
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"pb(
max_in_flight: 1
max_in_queue: 1
in_flight_timeout: 100000 # 100 ms
)");
)pb");
std::map<std::string, Packet> side_packets = {
{"limiter_options",
MakePacket<FlowLimiterCalculatorOptions>(limiter_options)},
@ -548,7 +548,7 @@ TEST_F(FlowLimiterCalculatorTest, TwoInputStreams) {
SetUpInputData();
SetUpSimulationClock();
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in_1'
input_stream: 'in_2'
node {
@ -576,13 +576,13 @@ TEST_F(FlowLimiterCalculatorTest, TwoInputStreams) {
input_stream: 'PACKET:out_1_sampled'
output_stream: 'PACKET:out_1'
}
)");
)pb");
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"(
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"pb(
max_in_flight: 1
max_in_queue: 1
in_flight_timeout: 100000 # 100 ms
)");
)pb");
std::map<std::string, Packet> side_packets = {
{"limiter_options",
MakePacket<FlowLimiterCalculatorOptions>(limiter_options)},
@ -657,7 +657,7 @@ TEST_F(FlowLimiterCalculatorTest, ZeroQueue) {
SetUpInputData();
SetUpSimulationClock();
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in_1'
input_stream: 'in_2'
node {
@ -685,13 +685,13 @@ TEST_F(FlowLimiterCalculatorTest, ZeroQueue) {
input_stream: 'PACKET:out_1_sampled'
output_stream: 'PACKET:out_1'
}
)");
)pb");
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"(
auto limiter_options = ParseTextProtoOrDie<FlowLimiterCalculatorOptions>(R"pb(
max_in_flight: 1
max_in_queue: 0
in_flight_timeout: 100000 # 100 ms
)");
)pb");
std::map<std::string, Packet> side_packets = {
{"limiter_options",
MakePacket<FlowLimiterCalculatorOptions>(limiter_options)},

View File

@ -64,13 +64,13 @@ const char kMatrixText2[] =
TEST(MatrixSubtractCalculatorTest, WrongConfig) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MatrixSubtractCalculator"
input_stream: "input_matrix"
input_side_packet: "SUBTRAHEND:side_matrix"
input_side_packet: "MINUEND:side_matrix2"
output_stream: "output_matrix"
)");
)pb");
CalculatorRunner runner(node_config);
auto status = runner.Run();
EXPECT_THAT(
@ -81,12 +81,12 @@ TEST(MatrixSubtractCalculatorTest, WrongConfig) {
TEST(MatrixSubtractCalculatorTest, WrongConfig2) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MatrixSubtractCalculator"
input_side_packet: "SUBTRAHEND:side_matrix"
input_stream: "SUBTRAHEND:side_matrix2"
output_stream: "output_matrix"
)");
)pb");
CalculatorRunner runner(node_config);
auto status = runner.Run();
EXPECT_THAT(status.message(), testing::HasSubstr("must be connected"));
@ -95,12 +95,12 @@ TEST(MatrixSubtractCalculatorTest, WrongConfig2) {
TEST(MatrixSubtractCalculatorTest, SubtractFromInput) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MatrixSubtractCalculator"
input_stream: "MINUEND:input_matrix"
input_side_packet: "SUBTRAHEND:side_matrix"
output_stream: "output_matrix"
)");
)pb");
CalculatorRunner runner(node_config);
Matrix* side_matrix = new Matrix();
MatrixFromTextProto(kMatrixText, side_matrix);
@ -124,12 +124,12 @@ TEST(MatrixSubtractCalculatorTest, SubtractFromInput) {
TEST(MatrixSubtractCalculatorTest, SubtractFromSideMatrix) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MatrixSubtractCalculator"
input_stream: "SUBTRAHEND:input_matrix"
input_side_packet: "MINUEND:side_matrix"
output_stream: "output_matrix"
)");
)pb");
CalculatorRunner runner(node_config);
Matrix* side_matrix = new Matrix();
MatrixFromTextProto(kMatrixText, side_matrix);

View File

@ -26,31 +26,33 @@ namespace {
// Checks that the calculator fails if no input streams are provided.
TEST(InvariantMergeInputStreamsCalculator, NoInputStreamsMustFail) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MergeCalculator"
output_stream: "merged_output"
)"));
)pb"));
// Expect calculator to fail.
ASSERT_FALSE(runner.Run().ok());
}
// Checks that the calculator fails with an incorrect number of output streams.
TEST(InvariantMergeInputStreamsCalculator, ExpectExactlyOneOutputStream) {
CalculatorRunner runner1(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner1(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MergeCalculator"
input_stream: "input1"
input_stream: "input2"
)"));
)pb"));
// Expect calculator to fail.
EXPECT_FALSE(runner1.Run().ok());
CalculatorRunner runner2(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner2(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MergeCalculator"
input_stream: "input1"
input_stream: "input2"
output_stream: "output1"
output_stream: "output2"
)"));
)pb"));
// Expect calculator to fail.
ASSERT_FALSE(runner2.Run().ok());
}
@ -58,12 +60,12 @@ TEST(InvariantMergeInputStreamsCalculator, ExpectExactlyOneOutputStream) {
// Ensures two streams with differing types can be merged correctly.
TEST(MediaPipeDetectionToSoapboxDetectionCalculatorTest,
TestMergingTwoStreams) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MergeCalculator"
input_stream: "input1"
input_stream: "input2"
output_stream: "combined_output"
)"));
)pb"));
// input1: integers 10, 20, 30, occurring at times 10, 20, 30.
runner.MutableInputs()->Index(0).packets.push_back(
@ -102,13 +104,13 @@ TEST(MediaPipeDetectionToSoapboxDetectionCalculatorTest,
// Ensures three streams with differing types can be merged correctly.
TEST(MediaPipeDetectionToSoapboxDetectionCalculatorTest,
TestMergingThreeStreams) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MergeCalculator"
input_stream: "input1"
input_stream: "input2"
input_stream: "input3"
output_stream: "combined_output"
)"));
)pb"));
// input1: integer 30 occurring at time 30.
runner.MutableInputs()->Index(0).packets.push_back(

View File

@ -31,7 +31,7 @@ namespace {
// Graph with default input stream handler, and the input selection is driven
// by an input stream. All MuxCalculator inputs are present at each timestamp.
constexpr char kTestGraphConfig1[] = R"proto(
constexpr char kTestGraphConfig1[] = R"pb(
input_stream: "input"
output_stream: "test_output"
node {
@ -60,12 +60,12 @@ constexpr char kTestGraphConfig1[] = R"proto(
output_stream: "OUTPUT:test_output"
input_stream_handler { input_stream_handler: "DefaultInputStreamHandler" }
}
)proto";
)pb";
// Graph with default input stream handler, and the input selection is driven
// by an input side packet. All MuxCalculator inputs are present at each
// timestamp.
constexpr char kTestGraphConfig2[] = R"proto(
constexpr char kTestGraphConfig2[] = R"pb(
input_side_packet: "input_selector"
input_stream: "input"
output_stream: "test_output"
@ -93,12 +93,12 @@ constexpr char kTestGraphConfig2[] = R"proto(
output_stream: "OUTPUT:test_output"
input_stream_handler { input_stream_handler: "DefaultInputStreamHandler" }
}
)proto";
)pb";
// Graph with mux input stream handler, and the input selection is driven
// by an input stream. Only one MuxCalculator input is present at each
// timestamp.
constexpr char kTestGraphConfig3[] = R"proto(
constexpr char kTestGraphConfig3[] = R"pb(
input_stream: "input"
output_stream: "test_output"
node {
@ -117,7 +117,7 @@ constexpr char kTestGraphConfig3[] = R"proto(
input_stream: "SELECT:input_select"
output_stream: "OUTPUT:test_output"
}
)proto";
)pb";
constexpr char kOutputName[] = "test_output";
constexpr char kInputName[] = "input";
@ -235,7 +235,7 @@ TEST(MuxCalculatorTest, InputStreamSelector_MuxInputStreamHandler) {
EXPECT_EQ(output, input_packets);
}
constexpr char kDualInputGraphConfig[] = R"proto(
constexpr char kDualInputGraphConfig[] = R"pb(
input_stream: "input_0"
input_stream: "input_1"
input_stream: "input_select"
@ -247,7 +247,7 @@ constexpr char kDualInputGraphConfig[] = R"proto(
input_stream: "SELECT:input_select"
output_stream: "OUTPUT:test_output"
}
)proto";
)pb";
TEST(MuxCalculatorTest, DiscardSkippedInputs_MuxInputStreamHandler) {
CalculatorGraphConfig config =

View File

@ -40,7 +40,7 @@ MATCHER_P2(BoolPacket, value, timestamp, "") {
TEST(PreviousLoopbackCalculator, CorrectTimestamps) {
std::vector<Packet> output_packets;
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'allow'
input_stream: 'value'
node {
@ -54,7 +54,7 @@ TEST(PreviousLoopbackCalculator, CorrectTimestamps) {
input_stream: 'PACKET:gated_value'
output_stream: 'PRESENCE:presence'
}
)");
)pb");
tool::AddVectorSink("presence", &graph_config, &output_packets);
CalculatorGraph graph;

View File

@ -452,7 +452,7 @@ TEST(PacketResamplerCalculatorTest, FrameRateTest) {
}
TEST(PacketResamplerCalculatorTest, SetVideoHeader) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "PacketResamplerCalculator"
input_stream: "DATA:in_data"
input_stream: "VIDEO_HEADER:in_video_header"
@ -461,7 +461,7 @@ TEST(PacketResamplerCalculatorTest, SetVideoHeader) {
options {
[mediapipe.PacketResamplerCalculatorOptions.ext] { frame_rate: 50.0 }
}
)"));
)pb"));
for (const int64 ts : {0, 5000, 10010, 15001, 19990}) {
runner.MutableInputs()->Tag("DATA").packets.push_back(
@ -705,7 +705,7 @@ TEST(PacketResamplerCalculatorTest, OutputTimestampRangeAligned) {
TEST(PacketResamplerCalculatorTest, OptionsSidePacket) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "PacketResamplerCalculator"
input_side_packet: "OPTIONS:options"
input_stream: "input"
@ -715,16 +715,16 @@ TEST(PacketResamplerCalculatorTest, OptionsSidePacket) {
frame_rate: 60
base_timestamp: 0
}
})");
})pb");
{
SimpleRunner runner(node_config);
auto options =
new CalculatorOptions(ParseTextProtoOrDie<CalculatorOptions>(
R"(
R"pb(
[mediapipe.PacketResamplerCalculatorOptions.ext] {
frame_rate: 30
})"));
})pb"));
runner.MutableSidePackets()->Tag("OPTIONS") = Adopt(options);
runner.SetInput({-222, 15000, 32000, 49999, 150000});
MP_ASSERT_OK(runner.Run());
@ -734,12 +734,12 @@ TEST(PacketResamplerCalculatorTest, OptionsSidePacket) {
SimpleRunner runner(node_config);
auto options =
new CalculatorOptions(ParseTextProtoOrDie<CalculatorOptions>(R"(
new CalculatorOptions(ParseTextProtoOrDie<CalculatorOptions>(R"pb(
merge_fields: false
[mediapipe.PacketResamplerCalculatorOptions.ext] {
frame_rate: 30
base_timestamp: 0
})"));
})pb"));
runner.MutableSidePackets()->Tag("OPTIONS") = Adopt(options);
runner.SetInput({-222, 15000, 32000, 49999, 150000});

View File

@ -69,7 +69,7 @@ MATCHER_P2(PairPacket, timestamp, pair, "") {
TEST(PreviousLoopbackCalculator, CorrectTimestamps) {
std::vector<Packet> in_prev;
CalculatorGraphConfig graph_config_ =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'PreviousLoopbackCalculator'
@ -93,7 +93,7 @@ TEST(PreviousLoopbackCalculator, CorrectTimestamps) {
input_stream: 'previous2'
output_stream: 'pair'
}
)");
)pb");
tool::AddVectorSink("pair", &graph_config_, &in_prev);
CalculatorGraph graph_;
@ -169,7 +169,7 @@ REGISTER_CALCULATOR(PacketOnCloseCalculator);
TEST(PreviousLoopbackCalculator, ClosesCorrectly) {
std::vector<Packet> outputs;
CalculatorGraphConfig graph_config_ =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'PreviousLoopbackCalculator'
@ -192,7 +192,7 @@ TEST(PreviousLoopbackCalculator, ClosesCorrectly) {
input_stream: 'out'
output_stream: 'close_out'
}
)");
)pb");
tool::AddVectorSink("close_out", &graph_config_, &outputs);
CalculatorGraph graph_;
@ -231,7 +231,7 @@ TEST(PreviousLoopbackCalculator, ClosesCorrectly) {
TEST(PreviousLoopbackCalculator, ProcessesMaxTimestamp) {
std::vector<Packet> out_and_previous_packets;
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'PreviousLoopbackCalculator'
@ -253,7 +253,7 @@ TEST(PreviousLoopbackCalculator, ProcessesMaxTimestamp) {
input_stream: 'previous'
output_stream: 'out_and_previous'
}
)");
)pb");
tool::AddVectorSink("out_and_previous", &graph_config,
&out_and_previous_packets);
@ -278,7 +278,7 @@ TEST(PreviousLoopbackCalculator, ProcessesMaxTimestamp) {
TEST(PreviousLoopbackCalculator, ProcessesMaxTimestampNonEmptyPrevious) {
std::vector<Packet> out_and_previous_packets;
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'PreviousLoopbackCalculator'
@ -300,7 +300,7 @@ TEST(PreviousLoopbackCalculator, ProcessesMaxTimestampNonEmptyPrevious) {
input_stream: 'previous'
output_stream: 'out_and_previous'
}
)");
)pb");
tool::AddVectorSink("out_and_previous", &graph_config,
&out_and_previous_packets);
@ -331,7 +331,7 @@ TEST(PreviousLoopbackCalculator, ProcessesMaxTimestampNonEmptyPrevious) {
TEST(PreviousLoopbackCalculator, EmptyLoopForever) {
std::vector<Packet> outputs;
CalculatorGraphConfig graph_config_ =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'PreviousLoopbackCalculator'
@ -354,7 +354,7 @@ TEST(PreviousLoopbackCalculator, EmptyLoopForever) {
input_stream: 'out'
output_stream: 'close_out'
}
)");
)pb");
tool::AddVectorSink("close_out", &graph_config_, &outputs);
CalculatorGraph graph_;
@ -386,7 +386,7 @@ class PreviousLoopbackCalculatorProcessingTimestampsTest
protected:
void SetUp() override {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'input'
input_stream: 'force_main_empty'
input_stream: 'force_loop_empty'
@ -424,7 +424,7 @@ class PreviousLoopbackCalculatorProcessingTimestampsTest
input_stream: 'passed_through_prev_loop'
output_stream: 'passed_through_input_and_prev_loop'
}
)");
)pb");
tool::AddVectorSink("passed_through_input_and_prev_loop", &graph_config,
&output_packets_);
MP_ASSERT_OK(graph_.Initialize(graph_config, {}));
@ -724,7 +724,7 @@ class PreviousLoopbackCalculatorDelayBehaviorTest : public testing::Test {
protected:
void SetUp() override {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'input'
# Drops "loop" when set to "true", delaying output of prev_loop, hence
# delaying output of the graph.
@ -755,7 +755,7 @@ class PreviousLoopbackCalculatorDelayBehaviorTest : public testing::Test {
input_stream: 'passed_through_prev_loop'
output_stream: 'passed_through_input_and_prev_loop'
}
)");
)pb");
tool::AddVectorSink("passed_through_input_and_prev_loop", &graph_config,
&output_packets_);
MP_ASSERT_OK(graph_.Initialize(graph_config, {}));

View File

@ -27,7 +27,7 @@ namespace mediapipe {
TEST(QuantizeFloatVectorCalculatorTest, WrongConfig) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "QuantizeFloatVectorCalculator"
input_stream: "FLOAT_VECTOR:float_vector"
output_stream: "ENCODED:encoded"
@ -36,7 +36,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig) {
min_quantized_value: 1
}
}
)");
)pb");
CalculatorRunner runner(node_config);
std::vector<float> empty_vector;
runner.MutableInputs()
@ -53,7 +53,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig) {
TEST(QuantizeFloatVectorCalculatorTest, WrongConfig2) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "QuantizeFloatVectorCalculator"
input_stream: "FLOAT_VECTOR:float_vector"
output_stream: "ENCODED:encoded"
@ -63,7 +63,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig2) {
min_quantized_value: 1
}
}
)");
)pb");
CalculatorRunner runner(node_config);
std::vector<float> empty_vector;
runner.MutableInputs()
@ -80,7 +80,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig2) {
TEST(QuantizeFloatVectorCalculatorTest, WrongConfig3) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "QuantizeFloatVectorCalculator"
input_stream: "FLOAT_VECTOR:float_vector"
output_stream: "ENCODED:encoded"
@ -90,7 +90,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig3) {
min_quantized_value: 1
}
}
)");
)pb");
CalculatorRunner runner(node_config);
std::vector<float> empty_vector;
runner.MutableInputs()
@ -107,7 +107,7 @@ TEST(QuantizeFloatVectorCalculatorTest, WrongConfig3) {
TEST(QuantizeFloatVectorCalculatorTest, TestEmptyVector) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "QuantizeFloatVectorCalculator"
input_stream: "FLOAT_VECTOR:float_vector"
output_stream: "ENCODED:encoded"
@ -117,7 +117,7 @@ TEST(QuantizeFloatVectorCalculatorTest, TestEmptyVector) {
min_quantized_value: -1
}
}
)");
)pb");
CalculatorRunner runner(node_config);
std::vector<float> empty_vector;
runner.MutableInputs()
@ -133,7 +133,7 @@ TEST(QuantizeFloatVectorCalculatorTest, TestEmptyVector) {
TEST(QuantizeFloatVectorCalculatorTest, TestNonEmptyVector) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "QuantizeFloatVectorCalculator"
input_stream: "FLOAT_VECTOR:float_vector"
output_stream: "ENCODED:encoded"
@ -143,7 +143,7 @@ TEST(QuantizeFloatVectorCalculatorTest, TestNonEmptyVector) {
min_quantized_value: -64
}
}
)");
)pb");
CalculatorRunner runner(node_config);
std::vector<float> vector = {0.0f, -64.0f, 64.0f, -32.0f, 32.0f};
runner.MutableInputs()
@ -171,7 +171,7 @@ TEST(QuantizeFloatVectorCalculatorTest, TestNonEmptyVector) {
TEST(QuantizeFloatVectorCalculatorTest, TestSaturation) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "QuantizeFloatVectorCalculator"
input_stream: "FLOAT_VECTOR:float_vector"
output_stream: "ENCODED:encoded"
@ -181,7 +181,7 @@ TEST(QuantizeFloatVectorCalculatorTest, TestSaturation) {
min_quantized_value: -64
}
}
)");
)pb");
CalculatorRunner runner(node_config);
std::vector<float> vector = {-65.0f, 65.0f};
runner.MutableInputs()

View File

@ -70,13 +70,13 @@ std::vector<T> PacketValues(const std::vector<Packet>& packets) {
constexpr int kNumImageFrames = 5;
constexpr int kNumFinished = 3;
CalculatorGraphConfig::Node GetDefaultNode() {
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "RealTimeFlowLimiterCalculator"
input_stream: "raw_frames"
input_stream: "FINISHED:finished"
input_stream_info: { tag_index: "FINISHED" back_edge: true }
output_stream: "gated_frames"
)");
)pb");
}
// Simple test to make sure that the RealTimeFlowLimiterCalculator outputs just
@ -219,7 +219,7 @@ class RealTimeFlowLimiterCalculatorTest : public testing::Test {
// Back-edge "finished" limits processing to one frame in-flight.
// The two LambdaCalculators are used to keep certain packet sets in flight.
CalculatorGraphConfig InflightGraphConfig() {
return ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
return ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in_1'
input_stream: 'in_2'
node {
@ -256,7 +256,7 @@ class RealTimeFlowLimiterCalculatorTest : public testing::Test {
output_stream: 'out_1'
output_stream: 'out_2'
}
)");
)pb");
}
protected:
@ -344,7 +344,7 @@ TEST(RealTimeFlowLimiterCalculator, TwoStreams) {
std::vector<Packet> a_passed;
std::vector<Packet> b_passed;
CalculatorGraphConfig graph_config_ =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in_a'
input_stream: 'in_b'
input_stream: 'finished'
@ -360,7 +360,7 @@ TEST(RealTimeFlowLimiterCalculator, TwoStreams) {
output_stream: 'in_b_sampled'
output_stream: 'ALLOW:allow'
}
)");
)pb");
std::string allow_cb_name;
tool::AddVectorSink("in_a_sampled", &graph_config_, &a_passed);
tool::AddVectorSink("in_b_sampled", &graph_config_, &b_passed);
@ -442,7 +442,7 @@ TEST(RealTimeFlowLimiterCalculator, TwoStreams) {
TEST(RealTimeFlowLimiterCalculator, CanConsume) {
std::vector<Packet> in_sampled_packets_;
CalculatorGraphConfig graph_config_ =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
input_stream: 'finished'
node {
@ -455,7 +455,7 @@ TEST(RealTimeFlowLimiterCalculator, CanConsume) {
output_stream: 'in_sampled'
output_stream: 'ALLOW:allow'
}
)");
)pb");
std::string allow_cb_name;
tool::AddVectorSink("in_sampled", &graph_config_, &in_sampled_packets_);
tool::AddCallbackCalculator("allow", &graph_config_, &allow_cb_name, true);

View File

@ -36,7 +36,7 @@ using testing::HasSubstr;
TEST(SidePacketToStreamCalculator, WrongConfig_MissingTick) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tick"
input_side_packet: "side_packet"
output_stream: "packet"
@ -45,7 +45,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_MissingTick) {
input_side_packet: "side_packet"
output_stream: "AT_TICK:packet"
}
)");
)pb");
CalculatorGraph graph;
auto status = graph.Initialize(graph_config);
EXPECT_FALSE(status.ok());
@ -58,7 +58,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_MissingTick) {
TEST(SidePacketToStreamCalculator, WrongConfig_MissingTimestampSideInput) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "timestamp"
input_side_packet: "side_packet"
output_stream: "packet"
@ -67,7 +67,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_MissingTimestampSideInput) {
input_side_packet: "side_packet"
output_stream: "AT_TIMESTAMP:packet"
}
)");
)pb");
CalculatorGraph graph;
auto status = graph.Initialize(graph_config);
EXPECT_FALSE(status.ok());
@ -79,7 +79,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_MissingTimestampSideInput) {
TEST(SidePacketToStreamCalculator, WrongConfig_NonExistentTag) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tick"
input_side_packet: "side_packet"
output_stream: "packet"
@ -88,7 +88,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_NonExistentTag) {
input_side_packet: "side_packet"
output_stream: "DOES_NOT_EXIST:packet"
}
)");
)pb");
CalculatorGraph graph;
auto status = graph.Initialize(graph_config);
EXPECT_FALSE(status.ok());
@ -102,7 +102,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_NonExistentTag) {
TEST(SidePacketToStreamCalculator, WrongConfig_MixedTags) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tick"
input_side_packet: "side_packet0"
input_side_packet: "side_packet1"
@ -113,7 +113,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_MixedTags) {
output_stream: "AT_TICK:packet0"
output_stream: "AT_PRE_STREAM:packet1"
}
)");
)pb");
CalculatorGraph graph;
auto status = graph.Initialize(graph_config);
EXPECT_FALSE(status.ok());
@ -127,7 +127,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_MixedTags) {
TEST(SidePacketToStreamCalculator, WrongConfig_NotEnoughSidePackets) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_side_packet: "side_packet0"
input_side_packet: "side_packet1"
node {
@ -136,7 +136,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_NotEnoughSidePackets) {
output_stream: "AT_PRESTREAM:0:packet0"
output_stream: "AT_PRESTREAM:1:packet1"
}
)");
)pb");
CalculatorGraph graph;
auto status = graph.Initialize(graph_config);
EXPECT_FALSE(status.ok());
@ -149,7 +149,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_NotEnoughSidePackets) {
TEST(SidePacketToStreamCalculator, WrongConfig_NotEnoughOutputStreams) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_side_packet: "side_packet0"
input_side_packet: "side_packet1"
node {
@ -158,7 +158,7 @@ TEST(SidePacketToStreamCalculator, WrongConfig_NotEnoughOutputStreams) {
input_side_packet: "side_packet1"
output_stream: "AT_PRESTREAM:packet0"
}
)");
)pb");
CalculatorGraph graph;
auto status = graph.Initialize(graph_config);
EXPECT_FALSE(status.ok());
@ -209,7 +209,7 @@ TEST(SidePacketToStreamCalculator, NoAtTickOutputTags) {
TEST(SidePacketToStreamCalculator, AtTick) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tick"
input_side_packet: "side_packet"
output_stream: "packet"
@ -219,7 +219,7 @@ TEST(SidePacketToStreamCalculator, AtTick) {
input_side_packet: "side_packet"
output_stream: "AT_TICK:packet"
}
)");
)pb");
std::vector<Packet> output_packets;
tool::AddVectorSink("packet", &graph_config, &output_packets);
CalculatorGraph graph;
@ -251,7 +251,7 @@ TEST(SidePacketToStreamCalculator, AtTick) {
TEST(SidePacketToStreamCalculator, AtTick_MultipleSidePackets) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tick"
input_side_packet: "side_packet0"
input_side_packet: "side_packet1"
@ -265,7 +265,7 @@ TEST(SidePacketToStreamCalculator, AtTick_MultipleSidePackets) {
output_stream: "AT_TICK:0:packet0"
output_stream: "AT_TICK:1:packet1"
}
)");
)pb");
std::vector<Packet> output_packets0;
tool::AddVectorSink("packet0", &graph_config, &output_packets0);
std::vector<Packet> output_packets1;
@ -305,7 +305,7 @@ TEST(SidePacketToStreamCalculator, AtTick_MultipleSidePackets) {
TEST(SidePacketToStreamCalculator, AtTimestamp) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_side_packet: "timestamp"
input_side_packet: "side_packet"
output_stream: "packet"
@ -315,7 +315,7 @@ TEST(SidePacketToStreamCalculator, AtTimestamp) {
input_side_packet: "side_packet"
output_stream: "AT_TIMESTAMP:packet"
}
)");
)pb");
std::vector<Packet> output_packets;
tool::AddVectorSink("packet", &graph_config, &output_packets);
CalculatorGraph graph;
@ -337,7 +337,7 @@ TEST(SidePacketToStreamCalculator, AtTimestamp) {
TEST(SidePacketToStreamCalculator, AtTimestamp_MultipleOutputs) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_side_packet: "timestamp"
input_side_packet: "side_packet0"
input_side_packet: "side_packet1"
@ -350,7 +350,7 @@ TEST(SidePacketToStreamCalculator, AtTimestamp_MultipleOutputs) {
output_stream: "AT_TIMESTAMP:0:packet0"
output_stream: "AT_TIMESTAMP:1:packet1"
}
)");
)pb");
std::vector<Packet> output_packets0;
tool::AddVectorSink("packet0", &graph_config, &output_packets0);
std::vector<Packet> output_packets1;

View File

@ -122,7 +122,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest, SmokeTest) {
// Prepare a graph to use the SplitNormalizedLandmarkListCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "landmarks_in"
node {
calculator: "SplitNormalizedLandmarkListCalculator"
@ -138,7 +138,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest, SmokeTest) {
}
}
}
)");
)pb");
std::vector<Packet> range_0_packets;
tool::AddVectorSink("range_0", &graph_config, &range_0_packets);
std::vector<Packet> range_1_packets;
@ -171,7 +171,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest, InvalidRangeTest) {
// Prepare a graph to use the SplitNormalizedLandmarkListCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "landmarks_in"
node {
calculator: "SplitNormalizedLandmarkListCalculator"
@ -183,7 +183,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest, InvalidRangeTest) {
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -196,7 +196,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest,
// Prepare a graph to use the SplitNormalizedLandmarkListCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "landmarks_in"
node {
calculator: "SplitNormalizedLandmarkListCalculator"
@ -209,7 +209,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest,
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -223,7 +223,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest,
// Prepare a graph to use the SplitNormalizedLandmarkListCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "landmarks_in"
node {
calculator: "SplitNormalizedLandmarkListCalculator"
@ -238,7 +238,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest,
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -252,7 +252,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest,
// Prepare a graph to use the SplitNormalizedLandmarkListCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "landmarks_in"
node {
calculator: "SplitNormalizedLandmarkListCalculator"
@ -266,7 +266,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest,
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -281,7 +281,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest, SmokeTestElementOnly) {
// Prepare a graph to use the SplitNormalizedLandmarkListCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "landmarks_in"
node {
calculator: "SplitNormalizedLandmarkListCalculator"
@ -298,7 +298,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest, SmokeTestElementOnly) {
}
}
}
)");
)pb");
std::vector<Packet> range_0_packets;
tool::AddVectorSink("range_0", &graph_config, &range_0_packets);
std::vector<Packet> range_1_packets;
@ -334,7 +334,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest, SmokeTestCombiningOutputs) {
// Prepare a graph to use the SplitNormalizedLandmarkListCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "landmarks_in"
node {
calculator: "SplitNormalizedLandmarkListCalculator"
@ -349,7 +349,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest, SmokeTestCombiningOutputs) {
}
}
}
)");
)pb");
std::vector<Packet> range_0_packets;
tool::AddVectorSink("range_0", &graph_config, &range_0_packets);
@ -377,7 +377,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest,
// Prepare a graph to use the SplitNormalizedLandmarkListCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "landmarks_in"
node {
calculator: "SplitNormalizedLandmarkListCalculator"
@ -394,7 +394,7 @@ TEST_F(SplitNormalizedLandmarkListCalculatorTest,
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;

View File

@ -163,7 +163,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTest) {
// Prepare a graph to use the SplitTfLiteTensorVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tensor_in"
node {
calculator: "SplitTfLiteTensorVectorCalculator"
@ -179,7 +179,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTest) {
}
}
}
)");
)pb");
std::vector<Packet> range_0_packets;
tool::AddVectorSink("range_0", &graph_config, &range_0_packets);
std::vector<Packet> range_1_packets;
@ -214,7 +214,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, InvalidRangeTest) {
// Prepare a graph to use the SplitTfLiteTensorVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tensor_in"
node {
calculator: "SplitTfLiteTensorVectorCalculator"
@ -226,7 +226,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, InvalidRangeTest) {
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -240,7 +240,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, InvalidOutputStreamCountTest) {
// Prepare a graph to use the SplitTfLiteTensorVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tensor_in"
node {
calculator: "SplitTfLiteTensorVectorCalculator"
@ -253,7 +253,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, InvalidOutputStreamCountTest) {
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -269,7 +269,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest,
// Prepare a graph to use the SplitTfLiteTensorVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tensor_in"
node {
calculator: "SplitTfLiteTensorVectorCalculator"
@ -284,7 +284,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest,
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -299,7 +299,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, InvalidOverlappingRangesTest) {
// Prepare a graph to use the SplitTfLiteTensorVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tensor_in"
node {
calculator: "SplitTfLiteTensorVectorCalculator"
@ -313,7 +313,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, InvalidOverlappingRangesTest) {
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -330,7 +330,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTestElementOnly) {
// Prepare a graph to use the SplitTfLiteTensorVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tensor_in"
node {
calculator: "SplitTfLiteTensorVectorCalculator"
@ -347,7 +347,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTestElementOnly) {
}
}
}
)");
)pb");
std::vector<Packet> range_0_packets;
tool::AddVectorSink("range_0", &graph_config, &range_0_packets);
std::vector<Packet> range_1_packets;
@ -385,7 +385,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTestCombiningOutputs) {
// Prepare a graph to use the SplitTfLiteTensorVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tensor_in"
node {
calculator: "SplitTfLiteTensorVectorCalculator"
@ -400,7 +400,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTestCombiningOutputs) {
}
}
}
)");
)pb");
std::vector<Packet> range_0_packets;
tool::AddVectorSink("range_0", &graph_config, &range_0_packets);
@ -428,7 +428,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest,
// Prepare a graph to use the SplitTfLiteTensorVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "tensor_in"
node {
calculator: "SplitTfLiteTensorVectorCalculator"
@ -445,7 +445,7 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest,
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -511,7 +511,7 @@ TEST_F(MovableSplitUniqueIntPtrCalculatorTest, InvalidOverlappingRangesTest) {
// Prepare a graph to use the TestMovableSplitUniqueIntPtrVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "input_vector"
node {
calculator: "MovableSplitUniqueIntPtrCalculator"
@ -524,7 +524,7 @@ TEST_F(MovableSplitUniqueIntPtrCalculatorTest, InvalidOverlappingRangesTest) {
}
}
}
)");
)pb");
// Run the graph.
CalculatorGraph graph;
@ -536,7 +536,7 @@ TEST_F(MovableSplitUniqueIntPtrCalculatorTest, SmokeTest) {
// Prepare a graph to use the TestMovableSplitUniqueIntPtrVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "input_vector"
node {
calculator: "MovableSplitUniqueIntPtrCalculator"
@ -552,7 +552,7 @@ TEST_F(MovableSplitUniqueIntPtrCalculatorTest, SmokeTest) {
}
}
}
)");
)pb");
std::vector<Packet> range_0_packets;
tool::AddVectorSink("range_0", &graph_config, &range_0_packets);
@ -592,7 +592,7 @@ TEST_F(MovableSplitUniqueIntPtrCalculatorTest, SmokeTestElementOnly) {
// Prepare a graph to use the TestMovableSplitUniqueIntPtrVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "input_vector"
node {
calculator: "MovableSplitUniqueIntPtrCalculator"
@ -609,7 +609,7 @@ TEST_F(MovableSplitUniqueIntPtrCalculatorTest, SmokeTestElementOnly) {
}
}
}
)");
)pb");
std::vector<Packet> range_0_packets;
tool::AddVectorSink("range_0", &graph_config, &range_0_packets);
@ -646,7 +646,7 @@ TEST_F(MovableSplitUniqueIntPtrCalculatorTest, SmokeTestCombiningOutputs) {
// Prepare a graph to use the TestMovableSplitUniqueIntPtrVectorCalculator.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "input_vector"
node {
calculator: "MovableSplitUniqueIntPtrCalculator"
@ -661,7 +661,7 @@ TEST_F(MovableSplitUniqueIntPtrCalculatorTest, SmokeTestCombiningOutputs) {
}
}
}
)");
)pb");
std::vector<Packet> range_0_packets;
tool::AddVectorSink("range_0", &graph_config, &range_0_packets);

View File

@ -41,7 +41,7 @@ constexpr char kWidthTag[] = "WIDTH";
TEST(ImageCroppingCalculatorTest, GetCroppingDimensionsNormal) {
auto calculator_node =
ParseTextProtoOrDie<mediapipe::CalculatorGraphConfig::Node>(
R"(
R"pb(
calculator: "ImageCroppingCalculator"
input_stream: "IMAGE_GPU:input_frames"
output_stream: "IMAGE_GPU:cropped_output_frames"
@ -54,7 +54,7 @@ TEST(ImageCroppingCalculatorTest, GetCroppingDimensionsNormal) {
rotation: 0.3
}
}
)");
)pb");
auto calculator_state = absl::make_unique<CalculatorState>(
"Node", 0, "Calculator", calculator_node, nullptr);
@ -79,7 +79,7 @@ TEST(ImageCroppingCalculatorTest, GetCroppingDimensionsNormal) {
TEST(ImageCroppingCalculatorTest, RedundantSpecInOptions) {
auto calculator_node =
ParseTextProtoOrDie<mediapipe::CalculatorGraphConfig::Node>(
R"(
R"pb(
calculator: "ImageCroppingCalculator"
input_stream: "IMAGE_GPU:input_frames"
output_stream: "IMAGE_GPU:cropped_output_frames"
@ -94,7 +94,7 @@ TEST(ImageCroppingCalculatorTest, RedundantSpecInOptions) {
rotation: 0.3
}
}
)");
)pb");
auto calculator_state = absl::make_unique<CalculatorState>(
"Node", 0, "Calculator", calculator_node, nullptr);
@ -119,7 +119,7 @@ TEST(ImageCroppingCalculatorTest, RedundantSpecInOptions) {
TEST(ImageCroppingCalculatorTest, RedundantSpectWithInputStream) {
auto calculator_node =
ParseTextProtoOrDie<mediapipe::CalculatorGraphConfig::Node>(
R"(
R"pb(
calculator: "ImageCroppingCalculator"
input_stream: "IMAGE_GPU:input_frames"
input_stream: "WIDTH:crop_width"
@ -136,7 +136,7 @@ TEST(ImageCroppingCalculatorTest, RedundantSpectWithInputStream) {
rotation: 0.3
}
}
)");
)pb");
auto calculator_state = absl::make_unique<CalculatorState>(
"Node", 0, "Calculator", calculator_node, nullptr);
@ -168,7 +168,7 @@ TEST(ImageCroppingCalculatorTest, RedundantSpectWithInputStream) {
TEST(ImageCroppingCalculatorTest, RedundantSpecWithInputStream) {
auto calculator_node =
ParseTextProtoOrDie<mediapipe::CalculatorGraphConfig::Node>(
R"(
R"pb(
calculator: "ImageCroppingCalculator"
input_stream: "IMAGE_GPU:input_frames"
input_stream: "RECT:rect"
@ -184,7 +184,7 @@ TEST(ImageCroppingCalculatorTest, RedundantSpecWithInputStream) {
rotation: 0.3
}
}
)");
)pb");
auto calculator_state = absl::make_unique<CalculatorState>(
"Node", 0, "Calculator", calculator_node, nullptr);
@ -196,9 +196,9 @@ TEST(ImageCroppingCalculatorTest, RedundantSpecWithInputStream) {
calculator_state.get(), inputTags, tool::CreateTagMap({}).value());
auto& inputs = cc->Inputs();
mediapipe::Rect rect = ParseTextProtoOrDie<mediapipe::Rect>(
R"(
R"pb(
width: 1 height: 1 x_center: 40 y_center: 40 rotation: 0.5
)");
)pb");
inputs.Tag(kRectTag).Value() = MakePacket<mediapipe::Rect>(rect);
RectSpec expectRect = {
.width = 1,

View File

@ -50,11 +50,11 @@ TEST(ImageFilePropertiesCalculatorTest, ReadsFocalLengthFromJpegInStreams) {
MP_ASSERT_OK(file::GetContents(image_filepath, &image_contents));
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "ImageFilePropertiesCalculator"
input_stream: "image_bytes"
output_stream: "properties"
)");
)pb");
CalculatorRunner runner(node_config);
runner.MutableInputs()->Index(0).packets.push_back(
@ -79,11 +79,11 @@ TEST(ImageFilePropertiesCalculatorTest, ReadsFocalLengthFromJpegInSidePackets) {
MP_ASSERT_OK(file::GetContents(image_filepath, &image_contents));
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "ImageFilePropertiesCalculator"
input_side_packet: "image_bytes"
output_side_packet: "properties"
)");
)pb");
CalculatorRunner runner(node_config);
runner.MutableSidePackets()->Index(0) =
@ -108,11 +108,11 @@ TEST(ImageFilePropertiesCalculatorTest,
MP_ASSERT_OK(file::GetContents(image_filepath, &image_contents));
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "ImageFilePropertiesCalculator"
input_stream: "image_bytes"
output_side_packet: "properties"
)");
)pb");
CalculatorRunner runner(node_config);
runner.MutableInputs()->Index(0).packets.push_back(

View File

@ -36,11 +36,11 @@ TEST(OpenCvEncodedImageToImageFrameCalculatorTest, TestRgbJpeg) {
Packet input_packet = MakePacket<std::string>(contents);
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "OpenCvEncodedImageToImageFrameCalculator"
input_stream: "encoded_image"
output_stream: "image_frame"
)");
)pb");
CalculatorRunner runner(node_config);
runner.MutableInputs()->Index(0).packets.push_back(
input_packet.At(Timestamp(0)));
@ -79,11 +79,11 @@ TEST(OpenCvEncodedImageToImageFrameCalculatorTest, TestGrayscaleJpeg) {
reinterpret_cast<const char*>(&encode_buffer[0]), encode_buffer.size())));
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "OpenCvEncodedImageToImageFrameCalculator"
input_stream: "encoded_image"
output_stream: "image_frame"
)");
)pb");
CalculatorRunner runner(node_config);
runner.MutableInputs()->Index(0).packets.push_back(
input_packet.At(Timestamp(0)));

View File

@ -41,7 +41,6 @@ class InferenceCalculatorSelectorImpl
(options.has_delegate() && options.delegate().has_gpu());
if (should_use_gpu) {
impls.emplace_back("Metal");
impls.emplace_back("MlDriftWebGl");
impls.emplace_back("Gl");
}
impls.emplace_back("Cpu");

View File

@ -118,10 +118,6 @@ struct InferenceCalculatorGl : public InferenceCalculator {
static constexpr char kCalculatorName[] = "InferenceCalculatorGl";
};
struct InferenceCalculatorMlDriftWebGl : public InferenceCalculator {
static constexpr char kCalculatorName[] = "InferenceCalculatorMlDriftWebGl";
};
struct InferenceCalculatorMetal : public InferenceCalculator {
static constexpr char kCalculatorName[] = "InferenceCalculatorMetal";
};

View File

@ -58,10 +58,6 @@ const std::vector<Param>& GetParams() {
p.push_back({"Metal", "Metal"});
p.back().delegate.mutable_gpu();
#endif // TARGET_IPHONE_SIMULATOR
#if __EMSCRIPTEN__
p.push_back({"MlDriftWebGl", "MlDriftWebGl"});
p.back().delegate.mutable_gpu();
#endif // __EMSCRIPTEN__
#if __ANDROID__ && 0 // Disabled for now since emulator can't go GLESv3
p.push_back({"Gl", "Gl"});
p.back().delegate.mutable_gpu();
@ -78,18 +74,6 @@ const std::vector<Param>& GetParams() {
class InferenceCalculatorTest : public testing::TestWithParam<Param> {
protected:
#if __EMSCRIPTEN__
// TODO: fix Tensor locking.
// The MlDrift backend currently fails in debug mode without this,
// because of Tensor locking issues. I am adding this temporarily since
// the calculator is already being used and it's better to have test
// coverage for it. Also, the issue doesn't apply to our Emscripten
// build in practice since it's single-threaded.
void SetUp(void) override {
absl::SetMutexDeadlockDetectionMode(absl::OnDeadlockCycle::kIgnore);
}
#endif // __EMSCRIPTEN__
void SetDelegateForParam(mediapipe::CalculatorGraphConfig_Node* node) {
*node->mutable_options()
->MutableExtension(mediapipe::InferenceCalculatorOptions::ext)

View File

@ -84,7 +84,7 @@ TEST_F(TensorConverterCalculatorTest, RandomMatrixColMajor) {
// Run the calculator and verify that one output is generated.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "matrix"
node {
calculator: "TensorConverterCalculator"
@ -96,7 +96,7 @@ TEST_F(TensorConverterCalculatorTest, RandomMatrixColMajor) {
}
}
}
)");
)pb");
std::vector<Packet> output_packets;
tool::AddVectorSink("tensor", &graph_config, &output_packets);
@ -146,7 +146,7 @@ TEST_F(TensorConverterCalculatorTest, RandomMatrixRowMajor) {
// Run the calculator and verify that one output is generated.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "matrix"
node {
calculator: "TensorConverterCalculator"
@ -158,7 +158,7 @@ TEST_F(TensorConverterCalculatorTest, RandomMatrixRowMajor) {
}
}
}
)");
)pb");
std::vector<Packet> output_packets;
tool::AddVectorSink("tensor", &graph_config, &output_packets);
@ -205,7 +205,7 @@ TEST_F(TensorConverterCalculatorTest, CustomDivAndSub) {
CalculatorGraph graph;
// Run the calculator and verify that one output is generated.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_image"
node {
calculator: "TensorConverterCalculator"
@ -220,7 +220,7 @@ TEST_F(TensorConverterCalculatorTest, CustomDivAndSub) {
}
}
}
)");
)pb");
std::vector<Packet> output_packets;
tool::AddVectorSink("tensor", &graph_config, &output_packets);

View File

@ -56,14 +56,14 @@ class TensorsToClassificationCalculatorTest : public ::testing::Test {
};
TEST_F(TensorsToClassificationCalculatorTest, CorrectOutput) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TensorsToClassificationCalculator"
input_stream: "TENSORS:tensors"
output_stream: "CLASSIFICATIONS:classifications"
options {
[mediapipe.TensorsToClassificationCalculatorOptions.ext] {}
}
)"));
)pb"));
BuildGraph(&runner, {0, 0.5, 1});
MP_ASSERT_OK(runner.Run());
@ -85,7 +85,7 @@ TEST_F(TensorsToClassificationCalculatorTest, CorrectOutput) {
}
TEST_F(TensorsToClassificationCalculatorTest, CorrectOutputWithLabelMapPath) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TensorsToClassificationCalculator"
input_stream: "TENSORS:tensors"
output_stream: "CLASSIFICATIONS:classifications"
@ -94,7 +94,7 @@ TEST_F(TensorsToClassificationCalculatorTest, CorrectOutputWithLabelMapPath) {
label_map_path: "mediapipe/calculators/tensor/testdata/labelmap.txt"
}
}
)"));
)pb"));
BuildGraph(&runner, {0, 0.5, 1});
MP_ASSERT_OK(runner.Run());
@ -117,7 +117,7 @@ TEST_F(TensorsToClassificationCalculatorTest, CorrectOutputWithLabelMapPath) {
TEST_F(TensorsToClassificationCalculatorTest,
CorrectOutputWithLabelMinScoreThreshold) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TensorsToClassificationCalculator"
input_stream: "TENSORS:tensors"
output_stream: "CLASSIFICATIONS:classifications"
@ -126,7 +126,7 @@ TEST_F(TensorsToClassificationCalculatorTest,
min_score_threshold: 0.6
}
}
)"));
)pb"));
BuildGraph(&runner, {0, 0.5, 1});
MP_ASSERT_OK(runner.Run());
@ -144,14 +144,14 @@ TEST_F(TensorsToClassificationCalculatorTest,
}
TEST_F(TensorsToClassificationCalculatorTest, CorrectOutputWithTopK) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TensorsToClassificationCalculator"
input_stream: "TENSORS:tensors"
output_stream: "CLASSIFICATIONS:classifications"
options {
[mediapipe.TensorsToClassificationCalculatorOptions.ext] { top_k: 2 }
}
)"));
)pb"));
BuildGraph(&runner, {0, 0.5, 1});
MP_ASSERT_OK(runner.Run());

View File

@ -57,11 +57,11 @@ class TensorsToFloatsCalculatorTest : public ::testing::Test {
};
TEST_F(TensorsToFloatsCalculatorTest, SingleValue) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TensorsToFloatsCalculator"
input_stream: "TENSORS:tensors"
output_stream: "FLOAT:float"
)"));
)pb"));
const float single_value = 0.5;
BuildGraph(&runner, {single_value});
@ -76,11 +76,11 @@ TEST_F(TensorsToFloatsCalculatorTest, SingleValue) {
}
TEST_F(TensorsToFloatsCalculatorTest, SingleValueAsVector) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TensorsToFloatsCalculator"
input_stream: "TENSORS:tensors"
output_stream: "FLOATS:floats"
)"));
)pb"));
const float single_value = 0.5;
BuildGraph(&runner, {single_value});
@ -95,11 +95,11 @@ TEST_F(TensorsToFloatsCalculatorTest, SingleValueAsVector) {
}
TEST_F(TensorsToFloatsCalculatorTest, FloatVector) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TensorsToFloatsCalculator"
input_stream: "TENSORS:tensors"
output_stream: "FLOATS:floats"
)"));
)pb"));
const std::vector<float> input_values = {0.f, 0.5f, 1.0f};
BuildGraph(&runner, input_values);
@ -116,14 +116,14 @@ TEST_F(TensorsToFloatsCalculatorTest, FloatVector) {
}
TEST_F(TensorsToFloatsCalculatorTest, FloatVectorWithSigmoid) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TensorsToFloatsCalculator"
input_stream: "TENSORS:tensors"
output_stream: "FLOATS:floats"
options {
[mediapipe.TensorsToFloatsCalculatorOptions.ext] { activation: SIGMOID }
}
)"));
)pb"));
const std::vector<float> input_values = {-1.f, 0.f, 1.0f};
const std::vector<float> expected_output_with_sigmoid = {0.269f, 0.5f,

View File

@ -68,31 +68,31 @@ class ObjectDetectionTensorsToDetectionsCalculatorTest
void CreateNodeConfig(CalculatorGraphConfig::Node* node_config) const {
ASSERT_NE(nullptr, node_config);
*node_config = ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
*node_config = ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "ObjectDetectionTensorsToDetectionsCalculator"
input_stream: "NUM_DETECTIONS:num_detections"
input_stream: "BOXES:boxes"
input_stream: "SCORES:scores"
input_stream: "CLASSES:classes"
output_stream: "DETECTIONS:detections"
)");
)pb");
}
void CreateNodeConfigRawTensors(
CalculatorGraphConfig::Node* node_config) const {
ASSERT_NE(nullptr, node_config);
*node_config = ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
*node_config = ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "ObjectDetectionTensorsToDetectionsCalculator"
input_stream: "BOXES:raw_detection_boxes"
input_stream: "SCORES:raw_detection_scores"
output_stream: "DETECTIONS:detections"
)");
)pb");
}
void CreateNodeConfigWithKeypoints(
CalculatorGraphConfig::Node* node_config) const {
ASSERT_NE(nullptr, node_config);
*node_config = ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
*node_config = ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "ObjectDetectionTensorsToDetectionsCalculator"
input_stream: "NUM_DETECTIONS:num_detections"
input_stream: "BOXES:boxes"
@ -100,7 +100,7 @@ class ObjectDetectionTensorsToDetectionsCalculatorTest
input_stream: "CLASSES:classes"
input_stream: "KEYPOINTS:keypoints"
output_stream: "DETECTIONS:detections"
)");
)pb");
}
void SetUpCalculatorRunner() {
@ -177,7 +177,7 @@ class ObjectDetectionTensorsToDetectionsCalculatorTest
InsertExtraSingltonDim(&input_scores_);
InsertExtraSingltonDim(&input_classes_);
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "ObjectDetectionTensorsToDetectionsCalculator"
input_stream: "NUM_DETECTIONS:num_detections"
input_stream: "BOXES:boxes"
@ -188,7 +188,7 @@ class ObjectDetectionTensorsToDetectionsCalculatorTest
[mediapipe.ObjectDetectionsTensorToDetectionsCalculatorOptions
.ext]: { tensor_dim_to_squeeze: 0 }
}
)");
)pb");
runner_ = absl::make_unique<CalculatorRunner>(node_config);
runner_->MutableInputs()
->Tag(kNumDetections)

View File

@ -267,6 +267,17 @@ class PackMediaSequenceCalculator : public CalculatorBase {
}
}
absl::Status VerifySize() {
const int64 MAX_PROTO_BYTES = 1073741823;
std::string id = mpms::HasExampleId(*sequence_)
? mpms::GetExampleId(*sequence_)
: "example";
RET_CHECK_LT(sequence_->ByteSizeLong(), MAX_PROTO_BYTES)
<< "sequence '" << id
<< "' would be too many bytes to serialize after adding features.";
return absl::OkStatus();
}
absl::Status Close(CalculatorContext* cc) override {
auto& options = cc->Options<PackMediaSequenceCalculatorOptions>();
if (options.reconcile_metadata()) {
@ -275,6 +286,9 @@ class PackMediaSequenceCalculator : public CalculatorBase {
options.reconcile_region_annotations(), sequence_.get()));
}
if (options.skip_large_sequences()) {
RET_CHECK_OK(VerifySize());
}
if (options.output_only_if_all_present()) {
absl::Status status = VerifySequence();
if (!status.ok()) {

View File

@ -61,4 +61,8 @@ message PackMediaSequenceCalculatorOptions {
// present, the previous images and timestamps will be removed before adding
// the new images.
optional bool replace_data_instead_of_append = 4 [default = true];
// If true, will return an error status if an output sequence would be too
// many bytes to serialize.
optional bool skip_large_sequences = 7 [default = true];
}

View File

@ -889,5 +889,24 @@ TEST_F(PackMediaSequenceCalculatorTest, TestOverwritingAndReconciling) {
MP_ASSERT_OK(runner_->Run());
}
TEST_F(PackMediaSequenceCalculatorTest, TestTooLargeInputFailsSoftly) {
SetUpCalculator({"FLOAT_FEATURE_TEST:test"}, {}, false, true);
auto input_sequence = ::absl::make_unique<tf::SequenceExample>();
// 1 billion floats should be > 1GB which can't be serialized. It should fail
// gracefully with this input.
int num_timesteps = 1000;
for (int i = 0; i < num_timesteps; ++i) {
auto vf_ptr = ::absl::make_unique<std::vector<float>>(1000000, i);
runner_->MutableInputs()
->Tag("FLOAT_FEATURE_TEST")
.packets.push_back(Adopt(vf_ptr.release()).At(Timestamp(i)));
}
runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") =
Adopt(input_sequence.release());
ASSERT_FALSE(runner_->Run().ok());
}
} // namespace
} // namespace mediapipe

View File

@ -68,7 +68,7 @@ void CompareAnchors(const std::vector<Anchor>& anchors_0,
}
TEST(SsdAnchorCalculatorTest, FaceDetectionConfig) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "SsdAnchorsCalculator"
output_side_packet: "anchors"
options {
@ -89,7 +89,7 @@ TEST(SsdAnchorCalculatorTest, FaceDetectionConfig) {
fixed_anchor_size: true
}
}
)"));
)pb"));
MP_ASSERT_OK(runner.Run()) << "Calculator execution failed.";
@ -106,7 +106,7 @@ TEST(SsdAnchorCalculatorTest, FaceDetectionConfig) {
}
TEST(SsdAnchorCalculatorTest, MobileSSDConfig) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "SsdAnchorsCalculator"
output_side_packet: "anchors"
options {
@ -132,7 +132,7 @@ TEST(SsdAnchorCalculatorTest, MobileSSDConfig) {
reduce_boxes_in_lowest_layer: true
}
}
)"));
)pb"));
MP_ASSERT_OK(runner.Run()) << "Calculator execution failed.";
const auto& anchors =

View File

@ -85,7 +85,7 @@ TEST_F(TfLiteConverterCalculatorTest, RandomMatrixColMajor) {
// Run the calculator and verify that one output is generated.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "matrix"
node {
calculator: "TfLiteConverterCalculator"
@ -97,7 +97,7 @@ TEST_F(TfLiteConverterCalculatorTest, RandomMatrixColMajor) {
}
}
}
)");
)pb");
std::vector<Packet> output_packets;
tool::AddVectorSink("tensor", &graph_config, &output_packets);
@ -146,7 +146,7 @@ TEST_F(TfLiteConverterCalculatorTest, RandomMatrixRowMajor) {
// Run the calculator and verify that one output is generated.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "matrix"
node {
calculator: "TfLiteConverterCalculator"
@ -158,7 +158,7 @@ TEST_F(TfLiteConverterCalculatorTest, RandomMatrixRowMajor) {
}
}
}
)");
)pb");
std::vector<Packet> output_packets;
tool::AddVectorSink("tensor", &graph_config, &output_packets);
@ -204,7 +204,7 @@ TEST_F(TfLiteConverterCalculatorTest, CustomDivAndSub) {
CalculatorGraph graph;
// Run the calculator and verify that one output is generated.
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_image"
node {
calculator: "TfLiteConverterCalculator"
@ -219,7 +219,7 @@ TEST_F(TfLiteConverterCalculatorTest, CustomDivAndSub) {
}
}
}
)");
)pb");
std::vector<Packet> output_packets;
tool::AddVectorSink("tensor", &graph_config, &output_packets);

View File

@ -28,7 +28,7 @@ TEST(TfLiteModelCalculatorTest, SmokeTest) {
// Prepare single calculator graph to and wait for packets.
CalculatorGraphConfig graph_config = ParseTextProtoOrDie<
CalculatorGraphConfig>(
R"(
R"pb(
node {
calculator: "ConstantSidePacketCalculator"
output_side_packet: "PACKET:model_path"
@ -52,7 +52,7 @@ TEST(TfLiteModelCalculatorTest, SmokeTest) {
input_side_packet: "MODEL_BLOB:model_blob"
output_side_packet: "MODEL:model"
}
)");
)pb");
CalculatorGraph graph(graph_config);
MP_ASSERT_OK(graph.StartRun({}));
MP_ASSERT_OK(graph.WaitUntilIdle());

View File

@ -73,14 +73,14 @@ class TfLiteTensorsToClassificationCalculatorTest : public ::testing::Test {
};
TEST_F(TfLiteTensorsToClassificationCalculatorTest, CorrectOutput) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TfLiteTensorsToClassificationCalculator"
input_stream: "TENSORS:tensors"
output_stream: "CLASSIFICATIONS:classifications"
options {
[mediapipe.TfLiteTensorsToClassificationCalculatorOptions.ext] {}
}
)"));
)pb"));
BuildGraph(&runner, {0, 0.5, 1});
MP_ASSERT_OK(runner.Run());
@ -103,7 +103,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest, CorrectOutput) {
TEST_F(TfLiteTensorsToClassificationCalculatorTest,
CorrectOutputWithLabelMapPath) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TfLiteTensorsToClassificationCalculator"
input_stream: "TENSORS:tensors"
output_stream: "CLASSIFICATIONS:classifications"
@ -112,7 +112,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest,
label_map_path: "mediapipe/calculators/tflite/testdata/labelmap.txt"
}
}
)"));
)pb"));
BuildGraph(&runner, {0, 0.5, 1});
MP_ASSERT_OK(runner.Run());
@ -135,7 +135,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest,
TEST_F(TfLiteTensorsToClassificationCalculatorTest,
CorrectOutputWithLabelMinScoreThreshold) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TfLiteTensorsToClassificationCalculator"
input_stream: "TENSORS:tensors"
output_stream: "CLASSIFICATIONS:classifications"
@ -144,7 +144,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest,
min_score_threshold: 0.6
}
}
)"));
)pb"));
BuildGraph(&runner, {0, 0.5, 1});
MP_ASSERT_OK(runner.Run());
@ -162,7 +162,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest,
}
TEST_F(TfLiteTensorsToClassificationCalculatorTest, CorrectOutputWithTopK) {
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"(
mediapipe::CalculatorRunner runner(ParseTextProtoOrDie<Node>(R"pb(
calculator: "TfLiteTensorsToClassificationCalculator"
input_stream: "TENSORS:tensors"
output_stream: "CLASSIFICATIONS:classifications"
@ -171,7 +171,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest, CorrectOutputWithTopK) {
top_k: 2
}
}
)"));
)pb"));
BuildGraph(&runner, {0, 0.5, 1});
MP_ASSERT_OK(runner.Run());

View File

@ -97,7 +97,7 @@ class AssociationDetectionCalculatorTest : public ::testing::Test {
};
TEST_F(AssociationDetectionCalculatorTest, DetectionAssocTest) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AssociationDetectionCalculator"
input_stream: "input_vec_0"
input_stream: "input_vec_1"
@ -108,7 +108,7 @@ TEST_F(AssociationDetectionCalculatorTest, DetectionAssocTest) {
min_similarity_threshold: 0.1
}
}
)"));
)pb"));
// Input Stream 0: det_0, det_1, det_2.
auto input_vec_0 = absl::make_unique<std::vector<::mediapipe::Detection>>();
@ -160,7 +160,7 @@ TEST_F(AssociationDetectionCalculatorTest, DetectionAssocTest) {
}
TEST_F(AssociationDetectionCalculatorTest, DetectionAssocTestWithPrev) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AssociationDetectionCalculator"
input_stream: "PREV:input_vec_0"
input_stream: "input_vec_1"
@ -170,7 +170,7 @@ TEST_F(AssociationDetectionCalculatorTest, DetectionAssocTestWithPrev) {
min_similarity_threshold: 0.1
}
}
)"));
)pb"));
// Input Stream 0: det_3, det_4.
auto input_vec_0 = absl::make_unique<std::vector<::mediapipe::Detection>>();
@ -209,7 +209,7 @@ TEST_F(AssociationDetectionCalculatorTest, DetectionAssocTestWithPrev) {
}
TEST_F(AssociationDetectionCalculatorTest, DetectionAssocTestReverse) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AssociationDetectionCalculator"
input_stream: "input_vec_0"
input_stream: "input_vec_1"
@ -220,7 +220,7 @@ TEST_F(AssociationDetectionCalculatorTest, DetectionAssocTestReverse) {
min_similarity_threshold: 0.1
}
}
)"));
)pb"));
// Input Stream 0: det_5.
auto input_vec_0 = absl::make_unique<std::vector<::mediapipe::Detection>>();
@ -332,7 +332,7 @@ class AssociationNormRectCalculatorTest : public ::testing::Test {
};
TEST_F(AssociationNormRectCalculatorTest, NormRectAssocTest) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AssociationNormRectCalculator"
input_stream: "input_vec_0"
input_stream: "input_vec_1"
@ -343,7 +343,7 @@ TEST_F(AssociationNormRectCalculatorTest, NormRectAssocTest) {
min_similarity_threshold: 0.1
}
}
)"));
)pb"));
// Input Stream 0: nr_0, nr_1, nr_2.
auto input_vec_0 =
@ -386,7 +386,7 @@ TEST_F(AssociationNormRectCalculatorTest, NormRectAssocTest) {
}
TEST_F(AssociationNormRectCalculatorTest, NormRectAssocTestReverse) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AssociationNormRectCalculator"
input_stream: "input_vec_0"
input_stream: "input_vec_1"
@ -397,7 +397,7 @@ TEST_F(AssociationNormRectCalculatorTest, NormRectAssocTestReverse) {
min_similarity_threshold: 0.1
}
}
)"));
)pb"));
// Input Stream 0: nr_5.
auto input_vec_0 =
@ -441,7 +441,7 @@ TEST_F(AssociationNormRectCalculatorTest, NormRectAssocTestReverse) {
}
TEST_F(AssociationNormRectCalculatorTest, NormRectAssocSingleInputStream) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "AssociationNormRectCalculator"
input_stream: "input_vec"
output_stream: "output_vec"
@ -450,7 +450,7 @@ TEST_F(AssociationNormRectCalculatorTest, NormRectAssocSingleInputStream) {
min_similarity_threshold: 0.1
}
}
)"));
)pb"));
// Input Stream : nr_3, nr_5.
auto input_vec =

View File

@ -41,14 +41,14 @@ void AddInputVector(const std::vector<int>& input, int64 timestamp,
TEST(TestIntCollectionHasMinSizeCalculator, DoesHaveMinSize) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TestIntCollectionHasMinSizeCalculator"
input_stream: "ITERABLE:input_vector"
output_stream: "output_vector"
options {
[mediapipe.CollectionHasMinSizeCalculatorOptions.ext] { min_size: 2 }
}
)");
)pb");
CalculatorRunner runner(node_config);
const std::vector<Packet>& outputs = runner.Outputs().Index(0).packets;
@ -70,12 +70,12 @@ TEST(TestIntCollectionHasMinSizeCalculator, DoesHaveMinSize) {
TEST(TestIntCollectionHasMinSizeCalculator,
DoesHaveMinSize_MinSizeAsSidePacket) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TestIntCollectionHasMinSizeCalculator"
input_stream: "ITERABLE:input_vector"
input_side_packet: "min_size"
output_stream: "output_vector"
)");
)pb");
CalculatorRunner runner(node_config);
const std::vector<Packet>& outputs = runner.Outputs().Index(0).packets;
@ -98,14 +98,14 @@ TEST(TestIntCollectionHasMinSizeCalculator,
TEST(TestIntCollectionHasMinSizeCalculator, DoesNotHaveMinSize) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TestIntCollectionHasMinSizeCalculator"
input_stream: "ITERABLE:input_vector"
output_stream: "output_vector"
options {
[mediapipe.CollectionHasMinSizeCalculatorOptions.ext] { min_size: 3 }
}
)");
)pb");
CalculatorRunner runner(node_config);
const std::vector<Packet>& outputs = runner.Outputs().Index(0).packets;
@ -127,12 +127,12 @@ TEST(TestIntCollectionHasMinSizeCalculator, DoesNotHaveMinSize) {
TEST(TestIntCollectionHasMinSizeCalculator,
DoesNotHaveMinSize_MinSizeAsSidePacket) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TestIntCollectionHasMinSizeCalculator"
input_stream: "ITERABLE:input_vector"
input_side_packet: "min_size"
output_stream: "output_vector"
)");
)pb");
CalculatorRunner runner(node_config);
const std::vector<Packet>& outputs = runner.Outputs().Index(0).packets;

View File

@ -94,10 +94,10 @@ TEST(DetectionClassificationsMergerCalculator,
Packet input_detection_packet =
MakePacket<Detection>(input_detection).At(Timestamp(0));
const ClassificationList& classification_list =
ParseTextProtoOrDie<ClassificationList>(R"(
ParseTextProtoOrDie<ClassificationList>(R"pb(
classification { index: 11 score: 0.5 label: "dog" display_name: "Dog" }
classification { index: 12 score: 0.4 label: "fox" display_name: "Fox" }
)");
)pb");
Packet classification_list_packet =
MakePacket<ClassificationList>(classification_list).At(Timestamp(0));
@ -119,7 +119,7 @@ TEST(DetectionClassificationsMergerCalculator,
EXPECT_THAT(output_packets, testing::SizeIs(1));
const Detection& output_detection = output_packets[0].Get<Detection>();
EXPECT_THAT(output_detection,
mediapipe::EqualsProto(ParseTextProtoOrDie<Detection>(R"(
mediapipe::EqualsProto(ParseTextProtoOrDie<Detection>(R"pb(
label: "dog"
label: "fox"
label_id: 11
@ -132,7 +132,7 @@ TEST(DetectionClassificationsMergerCalculator,
}
display_name: "Dog"
display_name: "Fox"
)")));
)pb")));
}
// Checks that merging succeeds when the input ClassificationList doesn't
@ -147,10 +147,10 @@ TEST(DetectionClassificationsMergerCalculator,
Packet input_detection_packet =
MakePacket<Detection>(input_detection).At(Timestamp(0));
const ClassificationList& classification_list =
ParseTextProtoOrDie<ClassificationList>(R"(
ParseTextProtoOrDie<ClassificationList>(R"pb(
classification { index: 11 score: 0.5 }
classification { index: 12 score: 0.4 }
)");
)pb");
Packet classification_list_packet =
MakePacket<ClassificationList>(classification_list).At(Timestamp(0));
@ -172,7 +172,7 @@ TEST(DetectionClassificationsMergerCalculator,
EXPECT_THAT(output_packets, testing::SizeIs(1));
const Detection& output_detection = output_packets[0].Get<Detection>();
EXPECT_THAT(output_detection,
mediapipe::EqualsProto(ParseTextProtoOrDie<Detection>(R"(
mediapipe::EqualsProto(ParseTextProtoOrDie<Detection>(R"pb(
label_id: 11
label_id: 12
score: 0.5
@ -181,7 +181,7 @@ TEST(DetectionClassificationsMergerCalculator,
format: BOUNDING_BOX
bounding_box { xmin: 50 ymin: 60 width: 70 height: 80 }
}
)")));
)pb")));
}
// Checks that merging fails if the input ClassificationList misses mandatory
@ -195,9 +195,9 @@ TEST(DetectionClassificationsMergerCalculator, FailsWithMissingIndex) {
Packet input_detection_packet =
MakePacket<Detection>(input_detection).At(Timestamp(0));
const ClassificationList& classification_list =
ParseTextProtoOrDie<ClassificationList>(R"(
ParseTextProtoOrDie<ClassificationList>(R"pb(
classification { score: 0.5 label: "dog" }
)");
)pb");
Packet classification_list_packet =
MakePacket<ClassificationList>(classification_list).At(Timestamp(0));
@ -227,9 +227,9 @@ TEST(DetectionClassificationsMergerCalculator, FailsWithMissingScore) {
Packet input_detection_packet =
MakePacket<Detection>(input_detection).At(Timestamp(0));
const ClassificationList& classification_list =
ParseTextProtoOrDie<ClassificationList>(R"(
ParseTextProtoOrDie<ClassificationList>(R"pb(
classification { index: 11 label: "dog" }
)");
)pb");
Packet classification_list_packet =
MakePacket<ClassificationList>(classification_list).At(Timestamp(0));
@ -260,10 +260,10 @@ TEST(DetectionClassificationsMergerCalculator,
Packet input_detection_packet =
MakePacket<Detection>(input_detection).At(Timestamp(0));
const ClassificationList& classification_list =
ParseTextProtoOrDie<ClassificationList>(R"(
ParseTextProtoOrDie<ClassificationList>(R"pb(
classification { index: 11 score: 0.5 label: "dog" display_name: "Dog" }
classification { index: 12 score: 0.4 display_name: "Fox" }
)");
)pb");
Packet classification_list_packet =
MakePacket<ClassificationList>(classification_list).At(Timestamp(0));
@ -294,10 +294,10 @@ TEST(DetectionClassificationsMergerCalculator,
Packet input_detection_packet =
MakePacket<Detection>(input_detection).At(Timestamp(0));
const ClassificationList& classification_list =
ParseTextProtoOrDie<ClassificationList>(R"(
ParseTextProtoOrDie<ClassificationList>(R"pb(
classification { index: 11 score: 0.5 label: "dog" }
classification { index: 12 score: 0.4 label: "fox" display_name: "Fox" }
)");
)pb");
Packet classification_list_packet =
MakePacket<ClassificationList>(classification_list).At(Timestamp(0));

View File

@ -57,12 +57,12 @@ Detection CreateDetection(const std::vector<std::string>& labels,
}
CalculatorGraphConfig::Node GetDefaultNode() {
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionLetterboxRemovalCalculator"
input_stream: "DETECTIONS:detections"
input_stream: "LETTERBOX_PADDING:letterbox_padding"
output_stream: "DETECTIONS:adjusted_detections"
)");
)pb");
}
TEST(DetectionLetterboxRemovalCalculatorTest, PaddingLeftRight) {

View File

@ -66,12 +66,12 @@ std::vector<Point2_f> GetPoints(const Detection& detection) {
// Test helper function to run "DetectionProjectionCalculator".
absl::StatusOr<Detection> RunProjectionCalculator(
Detection detection, std::array<float, 16> project_mat) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionProjectionCalculator"
input_stream: "DETECTIONS:detections"
input_stream: "PROJECTION_MATRIX:matrix"
output_stream: "DETECTIONS:projected_detections"
)"));
)pb"));
runner.MutableInputs()
->Tag("DETECTIONS")

View File

@ -84,11 +84,11 @@ Detection DetectionWithRelativeLocationData(double xmin, double ymin,
}
TEST(DetectionsToRectsCalculatorTest, DetectionToRect) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTION:detection"
output_stream: "RECT:rect"
)"));
)pb"));
auto detection = absl::make_unique<Detection>(
DetectionWithLocationData(100, 200, 300, 400));
@ -107,7 +107,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionToRect) {
absl::StatusOr<Rect> RunDetectionKeyPointsToRectCalculation(
Detection detection, std::pair<int, int> image_size) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTION:detection"
input_stream: "IMAGE_SIZE:image_size"
@ -117,7 +117,7 @@ absl::StatusOr<Rect> RunDetectionKeyPointsToRectCalculation(
conversion_mode: USE_KEYPOINTS
}
}
)"));
)pb"));
runner.MutableInputs()
->Tag("DETECTION")
@ -160,11 +160,11 @@ TEST(DetectionsToRectsCalculatorTest, DetectionKeyPointsToRect) {
}
TEST(DetectionsToRectsCalculatorTest, DetectionToNormalizedRect) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTION:detection"
output_stream: "NORM_RECT:rect"
)"));
)pb"));
auto detection = absl::make_unique<Detection>(
DetectionWithRelativeLocationData(0.1, 0.2, 0.3, 0.4));
@ -183,7 +183,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionToNormalizedRect) {
absl::StatusOr<NormalizedRect> RunDetectionKeyPointsToNormRectCalculation(
Detection detection) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTION:detection"
output_stream: "NORM_RECT:rect"
@ -192,7 +192,7 @@ absl::StatusOr<NormalizedRect> RunDetectionKeyPointsToNormRectCalculation(
conversion_mode: USE_KEYPOINTS
}
}
)"));
)pb"));
runner.MutableInputs()
->Tag("DETECTION")
@ -231,11 +231,11 @@ TEST(DetectionsToRectsCalculatorTest, DetectionKeyPointsToNormalizedRect) {
}
TEST(DetectionsToRectsCalculatorTest, DetectionsToRect) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTIONS:detections"
output_stream: "RECT:rect"
)"));
)pb"));
auto detections(absl::make_unique<std::vector<Detection>>());
detections->push_back(DetectionWithLocationData(100, 200, 300, 400));
@ -254,11 +254,11 @@ TEST(DetectionsToRectsCalculatorTest, DetectionsToRect) {
}
TEST(DetectionsToRectsCalculatorTest, DetectionsToNormalizedRect) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTIONS:detections"
output_stream: "NORM_RECT:rect"
)"));
)pb"));
auto detections(absl::make_unique<std::vector<Detection>>());
detections->push_back(DetectionWithRelativeLocationData(0.1, 0.2, 0.3, 0.4));
@ -277,11 +277,11 @@ TEST(DetectionsToRectsCalculatorTest, DetectionsToNormalizedRect) {
}
TEST(DetectionsToRectsCalculatorTest, DetectionsToRects) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTIONS:detections"
output_stream: "RECTS:rect"
)"));
)pb"));
auto detections(absl::make_unique<std::vector<Detection>>());
detections->push_back(DetectionWithLocationData(100, 200, 300, 400));
@ -302,11 +302,11 @@ TEST(DetectionsToRectsCalculatorTest, DetectionsToRects) {
}
TEST(DetectionsToRectsCalculatorTest, DetectionsToNormalizedRects) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTIONS:detections"
output_stream: "NORM_RECTS:rect"
)"));
)pb"));
auto detections(absl::make_unique<std::vector<Detection>>());
detections->push_back(DetectionWithRelativeLocationData(0.1, 0.2, 0.3, 0.4));
@ -328,11 +328,11 @@ TEST(DetectionsToRectsCalculatorTest, DetectionsToNormalizedRects) {
}
TEST(DetectionsToRectsCalculatorTest, DetectionToRects) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTION:detection"
output_stream: "RECTS:rect"
)"));
)pb"));
auto detection = absl::make_unique<Detection>(
DetectionWithLocationData(100, 200, 300, 400));
@ -351,11 +351,11 @@ TEST(DetectionsToRectsCalculatorTest, DetectionToRects) {
}
TEST(DetectionsToRectsCalculatorTest, DetectionToNormalizedRects) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTION:detection"
output_stream: "NORM_RECTS:rect"
)"));
)pb"));
auto detection = absl::make_unique<Detection>(
DetectionWithRelativeLocationData(0.1, 0.2, 0.3, 0.4));
@ -375,11 +375,11 @@ TEST(DetectionsToRectsCalculatorTest, DetectionToNormalizedRects) {
}
TEST(DetectionsToRectsCalculatorTest, WrongInputToRect) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTIONS:detections"
output_stream: "RECT:rect"
)"));
)pb"));
auto detections(absl::make_unique<std::vector<Detection>>());
detections->push_back(DetectionWithRelativeLocationData(0.1, 0.2, 0.3, 0.4));
@ -395,11 +395,11 @@ TEST(DetectionsToRectsCalculatorTest, WrongInputToRect) {
}
TEST(DetectionsToRectsCalculatorTest, WrongInputToNormalizedRect) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRectsCalculator"
input_stream: "DETECTIONS:detections"
output_stream: "NORM_RECT:rect"
)"));
)pb"));
auto detections(absl::make_unique<std::vector<Detection>>());
detections->push_back(DetectionWithLocationData(100, 200, 300, 400));

View File

@ -85,11 +85,11 @@ Detection CreateDetection(const std::vector<std::string>& labels,
}
TEST(DetectionsToRenderDataCalculatorTest, OnlyDetecctionList) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRenderDataCalculator"
input_stream: "DETECTION_LIST:detection_list"
output_stream: "RENDER_DATA:render_data"
)"));
)pb"));
LocationData location_data = CreateLocationData(100, 200, 300, 400);
auto detections(absl::make_unique<DetectionList>());
@ -119,11 +119,11 @@ TEST(DetectionsToRenderDataCalculatorTest, OnlyDetecctionList) {
}
TEST(DetectionsToRenderDataCalculatorTest, OnlyDetecctionVector) {
CalculatorRunner runner{ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner{ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRenderDataCalculator"
input_stream: "DETECTIONS:detections"
output_stream: "RENDER_DATA:render_data"
)")};
)pb")};
LocationData location_data = CreateLocationData(100, 200, 300, 400);
auto detections(absl::make_unique<std::vector<Detection>>());
@ -153,12 +153,12 @@ TEST(DetectionsToRenderDataCalculatorTest, OnlyDetecctionVector) {
}
TEST(DetectionsToRenderDataCalculatorTest, BothDetecctionListAndVector) {
CalculatorRunner runner{ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner{ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRenderDataCalculator"
input_stream: "DETECTION_LIST:detection_list"
input_stream: "DETECTIONS:detections"
output_stream: "RENDER_DATA:render_data"
)")};
)pb")};
LocationData location_data1 = CreateLocationData(100, 200, 300, 400);
auto detection_list(absl::make_unique<DetectionList>());
@ -194,7 +194,8 @@ TEST(DetectionsToRenderDataCalculatorTest, BothDetecctionListAndVector) {
TEST(DetectionsToRenderDataCalculatorTest, ProduceEmptyPacket) {
// Check when produce_empty_packet is false.
CalculatorRunner runner1{ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner1{
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRenderDataCalculator"
input_stream: "DETECTION_LIST:detection_list"
input_stream: "DETECTIONS:detections"
@ -204,7 +205,7 @@ TEST(DetectionsToRenderDataCalculatorTest, ProduceEmptyPacket) {
produce_empty_packet: false
}
}
)")};
)pb")};
auto detection_list1(absl::make_unique<DetectionList>());
runner1.MutableInputs()
@ -224,7 +225,8 @@ TEST(DetectionsToRenderDataCalculatorTest, ProduceEmptyPacket) {
ASSERT_EQ(0, exact1.size());
// Check when produce_empty_packet is true.
CalculatorRunner runner2{ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner2{
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "DetectionsToRenderDataCalculator"
input_stream: "DETECTION_LIST:detection_list"
input_stream: "DETECTIONS:detections"
@ -234,7 +236,7 @@ TEST(DetectionsToRenderDataCalculatorTest, ProduceEmptyPacket) {
produce_empty_packet: true
}
}
)")};
)pb")};
auto detection_list2(absl::make_unique<DetectionList>());
runner2.MutableInputs()

View File

@ -32,12 +32,12 @@ NormalizedLandmark CreateLandmark(float x, float y) {
}
CalculatorGraphConfig::Node GetDefaultNode() {
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "LandmarkLetterboxRemovalCalculator"
input_stream: "LANDMARKS:landmarks"
input_stream: "LETTERBOX_PADDING:letterbox_padding"
output_stream: "LANDMARKS:adjusted_landmarks"
)");
)pb");
}
TEST(LandmarkLetterboxRemovalCalculatorTest, PaddingLeftRight) {

View File

@ -24,7 +24,7 @@ namespace mediapipe {
namespace {
CalculatorGraphConfig::Node GetDefaultNode() {
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "PacketFrequencyCalculator"
input_stream: "packet_stream"
output_stream: "packet_frequency"
@ -34,11 +34,11 @@ CalculatorGraphConfig::Node GetDefaultNode() {
label: "stream_description"
}
}
)");
)pb");
}
CalculatorGraphConfig::Node GetNodeWithMultipleStreams() {
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
return ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "PacketFrequencyCalculator"
input_stream: "packet_stream_0"
input_stream: "packet_stream_1"
@ -55,7 +55,7 @@ CalculatorGraphConfig::Node GetNodeWithMultipleStreams() {
label: "stream_description_2"
}
}
)");
)pb");
}
// Tests packet frequency.

View File

@ -38,7 +38,7 @@ class PacketLatencyCalculatorTest : public ::testing::Test {
}
void InitializeSingleStreamGraph() {
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "delayed_packet_0"
input_stream: "camera_frames"
node {
@ -59,7 +59,7 @@ class PacketLatencyCalculatorTest : public ::testing::Test {
input_stream_handler: "ImmediateInputStreamHandler"
}
}
)");
)pb");
mediapipe::tool::AddVectorSink("packet_latency_0", &graph_config_,
&out_0_packets_);
@ -79,7 +79,7 @@ class PacketLatencyCalculatorTest : public ::testing::Test {
}
void InitializeMultipleStreamGraph() {
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "delayed_packet_0"
input_stream: "delayed_packet_1"
input_stream: "delayed_packet_2"
@ -107,7 +107,7 @@ class PacketLatencyCalculatorTest : public ::testing::Test {
input_stream_handler: "ImmediateInputStreamHandler"
}
}
)");
)pb");
mediapipe::tool::AddVectorSink("packet_latency_0", &graph_config_,
&out_0_packets_);
@ -131,7 +131,7 @@ class PacketLatencyCalculatorTest : public ::testing::Test {
}
void InitializeSingleStreamGraphWithoutClock() {
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "delayed_packet_0"
input_stream: "camera_frames"
node {
@ -150,7 +150,7 @@ class PacketLatencyCalculatorTest : public ::testing::Test {
input_stream_handler: "ImmediateInputStreamHandler"
}
}
)");
)pb");
mediapipe::tool::AddVectorSink("packet_latency_0", &graph_config_,
&out_0_packets_);

View File

@ -24,7 +24,7 @@
namespace mediapipe {
TEST(TopKScoresCalculatorTest, TestNodeConfig) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TopKScoresCalculator"
input_stream: "SCORES:score_vector"
output_stream: "TOP_K_INDEXES:top_k_indexes"
@ -32,7 +32,7 @@ TEST(TopKScoresCalculatorTest, TestNodeConfig) {
options: {
[mediapipe.TopKScoresCalculatorOptions.ext] {}
}
)"));
)pb"));
auto status = runner.Run();
ASSERT_TRUE(!status.ok());
@ -43,7 +43,7 @@ TEST(TopKScoresCalculatorTest, TestNodeConfig) {
}
TEST(TopKScoresCalculatorTest, TestTopKOnly) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TopKScoresCalculator"
input_stream: "SCORES:score_vector"
output_stream: "TOP_K_INDEXES:top_k_indexes"
@ -51,7 +51,7 @@ TEST(TopKScoresCalculatorTest, TestTopKOnly) {
options: {
[mediapipe.TopKScoresCalculatorOptions.ext] { top_k: 2 }
}
)"));
)pb"));
std::vector<float> score_vector{0.9, 0.2, 0.3, 1.0, 0.1};
@ -76,7 +76,7 @@ TEST(TopKScoresCalculatorTest, TestTopKOnly) {
}
TEST(TopKScoresCalculatorTest, TestThresholdOnly) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TopKScoresCalculator"
input_stream: "SCORES:score_vector"
output_stream: "TOP_K_INDEXES:top_k_indexes"
@ -84,7 +84,7 @@ TEST(TopKScoresCalculatorTest, TestThresholdOnly) {
options: {
[mediapipe.TopKScoresCalculatorOptions.ext] { threshold: 0.2 }
}
)"));
)pb"));
std::vector<float> score_vector{0.9, 0.2, 0.3, 1.0, 0.1};
@ -113,7 +113,7 @@ TEST(TopKScoresCalculatorTest, TestThresholdOnly) {
}
TEST(TopKScoresCalculatorTest, TestBothTopKAndThreshold) {
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
CalculatorRunner runner(ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TopKScoresCalculator"
input_stream: "SCORES:score_vector"
output_stream: "TOP_K_INDEXES:top_k_indexes"
@ -121,7 +121,7 @@ TEST(TopKScoresCalculatorTest, TestBothTopKAndThreshold) {
options: {
[mediapipe.TopKScoresCalculatorOptions.ext] { top_k: 4 threshold: 0.3 }
}
)"));
)pb"));
std::vector<float> score_vector{0.9, 0.2, 0.3, 1.0, 0.1};

View File

@ -31,11 +31,11 @@ namespace {
TEST(OpenCvVideoDecoderCalculatorTest, TestMp4Avc720pVideo) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "OpenCvVideoDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
output_stream: "VIDEO:video"
output_stream: "VIDEO_PRESTREAM:video_prestream")");
output_stream: "VIDEO_PRESTREAM:video_prestream")pb");
CalculatorRunner runner(node_config);
runner.MutableSidePackets()->Tag("INPUT_FILE_PATH") = MakePacket<std::string>(
file::JoinPath("./",
@ -77,11 +77,11 @@ TEST(OpenCvVideoDecoderCalculatorTest, TestMp4Avc720pVideo) {
TEST(OpenCvVideoDecoderCalculatorTest, TestFlvH264Video) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "OpenCvVideoDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
output_stream: "VIDEO:video"
output_stream: "VIDEO_PRESTREAM:video_prestream")");
output_stream: "VIDEO_PRESTREAM:video_prestream")pb");
CalculatorRunner runner(node_config);
runner.MutableSidePackets()->Tag("INPUT_FILE_PATH") = MakePacket<std::string>(
file::JoinPath("./",
@ -121,11 +121,11 @@ TEST(OpenCvVideoDecoderCalculatorTest, TestFlvH264Video) {
TEST(OpenCvVideoDecoderCalculatorTest, TestMkvVp8Video) {
CalculatorGraphConfig::Node node_config =
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "OpenCvVideoDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
output_stream: "VIDEO:video"
output_stream: "VIDEO_PRESTREAM:video_prestream")");
output_stream: "VIDEO_PRESTREAM:video_prestream")pb");
CalculatorRunner runner(node_config);
runner.MutableSidePackets()->Tag("INPUT_FILE_PATH") = MakePacket<std::string>(
file::JoinPath("./",

View File

@ -36,7 +36,8 @@ namespace {
// TODO: Investigate the “Could not open codec 'libx264'” error with
// opencv2.
TEST(OpenCvVideoEncoderCalculatorTest, DISABLED_TestMp4Avc720pVideo) {
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
CalculatorGraphConfig config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "OpenCvVideoDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
@ -49,13 +50,14 @@ TEST(OpenCvVideoEncoderCalculatorTest, DISABLED_TestMp4Avc720pVideo) {
input_stream: "VIDEO_PRESTREAM:video_prestream"
input_side_packet: "OUTPUT_FILE_PATH:output_file_path"
node_options {
[type.googleapis.com/mediapipe.OpenCvVideoEncoderCalculatorOptions]: {
[type.googleapis.com/
mediapipe.OpenCvVideoEncoderCalculatorOptions]: {
codec: "avc1"
video_format: "mp4"
}
}
}
)");
)pb");
std::map<std::string, Packet> input_side_packets;
input_side_packets["input_file_path"] = MakePacket<std::string>(
file::JoinPath("./",
@ -95,7 +97,8 @@ TEST(OpenCvVideoEncoderCalculatorTest, DISABLED_TestMp4Avc720pVideo) {
}
TEST(OpenCvVideoEncoderCalculatorTest, TestFlvH264Video) {
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
CalculatorGraphConfig config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "OpenCvVideoDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
@ -108,13 +111,14 @@ TEST(OpenCvVideoEncoderCalculatorTest, TestFlvH264Video) {
input_stream: "VIDEO_PRESTREAM:video_prestream"
input_side_packet: "OUTPUT_FILE_PATH:output_file_path"
node_options {
[type.googleapis.com/mediapipe.OpenCvVideoEncoderCalculatorOptions]: {
[type.googleapis.com/
mediapipe.OpenCvVideoEncoderCalculatorOptions]: {
codec: "MJPG"
video_format: "avi"
}
}
}
)");
)pb");
std::map<std::string, Packet> input_side_packets;
input_side_packets["input_file_path"] = MakePacket<std::string>(
file::JoinPath("./",
@ -156,7 +160,8 @@ TEST(OpenCvVideoEncoderCalculatorTest, TestFlvH264Video) {
}
TEST(OpenCvVideoEncoderCalculatorTest, TestMkvVp8Video) {
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
CalculatorGraphConfig config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "OpenCvVideoDecoderCalculator"
input_side_packet: "INPUT_FILE_PATH:input_file_path"
@ -169,13 +174,14 @@ TEST(OpenCvVideoEncoderCalculatorTest, TestMkvVp8Video) {
input_stream: "VIDEO_PRESTREAM:video_prestream"
input_side_packet: "OUTPUT_FILE_PATH:output_file_path"
node_options {
[type.googleapis.com/mediapipe.OpenCvVideoEncoderCalculatorOptions]: {
[type.googleapis.com/
mediapipe.OpenCvVideoEncoderCalculatorOptions]: {
codec: "PIM1"
video_format: "mkv"
}
}
}
)");
)pb");
std::map<std::string, Packet> input_side_packets;
input_side_packets["input_file_path"] = MakePacket<std::string>(
file::JoinPath("./",

View File

@ -25,7 +25,7 @@ namespace mediapipe {
namespace {
TEST(VideoPreStreamCalculatorTest, ProcessesWithFrameRateInOptions) {
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input"
node {
calculator: "VideoPreStreamCalculator"
@ -34,7 +34,7 @@ TEST(VideoPreStreamCalculatorTest, ProcessesWithFrameRateInOptions) {
options {
[mediapipe.VideoPreStreamCalculatorOptions.ext] { fps { value: 3 } }
}
})");
})pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
auto poller_status = graph.AddOutputStreamPoller("output");
@ -66,7 +66,7 @@ TEST(VideoPreStreamCalculatorTest, ProcessesWithFrameRateInOptions) {
}
TEST(VideoPreStreamCalculatorTest, ProcessesWithFrameRateInPreStream) {
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "frame"
input_stream: "input_header"
node {
@ -74,7 +74,7 @@ TEST(VideoPreStreamCalculatorTest, ProcessesWithFrameRateInPreStream) {
input_stream: "FRAME:frame"
input_stream: "VIDEO_PRESTREAM:input_header"
output_stream: "output_header"
})");
})pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
auto poller_status = graph.AddOutputStreamPoller("output_header");
@ -104,13 +104,13 @@ TEST(VideoPreStreamCalculatorTest, ProcessesWithFrameRateInPreStream) {
}
TEST(VideoPreStreamCalculatorTest, FailsWithoutFrameRateInOptions) {
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "frame"
node {
calculator: "VideoPreStreamCalculator"
input_stream: "frame"
output_stream: "output_header"
})");
})pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.StartRun({}));
@ -126,7 +126,7 @@ TEST(VideoPreStreamCalculatorTest, FailsWithoutFrameRateInOptions) {
// Input header missing.
TEST(VideoPreStreamCalculatorTest, FailsWithoutFrameRateInPreStream1) {
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "frame"
input_stream: "input_header"
node {
@ -135,7 +135,7 @@ TEST(VideoPreStreamCalculatorTest, FailsWithoutFrameRateInPreStream1) {
input_stream: "VIDEO_PRESTREAM:input_header"
output_stream: "output_header"
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.StartRun({}));
@ -152,7 +152,7 @@ TEST(VideoPreStreamCalculatorTest, FailsWithoutFrameRateInPreStream1) {
// Input header not at prestream (before, with, and after frame data).
TEST(VideoPreStreamCalculatorTest, FailsWithoutFrameRateInPreStream2) {
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "frame"
input_stream: "input_header"
node {
@ -161,7 +161,7 @@ TEST(VideoPreStreamCalculatorTest, FailsWithoutFrameRateInPreStream2) {
input_stream: "VIDEO_PRESTREAM:input_header"
output_stream: "output_header"
}
)");
)pb");
for (int64 timestamp = -1; timestamp < 2; ++timestamp) {
CalculatorGraph graph;

View File

@ -111,7 +111,7 @@ TEST(SignalFusingCalculatorTest, TwoInputNoTracking) {
auto input_face =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.5
signal_type: { standard: FACE_FULL }
@ -120,14 +120,14 @@ TEST(SignalFusingCalculatorTest, TwoInputNoTracking) {
score: 0.3
signal_type: { standard: FACE_FULL }
}
)"));
)pb"));
runner->MutableInputs()->Index(1).packets.push_back(
Adopt(input_face.release()).At(Timestamp(0)));
auto input_ocr =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.3
signal_type: { standard: TEXT }
@ -136,7 +136,7 @@ TEST(SignalFusingCalculatorTest, TwoInputNoTracking) {
score: 0.9
signal_type: { standard: TEXT }
}
)"));
)pb"));
runner->MutableInputs()->Index(2).packets.push_back(
Adopt(input_ocr.release()).At(Timestamp(0)));
@ -165,7 +165,7 @@ TEST(SignalFusingCalculatorTest, TwoInputShotLabeledTags) {
auto input_face =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.5
signal_type: { standard: FACE_FULL }
@ -174,7 +174,7 @@ TEST(SignalFusingCalculatorTest, TwoInputShotLabeledTags) {
score: 0.3
signal_type: { standard: FACE_FULL }
}
)"));
)pb"));
runner->MutableInputs()
->Get("SIGNAL", 0)
@ -182,7 +182,7 @@ TEST(SignalFusingCalculatorTest, TwoInputShotLabeledTags) {
auto input_ocr =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.3
signal_type: { standard: TEXT }
@ -191,7 +191,7 @@ TEST(SignalFusingCalculatorTest, TwoInputShotLabeledTags) {
score: 0.9
signal_type: { standard: TEXT }
}
)"));
)pb"));
runner->MutableInputs()
->Get("SIGNAL", 1)
@ -216,7 +216,7 @@ TEST(SignalFusingCalculatorTest, TwoInputNoShotLabeledTags) {
auto input_face =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.5
signal_type: { standard: FACE_FULL }
@ -225,7 +225,7 @@ TEST(SignalFusingCalculatorTest, TwoInputNoShotLabeledTags) {
score: 0.3
signal_type: { standard: FACE_FULL }
}
)"));
)pb"));
runner->MutableInputs()
->Get("SIGNAL", 0)
@ -233,7 +233,7 @@ TEST(SignalFusingCalculatorTest, TwoInputNoShotLabeledTags) {
auto input_ocr =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.3
signal_type: { standard: TEXT }
@ -242,7 +242,7 @@ TEST(SignalFusingCalculatorTest, TwoInputNoShotLabeledTags) {
score: 0.9
signal_type: { standard: TEXT }
}
)"));
)pb"));
runner->MutableInputs()
->Get("SIGNAL", 1)
@ -272,7 +272,7 @@ TEST(SignalFusingCalculatorTest, ThreeInputTracking) {
// Time zero.
auto input_face_0 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.2
signal_type: { standard: FACE_FULL }
@ -287,32 +287,32 @@ TEST(SignalFusingCalculatorTest, ThreeInputTracking) {
score: 0.1
signal_type: { standard: FACE_FULL }
}
)"));
)pb"));
runner->MutableInputs()->Index(1).packets.push_back(
Adopt(input_face_0.release()).At(Timestamp(0)));
auto input_ocr_0 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.2
signal_type: { custom: "text" }
}
)"));
)pb"));
runner->MutableInputs()->Index(2).packets.push_back(
Adopt(input_ocr_0.release()).At(Timestamp(0)));
auto input_agn_0 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.3
signal_type: { standard: LOGO }
tracking_id: 0
}
)"));
)pb"));
runner->MutableInputs()->Index(3).packets.push_back(
Adopt(input_agn_0.release()).At(Timestamp(0)));
@ -324,7 +324,7 @@ TEST(SignalFusingCalculatorTest, ThreeInputTracking) {
auto input_face_1 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.7
signal_type: { standard: FACE_FULL }
@ -339,32 +339,32 @@ TEST(SignalFusingCalculatorTest, ThreeInputTracking) {
score: 0.2
signal_type: { standard: FACE_FULL }
}
)"));
)pb"));
runner->MutableInputs()->Index(1).packets.push_back(
Adopt(input_face_1.release()).At(Timestamp(1)));
auto input_ocr_1 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.3
signal_type: { custom: "text" }
}
)"));
)pb"));
runner->MutableInputs()->Index(2).packets.push_back(
Adopt(input_ocr_1.release()).At(Timestamp(1)));
auto input_agn_1 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.3
signal_type: { standard: LOGO }
tracking_id: 0
}
)"));
)pb"));
runner->MutableInputs()->Index(3).packets.push_back(
Adopt(input_agn_1.release()).At(Timestamp(1)));
@ -376,7 +376,7 @@ TEST(SignalFusingCalculatorTest, ThreeInputTracking) {
auto input_face_2 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.8
signal_type: { standard: FACE_FULL }
@ -391,32 +391,32 @@ TEST(SignalFusingCalculatorTest, ThreeInputTracking) {
score: 0.3
signal_type: { standard: FACE_FULL }
}
)"));
)pb"));
runner->MutableInputs()->Index(1).packets.push_back(
Adopt(input_face_2.release()).At(Timestamp(2)));
auto input_ocr_2 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.3
signal_type: { custom: "text" }
}
)"));
)pb"));
runner->MutableInputs()->Index(2).packets.push_back(
Adopt(input_ocr_2.release()).At(Timestamp(2)));
auto input_agn_2 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.9
signal_type: { standard: LOGO }
tracking_id: 0
}
)"));
)pb"));
runner->MutableInputs()->Index(3).packets.push_back(
Adopt(input_agn_2.release()).At(Timestamp(2)));
@ -428,7 +428,7 @@ TEST(SignalFusingCalculatorTest, ThreeInputTracking) {
auto input_face_3 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.2
signal_type: { standard: FACE_FULL }
@ -443,32 +443,32 @@ TEST(SignalFusingCalculatorTest, ThreeInputTracking) {
score: 0.4
signal_type: { standard: FACE_FULL }
}
)"));
)pb"));
runner->MutableInputs()->Index(1).packets.push_back(
Adopt(input_face_3.release()).At(Timestamp(3)));
auto input_ocr_3 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.5
signal_type: { custom: "text" }
}
)"));
)pb"));
runner->MutableInputs()->Index(2).packets.push_back(
Adopt(input_ocr_3.release()).At(Timestamp(3)));
auto input_agn_3 =
absl::make_unique<DetectionSet>(ParseTextProtoOrDie<DetectionSet>(
R"(
R"pb(
detections {
score: 0.6
signal_type: { standard: LOGO }
tracking_id: 0
}
)"));
)pb"));
runner->MutableInputs()->Index(3).packets.push_back(
Adopt(input_agn_3.release()).At(Timestamp(3)));

View File

@ -27,10 +27,10 @@ namespace {
TEST(VisualScorerTest, ScoresArea) {
cv::Mat image_mat(200, 200, CV_8UC3);
SalientRegion region = ParseTextProtoOrDie<SalientRegion>(
R"(location { x: 10 y: 10 width: 100 height: 100 })");
R"pb(location { x: 10 y: 10 width: 100 height: 100 })pb");
VisualScorerOptions options = ParseTextProtoOrDie<VisualScorerOptions>(
R"(area_weight: 1.0 sharpness_weight: 0 colorfulness_weight: 0)");
R"pb(area_weight: 1.0 sharpness_weight: 0 colorfulness_weight: 0)pb");
VisualScorer scorer(options);
float score = 0.0;
MP_EXPECT_OK(scorer.CalculateScore(image_mat, region, &score));
@ -39,10 +39,10 @@ TEST(VisualScorerTest, ScoresArea) {
TEST(VisualScorerTest, ScoresSharpness) {
SalientRegion region = ParseTextProtoOrDie<SalientRegion>(
R"(location { x: 10 y: 10 width: 100 height: 100 })");
R"pb(location { x: 10 y: 10 width: 100 height: 100 })pb");
VisualScorerOptions options = ParseTextProtoOrDie<VisualScorerOptions>(
R"(area_weight: 0 sharpness_weight: 1.0 colorfulness_weight: 0)");
R"pb(area_weight: 0 sharpness_weight: 1.0 colorfulness_weight: 0)pb");
VisualScorer scorer(options);
// Compute the score of an empty image and an image with a rectangle.
@ -55,10 +55,10 @@ TEST(VisualScorerTest, ScoresSharpness) {
TEST(VisualScorerTest, ScoresColorfulness) {
SalientRegion region = ParseTextProtoOrDie<SalientRegion>(
R"(location { x: 10 y: 10 width: 50 height: 150 })");
R"pb(location { x: 10 y: 10 width: 50 height: 150 })pb");
VisualScorerOptions options = ParseTextProtoOrDie<VisualScorerOptions>(
R"(area_weight: 0 sharpness_weight: 0 colorfulness_weight: 1.0)");
R"pb(area_weight: 0 sharpness_weight: 0 colorfulness_weight: 1.0)pb");
VisualScorer scorer(options);
// Compute the scores of images with 1, 2 and 3 colors.

View File

@ -23,7 +23,8 @@ namespace mediapipe {
absl::Status PrintHelloWorld() {
// Configures a simple graph, which concatenates 2 PassThroughCalculators.
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
CalculatorGraphConfig config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in"
output_stream: "out"
node {
@ -36,7 +37,7 @@ absl::Status PrintHelloWorld() {
input_stream: "out1"
output_stream: "out"
}
)");
)pb");
CalculatorGraph graph;
MP_RETURN_IF_ERROR(graph.Initialize(config));

View File

@ -27,7 +27,7 @@ TEST(BuilderTest, BuildGraph) {
bar.Out("OUT").SetName("out") >> graph.Out("OUT");
CalculatorGraphConfig expected =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "IN:base"
input_side_packet: "SIDE:side"
output_stream: "OUT:out"
@ -42,7 +42,7 @@ TEST(BuilderTest, BuildGraph) {
input_stream: "IN:__stream_0"
output_stream: "OUT:out"
}
)");
)pb");
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
}
@ -92,7 +92,7 @@ TEST(BuilderTest, FanOut) {
adder.Out("OUT").SetName("out") >> graph.Out("OUT");
CalculatorGraphConfig expected =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "IN:base"
output_stream: "OUT:out"
node {
@ -106,7 +106,7 @@ TEST(BuilderTest, FanOut) {
input_stream: "IN:1:__stream_0"
output_stream: "OUT:out"
}
)");
)pb");
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
}
@ -120,7 +120,7 @@ TEST(BuilderTest, TypedMultiple) {
adder.Out(MPP_TAG("OUT")).SetName("out") >> graph.Out("OUT");
CalculatorGraphConfig expected =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "IN:base"
output_stream: "OUT:out"
node {
@ -134,7 +134,7 @@ TEST(BuilderTest, TypedMultiple) {
input_stream: "IN:1:__stream_0"
output_stream: "OUT:out"
}
)");
)pb");
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
}
@ -145,7 +145,7 @@ TEST(BuilderTest, PacketGenerator) {
generator.SideOut("OUT") >> graph.SideOut("OUT");
CalculatorGraphConfig expected =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_side_packet: "IN:__side_packet_0"
output_side_packet: "OUT:__side_packet_1"
packet_generator {
@ -153,7 +153,7 @@ TEST(BuilderTest, PacketGenerator) {
input_side_packet: "IN:__side_packet_0"
output_side_packet: "OUT:__side_packet_1"
}
)");
)pb");
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
}
@ -167,7 +167,7 @@ TEST(BuilderTest, EmptyTag) {
foo.Out("")[1].SetName("y") >> graph.Out("TWO");
CalculatorGraphConfig expected =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "A:a"
input_stream: "B:b"
input_stream: "C:c"
@ -181,7 +181,7 @@ TEST(BuilderTest, EmptyTag) {
output_stream: "x"
output_stream: "y"
}
)");
)pb");
EXPECT_THAT(graph.GetConfig(), EqualsProto(expected));
}

View File

@ -132,12 +132,12 @@ TEST(NodeTest, GetContract) {
// with what you have in the graph, then you let the calculator fill it in
// with what it expects, and then you see if they match.
const CalculatorGraphConfig::Node node_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "Foo"
input_stream: "BASE:base"
input_stream: "SCALE:scale"
output_stream: "OUT:out"
)");
)pb");
mediapipe::CalculatorContract contract;
MP_EXPECT_OK(contract.Initialize(node_config));
MP_EXPECT_OK(Foo::Contract::GetContract(&contract));
@ -147,13 +147,13 @@ TEST(NodeTest, GetContract) {
TEST(NodeTest, GetContractMulti) {
const CalculatorGraphConfig::Node node_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "Baz"
input_stream: "DATA:0:b"
input_stream: "DATA:1:c"
output_stream: "DATA:0:d"
output_stream: "DATA:1:e"
)");
)pb");
mediapipe::CalculatorContract contract;
MP_EXPECT_OK(contract.Initialize(node_config));
MP_EXPECT_OK(Baz::Contract::GetContract(&contract));
@ -204,7 +204,7 @@ TEST(NodeTest, RunInGraph5) { RunFooCalculatorInGraph("Foo5"); }
TEST(NodeTest, OptionalStream) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "base"
input_side_packet: "bias"
output_stream: "out"
@ -214,7 +214,7 @@ TEST(NodeTest, OptionalStream) {
input_side_packet: "BIAS:bias"
output_stream: "OUT:out"
}
)");
)pb");
std::vector<mediapipe::Packet> out_packets;
tool::AddVectorSink("out", &config, &out_packets);
mediapipe::CalculatorGraph graph;
@ -229,7 +229,7 @@ TEST(NodeTest, OptionalStream) {
TEST(NodeTest, DynamicTypes) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in"
output_stream: "out"
node {
@ -242,7 +242,7 @@ TEST(NodeTest, DynamicTypes) {
input_stream: "IN:bar"
output_stream: "OUT:out"
}
)");
)pb");
std::vector<mediapipe::Packet> out_packets;
tool::AddVectorSink("out", &config, &out_packets);
mediapipe::CalculatorGraph graph;
@ -257,7 +257,7 @@ TEST(NodeTest, DynamicTypes) {
TEST(NodeTest, MultiPort) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in0"
input_stream: "in1"
output_stream: "out0"
@ -279,7 +279,7 @@ TEST(NodeTest, MultiPort) {
input_stream: "IN:baz1"
output_stream: "OUT:out1"
}
)");
)pb");
std::vector<mediapipe::Packet> out0_packets;
std::vector<mediapipe::Packet> out1_packets;
tool::AddVectorSink("out0", &config, &out0_packets);
@ -325,7 +325,7 @@ MEDIAPIPE_REGISTER_NODE(SideFallback);
TEST(NodeTest, SideFallbackWithStream) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in"
input_stream: "factor"
output_stream: "out"
@ -335,7 +335,7 @@ TEST(NodeTest, SideFallbackWithStream) {
input_stream: "FACTOR:factor"
output_stream: "OUT:out"
}
)");
)pb");
std::vector<int> outputs;
mediapipe::CalculatorGraph graph;
MP_EXPECT_OK(graph.Initialize(config, {}));
@ -356,7 +356,7 @@ TEST(NodeTest, SideFallbackWithStream) {
TEST(NodeTest, SideFallbackWithSide) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in"
input_side_packet: "factor"
output_stream: "out"
@ -366,7 +366,7 @@ TEST(NodeTest, SideFallbackWithSide) {
input_side_packet: "FACTOR:factor"
output_stream: "OUT:out"
}
)");
)pb");
std::vector<int> outputs;
mediapipe::CalculatorGraph graph;
MP_EXPECT_OK(graph.Initialize(config, {}));
@ -385,7 +385,7 @@ TEST(NodeTest, SideFallbackWithSide) {
TEST(NodeTest, SideFallbackWithNone) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in"
output_stream: "out"
node {
@ -393,7 +393,7 @@ TEST(NodeTest, SideFallbackWithNone) {
input_stream: "IN:in"
output_stream: "OUT:out"
}
)");
)pb");
std::vector<int> outputs;
mediapipe::CalculatorGraph graph;
auto status = graph.Initialize(config, {});
@ -402,7 +402,7 @@ TEST(NodeTest, SideFallbackWithNone) {
TEST(NodeTest, SideFallbackWithBoth) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in"
input_stream: "factor"
input_side_packet: "factor_side"
@ -414,7 +414,7 @@ TEST(NodeTest, SideFallbackWithBoth) {
input_side_packet: "FACTOR:factor_side"
output_stream: "OUT:out"
}
)");
)pb");
std::vector<int> outputs;
mediapipe::CalculatorGraph graph;
auto status = graph.Initialize(config, {});
@ -423,7 +423,7 @@ TEST(NodeTest, SideFallbackWithBoth) {
TEST(NodeTest, OneOf) {
CalculatorGraphConfig config =
::mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
::mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in"
output_stream: "out"
node {
@ -431,7 +431,7 @@ TEST(NodeTest, OneOf) {
input_stream: "IN:in"
output_stream: "OUT:out"
}
)");
)pb");
std::vector<mediapipe::Packet> out_packets;
tool::AddVectorSink("out", &config, &out_packets);
mediapipe::CalculatorGraph graph;
@ -484,7 +484,7 @@ MEDIAPIPE_REGISTER_NODE(ListIntPackets);
TEST(NodeTest, DefaultTimestampChange0) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "a"
input_stream: "b"
output_stream: "out"
@ -504,7 +504,7 @@ TEST(NodeTest, DefaultTimestampChange0) {
input_stream: "INT:1:b"
output_stream: "STR:out"
}
)");
)pb");
std::vector<mediapipe::Packet> out_packets;
tool::AddVectorSink("out", &config, &out_packets);
mediapipe::CalculatorGraph graph;
@ -541,7 +541,7 @@ MEDIAPIPE_REGISTER_NODE(ConsumerNode);
TEST(NodeTest, ConsumeInputs) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "int"
input_stream: "any"
input_stream: "num"
@ -551,7 +551,7 @@ TEST(NodeTest, ConsumeInputs) {
input_stream: "ANY:any"
input_stream: "NUM:num"
}
)");
)pb");
mediapipe::CalculatorGraph graph;
MP_EXPECT_OK(graph.Initialize(config, {}));
MP_EXPECT_OK(graph.StartRun({}));

View File

@ -46,7 +46,7 @@ class FooBarImpl2 : public SubgraphImpl<FooBar2, FooBarImpl2> {
TEST(SubgraphTest, SubgraphConfig) {
CalculatorGraphConfig subgraph = FooBarImpl1().GetConfig({}).value();
const CalculatorGraphConfig expected_graph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "IN:__stream_0"
output_stream: "OUT:__stream_2"
node {
@ -59,14 +59,14 @@ TEST(SubgraphTest, SubgraphConfig) {
input_stream: "IN:__stream_1"
output_stream: "OUT:__stream_2"
}
)");
)pb");
EXPECT_THAT(subgraph, EqualsProto(expected_graph));
}
TEST(SubgraphTest, TypedSubgraphConfig) {
CalculatorGraphConfig subgraph = FooBarImpl2().GetConfig({}).value();
const CalculatorGraphConfig expected_graph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "IN:__stream_0"
output_stream: "OUT:__stream_2"
node {
@ -79,7 +79,7 @@ TEST(SubgraphTest, TypedSubgraphConfig) {
input_stream: "IN:__stream_1"
output_stream: "OUT:__stream_2"
}
)");
)pb");
EXPECT_THAT(subgraph, EqualsProto(expected_graph));
}
@ -97,7 +97,7 @@ TEST(SubgraphTest, ProtoApiConfig) {
bar->add_output_stream("OUT:__stream_2");
const CalculatorGraphConfig expected_graph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "IN:__stream_0"
output_stream: "OUT:__stream_2"
node {
@ -110,13 +110,13 @@ TEST(SubgraphTest, ProtoApiConfig) {
input_stream: "IN:__stream_1"
output_stream: "OUT:__stream_2"
}
)");
)pb");
EXPECT_THAT(graph, EqualsProto(expected_graph));
}
TEST(SubgraphTest, ExpandSubgraphs) {
CalculatorGraphConfig supergraph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
name: "simple_source"
calculator: "SomeSourceCalculator"
@ -127,9 +127,9 @@ TEST(SubgraphTest, ExpandSubgraphs) {
input_stream: "IN:foo"
output_stream: "OUT:output"
}
)");
)pb");
const CalculatorGraphConfig expected_graph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
name: "simple_source"
calculator: "SomeSourceCalculator"
@ -147,7 +147,7 @@ TEST(SubgraphTest, ExpandSubgraphs) {
input_stream: "IN:foobar____stream_1"
output_stream: "OUT:output"
}
)");
)pb");
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
EXPECT_THAT(supergraph, EqualsProto(expected_graph));
}

View File

@ -30,7 +30,7 @@ namespace {
TEST(CalculatorContractTest, Calculator) {
const CalculatorGraphConfig::Node node =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "MixtureOfExpertsFusionCalculator"
input_stream: "FRAME:fdense_pca_moe_aggregated_detection"
input_stream: "FNET:fnet_logreg_aggregated_detection"
@ -38,7 +38,7 @@ TEST(CalculatorContractTest, Calculator) {
input_stream: "VIDEO:fdense_averaged_pca_moe_v2_detection"
input_side_packet: "FUSION_MODEL:egraph_topical_packet_factory"
output_stream: "egraph_topical_detection"
)");
)pb");
CalculatorContract contract;
MP_EXPECT_OK(contract.Initialize(node));
EXPECT_EQ(contract.Inputs().NumEntries(), 4);
@ -49,7 +49,7 @@ TEST(CalculatorContractTest, Calculator) {
TEST(CalculatorContractTest, CalculatorOptions) {
const CalculatorGraphConfig::Node node =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "CalculatorTestCalculator"
input_stream: "DATA:ycbcr_frames"
input_stream: "VIDEO_HEADER:ycbcr_frames_prestream"
@ -57,7 +57,7 @@ TEST(CalculatorContractTest, CalculatorOptions) {
output_stream: "VIDEO_HEADER:ycbcr_downsampled_prestream"
options {
[mediapipe.CalculatorContractTestOptions.ext] { test_field: 1.0 }
})");
})pb");
CalculatorContract contract;
MP_EXPECT_OK(contract.Initialize(node));
const auto& test_options =
@ -71,14 +71,14 @@ TEST(CalculatorContractTest, CalculatorOptions) {
TEST(CalculatorContractTest, PacketGenerator) {
const PacketGeneratorConfig node =
mediapipe::ParseTextProtoOrDie<PacketGeneratorConfig>(R"(
mediapipe::ParseTextProtoOrDie<PacketGeneratorConfig>(R"pb(
packet_generator: "DaredevilLabeledTimeSeriesGenerator"
input_side_packet: "labeled_time_series"
output_side_packet: "time_series_header"
output_side_packet: "input_matrix"
output_side_packet: "label_set"
output_side_packet: "content_fingerprint"
)");
)pb");
CalculatorContract contract;
MP_EXPECT_OK(contract.Initialize(node));
EXPECT_EQ(contract.InputSidePackets().NumEntries(), 1);
@ -87,11 +87,11 @@ TEST(CalculatorContractTest, PacketGenerator) {
TEST(CalculatorContractTest, StatusHandler) {
const StatusHandlerConfig node =
mediapipe::ParseTextProtoOrDie<StatusHandlerConfig>(R"(
mediapipe::ParseTextProtoOrDie<StatusHandlerConfig>(R"pb(
status_handler: "TaskInjectorStatusHandler"
input_side_packet: "ROW:cid"
input_side_packet: "SPEC:task_specification"
)");
)pb");
CalculatorContract contract;
MP_EXPECT_OK(contract.Initialize(node));
EXPECT_EQ(contract.InputSidePackets().NumEntries(), 2);

View File

@ -306,7 +306,7 @@ REGISTER_CALCULATOR(CustomBoundCalculator);
TEST(CalculatorGraph, SetNextTimestampBoundPropagation) {
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
input_stream: 'gate'
node {
@ -338,7 +338,7 @@ TEST(CalculatorGraph, SetNextTimestampBoundPropagation) {
input_stream: 'merged'
output_stream: 'out'
}
)");
)pb");
Timestamp timestamp = Timestamp(0);
auto send_inputs = [&graph, &timestamp](int input, bool pass) {
@ -431,7 +431,7 @@ TEST(CalculatorGraph, NotAllInputPacketsAtNextTimestampBoundAvailable) {
//
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in0_unfiltered'
input_stream: 'in1_to_be_filtered'
node {
@ -445,7 +445,7 @@ TEST(CalculatorGraph, NotAllInputPacketsAtNextTimestampBoundAvailable) {
input_stream: 'in1_filtered'
output_stream: 'out'
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("out", &config, &packet_dump);
@ -503,7 +503,7 @@ TEST(CalculatorGraph, NotAllInputPacketsAtNextTimestampBoundAvailable) {
TEST(CalculatorGraph, PropagateBoundLoop) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'OutputAndBoundSourceCalculator'
output_stream: 'integers'
@ -526,7 +526,7 @@ TEST(CalculatorGraph, PropagateBoundLoop) {
input_stream: 'sum'
output_stream: 'old_sum'
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("sum", &config, &packet_dump);
@ -549,7 +549,7 @@ TEST(CalculatorGraph, CheckBatchProcessingBoundPropagation) {
// the sink calculator's input stream should report packet timestamp
// mismatches.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'OutputAndBoundSourceCalculator'
output_stream: 'integers'
@ -568,7 +568,7 @@ TEST(CalculatorGraph, CheckBatchProcessingBoundPropagation) {
}
}
node { calculator: 'IntSinkCalculator' input_stream: 'output' }
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.Run());
@ -581,7 +581,7 @@ TEST(CalculatorGraphBoundsTest, ImmediateHandlerBounds) {
// The second PassthroughCalculator delivers an output packet whenever the
// first PassThroughCalculator delivers a timestamp bound.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'input'
node {
calculator: 'CustomBoundCalculator'
@ -603,7 +603,7 @@ TEST(CalculatorGraphBoundsTest, ImmediateHandlerBounds) {
output_stream: 'bounds_output'
output_stream: 'output'
}
)");
)pb");
CalculatorGraph graph;
std::vector<Packet> output_packets;
MP_ASSERT_OK(graph.Initialize(config));
@ -703,7 +703,7 @@ TEST(CalculatorGraphBoundsTest, OffsetBoundPropagation) {
// The PassThroughCalculator delivers an output packet whenever the
// OffsetBoundCalculator delivers a timestamp bound.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'input'
node {
calculator: 'OffsetBoundCalculator'
@ -717,7 +717,7 @@ TEST(CalculatorGraphBoundsTest, OffsetBoundPropagation) {
output_stream: 'bounds_output'
output_stream: 'output'
}
)");
)pb");
CalculatorGraph graph;
std::vector<Packet> output_packets;
MP_ASSERT_OK(graph.Initialize(config));
@ -751,7 +751,7 @@ TEST(CalculatorGraphBoundsTest, BoundWithoutInputPackets) {
// The BoundToPacketCalculator delivers an output packet whenever the
// OffsetBoundCalculator delivers a timestamp bound.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'input'
node {
calculator: 'FuturePacketCalculator'
@ -768,7 +768,7 @@ TEST(CalculatorGraphBoundsTest, BoundWithoutInputPackets) {
input_stream: 'bounds'
output_stream: 'output'
}
)");
)pb");
CalculatorGraph graph;
std::vector<Packet> output_packets;
MP_ASSERT_OK(graph.Initialize(config));
@ -809,7 +809,7 @@ TEST(CalculatorGraphBoundsTest, FixedSizeHandlerBounds) {
// The PassthroughCalculator delivers an output packet whenever the
// LambdaCalculator delivers a timestamp bound.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'input'
input_side_packet: 'open_function'
input_side_packet: 'process_function'
@ -830,7 +830,7 @@ TEST(CalculatorGraphBoundsTest, FixedSizeHandlerBounds) {
output_stream: 'thinned_output'
output_stream: 'output'
}
)");
)pb");
CalculatorGraph graph;
// The task_semaphore counts the number of running tasks.
@ -951,7 +951,7 @@ TEST(CalculatorGraphBoundsTest, LastPacketCheck) {
// packet or input stream close. The output "last_output" shows the
// last packet, and "output" shows the timestamp bounds.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'input'
output_stream: 'output'
output_stream: 'last_output'
@ -972,7 +972,7 @@ TEST(CalculatorGraphBoundsTest, LastPacketCheck) {
output_stream: 'output'
output_stream: 'last_output'
}
)");
)pb");
CalculatorGraph graph;
std::vector<Packet> output_packets;
MP_ASSERT_OK(graph.Initialize(config));

View File

@ -185,7 +185,7 @@ REGISTER_PACKET_GENERATOR(Uint64PacketGenerator);
TEST(CalculatorGraph, OutputSidePacketInProcess) {
const int64 offset = 100;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "offset"
node {
calculator: "OutputSidePacketInProcessCalculator"
@ -197,7 +197,7 @@ TEST(CalculatorGraph, OutputSidePacketInProcess) {
output_stream: "output"
input_side_packet: "offset"
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
std::vector<Packet> output_packets;
@ -255,7 +255,7 @@ REGISTER_PACKET_GENERATOR(PassThroughGenerator);
TEST(CalculatorGraph, SharePacketGeneratorGraph) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'CountingSourceCalculator'
output_stream: 'count1'
@ -296,7 +296,7 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) {
input_side_packet: 'max_count4'
output_side_packet: 'max_count5'
}
)");
)pb");
// At this point config is a standard config which specifies both
// calculators and packet_factories/packet_genators. The following
@ -383,14 +383,14 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) {
TEST(CalculatorGraph, OutputSidePacketAlreadySet) {
const int64 offset = 100;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "offset"
node {
calculator: "OutputSidePacketInProcessCalculator"
input_stream: "offset"
output_side_packet: "offset"
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.StartRun({}));
@ -410,14 +410,14 @@ TEST(CalculatorGraph, OutputSidePacketAlreadySet) {
TEST(CalculatorGraph, OutputSidePacketWithTimestamp) {
const int64 offset = 100;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "offset"
node {
calculator: "OutputSidePacketWithTimestampCalculator"
input_stream: "offset"
output_side_packet: "offset"
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.StartRun({}));
@ -436,7 +436,7 @@ TEST(CalculatorGraph, OutputSidePacketWithTimestamp) {
TEST(CalculatorGraph, OutputSidePacketConsumedBySourceNode) {
const int max_count = 10;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "max_count"
node {
calculator: "OutputSidePacketInProcessCalculator"
@ -453,7 +453,7 @@ TEST(CalculatorGraph, OutputSidePacketConsumedBySourceNode) {
input_stream: "count"
output_stream: "output"
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
std::vector<Packet> output_packets;
@ -529,7 +529,7 @@ TEST(CalculatorGraph, SourceLayerInversion) {
// Set num_threads to 1 to force sequential execution for deterministic
// outputs.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
num_threads: 1
node {
calculator: "CountingSourceCalculator"
@ -563,7 +563,7 @@ TEST(CalculatorGraph, SourceLayerInversion) {
input_side_packet: "INCREMENT:increment2"
source_layer: 0
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(
config, {{"max_count", MakePacket<int>(max_count)},
@ -577,7 +577,7 @@ TEST(CalculatorGraph, SourceLayerInversion) {
// streams and no output streams.
TEST(CalculatorGraph, PacketGeneratorLikeCalculators) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "IntegerOutputSidePacketCalculator"
output_side_packet: "one"
@ -607,7 +607,7 @@ TEST(CalculatorGraph, PacketGeneratorLikeCalculators) {
input_side_packet: "three"
output_stream: "output"
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
std::vector<Packet> output_packets;
@ -624,7 +624,7 @@ TEST(CalculatorGraph, PacketGeneratorLikeCalculators) {
TEST(CalculatorGraph, OutputSummarySidePacketInClose) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_packets"
node {
calculator: "CountAndOutputSummarySidePacketInCloseCalculator"
@ -636,7 +636,7 @@ TEST(CalculatorGraph, OutputSummarySidePacketInClose) {
input_side_packet: "num_of_packets"
output_stream: "output"
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
std::vector<Packet> output_packets;
@ -665,7 +665,7 @@ TEST(CalculatorGraph, OutputSummarySidePacketInClose) {
TEST(CalculatorGraph, GetOutputSidePacket) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_packets"
node {
calculator: "CountAndOutputSummarySidePacketInCloseCalculator"
@ -681,7 +681,7 @@ TEST(CalculatorGraph, GetOutputSidePacket) {
input_side_packet: "input_uint64"
output_side_packet: "output_uint32_pair"
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
// Check a packet generated by the PacketGenerator, which is available after
@ -771,7 +771,7 @@ bool Equals(Packet p1, Packet p2) {
TEST(CalculatorGraph, OutputSidePacketCached) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "OutputSidePacketCachedCalculator"
output_side_packet: "model"
@ -781,7 +781,7 @@ TEST(CalculatorGraph, OutputSidePacketCached) {
input_side_packet: "model"
output_stream: "output"
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
std::vector<Packet> output_packets;

View File

@ -1283,7 +1283,7 @@ class CurrentThreadExecutor : public Executor {
// Returns a CalculatorGraphConfig used by tests.
CalculatorGraphConfig GetConfig() {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
# The graph configuration. We list the nodes in an arbitrary (not
# topologically-sorted) order to verify that CalculatorGraph can
# handle such configurations.
@ -1385,7 +1385,7 @@ CalculatorGraphConfig GetConfig() {
output_side_packet: "LOW:unused_low"
output_side_packet: "PAIR:node_5_converted"
}
)");
)pb");
return config;
}
@ -1739,7 +1739,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) {
// Status handlers with all inputs present should be OK.
auto graph = absl::make_unique<CalculatorGraph>();
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
packet_generator {
packet_generator: "StaticCounterStringGenerator"
output_side_packet: "created_by_factory"
@ -1763,7 +1763,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) {
status_handler: "StringStatusHandler"
input_side_packet: "extra_string"
}
)");
)pb");
MP_ASSERT_OK(graph->Initialize(config));
Packet extra_string = Adopt(new std::string("foo"));
Packet a_uint64 = Adopt(new uint64(0));
@ -1823,7 +1823,7 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) {
TEST(CalculatorGraph, GenerateInInitialize) {
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
packet_generator {
packet_generator: "StaticCounterStringGenerator"
input_side_packet: "created_by_factory"
@ -1852,7 +1852,7 @@ TEST(CalculatorGraph, GenerateInInitialize) {
input_side_packet: "foo3"
output_side_packet: "foo4"
}
)");
)pb");
int initial_count = StaticCounterStringGenerator::NumPacketsGenerated();
MP_ASSERT_OK(graph.Initialize(
config,
@ -1903,7 +1903,7 @@ void ResetCounters(std::map<std::string, Packet>* input_side_packets) {
TEST(CalculatorGraph, HandlersRun) {
std::unique_ptr<CalculatorGraph> graph(new CalculatorGraph());
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
packet_generator {
packet_generator: "FailingPacketGenerator"
output_side_packet: "unavailable"
@ -1926,7 +1926,7 @@ TEST(CalculatorGraph, HandlersRun) {
input_side_packet: "COUNTER2:unavailable_input_counter2"
input_side_packet: "EXTRA:unavailable"
}
)");
)pb");
std::map<std::string, Packet> input_side_packets(
{{"unused_input", AdoptAsUniquePtr(new int(0))},
{"no_input_counter1", AdoptAsUniquePtr(new int(0))},
@ -2073,14 +2073,14 @@ TEST(CalculatorGraph, HandlersRun) {
TEST(CalculatorGraph, SetOffsetInProcess) {
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'SetOffsetInProcessCalculator'
input_stream: 'in'
output_stream: 'out'
}
)");
)pb");
MP_ASSERT_OK(graph.Initialize(config));
MP_EXPECT_OK(graph.StartRun({}));
@ -2095,7 +2095,7 @@ TEST(CalculatorGraph, SetOffsetInProcess) {
TEST(CalculatorGraph, InputPacketLifetime) {
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'PassThroughCalculator'
@ -2107,7 +2107,7 @@ TEST(CalculatorGraph, InputPacketLifetime) {
input_stream: 'mid'
output_stream: 'out'
}
)");
)pb");
LifetimeTracker tracker;
Timestamp timestamp = Timestamp(0);
@ -2138,7 +2138,7 @@ TEST(CalculatorGraph, IfThenElse) {
// of the two branches different.
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
input_stream: 'select'
node {
@ -2175,7 +2175,7 @@ TEST(CalculatorGraph, IfThenElse) {
input_stream: 'SELECT:select'
output_stream: 'OUTPUT:out'
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("out", &config, &packet_dump);
@ -2281,7 +2281,7 @@ TEST(CalculatorGraph, IfThenElse2) {
// of the two branches different.
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
input_stream: 'select'
node {
@ -2319,7 +2319,7 @@ TEST(CalculatorGraph, IfThenElse2) {
output_stream: 'OUTPUT:out'
input_stream_handler { input_stream_handler: 'MuxInputStreamHandler' }
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("out", &config, &packet_dump);
@ -2402,7 +2402,7 @@ TEST(CalculatorGraph, ClosedSourceNodeShouldNotBeUnthrottled) {
// the source node filled an input stream and the input stream changes from
// being "full" to "not full".
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
num_threads: 1
max_queue_size: 100
node {
@ -2425,7 +2425,7 @@ TEST(CalculatorGraph, ClosedSourceNodeShouldNotBeUnthrottled) {
input_stream: 'decimated_second_stream'
output_stream: 'output'
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
@ -2443,7 +2443,7 @@ TEST(CalculatorGraph, ClosedSourceNodeShouldNotBeUnthrottled) {
// The scheduler should be able to run the graph from this initial state.
TEST(CalculatorGraph, OutputPacketInOpen) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
max_queue_size: 1
node {
calculator: 'GlobalCountSourceCalculator'
@ -2460,7 +2460,7 @@ TEST(CalculatorGraph, OutputPacketInOpen) {
input_stream: 'delayed_integers'
output_stream: 'output'
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("output", &config, &packet_dump);
@ -2492,7 +2492,7 @@ TEST(CalculatorGraph, OutputPacketInOpen) {
// The scheduler must schedule a throttled source node from the beginning.
TEST(CalculatorGraph, OutputPacketInOpen2) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
max_queue_size: 1
node {
calculator: 'GlobalCountSourceCalculator'
@ -2510,7 +2510,7 @@ TEST(CalculatorGraph, OutputPacketInOpen2) {
input_stream: 'integers'
output_stream: 'output'
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("output", &config, &packet_dump);
@ -2541,7 +2541,7 @@ TEST(CalculatorGraph, OutputPacketInOpen2) {
// upstream calculator outputs a packet in Open().
TEST(CalculatorGraph, EmptyInputInOpen) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
max_queue_size: 1
node {
calculator: 'GlobalCountSourceCalculator'
@ -2562,7 +2562,7 @@ TEST(CalculatorGraph, EmptyInputInOpen) {
calculator: 'AssertEmptyInputInOpenCalculator'
input_stream: 'integers'
}
)");
)pb");
std::atomic<int> global_counter(1);
std::map<std::string, Packet> input_side_packets;
@ -2576,7 +2576,7 @@ TEST(CalculatorGraph, EmptyInputInOpen) {
// Test for b/33568859.
TEST(CalculatorGraph, UnthrottleRespectsLayers) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
max_queue_size: 1
node {
calculator: 'GlobalCountSourceCalculator'
@ -2596,7 +2596,7 @@ TEST(CalculatorGraph, UnthrottleRespectsLayers) {
input_stream: 'integers1'
output_stream: 'integers1passthrough'
}
)");
)pb");
std::vector<Packet> layer0_packets;
std::vector<Packet> layer1_packets;
@ -2642,7 +2642,7 @@ TEST(CalculatorGraph, UnthrottleRespectsLayers) {
// so far. The graph has one cycle.
TEST(CalculatorGraph, Cycle) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'GlobalCountSourceCalculator'
input_side_packet: 'global_counter'
@ -2666,7 +2666,7 @@ TEST(CalculatorGraph, Cycle) {
input_stream: 'sum'
output_stream: 'old_sum'
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("sum", &config, &packet_dump);
@ -2693,7 +2693,7 @@ TEST(CalculatorGraph, Cycle) {
// packet timestamps ignored.
TEST(CalculatorGraph, CycleUntimed) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream_handler {
input_stream_handler: 'BarrierInputStreamHandler'
}
@ -2717,7 +2717,7 @@ TEST(CalculatorGraph, CycleUntimed) {
input_stream: 'sum'
output_stream: 'old_sum'
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("sum", &config, &packet_dump);
@ -2743,7 +2743,7 @@ TEST(CalculatorGraph, CycleUntimed) {
// The graph has two cycles.
TEST(CalculatorGraph, DirectFormI) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'GlobalCountSourceCalculator'
input_side_packet: 'global_counter'
@ -2818,7 +2818,7 @@ TEST(CalculatorGraph, DirectFormI) {
input_stream_handler: 'EarlyCloseInputStreamHandler'
}
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("y", &config, &packet_dump);
@ -2850,7 +2850,7 @@ TEST(CalculatorGraph, DirectFormI) {
// The graph has two cycles.
TEST(CalculatorGraph, DirectFormII) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'GlobalCountSourceCalculator'
input_side_packet: 'global_counter'
@ -2920,7 +2920,7 @@ TEST(CalculatorGraph, DirectFormII) {
input_stream_handler: 'EarlyCloseInputStreamHandler'
}
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("y", &config, &packet_dump);
@ -2951,7 +2951,7 @@ TEST(CalculatorGraph, DotProduct) {
// The use of BarrierInputStreamHandler in this graph aligns the input
// packets to a calculator by arrival order rather than by timestamp.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream_handler {
input_stream_handler: 'BarrierInputStreamHandler'
}
@ -3008,7 +3008,7 @@ TEST(CalculatorGraph, DotProduct) {
input_stream: 'z_product'
output_stream: 'dot_product'
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("dot_product", &config, &packet_dump);
@ -3047,7 +3047,7 @@ TEST(CalculatorGraph, DotProduct) {
TEST(CalculatorGraph, TerminatesOnCancelWithOpenGraphInputStreams) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'PassThroughCalculator'
input_stream: 'in_a'
@ -3057,7 +3057,7 @@ TEST(CalculatorGraph, TerminatesOnCancelWithOpenGraphInputStreams) {
}
input_stream: 'in_a'
input_stream: 'in_b'
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.StartRun({}));
@ -3076,14 +3076,14 @@ TEST(CalculatorGraph, TerminatesOnCancelWithOpenGraphInputStreams) {
TEST(CalculatorGraph, TerminatesOnCancelAfterPause) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'PassThroughCalculator'
input_stream: 'in'
output_stream: 'out'
}
input_stream: 'in'
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.StartRun({}));
@ -3138,7 +3138,7 @@ REGISTER_PACKET_GENERATOR(PassThroughGenerator);
TEST(CalculatorGraph, RecoverAfterRunError) {
PacketGeneratorGraph generator_graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
name: 'calculator1'
calculator: 'CountingSourceCalculator'
@ -3157,7 +3157,7 @@ TEST(CalculatorGraph, RecoverAfterRunError) {
status_handler: 'FailableStatusHandler'
input_side_packet: 'status_handler_command'
}
)");
)pb");
int packet_count = 0;
CalculatorGraph graph;
@ -3259,7 +3259,7 @@ TEST(CalculatorGraph, RecoverAfterRunError) {
TEST(CalculatorGraph, SetInputStreamMaxQueueSizeWorksSlowCalculator) {
using Semaphore = SemaphoreCalculator::Semaphore;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'SemaphoreCalculator'
input_stream: 'in'
@ -3277,7 +3277,7 @@ TEST(CalculatorGraph, SetInputStreamMaxQueueSizeWorksSlowCalculator) {
input_stream: 'in'
input_stream: 'in_2'
max_queue_size: 100
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
graph.SetGraphInputStreamAddMode(
@ -3352,7 +3352,7 @@ TEST(CalculatorGraph, AddPacketNoBusyLoop) {
// out
//
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
max_queue_size: 1
node {
@ -3366,7 +3366,7 @@ TEST(CalculatorGraph, AddPacketNoBusyLoop) {
input_stream: 'in'
output_stream: 'out'
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
graph.SetGraphInputStreamAddMode(
@ -3487,7 +3487,7 @@ absl::Status DoProcess(const InputStreamShardSet& inputs,
TEST(CalculatorGraph, ObserveOutputStream) {
const int max_count = 10;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'CountingSourceCalculator'
output_stream: 'count'
@ -3503,7 +3503,7 @@ TEST(CalculatorGraph, ObserveOutputStream) {
input_stream: 'mid'
output_stream: 'out'
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
@ -3539,7 +3539,7 @@ class PassThroughSubgraph : public Subgraph {
absl::StatusOr<CalculatorGraphConfig> GetConfig(
const SubgraphOptions& options) override {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'INPUT:input'
output_stream: 'OUTPUT:output'
node {
@ -3547,7 +3547,7 @@ class PassThroughSubgraph : public Subgraph {
input_stream: 'input'
output_stream: 'output'
}
)");
)pb");
return config;
}
};
@ -3556,7 +3556,7 @@ REGISTER_MEDIAPIPE_GRAPH(PassThroughSubgraph);
TEST(CalculatorGraph, ObserveOutputStreamSubgraph) {
const int max_count = 10;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'CountingSourceCalculator'
output_stream: 'count'
@ -3567,7 +3567,7 @@ TEST(CalculatorGraph, ObserveOutputStreamSubgraph) {
input_stream: 'INPUT:count'
output_stream: 'OUTPUT:out'
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
@ -3590,7 +3590,7 @@ TEST(CalculatorGraph, ObserveOutputStreamError) {
const int max_count = 10;
const int fail_count = 6;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'CountingSourceCalculator'
output_stream: 'count'
@ -3606,7 +3606,7 @@ TEST(CalculatorGraph, ObserveOutputStreamError) {
input_stream: 'mid'
output_stream: 'out'
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
@ -3640,7 +3640,7 @@ TEST(CalculatorGraph, ObserveOutputStreamError) {
TEST(CalculatorGraph, ObserveOutputStreamNonexistent) {
const int max_count = 10;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'CountingSourceCalculator'
output_stream: 'count'
@ -3656,7 +3656,7 @@ TEST(CalculatorGraph, ObserveOutputStreamNonexistent) {
input_stream: 'mid'
output_stream: 'out'
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
@ -3677,7 +3677,7 @@ TEST(CalculatorGraph, ObserveOutputStreamNonexistent) {
TEST(CalculatorGraph, FastSourceSlowSink) {
const int max_count = 10;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
num_threads: 2
max_queue_size: 100
node {
@ -3686,7 +3686,7 @@ TEST(CalculatorGraph, FastSourceSlowSink) {
input_side_packet: 'MAX_COUNT:max_count'
}
node { calculator: 'SlowCountingSinkCalculator' input_stream: 'out' }
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
@ -3707,9 +3707,9 @@ TEST(CalculatorGraph, GraphFinishesWhilePaused) {
//
// graph.WaitUntilDone must not block forever.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node { calculator: 'OneShot20MsCalculator' }
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_EXPECT_OK(graph.StartRun({}));
@ -3729,7 +3729,7 @@ TEST(CalculatorGraph, ConstructAndDestruct) { CalculatorGraph graph; }
TEST(CalculatorGraph, RecoverAfterPreviousFailInOpen) {
const int max_count = 10;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'CountingSourceCalculator'
output_stream: 'a'
@ -3752,7 +3752,7 @@ TEST(CalculatorGraph, RecoverAfterPreviousFailInOpen) {
input_side_packet: 'ERROR_ON_OPEN:fail'
}
node { calculator: 'IntSinkCalculator' input_stream: 'd' }
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(
graph.Initialize(config, {{"max_count", MakePacket<int>(max_count)}}));
@ -3764,7 +3764,7 @@ TEST(CalculatorGraph, RecoverAfterPreviousFailInOpen) {
TEST(CalculatorGraph, ReuseValidatedGraphConfig) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
packet_generator {
packet_generator: "StaticCounterStringGenerator"
input_side_packet: "created_by_factory"
@ -3798,7 +3798,7 @@ TEST(CalculatorGraph, ReuseValidatedGraphConfig) {
input_side_packet: "global_counter"
output_stream: "unused"
}
)");
)pb");
ValidatedGraphConfig validated_graph;
MP_ASSERT_OK(validated_graph.Initialize(config));
@ -3841,7 +3841,7 @@ class TestRangeStdDevSubgraph : public Subgraph {
absl::StatusOr<CalculatorGraphConfig> GetConfig(
const SubgraphOptions& options) override {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_side_packet: 'node_converted'
output_stream: 'DATA:range'
output_stream: 'SUM:range_sum'
@ -3860,7 +3860,7 @@ class TestRangeStdDevSubgraph : public Subgraph {
input_stream: 'MEAN:range_mean'
output_stream: 'range_stddev'
}
)");
)pb");
return config;
}
};
@ -3871,7 +3871,7 @@ class TestMergeSaverSubgraph : public Subgraph {
absl::StatusOr<CalculatorGraphConfig> GetConfig(
const SubgraphOptions& options) override {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'DATA1:range1'
input_stream: 'DATA2:range2'
output_stream: 'MERGE:merge'
@ -3888,7 +3888,7 @@ class TestMergeSaverSubgraph : public Subgraph {
input_stream: 'merge'
output_stream: 'final'
}
)");
)pb");
return config;
}
};
@ -3896,7 +3896,7 @@ REGISTER_MEDIAPIPE_GRAPH(TestMergeSaverSubgraph);
CalculatorGraphConfig GetConfigWithSubgraphs() {
CalculatorGraphConfig proto =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
# Ensure stream name for FindOutputStreamManager
output_stream: 'MERGE:merge'
packet_generator {
@ -3952,7 +3952,7 @@ CalculatorGraphConfig GetConfigWithSubgraphs() {
input_stream: 'DATA2:range5_stddev'
output_stream: 'FINAL:final_stddev'
}
)");
)pb");
return proto;
}
@ -3989,7 +3989,7 @@ TEST(CalculatorGraph, ReservedNameExecutorConfig) {
// A reserved executor name such as "__gpu" must not be used.
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
executor {
name: '__gpu'
@ -4003,7 +4003,7 @@ TEST(CalculatorGraph, ReservedNameExecutorConfig) {
input_stream: 'in'
output_stream: 'out'
}
)");
)pb");
absl::Status status = graph.Initialize(config);
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
EXPECT_THAT(status.message(), testing::AllOf(testing::HasSubstr("__gpu"),
@ -4014,7 +4014,7 @@ TEST(CalculatorGraph, ReservedNameNodeExecutor) {
// A reserved executor name such as "__gpu" must not be used.
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'PassThroughCalculator'
@ -4022,7 +4022,7 @@ TEST(CalculatorGraph, ReservedNameNodeExecutor) {
input_stream: 'in'
output_stream: 'out'
}
)");
)pb");
absl::Status status = graph.Initialize(config);
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
EXPECT_THAT(status.message(), testing::AllOf(testing::HasSubstr("__gpu"),
@ -4035,7 +4035,7 @@ TEST(CalculatorGraph, NonExistentExecutor) {
// provided to the graph with a CalculatorGraph::SetExecutor() call.
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'PassThroughCalculator'
@ -4043,7 +4043,7 @@ TEST(CalculatorGraph, NonExistentExecutor) {
input_stream: 'in'
output_stream: 'out'
}
)");
)pb");
absl::Status status = graph.Initialize(config);
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
EXPECT_THAT(status.message(),
@ -4059,7 +4059,7 @@ TEST(CalculatorGraph, UndeclaredExecutor) {
MP_ASSERT_OK(
graph.SetExecutor("xyz", std::make_shared<ThreadPoolExecutor>(1)));
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
node {
calculator: 'PassThroughCalculator'
@ -4067,7 +4067,7 @@ TEST(CalculatorGraph, UndeclaredExecutor) {
input_stream: 'in'
output_stream: 'out'
}
)");
)pb");
absl::Status status = graph.Initialize(config);
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
EXPECT_THAT(status.message(),
@ -4080,7 +4080,7 @@ TEST(CalculatorGraph, UntypedExecutorDeclaredButNotSet) {
// the graph with a CalculatorGraph::SetExecutor() call.
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
executor { name: 'xyz' }
node {
@ -4089,7 +4089,7 @@ TEST(CalculatorGraph, UntypedExecutorDeclaredButNotSet) {
input_stream: 'in'
output_stream: 'out'
}
)");
)pb");
absl::Status status = graph.Initialize(config);
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
EXPECT_THAT(status.message(),
@ -4103,7 +4103,7 @@ TEST(CalculatorGraph, DuplicateExecutorConfig) {
MP_ASSERT_OK(
graph.SetExecutor("xyz", std::make_shared<ThreadPoolExecutor>(1)));
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
executor { name: 'xyz' }
executor { name: 'xyz' }
@ -4113,7 +4113,7 @@ TEST(CalculatorGraph, DuplicateExecutorConfig) {
input_stream: 'in'
output_stream: 'out'
}
)");
)pb");
absl::Status status = graph.Initialize(config);
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
EXPECT_THAT(status.message(),
@ -4128,7 +4128,7 @@ TEST(CalculatorGraph, TypedExecutorDeclaredAndSet) {
MP_ASSERT_OK(
graph.SetExecutor("xyz", std::make_shared<ThreadPoolExecutor>(1)));
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
executor {
name: 'xyz'
@ -4143,7 +4143,7 @@ TEST(CalculatorGraph, TypedExecutorDeclaredAndSet) {
input_stream: 'in'
output_stream: 'out'
}
)");
)pb");
absl::Status status = graph.Initialize(config);
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
EXPECT_THAT(status.message(),
@ -4156,7 +4156,7 @@ TEST(CalculatorGraph, TypedExecutorDeclaredAndSet) {
TEST(CalculatorGraph, NumThreadsAndDefaultExecutorConfig) {
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
num_threads: 1
executor {
@ -4175,7 +4175,7 @@ TEST(CalculatorGraph, NumThreadsAndDefaultExecutorConfig) {
input_stream: 'mid'
output_stream: 'out'
}
)");
)pb");
absl::Status status = graph.Initialize(config);
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
EXPECT_THAT(status.message(),
@ -4188,7 +4188,7 @@ TEST(CalculatorGraph, NumThreadsAndDefaultExecutorConfig) {
TEST(CalculatorGraph, NumThreadsAndNonDefaultExecutorConfig) {
CalculatorGraph graph;
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: 'in'
num_threads: 1
executor {
@ -4209,7 +4209,7 @@ TEST(CalculatorGraph, NumThreadsAndNonDefaultExecutorConfig) {
input_stream: 'mid'
output_stream: 'out'
}
)");
)pb");
MP_EXPECT_OK(graph.Initialize(config));
}
@ -4227,14 +4227,14 @@ TEST(CalculatorGraph, RunWithNumThreadsInExecutorConfig) {
{"ThreadPoolExecutor", 1, false}};
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
executor {
options {
[mediapipe.ThreadPoolExecutorOptions.ext] { num_threads: 0 }
}
}
node { calculator: 'PthreadSelfSourceCalculator' output_stream: 'out' }
)");
)pb");
ThreadPoolExecutorOptions* default_executor_options =
config.mutable_executor(0)->mutable_options()->MutableExtension(
ThreadPoolExecutorOptions::ext);
@ -4266,7 +4266,7 @@ TEST(CalculatorGraph, CalculatorGraphNotInitialized) {
TEST(CalculatorGraph, SimulateAssertFailure) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
num_threads: 2
node {
calculator: 'PassThroughCalculator'
@ -4277,7 +4277,7 @@ TEST(CalculatorGraph, SimulateAssertFailure) {
}
input_stream: 'in_a'
input_stream: 'in_b'
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.StartRun({}));
@ -4293,7 +4293,7 @@ TEST(CalculatorGraph, SimulateAssertFailure) {
// the source node stops the graph.
TEST(CalculatorGraph, CheckInputTimestamp) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'CheckInputTimestampSourceCalculator'
output_stream: 'integer'
@ -4302,7 +4302,7 @@ TEST(CalculatorGraph, CheckInputTimestamp) {
calculator: 'CheckInputTimestampSinkCalculator'
input_stream: 'integer'
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.Run());
@ -4314,7 +4314,7 @@ TEST(CalculatorGraph, CheckInputTimestamp) {
// source node.
TEST(CalculatorGraph, CheckInputTimestamp2) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: 'CheckInputTimestamp2SourceCalculator'
output_stream: 'integer'
@ -4323,7 +4323,7 @@ TEST(CalculatorGraph, CheckInputTimestamp2) {
calculator: 'CheckInputTimestamp2SinkCalculator'
input_stream: 'integer'
}
)");
)pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.Run());
@ -4331,7 +4331,7 @@ TEST(CalculatorGraph, CheckInputTimestamp2) {
TEST(CalculatorGraph, GraphInputStreamWithTag) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "VIDEO_METADATA:video_metadata"
input_stream: "max_count"
node {
@ -4341,7 +4341,7 @@ TEST(CalculatorGraph, GraphInputStreamWithTag) {
output_stream: "FIRST_INPUT:output_0"
output_stream: "output_1"
}
)");
)pb");
std::vector<Packet> packet_dump;
tool::AddVectorSink("output_0", &config, &packet_dump);
CalculatorGraph graph;

View File

@ -91,7 +91,7 @@ class ParallelExecutionTest : public testing::Test {
TEST_F(ParallelExecutionTest, SlowPlusOneCalculatorsTest) {
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input"
node {
calculator: "SlowPlusOneCalculator"
@ -111,7 +111,7 @@ TEST_F(ParallelExecutionTest, SlowPlusOneCalculatorsTest) {
input_side_packet: "CALLBACK:callback"
}
num_threads: 5
)");
)pb");
// Starts MediaPipe graph.
CalculatorGraph graph(graph_config);

View File

@ -48,14 +48,14 @@ class GraphServiceTest : public ::testing::Test {
protected:
void SetUp() override {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "in"
node {
calculator: "TestServiceCalculator"
input_stream: "in"
output_stream: "out"
}
)");
)pb");
MP_ASSERT_OK(graph_.Initialize(config));
MP_ASSERT_OK(
graph_.ObserveOutputStream("out", [this](const Packet& packet) {
@ -98,11 +98,11 @@ TEST_F(GraphServiceTest, UseInCalculator) {
TEST_F(GraphServiceTest, Contract) {
const CalculatorGraphConfig::Node node =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig::Node>(R"pb(
calculator: "TestServiceCalculator"
input_stream: "in"
output_stream: "out"
)");
)pb");
CalculatorContract contract;
MP_EXPECT_OK(contract.Initialize(node));
MP_EXPECT_OK(TestServiceCalculator::GetContract(&contract));

View File

@ -33,7 +33,7 @@ namespace {
// Shows validation success for a graph and a subgraph.
TEST(GraphValidationTest, InitializeGraphFromProtos) {
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
type: "PassThroughGraph"
input_stream: "INPUT:stream_1"
output_stream: "OUTPUT:stream_2"
@ -42,8 +42,8 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
input_stream: "stream_1" # Any Type.
output_stream: "stream_2" # Same as input.
}
)");
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
)pb");
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "INPUT:stream_1"
output_stream: "OUTPUT:stream_2"
node {
@ -56,7 +56,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
input_stream: "INPUT:stream_2" # Any Type.
output_stream: "OUTPUT:stream_3" # Same as input.
}
)");
)pb");
GraphValidation validation_1;
MP_EXPECT_OK(
@ -66,7 +66,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
graph_1.Initialize({config_1, config_2}, {}, {}, "PassThroughGraph"));
EXPECT_THAT(
graph_1.Config(),
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
type: "PassThroughGraph"
input_stream: "INPUT:stream_1"
output_stream: "OUTPUT:stream_2"
@ -76,7 +76,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
output_stream: "stream_2"
}
executor {}
)")));
)pb")));
GraphValidation validation_2;
MP_EXPECT_OK(validation_2.Validate({config_1, config_2}, {}));
@ -84,7 +84,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
MP_EXPECT_OK(graph_2.Initialize({config_1, config_2}, {}));
EXPECT_THAT(
graph_2.Config(),
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "INPUT:stream_1"
output_stream: "OUTPUT:stream_2"
node {
@ -99,7 +99,7 @@ TEST(GraphValidationTest, InitializeGraphFromProtos) {
output_stream: "stream_3"
}
executor {}
)")));
)pb")));
}
// Shows validation failure due to an unregistered subgraph.
@ -129,7 +129,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
}
)",
&config_1));
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "INPUT:stream_1"
output_stream: "OUTPUT:stream_2"
node {
@ -152,8 +152,8 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
input_stream: "INPUT:stream_2" # Any Type.
output_stream: "OUTPUT:stream_3" # Same as input.
}
)");
auto options = ParseTextProtoOrDie<Subgraph::SubgraphOptions>(R"(
)pb");
auto options = ParseTextProtoOrDie<Subgraph::SubgraphOptions>(R"pb(
options: {
[mediapipe.TemplateSubgraphOptions.ext]: {
dict: {
@ -163,7 +163,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
}
}
}
})");
})pb");
GraphValidation validation_1;
MP_EXPECT_OK(validation_1.Validate({config_2}, {config_1}, {},
@ -173,7 +173,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
"PassThroughGraph", &options));
EXPECT_THAT(
graph_1.Config(),
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
type: "PassThroughGraph"
input_stream: "INPUT:stream_9"
output_stream: "OUTPUT:stream_2"
@ -184,7 +184,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
output_stream: "stream_2"
}
executor {}
)")));
)pb")));
GraphValidation validation_2;
MP_EXPECT_OK(validation_2.Validate({config_2}, {config_1}));
@ -192,7 +192,7 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
MP_EXPECT_OK(graph_2.Initialize({config_2}, {config_1}));
EXPECT_THAT(
graph_2.Config(),
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "INPUT:stream_1"
output_stream: "OUTPUT:stream_2"
node {
@ -207,14 +207,14 @@ TEST(GraphValidationTest, InitializeTemplateFromProtos) {
output_stream: "stream_3"
}
executor {}
)")));
)pb")));
}
// Shows passing validation of optional subgraph inputs and output streams.
TEST(GraphValidationTest, OptionalSubgraphStreams) {
// A subgraph defining two optional input streams
// and two optional output streams.
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
type: "PassThroughGraph"
input_stream: "INPUT:input_0"
input_stream: "INPUT:1:input_1"
@ -226,11 +226,11 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
input_stream: "input_1" # Any Type.
output_stream: "output_0" # Same as input.
}
)");
)pb");
// An enclosing graph that specifies one of the two optional input streams
// and one of the two optional output streams.
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "INPUT:foo_in"
output_stream: "OUTPUT:foo_out"
node {
@ -243,7 +243,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
input_stream: "INPUT:foo_bar" # Any Type.
output_stream: "OUTPUT:foo_out" # Same as input.
}
)");
)pb");
GraphValidation validation_1;
MP_EXPECT_OK(validation_1.Validate({config_1, config_2}, {}));
@ -253,7 +253,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
graph_1.Config(),
// The result includes only the requested input and output streams.
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "INPUT:foo_in"
output_stream: "OUTPUT:foo_out"
node {
@ -268,7 +268,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
output_stream: "foo_out"
}
executor {}
)")));
)pb")));
MP_EXPECT_OK(graph_1.StartRun({}));
MP_EXPECT_OK(graph_1.CloseAllPacketSources());
@ -279,7 +279,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreams) {
TEST(GraphValidationTest, OptionalSubgraphStreamsMismatched) {
// A subgraph defining two optional input streams
// and two optional output streams.
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
type: "PassThroughGraph"
input_stream: "INPUT:input_0"
input_stream: "INPUT:1:input_1"
@ -291,11 +291,11 @@ TEST(GraphValidationTest, OptionalSubgraphStreamsMismatched) {
input_stream: "input_1" # Any Type.
output_stream: "output_0" # Same as input.
}
)");
)pb");
// An enclosing graph that specifies one of the two optional input streams
// and both of the two optional output streams.
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "INPUT:foo_in"
output_stream: "OUTPUT:foo_out"
node {
@ -309,7 +309,7 @@ TEST(GraphValidationTest, OptionalSubgraphStreamsMismatched) {
input_stream: "INPUT:1:foo_bar" # Any Type.
output_stream: "OUTPUT:foo_out" # Same as input.
}
)");
)pb");
GraphValidation validation_1;
absl::Status status = validation_1.Validate({config_1, config_2}, {});
@ -344,7 +344,7 @@ REGISTER_CALCULATOR(OptionalSideInputTestCalculator);
TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
// A subgraph defining one optional input-side-packet.
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
type: "PassThroughGraph"
input_side_packet: "INPUT:input_0"
output_stream: "OUTPUT:output_0"
@ -353,17 +353,17 @@ TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
input_side_packet: "SIDEINPUT:input_0" # std::string
output_stream: "OUTPUT:output_0" # std::string
}
)");
)pb");
// An enclosing graph that omits the optional input-side-packet.
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_side_packet: "INPUT:foo_in"
output_stream: "OUTPUT:foo_out"
node {
calculator: "PassThroughGraph"
output_stream: "OUTPUT:foo_out" # std::string
}
)");
)pb");
GraphValidation validation_1;
MP_EXPECT_OK(validation_1.Validate({config_1, config_2}, {}));
@ -373,7 +373,7 @@ TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
graph_1.Config(),
// The expanded graph omits the optional input-side-packet.
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_side_packet: "INPUT:foo_in"
output_stream: "OUTPUT:foo_out"
node {
@ -382,7 +382,7 @@ TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
output_stream: "OUTPUT:foo_out"
}
executor {}
)")));
)pb")));
std::map<std::string, Packet> side_packets;
side_packets.insert({"foo_in", mediapipe::Adopt(new std::string("input"))});
@ -393,7 +393,7 @@ TEST(GraphValidationTest, OptionalInputNotProvidedForSubgraphCalculator) {
TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
// A subgraph defining one optional side-packet and two optional inputs.
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
type: "PassThroughGraph"
input_side_packet: "INPUT:input_0"
input_stream: "SELECT:select"
@ -406,10 +406,10 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
input_stream: "ENABLE:enable"
output_stream: "OUTPUT:output_0" # std::string
}
)");
)pb");
// An enclosing graph that specifies just one optional input.
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_2 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_side_packet: "INPUT:foo_in"
input_stream: "SELECT:foo_select"
output_stream: "OUTPUT:foo_out"
@ -418,7 +418,7 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
input_stream: "SELECT:foo_select"
output_stream: "OUTPUT:foo_out" # std::string
}
)");
)pb");
GraphValidation validation_1;
MP_ASSERT_OK(validation_1.Validate({config_1, config_2}, {}));
@ -430,7 +430,7 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
// The expanded graph includes only the specified input, "SELECT".
// Without the fix to RemoveIgnoredStreams(), the expanded graph
// includes the wrong input.
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_side_packet: "INPUT:foo_in"
input_stream: "SELECT:foo_select"
output_stream: "OUTPUT:foo_out"
@ -441,7 +441,7 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
output_stream: "OUTPUT:foo_out"
}
executor {}
)")));
)pb")));
std::map<std::string, Packet> side_packets;
side_packets.insert({"foo_in", mediapipe::Adopt(new std::string("input"))});
@ -453,7 +453,7 @@ TEST(GraphValidationTest, MultipleOptionalInputsForSubgraph) {
// Shows a calculator graph running with and without one optional side packet.
TEST(GraphValidationTest, OptionalInputsForGraph) {
// A subgraph defining one optional input-side-packet.
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto config_1 = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
type: "PassThroughGraph"
input_side_packet: "side_input_0"
input_stream: "stream_input_0"
@ -466,7 +466,7 @@ TEST(GraphValidationTest, OptionalInputsForGraph) {
input_stream: "ENABLE:stream_input_1"
output_stream: "OUTPUT:output_0"
}
)");
)pb");
GraphValidation validation_1;
MP_EXPECT_OK(validation_1.Validate({config_1}, {}));
CalculatorGraph graph_1;

View File

@ -249,7 +249,7 @@ TEST_F(GraphProfilerTestPeer, InitializeConfig) {
// Checks histogram_interval_size_usec and num_histogram_intervals.
CalculatorProfile actual =
GetCalculatorProfilesMap()->find(kDummyTestCalculatorName)->second;
EXPECT_THAT(actual, EqualsProto(R"(
EXPECT_THAT(actual, EqualsProto(R"pb(
name: "DummyTestCalculator"
process_runtime {
total: 0
@ -287,7 +287,7 @@ TEST_F(GraphProfilerTestPeer, InitializeConfig) {
count: 0
}
}
)"));
)pb"));
}
// Tests that Initialize() uses the ProfilerConfig in the graph definition.
@ -313,7 +313,7 @@ TEST_F(GraphProfilerTestPeer, InitializeConfigWithoutStreamLatency) {
// Checks histogram_interval_size_usec and num_histogram_intervals.
CalculatorProfile actual =
GetCalculatorProfilesMap()->find(kDummyTestCalculatorName)->second;
EXPECT_THAT(actual, EqualsProto(R"(
EXPECT_THAT(actual, EqualsProto(R"pb(
name: "DummyTestCalculator"
process_runtime {
total: 0
@ -323,7 +323,7 @@ TEST_F(GraphProfilerTestPeer, InitializeConfigWithoutStreamLatency) {
count: 0
count: 0
}
)"));
)pb"));
}
// Tests that Initialize() reads all the configs defined in the graph
@ -654,11 +654,11 @@ TEST_F(GraphProfilerTestPeer, SetOpenRuntime) {
simulation_clock->ThreadFinish();
ASSERT_EQ(profiles.size(), 1);
EXPECT_THAT(profiles[0], Partially(EqualsProto(R"(
EXPECT_THAT(profiles[0], Partially(EqualsProto(R"pb(
name: "DummyTestCalculator"
open_runtime: 100
process_runtime { total: 0 }
)")));
)pb")));
// Checks packets_info_ map hasn't changed.
ASSERT_EQ(GetPacketsInfoMap()->size(), 0);
}
@ -711,7 +711,7 @@ TEST_F(GraphProfilerTestPeer, SetOpenRuntimeWithStreamLatency) {
CalculatorProfile source_profile =
GetProfileWithName(profiles, "source_calc");
EXPECT_THAT(source_profile, EqualsProto(R"(
EXPECT_THAT(source_profile, EqualsProto(R"pb(
name: "source_calc"
open_runtime: 150
process_runtime {
@ -732,7 +732,7 @@ TEST_F(GraphProfilerTestPeer, SetOpenRuntimeWithStreamLatency) {
num_intervals: 1
count: 0
}
)"));
)pb"));
// Check packets_info_ map has been updated.
ASSERT_EQ(GetPacketsInfoMap()->size(), 1);
@ -773,7 +773,7 @@ TEST_F(GraphProfilerTestPeer, SetCloseRuntime) {
std::vector<CalculatorProfile> profiles = Profiles();
simulation_clock->ThreadFinish();
EXPECT_THAT(profiles[0], EqualsProto(R"(
EXPECT_THAT(profiles[0], EqualsProto(R"pb(
name: "DummyTestCalculator"
close_runtime: 100
process_runtime {
@ -782,7 +782,7 @@ TEST_F(GraphProfilerTestPeer, SetCloseRuntime) {
num_intervals: 1
count: 0
}
)"));
)pb"));
}
// Tests that SetCloseRuntime() updates |close_runtime| and doesn't affect other
@ -832,7 +832,7 @@ TEST_F(GraphProfilerTestPeer, SetCloseRuntimeWithStreamLatency) {
CalculatorProfile source_profile =
GetProfileWithName(profiles, "source_calc");
EXPECT_THAT(source_profile, EqualsProto(R"(
EXPECT_THAT(source_profile, EqualsProto(R"pb(
name: "source_calc"
close_runtime: 100
process_runtime {
@ -863,7 +863,7 @@ TEST_F(GraphProfilerTestPeer, SetCloseRuntimeWithStreamLatency) {
count: 0
}
}
)"));
)pb"));
PacketInfo expected_packet_info = {0,
/*production_time_usec=*/1000 + 100,
/*source_process_start_usec=*/1000 + 0};
@ -1003,7 +1003,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSample) {
simulation_clock->ThreadFinish();
ASSERT_EQ(profiles.size(), 1);
EXPECT_THAT(profiles[0], EqualsProto(R"(
EXPECT_THAT(profiles[0], EqualsProto(R"pb(
name: "DummyTestCalculator"
process_runtime {
total: 150
@ -1011,7 +1011,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSample) {
num_intervals: 1
count: 1
}
)"));
)pb"));
// Checks packets_info_ map hasn't changed.
ASSERT_EQ(GetPacketsInfoMap()->size(), 0);
}
@ -1061,7 +1061,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) {
CalculatorProfile source_profile =
GetProfileWithName(profiles, "source_calc");
EXPECT_THAT(profiles[0], Partially(EqualsProto(R"(
EXPECT_THAT(profiles[0], Partially(EqualsProto(R"pb(
process_runtime {
total: 150
interval_size_usec: 1000000
@ -1080,7 +1080,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) {
num_intervals: 1
count: 1
}
)")));
)pb")));
// Check packets_info_ map has been updated.
ASSERT_EQ(GetPacketsInfoMap()->size(), 1);
@ -1114,7 +1114,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) {
// 1000 process output latency total = 2000 (end) + 250 - 1000 (when source
// started) = 1250 For "stream_0" should have not changed since it was empty.
// For "stream_1" = 2000 (end) - 1250 (when source finished) = 850
EXPECT_THAT(consumer_profile, Partially(EqualsProto(R"(
EXPECT_THAT(consumer_profile, Partially(EqualsProto(R"pb(
name: "consumer_calc"
process_input_latency { total: 1000 }
process_output_latency { total: 1250 }
@ -1126,7 +1126,7 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) {
name: "stream_1"
latency { total: 850 }
}
)")));
)pb")));
// Check packets_info_ map for PacketId({"stream_1", 100}) should not yet be
// garbage collected.

View File

@ -122,11 +122,11 @@ TEST_F(GraphTracerTest, EmptyTrace) {
// Validate the GraphTrace data.
EXPECT_THAT(GetTrace(),
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"pb(
base_time: 0
base_timestamp: 0
stream_name: ""
)")));
)pb")));
}
TEST_F(GraphTracerTest, CalculatorTrace) {
@ -145,7 +145,7 @@ TEST_F(GraphTracerTest, CalculatorTrace) {
// Validate the GraphTrace data.
EXPECT_THAT(
GetTrace(), EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"(
GetTrace(), EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"pb(
base_time: 1608911100000000
base_timestamp: 1608911100000000
stream_name: ""
@ -166,7 +166,7 @@ TEST_F(GraphTracerTest, CalculatorTrace) {
}
output_trace { packet_timestamp: 0 stream_id: 2 event_data: 2 }
}
)")));
)pb")));
}
TEST_F(GraphTracerTest, GraphTrace) {
@ -226,7 +226,7 @@ TEST_F(GraphTracerTest, GraphTrace) {
// Validate the GraphTrace data.
EXPECT_THAT(
GetTrace(), EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"(
GetTrace(), EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"pb(
base_time: 1608911100000000
base_timestamp: 1608911100000000
stream_name: ""
@ -300,7 +300,7 @@ TEST_F(GraphTracerTest, GraphTrace) {
}
output_trace { packet_timestamp: 5 stream_id: 5 event_data: 10 }
}
)")));
)pb")));
// No timestamps are completed before start_time_.
// One timestamp is completed before start_time_ + 10ms.
@ -629,11 +629,11 @@ TEST_F(GraphTracerE2ETest, PassThroughGraphProfile) {
MP_EXPECT_OK(graph_.profiler()->GetCalculatorProfiles(&profiles));
EXPECT_EQ(1, profiles.size());
CalculatorProfile expected =
mediapipe::ParseTextProtoOrDie<CalculatorProfile>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorProfile>(R"pb(
name: "LambdaCalculator"
open_runtime: 0
close_runtime: 0
input_stream_profiles { name: "input_0" back_edge: false })");
input_stream_profiles { name: "input_0" back_edge: false })pb");
FillHistogram({20001, 20001, 20001, 20001, 20001, 20001},
expected.mutable_process_runtime());
@ -659,7 +659,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLog) {
absl::InfiniteFuture(), &trace);
GraphTrace node_timestamps = NodeTimestamps(trace);
EXPECT_THAT(node_timestamps,
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(R"pb(
calculator_trace { node_id: 1 input_timestamp: 10000 }
calculator_trace { node_id: 2 input_timestamp: 10000 }
calculator_trace { node_id: 3 input_timestamp: 10000 }
@ -805,7 +805,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLog) {
calculator_trace { node_id: 1 input_timestamp: 50001 }
calculator_trace { node_id: 1 input_timestamp: 10000 }
calculator_trace { node_id: 1 input_timestamp: 10000 }
)")));
)pb")));
// Validate a one-timestamp slice of the event trace.
GraphTrace trace_2;
@ -817,7 +817,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLog) {
EXPECT_THAT(
trace_2,
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(
R"(
R"pb(
base_time: 1544086800000000
base_timestamp: 10000
stream_name: ""
@ -986,7 +986,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLog) {
event_type: NOT_READY
start_time: 25005
}
)")));
)pb")));
}
// Read a GraphProfile from a file path.
@ -1047,7 +1047,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLogFiles) {
StripDataIds(&trace);
}
EXPECT_THAT(profile_2,
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphProfile>(R"(
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphProfile>(R"pb(
graph_trace {
base_time: 1544086800000000
base_timestamp: 0
@ -1233,7 +1233,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLogFiles) {
trace_enabled: true
}
}
)")));
)pb")));
}
TEST_F(GraphTracerE2ETest, DisableLoggingToDisk) {
@ -1295,7 +1295,7 @@ TEST_F(GraphTracerE2ETest, GpuTaskTrace) {
EXPECT_THAT(
trace_1,
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(
R"(
R"pb(
base_time: 1100
base_timestamp: 1000
stream_name: ""
@ -1324,7 +1324,7 @@ TEST_F(GraphTracerE2ETest, GpuTaskTrace) {
finish_time: 2100
thread_id: 0
}
)")));
)pb")));
GraphTrace trace_2;
builder.CreateLog(buffer, absl::InfinitePast(), absl::InfiniteFuture(),
@ -1332,7 +1332,7 @@ TEST_F(GraphTracerE2ETest, GpuTaskTrace) {
EXPECT_THAT(
trace_2,
EqualsProto(mediapipe::ParseTextProtoOrDie<GraphTrace>(
R"(
R"pb(
base_time: 1100
base_timestamp: 1000
stream_name: ""
@ -1368,7 +1368,7 @@ TEST_F(GraphTracerE2ETest, GpuTaskTrace) {
output_trace { packet_timestamp: 0 stream_id: 2 event_data: 0 }
thread_id: 0
}
)")));
)pb")));
}
// Show that trace_enabled activates the GlContextProfiler.

View File

@ -30,7 +30,7 @@ TEST(DefaultInputStreamHandlerTest, NoBatchingWorks) {
// A single calculator with two input streams, and two output streams. This
// calculator passes all the input packets along.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input0"
input_stream: "input1"
node {
@ -47,7 +47,7 @@ TEST(DefaultInputStreamHandlerTest, NoBatchingWorks) {
}
}
}
})");
})pb");
std::vector<Packet> sink_0, sink_1;
tool::AddVectorSink("output0", &config, &sink_0);
tool::AddVectorSink("output1", &config, &sink_1);
@ -88,7 +88,7 @@ TEST(DefaultInputStreamHandlerTest, Batches) {
// A single batching calculator with one input stream and one output stream.
// This calculator passes all the input packets onto the output streams.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input0"
node {
calculator: "PassThroughCalculator"
@ -102,7 +102,7 @@ TEST(DefaultInputStreamHandlerTest, Batches) {
}
}
}
})");
})pb");
std::vector<Packet> sink;
tool::AddVectorSink("output0", &config, &sink);
@ -152,7 +152,7 @@ TEST(DefaultInputStreamHandlerTest, BatchIsFlushedWhenClosing) {
// A single batching calculator with one input stream and one output stream.
// This calculator passes all the input packets onto the output streams.
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input0"
node {
calculator: "PassThroughCalculator"
@ -166,7 +166,7 @@ TEST(DefaultInputStreamHandlerTest, BatchIsFlushedWhenClosing) {
}
}
}
})");
})pb");
std::vector<Packet> sink;
tool::AddVectorSink("output0", &config, &sink);
@ -211,7 +211,7 @@ TEST(DefaultInputStreamHandlerTest, BatchIsFlushedWhenClosing) {
// batching except for the first timestamp of the batch.
TEST(DefaultInputStreamHandlerTest, DoesntPropagateTimestampWhenBatching) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input0"
input_stream: "input1"
node {
@ -233,7 +233,7 @@ TEST(DefaultInputStreamHandlerTest, DoesntPropagateTimestampWhenBatching) {
input_stream: "input1_batched"
output_stream: "output"
output_stream: "dummy"
})");
})pb");
std::vector<Packet> sink;
tool::AddVectorSink("output", &config, &sink);
CalculatorGraph graph;

View File

@ -149,7 +149,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPackets) {
// regulated by FixedSizeInputStreamHandler.
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(node {
R"pb(node {
calculator: "TestSourceCalculator"
output_stream: "input_packets"
}
@ -160,7 +160,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPackets) {
input_stream_handler {
input_stream_handler: "FixedSizeInputStreamHandler"
}
})");
})pb");
SetFixedMinSize(graph_config.mutable_node(1), GetParam());
std::vector<Packet> output_packets;
tool::AddVectorSink("output_packets", &graph_config, &output_packets);
@ -190,7 +190,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPacketsInFullStream) {
// CountingSourceCalculator will stay throttled and the test will time out.
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(max_queue_size: 10
R"pb(max_queue_size: 10
node {
calculator: "CountingSourceCalculator"
input_side_packet: "MAX_COUNT:max_count"
@ -204,7 +204,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPacketsInFullStream) {
input_stream_handler {
input_stream_handler: "FixedSizeInputStreamHandler"
}
})");
})pb");
SetFixedMinSize(graph_config.mutable_node(1), GetParam());
std::vector<Packet> output_packets;
tool::AddVectorSink("output_packets", &graph_config, &output_packets);
@ -220,7 +220,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPacketsInFullStream) {
TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "in_0"
input_stream: "in_1"
input_stream: "in_2"
@ -241,7 +241,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
}
}
}
})");
})pb");
SetFixedMinSize(graph_config.mutable_node(0), GetParam());
std::vector<Packet> output_packets[3];
for (int i = 0; i < 3; ++i) {
@ -289,7 +289,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
TEST_P(FixedSizeInputStreamHandlerTest, LateArrivalDrop) {
CalculatorGraphConfig graph_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "in_0"
input_stream: "in_1"
input_stream: "in_2"
@ -310,7 +310,7 @@ TEST_P(FixedSizeInputStreamHandlerTest, LateArrivalDrop) {
}
}
}
})");
})pb");
SetFixedMinSize(graph_config.mutable_node(0), GetParam());
std::vector<Packet> output_packets[3];
std::string in_streams[3];

View File

@ -28,7 +28,7 @@ namespace {
// MuxInputStreamHandler should fail when running this test.
TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input"
node {
calculator: "RoundRobinDemuxCalculator"
@ -75,7 +75,7 @@ TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
input_stream: "SELECT:select"
output_stream: "OUTPUT:output"
input_stream_handler { input_stream_handler: "MuxInputStreamHandler" }
})");
})pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.StartRun({}));

View File

@ -35,7 +35,7 @@ namespace {
// MuxInputStreamHandler should fail when running this test.
TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input"
node {
calculator: "RoundRobinDemuxCalculator"
@ -82,7 +82,7 @@ TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
input_stream: "SELECT:select"
output_stream: "OUTPUT:output"
# MuxInputStreamHandler set in GetContract().
})");
})pb");
CalculatorGraph graph;
MP_ASSERT_OK(graph.Initialize(config));
MP_ASSERT_OK(graph.StartRun({}));
@ -195,7 +195,7 @@ TEST(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
#define NUM_STREAMS 4
CalculatorGraphConfig graph_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "in_0"
input_stream: "in_1"
input_stream: "in_2"
@ -211,7 +211,7 @@ TEST(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
output_stream: "out_2"
output_stream: "out_3"
# FixedSizeInputStreamHandler set in GetContract()
})");
})pb");
std::vector<Packet> output_packets[NUM_STREAMS];
for (int i = 0; i < NUM_STREAMS; ++i) {
tool::AddVectorSink(absl::StrCat("out_", i), &graph_config,

View File

@ -84,7 +84,7 @@ absl::Status InputsToDebugString(const InputStreamShardSet& inputs,
TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) {
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(
R"(
R"pb(
input_stream: "a"
input_stream: "b"
input_stream: "c"
@ -123,7 +123,7 @@ TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) {
}
}
}
})");
})pb");
// The sync sets by stream name and CollectionItemId.
// {a, c, e}, {b, d}, {f}, {g}, {h}
// {0, 2, 4}, {1, 3}, {5}, {6}, {7}

View File

@ -26,7 +26,7 @@ namespace {
TEST(TimestampAlignInputStreamHandlerTest, Initialization) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_video"
input_stream: "input_camera"
node {
@ -43,7 +43,7 @@ TEST(TimestampAlignInputStreamHandlerTest, Initialization) {
}
}
}
})");
})pb");
std::vector<Packet> sink_video, sink_camera;
tool::AddVectorSink("output_video", &config, &sink_video);
tool::AddVectorSink("output_camera", &config, &sink_camera);
@ -121,7 +121,7 @@ TEST(TimestampAlignInputStreamHandlerTest, Initialization) {
TEST(TimestampAlignInputStreamHandlerTest, TickRate) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_video"
input_stream: "input_camera"
node {
@ -139,7 +139,7 @@ TEST(TimestampAlignInputStreamHandlerTest, TickRate) {
}
}
}
})");
})pb");
std::vector<Packet> sink_video, sink_camera;
tool::AddVectorSink("output_video", &config, &sink_video);
tool::AddVectorSink("output_camera", &config, &sink_camera);

View File

@ -110,13 +110,13 @@ REGISTER_MEDIAPIPE_GRAPH(EmitSideServiceStringTestSubgraph);
TEST(SubgraphServicesTest, EmitStringFromTestService) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
output_side_packet: "str"
node {
calculator: "EmitSideServiceStringTestSubgraph"
output_side_packet: "str"
}
)");
)pb");
Packet side_string;
tool::AddSidePacketSink("str", &config, &side_string);

View File

@ -22,15 +22,16 @@
namespace mediapipe {
TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeUnspecified) {
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
CalculatorGraphConfig config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
executor {
options {
[mediapipe.ThreadPoolExecutorOptions.ext] { num_threads: 2 }
}
}
)");
)pb");
CalculatorGraphConfig expected_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
executor {
options {
[mediapipe.ThreadPoolExecutorOptions.ext] {
@ -39,13 +40,14 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeUnspecified) {
}
}
}
)");
)pb");
tool::EnsureMinimumDefaultExecutorStackSize(131072, &config);
EXPECT_THAT(config, EqualsProto(expected_config));
}
TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeTooSmall) {
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
CalculatorGraphConfig config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
executor {
options {
[mediapipe.ThreadPoolExecutorOptions.ext] {
@ -54,9 +56,9 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeTooSmall) {
}
}
}
)");
)pb");
CalculatorGraphConfig expected_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
executor {
options {
[mediapipe.ThreadPoolExecutorOptions.ext] {
@ -65,13 +67,14 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeTooSmall) {
}
}
}
)");
)pb");
tool::EnsureMinimumDefaultExecutorStackSize(131072, &config);
EXPECT_THAT(config, EqualsProto(expected_config));
}
TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeLargeEnough) {
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
CalculatorGraphConfig config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
executor {
options {
[mediapipe.ThreadPoolExecutorOptions.ext] {
@ -80,9 +83,9 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeLargeEnough) {
}
}
}
)");
)pb");
CalculatorGraphConfig expected_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
executor {
options {
[mediapipe.ThreadPoolExecutorOptions.ext] {
@ -91,17 +94,18 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeExistingConfigSizeLargeEnough) {
}
}
}
)");
)pb");
tool::EnsureMinimumDefaultExecutorStackSize(131072, &config);
EXPECT_THAT(config, EqualsProto(expected_config));
}
TEST(GraphTest, MinimumDefaultExecutorStackSizeNumThreads) {
CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
CalculatorGraphConfig config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
num_threads: 1
)");
)pb");
CalculatorGraphConfig expected_config =
ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
executor {
options {
[mediapipe.ThreadPoolExecutorOptions.ext] {
@ -110,7 +114,7 @@ TEST(GraphTest, MinimumDefaultExecutorStackSizeNumThreads) {
}
}
}
)");
)pb");
tool::EnsureMinimumDefaultExecutorStackSize(131072, &config);
EXPECT_THAT(config, EqualsProto(expected_config));
}

View File

@ -43,7 +43,7 @@ namespace {
class SimulationClockTest : public ::testing::Test {
protected:
void SetUpInFlightGraph() {
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
graph_config_ = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_packets_0"
node {
calculator: 'FlowLimiterCalculator'
@ -84,7 +84,7 @@ class SimulationClockTest : public ::testing::Test {
output_stream: 'output_packets_0'
output_stream: 'finish_indicator'
}
)");
)pb");
}
// Initialize the test clock as a SimulationClock.
@ -246,7 +246,7 @@ TEST_F(SimulationClockTest, InFlight) {
// and SimulationClock. With tsan, this test reveals a race condition unless
// the SimulationClock destructor calls ThreadFinish to waits for all threads.
TEST_F(SimulationClockTest, DestroyClock) {
auto graph_config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
auto graph_config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "LambdaCalculator"
input_side_packet: 'callback_0'
@ -258,7 +258,7 @@ TEST_F(SimulationClockTest, DestroyClock) {
input_stream: "input_1"
output_stream: "output_1"
}
)");
)pb");
int input_count = 0;
ProcessFunction wait_0 = [&](const InputStreamShardSet& inputs,

View File

@ -75,14 +75,14 @@ TEST(CallbackFromGeneratorTest, TestAddVectorSink) {
TEST(CalculatorGraph, OutputSummarySidePacketInClose) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_packets"
node {
calculator: "CountAndOutputSummarySidePacketInCloseCalculator"
input_stream: "input_packets"
output_side_packet: "num_of_packets"
}
)");
)pb");
Packet summary_packet;
tool::AddSidePacketSink("num_of_packets", &config, &summary_packet);

View File

@ -71,7 +71,7 @@ class TestSubgraph : public Subgraph {
absl::StatusOr<CalculatorGraphConfig> GetConfig(
const SubgraphOptions& /*options*/) override {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "DATA:input_1"
node {
name: "regular_node"
@ -89,7 +89,7 @@ class TestSubgraph : public Subgraph {
packet_generator: "SomePacketGenerator"
output_side_packet: "side"
}
)");
)pb");
return config;
}
};
@ -100,7 +100,7 @@ class PacketFactoryTestSubgraph : public Subgraph {
absl::StatusOr<CalculatorGraphConfig> GetConfig(
const SubgraphOptions& /*options*/) override {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "DATA:input_1"
node {
name: "regular_node"
@ -118,7 +118,7 @@ class PacketFactoryTestSubgraph : public Subgraph {
packet_factory: "SomePacketFactory"
output_side_packet: "side"
}
)");
)pb");
return config;
}
};
@ -157,7 +157,7 @@ class NodeWithExecutorSubgraph : public Subgraph {
absl::StatusOr<CalculatorGraphConfig> GetConfig(
const SubgraphOptions& options) override {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "INPUT:foo"
output_stream: "OUTPUT:bar"
node {
@ -166,7 +166,7 @@ class NodeWithExecutorSubgraph : public Subgraph {
output_stream: "bar"
executor: "custom_thread_pool"
}
)");
)pb");
return config;
}
};
@ -179,7 +179,7 @@ class EnclosingSubgraph : public Subgraph {
absl::StatusOr<CalculatorGraphConfig> GetConfig(
const SubgraphOptions& options) override {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "IN:in"
output_stream: "OUT:out"
node {
@ -187,7 +187,7 @@ class EnclosingSubgraph : public Subgraph {
input_stream: "INPUT:in"
output_stream: "OUTPUT:out"
}
)");
)pb");
return config;
}
};
@ -195,7 +195,7 @@ REGISTER_MEDIAPIPE_GRAPH(EnclosingSubgraph);
TEST(SubgraphExpansionTest, TransformStreamNames) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "SomeSinkCalculator"
input_stream: "input_1"
@ -203,9 +203,9 @@ TEST(SubgraphExpansionTest, TransformStreamNames) {
input_stream: "AUDIO:0:input_3"
input_stream: "AUDIO:1:input_4"
}
)");
)pb");
CalculatorGraphConfig expected_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "SomeSinkCalculator"
input_stream: "input_1_foo"
@ -213,7 +213,7 @@ TEST(SubgraphExpansionTest, TransformStreamNames) {
input_stream: "AUDIO:0:input_3_foo"
input_stream: "AUDIO:1:input_4_foo"
}
)");
)pb");
auto add_foo = [](absl::string_view s) { return absl::StrCat(s, "_foo"); };
MP_EXPECT_OK(tool::TransformStreamNames(
(*config.mutable_node())[0].mutable_input_stream(), add_foo));
@ -222,7 +222,7 @@ TEST(SubgraphExpansionTest, TransformStreamNames) {
TEST(SubgraphExpansionTest, TransformNames) {
CalculatorGraphConfig config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_1"
node {
calculator: "SomeRegularCalculator"
@ -238,9 +238,9 @@ TEST(SubgraphExpansionTest, TransformNames) {
input_stream: "output_1"
output_stream: "output_2"
}
)");
)pb");
CalculatorGraphConfig expected_config =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "__sg0_input_1"
node {
calculator: "SomeRegularCalculator"
@ -257,7 +257,7 @@ TEST(SubgraphExpansionTest, TransformNames) {
input_stream: "__sg0_output_1"
output_stream: "__sg0_output_2"
}
)");
)pb");
auto add_prefix = [](absl::string_view s) {
return absl::StrCat("__sg0_", s);
};
@ -267,14 +267,14 @@ TEST(SubgraphExpansionTest, TransformNames) {
TEST(SubgraphExpansionTest, FindCorrespondingStreams) {
CalculatorGraphConfig config1 =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_1"
input_stream: "VIDEO:input_2"
input_stream: "AUDIO:0:input_3"
input_stream: "AUDIO:1:input_4"
)");
)pb");
CalculatorGraphConfig config2 =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "SomeSubgraph"
input_stream: "foo"
@ -282,7 +282,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreams) {
input_stream: "AUDIO:0:baz"
input_stream: "AUDIO:1:qux"
}
)");
)pb");
std::map<std::string, std::string> stream_map;
MP_EXPECT_OK(tool::FindCorrespondingStreams(
&stream_map, config1.input_stream(), config2.node()[0].input_stream()));
@ -296,13 +296,13 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreams) {
TEST(SubgraphExpansionTest, FindCorrespondingStreamsNonexistentTag) {
// The VIDEO tag does not exist in the subgraph.
CalculatorGraphConfig config1 =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_1"
input_stream: "AUDIO:0:input_3"
input_stream: "AUDIO:1:input_4"
)");
)pb");
CalculatorGraphConfig config2 =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "SomeSubgraph"
input_stream: "foo"
@ -310,7 +310,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreamsNonexistentTag) {
input_stream: "AUDIO:0:baz"
input_stream: "AUDIO:1:qux"
}
)");
)pb");
std::map<std::string, std::string> stream_map;
auto status = tool::FindCorrespondingStreams(
&stream_map, config1.input_stream(), config2.node()[0].input_stream());
@ -326,13 +326,13 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreamsNonexistentTag) {
TEST(SubgraphExpansionTest, FindCorrespondingStreamsTooFewIndexes) {
// The AUDIO tag has too few indexes in the subgraph (1 vs. 2).
CalculatorGraphConfig config1 =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input_1"
input_stream: "VIDEO:input_2"
input_stream: "AUDIO:0:input_3"
)");
)pb");
CalculatorGraphConfig config2 =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "SomeSubgraph"
input_stream: "foo"
@ -340,7 +340,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreamsTooFewIndexes) {
input_stream: "AUDIO:0:baz"
input_stream: "AUDIO:1:qux"
}
)");
)pb");
std::map<std::string, std::string> stream_map;
auto status = tool::FindCorrespondingStreams(
&stream_map, config1.input_stream(), config2.node()[0].input_stream());
@ -355,7 +355,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreamsTooFewIndexes) {
TEST(SubgraphExpansionTest, ConnectSubgraphStreams) {
CalculatorGraphConfig subgraph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "A:input_1"
input_stream: "B:input_2"
output_stream: "O:output_2"
@ -379,9 +379,9 @@ TEST(SubgraphExpansionTest, ConnectSubgraphStreams) {
input_side_packet: "side_input"
output_side_packet: "side_output"
}
)");
)pb");
CalculatorGraphConfig supergraph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
calculator: "SomeSubgraph"
input_stream: "A:foo"
@ -390,11 +390,11 @@ TEST(SubgraphExpansionTest, ConnectSubgraphStreams) {
input_side_packet: "SI:flip"
output_side_packet: "SO:flop"
}
)");
)pb");
// Note: graph input streams, output streams, and side packets on the
// subgraph are not changed because they are going to be discarded anyway.
CalculatorGraphConfig expected_subgraph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "A:input_1"
input_stream: "B:input_2"
output_stream: "O:output_2"
@ -418,23 +418,23 @@ TEST(SubgraphExpansionTest, ConnectSubgraphStreams) {
input_side_packet: "flip"
output_side_packet: "flop"
}
)");
)pb");
MP_EXPECT_OK(tool::ConnectSubgraphStreams(supergraph.node()[0], &subgraph));
EXPECT_THAT(subgraph, mediapipe::EqualsProto(expected_subgraph));
}
TEST(SubgraphExpansionTest, ExpandSubgraphs) {
CalculatorGraphConfig supergraph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
name: "simple_source"
calculator: "SomeSourceCalculator"
output_stream: "foo"
}
node { calculator: "TestSubgraph" input_stream: "DATA:foo" }
)");
)pb");
CalculatorGraphConfig expected_graph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
name: "simple_source"
calculator: "SomeSourceCalculator"
@ -456,14 +456,14 @@ TEST(SubgraphExpansionTest, ExpandSubgraphs) {
packet_generator: "SomePacketGenerator"
output_side_packet: "testsubgraph__side"
}
)");
)pb");
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
}
TEST(SubgraphExpansionTest, ValidateSubgraphFields) {
CalculatorGraphConfig supergraph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
name: "simple_source"
calculator: "SomeSourceCalculator"
@ -475,7 +475,7 @@ TEST(SubgraphExpansionTest, ValidateSubgraphFields) {
input_stream: "DATA:foo"
buffer_size_hint: -1 # This field is only applicable to calculators.
}
)");
)pb");
absl::Status s1 = tool::ValidateSubgraphFields(supergraph.node(1));
EXPECT_EQ(s1.code(), absl::StatusCode::kInvalidArgument);
EXPECT_THAT(s1.message(), testing::HasSubstr("foo_subgraph"));
@ -491,7 +491,7 @@ TEST(SubgraphExpansionTest, ValidateSubgraphFields) {
// subgraph executor support in the future.
TEST(SubgraphExpansionTest, ExecutorFieldOfNodeInSubgraphPreserved) {
CalculatorGraphConfig supergraph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "input"
executor {
name: "custom_thread_pool"
@ -505,9 +505,9 @@ TEST(SubgraphExpansionTest, ExecutorFieldOfNodeInSubgraphPreserved) {
input_stream: "IN:input"
output_stream: "OUT:output"
}
)");
)pb");
CalculatorGraphConfig expected_graph = mediapipe::ParseTextProtoOrDie<
CalculatorGraphConfig>(R"(
CalculatorGraphConfig>(R"pb(
input_stream: "input"
executor {
name: "custom_thread_pool"
@ -523,7 +523,7 @@ TEST(SubgraphExpansionTest, ExecutorFieldOfNodeInSubgraphPreserved) {
output_stream: "output"
executor: "custom_thread_pool"
}
)");
)pb");
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
}
@ -545,17 +545,17 @@ REGISTER_MEDIAPIPE_GRAPH(GraphServicesClientTestSubgraph);
TEST(SubgraphExpansionTest, GraphServicesUsage) {
CalculatorGraphConfig supergraph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node { calculator: "GraphServicesClientTestSubgraph" }
)");
)pb");
CalculatorGraphConfig expected_graph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
name: "graphservicesclienttestsubgraph__ExpectedNode"
calculator: "ExpectedNode"
}
)");
)pb");
GraphServiceManager service_manager;
MP_ASSERT_OK(service_manager.SetServiceObject(
kStringTestService, std::make_shared<std::string>("ExpectedNode")));

View File

@ -67,7 +67,7 @@ REGISTER_CALCULATOR(TripleIntCalculator);
// Note that the input and output tags supplied to the container node,
// must match the input and output tags required by the subnodes.
CalculatorGraphConfig SubnodeContainerExample() {
return mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
return mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_stream: "foo"
input_stream: "enable"
input_side_packet: "timezone"
@ -90,14 +90,14 @@ CalculatorGraphConfig SubnodeContainerExample() {
output_stream: "output_foo"
output_stream: "output_bar"
}
)");
)pb");
}
// A testing example of a SwitchContainer containing two subnodes.
// Note that the side-input and side-output tags supplied to the container node,
// must match the side-input and side-output tags required by the subnodes.
CalculatorGraphConfig SideSubnodeContainerExample() {
return mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
return mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_side_packet: "foo"
input_side_packet: "enable"
output_side_packet: "output_bar"
@ -120,7 +120,7 @@ CalculatorGraphConfig SideSubnodeContainerExample() {
output_side_packet: "output_foo"
output_side_packet: "output_bar"
}
)");
)pb");
}
// Runs the test container graph with a few input packets.
@ -217,7 +217,7 @@ TEST(SwitchContainerTest, ApplyToSubnodes) {
EXPECT_TRUE(SubgraphRegistry::IsRegistered("SwitchContainer"));
CalculatorGraphConfig supergraph = SubnodeContainerExample();
CalculatorGraphConfig expected_graph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
node {
name: "switchcontainer__SwitchDemuxCalculator"
calculator: "SwitchDemuxCalculator"
@ -256,7 +256,7 @@ TEST(SwitchContainerTest, ApplyToSubnodes) {
input_stream: "foo"
input_stream: "enable"
input_side_packet: "timezone"
)");
)pb");
expected_graph = OrderNodes(expected_graph, {4, 0, 3, 1, 2});
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
@ -275,7 +275,7 @@ TEST(SwitchContainerTest, ApplyToSideSubnodes) {
EXPECT_TRUE(SubgraphRegistry::IsRegistered("SwitchContainer"));
CalculatorGraphConfig supergraph = SideSubnodeContainerExample();
CalculatorGraphConfig expected_graph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_side_packet: "foo"
input_side_packet: "enable"
output_side_packet: "output_bar"
@ -314,7 +314,7 @@ TEST(SwitchContainerTest, ApplyToSideSubnodes) {
output_side_packet: "output_foo"
output_side_packet: "output_bar"
}
)");
)pb");
expected_graph = OrderNodes(expected_graph, {4, 0, 3, 1, 2});
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
@ -332,7 +332,7 @@ TEST(SwitchContainerTest, RunWithSideSubnodes) {
TEST(SwitchContainerTest, ValidateSideInputs) {
EXPECT_TRUE(SubgraphRegistry::IsRegistered("SwitchContainer"));
CalculatorGraphConfig supergraph =
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
input_side_packet: "foo"
input_side_packet: "enable"
output_side_packet: "output_bar"
@ -356,7 +356,7 @@ TEST(SwitchContainerTest, ValidateSideInputs) {
output_side_packet: "output_foo"
output_side_packet: "output_bar"
}
)");
)pb");
auto status = tool::ExpandSubgraphs(&supergraph);
EXPECT_EQ(std::pair(status.code(), std::string(status.message())),
std::pair(absl::StatusCode::kInvalidArgument,

View File

@ -51,6 +51,7 @@ absl::Status GlContext::CreateContextInternal(
CHECK(webgl_version == 1 || webgl_version == 2);
EmscriptenWebGLContextAttributes attrs;
emscripten_webgl_init_context_attributes(&attrs);
attrs.explicitSwapControl = 0;
attrs.depth = 1;
attrs.stencil = 0;

View File

@ -59,9 +59,10 @@ void RegisterNativesVector(JNIEnv *env, jclass cls,
const std::vector<JNINativeMethodStrings> &methods) {
// A client Java project may not use some methods and classes that we attempt
// to register and could be removed by Proguard. In that case, we want to
// avoid triggering a crash due to ClassNotFoundException, so we are trading
// safety check here in exchange for flexibility to list out all registrations
// without worrying about usage subset by client Java projects.
// avoid triggering a crash due to ClassNotFoundException triggered by
// failure of env->FindClass() calls. We are trading safety check here in
// in exchange for flexibility to list out all registrations without worrying
// about usage subset by client Java projects.
if (!cls || methods.empty()) {
LOG(INFO) << "Skipping registration and clearing exception. Class or "
"native methods not found, may be unused and/or trimmed by "
@ -77,7 +78,14 @@ void RegisterNativesVector(JNIEnv *env, jclass cls,
const_cast<char *>(methods[i].signature.c_str()), methods[i].fnPtr};
methods_array[i] = jniNativeMethod;
}
env->RegisterNatives(cls, methods_array, methods.size());
// Fatal crash if registration fails.
if (env->RegisterNatives(cls, methods_array, methods.size()) < 0) {
LOG(FATAL)
<< "Failed during native method registration, so likely the "
"signature of a method is incorrect. Make sure there are no typos "
"and "
"that symbols used in the signature have not been re-obfuscated.";
}
delete[] methods_array;
}
@ -106,7 +114,7 @@ void RegisterGraphNatives(JNIEnv *env) {
std::string packet_list_callback_name = class_registry.GetClassName(
mediapipe::android::ClassRegistry::kPacketListCallbackClassName);
std::string native_add_multi_stream_callback_signature =
absl::StrFormat("(JLjava/lang/List;L%s;)V", packet_list_callback_name);
absl::StrFormat("(JLjava/util/List;L%s;)V", packet_list_callback_name);
AddJNINativeMethod(&graph_methods, graph, "nativeAddMultiStreamCallback",
native_add_multi_stream_callback_signature.c_str(),
(void *)&GRAPH_METHOD(nativeAddMultiStreamCallback));

View File

@ -19,6 +19,9 @@ cc_library(
srcs = ["util.cc"],
hdrs = ["util.h"],
features = ["-parse_headers"],
linkopts = [
"-framework Accelerate",
],
visibility = ["//mediapipe/framework:mediapipe_internal"],
deps = [
":CFHolder",

View File

@ -397,7 +397,6 @@ void CalculatorGraphSubmodule(pybind11::module* module) {
pybind11::function callback_fn) {
RaisePyErrorIfNotOk(self->ObserveOutputStream(
stream_name, [callback_fn, stream_name](const Packet& packet) {
// Acquire a mutex so that only one callback_fn can run at once.
absl::MutexLock lock(&callback_mutex);
callback_fn(stream_name, packet);
return absl::OkStatus();

View File

@ -87,6 +87,7 @@ class _PacketDataType(enum.Enum):
BOOL_LIST = 'bool_list'
INT = 'int'
FLOAT = 'float'
FLOAT_LIST = 'float_list'
AUDIO = 'matrix'
IMAGE = 'image_frame'
PROTO = 'proto'
@ -108,6 +109,8 @@ NAME_TO_TYPE: Mapping[str, '_PacketDataType'] = {
_PacketDataType.INT,
'float':
_PacketDataType.FLOAT,
'::std::vector<float>':
_PacketDataType.FLOAT_LIST,
'::mediapipe::Matrix':
_PacketDataType.AUDIO,
'::mediapipe::ImageFrame':