diff --git a/mediapipe/framework/profiler/circular_buffer.h b/mediapipe/framework/profiler/circular_buffer.h index 13c9edba6b..f6f6a86178 100644 --- a/mediapipe/framework/profiler/circular_buffer.h +++ b/mediapipe/framework/profiler/circular_buffer.h @@ -167,7 +167,7 @@ char CircularBuffer::MaxLap(char u, char v) { template class CircularBuffer::iterator - : public std::iterator { + : public std::iterator { public: explicit iterator(const CircularBuffer* buffer, size_t index) : buffer_(buffer), index_(index) {} @@ -177,10 +177,10 @@ class CircularBuffer::iterator T operator*() const { return buffer_->GetAbsolute(index_); } T* operator->() const { &buffer_->GetAbsolute(index_); } iterator& operator++() { return (*this) += 1; } - iterator& operator+=(const int64& num) { return index_ += num, *this; } - int64 operator-(const iterator& it) const { return index_ - it.index_; } - iterator& operator+(const int64& num) { return iterator(*this) += num; } - iterator& operator-(const int64& num) { return iterator(*this) += -num; } + iterator& operator+=(const int64_t& num) { return index_ += num, *this; } + int64_t operator-(const iterator& it) const { return index_ - it.index_; } + iterator& operator+(const int64_t& num) { return iterator(*this) += num; } + iterator& operator-(const int64_t& num) { return iterator(*this) += -num; } private: const CircularBuffer* buffer_; diff --git a/mediapipe/framework/profiler/graph_profiler.cc b/mediapipe/framework/profiler/graph_profiler.cc index f5ea01e7a8..34ad8448a8 100644 --- a/mediapipe/framework/profiler/graph_profiler.cc +++ b/mediapipe/framework/profiler/graph_profiler.cc @@ -89,7 +89,7 @@ bool IsTraceIntervalEnabled(const ProfilerConfig& profiler_config, } using PacketInfoMap = - ShardedMap>>; + ShardedMap>>; // Inserts a PacketInfo into a PacketInfoMap. void InsertPacketInfo(PacketInfoMap* map, const PacketId& packet_id, @@ -162,9 +162,9 @@ void GraphProfiler::Initialize( ABSL_CHECK(!is_initialized_) << "Cannot initialize the profiler for the same graph multiple times."; profiler_config_ = validated_graph_config.Config().profiler_config(); - int64 interval_size_usec = profiler_config_.histogram_interval_size_usec(); + int64_t interval_size_usec = profiler_config_.histogram_interval_size_usec(); interval_size_usec = interval_size_usec ? interval_size_usec : 1000000; - int64 num_intervals = profiler_config_.num_histogram_intervals(); + int64_t num_intervals = profiler_config_.num_histogram_intervals(); num_intervals = num_intervals ? num_intervals : 1; if (IsTracerEnabled(profiler_config_)) { packet_tracer_ = absl::make_unique(profiler_config_); @@ -323,7 +323,7 @@ void GraphProfiler::AddPacketInfo(const TraceEvent& packet_info) { return; } - int64 production_time_usec = + int64_t production_time_usec = profiler_config_.use_packet_timestamp_for_added_packet() ? packet_timestamp.Value() : TimeNowUsec(); @@ -342,8 +342,8 @@ absl::Status GraphProfiler::GetCalculatorProfiles( return absl::OkStatus(); } -void GraphProfiler::InitializeTimeHistogram(int64 interval_size_usec, - int64 num_intervals, +void GraphProfiler::InitializeTimeHistogram(int64_t interval_size_usec, + int64_t num_intervals, TimeHistogram* histogram) { histogram->set_interval_size_usec(interval_size_usec); histogram->set_num_intervals(num_intervals); @@ -355,8 +355,8 @@ void GraphProfiler::InitializeOutputStreams( const CalculatorGraphConfig::Node& node_config) {} void GraphProfiler::InitializeInputStreams( - const CalculatorGraphConfig::Node& node_config, int64 interval_size_usec, - int64 num_intervals, CalculatorProfile* calculator_profile) { + const CalculatorGraphConfig::Node& node_config, int64_t interval_size_usec, + int64_t num_intervals, CalculatorProfile* calculator_profile) { std::shared_ptr input_tag_map = TagMap::Create(node_config.input_stream()).value(); std::set back_edge_ids = GetBackEdgeIds(node_config, *input_tag_map); @@ -405,15 +405,15 @@ void GraphProfiler::ResetTimeHistogram(TimeHistogram* histogram) { } void GraphProfiler::AddPacketInfoInternal(const PacketId& packet_id, - int64 production_time_usec, - int64 source_process_start_usec) { + int64_t production_time_usec, + int64_t source_process_start_usec) { PacketInfo packet_info = {0, production_time_usec, source_process_start_usec}; InsertPacketInfo(&packets_info_, packet_id, packet_info); } void GraphProfiler::AddPacketInfoForOutputPackets( const OutputStreamShardSet& output_stream_shard_set, - int64 production_time_usec, int64 source_process_start_usec) { + int64_t production_time_usec, int64_t source_process_start_usec) { for (const OutputStreamShard& output_stream_shard : output_stream_shard_set) { for (const Packet& output_packet : *output_stream_shard.OutputQueue()) { AddPacketInfoInternal(PacketId({output_stream_shard.Name(), @@ -423,11 +423,11 @@ void GraphProfiler::AddPacketInfoForOutputPackets( } } -int64 GraphProfiler::AddStreamLatencies( - const CalculatorContext& calculator_context, int64 start_time_usec, - int64 end_time_usec, CalculatorProfile* calculator_profile) { +int64_t GraphProfiler::AddStreamLatencies( + const CalculatorContext& calculator_context, int64_t start_time_usec, + int64_t end_time_usec, CalculatorProfile* calculator_profile) { // Update input streams profiles. - int64 min_source_process_start_usec = AddInputStreamTimeSamples( + int64_t min_source_process_start_usec = AddInputStreamTimeSamples( calculator_context, start_time_usec, calculator_profile); // Update output production times. @@ -437,14 +437,15 @@ int64 GraphProfiler::AddStreamLatencies( } void GraphProfiler::SetOpenRuntime(const CalculatorContext& calculator_context, - int64 start_time_usec, int64 end_time_usec) { + int64_t start_time_usec, + int64_t end_time_usec) { absl::ReaderMutexLock lock(&profiler_mutex_); if (!is_profiling_) { return; } const std::string& node_name = calculator_context.NodeName(); - int64 time_usec = end_time_usec - start_time_usec; + int64_t time_usec = end_time_usec - start_time_usec; auto profile_iter = calculator_profiles_.find(node_name); ABSL_CHECK(profile_iter != calculator_profiles_.end()) << absl::Substitute( "Calculator \"$0\" has not been added during initialization.", @@ -459,14 +460,14 @@ void GraphProfiler::SetOpenRuntime(const CalculatorContext& calculator_context, } void GraphProfiler::SetCloseRuntime(const CalculatorContext& calculator_context, - int64 start_time_usec, - int64 end_time_usec) { + int64_t start_time_usec, + int64_t end_time_usec) { absl::ReaderMutexLock lock(&profiler_mutex_); if (!is_profiling_) { return; } const std::string& node_name = calculator_context.NodeName(); - int64 time_usec = end_time_usec - start_time_usec; + int64_t time_usec = end_time_usec - start_time_usec; auto profile_iter = calculator_profiles_.find(node_name); ABSL_CHECK(profile_iter != calculator_profiles_.end()) << absl::Substitute( "Calculator \"$0\" has not been added during initialization.", @@ -480,7 +481,8 @@ void GraphProfiler::SetCloseRuntime(const CalculatorContext& calculator_context, } } -void GraphProfiler::AddTimeSample(int64 start_time_usec, int64 end_time_usec, +void GraphProfiler::AddTimeSample(int64_t start_time_usec, + int64_t end_time_usec, TimeHistogram* histogram) { if (end_time_usec < start_time_usec) { ABSL_LOG(ERROR) << absl::Substitute( @@ -489,21 +491,21 @@ void GraphProfiler::AddTimeSample(int64 start_time_usec, int64 end_time_usec, return; } - int64 time_usec = end_time_usec - start_time_usec; + int64_t time_usec = end_time_usec - start_time_usec; histogram->set_total(histogram->total() + time_usec); - int64 interval_index = time_usec / histogram->interval_size_usec(); + int64_t interval_index = time_usec / histogram->interval_size_usec(); if (interval_index > histogram->num_intervals() - 1) { interval_index = histogram->num_intervals() - 1; } histogram->set_count(interval_index, histogram->count(interval_index) + 1); } -int64 GraphProfiler::AddInputStreamTimeSamples( - const CalculatorContext& calculator_context, int64 start_time_usec, +int64_t GraphProfiler::AddInputStreamTimeSamples( + const CalculatorContext& calculator_context, int64_t start_time_usec, CalculatorProfile* calculator_profile) { - int64 input_timestamp_usec = calculator_context.InputTimestamp().Value(); - int64 min_source_process_start_usec = start_time_usec; - int64 input_stream_counter = -1; + int64_t input_timestamp_usec = calculator_context.InputTimestamp().Value(); + int64_t min_source_process_start_usec = start_time_usec; + int64_t input_stream_counter = -1; for (CollectionItemId id = calculator_context.Inputs().BeginId(); id < calculator_context.Inputs().EndId(); ++id) { ++input_stream_counter; @@ -537,8 +539,8 @@ int64 GraphProfiler::AddInputStreamTimeSamples( } void GraphProfiler::AddProcessSample( - const CalculatorContext& calculator_context, int64 start_time_usec, - int64 end_time_usec) { + const CalculatorContext& calculator_context, int64_t start_time_usec, + int64_t end_time_usec) { absl::ReaderMutexLock lock(&profiler_mutex_); if (!is_profiling_) { return; @@ -556,7 +558,7 @@ void GraphProfiler::AddProcessSample( calculator_profile->mutable_process_runtime()); if (profiler_config_.enable_stream_latency()) { - int64 min_source_process_start_usec = AddStreamLatencies( + int64_t min_source_process_start_usec = AddStreamLatencies( calculator_context, start_time_usec, end_time_usec, calculator_profile); // Update input and output trace latencies. AddTimeSample(min_source_process_start_usec, start_time_usec, diff --git a/mediapipe/framework/profiler/graph_profiler.h b/mediapipe/framework/profiler/graph_profiler.h index 6358cb0577..604da9e3f4 100644 --- a/mediapipe/framework/profiler/graph_profiler.h +++ b/mediapipe/framework/profiler/graph_profiler.h @@ -42,7 +42,7 @@ struct PacketId { // Stream name, excluding TAG if available. std::string stream_name; // Timestamp of the packet. - int64 timestamp_usec; + int64_t timestamp_usec; bool operator==(const PacketId& other) const { return (stream_name == other.stream_name) && @@ -53,12 +53,12 @@ struct PacketId { struct PacketInfo { // Number of remained consumer of this packet. // This is used to decide if this PacketInfo should be discarded. - int64 remaining_consumer_count; + int64_t remaining_consumer_count; // Packet production time based on profiler's clock. - int64 production_time_usec; + int64_t production_time_usec; // The time when the Process(), that generated the corresponding source // packet, was started. - int64 source_process_start_usec; + int64_t source_process_start_usec; // For testing. bool operator==(const PacketInfo& other) const { @@ -191,12 +191,12 @@ class GraphProfiler : public std::enable_shared_from_this { } inline ~Scope() { - int64 end_time_usec; + int64_t end_time_usec; if (profiler_->is_profiling_ || profiler_->is_tracing_) { end_time_usec = profiler_->TimeNowUsec(); } if (profiler_->is_profiling_) { - int64 end_time_usec = profiler_->TimeNowUsec(); + int64_t end_time_usec = profiler_->TimeNowUsec(); switch (calculator_method_) { case GraphTrace::OPEN: profiler_->SetOpenRuntime(calculator_context_, start_time_usec_, @@ -227,7 +227,7 @@ class GraphProfiler : public std::enable_shared_from_this { const GraphTrace::EventType calculator_method_; const CalculatorContext& calculator_context_; GraphProfiler* profiler_; - int64 start_time_usec_; + int64_t start_time_usec_; }; const ProfilerConfig& profiler_config() { return profiler_config_; } @@ -249,12 +249,12 @@ class GraphProfiler : public std::enable_shared_from_this { // is valid for profiling. void AddPacketInfo(const TraceEvent& packet_info) ABSL_LOCKS_EXCLUDED(profiler_mutex_); - static void InitializeTimeHistogram(int64 interval_size_usec, - int64 num_intervals, + static void InitializeTimeHistogram(int64_t interval_size_usec, + int64_t num_intervals, TimeHistogram* histogram); static void ResetTimeHistogram(TimeHistogram* histogram); // Add a sample to a time histogram. - static void AddTimeSample(int64 start_time_usec, int64 end_time_usec, + static void AddTimeSample(int64_t start_time_usec, int64_t end_time_usec, TimeHistogram* histogram); // Add output streams to the stream consumer count map. @@ -266,43 +266,43 @@ class GraphProfiler : public std::enable_shared_from_this { // not add them to |stream_consumer_counts_| to avoid using them for updating // |source_process_start_usec| and garbage collection while profiling. void InitializeInputStreams(const CalculatorGraphConfig::Node& node_config, - int64 interval_size_usec, int64 num_intervals, + int64_t interval_size_usec, int64_t num_intervals, CalculatorProfile* calculator_profile); // Returns the input stream back edges for a calculator. std::set GetBackEdgeIds(const CalculatorGraphConfig::Node& node_config, const tool::TagMap& input_tag_map); void AddPacketInfoInternal(const PacketId& packet_id, - int64 production_time_usec, - int64 source_process_start_usec); + int64_t production_time_usec, + int64_t source_process_start_usec); // Adds packet info for non-empty output packets. void AddPacketInfoForOutputPackets( const OutputStreamShardSet& output_stream_shard_set, - int64 production_time_usec, int64 source_process_start_usec); + int64_t production_time_usec, int64_t source_process_start_usec); // Updates the production time for outputs and the stream profile for inputs. - int64 AddStreamLatencies(const CalculatorContext& calculator_context, - int64 start_time_usec, int64 end_time_usec, - CalculatorProfile* calculator_profile); + int64_t AddStreamLatencies(const CalculatorContext& calculator_context, + int64_t start_time_usec, int64_t end_time_usec, + CalculatorProfile* calculator_profile); void SetOpenRuntime(const CalculatorContext& calculator_context, - int64 start_time_usec, int64 end_time_usec) + int64_t start_time_usec, int64_t end_time_usec) ABSL_LOCKS_EXCLUDED(profiler_mutex_); void SetCloseRuntime(const CalculatorContext& calculator_context, - int64 start_time_usec, int64 end_time_usec) + int64_t start_time_usec, int64_t end_time_usec) ABSL_LOCKS_EXCLUDED(profiler_mutex_); // Updates the input streams profiles for the calculator and returns the // minimum |source_process_start_usec| of all input packets, excluding empty // packets and back-edge packets. Returns -1 if there is no input packets. - int64 AddInputStreamTimeSamples(const CalculatorContext& calculator_context, - int64 start_time_usec, - CalculatorProfile* calculator_profile); + int64_t AddInputStreamTimeSamples(const CalculatorContext& calculator_context, + int64_t start_time_usec, + CalculatorProfile* calculator_profile); // Updates the Process() data for calculator. // Requires ReaderLock for is_profiling_. void AddProcessSample(const CalculatorContext& calculator_context, - int64 start_time_usec, int64 end_time_usec) + int64_t start_time_usec, int64_t end_time_usec) ABSL_LOCKS_EXCLUDED(profiler_mutex_); // Helper method to get trace_log_path. If the trace_log_path is empty and @@ -311,7 +311,7 @@ class GraphProfiler : public std::enable_shared_from_this { absl::StatusOr GetTraceLogPath(); // Helper method to get the clock time in microsecond. - int64 TimeNowUsec() { return ToUnixMicros(clock_->TimeNow()); } + int64_t TimeNowUsec() { return ToUnixMicros(clock_->TimeNow()); } private: // The settings for this tracer. @@ -332,7 +332,7 @@ class GraphProfiler : public std::enable_shared_from_this { CalculatorProfileMap calculator_profiles_; // Stores the production time of a packet, based on profiler's clock. using PacketInfoMap = - ShardedMap>>; + ShardedMap>>; PacketInfoMap packets_info_; // Global mutex for the profiler. diff --git a/mediapipe/framework/profiler/graph_profiler_stub.h b/mediapipe/framework/profiler/graph_profiler_stub.h index 72d5d7275d..cb49c315ea 100644 --- a/mediapipe/framework/profiler/graph_profiler_stub.h +++ b/mediapipe/framework/profiler/graph_profiler_stub.h @@ -15,6 +15,8 @@ #ifndef MEDIAPIPE_FRAMEWORK_PROFILER_MEDIAPIPE_PROFILER_STUB_H_ #define MEDIAPIPE_FRAMEWORK_PROFILER_MEDIAPIPE_PROFILER_STUB_H_ +#include + #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/timestamp.h" @@ -71,7 +73,7 @@ class TraceEvent { inline TraceEvent& set_packet_data_id(const Packet* packet) { return *this; } inline TraceEvent& set_thread_id(int thread_id) { return *this; } inline TraceEvent& set_is_finish(bool is_finish) { return *this; } - inline TraceEvent& set_event_data(int64 data) { return *this; } + inline TraceEvent& set_event_data(int64_t data) { return *this; } }; // GraphProfiler::CaptureProfile option, see the method for details. diff --git a/mediapipe/framework/profiler/graph_profiler_test.cc b/mediapipe/framework/profiler/graph_profiler_test.cc index 8a9bc141eb..8be57a5fee 100644 --- a/mediapipe/framework/profiler/graph_profiler_test.cc +++ b/mediapipe/framework/profiler/graph_profiler_test.cc @@ -65,17 +65,17 @@ CalculatorProfile GetProfileWithName( return CalculatorProfile::default_instance(); } -TimeHistogram CreateTimeHistogram(int64 total, std::vector counts) { +TimeHistogram CreateTimeHistogram(int64_t total, std::vector counts) { TimeHistogram time_histogram; time_histogram.set_total(total); - for (int64 c : counts) { + for (int64_t c : counts) { time_histogram.add_count(c); } return time_histogram; } using PacketInfoMap = - ShardedMap>>; + ShardedMap>>; // Returns a PacketInfo from a PacketInfoMap. PacketInfo* GetPacketInfo(PacketInfoMap* map, const PacketId& packet_id) { @@ -134,14 +134,14 @@ class GraphProfilerTestPeer : public testing::Test { return &profiler_.packets_info_; } - static void InitializeTimeHistogram(int64 interval_size_usec, - int64 num_intervals, + static void InitializeTimeHistogram(int64_t interval_size_usec, + int64_t num_intervals, TimeHistogram* histogram) { GraphProfiler::InitializeTimeHistogram(interval_size_usec, num_intervals, histogram); } - static void AddTimeSample(int64 start_time_usec, int64 end_time_usec, + static void AddTimeSample(int64_t start_time_usec, int64_t end_time_usec, TimeHistogram* histogram) { GraphProfiler::AddTimeSample(start_time_usec, end_time_usec, histogram); } @@ -151,7 +151,7 @@ class GraphProfilerTestPeer : public testing::Test { } void InitializeInputStreams(const CalculatorGraphConfig::Node& node_config, - int64 interval_size_usec, int64 num_intervals, + int64_t interval_size_usec, int64_t num_intervals, CalculatorProfile* calculator_profile) { profiler_.InitializeInputStreams(node_config, interval_size_usec, num_intervals, calculator_profile); @@ -166,13 +166,13 @@ class GraphProfilerTestPeer : public testing::Test { } void SetOpenRuntime(const CalculatorContext& calculator_context, - int64 start_time_usec, int64 end_time_usec) { + int64_t start_time_usec, int64_t end_time_usec) { profiler_.SetOpenRuntime(calculator_context, start_time_usec, end_time_usec); } void SetCloseRuntime(const CalculatorContext& calculator_context, - int64 start_time_usec, int64 end_time_usec) { + int64_t start_time_usec, int64_t end_time_usec) { profiler_.SetCloseRuntime(calculator_context, start_time_usec, end_time_usec); } @@ -180,7 +180,7 @@ class GraphProfilerTestPeer : public testing::Test { // Updates the Process() data for calculator. // Requires ReaderLock for is_profiling_. void AddProcessSample(const CalculatorContext& calculator_context, - int64 start_time_usec, int64 end_time_usec) { + int64_t start_time_usec, int64_t end_time_usec) { profiler_.AddProcessSample(calculator_context, start_time_usec, end_time_usec); } @@ -603,7 +603,7 @@ TEST_F(GraphProfilerTestPeer, AddPacketInfoUsingProfilerClock) { .set_input_ts(packet.Timestamp()) .set_packet_ts(packet.Timestamp()) .set_packet_data_id(&packet)); - int64 profiler_now_usec = ToUnixMicros(simulation_clock->TimeNow()); + int64_t profiler_now_usec = ToUnixMicros(simulation_clock->TimeNow()); PacketInfo expected_packet_info = { 0, @@ -961,8 +961,8 @@ TEST_F(GraphProfilerTestPeer, InitializeOutputStreams) { // excluding the back edges or input side packets. TEST_F(GraphProfilerTestPeer, InitializeInputStreams) { CalculatorProfile profile; - int64 interval_size_usec = 100; - int64 num_intervals = 1; + int64_t interval_size_usec = 100; + int64_t num_intervals = 1; // Without any input stream. auto node_config = CreateNodeConfig(R"( calculator: "SourceCalculator" @@ -1076,8 +1076,8 @@ TEST_F(GraphProfilerTestPeer, AddProcessSampleWithStreamLatency) { source_context.AddOutputs( {{}, {MakePacket("15").At(Timestamp(100))}}); - int64 when_source_started = 1000; - int64 when_source_finished = when_source_started + 150; + int64_t when_source_started = 1000; + int64_t when_source_finished = when_source_started + 150; simulation_clock->SleepUntil(absl::FromUnixMicros(when_source_started)); { GraphProfiler::Scope profiler_scope(GraphTrace::PROCESS, @@ -1206,7 +1206,7 @@ TEST(GraphProfilerTest, ParallelReads) { return absl::OkStatus(); })); MP_EXPECT_OK(graph.StartRun( - {{"range_step", MakePacket>(1000, 1)}})); + {{"range_step", MakePacket>(1000, 1)}})); // Repeatedly poll for profile data while the graph runs. while (true) { diff --git a/mediapipe/framework/profiler/graph_tracer.cc b/mediapipe/framework/profiler/graph_tracer.cc index be6ce5ae66..61e0d83030 100644 --- a/mediapipe/framework/profiler/graph_tracer.cc +++ b/mediapipe/framework/profiler/graph_tracer.cc @@ -45,7 +45,7 @@ absl::Duration GraphTracer::GetTraceLogInterval() { : kDefaultTraceLogInterval; } -int64 GraphTracer::GetTraceLogCapacity() { +int64_t GraphTracer::GetTraceLogCapacity() { return profiler_config_.trace_log_capacity() ? profiler_config_.trace_log_capacity() : 20000; diff --git a/mediapipe/framework/profiler/graph_tracer.h b/mediapipe/framework/profiler/graph_tracer.h index 89b43b58bf..5ce4384eee 100644 --- a/mediapipe/framework/profiler/graph_tracer.h +++ b/mediapipe/framework/profiler/graph_tracer.h @@ -50,7 +50,7 @@ class GraphTracer { absl::Duration GetTraceLogInterval(); // Returns the maximum number of trace events buffered in memory. - int64 GetTraceLogCapacity(); + int64_t GetTraceLogCapacity(); // Create a tracer to record up to |capacity| recent events. GraphTracer(const ProfilerConfig& profiler_config); diff --git a/mediapipe/framework/profiler/graph_tracer_test.cc b/mediapipe/framework/profiler/graph_tracer_test.cc index 4fe9826c06..fc6e810f98 100644 --- a/mediapipe/framework/profiler/graph_tracer_test.cc +++ b/mediapipe/framework/profiler/graph_tracer_test.cc @@ -46,7 +46,7 @@ namespace mediapipe { using PacketInfoMap = - ShardedMap>>; + ShardedMap>>; class GraphProfilerTestPeer { public: @@ -428,17 +428,17 @@ class GraphTracerE2ETest : public ::testing::Test { void SetUpRealClock() { clock_ = mediapipe::Clock::RealClock(); } - static Packet PacketAt(int64 ts) { - return Adopt(new int64(999)).At(Timestamp(ts)); + static Packet PacketAt(int64_t ts) { + return Adopt(new int64_t(999)).At(Timestamp(ts)); } static Packet None() { return Packet().At(Timestamp::OneOverPostStream()); } static bool IsNone(const Packet& packet) { return packet.Timestamp() == Timestamp::OneOverPostStream(); } // Return the values of the timestamps of a vector of Packets. - static std::vector TimestampValues( + static std::vector TimestampValues( const std::vector& packets) { - std::vector result; + std::vector result; for (const Packet& p : packets) { result.push_back(p.Timestamp().Value()); } @@ -551,7 +551,7 @@ class GraphTracerE2ETest : public ::testing::Test { }; // A callback to control the source LambdaCalculator. - std::vector> packets; + std::vector> packets; ProcessFunction wait_2 = [&](const InputStreamShardSet& inputs, OutputStreamShardSet* outputs) { if (!packets.empty()) { @@ -603,11 +603,11 @@ class GraphTracerE2ETest : public ::testing::Test { }; // Initialize a TimeHistogram protobuf with some latency values. -void FillHistogram(const std::vector& values, TimeHistogram* result) { +void FillHistogram(const std::vector& values, TimeHistogram* result) { result->set_num_intervals(100); result->set_interval_size_usec(1000); result->mutable_count()->Resize(result->num_intervals(), 0); - for (int64 v : values) { + for (int64_t v : values) { result->set_total(result->total() + v); int bin = v / result->interval_size_usec(); bin = std::min(bin, (int)result->num_intervals() - 1); diff --git a/mediapipe/framework/profiler/sharded_map_test.cc b/mediapipe/framework/profiler/sharded_map_test.cc index 5a47b390b4..bbc66e56a0 100644 --- a/mediapipe/framework/profiler/sharded_map_test.cc +++ b/mediapipe/framework/profiler/sharded_map_test.cc @@ -57,11 +57,11 @@ void TestWriteAndRead(Map& time_map) { // Tests writing, reading and erasing in a ShardedMap. TEST(ShardedMapTest, TestWriteAndRead) { - absl::node_hash_map simple_map; + absl::node_hash_map simple_map; TestWriteAndRead(simple_map); - ShardedMap safe_map(4999, 1); + ShardedMap safe_map(4999, 1); TestWriteAndRead(safe_map); - ShardedMap sharded_map(4999); + ShardedMap sharded_map(4999); TestWriteAndRead(sharded_map); } @@ -73,17 +73,17 @@ TEST(ShardedMapTest, TestWriteAndRead) { // Returns when all worker threads are done. template void TestParallelAccess(Map& time_map, int num_threads) { - int64 kNumTasks = 12; - int64 kMaxKey = 9901; - int64 kKeyStep = 1234; - int64 kNumWrites = 1000; - int64 kNumReads = 10; + int64_t kNumTasks = 12; + int64_t kMaxKey = 9901; + int64_t kKeyStep = 1234; + int64_t kNumWrites = 1000; + int64_t kNumReads = 10; mediapipe::ThreadPool pool(num_threads); pool.StartWorkers(); for (int i = 0; i < kNumTasks; ++i) { pool.Schedule([=, &time_map]() { - int64 next_key = i * kNumWrites * kNumReads * kKeyStep % kMaxKey; + int64_t next_key = i * kNumWrites * kNumReads * kKeyStep % kMaxKey; for (int j = 0; j < kNumWrites; ++j) { // One map write. time_map.insert({next_key, next_key}); @@ -123,15 +123,15 @@ absl::Duration time(const std::function& f) { // With bazel build -c opt, the ShardedMap reduces CPU time by 60%. TEST(ShardedMapTest, TestParallelAccess) { absl::Duration simple_time = time([] { - absl::node_hash_map simple_map; + absl::node_hash_map simple_map; TestParallelAccess(simple_map, 1); }); absl::Duration safe_time = time([] { - ShardedMap safe_map(4999, 1); + ShardedMap safe_map(4999, 1); TestParallelAccess(safe_map, 13); }); absl::Duration sharded_time = time([] { - ShardedMap sharded_map(4999); + ShardedMap sharded_map(4999); TestParallelAccess(sharded_map, 13); }); ABSL_LOG(INFO) << "Ellapsed time: simple_map: " << simple_time; diff --git a/mediapipe/framework/profiler/trace_buffer.h b/mediapipe/framework/profiler/trace_buffer.h index 8dc09aef7d..10921d3802 100644 --- a/mediapipe/framework/profiler/trace_buffer.h +++ b/mediapipe/framework/profiler/trace_buffer.h @@ -34,10 +34,10 @@ struct TraceEvent { bool is_finish = false; Timestamp input_ts = Timestamp::Unset(); Timestamp packet_ts = Timestamp::Unset(); - int32 node_id = -1; + int32_t node_id = -1; const std::string* stream_id = nullptr; - int32 thread_id = 0; - int64 event_data = 0; + int32_t thread_id = 0; + int64_t event_data = 0; TraceEvent(const EventType& event_type) : event_type(event_type) {} TraceEvent() {} diff --git a/mediapipe/framework/profiler/trace_builder.cc b/mediapipe/framework/profiler/trace_builder.cc index 9c3661ffe9..3f87dab346 100644 --- a/mediapipe/framework/profiler/trace_builder.cc +++ b/mediapipe/framework/profiler/trace_builder.cc @@ -103,7 +103,7 @@ void BasicTraceEventTypes(TraceEventRegistry* result) { class StringIdMap { public: // Returns the int32 identifier for a string object pointer. - int32 operator[](const std::string* id) { + int32_t operator[](const std::string* id) { if (id == nullptr) { return 0; } @@ -120,20 +120,20 @@ class StringIdMap { return string_id->second; } void clear() { pointer_id_map_.clear(), string_id_map_.clear(); } - const absl::node_hash_map& map() { + const absl::node_hash_map& map() { return string_id_map_; } private: - std::unordered_map pointer_id_map_; - absl::node_hash_map string_id_map_; - int32 next_id = 0; + std::unordered_map pointer_id_map_; + absl::node_hash_map string_id_map_; + int32_t next_id = 0; }; // A map defining int32 identifiers for object pointers. class AddressIdMap { public: - int32 operator[](int64 id) { + int32_t operator[](int64_t id) { auto pointer_id = pointer_id_map_.find(id); if (pointer_id != pointer_id_map_.end()) { return pointer_id->second; @@ -141,11 +141,11 @@ class AddressIdMap { return pointer_id_map_[id] = next_id++; } void clear() { pointer_id_map_.clear(); } - const absl::node_hash_map& map() { return pointer_id_map_; } + const absl::node_hash_map& map() { return pointer_id_map_; } private: - absl::node_hash_map pointer_id_map_; - int32 next_id = 0; + absl::node_hash_map pointer_id_map_; + int32_t next_id = 0; }; // Returns a vector of id names indexed by id. @@ -274,7 +274,7 @@ class TraceBuilder::Impl { private: // Calculate the base timestamp and time. void SetBaseTime(const std::vector& snapshot) { - if (base_time_ == std::numeric_limits::max()) { + if (base_time_ == std::numeric_limits::max()) { for (const TraceEvent& event : snapshot) { if (!event.input_ts.IsSpecialValue()) { base_ts_ = std::min(base_ts_, event.input_ts.Value()); @@ -284,20 +284,20 @@ class TraceBuilder::Impl { } base_time_ = std::min(base_time_, ToUnixMicros(event.event_time)); } - if (base_time_ == std::numeric_limits::max()) { + if (base_time_ == std::numeric_limits::max()) { base_time_ = 0; } - if (base_ts_ == std::numeric_limits::max()) { + if (base_ts_ == std::numeric_limits::max()) { base_ts_ = 0; } } } // Return a timestamp in micros relative to the base timetamp. - int64 LogTimestamp(Timestamp ts) { return ts.Value() - base_ts_; } + int64_t LogTimestamp(Timestamp ts) { return ts.Value() - base_ts_; } // Return a time in micros relative to the base time. - int64 LogTime(absl::Time time) { return ToUnixMicros(time) - base_time_; } + int64_t LogTime(absl::Time time) { return ToUnixMicros(time) - base_time_; } // Returns the output event that produced an input packet. const TraceEvent* FindOutputEvent(const TraceEvent& event) { @@ -394,9 +394,9 @@ class TraceBuilder::Impl { // Map from packet data pointers to int32 identifiers. AddressIdMap packet_data_id_map_; // The timestamp represented as 0 in the trace. - int64 base_ts_ = std::numeric_limits::max(); + int64_t base_ts_ = std::numeric_limits::max(); // The time represented as 0 in the trace. - int64 base_time_ = std::numeric_limits::max(); + int64_t base_time_ = std::numeric_limits::max(); // Indicates traits of each event type. TraceEventRegistry trace_event_registry_; }; diff --git a/mediapipe/util/tracking/box_detector.h b/mediapipe/util/tracking/box_detector.h index 27c0982126..dd66f4b8cb 100644 --- a/mediapipe/util/tracking/box_detector.h +++ b/mediapipe/util/tracking/box_detector.h @@ -68,7 +68,8 @@ class BoxDetectorInterface { // `timestamp_msec` should correspond to `tracking_data`. void DetectAndAddBox(const TrackingData &tracking_data, const TimedBoxProtoList &tracked_boxes, - int64 timestamp_msec, TimedBoxProtoList *detected_boxes); + int64_t timestamp_msec, + TimedBoxProtoList *detected_boxes); // Detects pre-set boxes from input frame and adds features from new boxes // into detector's index structure. Features and descriptors are extracted @@ -77,7 +78,8 @@ class BoxDetectorInterface { // `timestamp_msec` should correspond to `image`. void DetectAndAddBox(const cv::Mat &image, const TimedBoxProtoList &tracked_boxes, - int64 timestamp_msec, TimedBoxProtoList *detected_boxes); + int64_t timestamp_msec, + TimedBoxProtoList *detected_boxes); // Stops detection of box with `box_id`. void CancelBoxDetection(int box_id); @@ -97,7 +99,7 @@ class BoxDetectorInterface { void DetectAndAddBoxFromFeatures(const std::vector &features, const cv::Mat &descriptors, const TimedBoxProtoList &tracked_boxes, - int64 timestamp_msec, float scale_x, + int64_t timestamp_msec, float scale_x, float scale_y, TimedBoxProtoList *detected_boxes); diff --git a/mediapipe/util/tracking/box_tracker.h b/mediapipe/util/tracking/box_tracker.h index 8654e97fdc..a3842e2321 100644 --- a/mediapipe/util/tracking/box_tracker.h +++ b/mediapipe/util/tracking/box_tracker.h @@ -41,7 +41,7 @@ struct TimedBox { float right = 0; // Rotation of box w.r.t. center in radians. float rotation = 0; - int64 time_msec = 0; + int64_t time_msec = 0; // Confidence of the tracked box in range [0, 1]. float confidence = 0; std::vector quad_vertices; @@ -122,8 +122,8 @@ typedef std::map Path; // Returns box at specified time for a specific path segment. // Returns true on success, otherwise box is left untouched. // Optionally returns closest known MotionBoxState if state is not null. -bool TimedBoxAtTime(const PathSegment& segment, int64 time_msec, TimedBox* box, - MotionBoxState* state = nullptr); +bool TimedBoxAtTime(const PathSegment& segment, int64_t time_msec, + TimedBox* box, MotionBoxState* state = nullptr); // Tracks timed boxes from cached TrackingDataChunks created by // FlowPackagerCalculator. For usage see accompanying test. @@ -169,12 +169,12 @@ class BoxTracker { // Does not block caller, returns immediately. // Note: Use positive integers for id, we reserve negative ones for debugging // and visualization purposes. - void NewBoxTrack(const TimedBox& initial_pos, int id, int64 min_msec = 0, - int64 max_msec = std::numeric_limits::max()); + void NewBoxTrack(const TimedBox& initial_pos, int id, int64_t min_msec = 0, + int64_t max_msec = std::numeric_limits::max()); // Returns interval for which the state of the specified box is known. // (Returns -1, -1 if id is missing or no tracking has been done). - std::pair TrackInterval(int id); + std::pair TrackInterval(int id); // Returns box position for requested box at specified time. // Returns false if no such box exists. @@ -184,11 +184,11 @@ class BoxTracker { // checkpoints, the returned states are the closest (snapped) known tracking // states for the left and right checkpoint path. Therefore the size of states // is either two or one (if only one checkpoint exists). - bool GetTimedPosition(int id, int64 time_msec, TimedBox* result, + bool GetTimedPosition(int id, int64_t time_msec, TimedBox* result, std::vector* states = nullptr); // Returns chunk index for specified time. - int ChunkIdxFromTime(int64 msec) const { + int ChunkIdxFromTime(int64_t msec) const { return msec / options_.caching_chunk_size_msec(); } @@ -220,15 +220,15 @@ class BoxTracker { // To not interfere with other tracking requests it is recommended that you // use a unique id here. // Returns true on success. - bool GetTrackingData(int id, int64 request_time_msec, + bool GetTrackingData(int id, int64_t request_time_msec, TrackingData* tracking_data, int* tracking_data_msec = nullptr); private: // Asynchronous implementation function for box tracking. Schedules forward // and backward tracking. - void NewBoxTrackAsync(const TimedBox& initial_pos, int id, int64 min_msec, - int64 max_msec); + void NewBoxTrackAsync(const TimedBox& initial_pos, int id, int64_t min_msec, + int64_t max_msec); typedef std::pair AugmentedChunkPtr; // Attempts to read chunk at chunk_idx if it exists. Reads from cache @@ -250,7 +250,7 @@ class BoxTracker { ABSL_LOCKS_EXCLUDED(status_mutex_); // Determines closest index in passed TrackingDataChunk - int ClosestFrameIndex(int64 msec, const TrackingDataChunk& chunk) const; + int ClosestFrameIndex(int64_t msec, const TrackingDataChunk& chunk) const; // Adds new TimedBox to specified checkpoint with state. void AddBoxResult(const TimedBox& box, int id, int checkpoint, @@ -262,7 +262,7 @@ class BoxTracker { TrackingImplArgs(AugmentedChunkPtr chunk_ptr, const MotionBoxState& start_state_, int start_frame_, int chunk_idx_, int id_, int checkpoint_, bool forward_, - bool first_call_, int64 min_msec_, int64 max_msec_) + bool first_call_, int64_t min_msec_, int64_t max_msec_) : start_state(start_state_), start_frame(start_frame_), chunk_idx(chunk_idx_), @@ -295,8 +295,8 @@ class BoxTracker { int checkpoint; bool forward = true; bool first_call = true; - int64 min_msec; // minimum timestamp to track to - int64 max_msec; // maximum timestamp to track to + int64_t min_msec; // minimum timestamp to track to + int64_t max_msec; // maximum timestamp to track to }; // Actual tracking algorithm. diff --git a/mediapipe/util/tracking/flow_packager.h b/mediapipe/util/tracking/flow_packager.h index b0b6c9c155..4658201910 100644 --- a/mediapipe/util/tracking/flow_packager.h +++ b/mediapipe/util/tracking/flow_packager.h @@ -15,11 +15,11 @@ #ifndef MEDIAPIPE_UTIL_TRACKING_FLOW_PACKAGER_H_ #define MEDIAPIPE_UTIL_TRACKING_FLOW_PACKAGER_H_ +#include #include #include #include "absl/strings/string_view.h" -#include "mediapipe/framework/port/integral_types.h" #include "mediapipe/util/tracking/flow_packager.pb.h" #include "mediapipe/util/tracking/motion_estimation.pb.h" #include "mediapipe/util/tracking/region_flow.pb.h" @@ -117,10 +117,10 @@ class FlowPackager { // Fills in meta (first container) and termination data (last container). // Optionally, pass timestamps for each frame. void FinalizeTrackingContainerFormat( - std::vector* timestamps, // optional, can be null. + std::vector* timestamps, // optional, can be null. TrackingContainerFormat* container_fromat); void FinalizeTrackingContainerProto( - std::vector* timestamps, // optional, can be null. + std::vector* timestamps, // optional, can be null. TrackingContainerProto* proto); // Fast encode to binary representation. @@ -150,7 +150,7 @@ class FlowPackager { private: // Sets meta data for a set - void InitializeMetaData(int num_frames, const std::vector& msecs, + void InitializeMetaData(int num_frames, const std::vector& msecs, const std::vector& data_sizes, MetaData* meta_data) const; diff --git a/mediapipe/util/tracking/measure_time.h b/mediapipe/util/tracking/measure_time.h index 20b859b424..7a3a44b1ad 100644 --- a/mediapipe/util/tracking/measure_time.h +++ b/mediapipe/util/tracking/measure_time.h @@ -28,6 +28,7 @@ #ifndef MEDIAPIPE_UTIL_TRACKING_MEASURE_TIME_H_ #define MEDIAPIPE_UTIL_TRACKING_MEASURE_TIME_H_ +#include #include #include @@ -37,7 +38,6 @@ #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" -#include "mediapipe/framework/port/integral_types.h" extern bool flags_measure_time; @@ -133,10 +133,10 @@ class ScopedWallTimer { // While LogMessage is adequate for this, no good equivalent exists on // Android, so we employ a portable ostringstream for buffering. std::ostringstream stream_; - int64 start_time_; + int64_t start_time_; Accumulator* accumulator_; - int64 GetWallTime() { return absl::GetCurrentTimeNanos(); } + int64_t GetWallTime() { return absl::GetCurrentTimeNanos(); } }; class MeasureTimeFilter { diff --git a/mediapipe/util/tracking/motion_analysis.h b/mediapipe/util/tracking/motion_analysis.h index d2ed44d061..d633df42ff 100644 --- a/mediapipe/util/tracking/motion_analysis.h +++ b/mediapipe/util/tracking/motion_analysis.h @@ -85,12 +85,12 @@ class MotionAnalysis { // Call with every frame. Timestamp is optional (set to zero if not needed). // Optionally outputs list of features extracted from this frame. // Returns true on success. - bool AddFrame(const cv::Mat& frame, int64 timestamp_usec, + bool AddFrame(const cv::Mat& frame, int64_t timestamp_usec, RegionFlowFeatureList* feature_list = nullptr); // Same as above, but uses specified initial transform to seed // feature locations. - bool AddFrameWithSeed(const cv::Mat& frame, int64 timestamp_usec, + bool AddFrameWithSeed(const cv::Mat& frame, int64_t timestamp_usec, const Homography& initial_transform, RegionFlowFeatureList* feature_list = nullptr); @@ -106,7 +106,7 @@ class MotionAnalysis { // modification is applied. To yield modified features, simply // apply modify_features function to returned result. bool AddFrameGeneric( - const cv::Mat& frame, int64 timestamp_usec, + const cv::Mat& frame, int64_t timestamp_usec, const Homography& initial_transform, const Homography* rejection_transform = nullptr, const RegionFlowFeatureList* external_features = nullptr, diff --git a/mediapipe/util/tracking/motion_estimation.h b/mediapipe/util/tracking/motion_estimation.h index 4939a19179..1cd08063ea 100644 --- a/mediapipe/util/tracking/motion_estimation.h +++ b/mediapipe/util/tracking/motion_estimation.h @@ -51,13 +51,13 @@ #define MEDIAPIPE_UTIL_TRACKING_MOTION_ESTIMATION_H_ #include +#include #include #include #include #include #include -#include "mediapipe/framework/port/integral_types.h" #include "mediapipe/framework/port/vector.h" #include "mediapipe/util/tracking/camera_motion.pb.h" #include "mediapipe/util/tracking/motion_estimation.pb.h" @@ -675,8 +675,8 @@ class MotionEstimation { // during camera motion estimation. struct CameraMotionStreamHeader { CameraMotionStreamHeader() : frame_width(0), frame_height(0) {} - int32 frame_width; - int32 frame_height; + int32_t frame_width; + int32_t frame_height; }; // Direct fitting functions. diff --git a/mediapipe/util/tracking/push_pull_filtering.h b/mediapipe/util/tracking/push_pull_filtering.h index 80c6315329..56495f056a 100644 --- a/mediapipe/util/tracking/push_pull_filtering.h +++ b/mediapipe/util/tracking/push_pull_filtering.h @@ -114,7 +114,7 @@ class FilterWeightMultiplierOne { void SetLevel(int mip_map_level, bool pull_down_sampling) {} float GetWeight(const float* anchor_ptr, const float* filter_ptr, - const uint8* img_ptr, int x, int y) const { + const uint8_t* img_ptr, int x, int y) const { return 1.0f; } }; @@ -244,7 +244,7 @@ class PushPullFiltering { std::vector tap_offsets[4], std::vector tap_space_offsets[4]); - inline int ColorDiffL1(const uint8* lhs_ptr, const uint8* rhs_ptr) { + inline int ColorDiffL1(const uint8_t* lhs_ptr, const uint8_t* rhs_ptr) { return abs(static_cast(lhs_ptr[0]) - static_cast(rhs_ptr[0])) + abs(static_cast(lhs_ptr[1]) - static_cast(rhs_ptr[1])) + abs(static_cast(lhs_ptr[2]) - static_cast(rhs_ptr[2])); @@ -481,7 +481,7 @@ void PushPullFiltering::InitializeImagePyramid( ABSL_CHECK_EQ(base_level.type(), input_frame.type()); input_frame.copyTo(base_level); - CopyNecessaryBorder(&(*pyramid)[0]); + CopyNecessaryBorder(&(*pyramid)[0]); for (int l = 0; l < pyramid->size() - 1; ++l) { cv::Mat source((*pyramid)[l], @@ -491,7 +491,7 @@ void PushPullFiltering::InitializeImagePyramid( cv::Range(border_, (*pyramid)[l + 1].rows - border_), cv::Range(border_, (*pyramid)[l + 1].cols - border_)); cv::pyrDown(source, destination, destination.size()); - CopyNecessaryBorder(&(*pyramid)[l + 1]); + CopyNecessaryBorder(&(*pyramid)[l + 1]); } } @@ -908,7 +908,7 @@ void PushPullFiltering::PerformPushPullImpl( template inline const T* PtrOffset(const T* ptr, int offset) { - return reinterpret_cast(reinterpret_cast(ptr) + + return reinterpret_cast(reinterpret_cast(ptr) + offset); } @@ -994,8 +994,8 @@ void PushPullFiltering::PullDownSampling( float* dst_ptr = mip_map[l]->ptr(i + border) + border * channels; const float* src_ptr = mip_map[l - 1]->ptr(2 * i + border) + border * channels; - const uint8* img_ptr = - use_bilateral_ ? (input_frame_pyramid_[l - 1].template ptr( + const uint8_t* img_ptr = + use_bilateral_ ? (input_frame_pyramid_[l - 1].template ptr( 2 * i + border) + border * 3) : NULL; @@ -1017,7 +1017,7 @@ void PushPullFiltering::PullDownSampling( continue; } - const uint8* match_ptr = PtrOffset(img_ptr, (*space_offsets)[k]); + const uint8_t* match_ptr = PtrOffset(img_ptr, (*space_offsets)[k]); float bilateral_w = bilateral_lut_[ColorDiffL1(img_ptr, match_ptr) * bilateral_scale]; @@ -1152,9 +1152,9 @@ void PushPullFiltering::PushUpSampling( float* dst_ptr = mip_map[l]->ptr(i + border) + border * channels; const float* src_ptr = mip_map[l + 1]->ptr(i / 2 + border) + border * channels; - const uint8* img_ptr = + const uint8_t* img_ptr = use_bilateral_ - ? (input_frame_pyramid_[l].template ptr(i + border) + + ? (input_frame_pyramid_[l].template ptr(i + border) + border * 3) : NULL; @@ -1189,7 +1189,7 @@ void PushPullFiltering::PushUpSampling( continue; } - const uint8* match_ptr = PtrOffset(img_ptr, tap_space_offset[k]); + const uint8_t* match_ptr = PtrOffset(img_ptr, tap_space_offset[k]); float bilateral_w = bilateral_lut_[ColorDiffL1(img_ptr, match_ptr) * bilateral_scale]; diff --git a/mediapipe/util/tracking/region_flow_computation.h b/mediapipe/util/tracking/region_flow_computation.h index d0378767ba..8e774b1a41 100644 --- a/mediapipe/util/tracking/region_flow_computation.h +++ b/mediapipe/util/tracking/region_flow_computation.h @@ -89,11 +89,11 @@ class RegionFlowComputation { // Pass the frame's timestamp to have it stored in the result or zero if not // needed. // Returns true on success, false otherwise. - virtual bool AddImage(const cv::Mat& source, int64 timestamp_usec); + virtual bool AddImage(const cv::Mat& source, int64_t timestamp_usec); // Same as above, but seed initial feature position in the matching frame // with initial_transform. - virtual bool AddImageWithSeed(const cv::Mat& source, int64 timestamp_usec, + virtual bool AddImageWithSeed(const cv::Mat& source, int64_t timestamp_usec, const Homography& initial_transform); // Same as AddImage but also accepts an optional source_mask (pass empty @@ -102,7 +102,7 @@ class RegionFlowComputation { // grayscale of the same size as source, unless empty. virtual bool AddImageWithMask(const cv::Mat& source, const cv::Mat& source_mask, - int64 timestamp_usec); + int64_t timestamp_usec); // Call after AddImage* to retrieve last downscaled, grayscale image. cv::Mat GetGrayscaleFrameFromResults(); @@ -190,7 +190,7 @@ class RegionFlowComputation { // Adds image to the current buffer and starts tracking. bool AddImageAndTrack(const cv::Mat& source, const cv::Mat& source_mask, - int64 timestamp_usec, + int64_t timestamp_usec, const Homography& initial_transform); // Computes *change* in visual difference between adjacent frames. Normalized @@ -430,7 +430,7 @@ class RegionFlowComputation { std::unique_ptr feature_tmp_image_1_; std::unique_ptr feature_tmp_image_2_; - std::vector feature_status_; // Indicates if point could be + std::vector feature_status_; // Indicates if point could be // tracked. std::vector feature_track_error_; // Patch-based error. diff --git a/mediapipe/util/tracking/tone_estimation.h b/mediapipe/util/tracking/tone_estimation.h index 3d7defd2ec..a3b262656d 100644 --- a/mediapipe/util/tracking/tone_estimation.h +++ b/mediapipe/util/tracking/tone_estimation.h @@ -178,8 +178,8 @@ void ToneEstimation::ComputeClipMask(const ClipMaskOptions& options, } for (int i = 0; i < frame.rows; ++i) { - const uint8* img_ptr = frame.ptr(i); - uint8* clip_ptr = clip_mask->mask.template ptr(i); + const uint8_t* img_ptr = frame.ptr(i); + uint8_t* clip_ptr = clip_mask->mask.template ptr(i); for (int j = 0; j < frame.cols; ++j) { const int idx = C * j; @@ -328,8 +328,8 @@ void ToneEstimation::ComputeToneMatches( // bins to the right). However, matches that are over or underexposed // are discarded afterwards. for (int i = 0; i < patch_diam; ++i) { - const uint8* prev_ptr = prev_patch.ptr(i); - const uint8* curr_ptr = curr_patch.ptr(i); + const uint8_t* prev_ptr = prev_patch.ptr(i); + const uint8_t* curr_ptr = curr_patch.ptr(i); for (int j = 0; j < patch_diam; ++j) { const int j_c = C * j; for (int c = 0; c < C; ++c) { diff --git a/mediapipe/util/tracking/tone_models.h b/mediapipe/util/tracking/tone_models.h index bcbf158546..dcd74b7925 100644 --- a/mediapipe/util/tracking/tone_models.h +++ b/mediapipe/util/tracking/tone_models.h @@ -602,7 +602,7 @@ void ToneModelMethods::MapImageIndependent( // independent, we can assign the same value to each channel, which will be // transformed by the respective channel's transform. cv::Mat lut_input(1, 256, CV_8UC3); - uint8* lut_ptr = lut_input.ptr(0); + uint8_t* lut_ptr = lut_input.ptr(0); for (int k = 0; k < 256; ++k, lut_ptr += 3) { for (int c = 0; c < 3; ++c) { lut_ptr[c] = k; diff --git a/mediapipe/util/tracking/tracked_detection.h b/mediapipe/util/tracking/tracked_detection.h index 52032b631e..538aa02923 100644 --- a/mediapipe/util/tracking/tracked_detection.h +++ b/mediapipe/util/tracking/tracked_detection.h @@ -15,6 +15,7 @@ #ifndef MEDIAPIPE_UTIL_TRACKING_TRACKED_DETECTION_H_ #define MEDIAPIPE_UTIL_TRACKING_TRACKED_DETECTION_H_ +#include #include #include "absl/container/node_hash_map.h" @@ -29,7 +30,7 @@ class TrackedDetection { public: TrackedDetection() = delete; // Creates a detection that has a bounding box occupying the entire image. - TrackedDetection(int unique_id, int64 timestamp) + TrackedDetection(int unique_id, int64_t timestamp) : unique_id_(unique_id), initial_timestamp_(timestamp), last_updated_timestamp_(timestamp), @@ -37,7 +38,7 @@ class TrackedDetection { // Creates a detection with the specified bounding box normalized by image // dimensions. - TrackedDetection(int unique_id, int64 timestamp, + TrackedDetection(int unique_id, int64_t timestamp, const ::mediapipe::NormalizedRect& bounding_box) : unique_id_(unique_id), initial_timestamp_(timestamp), @@ -60,9 +61,9 @@ class TrackedDetection { // Merges labels and score from another TrackedDetection. void MergeLabelScore(const TrackedDetection& other); - int64 initial_timestamp() const { return initial_timestamp_; } - int64 last_updated_timestamp() const { return last_updated_timestamp_; } - void set_last_updated_timestamp(int64 timestamp) { + int64_t initial_timestamp() const { return initial_timestamp_; } + int64_t last_updated_timestamp() const { return last_updated_timestamp_; } + void set_last_updated_timestamp(int64_t timestamp) { last_updated_timestamp_ = timestamp; } @@ -111,9 +112,9 @@ class TrackedDetection { float bottom_ = 0.f; // The timestamp in milliseconds when this object is initialized. - int64 initial_timestamp_; + int64_t initial_timestamp_; // The latest timestamp when this object is updated. - int64 last_updated_timestamp_; + int64_t last_updated_timestamp_; // The id of the previous detection that this detection is associated with. int previous_id_; diff --git a/mediapipe/util/tracking/tracked_detection_manager.h b/mediapipe/util/tracking/tracked_detection_manager.h index 8dfc2ac2af..8c12c55362 100644 --- a/mediapipe/util/tracking/tracked_detection_manager.h +++ b/mediapipe/util/tracking/tracked_detection_manager.h @@ -15,6 +15,8 @@ #ifndef MEDIAPIPE_UTIL_TRACKING_DETECTION_MANAGER_H_ #define MEDIAPIPE_UTIL_TRACKING_DETECTION_MANAGER_H_ +#include + #include "absl/container/node_hash_map.h" #include "mediapipe/framework/formats/rect.pb.h" #include "mediapipe/util/tracking/tracked_detection.h" @@ -41,11 +43,12 @@ class TrackedDetectionManager { // detection. Returns the IDs of the detections that are removed due to // duplication. std::vector UpdateDetectionLocation( - int id, const ::mediapipe::NormalizedRect& bounding_box, int64 timestamp); + int id, const ::mediapipe::NormalizedRect& bounding_box, + int64_t timestamp); // Removes detections that are not updated after |timestamp|. Returns the IDs // of the detections that are removed. - std::vector RemoveObsoleteDetections(int64 timestamp); + std::vector RemoveObsoleteDetections(int64_t timestamp); // TODO: Do we really need this? Pursuit tracker doesn't do well // in loop closure. Boxes out of view are usually not attached to objects