Different camera rotation than device rotation

Started by billda, September 09, 2014, 01:32:06 PM

Previous topic - Next topic

billda

Hi, Ok i have another silly question. I am implementing some kind of augmented reality application. I am displaying camera preview and overlaying it with 3D object. I am getting data from gyroscope and rotating camera of jpct so object is rotated corresponding with device rotation. My problem is that model is moving quicker than "real world" at camera preview. I thought that it has something to do with FOV so i took that "FOV" code from vuforia sample, but it didnt solve that problem, model was streched and problem with rotation was not solved.

Is there any way how I can "normalize" this movements?

EgonOlsen

I'm not sure. If you are doing the transformation between the different coordinate systems properly, i would expect the rotations to be in sync. But then again, i've never used this stuff, so i've no real idea what kind of matrix the gyroscope API returns.

billda

Here is code for my transformation:

            cam = world.getCamera();
            Matrix r = getRotationMatrix(rotationMatrix);
            r.transformToGL();
            cam.setBack(r);


where rotationMatrix is matrix from gyroscope. Method getRotationMatrix is just converting between different data types for matrices. Do you think that I should do some extra transformation? I thought that its not necessary when all three rotations are in the right direction.

EgonOlsen

Looks fine at first glance. it would be nice to see getRotationMatrix() anyway...

billda

Okey, its only converting from 3x3 array to 4x4 matrix:

private Matrix getRotationMatrix(float[] data) {
            Matrix ret = new Matrix();

            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    ret.set(i, j, data[i * 3 + j]);
                }
            }
            ret.setRow(3, 0, 0, 0, 1);
            ret.setColumn(3, 0, 0, 0, 1);
            return ret;
       }

EgonOlsen

Looks ok...have you tried to leave out the r.transformToGL(); call just to make sure that the matrix isn't in the correct format already?