Giter Site home page Giter Site logo

yasuohasegawa / unityvisionmlsample Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 3.0 85.16 MB

This project is the sample code of working with ARFoiundation, Vision framework, and CoreML.

C# 7.11% Objective-C 0.31% Objective-C++ 0.48% Swift 4.72% C 2.05% ShaderLab 74.82% HLSL 10.52%
unity3d unity vision coreml arfoundation arkit

unityvisionmlsample's Introduction

UnityVisionMLSample

This project is the sample code of working with ARFoiundation, Vision framework, and CoreML.

This sample app is almost as same as the Apple sample below.
https://developer.apple.com/documentation/arkit/recognizing_and_labeling_arbitrary_objects?language=objc

The point is the app sends the ARSession pointer to the native side from Unity side when the app starts, so the app can share the ARSession between the Unity side and Native side. In this way, we can easily manage the ARSession from Native side.

The ARSession pointer has the structure.
We have to write the following struct class in the .h or .mm files to cast the pointer.

Here is the C# session pointer to get.

ARSession m_session;
var sessionSubsystem = (ARKitSessionSubsystem)m_session.subsystem;
sessionSubsystem.nativePtr

xxxxx.h
typedef struct UnityXRNativeSession_1
{
    int version;
    void* sessionPtr;
} UnityXRNativeSession_1;


Here is the how to cast from the C# session pointer to Native ARSession.

xxxxx.mm
UnityXRNativeSession_1* unityXRSession = (UnityXRNativeSession_1*) session;
ARSession* sess = (__bridge ARSession*)unityXRSession->sessionPtr;

The session is the pointer from the Unity.

This project is very simple that you can modify whatever you want.
It's good to start with the simple one always.

References:

https://github.com/chenjd/Unity-ARFoundation-HandDetection
https://medium.com/s23nyc-tech/using-machine-learning-and-coreml-to-control-arkit-24241c894e3b
https://forum.unity.com/threads/getting-access-to-the-arkit-arframe-pointer-with-arfoundation.589390/

Tested on:

Unity 2019.1.5f1
iPhoneXS Max iOS 12.2

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.