#StackBounty: #xamarin.forms #xamarin.android #fullscreen #statusbar After exiting fullscreen in Xamarin Forms Android app, status bar …

Bounty: 50

I have an app that switches between full screen (without a status bar and restricted to landscape orientation) and regular (with status bar and no orientation restriction). I’m using a service dependency to call a method on the MainActivity with a boolean flag. I’ve used two different methods of toggling the full screen setting: setting Window.DecorView.SystemUiVisibility and adding/clearing flags on Window. In the below code the second approach is commented out:

                if (fullScreenOn)
                    Window.DecorView.SystemUiVisibility = (StatusBarVisibility)(
                        | SystemUiFlags.HideNavigation
                        | SystemUiFlags.Immersive
                        | SystemUiFlags.ImmersiveSticky
                        | SystemUiFlags.LowProfile
                        | SystemUiFlags.LayoutStable
                        | SystemUiFlags.LayoutHideNavigation
                        | SystemUiFlags.LayoutFullscreen


                    RequestedOrientation = ScreenOrientation.Landscape;
                    Window.DecorView.SystemUiVisibility = (StatusBarVisibility)(
                        | SystemUiFlags.LayoutHideNavigation
                        | SystemUiFlags.LayoutFullscreen


                    RequestedOrientation = ScreenOrientation.Unspecified;

I have tried calling the dependency method from different places: OnAppearing() and OnDisappearing() in full screen pages, in all pages, just OnAppearing() in all pages, and also (not in the same build) from my navigation code when opening a new page or falling back to an existing one.

The app starts in a normal page and it all works until after viewing one of the full screen pages and returning to a normal page when the status bar comes back, but the page uses the full height of the screen and is overlapped as a result.

There’s a secondary annoyance which is that even when going from one full screen page to another, the status bar pops in and out.

The iOS version of the app doesn’t have either of these problems. Obviously, it uses a different implementation in it’s dependency method.

Edit: I have created a minimal app which reproduces the main problem at https://github.com/aptwebapps/StatusBarBug . Interestingly, it does NOT suffer from the annoyance of the status bar popping in and out when moving between two full screen pages.

Get this bounty!!!

#StackBounty: #android #tensorflow #xamarin #xamarin.android TensorFlow object detection fails on Xamarin Android with a reshape issue

Bounty: 50

I am following this blog post and GitHub almost exactly:



But when I run, take a picture and call this line:

var outputs = new float[tfLabels.Count];
tfInterface.Feed("Placeholder", floatValues, 1, 227, 227, 3);
tfInterface.Run(new[] { "loss" });
tfInterface.Fetch("loss", outputs);

The app actually crashes and generates the error below on the .Run line.

I get this error in the output window (and the app crashes):

04-04 17:39:12.575 E/TensorFlowInferenceInterface( 8017): Failed to
run TensorFlow inference with inputs:[Placeholder], outputs:[loss]
Unhandled Exception:

Java.Lang.IllegalArgumentException: Input to reshape is a tensor with
97556 values, but the requested shape requires a multiple of 90944
[[Node: block0_0_reshape0 = Reshape[T=DT_FLOAT, Tshape=DT_INT32,

According to the posts I am reading from the searching I am doing on this error, I sort of understand this is due to the image not fitting the expected size exactly but in the example I am following, this is resized to fit 227×227 everytime and converted to float like in these lines:

var resizedBitmap = Bitmap.CreateScaledBitmap(bitmap, 227, 227, false).Copy(Bitmap.Config.Argb8888, false);

var floatValues = new float[227 * 227 * 3];
var intValues = new int[227 * 227];

resizedBitmap.GetPixels(intValues, 0, 227, 0, 0, 227, 227);

for(int i = 0; i < intValues.Length; i++)
     var val = intValues[i];
     floatValues[i * 3 + 0] = ((val & 0xFF) - 104);
     floatValues[i * 3 + 1] = (((val >> 8) & 0xFF) - 117);
     floatValues[i * 3 + 2] = (((val >> 16) & 0xFF) - 123);

So, I don’t understand what is causing this or how to fix it. Please help!

UPDATE: I found out the issue is with my model or my labels. I found this out by simply swapping in the model and label file from the sample/github above while leaving all my code the same. When I did this, I no longer get the error. HOWEVER, this still doesn’t tell me much. The error is not very explanatory to point me in a direction of what could be wrong with my model. I assume it is the model because the labels file is simply just a text file with labels on each line. I used Custom Vision Service on Azure to create my model. It trained fine and tests just fine on the web portal. I then exported it as TensorFlow. So, I am not sure what I could have done wrong or how to fix it.


Get this bounty!!!