non 4:3 input aspect ratios in 3d engines

9 views
Skip to first unread message

Eero Koplimets

unread,
Jan 6, 2011, 6:18:16 AM1/6/11
to FLARToolKit userz
Just calling my vote to fix this - "( ) wide aspect ratios work well
for PV3D but no other framework. "

Recently changed project from pv3d to Alternativa 3D engine, got
working but then on some camera resolutions aligning problems started.
After some 4 hours of debugging and searching found this line in
flarmanager todo.txt...

Monitors have moved on from 4:3, can somebody check what's missing in
away3d and alternativa matrix transforms please?

Eero

Makc

unread,
Jan 6, 2011, 6:58:32 AM1/6/11
to flartool...@googlegroups.com
are you sure it's not just mismatch between your actual webcam and
calibration data you use? maybe post a screenshot?

Eero Koplimets

unread,
Jan 6, 2011, 9:37:08 AM1/6/11
to FLARToolKit userz
Its not mismatch of calibration. The more source ratio goes away from
4/3 the worsen the effect.

I'm using same detection result (FLARTransMatResult) on each sample
image below. With image of 3/2 ratio the PW3D works fine, Alternativa
has offset visible. After I manually add height to image (to make it
4/3) alternativa works also fine.

As far as I debugged I guess flartoolkit camera in papervision also
changes translation values in matrix3d, but other engine cameras just
add 0 0 0 1 to 4th column...

Here are some screenshots:
https://www.dropbox.com/gallery/20705/1/flartoolkit?h=aebd52#/

Eero

Makc

unread,
Jan 6, 2011, 10:42:03 AM1/6/11
to flartool...@googlegroups.com
On Thu, Jan 6, 2011 at 4:37 PM, Eero Koplimets <eero.ko...@gmail.com> wrote:
> As far as I debugged I guess flartoolkit camera in papervision also
> changes translation values in matrix3d, but other engine cameras just
> add 0 0 0 1 to 4th column...
>

that's weird, 0001 is supposed to go to 4th row, not column. could you
post your FLARTransMatResultand engine matrices?

Eero Koplimets

unread,
Jan 6, 2011, 12:17:22 PM1/6/11
to FLARToolKit userz
So the flartoolkit matrix looks like this...
[org.libspark.flartoolkit.core.transmat::FLARTransMatResult
-0.006, 0.999, -0.008, 198.983,
0.315, -0.005, -0.949, 157.491,
-0.949, -0.008, -0.314, 3398.768
]

And gets translated to flash.geom.Matrix3D

myObject3D.matrix = new Matrix3D(Vector.<Number>([
matrix.m00, matrix.m10, matrix.m20, 0,
matrix.m01, matrix.m11, matrix.m21, 0,
matrix.m02, matrix.m12, matrix.m22, 0,
matrix.m03, matrix.m13, matrix.m23, 1
]));

So my guess is that last row shouldn't be 0001 when aspect ratio is
other than 4/3.

Eero

On Jan 6, 5:42 pm, Makc <makc.the.gr...@gmail.com> wrote:

Makc

unread,
Jan 6, 2011, 2:29:42 PM1/6/11
to flartool...@googlegroups.com
well as you can see FLARTransMatResult provides only 12 values, to
replace 0001 with something else you need 16.

also, flash.geom.Matrix3D has its values ordered by columns, so
matrix.m00 matrix.m10 matrix.m20 0 is actually 1st column, and 0001 is
really last row.

it's hard to say where this comes from, but it could be that 4:3 video
corresponds to 1:1 aspect ratio, and changeScreenSize call to
dimensions other than 4:3 changes aspect from 1:1 internally (which
imho it should not do). can't say about away math, but alternativa
math relies on 1:1 aspect ratio for sures. if so, papervision math
must have some scaling hack in there to work with non-1:1 aspects.

personally, I would just set FLARParam to values corresponding to 1:1
aspect for your video size by hand.

eric socolofsky

