Skip to content

Commit 89a1681

Browse files
Debaditya SenDebaditya Sen
Debaditya Sen
authored and
Debaditya Sen
committed
working_AUG1_1
1 parent 6a0ce1a commit 89a1681

File tree

213 files changed

+540
-50558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+540
-50558
lines changed

.eclipse/projects/mediapipe.graphs.object_detection_3d.obj_parser:obj_parser_lib/bin/.project

-11
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,4 @@
2020
<nature>org.eclipse.jdt.core.javanature</nature>
2121
<nature>com.salesforce.bazel.eclipse.core.bazelnature</nature>
2222
</natures>
23-
<filteredResources>
24-
<filter>
25-
<id>1719489568429</id>
26-
<name></name>
27-
<type>30</type>
28-
<matcher>
29-
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30-
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31-
</matcher>
32-
</filter>
33-
</filteredResources>
3423
</projectDescription>

.vscode/settings.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@
101101
"stack": "cpp",
102102
"valarray": "cpp",
103103
"*.ipp": "cpp",
104-
"slist": "cpp"
104+
"slist": "cpp",
105+
"shared_mutex": "cpp",
106+
"__mutex_base": "cpp"
105107
},
106108
"java.compile.nullAnalysis.mode": "automatic",
107109
"java.completion.favoriteStaticMembers": [

mediapipe/calculators/core/bypass_calculator_test.cc

+146-134
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
#include "mediapipe/framework/port/status.h"
2626
#include "mediapipe/framework/port/status_matchers.h"
2727

28-
namespace mediapipe {
28+
namespace mediapipe
29+
{
2930

30-
namespace {
31+
namespace
32+
{
3133

32-
// A graph with using a BypassCalculator to pass through and ignore
33-
// most of its inputs and outputs.
34-
constexpr char kTestGraphConfig1[] = R"pb(
34+
// A graph with using a BypassCalculator to pass through and ignore
35+
// most of its inputs and outputs.
36+
constexpr char kTestGraphConfig1[] = R"pb(
3537
type: "AppearancesPassThroughSubgraph"
3638
input_stream: "APPEARANCES:appearances"
3739
input_stream: "VIDEO:video_frame"
@@ -55,9 +57,9 @@ constexpr char kTestGraphConfig1[] = R"pb(
5557
}
5658
)pb";
5759

58-
// A graph with using AppearancesPassThroughSubgraph as a do-nothing channel
59-
// for input frames and appearances.
60-
constexpr char kTestGraphConfig2[] = R"pb(
60+
// A graph with using AppearancesPassThroughSubgraph as a do-nothing channel
61+
// for input frames and appearances.
62+
constexpr char kTestGraphConfig2[] = R"pb(
6163
input_stream: "VIDEO_FULL_RES:video_frame"
6264
input_stream: "APPEARANCES:input_appearances"
6365
input_stream: "FEATURE_CONFIG:feature_config"
@@ -82,9 +84,9 @@ constexpr char kTestGraphConfig2[] = R"pb(
8284
}
8385
)pb";
8486

85-
// A graph with using BypassCalculator as a do-nothing channel
86-
// for input frames and appearances.
87-
constexpr char kTestGraphConfig3[] = R"pb(
87+
// A graph with using BypassCalculator as a do-nothing channel
88+
// for input frames and appearances.
89+
constexpr char kTestGraphConfig3[] = R"pb(
8890
input_stream: "VIDEO_FULL_RES:video_frame"
8991
input_stream: "APPEARANCES:input_appearances"
9092
input_stream: "FEATURE_CONFIG:feature_config"
@@ -117,9 +119,9 @@ constexpr char kTestGraphConfig3[] = R"pb(
117119
}
118120
)pb";
119121

120-
// A graph with using BypassCalculator as a disabled-gate
121-
// for input frames and appearances.
122-
constexpr char kTestGraphConfig4[] = R"pb(
122+
// A graph with using BypassCalculator as a disabled-gate
123+
// for input frames and appearances.
124+
constexpr char kTestGraphConfig4[] = R"pb(
123125
input_stream: "VIDEO_FULL_RES:video_frame"
124126
input_stream: "APPEARANCES:input_appearances"
125127
input_stream: "FEATURE_CONFIG:feature_config"
@@ -145,127 +147,137 @@ constexpr char kTestGraphConfig4[] = R"pb(
145147
}
146148
)pb";
147149

