From a53cc096050cab12940651799e13bee21bdcd1dc Mon Sep 17 00:00:00 2001 From: Craig Labenz Date: Mon, 24 Jul 2023 11:15:48 -0700 Subject: [PATCH] add c++ binding chicken scratches --- mediapipe/dart/mediapipe/cc/packet.c | 27 ++++++ mediapipe/dart/mediapipe/cc/packet.cc | 108 +++++++++++++++++++++ mediapipe/dart/mediapipe/cc/task_runner.cc | 40 ++++++++ 3 files changed, 175 insertions(+) create mode 100644 mediapipe/dart/mediapipe/cc/packet.c create mode 100644 mediapipe/dart/mediapipe/cc/packet.cc create mode 100644 mediapipe/dart/mediapipe/cc/task_runner.cc diff --git a/mediapipe/dart/mediapipe/cc/packet.c b/mediapipe/dart/mediapipe/cc/packet.c new file mode 100644 index 000000000..e275fdc23 --- /dev/null +++ b/mediapipe/dart/mediapipe/cc/packet.c @@ -0,0 +1,27 @@ +#include "packet.h" + +char *packet_create_string(char *data) +{ + + // another possibility - + // call MediaPipe functionality here instead of + // having another C++ layer? + + return PacketBinding.create_string(data); +} + +// psueodcode option 1 for high level C-wrapper: +// ClassificationResult classify_text(char* data) { +// packets = create_input_packets(data) +// results = classify(packets) +// return results +// } + +// psueodcode option 2 for high level C-wrapper: +// char* classify_text(char* data) { +// packets = create_input_packets(data) +// // could `results` already be a serioalized proto? +// results = classify(packets) +// // then we return the serialized proto straight to Dart? +// return results +// } \ No newline at end of file diff --git a/mediapipe/dart/mediapipe/cc/packet.cc b/mediapipe/dart/mediapipe/cc/packet.cc new file mode 100644 index 000000000..48d2c7d2b --- /dev/null +++ b/mediapipe/dart/mediapipe/cc/packet.cc @@ -0,0 +1,108 @@ +#include "google3/third_party/mediapipe/framework/packet.h"; + +// Copied from: https://source.corp.google.com/piper///depot/google3/third_party/mediapipe/python/pybind/packet_creator.cc;rcl=549487063 + +#ifdef __cplusplus +extern "C" +{ +#endif + + class PacketBinding + { + Packet create_string(std::string &data) + { + // actually call MediaPipe + } + + Packet create_bool(bool data) + { + } + + Packet create_int8(int8 data) + { + } + + Packet create_int16(int16 data) + { + } + + Packet create_int32(int32 data) + { + } + + Packet create_int64(int64 data) + { + } + + Packet create_uint8(uint8 data) + { + } + + Packet create_uint16(uint16 data) + { + } + + Packet create_uint32(uint32 data) + { + } + + Packet create_uint64(uint64 data) + { + } + + Packet create_float(float data) + { + } + + Packet create_double(double data) + { + } + + Packet create_int_array(std::vector &data) + { + } + + Packet create_float_array(std::vector &data) + { + } + + Packet create_int_vector(std::vector &data) + { + } + + Packet create_bool_vector(std::vector &data) + { + } + + Packet create_float_vector(std::vector &data) + { + } + + Packet create_string_vector(std::vector &data) + { + } + + Packet create_image_vector(std::vector &data) + { + } + + Packet create_packet_vector(std::vector &data) + { + } + + Packet create_string_to_packet_map(std::map &data) + { + } + + Packet create_matrix(Eigen::MatrixXf &matrix, bool transpose) + { + } + + Packet create_from_serialized(const bytes &encoding) + { + } + } + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/mediapipe/dart/mediapipe/cc/task_runner.cc b/mediapipe/dart/mediapipe/cc/task_runner.cc new file mode 100644 index 000000000..dd1e479b2 --- /dev/null +++ b/mediapipe/dart/mediapipe/cc/task_runner.cc @@ -0,0 +1,40 @@ +#include "third_party/mediapipe/tasks/cc/core/task_runner.h" + +// Inspired by: https://source.corp.google.com/piper///depot/google3/third_party/mediapipe/tasks/python/core/pybind/task_runner.cc;l=42;rcl=549487063 + +#ifdef __cplusplus +extern "C" +{ +#endif + + TaskRunner task_runner_create(CalculatorGraphConfig graph_config) + { + } + + Map task_runner_process(TaskRunner runner, Map input_packets) + { + } + + void task_runner_send(TaskRunner runner, Map input_packets) + { + } + + void task_runner_send(TaskRunner runner, Map input_packets) + { + } + + void task_runner_close(TaskRunner runner) + { + } + + void task_runner_restart(TaskRunner runner) + { + } + + CalculatorGraphConfig task_runner_get_graph_config(TaskRunner runner) + { + } + +#ifdef __cplusplus +} +#endif \ No newline at end of file