示例#1
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AssetManager assets      = Activity.Assets;
            var          filesToCopy = new string[] { "runtime_data/openalpr.conf"
                                                      , "runtime_data/region/eu.xml" };

            var AndroidDataDir       = Android.App.Application.Context.DataDir.AbsolutePath;
            var runtimeFolder        = new Java.IO.File(AndroidDataDir, "/files/runtime_data");
            var renamedRuntimeFolder = new Java.IO.File(AndroidDataDir, "runtime_data");

            runtimeFolder.RenameTo(renamedRuntimeFolder);

            var list = renamedRuntimeFolder.List();

            OpenALPRConfigFile = AndroidDataDir + "/runtime_data/openalpr.conf";

            var f       = new Java.IO.File(AndroidDataDir);
            var flist   = f.List();
            var lib     = new Java.IO.File(f, "lib");
            var liblist = lib.List();

            mStateCallback          = new CameraStateListener(this);
            mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);
            OpenALPRInstance        = new OpenALPR(this.Activity, AndroidDataDir, OpenALPRConfigFile, "eu", "ua");

            // fill ORIENTATIONS list
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);
        }
        public ActionResult ProcessImageBytes()
        {
            try
            {
                var picture     = Request.Body;
                var pictureSize = (int)Request.ContentLength;

                if (picture != null || picture.Length > 0)
                {
                    using (MemoryStream targetStream = new MemoryStream())
                    {
                        Stream sourceStream = picture;

                        byte[] buffer = new byte[pictureSize + 1];
                        int    read   = 0;

                        while ((read = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            targetStream.Write(buffer, 0, read);
                        }

                        Task <string> recognizeTask = Task.Run(() => OpenALPR.ProcessImage(buffer));
                        recognizeTask.Wait();

                        var response = JsonConvert.DeserializeObject <OpenALPRResponse>(recognizeTask.Result);

                        if (!response.error_code.Equals("400"))
                        {
                            response.error = "kk";
                        }

                        using (var recordFlowDAO = new FlowRecordDAO())
                            recordFlowDAO.Register("XUMBADO ATENÇÃO", null);

                        // Printa resultado
                        //SystemNotifier.SendNotificationAsync(response);
                    }

                    return(StatusCode(200));
                }

                return(StatusCode(406));
            }

            catch (Exception ex)
            {
                return(StatusCode(500));
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            AndroidDataDir        = ApplicationInfo.DataDir;
            OpenALPRConfigFile    = AndroidDataDir + "/runtime_data/openalpr.conf";
            OpenALPRRuntimeFolder = AndroidDataDir + "/runtime_data";
            TestImagePath         = AndroidDataDir + "/runtime_data/image.jpg";

            OpenALPRInstance = new OpenALPR(this, AndroidDataDir, OpenALPRConfigFile, "eu");

            Button recognizeButton = FindViewById <Button>(Resource.Id.recognizeButton);

            recognizeButton.Click += RecognizeButton_Click;
        }
 public OpenAlprScanner(string dataDirPath, string openAlprConfigFilePath, string country = "eu", string region = "")
 {
     _openALPRInstance = new OpenALPR(MainActivity.Instance, dataDirPath, openAlprConfigFilePath, country, region);
 }