Project import generated by Copybara.
GitOrigin-RevId: ea8d45731f5a052f79745e35bfd8240d6ac568d2
This commit is contained in:
@@ -55,6 +55,7 @@ cc_library(
|
||||
name = "desktop_cpu_calculators",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//mediapipe/calculators/core:constant_side_packet_calculator",
|
||||
"//mediapipe/calculators/tflite:tflite_model_calculator",
|
||||
"//mediapipe/calculators/util:local_file_contents_calculator",
|
||||
"//mediapipe/calculators/video:opencv_video_decoder_calculator",
|
||||
|
||||
@@ -635,12 +635,15 @@ void GlAnimationOverlayCalculator::LoadModelMatrices(
|
||||
|
||||
// Process model matrices, if any are being streamed in, and update our
|
||||
// list.
|
||||
current_model_matrices_.clear();
|
||||
if (has_model_matrix_stream_ &&
|
||||
!cc->Inputs().Tag("MODEL_MATRICES").IsEmpty()) {
|
||||
const TimedModelMatrixProtoList &model_matrices =
|
||||
cc->Inputs().Tag("MODEL_MATRICES").Get<TimedModelMatrixProtoList>();
|
||||
LoadModelMatrices(model_matrices, ¤t_model_matrices_);
|
||||
}
|
||||
|
||||
current_mask_model_matrices_.clear();
|
||||
if (has_mask_model_matrix_stream_ &&
|
||||
!cc->Inputs().Tag("MASK_MODEL_MATRICES").IsEmpty()) {
|
||||
const TimedModelMatrixProtoList &model_matrices =
|
||||
|
||||
@@ -8,6 +8,7 @@ input_side_packet: "LABELS_CSV:allowed_labels"
|
||||
input_side_packet: "MODEL_SCALE:model_scale"
|
||||
input_side_packet: "MODEL_TRANSFORMATION:model_transformation"
|
||||
input_side_packet: "TEXTURE:box_texture"
|
||||
input_side_packet: "MAX_NUM_OBJECTS:max_num_objects"
|
||||
input_side_packet: "ANIMATION_ASSET:box_asset_name"
|
||||
input_side_packet: "MASK_TEXTURE:obj_texture"
|
||||
input_side_packet: "MASK_ASSET:obj_asset_name"
|
||||
@@ -26,7 +27,7 @@ output_stream: "output_video"
|
||||
node {
|
||||
calculator: "FlowLimiterCalculator"
|
||||
input_stream: "input_video"
|
||||
input_stream: "FINISHED:lifted_objects"
|
||||
input_stream: "FINISHED:output_video"
|
||||
input_stream_info: {
|
||||
tag_index: "FINISHED"
|
||||
back_edge: true
|
||||
@@ -52,6 +53,7 @@ node {
|
||||
calculator: "ObjectronGpuSubgraph"
|
||||
input_stream: "IMAGE_GPU:throttled_input_video_3x4"
|
||||
input_side_packet: "LABELS_CSV:allowed_labels"
|
||||
input_side_packet: "MAX_NUM_OBJECTS:max_num_objects"
|
||||
output_stream: "FRAME_ANNOTATION:lifted_objects"
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,16 @@ input_side_packet: "FILE_PATH:0:box_landmark_model_path"
|
||||
input_side_packet: "LABELS_CSV:allowed_labels"
|
||||
input_side_packet: "OUTPUT_FILE_PATH:output_video_path"
|
||||
|
||||
# Generates side packet with max number of objects to detect/track.
|
||||
node {
|
||||
calculator: "ConstantSidePacketCalculator"
|
||||
output_side_packet: "PACKET:max_num_objects"
|
||||
node_options: {
|
||||
[type.googleapis.com/mediapipe.ConstantSidePacketCalculatorOptions]: {
|
||||
packet { int_value: 5 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Decodes an input video file into images and a video header.
|
||||
node {
|
||||
@@ -30,8 +40,9 @@ node {
|
||||
input_stream: "IMAGE:input_video"
|
||||
input_side_packet: "MODEL:box_landmark_model"
|
||||
input_side_packet: "LABELS_CSV:allowed_labels"
|
||||
output_stream: "LANDMARKS:box_landmarks"
|
||||
output_stream: "NORM_RECT:box_rect"
|
||||
input_side_packet: "MAX_NUM_OBJECTS:max_num_objects"
|
||||
output_stream: "MULTI_LANDMARKS:box_landmarks"
|
||||
output_stream: "NORM_RECTS:box_rect"
|
||||
}
|
||||
|
||||
# Subgraph that renders annotations and overlays them on top of the input
|
||||
@@ -39,8 +50,8 @@ node {
|
||||
node {
|
||||
calculator: "RendererSubgraph"
|
||||
input_stream: "IMAGE:input_video"
|
||||
input_stream: "LANDMARKS:box_landmarks"
|
||||
input_stream: "NORM_RECT:box_rect"
|
||||
input_stream: "MULTI_LANDMARKS:box_landmarks"
|
||||
input_stream: "NORM_RECTS:box_rect"
|
||||
output_stream: "IMAGE:output_video"
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ mediapipe_simple_subgraph(
|
||||
register_as = "RendererSubgraph",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//mediapipe/calculators/core:begin_loop_calculator",
|
||||
"//mediapipe/calculators/core:end_loop_calculator",
|
||||
"//mediapipe/calculators/util:annotation_overlay_calculator",
|
||||
"//mediapipe/calculators/util:detections_to_render_data_calculator",
|
||||
"//mediapipe/calculators/util:landmarks_to_render_data_calculator",
|
||||
|
||||
@@ -3,15 +3,26 @@
|
||||
type: "RendererSubgraph"
|
||||
|
||||
input_stream: "IMAGE:input_image"
|
||||
input_stream: "LANDMARKS:landmarks"
|
||||
input_stream: "NORM_RECT:rect"
|
||||
input_stream: "MULTI_LANDMARKS:multi_landmarks"
|
||||
input_stream: "NORM_RECTS:multi_rect"
|
||||
output_stream: "IMAGE:output_image"
|
||||
|
||||
# Outputs each element of multi_landmarks at a fake timestamp for the rest
|
||||
# of the graph to process. At the end of the loop, outputs the BATCH_END
|
||||
# timestamp for downstream calculators to inform them that all elements in the
|
||||
# vector have been processed.
|
||||
node {
|
||||
calculator: "BeginLoopNormalizedLandmarkListVectorCalculator"
|
||||
input_stream: "ITERABLE:multi_landmarks"
|
||||
output_stream: "ITEM:single_landmarks"
|
||||
output_stream: "BATCH_END:landmark_timestamp"
|
||||
}
|
||||
|
||||
# Converts landmarks to drawing primitives for annotation overlay.
|
||||
node {
|
||||
calculator: "LandmarksToRenderDataCalculator"
|
||||
input_stream: "NORM_LANDMARKS:landmarks"
|
||||
output_stream: "RENDER_DATA:landmark_render_data"
|
||||
input_stream: "NORM_LANDMARKS:single_landmarks"
|
||||
output_stream: "RENDER_DATA:single_landmark_render_data"
|
||||
node_options: {
|
||||
[type.googleapis.com/mediapipe.LandmarksToRenderDataCalculatorOptions] {
|
||||
landmark_connections: [1, 2] # edge 1-2
|
||||
@@ -33,11 +44,18 @@ node {
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
calculator: "EndLoopRenderDataCalculator"
|
||||
input_stream: "ITEM:single_landmark_render_data"
|
||||
input_stream: "BATCH_END:landmark_timestamp"
|
||||
output_stream: "ITERABLE:multi_landmarks_render_data"
|
||||
}
|
||||
|
||||
# Converts normalized rects to drawing primitives for annotation overlay.
|
||||
node {
|
||||
calculator: "RectToRenderDataCalculator"
|
||||
input_stream: "NORM_RECT:rect"
|
||||
output_stream: "RENDER_DATA:rect_render_data"
|
||||
input_stream: "NORM_RECTS:multi_rect"
|
||||
output_stream: "RENDER_DATA:multi_rect_render_data"
|
||||
node_options: {
|
||||
[type.googleapis.com/mediapipe.RectToRenderDataCalculatorOptions] {
|
||||
filled: false
|
||||
@@ -51,7 +69,7 @@ node {
|
||||
node {
|
||||
calculator: "AnnotationOverlayCalculator"
|
||||
input_stream: "IMAGE:input_image"
|
||||
input_stream: "landmark_render_data"
|
||||
input_stream: "rect_render_data"
|
||||
input_stream: "VECTOR:multi_landmarks_render_data"
|
||||
input_stream: "multi_rect_render_data"
|
||||
output_stream: "IMAGE:output_image"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user