From 91828a0116e24fee48b92301125c4de5f8ecfcb9 Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 23 Jun 2020 08:21:12 -0400 Subject: [PATCH] Edgetpu support (#26) * Move go-tflite custom to separate director to allow moving to upstream. Selected edgetpu compatible version of tensorflow. General cleanup * Add support for latest edgetpu library --- .gitignore | 3 +- Dockerfile | 34 +- Dockerfile.amd64 | 32 +- Dockerfile.arm32 | 37 +- Dockerfile.arm64 | 37 +- Dockerfile.builder | 35 +- Dockerfile.noavx | 32 +- Makefile | 5 + README.md | 2 + builder.sh | 9 +- detector/tflite/detector.go | 28 +- detector/tflite/{ => go-tflite}/callback.go | 0 .../{ => go-tflite}/delegates/delegates.go | 0 .../delegates/edgetpu/edgetpu.go | 8 +- .../delegates/edgetpu/edgetpu.go.h | 2 +- detector/tflite/{ => go-tflite}/tflite.go | 0 detector/tflite/{ => go-tflite}/tflite.go.h | 2 +- .../{ => go-tflite}/tflite_experimental.go | 0 .../{ => go-tflite}/tflite_experimental.go.h | 2 +- .../tflite/{ => go-tflite}/tflite_test.go | 0 .../tflite/{ => go-tflite}/tflite_type.go | 0 .../tflite/{ => go-tflite}/type_string.go | 0 go.mod | 8 +- go.sum | 15 + odrpc/rpc.pb.go | 1069 +++++++++++++---- odrpc/rpc.pb.gw.go | 179 ++- odrpc/rpc.swagger.json | 129 +- tftoolchain.sh => tf_arm_toolchain_patch.sh | 0 28 files changed, 1253 insertions(+), 415 deletions(-) mode change 100644 => 100755 builder.sh rename detector/tflite/{ => go-tflite}/callback.go (100%) rename detector/tflite/{ => go-tflite}/delegates/delegates.go (100%) rename detector/tflite/{ => go-tflite}/delegates/edgetpu/edgetpu.go (95%) rename detector/tflite/{ => go-tflite}/delegates/edgetpu/edgetpu.go.h (76%) rename detector/tflite/{ => go-tflite}/tflite.go (100%) rename detector/tflite/{ => go-tflite}/tflite.go.h (91%) rename detector/tflite/{ => go-tflite}/tflite_experimental.go (100%) rename detector/tflite/{ => go-tflite}/tflite_experimental.go.h (70%) rename detector/tflite/{ => go-tflite}/tflite_test.go (100%) rename detector/tflite/{ => go-tflite}/tflite_type.go (100%) rename detector/tflite/{ => go-tflite}/type_string.go (100%) rename tftoolchain.sh => tf_arm_toolchain_patch.sh (100%) diff --git a/.gitignore b/.gitignore index fb5e751..057df59 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ doods *.zip private models -example.yaml \ No newline at end of file +example.yaml +libedgetpu \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7c241b2..757272d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,8 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/p rm protoc-3.12.3-linux-x86_64.zip # Version Configuration -ARG BAZEL_VERSION="0.26.1" -ARG TF_VERSION="v1.15.3" +ARG BAZEL_VERSION="2.0.0" +ARG TF_VERSION="f394a768719a55b5c351ed1ecab2ec6f16f99dd4" ARG OPENCV_VERSION="4.3.0" ARG GO_VERSION="1.14.3" @@ -27,29 +27,31 @@ RUN wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/ # Download tensorflow sources ENV TF_VERSION $TF_VERSION -RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +#RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git && cd /opt/tensorflow && git checkout ${TF_VERSION} # Configure tensorflow ENV TF_NEED_GDR=0 TF_NEED_AWS=0 TF_NEED_GCP=0 TF_NEED_CUDA=0 TF_NEED_HDFS=0 TF_NEED_OPENCL_SYCL=0 TF_NEED_VERBS=0 TF_NEED_MPI=0 TF_NEED_MKL=0 TF_NEED_JEMALLOC=1 TF_ENABLE_XLA=0 TF_NEED_S3=0 TF_NEED_KAFKA=0 TF_NEED_IGNITE=0 TF_NEED_ROCM=0 RUN cd /opt/tensorflow && yes '' | ./configure -# Tensorflow build flags for rpi -ENV BAZEL_COPT_FLAGS="--local_resources 16000,16,1 -c opt --config monolithic --copt=-march=native --copt=-O3 --copt=-fomit-frame-pointer --incompatible_no_support_tools_in_action_inputs=false --config=noaws --config=nohdfs" -ENV BAZEL_EXTRA_FLAGS="" +# Tensorflow build flags +ENV BAZEL_COPT_FLAGS="-c opt --config monolithic --copt=-march=native --copt=-O3 --copt=-fomit-frame-pointer --incompatible_no_support_tools_in_action_inputs=false --config=noaws --config=nohdfs" +ENV BAZEL_EXTRA_FLAGS="--host_linkopt=-lm" # Compile and build tensorflow lite RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite:libtensorflowlite.so && \ install bazel-bin/tensorflow/lite/libtensorflowlite.so /usr/local/lib/libtensorflowlite.so && \ - bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/experimental/c:libtensorflowlite_c.so && \ - install bazel-bin/tensorflow/lite/experimental/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ + bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/c:libtensorflowlite_c.so && \ + install bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ mkdir -p /usr/local/include/flatbuffers && cp bazel-tensorflow/external/flatbuffers/include/flatbuffers/* /usr/local/include/flatbuffers # Compile and install tensorflow shared library RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow:libtensorflow.so && \ install bazel-bin/tensorflow/libtensorflow.so /usr/local/lib/libtensorflow.so && \ - ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 && \ + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.2 # cleanup so the cache directory isn't huge RUN cd /opt/tensorflow && \ @@ -84,15 +86,13 @@ RUN cd /tmp && \ make preinstall && make install && \ cd /tmp && rm -rf opencv* -# Download the edgetpu library and install it -RUN cd /tmp && git clone https://github.com/google-coral/edgetpu.git && \ - install edgetpu/libedgetpu/throttled/k8/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1.0 && \ - ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1 && \ +# Fetch the edgetpu library locally +ADD libedgetpu/out/throttled/k8/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1.0 +RUN ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1 && \ ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so && \ - mkdir -p /usr/local/include/libedgetpu && \ - install edgetpu/libedgetpu/edgetpu.h /usr/local/include/libedgetpu/edgetpu.h && \ - install edgetpu/libedgetpu/edgetpu_c.h /usr/local/include/libedgetpu/edgetpu_c.h && \ - rm -Rf edgetpu + mkdir -p /usr/local/include/libedgetpu +ADD libedgetpu/tflite/public/edgetpu.h /usr/local/include/libedgetpu/edgetpu.h +ADD libedgetpu/tflite/public/edgetpu_c.h /usr/local/include/libedgetpu/edgetpu_c.h # Configure the Go version to be used ENV GO_ARCH "amd64" diff --git a/Dockerfile.amd64 b/Dockerfile.amd64 index f1ea546..f5432c3 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile.amd64 @@ -14,8 +14,8 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/p rm protoc-3.12.3-linux-x86_64.zip # Version Configuration -ARG BAZEL_VERSION="0.26.1" -ARG TF_VERSION="v1.15.3" +ARG BAZEL_VERSION="2.0.0" +ARG TF_VERSION="f394a768719a55b5c351ed1ecab2ec6f16f99dd4" ARG OPENCV_VERSION="4.3.0" ARG GO_VERSION="1.14.3" @@ -27,29 +27,31 @@ RUN wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/ # Download tensorflow sources ENV TF_VERSION $TF_VERSION -RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +#RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git && cd /opt/tensorflow && git checkout ${TF_VERSION} # Configure tensorflow ENV TF_NEED_GDR=0 TF_NEED_AWS=0 TF_NEED_GCP=0 TF_NEED_CUDA=0 TF_NEED_HDFS=0 TF_NEED_OPENCL_SYCL=0 TF_NEED_VERBS=0 TF_NEED_MPI=0 TF_NEED_MKL=0 TF_NEED_JEMALLOC=1 TF_ENABLE_XLA=0 TF_NEED_S3=0 TF_NEED_KAFKA=0 TF_NEED_IGNITE=0 TF_NEED_ROCM=0 RUN cd /opt/tensorflow && yes '' | ./configure -# Tensorflow build flags for rpi +# Tensorflow build flags ENV BAZEL_COPT_FLAGS="--local_resources 16000,16,1 --config monolithic --copt=-O3 --copt=-fomit-frame-pointer --copt=-mfpmath=both --copt=-mavx --copt=-msse4.2 --incompatible_no_support_tools_in_action_inputs=false --config=noaws --config=nohdfs" -ENV BAZEL_EXTRA_FLAGS="" +ENV BAZEL_EXTRA_FLAGS="--host_linkopt=-lm" # Compile and build tensorflow lite RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite:libtensorflowlite.so && \ install bazel-bin/tensorflow/lite/libtensorflowlite.so /usr/local/lib/libtensorflowlite.so && \ - bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/experimental/c:libtensorflowlite_c.so && \ - install bazel-bin/tensorflow/lite/experimental/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ + bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/c:libtensorflowlite_c.so && \ + install bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ mkdir -p /usr/local/include/flatbuffers && cp bazel-tensorflow/external/flatbuffers/include/flatbuffers/* /usr/local/include/flatbuffers # Compile and install tensorflow shared library RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow:libtensorflow.so && \ install bazel-bin/tensorflow/libtensorflow.so /usr/local/lib/libtensorflow.so && \ - ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 && \ + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.2 # cleanup so the cache directory isn't huge RUN cd /opt/tensorflow && \ @@ -84,15 +86,13 @@ RUN cd /tmp && \ make preinstall && make install && \ cd /tmp && rm -rf opencv* -# Download the edgetpu library and install it -RUN cd /tmp && git clone https://github.com/google-coral/edgetpu.git && \ - install edgetpu/libedgetpu/throttled/k8/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1.0 && \ - ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1 && \ +# Fetch the edgetpu library locally +ADD libedgetpu/out/throttled/k8/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1.0 +RUN ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1 && \ ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so && \ - mkdir -p /usr/local/include/libedgetpu && \ - install edgetpu/libedgetpu/edgetpu.h /usr/local/include/libedgetpu/edgetpu.h && \ - install edgetpu/libedgetpu/edgetpu_c.h /usr/local/include/libedgetpu/edgetpu_c.h && \ - rm -Rf edgetpu + mkdir -p /usr/local/include/libedgetpu +ADD libedgetpu/tflite/public/edgetpu.h /usr/local/include/libedgetpu/edgetpu.h +ADD libedgetpu/tflite/public/edgetpu_c.h /usr/local/include/libedgetpu/edgetpu_c.h # Configure the Go version to be used ENV GO_ARCH "amd64" diff --git a/Dockerfile.arm32 b/Dockerfile.arm32 index cae6ca0..553df90 100644 --- a/Dockerfile.arm32 +++ b/Dockerfile.arm32 @@ -5,6 +5,7 @@ RUN dpkg --add-architecture armhf && \ apt-get update && apt-get install -y --no-install-recommends \ pkg-config zip zlib1g-dev unzip wget bash-completion git curl \ build-essential patch g++ python python-future python3 \ + python-numpy python-six \ cmake ca-certificates \ libc6-dev:armhf libstdc++6:armhf libusb-1.0-0:armhf @@ -15,8 +16,8 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/p rm protoc-3.12.3-linux-x86_64.zip # Version Configuration -ARG BAZEL_VERSION="0.26.1" -ARG TF_VERSION="v1.15.3" +ARG BAZEL_VERSION="2.0.0" +ARG TF_VERSION="f394a768719a55b5c351ed1ecab2ec6f16f99dd4" ARG OPENCV_VERSION="4.3.0" ARG GO_VERSION="1.14.3" @@ -28,37 +29,39 @@ RUN wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/ # Download tensorflow sources ENV TF_VERSION $TF_VERSION -RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +#RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git && cd /opt/tensorflow && git checkout ${TF_VERSION} # Download and configure the toolchain and patch tensorflow as needed ENV CROSSTOOL_COMPILER="yes" ENV CROSSTOOL_URL="https://releases.linaro.org/components/toolchain/binaries/5.5-2017.10/arm-linux-gnueabihf/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf.tar.xz" ENV CROSSTOOL_DIR="gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf" ENV CROSSTOOL_NAME="arm-linux-gnueabihf" -COPY tftoolchain.sh /opt/tftoolchain.sh -RUN cd /opt/tensorflow && /opt/tftoolchain.sh +COPY tf_arm_toolchain_patch.sh /opt/tf_arm_toolchain_patch.sh +RUN cd /opt/tensorflow && /opt/tf_arm_toolchain_patch.sh # Configure tensorflow ENV TF_NEED_GDR=0 TF_NEED_AWS=0 TF_NEED_GCP=0 TF_NEED_CUDA=0 TF_NEED_HDFS=0 TF_NEED_OPENCL_SYCL=0 TF_NEED_VERBS=0 TF_NEED_MPI=0 TF_NEED_MKL=0 TF_NEED_JEMALLOC=1 TF_ENABLE_XLA=0 TF_NEED_S3=0 TF_NEED_KAFKA=0 TF_NEED_IGNITE=0 TF_NEED_ROCM=0 RUN cd /opt/tensorflow && yes '' | ./configure -# Tensorflow build flags for rpi +# Tensorflow build flags ENV BAZEL_COPT_FLAGS="--local_resources 16000,16,1 --copt=-march=armv7-a --copt=-mfpu=neon-vfpv4 --copt=-mfloat-abi=hard --copt=-O3 --copt=-fno-tree-pre --copt=-fpermissive --copt=-std=c++11 --copt=-DS_IREAD=S_IRUSR --copt=-DS_IWRITE=S_IWUSR --copt=-U__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 --copt=-U__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 --copt=-U__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 --config=monolithic --copt=-funsafe-math-optimizations --copt=-ftree-vectorize --copt=-fomit-frame-pointer --copt=-DRASPBERRY_PI --noincompatible_strict_action_env --config=noaws --config=nohdfs --define tensorflow_mkldnn_contraction_kernel=0 --define=raspberry_pi_with_neon=true" -ENV BAZEL_EXTRA_FLAGS="--cpu=armeabi --crosstool_top=@local_config_arm_compiler//:toolchain" +ENV BAZEL_EXTRA_FLAGS="--cpu=armeabi --host_linkopt=-lm --crosstool_top=@local_config_arm_compiler//:toolchain" # Compile and build tensorflow lite RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite:libtensorflowlite.so && \ install bazel-bin/tensorflow/lite/libtensorflowlite.so /usr/local/lib/libtensorflowlite.so && \ - bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/experimental/c:libtensorflowlite_c.so && \ - install bazel-bin/tensorflow/lite/experimental/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ + bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/c:libtensorflowlite_c.so && \ + install bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ mkdir -p /usr/local/include/flatbuffers && cp bazel-tensorflow/external/flatbuffers/include/flatbuffers/* /usr/local/include/flatbuffers # Compile and install tensorflow shared library RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow:libtensorflow.so && \ install bazel-bin/tensorflow/libtensorflow.so /usr/local/lib/libtensorflow.so && \ - ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 && \ + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.2 # cleanup so the cache directory isn't huge RUN cd /opt/tensorflow && \ @@ -124,15 +127,13 @@ RUN cd /tmp && \ make preinstall && make install && \ cd /tmp && rm -rf opencv* -# Download the edgetpu library and install it -RUN cd /tmp && git clone https://github.com/google-coral/edgetpu.git && \ - install edgetpu/libedgetpu/direct/armv7a/libedgetpu.so.1.0 /tmp/sysroot/usr/lib/libedgetpu.so.1.0 && \ - ln -rs /tmp/sysroot/usr/lib/libedgetpu.so.1.0 /tmp/sysroot/usr/lib/libedgetpu.so.1 && \ +# Fetch the edgetpu library locally +ADD libedgetpu/out/throttled/armv7a/libedgetpu.so.1.0 /tmp/sysroot/usr/lib/libedgetpu.so.1.0 +RUN ln -rs /tmp/sysroot/usr/lib/libedgetpu.so.1.0 /tmp/sysroot/usr/lib/libedgetpu.so.1 && \ ln -rs /tmp/sysroot/usr/lib/libedgetpu.so.1.0 /tmp/sysroot/usr/lib/libedgetpu.so && \ - mkdir -p /tmp/sysroot/usr/include/libedgetpu && \ - install edgetpu/libedgetpu/edgetpu.h /tmp/sysroot/usr/include/libedgetpu/edgetpu.h && \ - install edgetpu/libedgetpu/edgetpu_c.h /tmp/sysroot/usr/include/libedgetpu/edgetpu_c.h && \ - rm -Rf edgetpu + mkdir -p /tmp/sysroot/usr/include/libedgetpu +ADD libedgetpu/tflite/public/edgetpu.h /tmp/sysroot/usr/include/libedgetpu/edgetpu.h +ADD libedgetpu/tflite/public/edgetpu_c.h /tmp/sysroot/usr/include/libedgetpu/edgetpu_c.h # Install Go ENV GO_VERSION $GO_VERSION diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index bff3a6c..fad222a 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -5,6 +5,7 @@ RUN dpkg --add-architecture arm64 && \ apt-get update && apt-get install -y --no-install-recommends \ pkg-config zip zlib1g-dev unzip wget bash-completion git curl \ build-essential patch g++ python python-future python3 \ + python-numpy python-six \ cmake ca-certificates \ libc6-dev:arm64 libstdc++6:arm64 libusb-1.0-0:arm64 @@ -15,8 +16,8 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/p rm protoc-3.12.3-linux-x86_64.zip # Version Configuration -ARG BAZEL_VERSION="0.26.1" -ARG TF_VERSION="v1.15.3" +ARG BAZEL_VERSION="2.0.0" +ARG TF_VERSION="f394a768719a55b5c351ed1ecab2ec6f16f99dd4" ARG OPENCV_VERSION="4.3.0" ARG GO_VERSION="1.14.3" @@ -28,15 +29,16 @@ RUN wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/ # Download tensorflow sources ENV TF_VERSION $TF_VERSION -RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +#RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git && cd /opt/tensorflow && git checkout ${TF_VERSION} # Download and configure the toolchain and patch tensorflow as needed ENV CROSSTOOL_COMPILER="yes" ENV CROSSTOOL_URL="https://releases.linaro.org/components/toolchain/binaries/5.5-2017.10/aarch64-linux-gnu/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu.tar.xz" ENV CROSSTOOL_DIR="gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu" ENV CROSSTOOL_NAME="aarch64-linux-gnu" -COPY tftoolchain.sh /opt/tftoolchain.sh -RUN cd /opt/tensorflow && /opt/tftoolchain.sh +COPY tf_arm_toolchain_patch.sh /opt/tf_arm_toolchain_patch.sh +RUN cd /opt/tensorflow && /opt/tf_arm_toolchain_patch.sh # Configure tensorflow ENV TF_NEED_GDR=0 TF_NEED_AWS=0 TF_NEED_GCP=0 TF_NEED_CUDA=0 TF_NEED_HDFS=0 TF_NEED_OPENCL_SYCL=0 TF_NEED_VERBS=0 TF_NEED_MPI=0 TF_NEED_MKL=0 TF_NEED_JEMALLOC=1 TF_ENABLE_XLA=0 TF_NEED_S3=0 TF_NEED_KAFKA=0 TF_NEED_IGNITE=0 TF_NEED_ROCM=0 @@ -44,21 +46,22 @@ RUN cd /opt/tensorflow && yes '' | ./configure # Tensorflow build flags for aarch64 (odroid c2 used for example) ENV BAZEL_COPT_FLAGS="--local_resources 16000,16,1 --copt=-march=armv8-a+crc+simd --copt=-mtune=cortex-a53 --copt=-O3 --copt=-flax-vector-conversions --copt=-std=c++11 --copt=-DS_IREAD=S_IRUSR --copt=-DS_IWRITE=S_IWUSR --config=monolithic --copt=-funsafe-math-optimizations --copt=-ftree-vectorize --copt=-fomit-frame-pointer --copt=-DRASPBERRY_PI --noincompatible_strict_action_env --config=v2 --config=noaws --config=nohdfs --define tensorflow_mkldnn_contraction_kernel=0 --define=raspberry_pi_with_neon=true" -ENV BAZEL_EXTRA_FLAGS="--cpu=armeabi --crosstool_top=@local_config_arm_compiler//:toolchain" +ENV BAZEL_EXTRA_FLAGS="--cpu=armeabi --host_linkopt=-lm --crosstool_top=@local_config_arm_compiler//:toolchain" # Compile and build tensorflow lite RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite:libtensorflowlite.so && \ install bazel-bin/tensorflow/lite/libtensorflowlite.so /usr/local/lib/libtensorflowlite.so && \ - bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/experimental/c:libtensorflowlite_c.so && \ - install bazel-bin/tensorflow/lite/experimental/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ + bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/c:libtensorflowlite_c.so && \ + install bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ mkdir -p /usr/local/include/flatbuffers && cp bazel-tensorflow/external/flatbuffers/include/flatbuffers/* /usr/local/include/flatbuffers # Compile and install tensorflow shared library RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow:libtensorflow.so && \ install bazel-bin/tensorflow/libtensorflow.so /usr/local/lib/libtensorflow.so && \ - ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 && \ + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.2 # cleanup so the cache directory isn't huge RUN cd /opt/tensorflow && \ @@ -125,15 +128,13 @@ RUN cd /tmp && \ make preinstall && make install && \ cd /tmp && rm -rf opencv* -# Download the edgetpu library and install it -RUN cd /tmp && git clone https://github.com/google-coral/edgetpu.git && \ - install edgetpu/libedgetpu/direct/aarch64/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1.0 && \ - ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1 && \ - ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so && \ - mkdir -p /usr/local/include/libedgetpu && \ - install edgetpu/libedgetpu/edgetpu.h /usr/local/include/libedgetpu/edgetpu.h && \ - install edgetpu/libedgetpu/edgetpu_c.h /usr/local/include/libedgetpu/edgetpu_c.h && \ - rm -Rf edgetpu +# Fetch the edgetpu library locally +ADD libedgetpu/out/throttled/aarch64/libedgetpu.so.1.0 /tmp/sysroot/usr/lib/libedgetpu.so.1.0 +RUN ln -rs /tmp/sysroot/usr/lib/libedgetpu.so.1.0 /tmp/sysroot/usr/lib/libedgetpu.so.1 && \ + ln -rs /tmp/sysroot/usr/lib/libedgetpu.so.1.0 /tmp/sysroot/usr/lib/libedgetpu.so && \ + mkdir -p /tmp/sysroot/usr/include/libedgetpu +ADD libedgetpu/tflite/public/edgetpu.h /tmp/sysroot/usr/include/libedgetpu/edgetpu.h +ADD libedgetpu/tflite/public/edgetpu_c.h /tmp/sysroot/usr/include/libedgetpu/edgetpu_c.h # Install Go ENV GO_VERSION $GO_VERSION diff --git a/Dockerfile.builder b/Dockerfile.builder index e06c8f2..dc13f2a 100644 --- a/Dockerfile.builder +++ b/Dockerfile.builder @@ -14,8 +14,8 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/p rm protoc-3.12.3-linux-x86_64.zip # Version Configuration -ARG BAZEL_VERSION="0.26.1" -ARG TF_VERSION="v1.15.3" +ARG BAZEL_VERSION="2.0.0" +ARG TF_VERSION="f394a768719a55b5c351ed1ecab2ec6f16f99dd4" ARG OPENCV_VERSION="4.3.0" ARG GO_VERSION="1.14.3" @@ -27,29 +27,31 @@ RUN wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/ # Download tensorflow sources ENV TF_VERSION $TF_VERSION -RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +#RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git && cd /opt/tensorflow && git checkout ${TF_VERSION} # Configure tensorflow ENV TF_NEED_GDR=0 TF_NEED_AWS=0 TF_NEED_GCP=0 TF_NEED_CUDA=0 TF_NEED_HDFS=0 TF_NEED_OPENCL_SYCL=0 TF_NEED_VERBS=0 TF_NEED_MPI=0 TF_NEED_MKL=0 TF_NEED_JEMALLOC=1 TF_ENABLE_XLA=0 TF_NEED_S3=0 TF_NEED_KAFKA=0 TF_NEED_IGNITE=0 TF_NEED_ROCM=0 RUN cd /opt/tensorflow && yes '' | ./configure -# Tensorflow build flags for rpi +# Tensorflow build flags ENV BAZEL_COPT_FLAGS="--local_resources 16000,16,1 -c opt --config monolithic --copt=-march=native --copt=-O3 --copt=-fomit-frame-pointer --incompatible_no_support_tools_in_action_inputs=false --config=noaws --config=nohdfs" -ENV BAZEL_EXTRA_FLAGS="" +ENV BAZEL_EXTRA_FLAGS="--host_linkopt=-lm" # Compile and build tensorflow lite RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite:libtensorflowlite.so && \ install bazel-bin/tensorflow/lite/libtensorflowlite.so /usr/local/lib/libtensorflowlite.so && \ - bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/experimental/c:libtensorflowlite_c.so && \ - install bazel-bin/tensorflow/lite/experimental/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ + bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/c:libtensorflowlite_c.so && \ + install bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ mkdir -p /usr/local/include/flatbuffers && cp bazel-tensorflow/external/flatbuffers/include/flatbuffers/* /usr/local/include/flatbuffers # Compile and install tensorflow shared library RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow:libtensorflow.so && \ install bazel-bin/tensorflow/libtensorflow.so /usr/local/lib/libtensorflow.so && \ - ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 && \ + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.2 # cleanup so the cache directory isn't huge RUN cd /opt/tensorflow && \ @@ -84,15 +86,13 @@ RUN cd /tmp && \ make preinstall && make install && \ cd /tmp && rm -rf opencv* -# Download the edgetpu library and install it -RUN cd /tmp && git clone https://github.com/google-coral/edgetpu.git && \ - install edgetpu/libedgetpu/throttled/k8/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1.0 && \ - ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1 && \ +# Fetch the edgetpu library locally +ADD libedgetpu/out/throttled/k8/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1.0 +RUN ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1 && \ ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so && \ - mkdir -p /usr/local/include/libedgetpu && \ - install edgetpu/libedgetpu/edgetpu.h /usr/local/include/libedgetpu/edgetpu.h && \ - install edgetpu/libedgetpu/edgetpu_c.h /usr/local/include/libedgetpu/edgetpu_c.h && \ - rm -Rf edgetpu + mkdir -p /usr/local/include/libedgetpu +ADD libedgetpu/tflite/public/edgetpu.h /usr/local/include/libedgetpu/edgetpu.h +ADD libedgetpu/tflite/public/edgetpu_c.h /usr/local/include/libedgetpu/edgetpu_c.h # Configure the Go version to be used ENV GO_ARCH "amd64" @@ -120,3 +120,6 @@ ENV CGO_ENABLED=1 ENV CGO_CFLAGS=-I/opt/tensorflow ENV PATH /usr/local/go/bin:/go/bin:${PATH} ENV GOPATH /go + +# Switch to /build +WORKDIR /build diff --git a/Dockerfile.noavx b/Dockerfile.noavx index 2bb4ea4..7abf349 100644 --- a/Dockerfile.noavx +++ b/Dockerfile.noavx @@ -14,8 +14,8 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/p rm protoc-3.12.3-linux-x86_64.zip # Version Configuration -ARG BAZEL_VERSION="0.26.1" -ARG TF_VERSION="v1.15.3" +ARG BAZEL_VERSION="2.0.0" +ARG TF_VERSION="f394a768719a55b5c351ed1ecab2ec6f16f99dd4" ARG OPENCV_VERSION="4.3.0" ARG GO_VERSION="1.14.3" @@ -27,29 +27,31 @@ RUN wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/ # Download tensorflow sources ENV TF_VERSION $TF_VERSION -RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +#RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git --branch $TF_VERSION --single-branch +RUN cd /opt && git clone https://github.com/tensorflow/tensorflow.git && cd /opt/tensorflow && git checkout ${TF_VERSION} # Configure tensorflow ENV TF_NEED_GDR=0 TF_NEED_AWS=0 TF_NEED_GCP=0 TF_NEED_CUDA=0 TF_NEED_HDFS=0 TF_NEED_OPENCL_SYCL=0 TF_NEED_VERBS=0 TF_NEED_MPI=0 TF_NEED_MKL=0 TF_NEED_JEMALLOC=1 TF_ENABLE_XLA=0 TF_NEED_S3=0 TF_NEED_KAFKA=0 TF_NEED_IGNITE=0 TF_NEED_ROCM=0 RUN cd /opt/tensorflow && yes '' | ./configure -# Tensorflow build flags for rpi +# Tensorflow build flags ENV BAZEL_COPT_FLAGS="--local_resources 16000,16,1 --config monolithic --copt=-O3 --copt=-fomit-frame-pointer --config=noaws --config=nohdfs" -ENV BAZEL_EXTRA_FLAGS="" +ENV BAZEL_EXTRA_FLAGS="--host_linkopt=-lm" # Compile and build tensorflow lite RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite:libtensorflowlite.so && \ install bazel-bin/tensorflow/lite/libtensorflowlite.so /usr/local/lib/libtensorflowlite.so && \ - bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/experimental/c:libtensorflowlite_c.so && \ - install bazel-bin/tensorflow/lite/experimental/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ + bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/lite/c:libtensorflowlite_c.so && \ + install bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so && \ mkdir -p /usr/local/include/flatbuffers && cp bazel-tensorflow/external/flatbuffers/include/flatbuffers/* /usr/local/include/flatbuffers # Compile and install tensorflow shared library RUN cd /opt/tensorflow && \ bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow:libtensorflow.so && \ install bazel-bin/tensorflow/libtensorflow.so /usr/local/lib/libtensorflow.so && \ - ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.1 && \ + ln -rs /usr/local/lib/libtensorflow.so /usr/local/lib/libtensorflow.so.2 # cleanup so the cache directory isn't huge RUN cd /opt/tensorflow && \ @@ -84,15 +86,13 @@ RUN cd /tmp && \ make preinstall && make install && \ cd /tmp && rm -rf opencv* -# Download the edgetpu library and install it -RUN cd /tmp && git clone https://github.com/google-coral/edgetpu.git && \ - install edgetpu/libedgetpu/throttled/k8/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1.0 && \ - ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1 && \ +# Fetch the edgetpu library locally +ADD libedgetpu/out/throttled/k8/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1.0 +RUN ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so.1 && \ ln -rs /usr/local/lib/libedgetpu.so.1.0 /usr/local/lib/libedgetpu.so && \ - mkdir -p /usr/local/include/libedgetpu && \ - install edgetpu/libedgetpu/edgetpu.h /usr/local/include/libedgetpu/edgetpu.h && \ - install edgetpu/libedgetpu/edgetpu_c.h /usr/local/include/libedgetpu/edgetpu_c.h && \ - rm -Rf edgetpu + mkdir -p /usr/local/include/libedgetpu +ADD libedgetpu/tflite/public/edgetpu.h /usr/local/include/libedgetpu/edgetpu.h +ADD libedgetpu/tflite/public/edgetpu_c.h /usr/local/include/libedgetpu/edgetpu_c.h # Configure the Go version to be used ENV GO_ARCH "amd64" diff --git a/Makefile b/Makefile index 6000e5a..900a1ad 100644 --- a/Makefile +++ b/Makefile @@ -81,3 +81,8 @@ docker-arm64: .PHONY: docker-builder docker-builder: docker build -t docker.io/snowzach/doods:builder -f Dockerfile.builder . + +.PHONY: libedgetpu +libedgetpu: + git clone https://github.com/google-coral/libedgetpu || true + bash -c 'cd libedgetpu; DOCKER_CPUS="k8 armv7a aarch64" DOCKER_TARGETS=libedgetpu make docker-build' diff --git a/README.md b/README.md index 521b8fc..9e7ac9e 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,9 @@ For whatever reason, it can take a good 60-80 seconds before the model finishes You can compile it yourself using the plain `Dockerfile` which should pick the optimal CPU flags for your architecture. Make the `snowzach/doods:local` image with this command: ``` +$ make libedgetpu $ make docker ``` +You only need to make libedgetpu once, it will download and compile it for all architectures. I hope to streamline that process into the main dockerfile at some point [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QG353JUXA6BFW&source=url) diff --git a/builder.sh b/builder.sh old mode 100644 new mode 100755 index c4f12db..9227ac6 --- a/builder.sh +++ b/builder.sh @@ -1,2 +1,9 @@ #!/bin/bash -docker run -it -v $PWD:/build --device /dev/bus/usb snowzach/doods:builder bash +# Check for edgetpu and specify devices if found +DOCKER_EXTRA="" +if `lsusb | egrep "(1a6e:089a|18d1:9302)" > /dev/null`; then + DOCKER_EXTRA="--device /dev/bus/usb " + echo "EdgeTPU detected..." +fi + +docker run -it -v $PWD:/build -v $PWD:/build ${DOCKER_EXTRA} snowzach/doods:builder bash diff --git a/detector/tflite/detector.go b/detector/tflite/detector.go index 4df4004..5b4d952 100644 --- a/detector/tflite/detector.go +++ b/detector/tflite/detector.go @@ -18,8 +18,10 @@ import ( "github.com/snowzach/doods/conf" "github.com/snowzach/doods/detector/dconfig" - "github.com/snowzach/doods/detector/tflite/delegates/edgetpu" "github.com/snowzach/doods/odrpc" + + "github.com/snowzach/doods/detector/tflite/go-tflite" + "github.com/snowzach/doods/detector/tflite/go-tflite/delegates/edgetpu" ) const ( @@ -32,8 +34,8 @@ type detector struct { logger *zap.SugaredLogger labels map[int]string - model *Model - inputType TensorType + model *tflite.Model + inputType tflite.TensorType outputFormat int pool chan *tflInterpreter @@ -45,7 +47,7 @@ type detector struct { type tflInterpreter struct { device *edgetpu.Device - *Interpreter + *tflite.Interpreter } func New(c *dconfig.DetectorConfig) (*detector, error) { @@ -65,7 +67,7 @@ func New(c *dconfig.DetectorConfig) (*detector, error) { d.config.Labels = make([]string, 0) // Create the model - d.model = NewModelFromFile(d.config.Model) + d.model = tflite.NewModelFromFile(d.config.Model) if d.model == nil { return nil, fmt.Errorf("could not load model %s", d.config.Model) } @@ -142,7 +144,7 @@ func New(c *dconfig.DetectorConfig) (*detector, error) { d.config.Width = int32(input.Dim(2)) d.config.Channels = int32(input.Dim(3)) d.inputType = input.Type() - if d.inputType != UInt8 { + if d.inputType != tflite.UInt8 { return nil, fmt.Errorf("unsupported tensor input type: %s", d.inputType) } @@ -165,7 +167,7 @@ func New(c *dconfig.DetectorConfig) (*detector, error) { d.outputFormat = OutputFormat_1_scores // Check the output types tensor := interpreter.GetOutputTensor(0) - if tensor.Type() != UInt8 { + if tensor.Type() != tflite.UInt8 { return nil, fmt.Errorf("unsupported tensor output type: %s", tensor.Type()) } // Ensure the length of the labels match the detection size @@ -179,9 +181,9 @@ func New(c *dconfig.DetectorConfig) (*detector, error) { return d, nil } -func (d *detector) newInterpreter(device *edgetpu.Device) (*Interpreter, error) { +func (d *detector) newInterpreter(device *edgetpu.Device) (*tflite.Interpreter, error) { // Options - options := NewInterpreterOptions() + options := tflite.NewInterpreterOptions() options.SetNumThread(d.numThreads) options.SetErrorReporter(func(msg string, user_data interface{}) { d.logger.Warnw("Error", "message", msg, "user_data", user_data) @@ -196,14 +198,14 @@ func (d *detector) newInterpreter(device *edgetpu.Device) (*Interpreter, error) options.AddDelegate(etpuInstance) } - interpreter := NewInterpreter(d.model, options) + interpreter := tflite.NewInterpreter(d.model, options) if interpreter == nil { return nil, fmt.Errorf("Could not create interpreter") } // Allocate status := interpreter.AllocateTensors() - if status != OK { + if status != tflite.OK { return nil, fmt.Errorf("interpreter allocate failed") } @@ -279,7 +281,7 @@ func (d *detector) Detect(ctx context.Context, request *odrpc.DetectRequest) (*o start := time.Now() // Perform the detection - var invokeStatus Status + var invokeStatus tflite.Status complete := make(chan struct{}) go func() { invokeStatus = interpreter.Invoke() @@ -301,7 +303,7 @@ func (d *detector) Detect(ctx context.Context, request *odrpc.DetectRequest) (*o <-complete // Complete no timeout // Capture Errors - if invokeStatus != OK { + if invokeStatus != tflite.OK { d.logger.Errorw("Detector error", "id", request.Id, "status", invokeStatus, zap.Any("device", interpreter.device)) return &odrpc.DetectResponse{ Id: request.Id, diff --git a/detector/tflite/callback.go b/detector/tflite/go-tflite/callback.go similarity index 100% rename from detector/tflite/callback.go rename to detector/tflite/go-tflite/callback.go diff --git a/detector/tflite/delegates/delegates.go b/detector/tflite/go-tflite/delegates/delegates.go similarity index 100% rename from detector/tflite/delegates/delegates.go rename to detector/tflite/go-tflite/delegates/delegates.go diff --git a/detector/tflite/delegates/edgetpu/edgetpu.go b/detector/tflite/go-tflite/delegates/edgetpu/edgetpu.go similarity index 95% rename from detector/tflite/delegates/edgetpu/edgetpu.go rename to detector/tflite/go-tflite/delegates/edgetpu/edgetpu.go index 7965603..949108e 100644 --- a/detector/tflite/delegates/edgetpu/edgetpu.go +++ b/detector/tflite/go-tflite/delegates/edgetpu/edgetpu.go @@ -12,7 +12,7 @@ import ( "fmt" "unsafe" - "github.com/snowzach/doods/detector/tflite/delegates" + "github.com/snowzach/doods/detector/tflite/go-tflite/delegates" ) const ( @@ -50,7 +50,7 @@ func New(device Device) delegates.Delegater { // Delete the delegate func (etpu *Delegate) Delete() { - C.edgetpu_free_delegate(etpu.d); + C.edgetpu_free_delegate(etpu.d) } // Return a pointer @@ -77,7 +77,7 @@ func Verbosity(v int) { // DeviceList fetches a list of devices func DeviceList() ([]Device, error) { - + // Fetch the list of devices var numDevices C.size_t cDevices := C.edgetpu_list_devices(&numDevices) @@ -85,7 +85,7 @@ func DeviceList() ([]Device, error) { if cDevices == nil { return []Device{}, nil } - + // Cast the result to a Go slice deviceSlice := (*[1024]C.struct_edgetpu_device)(unsafe.Pointer(cDevices))[:numDevices:numDevices] diff --git a/detector/tflite/delegates/edgetpu/edgetpu.go.h b/detector/tflite/go-tflite/delegates/edgetpu/edgetpu.go.h similarity index 76% rename from detector/tflite/delegates/edgetpu/edgetpu.go.h rename to detector/tflite/go-tflite/delegates/edgetpu/edgetpu.go.h index b2b77d3..e805934 100644 --- a/detector/tflite/delegates/edgetpu/edgetpu.go.h +++ b/detector/tflite/go-tflite/delegates/edgetpu/edgetpu.go.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #endif diff --git a/detector/tflite/tflite.go b/detector/tflite/go-tflite/tflite.go similarity index 100% rename from detector/tflite/tflite.go rename to detector/tflite/go-tflite/tflite.go diff --git a/detector/tflite/tflite.go.h b/detector/tflite/go-tflite/tflite.go.h similarity index 91% rename from detector/tflite/tflite.go.h rename to detector/tflite/go-tflite/tflite.go.h index 138b845..a2570c3 100644 --- a/detector/tflite/tflite.go.h +++ b/detector/tflite/go-tflite/tflite.go.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include extern void _go_error_reporter(void*, char*); diff --git a/detector/tflite/tflite_experimental.go b/detector/tflite/go-tflite/tflite_experimental.go similarity index 100% rename from detector/tflite/tflite_experimental.go rename to detector/tflite/go-tflite/tflite_experimental.go diff --git a/detector/tflite/tflite_experimental.go.h b/detector/tflite/go-tflite/tflite_experimental.go.h similarity index 70% rename from detector/tflite/tflite_experimental.go.h rename to detector/tflite/go-tflite/tflite_experimental.go.h index 1980fd3..6bedd70 100644 --- a/detector/tflite/tflite_experimental.go.h +++ b/detector/tflite/go-tflite/tflite_experimental.go.h @@ -6,5 +6,5 @@ #include #include #include -#include +#include #endif diff --git a/detector/tflite/tflite_test.go b/detector/tflite/go-tflite/tflite_test.go similarity index 100% rename from detector/tflite/tflite_test.go rename to detector/tflite/go-tflite/tflite_test.go diff --git a/detector/tflite/tflite_type.go b/detector/tflite/go-tflite/tflite_type.go similarity index 100% rename from detector/tflite/tflite_type.go rename to detector/tflite/go-tflite/tflite_type.go diff --git a/detector/tflite/type_string.go b/detector/tflite/go-tflite/type_string.go similarity index 100% rename from detector/tflite/type_string.go rename to detector/tflite/go-tflite/type_string.go diff --git a/go.mod b/go.mod index 3941e2b..9a71439 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,9 @@ require ( github.com/go-chi/chi v4.0.2+incompatible github.com/go-chi/render v1.0.1 github.com/gogo/protobuf v1.3.1 - github.com/golang/protobuf v1.3.2 + github.com/golang/protobuf v1.3.3 github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 - github.com/grpc-ecosystem/grpc-gateway v1.12.1 + github.com/grpc-ecosystem/grpc-gateway v1.14.6 github.com/hybridgroup/mjpeg v0.0.0-20140228234708-4680f319790e github.com/lmittmann/ppm v1.0.0 github.com/mattn/go-pointer v0.0.0-20190911064623-a0a44394634f @@ -30,8 +30,8 @@ require ( golang.org/x/net v0.0.0-20191105084925-a882066a44e0 golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd // indirect golang.org/x/tools v0.0.0-20191105231337-689d0f08e67a // indirect - google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 - google.golang.org/grpc v1.25.0 + google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884 + google.golang.org/grpc v1.29.1 gopkg.in/yaml.v2 v2.2.5 // indirect ) diff --git a/go.sum b/go.sum index 0231c5c..332cc6a 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,7 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -21,6 +22,7 @@ github.com/blendle/zapdriver v1.2.1/go.mod h1:mdXfREi6u5MArG4j9fewC+FGnXaBR+T4Ox github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= @@ -34,6 +36,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/faiface/glhf v0.0.0-20181018222622-82a6317ac380/go.mod h1:zqnPFFIuYFFxl7uH2gYByJwIVKG7fRqlqQCbzAnHs9g= github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3/go.mod h1:VEPNJUlxl5KdWjDvz6Q1l+rJlxF2i6xqDeGuGAxa87M= @@ -69,6 +73,8 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -90,6 +96,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.12.0 h1:SFRyYOyhgiU1kJG/PmbkWP/iSlizvD github.com/grpc-ecosystem/grpc-gateway v1.12.0/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.12.1 h1:zCy2xE9ablevUOrUZc3Dl72Dt+ya2FNAvC2yLYMHzi4= github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= +github.com/grpc-ecosystem/grpc-gateway v1.14.6 h1:8ERzHx8aj1Sc47mu9n/AksaKCSWrMchFtkdrS4BIj5o= +github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -258,6 +266,7 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -325,6 +334,8 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 h1:UXl+Zk3jqqcbEVV7ace5lrt4YdA4tXiz3f/KbmD29Vo= google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884 h1:fiNLklpBwWK1mth30Hlwk+fcdBmIALlgF5iy77O37Ig= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -335,6 +346,10 @@ google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= google.golang.org/grpc v1.25.0 h1:ItERT+UbGdX+s4u+nQNlVM/Q7cbmf7icKfvzbWqVtq0= google.golang.org/grpc v1.25.0/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= diff --git a/odrpc/rpc.pb.go b/odrpc/rpc.pb.go index f674772..9f22d30 100644 --- a/odrpc/rpc.pb.go +++ b/odrpc/rpc.pb.go @@ -14,8 +14,11 @@ import ( empty "github.com/golang/protobuf/ptypes/empty" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" io "io" math "math" + math_bits "math/bits" reflect "reflect" strings "strings" ) @@ -29,7 +32,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GetDetectorsResponse struct { Detectors []*Detector `protobuf:"bytes,1,rep,name=detectors,proto3" json:"detectors,omitempty"` @@ -48,7 +51,7 @@ func (m *GetDetectorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte return xxx_messageInfo_GetDetectorsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -104,7 +107,7 @@ func (m *Detector) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Detector.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -182,6 +185,8 @@ type DetectRequest struct { Data Raw `protobuf:"bytes,3,opt,name=data,proto3,casttype=Raw" json:"data"` // What to detect Detect map[string]float32 `protobuf:"bytes,4,rep,name=detect,proto3" json:"detect,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"fixed32,2,opt,name=value,proto3"` + // Sub regions for detection + Regions []*DetectRegion `protobuf:"bytes,5,rep,name=regions,proto3" json:"regions,omitempty"` } func (m *DetectRequest) Reset() { *m = DetectRequest{} } @@ -197,7 +202,7 @@ func (m *DetectRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return xxx_messageInfo_DetectRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -244,6 +249,90 @@ func (m *DetectRequest) GetDetect() map[string]float32 { return nil } +func (m *DetectRequest) GetRegions() []*DetectRegion { + if m != nil { + return m.Regions + } + return nil +} + +type DetectRegion struct { + // Coordinates + Top float32 `protobuf:"fixed32,1,opt,name=top,proto3" json:"top"` + Left float32 `protobuf:"fixed32,2,opt,name=left,proto3" json:"left"` + Bottom float32 `protobuf:"fixed32,3,opt,name=bottom,proto3" json:"bottom"` + Right float32 `protobuf:"fixed32,4,opt,name=right,proto3" json:"right"` + // What to detect + Detect map[string]float32 `protobuf:"bytes,5,rep,name=detect,proto3" json:"detect,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"fixed32,2,opt,name=value,proto3"` +} + +func (m *DetectRegion) Reset() { *m = DetectRegion{} } +func (*DetectRegion) ProtoMessage() {} +func (*DetectRegion) Descriptor() ([]byte, []int) { + return fileDescriptor_edafdb9f55df517e, []int{3} +} +func (m *DetectRegion) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DetectRegion) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DetectRegion.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DetectRegion) XXX_Merge(src proto.Message) { + xxx_messageInfo_DetectRegion.Merge(m, src) +} +func (m *DetectRegion) XXX_Size() int { + return m.Size() +} +func (m *DetectRegion) XXX_DiscardUnknown() { + xxx_messageInfo_DetectRegion.DiscardUnknown(m) +} + +var xxx_messageInfo_DetectRegion proto.InternalMessageInfo + +func (m *DetectRegion) GetTop() float32 { + if m != nil { + return m.Top + } + return 0 +} + +func (m *DetectRegion) GetLeft() float32 { + if m != nil { + return m.Left + } + return 0 +} + +func (m *DetectRegion) GetBottom() float32 { + if m != nil { + return m.Bottom + } + return 0 +} + +func (m *DetectRegion) GetRight() float32 { + if m != nil { + return m.Right + } + return 0 +} + +func (m *DetectRegion) GetDetect() map[string]float32 { + if m != nil { + return m.Detect + } + return nil +} + // Area for detection type Detection struct { // Coordinates @@ -258,7 +347,7 @@ type Detection struct { func (m *Detection) Reset() { *m = Detection{} } func (*Detection) ProtoMessage() {} func (*Detection) Descriptor() ([]byte, []int) { - return fileDescriptor_edafdb9f55df517e, []int{3} + return fileDescriptor_edafdb9f55df517e, []int{4} } func (m *Detection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -268,7 +357,7 @@ func (m *Detection) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Detection.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -341,7 +430,7 @@ type DetectResponse struct { func (m *DetectResponse) Reset() { *m = DetectResponse{} } func (*DetectResponse) ProtoMessage() {} func (*DetectResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_edafdb9f55df517e, []int{4} + return fileDescriptor_edafdb9f55df517e, []int{5} } func (m *DetectResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -351,7 +440,7 @@ func (m *DetectResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return xxx_messageInfo_DetectResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -396,6 +485,8 @@ func init() { proto.RegisterType((*Detector)(nil), "odrpc.Detector") proto.RegisterType((*DetectRequest)(nil), "odrpc.DetectRequest") proto.RegisterMapType((map[string]float32)(nil), "odrpc.DetectRequest.DetectEntry") + proto.RegisterType((*DetectRegion)(nil), "odrpc.DetectRegion") + proto.RegisterMapType((map[string]float32)(nil), "odrpc.DetectRegion.DetectEntry") proto.RegisterType((*Detection)(nil), "odrpc.Detection") proto.RegisterType((*DetectResponse)(nil), "odrpc.DetectResponse") } @@ -403,52 +494,55 @@ func init() { func init() { proto.RegisterFile("odrpc/rpc.proto", fileDescriptor_edafdb9f55df517e) } var fileDescriptor_edafdb9f55df517e = []byte{ - // 713 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xbd, 0x6b, 0xdc, 0x4a, - 0x10, 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, 0xd7, 0x1f, 0x1f, 0x8d, 0x16, 0x06, 0xef, 0x7a, 0x6e, 0xf0, - 0x00, 0x1a, 0x4a, 0x88, 0xd7, 0xef, 0x6b, 0x8c, 0xf6, 0x5f, 0x77, 0x58, 0xed, 0x6a, 0x4f, 0xba, - 0xda, 0x71, 0x16, 0xb4, 0xab, 0x43, 0xb4, 0x73, 0xbc, 0xe5, 0xfc, 0xad, 0x91, 0xf7, 0xfa, 0x56, - 0xf3, 0xbe, 0x39, 0x44, 0x3b, 0xf8, 0x7f, 0x68, 0x29, 0x1f, 0x8f, 0x79, 0x4a, 0xfd, 0xf1, 0x9f, - 0x5d, 0x57, 0xe9, 0xa2, 0x3d, 0xd4, 0x7b, 0x72, 0x76, 0x61, 0x55, 0xce, 0x2f, 0xac, 0xca, 0xd5, - 0x85, 0x85, 0xde, 0x16, 0x16, 0xfa, 0x54, 0x58, 0xe8, 0x4b, 0x61, 0xa1, 0xb3, 0xc2, 0x42, 0xdf, - 0x0b, 0x0b, 0xfd, 0x2c, 0xac, 0xca, 0x55, 0x61, 0xa1, 0x0f, 0x97, 0x56, 0xe5, 0xec, 0xd2, 0xaa, - 0x9c, 0x5f, 0x5a, 0x95, 0x63, 0x7b, 0xee, 0x7f, 0x94, 0xc5, 0xec, 0xf4, 0x95, 0x1f, 0x0c, 0xbd, - 0x90, 0xb1, 0x30, 0xf3, 0xe4, 0x5d, 0xfd, 0x86, 0xac, 0xe1, 0xbf, 0xbf, 0x03, 0x00, 0x00, 0xff, - 0xff, 0x34, 0xec, 0xef, 0x48, 0x0c, 0x05, 0x00, 0x00, + // 758 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0xbf, 0x6f, 0xdb, 0x46, + 0x14, 0xd6, 0x51, 0xbf, 0xac, 0x67, 0xf9, 0x07, 0xae, 0xae, 0xcb, 0xca, 0x06, 0x29, 0xd0, 0x8b, + 0x60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 0xa8, 0x0e, 0x86, 0xff, 0x86, 0xe6, 0x7c, 0x5f, 0xc1, 0x9b, + 0xae, 0x6a, 0x5a, 0x6e, 0xd1, 0x8e, 0xdc, 0x63, 0xd1, 0xb4, 0x5a, 0x5b, 0xfa, 0x94, 0x45, 0x4d, + 0xc8, 0xc1, 0x4f, 0xdf, 0x7e, 0x78, 0x69, 0x34, 0x31, 0x78, 0xb7, 0x9d, 0x06, 0x47, 0x50, 0x53, + 0x42, 0xbc, 0xb1, 0xa8, 0x94, 0x5a, 0xdf, 0x3f, 0x60, 0x75, 0xa8, 0x7d, 0x19, 0x6a, 0xd7, 0xa9, + 0xeb, 0x50, 0x47, 0x68, 0xf7, 0x64, 0xdb, 0xf9, 0x41, 0x23, 0xef, 0xf1, 0xbd, 0x72, 0x7f, 0x72, + 0x84, 0x76, 0xf1, 0xaf, 0x45, 0x51, 0xfc, 0xc9, 0x33, 0xea, 0x0f, 0xbf, 0xec, 0xb8, 0x52, 0x07, + 0xed, 0xa3, 0xee, 0x5f, 0x17, 0x57, 0x56, 0xe9, 0xf2, 0xca, 0x2a, 0xdd, 0x5c, 0x59, 0xe8, 0x7c, + 0x6a, 0xa1, 0x57, 0x53, 0x0b, 0xbd, 0x99, 0x5a, 0xe8, 0x62, 0x6a, 0xa1, 0xf7, 0x53, 0x0b, 0x7d, + 0x9c, 0x5a, 0xa5, 0x9b, 0xa9, 0x85, 0x5e, 0x5c, 0x5b, 0xa5, 0x8b, 0x6b, 0xab, 0x74, 0x79, 0x6d, + 0x95, 0x4e, 0xec, 0xb9, 0x0e, 0x9e, 0x27, 0xec, 0xec, 0x91, 0x1f, 0xf4, 0xbd, 0x90, 0xb1, 0x30, + 0xf7, 0xe4, 0x59, 0xbd, 0x9a, 0xf4, 0xf0, 0xa7, 0xcf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x51, 0x05, + 0xad, 0x44, 0x3e, 0x06, 0x00, 0x00, } func (this *GetDetectorsResponse) Equal(that interface{}) bool { @@ -563,6 +657,55 @@ func (this *DetectRequest) Equal(that interface{}) bool { return false } } + if len(this.Regions) != len(that1.Regions) { + return false + } + for i := range this.Regions { + if !this.Regions[i].Equal(that1.Regions[i]) { + return false + } + } + return true +} +func (this *DetectRegion) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DetectRegion) + if !ok { + that2, ok := that.(DetectRegion) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Top != that1.Top { + return false + } + if this.Left != that1.Left { + return false + } + if this.Bottom != that1.Bottom { + return false + } + if this.Right != that1.Right { + return false + } + if len(this.Detect) != len(that1.Detect) { + return false + } + for i := range this.Detect { + if this.Detect[i] != that1.Detect[i] { + return false + } + } return true } func (this *Detection) Equal(that interface{}) bool { @@ -671,7 +814,7 @@ func (this *DetectRequest) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 8) + s := make([]string, 0, 9) s = append(s, "&odrpc.DetectRequest{") s = append(s, "Id: "+fmt.Sprintf("%#v", this.Id)+",\n") s = append(s, "DetectorName: "+fmt.Sprintf("%#v", this.DetectorName)+",\n") @@ -689,6 +832,35 @@ func (this *DetectRequest) GoString() string { if this.Detect != nil { s = append(s, "Detect: "+mapStringForDetect+",\n") } + if this.Regions != nil { + s = append(s, "Regions: "+fmt.Sprintf("%#v", this.Regions)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *DetectRegion) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 9) + s = append(s, "&odrpc.DetectRegion{") + s = append(s, "Top: "+fmt.Sprintf("%#v", this.Top)+",\n") + s = append(s, "Left: "+fmt.Sprintf("%#v", this.Left)+",\n") + s = append(s, "Bottom: "+fmt.Sprintf("%#v", this.Bottom)+",\n") + s = append(s, "Right: "+fmt.Sprintf("%#v", this.Right)+",\n") + keysForDetect := make([]string, 0, len(this.Detect)) + for k, _ := range this.Detect { + keysForDetect = append(keysForDetect, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForDetect) + mapStringForDetect := "map[string]float32{" + for _, k := range keysForDetect { + mapStringForDetect += fmt.Sprintf("%#v: %#v,", k, this.Detect[k]) + } + mapStringForDetect += "}" + if this.Detect != nil { + s = append(s, "Detect: "+mapStringForDetect+",\n") + } s = append(s, "}") return strings.Join(s, "") } @@ -817,6 +989,20 @@ type OdrpcServer interface { DetectStream(Odrpc_DetectStreamServer) error } +// UnimplementedOdrpcServer can be embedded to have forward compatible implementations. +type UnimplementedOdrpcServer struct { +} + +func (*UnimplementedOdrpcServer) GetDetectors(ctx context.Context, req *empty.Empty) (*GetDetectorsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDetectors not implemented") +} +func (*UnimplementedOdrpcServer) Detect(ctx context.Context, req *DetectRequest) (*DetectResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Detect not implemented") +} +func (*UnimplementedOdrpcServer) DetectStream(srv Odrpc_DetectStreamServer) error { + return status.Errorf(codes.Unimplemented, "method DetectStream not implemented") +} + func RegisterOdrpcServer(s *grpc.Server, srv OdrpcServer) { s.RegisterService(&_Odrpc_serviceDesc, srv) } @@ -910,7 +1096,7 @@ var _Odrpc_serviceDesc = grpc.ServiceDesc{ func (m *GetDetectorsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -918,29 +1104,36 @@ func (m *GetDetectorsResponse) Marshal() (dAtA []byte, err error) { } func (m *GetDetectorsResponse) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetDetectorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l if len(m.Detectors) > 0 { - for _, msg := range m.Detectors { - dAtA[i] = 0xa - i++ - i = encodeVarintRpc(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Detectors) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Detectors[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRpc(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0xa } } - return i, nil + return len(dAtA) - i, nil } func (m *Detector) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -948,65 +1141,67 @@ func (m *Detector) Marshal() (dAtA []byte, err error) { } func (m *Detector) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Detector) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Name) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) + if m.Channels != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.Channels)) + i-- + dAtA[i] = 0x38 } - if len(m.Type) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.Type))) - i += copy(dAtA[i:], m.Type) + if m.Height != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x30 } - if len(m.Model) > 0 { - dAtA[i] = 0x1a - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.Model))) - i += copy(dAtA[i:], m.Model) + if m.Width != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.Width)) + i-- + dAtA[i] = 0x28 } if len(m.Labels) > 0 { - for _, s := range m.Labels { + for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Labels[iNdEx]) + copy(dAtA[i:], m.Labels[iNdEx]) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Labels[iNdEx]))) + i-- dAtA[i] = 0x22 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) } } - if m.Width != 0 { - dAtA[i] = 0x28 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.Width)) + if len(m.Model) > 0 { + i -= len(m.Model) + copy(dAtA[i:], m.Model) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Model))) + i-- + dAtA[i] = 0x1a } - if m.Height != 0 { - dAtA[i] = 0x30 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.Height)) + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x12 } - if m.Channels != 0 { - dAtA[i] = 0x38 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.Channels)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *DetectRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1014,106 +1209,200 @@ func (m *DetectRequest) Marshal() (dAtA []byte, err error) { } func (m *DetectRequest) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DetectRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Id) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.Id))) - i += copy(dAtA[i:], m.Id) - } - if len(m.DetectorName) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.DetectorName))) - i += copy(dAtA[i:], m.DetectorName) - } - if len(m.Data) > 0 { - dAtA[i] = 0x1a - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.Data))) - i += copy(dAtA[i:], m.Data) + if len(m.Regions) > 0 { + for iNdEx := len(m.Regions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Regions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } } if len(m.Detect) > 0 { - for k, _ := range m.Detect { - dAtA[i] = 0x22 - i++ + for k := range m.Detect { v := m.Detect[k] - mapSize := 1 + len(k) + sovRpc(uint64(len(k))) + 1 + 4 - i = encodeVarintRpc(dAtA, i, uint64(mapSize)) - dAtA[i] = 0xa - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(k))) - i += copy(dAtA[i:], k) - dAtA[i] = 0x15 - i++ + baseI := i + i -= 4 encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(v)))) - i += 4 + i-- + dAtA[i] = 0x15 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintRpc(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintRpc(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x22 } } - return i, nil + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x1a + } + if len(m.DetectorName) > 0 { + i -= len(m.DetectorName) + copy(dAtA[i:], m.DetectorName) + i = encodeVarintRpc(dAtA, i, uint64(len(m.DetectorName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *Detection) Marshal() (dAtA []byte, err error) { +func (m *DetectRegion) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } return dAtA[:n], nil } -func (m *Detection) MarshalTo(dAtA []byte) (int, error) { - var i int +func (m *DetectRegion) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DetectRegion) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.Top != 0 { - dAtA[i] = 0xd - i++ - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Top)))) - i += 4 + if len(m.Detect) > 0 { + for k := range m.Detect { + v := m.Detect[k] + baseI := i + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(v)))) + i-- + dAtA[i] = 0x15 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintRpc(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintRpc(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x2a + } } - if m.Left != 0 { - dAtA[i] = 0x15 - i++ - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Left)))) - i += 4 + if m.Right != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Right)))) + i-- + dAtA[i] = 0x25 } if m.Bottom != 0 { - dAtA[i] = 0x1d - i++ + i -= 4 encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Bottom)))) - i += 4 - } - if m.Right != 0 { - dAtA[i] = 0x25 - i++ - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Right)))) - i += 4 + i-- + dAtA[i] = 0x1d } - if len(m.Label) > 0 { - dAtA[i] = 0x2a - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.Label))) - i += copy(dAtA[i:], m.Label) + if m.Left != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Left)))) + i-- + dAtA[i] = 0x15 } + if m.Top != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Top)))) + i-- + dAtA[i] = 0xd + } + return len(dAtA) - i, nil +} + +func (m *Detection) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Detection) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Detection) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l if m.Confidence != 0 { - dAtA[i] = 0x35 - i++ + i -= 4 encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Confidence)))) - i += 4 + i-- + dAtA[i] = 0x35 } - return i, nil + if len(m.Label) > 0 { + i -= len(m.Label) + copy(dAtA[i:], m.Label) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Label))) + i-- + dAtA[i] = 0x2a + } + if m.Right != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Right)))) + i-- + dAtA[i] = 0x25 + } + if m.Bottom != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Bottom)))) + i-- + dAtA[i] = 0x1d + } + if m.Left != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Left)))) + i-- + dAtA[i] = 0x15 + } + if m.Top != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Top)))) + i-- + dAtA[i] = 0xd + } + return len(dAtA) - i, nil } func (m *DetectResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1121,45 +1410,56 @@ func (m *DetectResponse) Marshal() (dAtA []byte, err error) { } func (m *DetectResponse) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DetectResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Id) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.Id))) - i += copy(dAtA[i:], m.Id) + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0x1a } if len(m.Detections) > 0 { - for _, msg := range m.Detections { - dAtA[i] = 0x12 - i++ - i = encodeVarintRpc(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Detections) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Detections[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRpc(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0x12 } } - if len(m.Error) > 0 { - dAtA[i] = 0x1a - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.Error))) - i += copy(dAtA[i:], m.Error) + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func encodeVarintRpc(dAtA []byte, offset int, v uint64) int { + offset -= sovRpc(v) + base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 offset++ } dAtA[offset] = uint8(v) - return offset + 1 + return base } func (m *GetDetectorsResponse) Size() (n int) { if m == nil { @@ -1238,6 +1538,41 @@ func (m *DetectRequest) Size() (n int) { n += mapEntrySize + 1 + sovRpc(uint64(mapEntrySize)) } } + if len(m.Regions) > 0 { + for _, e := range m.Regions { + l = e.Size() + n += 1 + l + sovRpc(uint64(l)) + } + } + return n +} + +func (m *DetectRegion) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Top != 0 { + n += 5 + } + if m.Left != 0 { + n += 5 + } + if m.Bottom != 0 { + n += 5 + } + if m.Right != 0 { + n += 5 + } + if len(m.Detect) > 0 { + for k, v := range m.Detect { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovRpc(uint64(len(k))) + 1 + 4 + n += mapEntrySize + 1 + sovRpc(uint64(mapEntrySize)) + } + } return n } @@ -1293,14 +1628,7 @@ func (m *DetectResponse) Size() (n int) { } func sovRpc(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n + return (math_bits.Len64(x|1) + 6) / 7 } func sozRpc(x uint64) (n int) { return sovRpc(uint64((x << 1) ^ uint64((int64(x) >> 63)))) @@ -1309,8 +1637,13 @@ func (this *GetDetectorsResponse) String() string { if this == nil { return "nil" } + repeatedStringForDetectors := "[]*Detector{" + for _, f := range this.Detectors { + repeatedStringForDetectors += strings.Replace(f.String(), "Detector", "Detector", 1) + "," + } + repeatedStringForDetectors += "}" s := strings.Join([]string{`&GetDetectorsResponse{`, - `Detectors:` + strings.Replace(fmt.Sprintf("%v", this.Detectors), "Detector", "Detector", 1) + `,`, + `Detectors:` + repeatedStringForDetectors + `,`, `}`, }, "") return s @@ -1335,6 +1668,11 @@ func (this *DetectRequest) String() string { if this == nil { return "nil" } + repeatedStringForRegions := "[]*DetectRegion{" + for _, f := range this.Regions { + repeatedStringForRegions += strings.Replace(f.String(), "DetectRegion", "DetectRegion", 1) + "," + } + repeatedStringForRegions += "}" keysForDetect := make([]string, 0, len(this.Detect)) for k, _ := range this.Detect { keysForDetect = append(keysForDetect, k) @@ -1350,6 +1688,31 @@ func (this *DetectRequest) String() string { `DetectorName:` + fmt.Sprintf("%v", this.DetectorName) + `,`, `Data:` + fmt.Sprintf("%v", this.Data) + `,`, `Detect:` + mapStringForDetect + `,`, + `Regions:` + repeatedStringForRegions + `,`, + `}`, + }, "") + return s +} +func (this *DetectRegion) String() string { + if this == nil { + return "nil" + } + keysForDetect := make([]string, 0, len(this.Detect)) + for k, _ := range this.Detect { + keysForDetect = append(keysForDetect, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForDetect) + mapStringForDetect := "map[string]float32{" + for _, k := range keysForDetect { + mapStringForDetect += fmt.Sprintf("%v: %v,", k, this.Detect[k]) + } + mapStringForDetect += "}" + s := strings.Join([]string{`&DetectRegion{`, + `Top:` + fmt.Sprintf("%v", this.Top) + `,`, + `Left:` + fmt.Sprintf("%v", this.Left) + `,`, + `Bottom:` + fmt.Sprintf("%v", this.Bottom) + `,`, + `Right:` + fmt.Sprintf("%v", this.Right) + `,`, + `Detect:` + mapStringForDetect + `,`, `}`, }, "") return s @@ -1373,9 +1736,14 @@ func (this *DetectResponse) String() string { if this == nil { return "nil" } + repeatedStringForDetections := "[]*Detection{" + for _, f := range this.Detections { + repeatedStringForDetections += strings.Replace(f.String(), "Detection", "Detection", 1) + "," + } + repeatedStringForDetections += "}" s := strings.Join([]string{`&DetectResponse{`, `Id:` + fmt.Sprintf("%v", this.Id) + `,`, - `Detections:` + strings.Replace(fmt.Sprintf("%v", this.Detections), "Detection", "Detection", 1) + `,`, + `Detections:` + repeatedStringForDetections + `,`, `Error:` + fmt.Sprintf("%v", this.Error) + `,`, `}`, }, "") @@ -1947,6 +2315,243 @@ func (m *DetectRequest) Unmarshal(dAtA []byte) error { } m.Detect[mapkey] = mapvalue iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Regions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Regions = append(m.Regions, &DetectRegion{}) + if err := m.Regions[len(m.Regions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthRpc + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthRpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DetectRegion) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DetectRegion: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DetectRegion: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Top", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.Top = float32(math.Float32frombits(v)) + case 2: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Left", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.Left = float32(math.Float32frombits(v)) + case 3: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Bottom", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.Bottom = float32(math.Float32frombits(v)) + case 4: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Right", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.Right = float32(math.Float32frombits(v)) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Detect", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Detect == nil { + m.Detect = make(map[string]float32) + } + var mapkey string + var mapvalue float32 + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthRpc + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthRpc + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapvaluetemp uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + mapvaluetemp = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + mapvalue = math.Float32frombits(mapvaluetemp) + } else { + iNdEx = entryPreIndex + skippy, err := skipRpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthRpc + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Detect[mapkey] = mapvalue + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipRpc(dAtA[iNdEx:]) @@ -2265,6 +2870,7 @@ func (m *DetectResponse) Unmarshal(dAtA []byte) error { func skipRpc(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 + depth := 0 for iNdEx < l { var wire uint64 for shift := uint(0); ; shift += 7 { @@ -2296,10 +2902,8 @@ func skipRpc(dAtA []byte) (n int, err error) { break } } - return iNdEx, nil case 1: iNdEx += 8 - return iNdEx, nil case 2: var length int for shift := uint(0); ; shift += 7 { @@ -2320,55 +2924,30 @@ func skipRpc(dAtA []byte) (n int, err error) { return 0, ErrInvalidLengthRpc } iNdEx += length - if iNdEx < 0 { - return 0, ErrInvalidLengthRpc - } - return iNdEx, nil case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRpc - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipRpc(dAtA[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - if iNdEx < 0 { - return 0, ErrInvalidLengthRpc - } - } - return iNdEx, nil + depth++ case 4: - return iNdEx, nil + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupRpc + } + depth-- case 5: iNdEx += 4 - return iNdEx, nil default: return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } + if iNdEx < 0 { + return 0, ErrInvalidLengthRpc + } + if depth == 0 { + return iNdEx, nil + } } - panic("unreachable") + return 0, io.ErrUnexpectedEOF } var ( - ErrInvalidLengthRpc = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowRpc = fmt.Errorf("proto: integer overflow") + ErrInvalidLengthRpc = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowRpc = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupRpc = fmt.Errorf("proto: unexpected end of group") ) diff --git a/odrpc/rpc.pb.gw.go b/odrpc/rpc.pb.gw.go index 00b1b8d..95ce00d 100644 --- a/odrpc/rpc.pb.gw.go +++ b/odrpc/rpc.pb.gw.go @@ -9,25 +9,28 @@ It translates gRPC into RESTful JSON APIs. package odrpc import ( + "context" "io" "net/http" + "github.com/golang/protobuf/descriptor" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/empty" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/utilities" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/status" ) +// Suppress "imported and not used" errors var _ codes.Code var _ io.Reader var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage func request_Odrpc_GetDetectors_0(ctx context.Context, marshaler runtime.Marshaler, client OdrpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq empty.Empty @@ -38,11 +41,24 @@ func request_Odrpc_GetDetectors_0(ctx context.Context, marshaler runtime.Marshal } +func local_request_Odrpc_GetDetectors_0(ctx context.Context, marshaler runtime.Marshaler, server OdrpcServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq empty.Empty + var metadata runtime.ServerMetadata + + msg, err := server.GetDetectors(ctx, &protoReq) + return msg, metadata, err + +} + func request_Odrpc_Detect_0(ctx context.Context, marshaler runtime.Marshaler, client OdrpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq DetectRequest var metadata runtime.ServerMetadata - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -51,11 +67,32 @@ func request_Odrpc_Detect_0(ctx context.Context, marshaler runtime.Marshaler, cl } +func local_request_Odrpc_Detect_0(ctx context.Context, marshaler runtime.Marshaler, server OdrpcServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DetectRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Detect(ctx, &protoReq) + return msg, metadata, err + +} + func request_Odrpc_Detect_1(ctx context.Context, marshaler runtime.Marshaler, client OdrpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq DetectRequest var metadata runtime.ServerMetadata - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -82,6 +119,109 @@ func request_Odrpc_Detect_1(ctx context.Context, marshaler runtime.Marshaler, cl } +func local_request_Odrpc_Detect_1(ctx context.Context, marshaler runtime.Marshaler, server OdrpcServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DetectRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["detector_name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "detector_name") + } + + protoReq.DetectorName, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "detector_name", err) + } + + msg, err := server.Detect(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterOdrpcHandlerServer registers the http handlers for service Odrpc to "mux". +// UnaryRPC :call OdrpcServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +func RegisterOdrpcHandlerServer(ctx context.Context, mux *runtime.ServeMux, server OdrpcServer) error { + + mux.Handle("GET", pattern_Odrpc_GetDetectors_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Odrpc_GetDetectors_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Odrpc_GetDetectors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Odrpc_Detect_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Odrpc_Detect_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Odrpc_Detect_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Odrpc_Detect_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Odrpc_Detect_1(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Odrpc_Detect_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + // RegisterOdrpcHandlerFromEndpoint is same as RegisterOdrpcHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterOdrpcHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { @@ -123,15 +263,6 @@ func RegisterOdrpcHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie mux.Handle("GET", pattern_Odrpc_GetDetectors_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateContext(ctx, mux, req) if err != nil { @@ -152,15 +283,6 @@ func RegisterOdrpcHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie mux.Handle("POST", pattern_Odrpc_Detect_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateContext(ctx, mux, req) if err != nil { @@ -181,15 +303,6 @@ func RegisterOdrpcHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie mux.Handle("POST", pattern_Odrpc_Detect_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateContext(ctx, mux, req) if err != nil { @@ -211,11 +324,11 @@ func RegisterOdrpcHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Odrpc_GetDetectors_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"detectors"}, "")) + pattern_Odrpc_GetDetectors_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"detectors"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Odrpc_Detect_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"detect"}, "")) + pattern_Odrpc_Detect_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"detect"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Odrpc_Detect_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"detect", "detector_name"}, "")) + pattern_Odrpc_Detect_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"detect", "detector_name"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/odrpc/rpc.swagger.json b/odrpc/rpc.swagger.json index 2891164..2712e27 100644 --- a/odrpc/rpc.swagger.json +++ b/odrpc/rpc.swagger.json @@ -4,10 +4,6 @@ "title": "odrpc/rpc.proto", "version": "version not set" }, - "schemes": [ - "http", - "https" - ], "consumes": [ "application/json" ], @@ -18,13 +14,19 @@ "/detect": { "post": { "summary": "Process an request", - "operationId": "Detect", + "operationId": "odrpc_Detect", "responses": { "200": { - "description": "", + "description": "A successful response.", "schema": { "$ref": "#/definitions/odrpcDetectResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "parameters": [ @@ -45,13 +47,19 @@ "/detect/{detector_name}": { "post": { "summary": "Process an request", - "operationId": "Detect2", + "operationId": "odrpc_Detect2", "responses": { "200": { - "description": "", + "description": "A successful response.", "schema": { "$ref": "#/definitions/odrpcDetectResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "parameters": [ @@ -79,13 +87,19 @@ "/detectors": { "get": { "summary": "Get Config", - "operationId": "GetDetectors", + "operationId": "odrpc_GetDetectors", "responses": { "200": { - "description": "", + "description": "A successful response.", "schema": { "$ref": "#/definitions/odrpcGetDetectorsResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "tags": [ @@ -95,6 +109,36 @@ } }, "definitions": { + "odrpcDetectRegion": { + "type": "object", + "properties": { + "top": { + "type": "number", + "format": "float", + "title": "Coordinates" + }, + "left": { + "type": "number", + "format": "float" + }, + "bottom": { + "type": "number", + "format": "float" + }, + "right": { + "type": "number", + "format": "float" + }, + "detect": { + "type": "object", + "additionalProperties": { + "type": "number", + "format": "float" + }, + "title": "What to detect" + } + } + }, "odrpcDetectRequest": { "type": "object", "properties": { @@ -118,6 +162,13 @@ "format": "float" }, "title": "What to detect" + }, + "regions": { + "type": "array", + "items": { + "$ref": "#/definitions/odrpcDetectRegion" + }, + "title": "Sub regions for detection" } }, "title": "The Process Request" @@ -221,6 +272,64 @@ } } } + }, + "protobufAny": { + "type": "object", + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "type": "string", + "format": "byte" + } + } + }, + "runtimeError": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + }, + "runtimeStreamError": { + "type": "object", + "properties": { + "grpc_code": { + "type": "integer", + "format": "int32" + }, + "http_code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "http_status": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } } } } diff --git a/tftoolchain.sh b/tf_arm_toolchain_patch.sh similarity index 100% rename from tftoolchain.sh rename to tf_arm_toolchain_patch.sh