Log in or register to post comments

Camera view stretched on Android

June 26, 2014 - 11:42am #24

Hello,

I'm using Unity 4.5.0 and Vuforia 3.0.6, I have same problem with my application and imageTarget sample 3.0.7.

If I use my LG4X phone, 1280x720 resolution, camera is ok.

If I use a Nexus 7 tablet, 1280x800 resolution, camera view is stretched.

Seems this same issue:

https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/camera-view-stretched-and-rotation-90-deg-unity-451

Can you tell me if it's a bug that need to be fixed, or if is something I must set through code? And how?

PS. I may had dreamt it, but my app was stretched, then I installed the imageTarget sample and I'm almost sure it wasn't stretched, so I went back to my app that was still stretched, then back again to imageTarget sample and it was stretched. From then, always stretched, even by restarting the tablet and uninstalling and reinstalling all the apps.This is just an hint, I'm not sure that it worked that first time.
 

Thanks!

Mattia

 

 

Camera view stretched on Android

June 30, 2014 - 12:38am #23

Hi, since this seems to be a device-specific problem,

coul you please provide a report with as many details as possible following the schema outlines here:

https://developer.vuforia.com/forum/device-support/how-report-device-issue

(Note: you don't have to provide ALL the information outlined there, but as many as possible as they are applicable to your case).

This will help us have a clear and unambiguous determination of the issue.

Thanks,

 

 

Camera view stretched on Android

June 30, 2014 - 1:00am #22

Hello,

I'll post the report tonight because I don't have the device here now to read the exact model details.

From other posts I also understood that it may be an error caused by the inevitable cropping/resize of the camera image to adapt it to the screen.

Howewer if, as you say, it may be a device specific issue, and Nexus 7 is a quite common device, would it be possible to know how the cropping/resize works? It' s based on a preloaded list of devices and configurations, or screen width/height and camera width/height are requested and cropping/resize calculated for each device dynamically?

Thanks,

Mattia

 

Camera view stretched on Android

June 30, 2014 - 2:42am #21

First, it is important to establish the exact device model, as there might be a few different flavours of the "Nexus 7" (possibly with slightly different hardware installed); that's one of the reasons why we ask to produce a detailed report following those guidelines.

Second; the camera image "resize/crop" logic is simple:

  • the camera image is normally not stretched (and if it is, this may mean there is a bug or issue somewhere, that's what we need to figure out based on the details that you will provide for your case)
  • the camera image is scaled to fit into the screen;  since, the screen resolution is usually differerent from the camera resolution, and in particular, the Aspect Ratio (width/height) of the Camera image is different from the Asepct Ratio of the screen, the "fit" scaling will make sure that the camera image is filling the screen in one dimension (for example, in Width) while "exceeding" the screen in the other dimension (which means that part of the camera image is actually drawn "outside" the screen bounds.... and this is precisely done with the prupose of avoiding the strecthing effect).

So, looking forward to receiving your detailed report.

 

 

Camera view stretched on Android

June 30, 2014 - 8:10am #20

i tried my app on a samsung  Nexus 7 and same here - app is squashed in landscape and stretech in portrait. Which totally messes the tracking. - Seems to be linked to the version of unity, as an older version of the app made with older version of unity did not  have the same issue on that machine..

 

Camera view stretched on Android

June 30, 2014 - 11:09am #19

Here's my report:

  •  
  • Description of the issue,

On screen camera image is stretched, thinner in portrait, fatter in landscape mode

AR detection is then faulty, because the target appears in the wrong perspective

Can be reproduced with the imageTarget sample, tested with 3.0.7

  • Exact Device Model number

Nexus 7
Android 4.4.4
Kernel 3.4.0-g03485a6
Build number KTU84P

These are all the information that appears in the tablet information menu

  • Installed OS version

Android 4.4.4, stock

  • Vuforia SDK version 

3.0.6

  • Platform

Unity 4.5.0

imageTarget sample, unmodified

 

  • are you aware of other software potentially accessing your device camera while Vuforia is running ?

no

  • Occurence vs. Internet connection:
    • can the issue be reproduced on a first run after disabling Internet connection, uninstalling the App and reinstalling it again (with Internet connectivity OFF) ? 
    • can the issue be reproduced on a second run after re-enabling Internet connectivity and running the app again ?

yes, followed the disinstallation unistallation reinstallation procedure, problem persists

 

 

 

Camera view stretched on Android

June 30, 2014 - 11:44am #18

mee to

same android, nexus, unity, vuforia

Camera view stretched on Android

June 30, 2014 - 11:49am #17

Thanks mdurli for the detailed report.

We are going to look at this issue; in the meantime, could you also make this test:

download the pre-built Android native APK from here:

https://developer.vuforia.com/resources/sample-apps/features

 (See the "Download APK" button under "Try on your Android device");  if you install it on the Nexus 7, does it also look stretched?

asking because that APK is built with the native SDK, not using Unity, and this might make a difference.

 

Camera view stretched on Android

June 30, 2014 - 3:38pm #16

Downloaded and tried the Android APK, exactly the same behaviour

 

thanks

Camera view stretched on Android

July 1, 2014 - 12:56am #15

Update:

we have reproduce this issue, which appears to be specific to this device-OS combination <Nexus 7 wiht Android 4.4.4> specifically when using the 720p camera resolution.

The same device on previous Android versions does not show this issue.

Our preliminary analysis suggests that Vuforia is correctly handling the camera image (as we extracted and analyzed the camera frames), which suggets that there might be an issue with the native Camera preview on this specific device (Nexus 7) with this specific OS (Android 4.4.4), at that specific camera resolution (720p)...   apparently not caused by Vuforia.

 

A temporary workaround is to use the camera mode "MODE_OPTMIZE_SPEED", which uses a slightly lower resolution of the camera preview frames, and as such it is unaffected by this issue; you can set the camera mode in Unity by opening the ARCamera inspector, and select that mode from the Drop-Down menu in the QCARBehaviour component.

 

In the meantime, we will keep investigating this issue. If there are any udpates I will post them here.

 

 

Camera view stretched on Android

July 1, 2014 - 2:04pm #14

Update:

I got confirmation from our engineering team that that the camera image at 720p is distorted at the source (i.e. the camera preview image as extracted from the device camera, i.e. prior to any processing done by Vuforia).

This stretching was introduced in the 4.4.3 Nexus 7 update last month, it’s been widely reported for the FRONT camera due to the fact that it breaks the face unlock feature for the tablet.
See the bug report here:
Some google searching for nexus 7 4.4.3 camera distortion will find a few more posts on the subject
 

As mentioned in my previous post, the issue so far is only observed on Nexus 7 with Android version 4.4.x , at the specific camera resolution of 720p only.

There are no further updates on the issue at present.

In the meantime, the correct camera view rendering in Vuforia can be obtained by selecting the camera mode MODE_OPTMIZE_SPEED.

 

 

Camera view stretched on Android

July 23, 2014 - 12:14am #13

UPDATE:

could you all  verify whether the issue is still occurring or not,  by:

- downloading and installing the latest Vuforia SDK 3.0.9 (released yesterday)

- uninstall any previous Vufori samples from your Nexus device

- make sure your internet connection is ON 

- build and run one of the Vuforia sample

 

Camera view stretched on Android

July 23, 2014 - 2:39am #12

I'll be able to test it in the next hours.

May I ask why the internet connection must be on? Does it send or retrieve information from your servers?

How does it affects the app experience for the users who doesn't have internet connection on?

thanks,

mattia

Camera view stretched on Android

July 23, 2014 - 9:19am #11

May I ask why the internet connection must be on? Does it send or retrieve information from your servers?

How does it affects the app experience for the users who doesn't have internet connection on?

In general:

Computer Vision applications need the most up to date camera and display settings to work optimally. As we profile devices, we put this data up on our servers for the SDK to download at runtime and use. For users without an internet connection, the SDK will attempt to use default parameters which in most cases are good enough to start and when the SDK (always on the first ever run of the app and then occasionally) checks with the server and finds updated settings for that particular device, it will download and use them. I want to stress that even without the internet connection, your app will run fine and the end user experience is not impacted

Specifically for the Nexus 7 issue:

this issue has been introduced in Nexus 7 with Android 4.4.3; since this is not an issue caused by Vuforia (we have verified the source camera image is actually stretched when using HD 720p resolution), the image aspect ratio must be corrected by selecting a different resolution with the approach above (server connection).

However, if you are concerned about potential end users that may not be using Internet connection, the easiest solution is to select the camera mode MODE_OPTIMIZE_SPEED, which in this case will have the same effect of preserving the good aspect ratio.

 

Camera view stretched on Android

July 29, 2014 - 7:16am #10

Hello,

sorry for the delay but I've been able to test on the nexus 7 only now.

Unfortunately the problem, using optimize for QUALITY persists.

Image ratio is ok if optimizing for SPEED.

Thanks,
Mattia

 

Camera view stretched on Android

July 29, 2014 - 7:51am #9

I always made the tests with the rear camera (the hi res one on the back).

Now for the first time I'm making one with the front camera, and image is distorted here too (I compared with the standard Camera app).

Unfortunately the behaviour is the same in both camera QUALITY and SPEED settings.

So, rear camera: ok with SPEED, distorted with QUALITY, front camera: distorted with QUALITY and SPEED

Thanks,

Mattia

Camera view stretched on Android

July 29, 2014 - 1:01pm #8

Thanks for the feedback.

Could you confirm that you have:

- uninstalled the original App from the device

- reinstalled the App (using 3.0.9)

- enabled Internet ?

- re-run the App more than once (note: on the first run, the distortion will still be there, but theoretically it should disappear on subsequent runs)

?

 

Camera view stretched on Android

July 29, 2014 - 3:42pm #7

Hello,

I confirm everything, and yes, at last setting MODE_OPTIMIZE_QUALITY doesn't distort (I had to test it many times though, before it actually started to work right).

Another few questions:

1) now both MODE_OPTIMIZE_QUALITY or MODE_OPTIMIZE_SPEED (set on Inspector, recompiling and reinstalling) work (no distortion), but I really can't tell the difference... is it ok? in both cases quality seems to be the same as the preview of the Camera app

2) I tried to switch at runtime to see the difference, with this code (in Inspector is set to QUALITY):

