arkit

Creating path using CGMutablePath creates line to wrong CGPoint

≯℡__Kan透↙ 提交于 2019-12-04 05:55:42
问题 I was planning to display information of AR object in screen with arrow in 2D. So I used projectPoint to get corresponding position of object in screen. I have this function to return convert 3D position of node to 2D and CGPoint to display info text in. func getPoint(sceneView: ARSCNView) -> (CGPoint, CGPoint){ let projectedPoint = sceneView.projectPoint(node.worldPosition) return (point, CGPoint(x: CGFloat(projectedPoint.x), y: CGFloat(projectedPoint.y)) ) } and this to draw line using

Add image to AR Resources on the fly for image recognition

天涯浪子 提交于 2019-12-04 02:34:39
ARKit 1.5 introduces image recognition. In the code you have to create a Set of the reference images like this: let referenceImages = ARReferenceImage.referenceImages(inGroupNamed: "AR Resources", bundle: nil) and then images contained in the Set can be recognised. I wanted to know if it is possible to add images on the fly to this AR Resources folder. For example a user could take a picture and send it to a server, it is then recognised by the ARKit . Or a user could receive a set of images based on his location, etc. You cannot amend the contents of the default folder at runtime, although

AR Reference image - The histogram of the image is narrow

此生再无相见时 提交于 2019-12-04 02:11:44
问题 I am adding an image into ARKit project. But it gives error. 回答1: You have an image whose content is not good for detection. There's a section in the WWDC18 talk What's New in ARKit 2 that talks about this and has some examples of what's good and what's not: The image on the right has multiple problems, but shares the "uniform color regions" and "narrow histogram" issues you have. For a human, that image is pretty easy to recognize, because it uses our ability to identify solid shapes on

Adding a SCNBillboardConstraint makes the node dissapear

只愿长相守 提交于 2019-12-04 00:29:10
问题 After what I've read in the documentation and on the internet a SCNBillboardConstraint would rotate a node to always face the pointOfView node - in the case of ARKit , the user's camera. The thing is, when I add a SCNBillboardConstraint to a child node, it dissapears. The nodes are just some SCNTexts added as a subchild of a more complex model. The hierarchy looks something like this: RootNode - > Text node (two of them). Just after I added the root node to the scene's root node, I add this

ARKit - How to contain SCNText within another SCNNode (speech bubble)

自作多情 提交于 2019-12-03 20:53:06
I am trying to create a quote generator with simple text within a speech bubble in ARKit. I can show the speech bubble with text, but the text always starts in the middle and overflows outside of the speech bubble. Any help getting it align in the top left of the speech bubble and wrapping within the speech bubble would be appreciated. Result Classes class SpeechBubbleNode: SCNNode { private let textNode = TextNode() var string: String? { didSet { textNode.string = string } } override init() { super.init() // Speech Bubble let plane = SCNPlane(width: 200.0, height: 100.0) plane.cornerRadius =

SceneKit nodes aren't changing position with scene's root node

 ̄綄美尐妖づ 提交于 2019-12-03 20:43:06
I'm using SceneKit with ARKit, and right now have a simple app where I tap on the screen and it adds an ARAnchor and a SCNNode to my scene. At some point, I'm going to want to move the entire scene, so I tried changing sceneView.scene.rootNode.position.x += 10 to test this out. If I call this on any particular node, that node does move appropriately. But calling this on rootNode , nothing happens, where I'd expect every child node (which is every node in the scene) to move along with it. Why are my other nodes not moving appropriately, and is there something I can do to fix this? Or am I

How to detect vertical planes in ARKit?

陌路散爱 提交于 2019-12-03 17:55:43
问题 How is it possible to implement a vertical plane detection (i.e. for walls)? let configuration = ARWorldTrackingSessionConfiguration() configuration.planeDetection = .horizontal //TODO 回答1: Edit: This is now supported as of ARKit 1.5 (iOS 11.3). Simply use .vertical . I have kept the previous post below for historical purposes. TL;DR Vertical plane detection is not (yet) a feature that exists in ARKit. The .horizontal suggests that this feature could be being worked on and might be added in

Metal file as part of an iOS framework

大憨熊 提交于 2019-12-03 17:26:31
问题 I am trying to create a framework that works with METAL Api (iOS). I am pretty new to this platform and I would like to know how to build the framework to work with .metal files (I am building a static lib, not dynamic). Should they be a part of the .a file, or as a resource files in the framework bundle? Or is there an other way to do that? Thanks. Update: For those who tackle this - I ended up following warrenm's 1's suggested option - converted the .metal file into a string and calling

Importing .scn file to scene from URL with textures

久未见 提交于 2019-12-03 15:36:13
I am using ARKit for my application and I try to dynamically load .scn files from web-server Here is a part of my code let url = URL(string: "http://192.168.0.31:1234/5a27e09cbad20a7a03ad5d80/box/box.scn") if let objectScene = try? SCNScene(url: url!, options: [.overrideAssetURLs: true]) { print("load success") let node = SCNNode() for childNode in objectScene.rootNode.childNodes { node.addChildNode(childNode) } sceneView.scene.rootNode.addChildNode(node) } else { print("error loading") } here box.scn contains textures. And I got an error Failed loading: C3DImage 0x1c00f6f80 src:file:///var

How do you play a video with alpha channel using AVFoundation?

自闭症网瘾萝莉.ら 提交于 2019-12-03 14:24:18
I have an AR application which uses SceneKit , and imports a video on to scene using AVPlayer and thereby adding it as a child node of an SKVideo node. The video is visible as it is supposed to, but the transparency in the video is not achieved. Code as follows: let spriteKitScene = SKScene(size: CGSize(width: self.sceneView.frame.width, height: self.sceneView.frame.height)) spriteKitScene.scaleMode = .aspectFit guard let fileURL = Bundle.main.url(forResource: "Triple_Tap_1", withExtension: "mp4") else { return } let videoPlayer = AVPlayer(url: fileURL) videoPlayer.actionAtItemEnd = .none let