Project import generated by Copybara.
GitOrigin-RevId: d4a11282d20fe4d2e137f9032cf349750030dcb9
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
// Copyright 2021 The MediaPipe Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package mediapipe;
|
||||
|
||||
// Joint of a 3D human model (e.g. elbow, knee, wrist). Contains 3D rotation of
|
||||
// the joint and its visibility.
|
||||
message Joint {
|
||||
// Joint rotation in 6D contineous representation.
|
||||
// Such representation is more sutable for NN model training and can be
|
||||
// converted to quaternions and Euler angles if needed. Details can be found
|
||||
// in https://arxiv.org/abs/1812.07035.
|
||||
repeated float rotation_6d = 1;
|
||||
|
||||
// Joint visibility.
|
||||
// Float score of whether joint is visible: present on the screen and not
|
||||
// occluded by other objects. Depending on the model, visibility value is
|
||||
// either a sigmoid or an argument of sigmoid, but in any case higher value
|
||||
// indicates higher probability of joint being visible. Should stay unset if
|
||||
// not supported.
|
||||
optional float visibility = 2;
|
||||
}
|
||||
|
||||
// Group of Joint protos.
|
||||
message JointList {
|
||||
repeated Joint joint = 1;
|
||||
}
|
||||
@@ -109,8 +109,7 @@ class Image {
|
||||
return gpu_buffer_.GetCVPixelBufferRef();
|
||||
}
|
||||
#else
|
||||
const mediapipe::GlTextureBufferSharedPtr& GetGlTextureBufferSharedPtr()
|
||||
const {
|
||||
mediapipe::GlTextureBufferSharedPtr GetGlTextureBufferSharedPtr() const {
|
||||
if (use_gpu_ == false) ConvertToGpu();
|
||||
return gpu_buffer_.GetGlTextureBufferSharedPtr();
|
||||
}
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
// For consistency, we now set MEDIAPIPE_MOBILE there too. However, for the sake
|
||||
// of projects that may want to build MediaPipe using alternative build systems,
|
||||
// we also try to set platform-specific defines in this header if missing.
|
||||
#if !defined(MEDIAPIPE_MOBILE) && \
|
||||
(defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) || \
|
||||
defined(__EMSCRIPTEN__))
|
||||
#if !defined(MEDIAPIPE_MOBILE) && \
|
||||
(defined(__ANDROID__) || defined(__EMSCRIPTEN__))
|
||||
#define MEDIAPIPE_MOBILE
|
||||
#endif
|
||||
|
||||
@@ -36,6 +35,11 @@
|
||||
#include "TargetConditionals.h" // for TARGET_OS_*
|
||||
#if !defined(MEDIAPIPE_IOS) && !TARGET_OS_OSX
|
||||
#define MEDIAPIPE_IOS
|
||||
|
||||
#if !defined(MEDIAPIPE_MOBILE) && !TARGET_OS_OSX
|
||||
#define MEDIAPIPE_MOBILE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(MEDIAPIPE_OSX) && TARGET_OS_OSX
|
||||
#define MEDIAPIPE_OSX
|
||||
|
||||
@@ -65,9 +65,9 @@ absl::Status CopyLiteralOptions(CalculatorGraphConfig::Node parent_node,
|
||||
|
||||
OptionsSyntaxUtil syntax_util;
|
||||
for (auto& node : *config->mutable_node()) {
|
||||
FieldData node_data = options_field_util::AsFieldData(node);
|
||||
|
||||
for (const std::string& option_def : node.option_value()) {
|
||||
FieldData node_data = options_field_util::AsFieldData(node);
|
||||
|
||||
std::vector<absl::string_view> tag_and_name =
|
||||
syntax_util.StrSplitTags(option_def);
|
||||
std::string graph_tag = syntax_util.OptionFieldsTag(tag_and_name[1]);
|
||||
@@ -96,6 +96,7 @@ absl::Status CopyLiteralOptions(CalculatorGraphConfig::Node parent_node,
|
||||
status.Update(MergeField(node_path, packet_data, &node_options));
|
||||
options_field_util::SetOptionsMessage(node_options, &node);
|
||||
}
|
||||
node.clear_option_value();
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,6 @@ TEST_F(OptionsUtilTest, CopyLiteralOptions) {
|
||||
NightLightCalculatorOptions expected_node_options;
|
||||
expected_node_options.add_num_lights(8);
|
||||
expected_node.add_node_options()->PackFrom(expected_node_options);
|
||||
*expected_node.add_option_value() = "num_lights:options/chain_length";
|
||||
EXPECT_THAT(actual_node, EqualsProto(expected_node));
|
||||
|
||||
MP_EXPECT_OK(graph.StartRun({}));
|
||||
|
||||
@@ -656,7 +656,6 @@ TEST(SubgraphExpansionTest, SimpleSubgraphOptionsUsage) {
|
||||
chain_length: 3
|
||||
}
|
||||
}
|
||||
option_value: "chain_length:options/chain_length"
|
||||
}
|
||||
type: "MoonSubgraph"
|
||||
graph_options {
|
||||
@@ -666,5 +665,84 @@ TEST(SubgraphExpansionTest, SimpleSubgraphOptionsUsage) {
|
||||
EXPECT_THAT(moon_subgraph, mediapipe::EqualsProto(expected_graph));
|
||||
}
|
||||
|
||||
// Shows ExpandSubgraphs applied twice. "option_value" fields are evaluated
|
||||
// and removed on the first ExpandSubgraphs call. If "option_value" fields
|
||||
// are not removed during ExpandSubgraphs, they evaluate incorrectly on the
|
||||
// second ExpandSubgraphs call and this test fails on "expected_node_options".
|
||||
TEST(SubgraphExpansionTest, SimpleSubgraphOptionsTwice) {
|
||||
GraphRegistry graph_registry;
|
||||
|
||||
// Register a simple-subgraph that accepts graph options.
|
||||
auto moon_subgraph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
type: "MoonSubgraph"
|
||||
graph_options: {
|
||||
[type.googleapis.com/mediapipe.NodeChainSubgraphOptions] {}
|
||||
}
|
||||
node: {
|
||||
calculator: "MoonCalculator"
|
||||
node_options: {
|
||||
[type.googleapis.com/mediapipe.NodeChainSubgraphOptions] {}
|
||||
}
|
||||
option_value: "chain_length:options/chain_length"
|
||||
}
|
||||
)pb");
|
||||
graph_registry.Register("MoonSubgraph", moon_subgraph);
|
||||
|
||||
// Invoke the simple-subgraph with graph options.
|
||||
// The empty NodeChainSubgraphOptions below allows "option_value" fields
|
||||
// on "MoonCalculator" to evaluate incorrectly, if not removed.
|
||||
auto sky_graph = mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
graph_options: {
|
||||
[type.googleapis.com/mediapipe.NodeChainSubgraphOptions] {}
|
||||
}
|
||||
node: {
|
||||
calculator: "MoonSubgraph"
|
||||
options: {
|
||||
[mediapipe.NodeChainSubgraphOptions.ext] {
|
||||
node_type: "DoubleIntCalculator"
|
||||
chain_length: 3
|
||||
}
|
||||
}
|
||||
}
|
||||
)pb");
|
||||
|
||||
// The first ExpandSubgraphs call evaluates and removes "option_value" fields.
|
||||
MP_ASSERT_OK(tool::ExpandSubgraphs(&sky_graph, &graph_registry));
|
||||
auto expanded_1 = sky_graph;
|
||||
|
||||
// The second ExpandSubgraphs call has no effect on the expanded graph.
|
||||
MP_ASSERT_OK(tool::ExpandSubgraphs(&sky_graph, &graph_registry));
|
||||
|
||||
// Validate the expected node_options for the "MoonSubgraph".
|
||||
// If the "option_value" fields are not removed during ExpandSubgraphs,
|
||||
// this test fails with an incorrect value for "chain_length".
|
||||
auto expected_node_options =
|
||||
mediapipe::ParseTextProtoOrDie<mediapipe::NodeChainSubgraphOptions>(
|
||||
"chain_length: 3");
|
||||
mediapipe::NodeChainSubgraphOptions node_options;
|
||||
sky_graph.node(0).node_options(0).UnpackTo(&node_options);
|
||||
ASSERT_THAT(node_options, mediapipe::EqualsProto(expected_node_options));
|
||||
|
||||
// Validate the results from both ExpandSubgraphs() calls.
|
||||
CalculatorGraphConfig expected_graph =
|
||||
mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"pb(
|
||||
graph_options {
|
||||
[type.googleapis.com/mediapipe.NodeChainSubgraphOptions] {}
|
||||
}
|
||||
node {
|
||||
name: "moonsubgraph__MoonCalculator"
|
||||
calculator: "MoonCalculator"
|
||||
node_options {
|
||||
[type.googleapis.com/mediapipe.NodeChainSubgraphOptions] {
|
||||
chain_length: 3
|
||||
}
|
||||
}
|
||||
}
|
||||
)pb");
|
||||
EXPECT_THAT(expanded_1, mediapipe::EqualsProto(expected_graph));
|
||||
EXPECT_THAT(sky_graph, mediapipe::EqualsProto(expected_graph));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace mediapipe
|
||||
|
||||
Reference in New Issue
Block a user