Esempio n. 1
0
    void Start()
    {
        _spawnedModels = new Dictionary <int, AugmentedModel>();
        setModelManager(new LocalModelManager("artifacts/"));
        int[] modelIds = _modelManager.availableModelIds();

        for (int i = 0; i < modelIds.Length; ++i)
        {
            Texture2D img  = _modelManager.getTrackedImage(i);
            string    name = "" + i;
            _trackedImageDatabase.AddImage(name, img, 1);
        }
    }
Esempio n. 2
0
    public void Create()
    {
        foreach (var image in DownloadManager.images)
        {
            Debug.Log("<DEBUG> CREATE " + image.name + " " + image.isReadable + " " + image.format);
            int x = newDatabase.AddImage(image.name, image);
            Debug.Log("<DEBUG> Val returned on adding Image = " + x);
        }

        Debug.Log("<DEBUG> Databse count = " + newDatabase.Count);
        if (session != null)
        {
            session.SessionConfig.AugmentedImageDatabase = newDatabase;
            Debug.Log("<DEBUG> NEW DATABASE SET");
        }
        else
        {
            Debug.Log("<DEBUG> SESSION IS NULL");
        }
    }
Esempio n. 3
0
        /// <summary>
        /// Loads the images for image recognition
        /// </summary>
        protected override async void LoadArAssets()
        {
            var characterRepository = Mvx.IoCProvider.Resolve <ICharacterRepository>();

            this.characters = await characterRepository.GetAll();

            var assets = MainActivity.Instance.Assets;

            this.imageDatabase = new AugmentedImageDatabase(this.session);
            foreach (var character in this.characters)
            {
                character.Captured = false;
                using (var streamReader = new StreamReader(assets.Open(character.AssetSticker)))
                {
                    var image = BitmapFactory.DecodeStream(streamReader.BaseStream);
                    imageDatabase.AddImage(character.Name, image, 0.15f);
                }
            }

            config.AugmentedImageDatabase = this.imageDatabase;
            session.Configure(config);
        }
Esempio n. 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);
            mSurfaceView           = FindViewById <GLSurfaceView>(Resource.Id.surfaceview);
            mDisplayRotationHelper = new DisplayRotationHelper(this);

            Java.Lang.Exception exception = null;
            string message = null;

            try
            {
                mSession = new Session(/*context=*/ this);
            }
            catch (UnavailableArcoreNotInstalledException e)
            {
                message   = "Please install ARCore";
                exception = e;
            }
            catch (UnavailableApkTooOldException e)
            {
                message   = "Please update ARCore";
                exception = e;
            }
            catch (UnavailableSdkTooOldException e)
            {
                message   = "Please update this app";
                exception = e;
            }
            catch (Java.Lang.Exception e)
            {
                exception = e;
                message   = "This device does not support AR";
            }

            if (message != null)
            {
                Toast.MakeText(this, message, ToastLength.Long).Show();
                return;
            }


            // Create default config, check is supported, create session from that config.
            var config = new Google.AR.Core.Config(mSession);

            if (!mSession.IsSupported(config))
            {
                Toast.MakeText(this, "This device does not support AR", ToastLength.Long).Show();
                Finish();
                return;
            }

            AugmentedImageDatabase imageDatabase = new AugmentedImageDatabase(mSession);

            Bitmap bitmap = null;

            try
            {
                var inputStream = Assets.Open("qrcode.png");
                bitmap = BitmapFactory.DecodeStream(inputStream);
            }
            catch (IOException e)
            {
                Log.Error(TAG, "I/O exception loading augmented image bitmap.", e);
            }
            index = imageDatabase.AddImage("interstellar", bitmap, 0.01f);
            config.AugmentedImageDatabase = imageDatabase;

            mSession.Configure(config);

            mGestureDetector = new GestureDetector(this, new TapGestureDetector
            {
                SingleTapUpHandler = (MotionEvent arg) => {
                    OnSingleTap(arg);
                    return(true);
                },
                DownHandler = (MotionEvent arg) => true
            });

            mSurfaceView.SetOnTouchListener(this);



            // Set up renderer.
            mSurfaceView.PreserveEGLContextOnPause = true;
            mSurfaceView.SetEGLContextClientVersion(2);
            mSurfaceView.SetEGLConfigChooser(8, 8, 8, 8, 16, 0); // Alpha used for plane blending.
            mSurfaceView.SetRenderer(this);
            mSurfaceView.RenderMode = Rendermode.Continuously;
        }