AR 增强现实 开发入门详解 android studio Vuforia(一)

准备工作

Android studio  NDK 必须安装,如果没有安装,在这个界面会有提示安装按钮,网络不通的可以百度手动安装

AR 增强现实 开发入门详解 android studio Vuforia(一)_第1张图片

Gradle Version 版本需要为2.14.1及以上,如果不到,手动修改点OK,软件会自动下载更新

AR 增强现实 开发入门详解 android studio Vuforia(一)_第2张图片


接下来就是准备demo,到高通官网注册账号:

https://developer.vuforia.com/

申请key,这里的key是通用的在后续修改背景图时一样可以使用

https://developer.vuforia.com/targetmanager/licenseManager/licenseListing

下载SDK和Sample

https://developer.vuforia.com/downloads/sdk

下载后Sample解压如下

AR 增强现实 开发入门详解 android studio Vuforia(一)_第3张图片

新建文件夹ardemo,把上图文件全部复制到文件夹ardemo中。

下载后sdk解压如下

AR 增强现实 开发入门详解 android studio Vuforia(一)_第4张图片

把文件夹ardemo拷贝到samples中。

准备工作完成。

运行项目

正常跑起来后,在SampleApplicationSession.java 全局搜索setInitParameters,将key填入 

 protected Boolean doInBackground(Void... params)
        {
            // Prevent the onDestroy() method to overlap with initialization:
            synchronized (mShutdownLock)
            {
                Vuforia.setInitParameters(mActivity, mVuforiaFlags, "填入key");

                do
                {
                    // Vuforia.init() blocks until an initialization step is
                    // complete, then it proceeds to the next step and reports
                    // progress in percents (0 ... 100%).
                    // If Vuforia.init() returns -1, it indicates an error.
                    // Initialization is done when progress has reached 100%.
                    mProgressValue = Vuforia.init();
                    
                    // Publish the progress value:
                    publishProgress(mProgressValue);
                    
                    // We check whether the task has been canceled in the
                    // meantime (by calling AsyncTask.cancel(true)).
                    // and bail out if it has, thus stopping this thread.
                    // This is necessary as the AsyncTask will run to completion
                    // regardless of the status of the component that
                    // started is.
                } while (!isCancelled() && mProgressValue >= 0
                    && mProgressValue < 100);

                return (mProgressValue > 0);
            }
        }

demo中的gradle只配置了一种cpu架构可以根据自己需要进行添加

 buildTypes {
        release {
            minifyEnabled false
            ndk {
                abiFilters "armeabi-v7a","x86"
            }
        }
        debug {
            minifyEnabled false
            debuggable true
            ndk {
                abiFilters "armeabi-v7a","x86"
            }
        }
    }

下面看下效果



demo


AR 增强现实 开发入门详解 android studio Vuforia(二)更换背景目标图片

你可能感兴趣的:(AR,Unity3D入门实例)