By joshsavage
on Tue, 02/05/2013 - 09:58
I'm having an issue on Android devices getting image data after reloading the unity scene with the latest Unity Vuforia 2.0 extension.
When the scene is first loaded the RGB image data is correct however as soon as the app is put into the background and re-run, or if another scene is loaded and then the AR Camera scene is loaded again, the RGB data isn't correct.
I am getting the camera image using :
image = CameraDevice.Instance.GetCameraImage(Image.PIXEL_FORMAT.RGB888);
This doesn't return null and according to isValid method is valid, pixel sizes are fine, and PixelFormat still returns RGB888. However, when I check the RGB pixel colours they are not correct after the scene is reloaded.
Getting Camera Image after scene is reloaded
Updating with article here:
https://developer.vuforia.com/forum/faq/unity-how-can-i-reset-frame-format-scene-reload
Getting Camera Image after scene is reloaded
I just checked iOS and it seems to be an issue as well.
Getting Camera Image after scene is reloaded
Hi, to help reproduce your issue, could you tell where do you use that code ? is it called from the Update() function of your own script ? is the script attached to the ARCamera ?
(so that I can setup a project as similar as possible to yours...)
Getting Camera Image after scene is reloaded
Thank you for your quick response.
It is called from the Update() function of my own script that is attached to a seperate game object. The game object is not inside the AR Camera.
Getting Camera Image after scene is reloaded
Hi, so, here is what I have tried:
Getting Camera Image after scene is reloaded
I'm still having the issue. After the home button is pressed or the scene is switched the pixel values do not update. They seem frozen on the last frame before the scene change. I slightly modified your script so you will be able to more easily see what I'm talking about (see below).
Getting Camera Image after scene is reloaded
Hi, I see what you say;
indeed, I can confirm that the pixel buffer appears to be "stuck" on the same values after switching level;
I am bringing this up to the Vuforia team's attention, I will update you on the progress (also checking for some workarounds).
Getting Camera Image after scene is reloaded
Hey, quick update:
I managed to find a simple workaround for that, which consists of resetting the frame format in teh Start() method of the script:
Getting Camera Image after scene is reloaded
Thanks a lot for the work around!
I tested it and it works well for when the scene is reloaded but the "Start" method isn't called when the app comes back to the foreground after say the home button is pressed.
Here is the solution that worked for me:
Getting Camera Image after scene is reloaded
Great!
Getting Camera Image after scene is reloaded
I was switching between front and back cameras but wouldn't get the new camera's pixel data. It would still give the previous camera's last frame. Adding this line before setting frame format again, fixed it.