Giter Site home page Giter Site logo

61315 / mediapipe-prebuilt Goto Github PK

View Code? Open in Web Editor NEW
32.0 3.0 9.0 213.38 MB

Prebuilt mediapipe packages and demos ready to deploy on your device at one go. 💨

License: MIT License

Objective-C 5.16% Starlark 27.32% Objective-C++ 42.41% C++ 25.10%
iris mediapipe eye tracking ios gaze swift multipose pose

mediapipe-prebuilt's Introduction

mediapipe-iris-ios

Realtime iris tracking demo for iOS

Preview

preview

What is MediaPipe?

MediaPipe offers cross-platform, customizable ML solutions for live and streaming media.

  • End-to-End acceleration: Built-in fast ML inference and processing accelerated even on common hardware
  • Build once, deploy anywhere: Unified solution works across Android, iOS, desktop/cloud, web and IoT
  • Ready-to-use solutions: Cutting-edge ML solutions demonstrating full power of the framework
  • Free and open source: Framework and solutions both under Apache 2.0, fully extensible and customizable

Demo

What about it?

This project is a mere copy of a demo provided by MediaPipe team. Only packaged to a dynamic framework ready to deploy on your device at one go, sparing you 😇painstaking😇 python setup.

Important: Use this project for evaluation purposes only. It is strongly recommended to build your own project/framework. MediaPipe provides streamlined build process using bazel script. This also fits well for the CI environment. You can find tutorials here.

Noise filtering

MediaPipe provides a rich set of helper classes regarding implementation of ML models. It includes math library like eigen, image processing library like opencv and many more. Most of them are abstracted for specific use cases, packed as calculators, each calculators working as a node, allowing you to create desired ML pipeline just connecting those nodes. Some of those calculators are also fine-tuned both algorithm-wise and parameter-wise, let alone the ML models being fine-tuned meaning noble paging strategy for GPU runtime and such. You don't get this kind of bargain often.

Here is one example of calculators. See the difference between the two eyes? One being stabilized and the other being fluctuating/jittering? That is because I applied a smoothing calculator to the left side of landmarks only.

noisefilter

It is mostly a random digital noise which makes it safe to assume the noise is somewhat Gaussian, so I chose the one-euro-filter. See how the calculator handles jittering? Try the demo yourself. All included in the bundle calculators, say no more.

One I used for this demo is LandmarksSmoothingCalculator:

# Applies smoothing to the single set of iris landmarks.
node {
  calculator: "LandmarksSmoothingCalculator"
  input_stream: "NORM_LANDMARKS:left_iris_landmarks"
  input_stream: "IMAGE_SIZE:input_image_size"
  output_stream: "NORM_FILTERED_LANDMARKS:smoothed_left_iris_landmarks"
  options: {
    [mediapipe.LandmarksSmoothingCalculatorOptions.ext] {
      one_euro_filter {
        min_cutoff: 0.01
        beta: 10.0
        derivate_cutoff: 1.0
      }
    }
  }
}

Those calculators are well documented/commented too, such as:

...
// For the details of the filter implementation and the procedure of its
// configuration please check http://cristal.univ-lille.fr/~casiez/1euro/
message OneEuroFilter {
    // Frequency of incomming frames defined in frames per seconds. Used only if
    // can't be calculated from provided events (e.g. on the very first frame).
    optional float frequency = 1 [default = 30.0];
...

Pose estimation

pose-estimation

TODO

Build MediaPipe project as a framework

  1. Create a BUILD file:
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_framework")

ios_framework(
    name = "MPPIrisTracking",
    hdrs = [
        "MPPIrisTracker.h",
    ],
    infoplists = ["Info.plist"],
    bundle_id = "com.studio61315.MPPIrisTraking",
    families = ["iphone", "ipad"],
    minimum_os_version = "12.0",
    deps = [
        ":MPPIrisTrackingLibrary",
        "@ios_opencv//:OpencvFramework",
    ],
)

objc_library(
    name = "MPPIrisTrackingLibrary",
    srcs = [
        "MPPIrisTracker.mm",
    ],
    hdrs = [
        "MPPIrisTracker.h",
    ],
    copts = ["-std=c++17"],
    data = [
        "//mediapipe/graphs/iris_tracking:iris_tracking_gpu.binarypb",
        "//mediapipe/modules/face_detection:face_detection_front.tflite",
        "//mediapipe/modules/face_landmark:face_landmark.tflite",
        "//mediapipe/modules/iris_landmark:iris_landmark.tflite",
    ],
    sdk_frameworks = [
        "AVFoundation",
        "CoreGraphics",
        "CoreMedia",
        "UIKit"
    ],
    deps = [
        "//mediapipe/objc:mediapipe_framework_ios",
        "//mediapipe/objc:mediapipe_input_sources_ios",
        "//mediapipe/objc:mediapipe_layer_renderer",
    ] + select({
        "//mediapipe:ios_i386": [],
        "//mediapipe:ios_x86_64": [],
        "//conditions:default": [
            "//mediapipe/graphs/iris_tracking:iris_tracking_gpu_deps",
            "//mediapipe/framework/formats:landmark_cc_proto",
        ],
    }),
)

  1. Run bazel command:
bazel build -c opt --config=ios_fat mediapipe/examples/ios/iristrackinggpuframework:MPPIrisTracking --verbose_failures

License

mediapipe-iris-ios is available under the MIT license. See the LICENSE file for more info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.