if (GUI.Button(new Rect(11049010050), "Speed"))
		{

			CameraDevice.Instance.Stop();
			CameraDevice.Instance.Deinit();
			CameraDevice.Instance.Init(cameraDirection);
            bool modeSet = CameraDevice.Instance.SelectVideoMode(CameraDevice.CameraDeviceMode.MODE_OPTIMIZE_SPEED);
            DebugConsole.Log("modeSet " + modeSet);                        
			CameraDevice.Instance.Start();
		}

It returns true, it turns off and on the camera, but quality seems remained the same, and if I run:

qCARBehaviour = GetComponent<QCARBehaviour>();

DebugConsole.Log("getCameraDeviceMode: " + qCARBehaviour.CameraDeviceMode);      

it returns MODE_OPTIMIZE_QUALITY, so SelectVideoMode seems to have no effect.
Am I doing something wrong in my code

3) image from FRONT camera is still distorted, with Camera app is not

Thanks for the support!

Mattia

 

 

 

Camera view stretched on Android

July 30, 2014 - 12:29am #6

1) now both MODE_OPTIMIZE_QUALITY or MODE_OPTIMIZE_SPEED (set on Inspector, recompiling and reinstalling) work (no distortion), but I really can't tell the difference... is it ok?

Yes, that's normal, as indeed the problem is corrected by not using the 720p HD resolution (see my previous message with details)

