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

准备工作

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


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



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

https://developer.vuforia.com/

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

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

下载SDK和Sample

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

下载后Sample解压如下


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

下载后sdk解压如下


把文件夹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(二)更换背景目标图片

评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风晴03

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值