From 316bd05e86d81053c81085d087e5ec30712e022d Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Wed, 29 Mar 2023 01:31:00 -0700 Subject: [PATCH] Internal change PiperOrigin-RevId: 520263349 --- mediapipe/python/pybind/image.cc | 18 +++---- mediapipe/python/pybind/image_frame.cc | 12 ++--- mediapipe/python/pybind/packet.cc | 4 +- mediapipe/python/pybind/packet_creator.cc | 38 +++++++------- mediapipe/python/pybind/packet_getter.cc | 60 +++++++++++------------ mediapipe/python/pybind/timestamp.cc | 4 +- 6 files changed, 68 insertions(+), 68 deletions(-) diff --git a/mediapipe/python/pybind/image.cc b/mediapipe/python/pybind/image.cc index 1bcca12ff..6049abfae 100644 --- a/mediapipe/python/pybind/image.cc +++ b/mediapipe/python/pybind/image.cc @@ -87,7 +87,7 @@ void ImageSubmodule(pybind11::module* module) { image .def( py::init([](mediapipe::ImageFormat::Format format, - const py::array_t& data) { + const py::array_t& data) { if (format != mediapipe::ImageFormat::GRAY8 && format != mediapipe::ImageFormat::SRGB && format != mediapipe::ImageFormat::SRGBA) { @@ -96,13 +96,13 @@ void ImageSubmodule(pybind11::module* module) { "SRGB, and SRGBA MediaPipe image formats."); } return Image(std::shared_ptr( - CreateImageFrame(format, data))); + CreateImageFrame(format, data))); }), R"doc(For uint8 data type, valid ImageFormat are GRAY8, SGRB, and SRGBA.)doc", py::arg("image_format"), py::arg("data").noconvert()) .def( py::init([](mediapipe::ImageFormat::Format format, - const py::array_t& data) { + const py::array_t& data) { if (format != mediapipe::ImageFormat::GRAY16 && format != mediapipe::ImageFormat::SRGB48 && format != mediapipe::ImageFormat::SRGBA64) { @@ -112,7 +112,7 @@ void ImageSubmodule(pybind11::module* module) { "SRGB48, and SRGBA64 MediaPipe image formats."); } return Image(std::shared_ptr( - CreateImageFrame(format, data))); + CreateImageFrame(format, data))); }), R"doc(For uint16 data type, valid ImageFormat are GRAY16, SRGB48, and SRGBA64.)doc", py::arg("image_format"), py::arg("data").noconvert()) @@ -182,11 +182,11 @@ void ImageSubmodule(pybind11::module* module) { py::cast(self, py::return_value_policy::reference); switch (self.GetImageFrameSharedPtr()->ByteDepth()) { case 1: - return GetValue(*self.GetImageFrameSharedPtr(), pos, - py_object); + return GetValue(*self.GetImageFrameSharedPtr(), pos, + py_object); case 2: - return GetValue(*self.GetImageFrameSharedPtr(), pos, - py_object); + return GetValue(*self.GetImageFrameSharedPtr(), pos, + py_object); case 4: return GetValue(*self.GetImageFrameSharedPtr(), pos, py_object); @@ -223,7 +223,7 @@ void ImageSubmodule(pybind11::module* module) { R"doc(Return True if the pixel data is unallocated.)doc") .def( "is_aligned", - [](Image& self, uint32 alignment_boundary) { + [](Image& self, uint32_t alignment_boundary) { return self.GetImageFrameSharedPtr()->IsAligned(alignment_boundary); }, R"doc(Return True if each row of the data is aligned to alignment boundary, which must be 1 or a power of 2. diff --git a/mediapipe/python/pybind/image_frame.cc b/mediapipe/python/pybind/image_frame.cc index bc7a9753d..d6126a542 100644 --- a/mediapipe/python/pybind/image_frame.cc +++ b/mediapipe/python/pybind/image_frame.cc @@ -114,7 +114,7 @@ void ImageFrameSubmodule(pybind11::module* module) { image_frame .def( py::init([](mediapipe::ImageFormat::Format format, - const py::array_t& data) { + const py::array_t& data) { if (format != mediapipe::ImageFormat::GRAY8 && format != mediapipe::ImageFormat::SRGB && format != mediapipe::ImageFormat::SRGBA) { @@ -122,13 +122,13 @@ void ImageFrameSubmodule(pybind11::module* module) { "uint8 image data should be one of the GRAY8, " "SRGB, and SRGBA MediaPipe image formats."); } - return CreateImageFrame(format, data); + return CreateImageFrame(format, data); }), R"doc(For uint8 data type, valid ImageFormat are GRAY8, SGRB, and SRGBA.)doc", py::arg("image_format"), py::arg("data").noconvert()) .def( py::init([](mediapipe::ImageFormat::Format format, - const py::array_t& data) { + const py::array_t& data) { if (format != mediapipe::ImageFormat::GRAY16 && format != mediapipe::ImageFormat::SRGB48 && format != mediapipe::ImageFormat::SRGBA64) { @@ -137,7 +137,7 @@ void ImageFrameSubmodule(pybind11::module* module) { "uint16 image data should be one of the GRAY16, " "SRGB48, and SRGBA64 MediaPipe image formats."); } - return CreateImageFrame(format, data); + return CreateImageFrame(format, data); }), R"doc(For uint16 data type, valid ImageFormat are GRAY16, SRGB48, and SRGBA64.)doc", py::arg("image_format"), py::arg("data").noconvert()) @@ -203,9 +203,9 @@ void ImageFrameSubmodule(pybind11::module* module) { py::cast(self, py::return_value_policy::reference); switch (self.ByteDepth()) { case 1: - return GetValue(self, pos, py_object); + return GetValue(self, pos, py_object); case 2: - return GetValue(self, pos, py_object); + return GetValue(self, pos, py_object); case 4: return GetValue(self, pos, py_object); default: diff --git a/mediapipe/python/pybind/packet.cc b/mediapipe/python/pybind/packet.cc index 29054a4b0..2171e0612 100644 --- a/mediapipe/python/pybind/packet.cc +++ b/mediapipe/python/pybind/packet.cc @@ -53,11 +53,11 @@ void PacketSubmodule(pybind11::module* module) { packet.def(py::init()) .def("at", [](Packet* self, - int64 ts_value) { return self->At(Timestamp(ts_value)); }) + int64_t ts_value) { return self->At(Timestamp(ts_value)); }) .def("at", [](Packet* self, Timestamp ts) { return self->At(ts); }) .def_property( "timestamp", &Packet::Timestamp, - [](Packet* p, int64 ts_value) { *p = p->At(Timestamp(ts_value)); }) + [](Packet* p, int64_t ts_value) { *p = p->At(Timestamp(ts_value)); }) .def("__repr__", [](const Packet& self) { return absl::StrCat( "(format, data, copy).release()); + return Adopt(CreateImageFrame(format, data, copy).release()); } else if (format == mediapipe::ImageFormat::GRAY16 || format == mediapipe::ImageFormat::SRGB48 || format == mediapipe::ImageFormat::SRGBA64) { - return Adopt(CreateImageFrame(format, data, copy).release()); + return Adopt(CreateImageFrame(format, data, copy).release()); } else if (format == mediapipe::ImageFormat::VEC32F1 || format == mediapipe::ImageFormat::VEC32F2) { return Adopt(CreateImageFrame(format, data, copy).release()); @@ -56,12 +56,12 @@ Packet CreateImagePacket(mediapipe::ImageFormat::Format format, format == mediapipe::ImageFormat::SRGBA || format == mediapipe::ImageFormat::GRAY8) { return MakePacket(std::shared_ptr( - CreateImageFrame(format, data, copy))); + CreateImageFrame(format, data, copy))); } else if (format == mediapipe::ImageFormat::GRAY16 || format == mediapipe::ImageFormat::SRGB48 || format == mediapipe::ImageFormat::SRGBA64) { return MakePacket(std::shared_ptr( - CreateImageFrame(format, data, copy))); + CreateImageFrame(format, data, copy))); } else if (format == mediapipe::ImageFormat::VEC32F1 || format == mediapipe::ImageFormat::VEC32F2) { return MakePacket(std::shared_ptr( @@ -139,7 +139,7 @@ void PublicPacketCreators(pybind11::module* m) { m->def( "create_int", - [](int64 data) { + [](int64_t data) { RaisePyErrorIfOverflow(data, INT_MIN, INT_MAX); return MakePacket(data); }, @@ -163,9 +163,9 @@ void PublicPacketCreators(pybind11::module* m) { m->def( "create_int8", - [](int64 data) { + [](int64_t data) { RaisePyErrorIfOverflow(data, INT8_MIN, INT8_MAX); - return MakePacket(data); + return MakePacket(data); }, R"doc(Create a MediaPipe int8 Packet from an integer. @@ -187,9 +187,9 @@ void PublicPacketCreators(pybind11::module* m) { m->def( "create_int16", - [](int64 data) { + [](int64_t data) { RaisePyErrorIfOverflow(data, INT16_MIN, INT16_MAX); - return MakePacket(data); + return MakePacket(data); }, R"doc(Create a MediaPipe int16 Packet from an integer. @@ -211,9 +211,9 @@ void PublicPacketCreators(pybind11::module* m) { m->def( "create_int32", - [](int64 data) { + [](int64_t data) { RaisePyErrorIfOverflow(data, INT32_MIN, INT32_MAX); - return MakePacket(data); + return MakePacket(data); }, R"doc(Create a MediaPipe int32 Packet from an integer. @@ -234,7 +234,7 @@ void PublicPacketCreators(pybind11::module* m) { py::arg().noconvert(), py::return_value_policy::move); m->def( - "create_int64", [](int64 data) { return MakePacket(data); }, + "create_int64", [](int64_t data) { return MakePacket(data); }, R"doc(Create a MediaPipe int64 Packet from an integer. Args: @@ -254,9 +254,9 @@ void PublicPacketCreators(pybind11::module* m) { m->def( "create_uint8", - [](int64 data) { + [](int64_t data) { RaisePyErrorIfOverflow(data, 0, UINT8_MAX); - return MakePacket(data); + return MakePacket(data); }, R"doc(Create a MediaPipe uint8 Packet from an integer. @@ -278,9 +278,9 @@ void PublicPacketCreators(pybind11::module* m) { m->def( "create_uint16", - [](int64 data) { + [](int64_t data) { RaisePyErrorIfOverflow(data, 0, UINT16_MAX); - return MakePacket(data); + return MakePacket(data); }, R"doc(Create a MediaPipe uint16 Packet from an integer. @@ -302,9 +302,9 @@ void PublicPacketCreators(pybind11::module* m) { m->def( "create_uint32", - [](int64 data) { + [](int64_t data) { RaisePyErrorIfOverflow(data, 0, UINT32_MAX); - return MakePacket(data); + return MakePacket(data); }, R"doc(Create a MediaPipe uint32 Packet from an integer. @@ -325,7 +325,7 @@ void PublicPacketCreators(pybind11::module* m) { py::arg().noconvert(), py::return_value_policy::move); m->def( - "create_uint64", [](uint64 data) { return MakePacket(data); }, + "create_uint64", [](uint64_t data) { return MakePacket(data); }, R"doc(Create a MediaPipe uint64 Packet from an integer. Args: diff --git a/mediapipe/python/pybind/packet_getter.cc b/mediapipe/python/pybind/packet_getter.cc index 2178727db..93adfa018 100644 --- a/mediapipe/python/pybind/packet_getter.cc +++ b/mediapipe/python/pybind/packet_getter.cc @@ -100,15 +100,15 @@ void PublicPacketGetters(pybind11::module* m) { "get_int", [](const Packet& packet) { if (packet.ValidateAsType().ok()) { - return static_cast(packet.Get()); - } else if (packet.ValidateAsType().ok()) { - return static_cast(packet.Get()); - } else if (packet.ValidateAsType().ok()) { - return static_cast(packet.Get()); - } else if (packet.ValidateAsType().ok()) { - return static_cast(packet.Get()); - } else if (packet.ValidateAsType().ok()) { - return static_cast(packet.Get()); + return static_cast(packet.Get()); + } else if (packet.ValidateAsType().ok()) { + return static_cast(packet.Get()); + } else if (packet.ValidateAsType().ok()) { + return static_cast(packet.Get()); + } else if (packet.ValidateAsType().ok()) { + return static_cast(packet.Get()); + } else if (packet.ValidateAsType().ok()) { + return static_cast(packet.Get()); } throw RaisePyError( PyExc_ValueError, @@ -133,14 +133,14 @@ void PublicPacketGetters(pybind11::module* m) { m->def( "get_uint", [](const Packet& packet) { - if (packet.ValidateAsType().ok()) { - return static_cast(packet.Get()); - } else if (packet.ValidateAsType().ok()) { - return static_cast(packet.Get()); - } else if (packet.ValidateAsType().ok()) { - return static_cast(packet.Get()); - } else if (packet.ValidateAsType().ok()) { - return static_cast(packet.Get()); + if (packet.ValidateAsType().ok()) { + return static_cast(packet.Get()); + } else if (packet.ValidateAsType().ok()) { + return static_cast(packet.Get()); + } else if (packet.ValidateAsType().ok()) { + return static_cast(packet.Get()); + } else if (packet.ValidateAsType().ok()) { + return static_cast(packet.Get()); } throw RaisePyError( PyExc_ValueError, @@ -194,19 +194,19 @@ void PublicPacketGetters(pybind11::module* m) { [](const Packet& packet) { if (packet.ValidateAsType>().ok()) { auto int_list = packet.Get>(); - return std::vector(int_list.begin(), int_list.end()); - } else if (packet.ValidateAsType>().ok()) { - auto int_list = packet.Get>(); - return std::vector(int_list.begin(), int_list.end()); - } else if (packet.ValidateAsType>().ok()) { - auto int_list = packet.Get>(); - return std::vector(int_list.begin(), int_list.end()); - } else if (packet.ValidateAsType>().ok()) { - auto int_list = packet.Get>(); - return std::vector(int_list.begin(), int_list.end()); - } else if (packet.ValidateAsType>().ok()) { - auto int_list = packet.Get>(); - return std::vector(int_list.begin(), int_list.end()); + return std::vector(int_list.begin(), int_list.end()); + } else if (packet.ValidateAsType>().ok()) { + auto int_list = packet.Get>(); + return std::vector(int_list.begin(), int_list.end()); + } else if (packet.ValidateAsType>().ok()) { + auto int_list = packet.Get>(); + return std::vector(int_list.begin(), int_list.end()); + } else if (packet.ValidateAsType>().ok()) { + auto int_list = packet.Get>(); + return std::vector(int_list.begin(), int_list.end()); + } else if (packet.ValidateAsType>().ok()) { + auto int_list = packet.Get>(); + return std::vector(int_list.begin(), int_list.end()); } throw RaisePyError(PyExc_ValueError, "Packet doesn't contain int, int8, int16, int32, or " diff --git a/mediapipe/python/pybind/timestamp.cc b/mediapipe/python/pybind/timestamp.cc index 6d4b58a5a..78c138047 100644 --- a/mediapipe/python/pybind/timestamp.cc +++ b/mediapipe/python/pybind/timestamp.cc @@ -56,7 +56,7 @@ void TimestampSubmodule(pybind11::module* module) { )doc"); timestamp.def(py::init()) - .def(py::init()) + .def(py::init()) .def_property_readonly("value", &Timestamp::Value) .def_property_readonly_static( "UNSET", [](py::object) { return Timestamp::Unset(); }) @@ -137,7 +137,7 @@ void TimestampSubmodule(pybind11::module* module) { timestamp_now = mp.Timestamp.from_seconds(time.time()) )doc"); - py::implicitly_convertible(); + py::implicitly_convertible(); } } // namespace python