gpt4 book ai didi

swift - RealityKit 中的 ARVideoNode

转载 作者:行者123 更新时间:2023-12-02 05:46:47 31 4
gpt4 key购买 nike

我正在试验 Open AI 的 ChatGPT,当被要求提供一个代码,用于在跟踪引用图像时在 RealityKit 的 AR 场景中播放视频,它使用 ARVideoNode 而不是我预期的 AVPlayer VideoMaterial 解决方案。当我问到为什么 ARVideoNodeVideoMaterial 上比 AVPlayer 更好时,它甚至给了我一个答案,但我从未听说过 ARVideoNode 在 RealityKit 中。

我是不是遗漏了什么,或者这只是 AI 的一个缺陷?

import RealityKit

// Set up image tracking
let configuration = ARImageTrackingConfiguration()
configuration.detectionImages = ["reference-image-1", "reference-image-2"]
arView.session.run(configuration)

// Create a dictionary to map reference image names to video file names
let videoFileNames = ["reference-image-1": "video-1.mp4",
"reference-image-2": "video-2.mp4"]

// Track the reference images and display the corresponding
// videos on top of them
var videoNodes = [String: ARVideoNode]()
arView.scene.subscribe(to: ARImageAnchor.self) { (anchor: ARImageAnchor) in
// Get the video file name for the tracked image
guard let videoFileName = videoFileNames[anchor.name] else { return }

// Load the video file
let videoURL = URL(fileURLWithPath: "path/to/\(videoFileName)")
let videoAsset = VideoAsset(url: videoURL)

// Create an ARVideoNode and add it to the scene
let videoNode = ARVideoNode(asset: videoAsset)
arView.scene.anchors.append(videoNode)
videoNodes[anchor.name] = videoNode

// Position the video node on top of the image
videoNode.transform = anchor.transform

// Play the video
videoNode.play()
}

// Monitor the tracking status of the reference images
// and pause/resume the videos as needed
arView.scene.subscribe(to: ARImageAnchor.self) { (anchor: ARImageAnchor) in
// Get the video node for the tracked image
guard let videoNode = videoNodes[anchor.name] else { return }

if anchor.isTracked {
// Resume playing the video if the image is being tracked
videoNode.play()
} else {
// Pause the video if the image is not being tracked
videoNode.pause()
}
}

最佳答案

这不是缺陷,而是 ChatGPT 的错误答案。据我所知,九段的ARVideoNode是用于呈现视频内容的 ARNode 父类的子类。即使在编程语言方面,它也与 RealityKit 无关 - KudanAR SDK native 使用 Objective-C适用于 iOS 和 Java 适用于 Android。

这是 SO temporary policy关于 ChatGPT:

Overall, because the average rate of getting correct answers from ChatGPT is too low, the posting of answers created by ChatGPT is substantially harmful to the site and to users who are asking and looking for correct answers.

关于swift - RealityKit 中的 ARVideoNode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74838159/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com