viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.3k stars 482 forks source link

Place ViroImage perpendicular to floor #330

Closed Tamiyadd closed 6 years ago

Tamiyadd commented 6 years ago

Hi, using a vertical ViroARImageMarker i'm trying to place a ViroImage perpendicular to floor but sometimes the image it is not. There is a way to make the image appear always perpendicular to the floor? thanks

dam00n commented 6 years ago

Hi @Tamiyadd, take a look at our AR Poster Demo sample to see how to do this. The poster is vertical and the 3Dobject is perpendicular to the floor. -> https://github.com/viromedia/viro/tree/master/js/ARPosterDemo

Rotate the node relative to the image marker e.g.

<ViroNode position={[0, -.1, 0]} scale={[0,0,0]} rotation={[-90, 0, 0]} dragType="FixedToWorld" onDrag={()=>{}} animation={{name:"scaleModel", run:this.state.playAnim,}} >

Tamiyadd commented 6 years ago

hi @dam00n i'm using that code but as you can see from my screenshoot the item is not perpendicular

img_8236

this is the marker img_8238

and this is how the camera get the marker, i've put a copy of the marker in position: {[0,0,0]} so i can see what the camera get img_8237

dam00n commented 6 years ago

@Tamiyadd can you try another marker and see if you see the same drift. Perhaps the Tesla Marker or another marker in your office as a comparison test? Would like to see if the issue is with the marker or the platform.

Here is ARKit's guidance regarding image markers -> https://developer.apple.com/design/human-interface-guidelines/ios/system-capabilities/augmented-reality/

"Design and display reference images to optimize detection. When you provide reference images, you specify the physical size at which you expect to find those images in the user’s environment. Providing a more precise size measurement helps ARKit detect images faster and provide more accurate estimates of their real-world position. Detection performance and accuracy are best for flat rectangular images with high contrast and bold details. Avoid trying to detect images that appear on reflective or curved real-world surfaces."

If you are able to change your marker, perhaps adding more high contrast and bold details might help?

Tamiyadd commented 6 years ago

@dam00n yeah i can confirm that with the example marker the recognition works a lot better! There is a way to compensate the drift without changing the marker?

dam00n commented 6 years ago

Unfortunately there is not much you can do at this time to compensate for the drift besides changing the marker.

Tamiyadd commented 6 years ago

@dam00n can i know when an image is exactly on the marker? because if i can know that i can create a workaround and make the user adjust the rotation using pauseUpdates={false} then lock the correct rotation disabling the updates.

i have also noticed that using transformBehaviors={'BillboardY'} the image stand more perpendicular but it rotate on Y axys, can i prevent that rotation?

thanks

achuvm commented 6 years ago

Hi @Tamiyadd,

Unfortunately, ARCore/ARKit don't provide any "confidence" values for you (or us) to determine how "accurate" a match is.

If you want something to be perpendicular to the ground, you can manually listen to onAnchorFound or onAnchorUpdated and set the position/rotation of an object based on the returned Anchor's position and/or rotation. Keep in mind that for rotations, there are multiple combinations of X, Y and Z values that can represent a rotation (rotations aren't "stable" in value).

The use of BillboardY is to make an object rotate about the y-axis to always face the user, so as you move about your world, the object will always follow you. Something you could consider is using the given rotation of the found Image Anchor to compute the projected X-Z rotation and use that rotate the image (after positioning) to make sure the image faces "forward" from the marker.

Let me know if you have any other questions!

dam00n commented 6 years ago

Closing this issue due to inactivity. If you are still having issues, please re-open and provide additional comments so we can investigate further. Thanks