2) ........it returns MODE_OPTIMIZE_QUALITY, so SelectVideoMode seems to have no effect. Am I doing something wrong in my code

Your code looks correct; I believe here the SelectVideoMode is actually correctly setting the desired mode, however  QCARBehaviour does not seem to report back the correct value when querying it (so, it could be a bug in the reporting getter function, I'll look into it). 

3) image from FRONT camera is still distorted, with Camera app is not

OK, chances are that the issue was fixed for the rear camera only. I'll report this to the team and get back to you as soon as I have updates..

 

 

Camera view stretched on Android

July 30, 2014 - 12:39am #5

Can you also confirm in which modes the FRONT camera appears stretched ?

(SPEED, QUALITY, DEFAULT) ?

Camera view stretched on Android

July 30, 2014 - 12:43am #4

Yes ,setting quality in Inspector to SPEED, QUALITY, or NORMAL has no effect with the front camera, the image appears always distorted.

thanks

Camera view stretched on Android

July 30, 2014 - 8:31am #3

Thanks for confirming. 

I just got confirmation from the team that the Front camera issue is a different one;

in fact, in this case even if running on a 640x480 resolution, the Front camera will still appear stretched, due to another bug/issue in the N7 on Android 4.4.3+;

the issue is reported here:

https://code.google.com/p/android/issues/detail?id=70830

You may want to follow that thread to see if Google will fix this at some point.

 

 

Camera view stretched on Android

February 10, 2019 - 10:15pm #2

Im facing the same issue with Galaxy J7 pro with Android 8.0 version. Back  CameraPreview stretching images

Camera view stretched on Android

February 13, 2019 - 10:54am #1
Log in or register to post comments