按到以下教程制作出现以下问题

1、视频不能播放

解决方案:1、加入SceneManager 2、给ARCamera加上PlayVideo.cs

问题2:勾选auto play后,还是不能自动播放

解决方案:给ImageTarget 加上 TrackableEventHandler.cs

2、加入SceneManager了后,在启动软件时有高通的介绍和设置之类的,要取消的话在代码中改,注销红色部分即可

AppManager.cs

public virtual void InitManager()
    {
        mSplashView = new SplashScreenView();
        mAboutView = new AboutScreenView();
        mAboutView.SetTitle(TitleForAboutPage);
        mAboutView.OnStartButtonTapped += OnAboutStartButtonTapped;
        m_UIEventHandler.CloseView += OnTappedOnCloseButton;
        m_UIEventHandler.GoToAboutPage += OnTappedOnGoToAboutPage;
        InputController.SingleTapped += OnSingleTapped;
        InputController.DoubleTapped += OnDoubleTapped;
        InputController.BackButtonTapped += OnBackButtonTapped;

//mSplashView.LoadView();
        //StartCoroutine(LoadAboutPageForFirstTime());

        mActiveViewType = ViewType.SPLASHVIEW;
    }

前段时间忙公司的事,好久没到CSDN来了,看到教程有这么多人参考,决心再接再厉,这篇教程就讲讲怎么做video形式的增强现实。(自己做了个案例,少女时代著名的甩大腿舞戳我O(∩_∩)O)

高通的SDK好像没有video的预制件,所以我一般都下载最新的samples,里面有我们需要用到的预制件。高通官网下载:

将包导入unity,大家可以选择自行研究例子,理清制作思路,当然也可以直接利用我总结出来的方法制作。

1、和之前介绍的AR制作一样,首先删掉main camera,在Assets搜索AR Camera并将其拖到Hierarchy,同样的将ImageTarget也拖进来,对ImageTarget参数进行修改,这里我使用例子里的识别图。

2、在assets里找到video这个预制件,将他拖到imagetarget下作为子物体。

3、 修改video的参数,path是视频的名字加后缀,例如:VuforiaSizzleReel_1.m4v,因为视频一般较大,所以建议大家将视频格式转为3g2,可以大大压缩视频所占空间,唯一的缺点是不能在电脑上测试。

4、 最重要的问题,vuforia如何找到视频的路径?答案是,视频必须放在指定文件夹下,当然可以到代码修改文件夹。默认的是StreamingAssets文件夹下

5、其他的操作,如需控制视频播放,比如识别图移出摄像头,然后再次识别,视频是从头开始播放还是从上一次的位置播放呢?大家自行阅读VideoPlaybackBehaviour这个脚本,然后修改代码就可以了~\(≧▽≦)/~啦啦啦

以上教程原地址:http://blog.csdn.net/dzyi_/article/details/34847339

按照原作者的想法,是可以实现手机观察到播放封面,但没法点击播放。针对这个问题,我翻看了官方论坛,因为最新的unity包缺少了一个C#文件。把缺少的文件加上,可以实现播放,以下为详细说明:

The objective here is to show how to replicate the essence of the Vuforia-VideoPlayback sample scene using the Vuforia prefabs and the drag and drop approach of Unity:

  • Create a new Unity project
  • Import the Vuforia video playback unity package
  • Create a new scene
  • Drag the ARCamera prefab into the Unity scene
  • Under the DataSetLoadBehaviour in the Inspector tick “Load Data Set StonesAndChips”, and the 'Activate' checkbox below this
  • From '/Qualcomm AugmentedReality/Prefabs' drag the ImageTarget prefab into the scene
    • For the Image Target select “StonesAndChips” as the dataset and the Image Target should change to the Stones texture
  • From Vuforia Video Playback/Prefabs drag the Video prefab to be the child of the Image Target
    • In the Inspector under “Video Playback Behaviour (Script)” set the path to 'VuforiaSizzleReel_1.m4v'
  • Drag the TrackableEventHandler from Scripts to the Image Target (this plays the video)
  • Remove the DefaultTrackableEventHandler script from the Image Target as it is not needed.
  • Autoplay works already, however tapping the video does not yet work. In order to fix this, simply create a VideoPlaybackController script, fill it with the code below, and then attach this to the ARCamera.

