This is only necessary if one wants to release the program while keeping the context around.
+ */
+ public void release() {
+ GLES20.glDeleteProgram(program);
+ }
+ /**
+ * Not needed anymore, to be cleaned
+ * */
+ private void drawDetection(Detection detection) {
+
+ if (!detection.hasLocationData()) {
+ return;
+ }
+ // Draw keypoints.
+// float[] points = new float[FaceKeypoint.NUM_KEY_POINTS * 2];
+// for (int i = 0; i < FaceKeypoint.NUM_KEY_POINTS; ++i) {
+// points[2 * i] = detection.getLocationData().getRelativeKeypoints(i).getX();
+// points[2 * i + 1] = detection.getLocationData().getRelativeKeypoints(i).getY();
+// }
+// GLES20.glUniform4fv(colorHandle, 1, KEYPOINT_COLOR, 0);
+// FloatBuffer vertexBuffer =
+// ByteBuffer.allocateDirect(points.length * 4)
+// .order(ByteOrder.nativeOrder())
+// .asFloatBuffer()
+// .put(points);
+// vertexBuffer.position(0);
+// GLES20.glEnableVertexAttribArray(positionHandle);
+// GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 0, vertexBuffer);
+// GLES20.glDrawArrays(GLES20.GL_POINTS, 0, FaceKeypoint.NUM_KEY_POINTS);
+ if (!detection.getLocationData().hasRelativeBoundingBox()) {
+ return;
+ }
+ // Draw bounding box.
+// float left = detection.getLocationData().getRelativeBoundingBox().getXmin();
+// float top = detection.getLocationData().getRelativeBoundingBox().getYmin();
+// float right = left + detection.getLocationData().getRelativeBoundingBox().getWidth();
+// float bottom = top + detection.getLocationData().getRelativeBoundingBox().getHeight();
+// drawLine(top, left, top, right);
+// drawLine(bottom, left, bottom, right);
+// drawLine(top, left, bottom, left);
+// drawLine(top, right, bottom, right);
+ }
+
+ private void drawLine(float y1, float x1, float y2, float x2) {
+ GLES20.glUniform4fv(colorHandle, 1, BBOX_COLOR, 0);
+ GLES20.glLineWidth(BBOX_THICKNESS);
+ float[] vertex = {x1, y1, x2, y2};
+ FloatBuffer vertexBuffer =
+ ByteBuffer.allocateDirect(vertex.length * 4)
+ .order(ByteOrder.nativeOrder())
+ .asFloatBuffer()
+ .put(vertex);
+ vertexBuffer.position(0);
+ GLES20.glEnableVertexAttribArray(positionHandle);
+ GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 0, vertexBuffer);
+ GLES20.glDrawArrays(GLES20.GL_LINES, 0, 2);
+ }
+}
diff --git a/mediapipe/java/com/google/mediapipe/solutions/posetracking/copperlabs_aar.bzl b/mediapipe/java/com/google/mediapipe/solutions/posetracking/copperlabs_aar.bzl
new file mode 100644
index 000000000..e5feaf032
--- /dev/null
+++ b/mediapipe/java/com/google/mediapipe/solutions/posetracking/copperlabs_aar.bzl
@@ -0,0 +1,347 @@
+# Copyright 2019-2020 The MediaPipe Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Generates Copperlab AAR including different variants of .so in jni folder.
+
+Usage:
+
+Creates a new copperlabs_aar() target in a BUILD file. For example,
+putting the following code into mediapipe/examples/android/aar_demo/BUILD.
+
+```
+load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")
+
+mediapipe_aar(
+ name = "demo",
+ calculators = ["//mediapipe/calculators/core:pass_through_calculator"],
+)
+```
+
+Then, runs the following Bazel command to generate the aar.
+
+```
+$ bazel build --strip=always -s -c opt \
+ --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
+ --fat_apk_cpu=arm64-v8a,armeabi-v7a \
+ mediapipe/examples/android/aar_demo:demo.aar
+```
+
+Finally, imports the aar into Android Studio.
+
+"""
+
+load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android_library")
+
+def copperlabs_aar(
+ name,
+ srcs = [],
+ gen_libmediapipe = True,
+ calculators = [],
+ assets = [],
+ assets_dir = "",
+ additional_deps = []):
+ """Generates MediaPipe android archive library.
+
+ Args:
+ name: the name of the aar.
+ srcs: the additional java source code to be added into the android library.
+ gen_libmediapipe: whether to generate libmediapipe_jni.so. Default to True.
+ calculators: the calculator libraries to be compiled into the jni library.
+ assets: additional assets to be included into the archive.
+ assets_dir: path where the assets will the packaged.
+ """
+
+ # When "--define EXCLUDE_OPENCV_SO_LIB=1" is set in the build command,
+ # the OpenCV so libraries will be excluded from the AAR package to
+ # save the package size.
+ native.config_setting(
+ name = "exclude_opencv_so_lib",
+ define_values = {
+ "EXCLUDE_OPENCV_SO_LIB": "1",
+ },
+ visibility = ["//visibility:public"],
+ )
+
+ # When "--define ENABLE_STATS_LOGGING=1" is set in the build command,
+ # the solution stats logging component will be added into the AAR.
+ # This flag is for internal use only.
+ native.config_setting(
+ name = "enable_stats_logging",
+ define_values = {
+ "ENABLE_STATS_LOGGING": "1",
+ },
+ visibility = ["//visibility:public"],
+ )
+
+ _mediapipe_jni(
+ name = name + "_jni",
+ gen_libmediapipe = gen_libmediapipe,
+ calculators = calculators,
+ )
+
+ _mediapipe_proto(
+ name = name + "_proto",
+ )
+
+ native.genrule(
+ name = name + "_aar_manifest_generator",
+ outs = ["AndroidManifest.xml"],
+ cmd = """
+cat > $(OUTS) <