unread,
Jan 6, 2011, 3:59:29 PM1/6/11
to flartool...@googlegroups.com
i think the origin of this post came from FLARManager's todo.txt file (is that right, eero?). i'll have to look into it, but this is a fairly long-standing omission in support; surprisingly, this is the first time i've heard someone ask for it to be fixed. since PV is all-but-dead, it makes sense for this to be a high priority.

i'll take a look as soon as i have a moment.
-e

Eero Koplimets

unread,
Jan 7, 2011, 3:14:39 AM1/7/11
to FLARToolKit userz
Hi,

Thank you makc and eric for picking this up.

Flarmanager todo.txt confirmed my theory of alignment issues in lib
after changing 3d engine.

As I see, only the PV matrix transform calculates values for 4th row,
others use 0001
http://www.libspark.org/browser/as3/FLARToolKit/trunk/src/org/libspark/flartoolkit/support/pv3d/FLARCamera3D.as

Eero

Makc

unread,
Jan 7, 2011, 6:07:19 AM1/7/11
to flartool...@googlegroups.com
On Fri, Jan 7, 2011 at 10:14 AM, Eero Koplimets
<eero.ko...@gmail.com> wrote:
> As I see, only the PV matrix transform calculates values for 4th row,
> others use 0001
> http://www.libspark.org/browser/as3/FLARToolKit/trunk/src/org/libspark/flartoolkit/support/pv3d/FLARCamera3D.as

you're really looking in the wrong place, this one calculates
projection matrix, not transformation matrix.

Makc

unread,
Jan 7, 2011, 8:47:12 AM1/7/11
to flartool...@googlegroups.com
just to prove my point,
add this method to FLARParam class,

public function setScreenSize (w:int, h:int):void {
_screen_size.w = w;
_screen_size.h = h;

// this hack should not be needed in flartoolkit trunk
var hack:Number = 0.1;

var diag:Number = Math.sqrt (w * w + h * h); // 640x480 -> 800
var dist:Vector.<Number> = Vector.<Number>([
w / 2, h / 2, 25 * Math.pow (800 / diag, 2), 1.01
]);
trace ("1, dist", dist);

var proj:Vector.<Number> = Vector.<Number>([
0.9 * diag + hack, 0, w / 2, 0,
0, 0.9 * diag - hack, h / 2, 0,
0, 0, 1, 0
]);
trace ("1, proj", proj)

setValue (dist, proj);
}

and change line 136 in flartoolkitmanager class to
this.cameraParams.setScreenSize(flarSource.source.width,
flarSource.source.height);

and - voila - it all works again

Untitled.png

sergio silva

unread,
Jan 7, 2011, 1:39:44 PM1/7/11
to flartool...@googlegroups.com
Yes,
MarKc as always is right, but it tends to just give the directions, not the answers, to people questions, I think it's a away of helpping.
Regards
Sérgio

2011/1/7 Makc <makc.th...@gmail.com>

makc

unread,
Jan 7, 2011, 2:15:43 PM1/7/11
to FLARToolKit userz
On Jan 7, 8:39 pm, sergio silva <spsantossi...@gmail.com> wrote:
> it tends to just give the directions, not the
> answers, to people questions

what kind of answer would you offer? this guy comes here and is like
"hey guys, I've found non-4:3 screen sizes do not work, ok"......
well ..... my answer to that is "wow you're right, it doesn't".... but
omehow I don't think it's helpful :)

but then he went after 0001 combo, can't imagine the reason he's not
happy about those numbers. so I made a guess and proved it right, now
it's up to eric to decide how to fix it in flarmanager.

sergio silva

unread,
Jan 7, 2011, 4:07:33 PM1/7/11
to flartool...@googlegroups.com
Sorry MaKc,
Didn't want to hurt you feelings, I was just pointing a fact that you are an excelent problem solver, you always show people the right direction, and for me that's great and if pleople do follow your direction they will learn the lesson, the problem is that many people may think you are just joking with them. So may think your directions are not worth the efford of being follow.

BUT please read MaKC direction and follow he usually points the right direction.

Regards
Sérgio

2011/1/7 makc <makc.th...@gmail.com>
Reply all
Reply to author
Forward
0 new messages