List
Change camera type on runtime
Posted Date: 2018-08-14 16:09     Edited Date: 2018-08-21 7:59     Writer: inactive

Hello, i have an issue with camera on mobile device. When i change the type like this:

        CameraDevice cameraDevice = CameraDevice.GetInstance();
        cameraDevice.Stop();

        AbstractConfigurationScriptableObject conf = ConfigurationScriptableObject.GetInstance();
        conf.CameraType = (imgSwchr.State == 0) ? CameraDevice.CameraType.Rear : CameraDevice.CameraType.Face;

        cameraDevice.Start();

It does change camera from rear to face, but face gets image flipped verticaly. I tried to counter this by using:

        cameraDevice.FlipVideo(CameraDevice.FlipDirection.VERTICAL, true);

But it changes only the projected image. Game world is still flipped. I guess i can flip game world as well, but i don't know if this is the right way to do.. And another thing -- i had this issue on Samsung Galaxy S7, Google Pixel, Samsung Galaxy J3, tried also other older phones, and all of them flip image. But when i deployed on iPad everything was normal. What is the problem and what should i do?

I'm using Unity 2017.3, and newest MAXST sdk

 

Posted Date: 2018-08-19 23:29     Edited Date: 2018-08-19 23:29     Writer: inactive

We are sorry for making you waiting.

If you flip video the texture of game object would be flipped also.

So you should change texture coordinate for proper displaying.

We could not find the way on android device how to flip face camera properly.

If we can find that way we will apply it to next update.

Thank you

Jack, SDK support team

Posted Date: 2018-08-20 12:59     Edited Date: 2018-08-20 12:59     Writer: inactive

How do i change texture coordinate? I tried to change scale on CameraBackground material:

cameraBgMaterial.mainTextureScale = new Vector2(1,-1);

But it's not applying in the runtime, but when i change tiling property in the editor it changes. How to change via script properly?

Posted Date: 2018-08-20 13:44     Edited Date: 2018-08-20 13:44     Writer: inactive

Oh, i get it now. I got instance of material before it was instantiated by SDK. Now my question: Is there a callback or bool variable that tells that backround texture is created or not?

Posted Date: 2018-08-20 13:49     Edited Date: 2018-08-20 13:49     Writer: inactive

There seem to be a misunderstanding between us.

We thought that camera image flipped properly, but the textures of augmented object were mirrored.

Could you please post the screen capture of your program?

 

Posted Date: 2018-08-20 14:20     Edited Date: 2018-08-20 14:20     Writer: inactive

This is normal rear camera:

This is face camera:

This is without using cameraDevice.FlipVideo(CameraDevice.FlipDirection.VERTICAL, true).

With it: gameworld is flipped upside-down. For example instant tracker will track ceiling instead of floor (or so it looks like), but background texture looks properly.
P.S. cameraBgMaterial.mainTextureScale = new Vector2(1,-1); I made it work on PC but it doesn't on Android device.

 

 

Posted Date: 2018-08-20 14:40     Edited Date: 2018-08-20 14:42     Writer: inactive

With cameraDevice.FlipVideo(CameraDevice.FlipDirection.VERTICAL, true).

Rear:

Face:

P.S. I use FlipVideo only in face mode.

Posted Date: 2018-08-21 1:07     Edited Date: 2018-08-21 1:07     Writer: inactive

In spite of several hours researching we could not find proper way to solve your problem.

Because our instant tracker use device's motion sensor and camera image simultaneously we need to investigate to calibrating two factor's coordinate system.

However it is hard thing to solve.

Do you mind to let us know what is your purpose of using instant tracker with face camera?

Actually we don't thing that instant tracker is so good for face camera.

Posted Date: 2018-08-21 7:59     Edited Date: 2018-08-21 7:59     Writer: inactive

You're right. We discussed in team, and we don't really need instant tracker in face mode. I checked image tracker and it worked fine. It's my bad i only checked the instant tracker and thought it would apply to image as well. Thank you, I appreciate your help.