【问题标题】:How to fix the number of prefabs that the ARCore can display at the same time ? (with image recognition)如何修复 ARCore 可以同时显示的预制件数量? (带图像识别)
【发布时间】:2019-08-01 03:06:54
【问题描述】:

当前的应用程序允许您检测海报并以海报的大小显示启动视频的平面。

我的问题是视频中有声音,例如,如果你同时看 3 张海报,你就什么都听不懂了。

我正在尝试启用用户正在观看的视频的声音,或者限制同时显示的视频数量(例如在显示另一个视频之前等待第一个视频完成)

我目前使用的是 unity 2019.1.6 带有arcore 1.10.0 版本的android 构建

我尝试通过触发器使用系统,然后通过Raycast但无事可做,我仍然有声音并且视频都显示了。

[SerializeField] private VideoClip[] videoClips;
public AugmentedImage Image;
private VideoPlayer video;

void Start()
{
    video = GetComponent<VideoPlayer>();
    video.loopPointReached += OnStop;
}

private void OnStop(VideoPlayer source)
{
    gameObject.SetActive(false);
}

void Update()
{
    if (Image == null || Image.TrackingState != TrackingState.Tracking)
    {
        return;
    }

    if (!video.isPlaying)
    {
        video.clip = videoClips[Image.DatabaseIndex];
        video.Play();
    }

    transform.localScale = new Vector3(Image.ExtentX - 1, Image.ExtentZ, 1);
}

我的结果很奇怪,要么视频不再出现但有视频的声音,要么什么都不显示。

你能帮帮我吗?

【问题讨论】:

    标签: unity3d video image-recognition arcore


    【解决方案1】:

    我不完全了解您的代码和设置,但我只是检查用户正在查看的方向与用户和图像之间的矢量之间的角度。类似的东西,例如

    [Tooltip("Angle in degrees between view direction and positions vector has to be smaller than this to activate the video")]
    [SerializeField] private float angleThreshold = 20f;
    
    // if possible already reference this via the Inspector
    [SerializeField] private Camera mainCamera;
    
    void Start()
    {
        if(!mainCamera) mainCamera = Camera.main;
    }
    
    void Update()
    {
        // get positions vector
        var direction = (Image.CenterPose.position - mainCamera.transform.position).normalized;
        // get view direction
        var viewDirection = mainCamera.transform.forward;
        // get angle between them
        var angle = Vector3.Angle(viewDirection, direction);
    
        // optionally you could use only the X axis for the angle check 
        // by eliminating the Y value of both vectors
        // allowing the user to still look up and down 
        //direction = (new Vector3(Image.CenterPose.position.x, 0, Image.CenterPose.position.z) - new Vector3(mainCamera.transform.position.x, 0 , mainCamera.transform.position.z)).normalized;
        //viewDirection = new Vector3(viewDirection.x, 0, viewDirection.z);
    
        // also check the angle
        if (Image == null || Image.TrackingState != TrackingState.Tracking || angle > angleThreshold)
        {
            // optional: I would also stop the video if no longer in focus
            if (video.isPlaying && video.clip == videoClips[Image.DatabaseIndex]) video.Stop();
            return;
        }
    
        if (!video.isPlaying)
        {
            video.clip = videoClips[Image.DatabaseIndex];
            video.Play();
        }
    
        transform.localScale = new Vector3(Image.ExtentX - 1, Image.ExtentZ, 1);
    }
    

    【讨论】:

    • 您好,我的设置和代码与本教程视频很接近(几乎是复制和粘贴):youtube.com/watch?v=GkzMFNmvums 好主意,直​​到现在我一直在尝试使用统一工具解决我的问题。 ...我可以做数学。当你戴上眼罩^^
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 2019-02-14
    • 1970-01-01
    • 1970-01-01
    • 2014-03-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多