public JObject Post(string guid, [FromBody] JObject value) { JObject ret = new JObject(); try { __Prekrsaj p = value.ToObject <__Prekrsaj>(); List <string> slike64 = p.Slike; // value["Slike"].ToObject<List<string>>(); List <byte[]> slike = new List <byte[]>(); if (slike64 != null) { foreach (var s in slike64) { try { slike.Add(Convert.FromBase64String(s)); } catch { } } } var ispis = MethodsPrometno.SpremiPrekrsaj(guid, p, slike, out int idLokacije); ret.Add("Ispis", ispis); ret.Add("IDLokacije", idLokacije); } catch (Exception ex) { MethodsPrometno.SpremiGresku(guid, ex, "SPREMI PREKRSAJ CONTROLLER"); } return(ret); }
JObject Recognize(string pic64, bool prepoznajVozilo, bool koordinateTablice) { var ret = new JObject(); try { var drzave = MethodsPrometno.Drzave(); string secretKey = "sk_b1572dbc0c19945677074b5e"; //Client openALPRClient = new Client(); //Response x = await openALPRClient.RecognizeBytesAsync(value, secretKey, Recognize_vehicle._1, "eu", null, Return_image._0, 10, null); JObject vozilo; Rectangle plateRect = new Rectangle(); var lprs = PG.Servisi.RESTApi.OpenALRPApi.Recognize(pic64, prepoznajVozilo, ref plateRect, out vozilo); //var lprs = Methods.LPR(value); if (!string.IsNullOrEmpty(lprs.Item1)) { String drz = ""; if (!string.IsNullOrEmpty(lprs.Item2)) { string dd = lprs.Item2; if (lprs.Item2.Trim().Length > 2) { dd = lprs.Item2.Substring(lprs.Item2.Length - 2).ToUpper(); } foreach (var d in drzave) { if (d.ISOKratica == dd) { drz = d.Kratica; } } } ret = AnalyzeLPR(lprs.Item1, drz); if (vozilo != null && vozilo.Count > 0) { ret.Add(new JProperty("vozilo", vozilo)); } if (koordinateTablice && !plateRect.IsEmpty) { JObject tablica = new JObject(); tablica.Add("x", plateRect.X); tablica.Add("y", plateRect.Y); tablica.Add("width", plateRect.Width); tablica.Add("height", plateRect.Height); ret.Add(new JProperty("tablica", tablica)); } } } catch (Exception ex) { MethodsPrometno.SpremiGresku("", ex, "LPR CONTROLLER"); throw ex; } return(ret); }
public IEnumerable <_Drzava> Get() { var ret = new List <_Drzava>(); var l = MethodsPrometno.Drzave(); foreach (var d in l) { ret.Add(d); } return(ret); }
public string Get(string kratica) { string ret = null; var l = MethodsPrometno.Drzave(); foreach (var d in l) { if (d.Kratica.ToUpper() == kratica.ToString().ToUpper()) { ret = d.Drzava; break; } } return(ret); }
public int Put(string guid, int idLokacije, [FromBody]List<string> value) { int i = 0; List<byte[]> slike = new List<byte[]>(); foreach (var s in value) { try { slike.Add(Convert.FromBase64String(s)); i++; } catch { } } if (i == 0) return 0; else return MethodsPrometno.DodajSliku(guid, idLokacije, slike); }
public Authorization Post([FromBody] Prijava value) { Authorization ret = null; bool blokiranaJLS; try { MD5 md5 = new MD5CryptoServiceProvider(); byte[] originalBytes = Encoding.Default.GetBytes(value.Password); byte[] encodedBytes = md5.ComputeHash(originalBytes); var d = MethodsPrometno.Prijava(value.City_ID, value.UID, BitConverter.ToString(encodedBytes), out blokiranaJLS); if (d != null) { ret = new Authorization(); ret.Djelatnik = d; ret.Date = DateTime.Now.Date; ret.GUID = Guid.NewGuid().ToString(); ret.City = MethodsPrometno.Grad(value.City_ID); if (!string.IsNullOrEmpty(value.DeviceID)) { var t = MethodsPrometno.GetTerminal(ret.City.Baza, value.DeviceID, value.DeviceName); ret.TerminalName = t.Naziv; ret.TerminalID = t.IDTerminala; if (!string.IsNullOrEmpty(value.ProgramVersion)) { MethodsPrometno.UpdateVerzija(ret.City.Baza, value.DeviceID, value.ProgramVersion, value.OSVersion); } } } } catch (Exception ex) { string city = "", uid = ""; if (value != null) { city = value.City_ID; uid = value.UID; } MethodsPrometno.SpremiGresku(city, ex, "Prijava - " + uid); } return(ret); }
public JArray Get(string grad, int id) { JArray ret = new JArray(); var ps = MethodsPrometno.Printeri(grad, id); var ms = MethodsPrometno.Modeli(); var q = from p in ps join m in ms on p.IDModela equals m.Value select JObject.FromObject(new { IDPrintera = p.IDPrintera, Naziv = p.Naziv, MAC = p.MAC, PIN = p.PIN, InterniBroj = p.InterniBroj, Model = m.Text }); foreach (var r in q) { ret.Add(r); } //foreach(var r in q) //{ // JObject printer = new JObject(); // printer.Add(new JProperty("IDPrintera", r.IDPrintera)); // printer.Add(new JProperty("Naziv", r.Naziv)); // printer.Add(new JProperty("InterniBroj", r.InterniBroj)); // printer.Add(new JProperty("MAC", r.MAC)); // printer.Add(new JProperty("Model", r.Model)); // ret.Add(printer); //} return(ret); }
JObject AnalyzeLPR(string reg, string drz) { var ret = new JObject(); try { if (!string.IsNullOrEmpty(reg)) { if (drz == null) { drz = ""; } PlateDefinition.CountryResultSet[] res = PlateDefinition.SearchResults(reg); foreach (var r in res) { if (r.Country.ToUpper() == drz.ToUpper()) { ret.Add(CountryPlates(r)); } } foreach (var r in res) { if (r.Country.ToUpper() != drz.ToUpper()) { ret.Add(CountryPlates(r)); } } } } catch (Exception ex) { MethodsPrometno.SpremiGresku("", ex, "LPR CONTROLLER"); throw ex; } return(ret); }
public int Post(string guid, [FromBody] JObject value) { _Lokacija lok = value.ToObject <_Lokacija>(); return(MethodsPrometno.SpremiLokaciju(guid, lok)); }
public __Prekrsaj[] Get(string guid, int id, int filter, int index, int pagesize) { return(MethodsPrometno.DohvatiPrekrsaje(guid, null, filter, id, index, pagesize)); }
public _Prekrsaj Get(string guid, int idLokacije) { return(MethodsPrometno.DohvatiPrekrsaj(guid, idLokacije)); }
public Object Get(string guid, double lat, double lon) { return(MethodsPrometno.PopisUlica(guid, lat, lon).ToArray()); }
public string Post(string guid, int idLokacije, int tipPrintera) { return(MethodsPrometno.KopijaDokumenta(guid, idLokacije, tipPrintera)); }
public _Grad Get(string aktivacijskiKod) { return(MethodsPrometno.Aktivacija(aktivacijskiKod)); }
public static Tuple <string, string> Recognize(string base64Image, bool prepoznajVozilo, ref Rectangle plateRect, out JObject vozilo) { String reg = "", drz = ""; var apiInstance = new DefaultApi("https://api.openalpr.com/v2"); //new DefaultApi(); //var imageBytes = base64image; // string | The image file that you wish to analyze encoded in base64 var secretKey = "sk_b1572dbc0c19945677074b5e"; // string | The secret key used to authenticate your account. You can view your secret key by visiting https://cloud.openalpr.com/ var country = "eu"; // string | Defines the training data used by OpenALPR. \"us\" analyzes North-American style plates. \"eu\" analyzes European-style plates. This field is required if using the \"plate\" task You may use multiple datasets by using commas between the country codes. For example, 'au,auwide' would analyze using both the Australian plate styles. A full list of supported country codes can be found here https://github.com/openalpr/openalpr/tree/master/runtime_data/config var recognizeVehicle = (prepoznajVozilo)? 1:0; // int? | If set to 1, the vehicle will also be recognized in the image This requires an additional credit per request (optional) (default to 0) string state = null; // string | Corresponds to a US state or EU country code used by OpenALPR pattern recognition. For example, using \"md\" matches US plates against the Maryland plate patterns. Using \"fr\" matches European plates against the French plate patterns. (optional) (default to ) var returnImage = 0; // int? | If set to 1, the image you uploaded will be encoded in base64 and sent back along with the response (optional) (default to 0) var topn = 12; // int? | The number of results you would like to be returned for plate candidates and vehicle classifications (optional) (default to 10) string prewarp = null; // string | Prewarp configuration is used to calibrate the analyses for the angle of a particular camera. More information is available here http://doc.openalpr.com/accuracy_improvements.html#calibration (optional) (default to ) vozilo = new JObject(); byte[] mbmp = Convert.FromBase64String(base64Image); try { InlineResponse200 result = apiInstance.RecognizeFile(new MemoryStream(mbmp), secretKey, country, recognizeVehicle, state, returnImage, topn, prewarp); if (result != null && result.Results.Count > 0) { reg = result.Results[0].Plate; drz = result.Results[0].Region; if (result.Results[0].Vehicle != null) { vozilo.Add(new JProperty("marka", result.Results[0].Vehicle.Make[0].Name)); vozilo.Add(new JProperty("boja", result.Results[0].Vehicle.Color[0].Name)); } if (plateRect != null) { var coord = result.Results[0].Coordinates; try { int left = -1, top = -1, right = -1, bottom = -1; foreach (Coordinate c in coord) { if (left < 0 || left > c.X) { left = (int)c.X; } if (right < 0 || right < c.X) { right = (int)c.X; } if (top < 0 || top > c.Y) { top = (int)c.Y; } if (bottom < 0 || bottom < c.Y) { bottom = (int)c.Y; } } if (left >= 0 && right >= 0 && top >= 0 && bottom >= 0) { plateRect.X = left; plateRect.Y = top; plateRect.Width = right - left; plateRect.Height = bottom - top; } //if (coord.Count == 4) //{ // int x = Math.Min((int)coord[0].X, (int)coord[3].X); // int y = Math.Min((int)coord[0].Y, (int)coord[1].Y); // int w = Math.Max((int)coord[1].X, (int)coord[2].X) - x; // int h = Math.Max((int)coord[2].Y, (int)coord[3].Y) - y; // plateRect.X = x; // plateRect.Y = y; // plateRect.Width = w; // plateRect.Height = h; //} }catch (Exception ex) { MethodsPrometno.SpremiGresku("", ex, "OPENNALPR RECOGNIZE - koordinate tablice..."); } } } Debug.WriteLine(result); } catch (Exception e) { MethodsPrometno.SpremiGresku("", e, "OPENNALPR RECOGNIZE"); } return(new Tuple <string, string>(reg, drz)); }
public IEnumerable <_Zakon> Get(string grad) { //return MethodsPrometno.DohvatiPrekrsaje("PROMETNIK_RIJEKA", "", 7, 0, 0, 40); return(MethodsPrometno.DohvatiZakone(grad)); }
public JArray Get(string guid, int idLokacije) { return MethodsPrometno.DohvatiSlike(guid, idLokacije); }