public override void ViewDidLoad() { base.ViewDidLoad(); RootElement root = Root; root.UnevenRows = true; UIImageView imageView = new UIImageView(View.Frame); StringElement messageElement = new StringElement(""); StringElement licenseElement = new StringElement(""); root.Add(new Section() { new StyledStringElement("Process", delegate { using (Image<Bgr, Byte> image = new Image<Bgr, byte>( "license-plate.jpg")) { LicensePlateDetector detector = new LicensePlateDetector("."); Stopwatch watch = Stopwatch.StartNew(); // time the detection process List<IInputOutputArray> licensePlateImagesList = new List<IInputOutputArray>(); List<IInputOutputArray> filteredLicensePlateImagesList = new List<IInputOutputArray>(); List<RotatedRect> licenseBoxList = new List<RotatedRect>(); List<string> words = detector.DetectLicensePlate( image, licensePlateImagesList, filteredLicensePlateImagesList, licenseBoxList); watch.Stop(); //stop the timer messageElement.Value = String.Format("{0} milli-seconds", watch.Elapsed.TotalMilliseconds); StringBuilder builder = new StringBuilder(); foreach (String w in words) builder.AppendFormat("{0} ", w); licenseElement.Value = builder.ToString(); messageElement.GetImmediateRootElement().Reload(messageElement, UITableViewRowAnimation.Automatic); licenseElement.GetImmediateRootElement().Reload(licenseElement, UITableViewRowAnimation.Automatic); foreach (RotatedRect box in licenseBoxList) { image.Draw(box, new Bgr(Color.Red), 2); } Size frameSize = FrameSize; using (Mat resized = new Mat()) { CvInvoke.ResizeForFrame(image, resized, frameSize); imageView.Image = resized.ToUIImage(); imageView.Frame = new RectangleF(PointF.Empty, resized.Size); } imageView.SetNeedsDisplay(); ReloadData(); } } )}); root.Add(new Section("Recognition Time") { messageElement }); root.Add(new Section("License Plate") { licenseElement }); root.Add(new Section() { imageView }); }
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions) { Console.WriteLine ("[AppDelegate] FinishedLaunching"); UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval (UIApplication.BackgroundFetchIntervalMinimum); Window = new UIWindow (UIScreen.MainScreen.Bounds); _downloader = new Downloader (); _downloader.Finished = FinishedDownload; _downloads = new Section ("Downloads") { }; string templateurl = "http://pokeprice.local/api/v1/card/image/BLW/{0}"; string zipurl = "http://pokeprice.local/api/v1/card/zip/{0}"; string httpurl = "http://pokeprice.local/api/v1/http/{0}"; string redirecturl = "http://pokeprice.local/api/v1/http/redirect/infinite/0"; string scollections = "AOR,AQ,AR,B2,BCR,BEST,BKT,BLW,BS,CG,CL,DCR,DEX,DF,DP,DR,DRV,DRX,DS,DX,EM,EPO,EX,FFI,FLF,FO,G1,G2,GE,HL,HP,HS,JU,KSS,LA,LC,LM,LTR,MA,MCD2011,MCD2012,MD,MT,N1,N2,N3,N4,NINTENDOBLACK,NVI,NXD,PHF,PK,PL,PLB,PLF,PLS,POP1,POP2,POP3,POP4,POP5,POP6,POP7,POP8,POP9,PR-BLW,PR-DP,PR-HS,PR-XY,PRC,RG,ROS,RR,RS,RU,SF,SI,SK,SS,SV,SW,TM,TR,TRR,UD,UF,UL,VICTORY,WIZARDSBLACK,XY"; string[] collections = scollections.Split (','); #if REMOTE templateurl = templateurl.Replace("http://pokeprice.local", "https://pokeprice.com"); zipurl = zipurl.Replace("http://pokeprice.local", "https://pokeprice.com"); httpurl = httpurl.Replace("http://pokeprice.local", "https://pokeprice.com"); redirecturl = redirecturl.Replace("http://pokeprice.local", "https://pokeprice.com"); #endif var enable = new BooleanElement ("Enabled", true); enable.ValueChanged += (sender, e) => { _downloader.Enabled = enable.Value; }; var globalprogress = new StringElement (""); var root = new RootElement ("Root") { new Section ("Management"){ enable, globalprogress }, _downloads }; _downloader.Progress += (progress) => { float percent = (progress.Written / (float)progress.Total) * 100; int ipercent = (int)percent; string caption = string.Format("{0} {1} {2}% ({3} / {4})", "Global", progress.State.ToString(), ipercent, progress.Written, progress.Total ); InvokeOnMainThread(() => { globalprogress.Caption = caption; globalprogress .GetImmediateRootElement() .Reload(globalprogress, UITableViewRowAnimation.Automatic); }); }; _sample = new DialogViewController (root); var add = new UIBarButtonItem ("Add", UIBarButtonItemStyle.Bordered, (sender, e) => { string url = string.Format(templateurl, 1); Add(url); }); var addall = new UIBarButtonItem ("All", UIBarButtonItemStyle.Bordered, (sender, e) => { for(int i=1; i<80; i++) { string url = string.Format(templateurl, i); Add(url); } }); var zips = new UIBarButtonItem ("Z", UIBarButtonItemStyle.Bordered, (sender, e) => { foreach(string coll in collections) { string url = string.Format(zipurl, coll); Add(url); } }); var s404 = new UIBarButtonItem ("4", UIBarButtonItemStyle.Bordered, (sender, e) => { string url = string.Format(httpurl, 404); Add(url); }); var s500 = new UIBarButtonItem ("5", UIBarButtonItemStyle.Bordered, (sender, e) => { string url = string.Format(httpurl, 500); Add(url); }); var s301 = new UIBarButtonItem ("3", UIBarButtonItemStyle.Bordered, (sender, e) => { string url = string.Format(httpurl, 301); Add(url); }); var s301p = new UIBarButtonItem ("3+", UIBarButtonItemStyle.Bordered, (sender, e) => { string url = string.Format(redirecturl, 301); Add(url); }); var reset = new UIBarButtonItem ("Reset", UIBarButtonItemStyle.Bordered, async (sender, e) => { await _downloader.Reset(); Sync(); }); var sync = new UIBarButtonItem ("S", UIBarButtonItemStyle.Bordered, (sender, e) => { Sync(); }); Navigation = new UINavigationController (); Window.RootViewController = Navigation; Window.MakeKeyAndVisible (); Navigation.PushViewController (_sample, false); _sample.SetToolbarItems (new [] { add, addall, zips, s404, s500, s301, s301p, reset, sync}, true); Navigation.SetToolbarHidden (false, true); return true; }