From 2842e21665ebdaa2f44ad96f15143b14bbf5a71a Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Wed, 24 May 2023 19:26:01 +0530 Subject: [PATCH] Updated parse_proto_utils --- .../vision/utils/sources/parse_proto_utils.cc | 15 ++++++--------- .../test/vision/utils/sources/parse_proto_utils.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/mediapipe/tasks/ios/test/vision/utils/sources/parse_proto_utils.cc b/mediapipe/tasks/ios/test/vision/utils/sources/parse_proto_utils.cc index 847f25271..c0c1e1f4d 100644 --- a/mediapipe/tasks/ios/test/vision/utils/sources/parse_proto_utils.cc +++ b/mediapipe/tasks/ios/test/vision/utils/sources/parse_proto_utils.cc @@ -17,7 +17,6 @@ limitations under the License. #include #include -#include "google/protobuf/io/zero_copy_stream_impl.h" namespace mediapipe::tasks::ios::test::vision::utils { @@ -26,18 +25,16 @@ namespace { } absl::Status get_proto_from_pbtxt(const std::string file_path, google::protobuf::Message& proto) { - std::ifstream fin(file_path); - - if(!fin.is_open()) return absl::InvalidArgumentError( + + std::ifstream file_input_stream(file_path); + if(!file_input_stream.is_open()) return absl::InvalidArgumentError( "Cannot read input file."); - std::stringstream strings_stream; - - strings_stream << fin.rdbuf(); + std::stringstream strings_stream ; + strings_stream << file_input_stream.rdbuf(); return TextFormat::ParseFromString(strings_stream.str(), &proto) ? absl::OkStatus() : absl::InvalidArgumentError( "Cannot read a valid proto from the input file."); - } -} // namespace mediapipe::tasks::text::utils +} // namespace mediapipe::tasks::ios::test::vision::utils diff --git a/mediapipe/tasks/ios/test/vision/utils/sources/parse_proto_utils.h b/mediapipe/tasks/ios/test/vision/utils/sources/parse_proto_utils.h index bafd00946..5ea59796b 100644 --- a/mediapipe/tasks/ios/test/vision/utils/sources/parse_proto_utils.h +++ b/mediapipe/tasks/ios/test/vision/utils/sources/parse_proto_utils.h @@ -23,6 +23,6 @@ limitations under the License. namespace mediapipe::tasks::ios::test::vision::utils { absl::Status get_proto_from_pbtxt(const std::string file_path, google::protobuf::Message& proto); -} // namespace mediapipe::tasks::ios::test::utils +} // namespace mediapipe::tasks::ios::test::vision::utils #endif // MEDIAPIPE_TASKS_IOS_TEST_VISION_UTILS_H_