148-
// Reports packet timestamp and string contents, or "<empty>"".
149-
std::string DebugString(Packet p) {
150-
return absl::StrCat(p.Timestamp().DebugString(), ":",
151-
p.IsEmpty() ? "<empty>" : p.Get<std::string>());
152-
}
153-
154-
// Shows a bypass subgraph that passes through one stream.
155-
TEST(BypassCalculatorTest, SubgraphChannel) {
156-
CalculatorGraphConfig config_1 =
157-
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(kTestGraphConfig1);
158-
CalculatorGraphConfig config_2 =
159-
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(kTestGraphConfig2);
160-
CalculatorGraph graph;
161-
MP_ASSERT_OK(graph.Initialize({config_1, config_2}, {}));
162-
163-
std::vector<std::string> analyzed_appearances;
164-
MP_ASSERT_OK(graph.ObserveOutputStream(
165-
"analyzed_appearances",
166-
[&](const Packet& p) {
167-
analyzed_appearances.push_back(DebugString(p));
168-
return absl::OkStatus();
169-
},
170-
true));
171-
std::vector<std::string> federated_gaze_output;
172-
MP_ASSERT_OK(graph.ObserveOutputStream(
173-
"federated_gaze_output",
174-
[&](const Packet& p) {
175-
federated_gaze_output.push_back(DebugString(p));
176-
return absl::OkStatus();
177-
},
178-
true));
179-
MP_ASSERT_OK(graph.StartRun({}));
180-
181-
MP_ASSERT_OK(graph.AddPacketToInputStream(
182-
"input_appearances", MakePacket<std::string>("a1").At(Timestamp(200))));
183-
MP_ASSERT_OK(graph.AddPacketToInputStream(
184-
"video_frame", MakePacket<std::string>("v1").At(Timestamp(200))));
185-
MP_ASSERT_OK(graph.AddPacketToInputStream(
186-
"feature_config", MakePacket<std::string>("f1").At(Timestamp(200))));
187-
MP_ASSERT_OK(graph.WaitUntilIdle());
188-
189-
EXPECT_THAT(analyzed_appearances, testing::ElementsAre("200:a1"));
190-
EXPECT_THAT(federated_gaze_output, testing::ElementsAre("200:<empty>"));
191-
192-
MP_ASSERT_OK(graph.CloseAllInputStreams());
193-
MP_ASSERT_OK(graph.WaitUntilDone());
194-
}
195-
196-
// Shows a BypassCalculator that passes through one stream.
197-
TEST(BypassCalculatorTest, CalculatorChannel) {
198-
CalculatorGraphConfig config_3 =
199-
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(kTestGraphConfig3);
200-
CalculatorGraph graph;
201-
MP_ASSERT_OK(graph.Initialize({config_3}, {}));
202-
203-
std::vector<std::string> analyzed_appearances;
204-
MP_ASSERT_OK(graph.ObserveOutputStream(
205-
"analyzed_appearances",
206-
[&](const Packet& p) {
207-
analyzed_appearances.push_back(DebugString(p));
208-
return absl::OkStatus();
209-
},
210-
true));
211-
std::vector<std::string> federated_gaze_output;
212-
MP_ASSERT_OK(graph.ObserveOutputStream(
213-
"federated_gaze_output",
214-
[&](const Packet& p) {
215-
federated_gaze_output.push_back(DebugString(p));
216-
return absl::OkStatus();
217-
},
218-
true));
219-
MP_ASSERT_OK(graph.StartRun({}));
220-
221-
MP_ASSERT_OK(graph.AddPacketToInputStream(
222-
"input_appearances", MakePacket<std::string>("a1").At(Timestamp(200))));
223-
MP_ASSERT_OK(graph.AddPacketToInputStream(
224-
"video_frame", MakePacket<std::string>("v1").At(Timestamp(200))));
225-
MP_ASSERT_OK(graph.AddPacketToInputStream(
226-
"feature_config", MakePacket<std::string>("f1").At(Timestamp(200))));
227-
MP_ASSERT_OK(graph.WaitUntilIdle());
150+
// Reports packet timestamp and string contents, or "<empty>"".
151+
std::string DebugString(Packet p)
152+
{
153+
return absl::StrCat(p.Timestamp().DebugString(), ":",
154+
p.IsEmpty() ? "<empty>" : p.Get<std::string>());
155+
}
228156

229-
EXPECT_THAT(analyzed_appearances, testing::ElementsAre("200:a1"));
230-
EXPECT_THAT(federated_gaze_output, testing::ElementsAre("200:<empty>"));
157+
// Shows a bypass subgraph that passes through one stream.
158+
TEST(BypassCalculatorTest, SubgraphChannel)
159+
{
160+
CalculatorGraphConfig config_1 =
161+
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(kTestGraphConfig1);
162+
CalculatorGraphConfig config_2 =
163+
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(kTestGraphConfig2);
164+
CalculatorGraph graph;
165+
MP_ASSERT_OK(graph.Initialize({config_1, config_2}, {}));
166+
167+
std::vector<std::string> analyzed_appearances;
168+
MP_ASSERT_OK(graph.ObserveOutputStream(
169+
"analyzed_appearances",
170+
[&](const Packet &p)
171+
{
172+
analyzed_appearances.push_back(DebugString(p));
173+
return absl::OkStatus();
174+
},
175+
true));
176+
std::vector<std::string> federated_gaze_output;
177+
MP_ASSERT_OK(graph.ObserveOutputStream(
178+
"federated_gaze_output",
179+
[&](const Packet &p)
180+
{
181+
federated_gaze_output.push_back(DebugString(p));
182+
return absl::OkStatus();
183+
},
184+
true));
185+
MP_ASSERT_OK(graph.StartRun({}));
186+
187+
MP_ASSERT_OK(graph.AddPacketToInputStream(
188+
"input_appearances", MakePacket<std::string>("a1").At(Timestamp(200))));
189+
MP_ASSERT_OK(graph.AddPacketToInputStream(
190+
"video_frame", MakePacket<std::string>("v1").At(Timestamp(200))));
191+
MP_ASSERT_OK(graph.AddPacketToInputStream(
192+
"feature_config", MakePacket<std::string>("f1").At(Timestamp(200))));
193+
MP_ASSERT_OK(graph.WaitUntilIdle());
194+
195+
EXPECT_THAT(analyzed_appearances, testing::ElementsAre("200:a1"));
196+
EXPECT_THAT(federated_gaze_output, testing::ElementsAre("200:<empty>"));
197+
198+
MP_ASSERT_OK(graph.CloseAllInputStreams());
199+
MP_ASSERT_OK(graph.WaitUntilDone());
200+
}
231201

232-
MP_ASSERT_OK(graph.CloseAllInputStreams());
233-
MP_ASSERT_OK(graph.WaitUntilDone());
234-
}
235-
236-
// Shows a BypassCalculator that discards all inputs when ENABLED is false.
237-
TEST(BypassCalculatorTest, GatedChannel) {
238-
CalculatorGraphConfig config_3 =
239-
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(kTestGraphConfig4);
240-
CalculatorGraph graph;
241-
MP_ASSERT_OK(graph.Initialize({config_3}, {}));
242-
243-
std::vector<std::string> analyzed_appearances;
244-
MP_ASSERT_OK(graph.ObserveOutputStream(
245-
"analyzed_appearances",
246-
[&](const Packet& p) {
247-
analyzed_appearances.push_back(DebugString(p));
248-
return absl::OkStatus();
249-
},
250-
true));
251-
std::vector<std::string> video_frame;
252-
MP_ASSERT_OK(graph.ObserveOutputStream(
253-
"video_frame_out",
254-
[&](const Packet& p) {
255-
video_frame.push_back(DebugString(p));
256-
return absl::OkStatus();
257-
},
258-
true));
259-
MP_ASSERT_OK(graph.StartRun({}));
260-
261-
// Close the gate.
262-
MP_ASSERT_OK(graph.AddPacketToInputStream(
263-
"gaze_enabled", MakePacket<bool>(false).At(Timestamp(200))));
264-
MP_ASSERT_OK(graph.WaitUntilIdle());
202+
// Shows a BypassCalculator that passes through one stream.
203+
TEST(BypassCalculatorTest, CalculatorChannel)
204+
{
205+
CalculatorGraphConfig config_3 =
206+
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(kTestGraphConfig3);
207+
CalculatorGraph graph;
208+
MP_ASSERT_OK(graph.Initialize({config_3}, {}));
209+
210+
std::vector<std::string> analyzed_appearances;
211+
MP_ASSERT_OK(graph.ObserveOutputStream(
212+
"analyzed_appearances",
213+
[&](const Packet &p)
214+
{
215+
analyzed_appearances.push_back(DebugString(p));
216+
return absl::OkStatus();
217+
},
218+
true));
219+
std::vector<std::string> federated_gaze_output;
220+
MP_ASSERT_OK(graph.ObserveOutputStream(
221+
"federated_gaze_output",
222+
[&](const Packet &p)
223+
{
224+
federated_gaze_output.push_back(DebugString(p));
225+
return absl::OkStatus();
226+
},
227+
true));
228+
MP_ASSERT_OK(graph.StartRun({}));
229+
230+
MP_ASSERT_OK(graph.AddPacketToInputStream(
231+
"input_appearances", MakePacket<std::string>("a1").At(Timestamp(200))));
232+
MP_ASSERT_OK(graph.AddPacketToInputStream(
233+
"video_frame", MakePacket<std::string>("v1").At(Timestamp(200))));
234+
MP_ASSERT_OK(graph.AddPacketToInputStream(
235+
"feature_config", MakePacket<std::string>("f1").At(Timestamp(200))));
236+
MP_ASSERT_OK(graph.WaitUntilIdle());
237+
238+
EXPECT_THAT(analyzed_appearances, testing::ElementsAre("200:a1"));
239+
EXPECT_THAT(federated_gaze_output, testing::ElementsAre("200:<empty>"));
240+
241+
MP_ASSERT_OK(graph.CloseAllInputStreams());
242+
MP_ASSERT_OK(graph.WaitUntilDone());
243+
}
265244

266-
// Send packets at timestamp 200.
245+
// Shows a BypassCalculator that discards all inputs when ENABLED is false.
246+
TEST(BypassCalculatorTest, GatedChannel)
247+
{
248+
CalculatorGraphConfig config_3 =
249+
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(kTestGraphConfig4);
250+
CalculatorGraph graph;
251+
MP_ASSERT_OK(graph.Initialize({config_3}, {}));
252+
253+
std::vector<std::string> analyzed_appearances;
254+
MP_ASSERT_OK(graph.ObserveOutputStream(
255+
"analyzed_appearances",
256+
[&](const Packet &p)
257+
{
258+
analyzed_appearances.push_back(DebugString(p));
259+
return absl::OkStatus();
260+
},
261+
true));
262+
std::vector<std::string> video_frame;
263+
MP_ASSERT_OK(graph.ObserveOutputStream(
264+
"video_frame_out",
265+
[&](const Packet &p)
266+
{
267+
video_frame.push_back(DebugString(p));
268+
return absl::OkStatus();
269+
},
270+
true));
271+
MP_ASSERT_OK(graph.StartRun({}));
272+
273+
// Close the gate.
274+
MP_ASSERT_OK(graph.AddPacketToInputStream(
275+
"gaze_enabled", MakePacket<bool>(false).At(Timestamp(200))));
276+
MP_ASSERT_OK(graph.WaitUntilIdle());
277+
278+
// Send packets at timestamp 200.
267279
MP_ASSERT_OK(graph.AddPacketToInputStream(
268-
"input_appearances", MakePacket<std::string>("a1").At(Timestamp(200))));
280+
"input_appearances", MakePacket<std::string>("a1")Timestamp(200))));
269281
MP_ASSERT_OK(graph.AddPacketToInputStream(
270282
"video_frame", MakePacket<std::string>("v1").At(Timestamp(200))));
271283
MP_ASSERT_OK(graph.AddPacketToInputStream(
@@ -297,8 +309,8 @@ TEST(BypassCalculatorTest, GatedChannel) {
297309

298310
MP_ASSERT_OK(graph.CloseAllInputStreams());
299311
MP_ASSERT_OK(graph.WaitUntilDone());
300-
}
312+
}
301313

302-
} // namespace
314+
} // namespace
303315

304-
} // namespace mediapipe
316+
} // namespace mediapipe

mediapipe/calculators/core/frame_mux.cc

Whitespace-only changes.

0 commit comments

Comments
 (0)