1.生成扫描图片
https://developer.vuforia.com/ 注册账号(注意密码必须有大小写和数字,否则注册不成功)生成识别图的unity包。
然后配置下图
创建Database
进入Database
添加Target
设置完成后点击Add
识别图生成好了,点选之后选择下载
下载 ARTest.unitypackage,导入Unity
高通是通过在图片上注册识别点来进行识别的,所以识别度与颜色没有关系。图片越复杂识别点越多,识别效果也就越好,所以相似的图片可能识别点分布相近导致识别效果差,我们可以通过添加文字的方式来区别。黄色的小叉就是识别点了。
最后下载高通开发包
下载好后导入unity,将下载好的识别图的unity包也导入进来
License Key码:
ASk4ybT/AAAAGZEd53eFWEPpgJho90qREIhuxNxpyoEqPGMNjQLIzHF9Aa0Qwx6A2Xv0v3ZEyBnJ4TUy5o6SPfbbo+htryAlzKC9LxLHyAYDZ7IIWB6cTv6zM+pel9lD3ZU6XJWJAYFDJiTPimICWfwklJ5WmoI5ZOvojUkg9hLv9t+1BnstdnrFNuROfIq4Mgx4tLXKtIsiPNbO/tcK0+GJlgeO+SnTnG/11lo7Lwlo1LxRszFTKGIt4LD4XgGQTolrgnul7+p6YkQasNClLtzCxGF8BcnjjsKAz0gRXW8Z4w7zxncQVzNvGXbOG5WAIPxJsK5YEMK/4tDPbrt2CN+n/gqPDvZ4LNCdFQUr984BDjPR0s+5WwYx
2.制作AR
删掉Main Camera,搜索AR Camera并将其拖到Hierarchy,同样的将ImageTarget也拖进来,对ImageTarget进行修改,Data Set修改为识别图的unity包的名字
填写App license Key
对AR Camera进行修改,将你要使用的数据勾选上就可以了
最后将模型拖拽至ImageTarget下面就行了
安卓发布流程
【注】:如果项目中出现如下错误:
Assets/Vuforia/Scripts/Utilities/VRIntegrationHelper.cs(108,29): error CS1061: Type UnityEngine.Camera' does not contain a definition for
SetStereoProjectionMatrices’ and no extension method SetStereoProjectionMatrices' of type
UnityEngine.Camera’ could be found (are you missing a using directive or an assembly reference?)
是导入包的时候VRIntegrationHelper类中的问题:
问题是Unity版本比较低
修改代码如下:
实例代码:
#if !(UNITY_5_2 || UNITY_5_1 || UNITY_5_0) // UNITY_5_3 and above
// read back the projection matrices set by Vuforia and set them to the stereo cameras
// not sure if the matrices would automatically propagate between the left and right, so setting it explicitly twice
mLeftCamera.SetStereoProjectionMatrices(mLeftCamera.projectionMatrix, mRightCamera.projectionMatrix);
mRightCamera.SetStereoProjectionMatrices(mLeftCamera.projectionMatrix, mRightCamera.projectionMatrix);
#endif