大概意思就是(我英语不好,懂意思就好= =#,英语好的还是读上文吧):

  • 创建一个新的Unity工程
  • 引入Vuforia video playback的unity包
  • 创建一个新的场景
  • 拖ARCamera进场景(ARCamera搜索下很好找到)
  • 点击场景中的ARCamera,右边Inspector栏目,DataSetLoadBehaviour(script)中“Load Data Set StonesAndChips”和 'Activate'都打上勾
  • 从'/Qualcomm AugmentedReality/Prefabs'目录中Image Target拖入场景,右边Data Set选择“StonesAndChips”
  • 从“Vuforia Video Playback/Prefabs”目录中Video拖入场景,右边“Video Playback Behaviour (Script)”中path栏输入'VuforiaSizzleReel_1.m4v'(测试是播放这个视频),或者也可以使用
    [html]  view plain copy
    1. http://oneshot.qualcomm.com/webAR/content/strawberryfields_H264_AAC.mp4

    这个网络视频进行测试

  • 把TrackableEventHandler这个C#文件放到Image Target中,主要是用来播放视频的
  • 从Image Target中移除DefaultTrackableEventHandler这个文件的使用,因为这个文件根本不需要,移除的话其实把它的打勾去掉也可以
  • 自动播放要不要打上勾随自己需要,   创建VideoPlaybackController的C#文件放入ARCamera中,VideoPlaybackController中的代码如下:
[csharp]  view plain copy
  1. /*==============================================================================
  2. Copyright (c) 2012-2014 Qualcomm Connected Experiences, Inc.
  3. All Rights Reserved.
  4. This  Vuforia(TM) sample application in source code form ("Sample Code") for the
  5. Vuforia Software Development Kit and/or Vuforia Extension for Unity
  6. (collectively, the "Vuforia SDK") may in all cases only be used in conjunction
  7. with use of the Vuforia SDK, and is subject in all respects to all of the terms
  8. and conditions of the Vuforia SDK License Agreement, which may be found at
  9. <a title="https://developer.vuforia.com/legal/license" href="https://developer.vuforia.com/legal/license">https://developer.vuforia.com/legal/license</a>.
  10. By retaining or using the Sample Code in any manner, you confirm your agreement
  11. to all the terms and conditions of the Vuforia SDK License Agreement.  If you do
  12. not agree to all the terms and conditions of the Vuforia SDK License Agreement,
  13. then you may not retain or use any of the Sample Code in any manner.
  14. ==============================================================================*/
  15. using UnityEngine;
  16. using System.Collections;
  17. /// <summary>
  18. /// This class contains the logic to handle taps on VideoPlaybackBehaviour game objects
  19. /// and starts playing the according video. It also pauses other videos when a new one is
  20. /// started.
  21. /// </summary>
  22. public class VideoPlaybackController : MonoBehaviour
  23. {
  24. #region PRIVATE_MEMBER_VARIABLES
  25. private Vector2 mTouchStartPos;
  26. private bool mTouchMoved = false;
  27. private float mTimeElapsed = 0.0f;
  28. private bool mTapped = false;
  29. private float mTimeElapsedSinceTap = 0.0f;
  30. private bool mWentToFullScreen = false;
  31. #endregion // PRIVATE_MEMBER_VARIABLES
  32. #region UNITY_MONOBEHAVIOUR_METHODS
  33. void Update()
  34. {
  35. // Determine the number of taps
  36. // Note: Input.tapCount doesn't work on Android
  37. if (Input.touchCount > 0)
  38. {
  39. Touch touch = Input.touches[0];
  40. if (touch.phase == TouchPhase.Began)
  41. {
  42. mTouchStartPos = touch.position;
  43. mTouchMoved = false;
  44. mTimeElapsed = 0.0f;
  45. }
  46. else
  47. {
  48. mTimeElapsed += Time.deltaTime;
  49. }
  50. if (touch.phase == TouchPhase.Moved)
  51. {
  52. if (Vector2.Distance(mTouchStartPos, touch.position) > 40)
  53. {
  54. // Touch moved too far
  55. mTouchMoved = true;
  56. }
  57. }
  58. else if (touch.phase == TouchPhase.Ended)
  59. {
  60. if (!mTouchMoved && mTimeElapsed < 1.0)
  61. {
  62. if (mTapped)
  63. {
  64. // Second tap
  65. HandleDoubleTap();
  66. mTapped = false;
  67. }
  68. else
  69. {
  70. // Wait to see if this is a double tap
  71. mTapped = true;
  72. mTimeElapsedSinceTap = 0.0f;
  73. }
  74. }
  75. }
  76. }
  77. if (mTapped)
  78. {
  79. if (mTimeElapsedSinceTap >= 0.5f)
  80. {
  81. // Not a double tap
  82. HandleTap();
  83. mTapped = false;
  84. }
  85. else
  86. {
  87. mTimeElapsedSinceTap += Time.deltaTime;
  88. }
  89. }
  90. // special handling in play mode:
  91. if (QCARRuntimeUtilities.IsPlayMode())
  92. {
  93. if (Input.GetMouseButtonUp(0))
  94. {
  95. if (PickVideo(Input.mousePosition) != null)
  96. Debug.LogWarning("Playing videos is currently not supported in Play Mode.");
  97. }
  98. }
  99. }
  100. #endregion // UNITY_MONOBEHAVIOUR_METHODS
  101. #region PRIVATE_METHODS
  102. /// <summary>
  103. /// Handle single tap event
  104. /// </summary>
  105. private void HandleTap()
  106. {
  107. // Find out which video was tapped, if any
  108. VideoPlaybackBehaviour video = PickVideo(mTouchStartPos);
  109. if (video != null)
  110. {
  111. if (video.VideoPlayer.IsPlayableOnTexture())
  112. {
  113. // This video is playable on a texture, toggle playing/paused
  114. VideoPlayerHelper.MediaState state = video.VideoPlayer.GetStatus();
  115. if (state == VideoPlayerHelper.MediaState.PAUSED ||
  116. state == VideoPlayerHelper.MediaState.READY ||
  117. state == VideoPlayerHelper.MediaState.STOPPED)
  118. {
  119. // Pause other videos before playing this one
  120. PauseOtherVideos(video);
  121. // Play this video on texture where it left off
  122. video.VideoPlayer.Play(false, video.VideoPlayer.GetCurrentPosition());
  123. }
  124. else if (state == VideoPlayerHelper.MediaState.REACHED_END)
  125. {
  126. // Pause other videos before playing this one
  127. PauseOtherVideos(video);
  128. // Play this video from the beginning
  129. video.VideoPlayer.Play(false, 0);
  130. }
  131. else if (state == VideoPlayerHelper.MediaState.PLAYING)
  132. {
  133. // Video is already playing, pause it
  134. video.VideoPlayer.Pause();
  135. }
  136. }
  137. else
  138. {
  139. // Display the busy icon
  140. video.ShowBusyIcon();
  141. // This video cannot be played on a texture, play it full screen
  142. video.VideoPlayer.Play(true, 0);
  143. mWentToFullScreen = true;
  144. }
  145. }
  146. }
  147. /// <summary>
  148. /// Handle double tap event
  149. /// </summary>
  150. private void HandleDoubleTap()
  151. {
  152. // Find out which video was tapped, if any
  153. VideoPlaybackBehaviour video = PickVideo(mTouchStartPos);
  154. if (video != null)
  155. {
  156. if (video.VideoPlayer.IsPlayableFullscreen())
  157. {
  158. // Pause the video if it is currently playing
  159. video.VideoPlayer.Pause();
  160. // Seek the video to the beginning();
  161. video.VideoPlayer.SeekTo(0.0f);
  162. // Display the busy icon
  163. video.ShowBusyIcon();
  164. // Play the video full screen
  165. video.VideoPlayer.Play(true, 0);
  166. mWentToFullScreen = true;
  167. }
  168. }
  169. }
  170. /// <summary>
  171. /// Find the video object under the screen point
  172. /// </summary>
  173. private VideoPlaybackBehaviour PickVideo(Vector3 screenPoint)
  174. {
  175. VideoPlaybackBehaviour[] videos = (VideoPlaybackBehaviour[])
  176. FindObjectsOfType(typeof(VideoPlaybackBehaviour));
  177. Ray ray = Camera.main.ScreenPointToRay(screenPoint);
  178. RaycastHit hit = new RaycastHit();
  179. foreach (VideoPlaybackBehaviour video in videos)
  180. {
  181. if (video.collider.Raycast(ray, out hit, 10000))
  182. {
  183. return video;
  184. }
  185. }
  186. return null;
  187. }
  188. /// <summary>
  189. /// Pause all videos except this one
  190. /// </summary>
  191. private void PauseOtherVideos(VideoPlaybackBehaviour currentVideo)
  192. {
  193. VideoPlaybackBehaviour[] videos = (VideoPlaybackBehaviour[])
  194. FindObjectsOfType(typeof(VideoPlaybackBehaviour));
  195. foreach (VideoPlaybackBehaviour video in videos)
  196. {
  197. if (video != currentVideo)
  198. {
  199. if (video.CurrentState == VideoPlayerHelper.MediaState.PLAYING)
  200. {
  201. video.VideoPlayer.Pause();
  202. }
  203. }
  204. }
  205. }
  206. #endregion // PRIVATE_METHODS
  207. #region PUBLIC_METHODS
  208. /// <summary>
  209. /// One-time check for the Instructional Screen
  210. /// </summary>
  211. public bool CheckWentToFullScreen()
  212. {
  213. bool result = mWentToFullScreen;
  214. mWentToFullScreen = false;
  215. return result;
  216. }
  217. #endregion // PUBLIC_METHODS
  218. }


高通AR加视屏解决方案相关推荐

  1. Unity 高通AR发布到Android发生黑屏

    这两天在做Unity 高通AR发布到Android的时候发生黑屏现象 后来发觉是不调用摄像头而不是黑屏(所谓黑屏是因为摄像头背景就是黑色的) 最后发觉是高通的文件夹出现错误 重新复制之前备份的一个高通 ...

  2. Unity3D制作高通AR(增强现实)图片识别应用

    最近在做游戏和AR,反正能做就做,这里简单介绍下高通AR图片识别的应用制作. 高通官网:https://developer.vuforia.com/ 首选下载unity3d的开发包 然后注册账号,登录 ...

  3. 高通AR增强现实Unity3D

    高通AR增强现实Unity3D | 浏览: 780 | 更新: 2013-04-02 13:04 35 75 AR: 增强现实,台湾翻译叫做扩张实境 1.注册.然后下载sdk(注册账号主要是为了第3步 ...

  4. 基于高通AR SDK的Demo总结(一)——常规3D模型的行为脚本

    下载高通AR SDK以及在Unity中的基本搭建不再阐述,具体给出dzyi大神的文章以便参阅:http://blog.csdn.net/dzyi_/article/details/22892641 这 ...

  5. 【Unity 03】高通 AR SDK基本使用以及项目发布

    PS:本系列笔记将会记录我此次在北京学习Unity开发的总体过程,方便后期写总结,笔记为日更. 笔记内容均为 自己理解,会有遗漏处,不保证每个都对,仅供参考 Part 1 网站注册: 官网:https ...

  6. Unity Vuforia(高通)AR

    Unity Vuforia制作AR软件 使用过高通AR.百度AR.EasyAR,还是觉得高通的使用起来更加简易.今天就记录一下怎么使用Vuforia制作一个可识别2D图片与3D物体的AR软件. 使用步 ...

  7. unity开发-高通Ar

    今天没什么事干,就来搞下这个高通AR,用unity做一个简单的小demo,我会把原项目发给大家,顺便说下步骤,让大家看下,一起学习下. 骚年们先看下效果图吧! 最终项目是发布在手机上的,然后运行,扫描 ...

  8. 高通AR增强现实最新教程unity3d

    高通AR增强现实最新教程 之前网上很多有关于高通AR增强现实的教程,教我们unity的龙哥跟我们说这方面的时候便去搜了搜,但是很不巧的是,这玩意在前几天刚刚更新了,所以.......这应该是目前最新的 ...

  9. 关于unity增强现实AR之高通AR(vufoia)的研究

    研究高通AR有段时间了,具体到识别去官网上注册,打包,将包导入unity3d,需要注意的是识别图片大小问题. 关于识别多物体总结一下: 首先还是一样去官网上打包,https://developer.v ...

最新文章

  1. 选择Scrum看板工具的七点特征
  2. Transform(CTM,Translate,Rotate,Scale)
  3. 机器学习基础(一)——人工神经网络与简单的感知器
  4. spring中事务的设计和实现
  5. 成功解决preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous.
  6. Python使用技巧
  7. python学习-高阶函数(函数传参、返回函数(闭包)、匿名函数lambda)
  8. 图论--边双连通V-DCC缩点
  9. Guavate:桥接Guava和Java8的微型库
  10. 计算机网上作业系统论文,网上作业提交系统的设计与实现
  11. robust off matlab,matlab_robust LM test 求指点!(空间计量)
  12. css的font修改颜色,css的font字体颜色如何设置
  13. Python如何从一个文件中调用另一个文件的类
  14. Linux文件夹操作
  15. 做了一款股票复盘工具
  16. 华为交换机导入配置_华为交换机配置文件备份与还原
  17. Spark核心开发者:性能超Hadoop百倍,算法实现仅有其1/10或1/100
  18. HTTP Cache(缓存)
  19. 北京6家IMAX影院比较(盘点)
  20. django 下载安装xadmin(django3.x + python3.6+xadmin2.x)

热门文章

  1. 计算机组成原理指令系统的设计,计算机组成原理与系统设计
  2. 【图片选择】Android 仿微信图片选择器疾风加载 (单选,多选,相机)--唯剑做伴且随疾风前行
  3. matlab模拟出现较大误差是什么原因,【求助】matlab 对复杂计算会出现较大误差吗?...
  4. 用函数实现判断素数(以及改进思路)
  5. 如何区分物联网卡与手机SIM卡
  6. 马毅:低维模型与深度模型的殊途同归
  7. 数据库MySQL-读写分离
  8. 2016年8月30日 星期二 --出埃及记 Exodus 16:31
  9. 【毕业设计】单片机机器视觉人体识别小车 - 深度学习 yolo目标检测 人体识别 树莓派
  10. 数智化转型进入“精装时代”,容联云助力千行百业加速上云用数赋智