Rename hand landmarker related graphs.
PiperOrigin-RevId: 478706652
This commit is contained in:
parent
2cb9ebb5e3
commit
25e424baaf
|
@ -66,7 +66,7 @@ cc_library(
|
|||
"//mediapipe/tasks/cc/vision/gesture_recognizer/calculators:landmarks_to_matrix_calculator",
|
||||
"//mediapipe/tasks/cc/vision/gesture_recognizer/calculators:landmarks_to_matrix_calculator_cc_proto",
|
||||
"//mediapipe/tasks/cc/vision/gesture_recognizer/proto:hand_gesture_recognizer_graph_options_cc_proto",
|
||||
"//mediapipe/tasks/cc/vision/hand_landmarker:hand_landmarker_subgraph",
|
||||
"//mediapipe/tasks/cc/vision/hand_landmarker:hand_landmarks_detector_graph",
|
||||
"//mediapipe/tasks/cc/vision/utils:image_tensor_specs",
|
||||
"//mediapipe/tasks/metadata:metadata_schema_cc",
|
||||
"@com_google_absl//absl/status",
|
||||
|
|
|
@ -19,10 +19,10 @@ package(default_visibility = [
|
|||
licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "hand_landmarker_subgraph",
|
||||
srcs = ["hand_landmarker_subgraph.cc"],
|
||||
name = "hand_landmarks_detector_graph",
|
||||
srcs = ["hand_landmarks_detector_graph.cc"],
|
||||
deps = [
|
||||
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarker_subgraph_options_cc_proto",
|
||||
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarks_detector_graph_options_cc_proto",
|
||||
"@com_google_absl//absl/status",
|
||||
"@com_google_absl//absl/status:statusor",
|
||||
"//mediapipe/calculators/core:split_vector_calculator",
|
||||
|
@ -72,7 +72,7 @@ cc_library(
|
|||
name = "hand_landmarker_graph",
|
||||
srcs = ["hand_landmarker_graph.cc"],
|
||||
deps = [
|
||||
":hand_landmarker_subgraph",
|
||||
":hand_landmarks_detector_graph",
|
||||
"//mediapipe/calculators/core:begin_loop_calculator",
|
||||
"//mediapipe/calculators/core:clip_vector_size_calculator_cc_proto",
|
||||
"//mediapipe/calculators/core:end_loop_calculator",
|
||||
|
@ -99,7 +99,7 @@ cc_library(
|
|||
"//mediapipe/tasks/cc/vision/hand_landmarker/calculators:hand_association_calculator",
|
||||
"//mediapipe/tasks/cc/vision/hand_landmarker/calculators:hand_association_calculator_cc_proto",
|
||||
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarker_graph_options_cc_proto",
|
||||
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarker_subgraph_options_cc_proto",
|
||||
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarks_detector_graph_options_cc_proto",
|
||||
],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
|
|
@ -36,7 +36,7 @@ limitations under the License.
|
|||
#include "mediapipe/tasks/cc/vision/hand_detector/proto/hand_detector_graph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_association_calculator.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_graph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_subgraph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarks_detector_graph_options.pb.h"
|
||||
|
||||
namespace mediapipe {
|
||||
namespace tasks {
|
||||
|
@ -55,7 +55,7 @@ using ::mediapipe::tasks::vision::hand_detector::proto::
|
|||
using ::mediapipe::tasks::vision::hand_landmarker::proto::
|
||||
HandLandmarkerGraphOptions;
|
||||
using ::mediapipe::tasks::vision::hand_landmarker::proto::
|
||||
HandLandmarkerSubgraphOptions;
|
||||
HandLandmarksDetectorGraphOptions;
|
||||
|
||||
constexpr char kImageTag[] = "IMAGE";
|
||||
constexpr char kLandmarksTag[] = "LANDMARKS";
|
||||
|
@ -78,14 +78,14 @@ struct HandLandmarkerOutputs {
|
|||
|
||||
} // namespace
|
||||
|
||||
// A "mediapipe.tasks.vision.HandLandmarkerGraph" performs hand
|
||||
// A "mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph" performs hand
|
||||
// landmarks detection. The HandLandmarkerGraph consists of two subgraphs:
|
||||
// HandDetectorGraph and HandLandmarkerSubgraph. HandLandmarkerSubgraph detects
|
||||
// landmarks from bounding boxes produced by HandDetectorGraph.
|
||||
// HandLandmarkerGraph tracks the landmarks over time, and skips the
|
||||
// HandDetectorGraph. If the tracking is lost or the detectd hands are
|
||||
// less than configured max number hands, HandDetectorGraph would be triggered
|
||||
// to detect hands.
|
||||
// HandDetectorGraph and MultipleHandLandmarksDetectorGraph.
|
||||
// MultipleHandLandmarksDetectorGraph detects landmarks from bounding boxes
|
||||
// produced by HandDetectorGraph. HandLandmarkerGraph tracks the landmarks over
|
||||
// time, and skips the HandDetectorGraph. If the tracking is lost or the detectd
|
||||
// hands are less than configured max number hands, HandDetectorGraph would be
|
||||
// triggered to detect hands.
|
||||
//
|
||||
// Accepts CPU input images and outputs Landmarks on CPU.
|
||||
//
|
||||
|
@ -113,7 +113,7 @@ struct HandLandmarkerOutputs {
|
|||
//
|
||||
// Example:
|
||||
// node {
|
||||
// calculator: "mediapipe.tasks.vision.HandLandmarkerGraph"
|
||||
// calculator: "mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"
|
||||
// input_stream: "IMAGE:image_in"
|
||||
// output_stream: "LANDMARKS:hand_landmarks"
|
||||
// output_stream: "WORLD_LANDMARKS:world_hand_landmarks"
|
||||
|
@ -138,7 +138,7 @@ struct HandLandmarkerOutputs {
|
|||
// min_detection_confidence: 0.5
|
||||
// num_hands: 2
|
||||
// }
|
||||
// hand_landmarker_subgraph_options {
|
||||
// hand_landmarks_detector_graph_options {
|
||||
// base_options {
|
||||
// model_asset {
|
||||
// file_name: "hand_landmark_lite.tflite"
|
||||
|
@ -238,15 +238,17 @@ class HandLandmarkerGraph : public core::ModelTaskGraph {
|
|||
hand_rects >> clip_hand_rects.In("");
|
||||
auto clipped_hand_rects = clip_hand_rects.Out("");
|
||||
|
||||
auto& hand_landmarker_subgraph = graph.AddNode(
|
||||
"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerSubgraph");
|
||||
hand_landmarker_subgraph.GetOptions<HandLandmarkerSubgraphOptions>()
|
||||
.CopyFrom(tasks_options.hand_landmarker_subgraph_options());
|
||||
image_in >> hand_landmarker_subgraph.In("IMAGE");
|
||||
clipped_hand_rects >> hand_landmarker_subgraph.In("HAND_RECT");
|
||||
auto& hand_landmarks_detector_graph = graph.AddNode(
|
||||
"mediapipe.tasks.vision.hand_landmarker."
|
||||
"MultipleHandLandmarksDetectorGraph");
|
||||
hand_landmarks_detector_graph
|
||||
.GetOptions<HandLandmarksDetectorGraphOptions>()
|
||||
.CopyFrom(tasks_options.hand_landmarks_detector_graph_options());
|
||||
image_in >> hand_landmarks_detector_graph.In("IMAGE");
|
||||
clipped_hand_rects >> hand_landmarks_detector_graph.In("HAND_RECT");
|
||||
|
||||
auto hand_rects_for_next_frame =
|
||||
hand_landmarker_subgraph[Output<std::vector<NormalizedRect>>(
|
||||
hand_landmarks_detector_graph[Output<std::vector<NormalizedRect>>(
|
||||
kHandRectNextFrameTag)];
|
||||
// Back edge.
|
||||
hand_rects_for_next_frame >> previous_loopback.In("LOOP");
|
||||
|
@ -257,13 +259,13 @@ class HandLandmarkerGraph : public core::ModelTaskGraph {
|
|||
image_in >> pass_through.In("");
|
||||
|
||||
return {{
|
||||
/* landmark_lists= */ hand_landmarker_subgraph
|
||||
/* landmark_lists= */ hand_landmarks_detector_graph
|
||||
[Output<std::vector<NormalizedLandmarkList>>(kLandmarksTag)],
|
||||
/* world_landmark_lists= */
|
||||
hand_landmarker_subgraph[Output<std::vector<LandmarkList>>(
|
||||
hand_landmarks_detector_graph[Output<std::vector<LandmarkList>>(
|
||||
kWorldLandmarksTag)],
|
||||
/* hand_rects_next_frame= */ hand_rects_for_next_frame,
|
||||
hand_landmarker_subgraph[Output<std::vector<ClassificationList>>(
|
||||
hand_landmarks_detector_graph[Output<std::vector<ClassificationList>>(
|
||||
kHandednessTag)],
|
||||
/* palm_rects= */
|
||||
hand_detector[Output<std::vector<NormalizedRect>>(kPalmRectsTag)],
|
||||
|
|
|
@ -38,7 +38,7 @@ limitations under the License.
|
|||
#include "mediapipe/tasks/cc/core/task_runner.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_detector/proto/hand_detector_graph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_graph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_subgraph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarks_detector_graph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/utils/image_utils.h"
|
||||
#include "tensorflow/lite/c/common.h"
|
||||
#include "tensorflow/lite/core/shims/cc/shims_test_util.h"
|
||||
|
@ -111,7 +111,7 @@ absl::StatusOr<std::unique_ptr<TaskRunner>> CreateTaskRunner() {
|
|||
->set_file_name(JoinPath("./", kTestDataDirectory, kPalmDetectionModel));
|
||||
options.mutable_hand_detector_graph_options()->mutable_base_options();
|
||||
options.mutable_hand_detector_graph_options()->set_num_hands(kMaxNumHands);
|
||||
options.mutable_hand_landmarker_subgraph_options()
|
||||
options.mutable_hand_landmarks_detector_graph_options()
|
||||
->mutable_base_options()
|
||||
->mutable_model_asset()
|
||||
->set_file_name(
|
||||
|
|
|
@ -40,7 +40,7 @@ limitations under the License.
|
|||
#include "mediapipe/tasks/cc/core/proto/inference_subgraph.pb.h"
|
||||
#include "mediapipe/tasks/cc/core/utils.h"
|
||||
#include "mediapipe/tasks/cc/metadata/metadata_extractor.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_subgraph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarks_detector_graph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/utils/image_tensor_specs.h"
|
||||
#include "mediapipe/tasks/metadata/metadata_schema_generated.h"
|
||||
#include "mediapipe/util/label_map.pb.h"
|
||||
|
@ -60,7 +60,7 @@ using ::mediapipe::api2::builder::Source;
|
|||
using ::mediapipe::tasks::components::utils::AllowIf;
|
||||
using ::mediapipe::tasks::core::ModelResources;
|
||||
using ::mediapipe::tasks::vision::hand_landmarker::proto::
|
||||
HandLandmarkerSubgraphOptions;
|
||||
HandLandmarksDetectorGraphOptions;
|
||||
using LabelItems = mediapipe::proto_ns::Map<int64, ::mediapipe::LabelMapItem>;
|
||||
|
||||
constexpr char kImageTag[] = "IMAGE";
|
||||
|
@ -96,7 +96,8 @@ struct HandLandmarkerOutputs {
|
|||
Source<std::vector<ClassificationList>> handednesses;
|
||||
};
|
||||
|
||||
absl::Status SanityCheckOptions(const HandLandmarkerSubgraphOptions& options) {
|
||||
absl::Status SanityCheckOptions(
|
||||
const HandLandmarksDetectorGraphOptions& options) {
|
||||
if (options.min_detection_confidence() < 0 ||
|
||||
options.min_detection_confidence() > 1) {
|
||||
return CreateStatusWithPayload(absl::StatusCode::kInvalidArgument,
|
||||
|
@ -183,8 +184,8 @@ void ConfigureHandRectTransformationCalculator(
|
|||
|
||||
} // namespace
|
||||
|
||||
// A "mediapipe.tasks.vision.SingleHandLandmarkerSubgraph" performs hand
|
||||
// landmark detection.
|
||||
// A "mediapipe.tasks.vision.hand_landmarker.SingleHandLandmarksDetectorGraph"
|
||||
// performs hand landmarks detection.
|
||||
// - Accepts CPU input images and outputs Landmark on CPU.
|
||||
//
|
||||
// Inputs:
|
||||
|
@ -212,7 +213,8 @@ void ConfigureHandRectTransformationCalculator(
|
|||
//
|
||||
// Example:
|
||||
// node {
|
||||
// calculator: "mediapipe.tasks.vision.SingleHandLandmarkerSubgraph"
|
||||
// calculator:
|
||||
// "mediapipe.tasks.vision.hand_landmarker.SingleHandLandmarksDetectorGraph"
|
||||
// input_stream: "IMAGE:input_image"
|
||||
// input_stream: "HAND_RECT:hand_rect"
|
||||
// output_stream: "LANDMARKS:hand_landmarks"
|
||||
|
@ -221,7 +223,7 @@ void ConfigureHandRectTransformationCalculator(
|
|||
// output_stream: "PRESENCE:hand_presence"
|
||||
// output_stream: "PRESENCE_SCORE:hand_presence_score"
|
||||
// options {
|
||||
// [mediapipe.tasks.vision.hand_landmarker.proto.HandLandmarkerSubgraphOptions.ext]
|
||||
// [mediapipe.tasks.vision.hand_landmarker.proto.HandLandmarksDetectorGraphOptions.ext]
|
||||
// {
|
||||
// base_options {
|
||||
// model_asset {
|
||||
|
@ -232,16 +234,17 @@ void ConfigureHandRectTransformationCalculator(
|
|||
// }
|
||||
// }
|
||||
// }
|
||||
class SingleHandLandmarkerSubgraph : public core::ModelTaskGraph {
|
||||
class SingleHandLandmarksDetectorGraph : public core::ModelTaskGraph {
|
||||
public:
|
||||
absl::StatusOr<CalculatorGraphConfig> GetConfig(
|
||||
SubgraphContext* sc) override {
|
||||
ASSIGN_OR_RETURN(const auto* model_resources,
|
||||
CreateModelResources<HandLandmarkerSubgraphOptions>(sc));
|
||||
ASSIGN_OR_RETURN(
|
||||
const auto* model_resources,
|
||||
CreateModelResources<HandLandmarksDetectorGraphOptions>(sc));
|
||||
Graph graph;
|
||||
ASSIGN_OR_RETURN(auto hand_landmark_detection_outs,
|
||||
BuildSingleHandLandmarkerSubgraph(
|
||||
sc->Options<HandLandmarkerSubgraphOptions>(),
|
||||
BuildSingleHandLandmarksDetectorGraph(
|
||||
sc->Options<HandLandmarksDetectorGraphOptions>(),
|
||||
*model_resources, graph[Input<Image>(kImageTag)],
|
||||
graph[Input<NormalizedRect>(kHandRectTag)], graph));
|
||||
hand_landmark_detection_outs.hand_landmarks >>
|
||||
|
@ -264,14 +267,16 @@ class SingleHandLandmarkerSubgraph : public core::ModelTaskGraph {
|
|||
// Adds a mediapipe hand landmark detection graph into the provided
|
||||
// builder::Graph instance.
|
||||
//
|
||||
// subgraph_options: the mediapipe tasks module HandLandmarkerSubgraphOptions.
|
||||
// model_resources: the ModelSources object initialized from a hand landmark
|
||||
// subgraph_options: the mediapipe tasks module
|
||||
// HandLandmarksDetectorGraphOptions. model_resources: the ModelSources object
|
||||
// initialized from a hand landmark
|
||||
// detection model file with model metadata.
|
||||
// image_in: (mediapipe::Image) stream to run hand landmark detection on.
|
||||
// rect: (NormalizedRect) stream to run on the RoI of image.
|
||||
// graph: the mediapipe graph instance to be updated.
|
||||
absl::StatusOr<SingleHandLandmarkerOutputs> BuildSingleHandLandmarkerSubgraph(
|
||||
const HandLandmarkerSubgraphOptions& subgraph_options,
|
||||
absl::StatusOr<SingleHandLandmarkerOutputs>
|
||||
BuildSingleHandLandmarksDetectorGraph(
|
||||
const HandLandmarksDetectorGraphOptions& subgraph_options,
|
||||
const core::ModelResources& model_resources, Source<Image> image_in,
|
||||
Source<NormalizedRect> hand_rect, Graph& graph) {
|
||||
MP_RETURN_IF_ERROR(SanityCheckOptions(subgraph_options));
|
||||
|
@ -415,11 +420,13 @@ class SingleHandLandmarkerSubgraph : public core::ModelTaskGraph {
|
|||
}
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
REGISTER_MEDIAPIPE_GRAPH(
|
||||
::mediapipe::tasks::vision::hand_landmarker::SingleHandLandmarkerSubgraph);
|
||||
::mediapipe::tasks::vision::hand_landmarker::SingleHandLandmarksDetectorGraph); // NOLINT
|
||||
// clang-format on
|
||||
|
||||
// A "mediapipe.tasks.vision.HandLandmarkerSubgraph" performs multi hand
|
||||
// landmark detection.
|
||||
// A "mediapipe.tasks.vision.hand_landmarker.MultipleHandLandmarksDetectorGraph"
|
||||
// performs multi hand landmark detection.
|
||||
// - Accepts CPU input image and a vector of hand rect RoIs to detect the
|
||||
// multiple hands landmarks enclosed by the RoIs. Output vectors of
|
||||
// hand landmarks related results, where each element in the vectors
|
||||
|
@ -450,7 +457,8 @@ REGISTER_MEDIAPIPE_GRAPH(
|
|||
//
|
||||
// Example:
|
||||
// node {
|
||||
// calculator: "mediapipe.tasks.vision.HandLandmarkerSubgraph"
|
||||
// calculator:
|
||||
// "mediapipe.tasks.vision.hand_landmarker.MultipleHandLandmarksDetectorGraph"
|
||||
// input_stream: "IMAGE:input_image"
|
||||
// input_stream: "HAND_RECT:hand_rect"
|
||||
// output_stream: "LANDMARKS:hand_landmarks"
|
||||
|
@ -460,7 +468,7 @@ REGISTER_MEDIAPIPE_GRAPH(
|
|||
// output_stream: "PRESENCE_SCORE:hand_presence_score"
|
||||
// output_stream: "HANDEDNESS:handedness"
|
||||
// options {
|
||||
// [mediapipe.tasks.vision.hand_landmarker.proto.HandLandmarkerSubgraphOptions.ext]
|
||||
// [mediapipe.tasks.vision.hand_landmarker.proto.HandLandmarksDetectorGraphOptions.ext]
|
||||
// {
|
||||
// base_options {
|
||||
// model_asset {
|
||||
|
@ -471,15 +479,15 @@ REGISTER_MEDIAPIPE_GRAPH(
|
|||
// }
|
||||
// }
|
||||
// }
|
||||
class HandLandmarkerSubgraph : public core::ModelTaskGraph {
|
||||
class MultipleHandLandmarksDetectorGraph : public core::ModelTaskGraph {
|
||||
public:
|
||||
absl::StatusOr<CalculatorGraphConfig> GetConfig(
|
||||
SubgraphContext* sc) override {
|
||||
Graph graph;
|
||||
ASSIGN_OR_RETURN(
|
||||
auto hand_landmark_detection_outputs,
|
||||
BuildHandLandmarkerSubgraph(
|
||||
sc->Options<HandLandmarkerSubgraphOptions>(),
|
||||
BuildHandLandmarksDetectorGraph(
|
||||
sc->Options<HandLandmarksDetectorGraphOptions>(),
|
||||
graph[Input<Image>(kImageTag)],
|
||||
graph[Input<std::vector<NormalizedRect>>(kHandRectTag)], graph));
|
||||
hand_landmark_detection_outputs.landmark_lists >>
|
||||
|
@ -499,14 +507,15 @@ class HandLandmarkerSubgraph : public core::ModelTaskGraph {
|
|||
}
|
||||
|
||||
private:
|
||||
absl::StatusOr<HandLandmarkerOutputs> BuildHandLandmarkerSubgraph(
|
||||
const HandLandmarkerSubgraphOptions& subgraph_options,
|
||||
absl::StatusOr<HandLandmarkerOutputs> BuildHandLandmarksDetectorGraph(
|
||||
const HandLandmarksDetectorGraphOptions& subgraph_options,
|
||||
Source<Image> image_in,
|
||||
Source<std::vector<NormalizedRect>> multi_hand_rects, Graph& graph) {
|
||||
auto& hand_landmark_subgraph = graph.AddNode(
|
||||
"mediapipe.tasks.vision.hand_landmarker.SingleHandLandmarkerSubgraph");
|
||||
hand_landmark_subgraph.GetOptions<HandLandmarkerSubgraphOptions>().CopyFrom(
|
||||
subgraph_options);
|
||||
"mediapipe.tasks.vision.hand_landmarker."
|
||||
"SingleHandLandmarksDetectorGraph");
|
||||
hand_landmark_subgraph.GetOptions<HandLandmarksDetectorGraphOptions>()
|
||||
.CopyFrom(subgraph_options);
|
||||
|
||||
auto& begin_loop_multi_hand_rects =
|
||||
graph.AddNode("BeginLoopNormalizedRectCalculator");
|
||||
|
@ -580,8 +589,10 @@ class HandLandmarkerSubgraph : public core::ModelTaskGraph {
|
|||
}
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
REGISTER_MEDIAPIPE_GRAPH(
|
||||
::mediapipe::tasks::vision::hand_landmarker::HandLandmarkerSubgraph);
|
||||
::mediapipe::tasks::vision::hand_landmarker::MultipleHandLandmarksDetectorGraph); // NOLINT
|
||||
// clang-format on
|
||||
|
||||
} // namespace hand_landmarker
|
||||
} // namespace vision
|
|
@ -39,7 +39,7 @@ limitations under the License.
|
|||
#include "mediapipe/tasks/cc/core/proto/base_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/core/proto/external_file.pb.h"
|
||||
#include "mediapipe/tasks/cc/core/task_runner.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_subgraph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarks_detector_graph_options.pb.h"
|
||||
#include "mediapipe/tasks/cc/vision/utils/image_utils.h"
|
||||
|
||||
namespace mediapipe {
|
||||
|
@ -58,7 +58,7 @@ using ::mediapipe::file::JoinPath;
|
|||
using ::mediapipe::tasks::core::TaskRunner;
|
||||
using ::mediapipe::tasks::vision::DecodeImageFromFile;
|
||||
using ::mediapipe::tasks::vision::hand_landmarker::proto::
|
||||
HandLandmarkerSubgraphOptions;
|
||||
HandLandmarksDetectorGraphOptions;
|
||||
using ::testing::ElementsAreArray;
|
||||
using ::testing::EqualsProto;
|
||||
using ::testing::Pointwise;
|
||||
|
@ -114,12 +114,13 @@ absl::StatusOr<std::unique_ptr<TaskRunner>> CreateSingleHandTaskRunner(
|
|||
Graph graph;
|
||||
|
||||
auto& hand_landmark_detection = graph.AddNode(
|
||||
"mediapipe.tasks.vision.hand_landmarker.SingleHandLandmarkerSubgraph");
|
||||
"mediapipe.tasks.vision.hand_landmarker."
|
||||
"SingleHandLandmarksDetectorGraph");
|
||||
|
||||
auto options = std::make_unique<HandLandmarkerSubgraphOptions>();
|
||||
auto options = std::make_unique<HandLandmarksDetectorGraphOptions>();
|
||||
options->mutable_base_options()->mutable_model_asset()->set_file_name(
|
||||
JoinPath("./", kTestDataDirectory, model_name));
|
||||
hand_landmark_detection.GetOptions<HandLandmarkerSubgraphOptions>().Swap(
|
||||
hand_landmark_detection.GetOptions<HandLandmarksDetectorGraphOptions>().Swap(
|
||||
options.get());
|
||||
|
||||
graph[Input<Image>(kImageTag)].SetName(kImageName) >>
|
||||
|
@ -153,12 +154,13 @@ absl::StatusOr<std::unique_ptr<TaskRunner>> CreateMultiHandTaskRunner(
|
|||
Graph graph;
|
||||
|
||||
auto& multi_hand_landmark_detection = graph.AddNode(
|
||||
"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerSubgraph");
|
||||
"mediapipe.tasks.vision.hand_landmarker."
|
||||
"MultipleHandLandmarksDetectorGraph");
|
||||
|
||||
auto options = std::make_unique<HandLandmarkerSubgraphOptions>();
|
||||
auto options = std::make_unique<HandLandmarksDetectorGraphOptions>();
|
||||
options->mutable_base_options()->mutable_model_asset()->set_file_name(
|
||||
JoinPath("./", kTestDataDirectory, model_name));
|
||||
multi_hand_landmark_detection.GetOptions<HandLandmarkerSubgraphOptions>()
|
||||
multi_hand_landmark_detection.GetOptions<HandLandmarksDetectorGraphOptions>()
|
||||
.Swap(options.get());
|
||||
|
||||
graph[Input<Image>(kImageTag)].SetName(kImageName) >>
|
|
@ -21,8 +21,8 @@ package(default_visibility = [
|
|||
licenses(["notice"])
|
||||
|
||||
mediapipe_proto_library(
|
||||
name = "hand_landmarker_subgraph_options_proto",
|
||||
srcs = ["hand_landmarker_subgraph_options.proto"],
|
||||
name = "hand_landmarks_detector_graph_options_proto",
|
||||
srcs = ["hand_landmarks_detector_graph_options.proto"],
|
||||
deps = [
|
||||
"//mediapipe/framework:calculator_options_proto",
|
||||
"//mediapipe/framework:calculator_proto",
|
||||
|
@ -34,7 +34,7 @@ mediapipe_proto_library(
|
|||
name = "hand_landmarker_graph_options_proto",
|
||||
srcs = ["hand_landmarker_graph_options.proto"],
|
||||
deps = [
|
||||
":hand_landmarker_subgraph_options_proto",
|
||||
":hand_landmarks_detector_graph_options_proto",
|
||||
"//mediapipe/framework:calculator_options_proto",
|
||||
"//mediapipe/framework:calculator_proto",
|
||||
"//mediapipe/tasks/cc/core/proto:base_options_proto",
|
||||
|
|
|
@ -20,7 +20,7 @@ package mediapipe.tasks.vision.hand_landmarker.proto;
|
|||
import "mediapipe/framework/calculator.proto";
|
||||
import "mediapipe/tasks/cc/core/proto/base_options.proto";
|
||||
import "mediapipe/tasks/cc/vision/hand_detector/proto/hand_detector_graph_options.proto";
|
||||
import "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_subgraph_options.proto";
|
||||
import "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarks_detector_graph_options.proto";
|
||||
|
||||
message HandLandmarkerGraphOptions {
|
||||
extend mediapipe.CalculatorOptions {
|
||||
|
@ -35,7 +35,8 @@ message HandLandmarkerGraphOptions {
|
|||
hand_detector_graph_options = 2;
|
||||
|
||||
// Options for hand landmarker subgraph.
|
||||
optional HandLandmarkerSubgraphOptions hand_landmarker_subgraph_options = 3;
|
||||
optional HandLandmarksDetectorGraphOptions
|
||||
hand_landmarks_detector_graph_options = 3;
|
||||
|
||||
// Minimum confidence for hand landmarks tracking to be considered
|
||||
// successfully.
|
||||
|
|
|
@ -20,9 +20,9 @@ package mediapipe.tasks.vision.hand_landmarker.proto;
|
|||
import "mediapipe/framework/calculator.proto";
|
||||
import "mediapipe/tasks/cc/core/proto/base_options.proto";
|
||||
|
||||
message HandLandmarkerSubgraphOptions {
|
||||
message HandLandmarksDetectorGraphOptions {
|
||||
extend mediapipe.CalculatorOptions {
|
||||
optional HandLandmarkerSubgraphOptions ext = 474472470;
|
||||
optional HandLandmarksDetectorGraphOptions ext = 474472470;
|
||||
}
|
||||
// Base options for configuring MediaPipe Tasks, such as specifying the TfLite
|
||||
// model file with metadata, accelerator options, etc.
|
Loading…
Reference in New Issue
Block a user