Trackable custom anchors in ARKit - swift

Is there a way to create a custom anchor with ARKit that is trackable? I am trying to build and AR app and put an anchor on a moving 3D object and have a scenekit node render on that object. For example, can a create an anchor on someone's hand/leg/toe/dog/ball (without a VNHandPoseRequest) that conforms to ARTrackable? I have a model that gives me the exact 3D location of this initial anchor and that is how I plan of initializing it, but now I need a way to track that 3D point in realtime in an ARScene.

Related

Unity3D: Position objects relative to Vuforia Image marker im multiple scenes

I have two scenes:
Scene1: User has to track Image marker.
Scene2: Display Objects relative to the image marker scanned in Scene1.
In Scene1 i attached "Vuforia Behaviour Script" to the MRKT camera. In Scene2 im just using the out of the box camera from MRTK (wihtout Vuforia Behaviour Script).
Is there any way to store the position data to archive this?
Im using Hololens2 With MRTK
You can use Spatial Anchor to track the special point in the world. When you are using this technology, you should note the locations where you create anchors should have stable visual features(that is, features that don't change often). For example, the physical surface you mentioned Vuforia image marker is not a good point to create anchors. However, it would be good practice to place anchors where they have stable visual features around Vuforia image markers and record the relative position of the image marker from the anchor.
If you are new to the Spatial Anchor, you can start from here: Spatial Anchor

Unity AR Foundation object anchor problem

I am new on unity ar foundation and I am trying to create simple screen that when camera looks to the target image, my object will be visible at that point and some other objects will be visible according to first object position (referans point).
When camera looks the target image, my object becomes visible but when I move camera, object also moves with camera direction as well like that; check here to see video
What can I do to keep object always at the same point even camera moves (even it can be render once -no update-).. any advise ? Thanks
Which AR platform do you working on? (ARKit & ARCore) You don't need an anchor if you use the tracked image. Because it is already an anchor. Update your game object transform if only if tracked image anchor tracking state is tracking & limited. Also the image you provided has few trackable features. You should test your code with an image that has more features than the current image. Also setting the image's physical size correctly greatly improves tracking.

ARKit: Change FOV for rendered content

I'm looking to change the field of view for the rendered content in my AR session. Obviously we can't change the raw camera FOV, but I think it should be possible to change the field of view for the rendered SceneKit content.
Changing the camera field of view is trivial in a raw SceneKit SCNCamera... but I don't know how to do this within an ARSCNView.
You might be able to access the pointOfView property of your ARSCNView (and then retrieve the active SCNCamera).
If that doesn't work (ARKit changing the camera property every frame etc.), you can always go the path of writing the code yourself by using ARSession directly with SCNView.
Note that unless you have a 3D scene covering the entire camera stream, changing the FoV of your virtual camera would break the AR registration (alignment).
The developer documentation for ARSession suggests "If you build your own renderer for AR content, you'll need to instantiate and maintain an ARSession object yourself."
This repo does this: https://github.com/hanleyweng/iOS-ARKit-Headset-View
This code will retrieve the camera from an ARSCNView if there is one:
sceneView.scene.rootNode.childNodes.first(where: { $0.camera != nil})
Note that this will return the camera's associated node, which you may need if you want to control its position or angle directly. The SCNCamera itself is stored in the node's camera property.
It's best not to touch the AR camera if you can avoid it as it will mess up the association between the world model and the scene. I occasionally use this technique if I want a control system that can optionally use AR to track device motion and angle, but which doesn't have to translate into real-world coordinates (i.e. VR apps that don't display the camera feed).
Essentially, I'd only do this if you're using AROrientationTrackingConfiguration or similar.
EDIT I should probably mention that ARKit overrides the camera's projectionTransform property, so you probably won't be able to set fieldOfView manually. I've had some success setting xFov and yFov, but since these are deprecated you shouldn't rely on them.

ARKit large model follows camera instead of staying stationary

My code looks for a QR Code in the frame received during the session(didUpdate) ARSCNViewDelegate method. I check to see if all four corners and the center of the QR Code are in the same plane with hitTest, and then drop an ARAnchor at the center. I create a SCNReferenceNode for the anchor with a reference to a scenekit model of a fairly large house (70'w x 30'd x 30'h) I position the house 30 meters in front (z =-30) and 30 meters to the right (x=30) of the detected QR Code, and it initially appears OK. However, if I try to "walk around" the model, it moves with me, always maintaining a constant distance and offset from my iPad camera. I have tried using my own anchors, the plane anchors created by ARKit, and lots of other ideas, nothing changes. How can I get it to stay put, like the plane model does in the boilerplate ARKit xcode project?
It sounds like although you created some new anchors, that you perhaps didn't assign your model to them? So when your model gets loaded and presented, it's being 'tracked' on the gyro. So you get that Pokemon Go effect where regardless of what you do the AR model doesn't change in size.

Clickable and Rotatable models using Unity and ARToolkit

Can the 3D models used with the markers be made clickable and rotate able using Unity3D engine and ARToolkit unity. Basically in the AR desktop application we are making , we want to implement this functionality on the 3D models as well. Kindly need help in this matter. ThankYou.
The only issue you could find is that the Transformation of the AR Tracked Object changes based on the visual information.
If you simply use that as a base object and put any other models as children of that one, you can modify their position and rotation in the same way you would do for any other situation.
So, as you see, the Marker scene has nothing but an AR Tracked Object, this is the object that will be updated with the pose of the marker.
Then, the Cube is a child of this object. If you modify the localPosition or localRotation of the cube it will work as you want it.
The Cube is a child of the Marker scene, its global position and rotation will be a combination of the position and rotation of its parent with its local position and rotation (this is standard 3DEngine / SceneGraph behaviour).