Project import generated by Copybara.

GitOrigin-RevId: 5b23708185311ae39a8605b0c2eff721e7b4939f
This commit is contained in:
MediaPipe Team
2020-08-05 20:27:31 -04:00
committed by chuoling
parent bdfdaef305
commit 2f86a459b6
115 changed files with 5242 additions and 251 deletions
+1 -1
View File
@@ -575,7 +575,7 @@ CalculatorGraph::PrepareGpu(const std::map<std::string, Packet>& side_packets) {
// Set up executors.
for (auto& node : *nodes_) {
if (node.UsesGpu()) {
gpu_resources->PrepareGpuNode(&node);
MP_RETURN_IF_ERROR(gpu_resources->PrepareGpuNode(&node));
}
}
for (const auto& name_executor : gpu_resources->GetGpuExecutors()) {
+14 -15
View File
@@ -473,6 +473,19 @@ bool CalculatorNode::OutputsAreConstant(CalculatorContext* cc) {
"Calculator::Open() for node \"$0\" failed: ", DebugName());
needs_to_close_ = true;
bool offset_enabled = false;
for (auto& stream : output_stream_handler_->OutputStreams()) {
offset_enabled = offset_enabled || stream->Spec()->offset_enabled;
}
if (offset_enabled && input_stream_handler_->SyncSetCount() > 1) {
LOG(WARNING) << absl::Substitute(
"Calculator node \"$0\" is configured with multiple input sync-sets "
"and an output timestamp-offset, which will often conflict due to "
"the order of packet arrival. With multiple input sync-sets, use "
"SetProcessTimestampBounds in place of SetTimestampOffset.",
DebugName());
}
output_stream_handler_->Open(outputs);
{
@@ -737,21 +750,7 @@ std::string CalculatorNode::DebugInputStreamNames() const {
std::string CalculatorNode::DebugName() const {
DCHECK(calculator_state_);
const std::string first_output_stream_name =
output_stream_handler_->FirstStreamName();
if (!first_output_stream_name.empty()) {
// A calculator is unique by its output streams (one of them is
// sufficient) unless it is a sink. For readability, its type name is
// included.
return absl::Substitute(
"[$0, $1 with output stream: $2]", calculator_state_->NodeName(),
calculator_state_->CalculatorType(), first_output_stream_name);
}
// If it is a sink, its full node spec is returned.
return absl::Substitute(
"[$0, $1 with node ID: $2 and $3]", calculator_state_->NodeName(),
calculator_state_->CalculatorType(), node_id_, DebugInputStreamNames());
return calculator_state_->NodeName();
}
// TODO: Split this function.
+1 -3
View File
@@ -259,9 +259,7 @@ class CalculatorNodeTest : public ::testing::Test {
TEST_F(CalculatorNodeTest, Initialize) {
InitializeEnvironment(/*use_tags=*/false);
EXPECT_EQ(2, node_->Id());
EXPECT_THAT(node_->DebugName(),
::testing::AllOf(::testing::HasSubstr("CountCalculator"),
::testing::HasSubstr("stream_b")));
EXPECT_THAT(node_->DebugName(), ::testing::HasSubstr("CountCalculator"));
EXPECT_FALSE(node_->Prepared());
EXPECT_FALSE(node_->Opened());
+6
View File
@@ -63,6 +63,12 @@ mediapipe_proto_library(
visibility = ["//visibility:public"],
)
mediapipe_proto_library(
name = "image_file_properties_proto",
srcs = ["image_file_properties.proto"],
visibility = ["//visibility:public"],
)
cc_library(
name = "deleting_file",
srcs = ["deleting_file.cc"],
@@ -0,0 +1,30 @@
// Copyright 2019 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;
// A list of properties extracted from EXIF metadata from an image file.
message ImageFileProperties {
// Image dimensions.
optional uint32 image_width = 1;
optional uint32 image_height = 2;
// Focal length of camera lens in millimeters.
optional double focal_length_mm = 3;
// Focal length of camera lens in 35 mm equivalent.
optional double focal_length_35mm = 4;
// Focal length in pixels.
optional double focal_length_pixels = 5;
}
@@ -185,6 +185,9 @@ class InputStreamHandler {
// When true, Calculator::Process is called for every input timestamp bound.
bool ProcessTimestampBounds() { return process_timestamps_; }
// Returns the number of sync-sets populated by this input stream handler.
virtual int SyncSetCount() { return 1; }
// A helper class to build input packet sets for a certain set of streams.
//
// ReadyForProcess requires all of the streams to be fully determined
+1 -1
View File
@@ -404,7 +404,7 @@ cc_library(
visibility = ["//mediapipe/framework/port:__pkg__"],
deps = [
":status",
"//mediapipe/framework/deps:status_matchers",
"@com_google_googletest//:gtest",
],
)
@@ -56,6 +56,9 @@ class ImmediateInputStreamHandler : public InputStreamHandler {
void FillInputSet(Timestamp input_timestamp,
InputStreamShardSet* input_set) override;
// Returns the number of sync-sets maintained by this input-handler.
int SyncSetCount() override;
absl::Mutex mutex_;
// The packet-set builder for each input stream.
std::vector<SyncSet> sync_sets_ ABSL_GUARDED_BY(mutex_);
@@ -169,4 +172,9 @@ void ImmediateInputStreamHandler::FillInputSet(Timestamp input_timestamp,
}
}
int ImmediateInputStreamHandler::SyncSetCount() {
absl::MutexLock lock(&mutex_);
return sync_sets_.size();
}
} // namespace mediapipe
@@ -67,6 +67,9 @@ class SyncSetInputStreamHandler : public InputStreamHandler {
InputStreamShardSet* input_set)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Returns the number of sync-sets maintained by this input-handler.
int SyncSetCount() override;
private:
absl::Mutex mutex_;
// The ids of each set of inputs.
@@ -194,4 +197,9 @@ void SyncSetInputStreamHandler::FillInputSet(Timestamp input_timestamp,
ready_timestamp_ = Timestamp::Done();
}
int SyncSetInputStreamHandler::SyncSetCount() {
absl::MutexLock lock(&mutex_);
return sync_sets_.size();
}
} // namespace mediapipe