Change calculator's behaviour

- Now clock input stream is optional
- If there are clock stream, always emit count. If not, emit count when vector stream is come in.
This commit is contained in:
dom607 2020-07-02 14:42:32 +09:00
parent 19983e3bd9
commit 1641986a7b
3 changed files with 15 additions and 4 deletions

View File

@ -39,9 +39,10 @@ template <typename VectorT>
class CountingVectorSizeCalculator : public CalculatorBase { class CountingVectorSizeCalculator : public CalculatorBase {
public: public:
static ::mediapipe::Status GetContract(CalculatorContract* cc) { static ::mediapipe::Status GetContract(CalculatorContract* cc) {
// Check tag. if (cc->Inputs().HasTag("CLOCK")) {
RET_CHECK(cc->Inputs().HasTag("CLOCK"));
cc->Inputs().Tag("CLOCK").SetAny(); cc->Inputs().Tag("CLOCK").SetAny();
}
RET_CHECK(cc->Inputs().HasTag("VECTOR")); RET_CHECK(cc->Inputs().HasTag("VECTOR"));
cc->Inputs().Tag("VECTOR").Set<VectorT>(); cc->Inputs().Tag("VECTOR").Set<VectorT>();
RET_CHECK(cc->Outputs().HasTag("COUNT")); RET_CHECK(cc->Outputs().HasTag("COUNT"));

View File

@ -74,8 +74,8 @@ mediapipe_simple_subgraph(
"//mediapipe/calculators/image:image_properties_calculator", "//mediapipe/calculators/image:image_properties_calculator",
"//mediapipe/calculators/util:association_norm_rect_calculator", "//mediapipe/calculators/util:association_norm_rect_calculator",
"//mediapipe/calculators/util:collection_has_min_size_calculator", "//mediapipe/calculators/util:collection_has_min_size_calculator",
"//mediapipe/modules/face_detection:face_detection_front_cpu",
"//mediapipe/calculators/util:counting_vector_size_calculator", "//mediapipe/calculators/util:counting_vector_size_calculator",
"//mediapipe/modules/face_detection:face_detection_front_cpu",
], ],
) )
@ -96,6 +96,7 @@ mediapipe_simple_subgraph(
"//mediapipe/calculators/image:image_properties_calculator", "//mediapipe/calculators/image:image_properties_calculator",
"//mediapipe/calculators/util:association_norm_rect_calculator", "//mediapipe/calculators/util:association_norm_rect_calculator",
"//mediapipe/calculators/util:collection_has_min_size_calculator", "//mediapipe/calculators/util:collection_has_min_size_calculator",
"//mediapipe/calculators/util:counting_vector_size_calculator",
"//mediapipe/modules/face_detection:face_detection_front_gpu", "//mediapipe/modules/face_detection:face_detection_front_gpu",
], ],
) )

View File

@ -43,6 +43,8 @@ output_stream: "ROIS_FROM_LANDMARKS:face_rects_from_landmarks"
# Regions of interest calculated based on face detections. # Regions of interest calculated based on face detections.
# (std::vector<NormalizedRect>) # (std::vector<NormalizedRect>)
output_stream: "ROIS_FROM_DETECTIONS:face_rects_from_detections" output_stream: "ROIS_FROM_DETECTIONS:face_rects_from_detections"
# (int)
output_stream: "FACE_COUNT_FROM_LANDMARKS:face_count"
# Determines if an input vector of NormalizedRect has a size greater than or # Determines if an input vector of NormalizedRect has a size greater than or
# equal to the provided num_faces. # equal to the provided num_faces.
@ -189,6 +191,13 @@ node {
output_stream: "ITERABLE:multi_face_landmarks" output_stream: "ITERABLE:multi_face_landmarks"
} }
node {
calculator: "CountingNormalizedLandmarkListVectorSizeCalculator"
input_stream: "CLOCK:image"
input_stream: "VECTOR:multi_face_landmarks"
output_stream: "COUNT:face_count"
}
# Collects a NormalizedRect for each face into a vector. Upon receiving the # Collects a NormalizedRect for each face into a vector. Upon receiving the
# BATCH_END timestamp, outputs the vector of NormalizedRect at the BATCH_END # BATCH_END timestamp, outputs the vector of NormalizedRect at the BATCH_END
# timestamp. # timestamp.