jcmellado / js-aruco

JavaScript library for Augmented Reality applications
Other
600 stars 132 forks source link

samples/debug-posit shows incorrectly posed rectangles #25

Closed mncharity closed 6 years ago

mncharity commented 6 years ago

I ran debug-posit.html on a stationary marker cube. Attached are three captured frames, and a composite.

Several solid-color rectangles are shown with implausibly incorrect orientations. These orientations are stable, not transients.

I have not explored whether these are caused by the sample display code, and/or by the underlying pose estimators.

debug-posit--composite debug-posit--frame1 debug-posit--frame2 debug-posit--frame3

jcmellado commented 6 years ago

You hit the "ambiguity problem".

It generally happens when the marker is small in relation to the image, or in very inclined positions. When tracking a marker, you see this effect as a strange change flip of the z-axis of the marker.

See the "Tracking the position of a marker" (and "Benefits of using Marker Maps") sections from here: https://www.uco.es/investiga/grupos/ava/node/26

mncharity commented 6 years ago

You hit the "ambiguity problem".

I'm confused. The ambiguity problem seems to be (thanks sci-hub!) that two candidate poses both place their corners observationally close to the observed locations. But the posed rectangles drawn, have corners observationally distant from the observed locations. debug-posit--overlay

jcmellado commented 6 years ago

Well, maybe I'm wrong and misunderstood the problem. I have been asked for this before.

I ported two algorithms (pose1.js and pose2.js), not sure what are you using, probably the first one.

The pose estimation is an iterative algorithm looking for convergence. You could draw the estimated pose on each iteration in order to understand what is going wrong.

Maybe the points are not been passed to the algorithm in the correct order in some cases.

mncharity commented 6 years ago

Adding object.eulerOrder = 'YXZ'; to createPlane in debug-posit.html fixes the issue.

Would you like a PR?

Thank you for sharing your work!

jcmellado commented 6 years ago

Really? Awesome!

The example is using Three.js r70, and eulerOrder is deprecated: https://github.com/mrdoob/three.js/blob/r70/src/core/Object3D.js#L92

I'll made some tests and fix the sample.

Thanks

mncharity commented 6 years ago

eulerOrder is deprecated

Ah, good catch. And it seems gone in the current r89. The suggested alternative, .rotation.order is still present.

So, did you intend to use object.rotation.order instead of object.eulerOrder in "Fixed POSIT demo" 34ea629? It does seem to work.

Really?

FWIW, I found it helpful to overlay debug-posit.html's lower-left pane, on the upper-left pane with video, making it much easier to accurately eyeball alignment while exploring lots of poses.

jcmellado commented 6 years ago

So, did you intend to use object.rotation.order instead of object.eulerOrder in "Fixed POSIT demo" 34ea629? It does seem to work.

No, I was in a hurry