Log in or register to post comments

Bug in VideoTextureBehaviour.cs

March 27, 2012 - 12:53pm #1

This routine, I think, should be reduced to just this:

    // Returns true if the video mesh should be scaled to match the width of the screen
    // Returns false if the video mesh should be scaled to match the height of the screen
    private bool ShouldFitWidth()
    {
        return (mTextureInfo.imageSize.x >= mTextureInfo.imageSize.y); // if cam image is wider than tall, it should fit width
    }

The original code looks at screen width and height, but I don't think it matters, and was giving me the wrong answer in landscape orientation.

Re: Bug in VideoTextureBehaviour.cs

March 29, 2012 - 12:41pm #5

Ah ok, my misunderstanding. That's good to know, and I think I want it as an option in my project, stretch-to-fill or stretch-to-fit.

It was the Xoom and Xoom 2 that were different. And they were different from each other too. Ex: the Xoom's camera image filled about 1/3 of the screen, where same code running on a Droid was just fine. And I have not seen 'orthographic' work on any device, image is always too small. I suspect there is some assumption of position or something I'm missing.

Re: Bug in VideoTextureBehaviour.cs

March 28, 2012 - 8:34pm #4

So this isn't what the sample does. What you're showing here is an "Aspect Fit" scaling. By default Vuforia uses an "Aspect Fill", where the camera image is scaled to fill the screen while maintaing the aspect ratio of the image. This means that part of the camera image is "rendered" off screen.

Which tablet are you seeing strange results with? We can try to test on our end.

Note that the BackgroundTextureAccess sample has trouble with autorotate, I believe. I suggest testing it in a fixed Landscape Left orientation.

- Kim

Re: Bug in VideoTextureBehaviour.cs

March 28, 2012 - 12:49pm #3

I may need to draw a picture and post it. By the way, the 'orthographic' option doesn't work in any of the cases I tried, the image is about 1/5 (but not exactly) the width/height it should be. And Xoom tablets are giving wildly different results (Xoom1 vs Xoom2 vs anything else). I think part of the problem is that 'soft buttons' take up part of the screen, onto which Unity does not render, but does consider part of the screen size. I need to verify this, but I get better results on phones that have those buttons off the screen.

Ok, here are the 4 scenarios I'm considering, maybe I'm missing something?
Landscape screen, landscape camera
Landscape screen, portrait camera
Portrait screen, landscape camera
Portrait screen, portrait camera.

In all cases, if the camera image is wider than it is tall, it should be scaled to fit width, else, height.

Re: Bug in VideoTextureBehaviour.cs

March 27, 2012 - 8:08pm #2

It's more complicated than that. On some devices, the aspect ratio of the camera image is "wider" than the aspect ratio of the screen (even when held in landscape). In this case you want to stretch the camera image to fill the height of the screen, with a little excess off to the left and right. Your check would result in fitting just the width, leaving a black bar on top and bottom.

It might be possible to simplify the current code, but you say it was giving you the wrong result? What is the resolution of your screen, and what is the camera image size?

- Kim

Log in or register to post comments