Beispiel #1
0
        public MasterForm LoadMasterForm(string attributesFileName, string fieldsFileName)
        {
            FormProcessingEngine tempProcessingEngine = new FormProcessingEngine();

            tempProcessingEngine.OcrEngine = OcrEngine;
            //tempProcessingEngine.BarcodeEngine = null;

            MasterForm form = new MasterForm();

            if (File.Exists(attributesFileName))
            {
                byte[] formData = File.ReadAllBytes(attributesFileName);
                form.Attributes.SetData(formData);
                form.Properties = RecognitionEngine.GetFormProperties(form.Attributes);
            }

            if (File.Exists(fieldsFileName))
            {
                tempProcessingEngine.LoadFields(fieldsFileName);
                form.Resolution      = tempProcessingEngine.Pages[0].DpiX;
                form.ProcessingPages = tempProcessingEngine.Pages;
            }

            return(form);
        }
Beispiel #2
0
        public async Task <HttpResponseMessage> ExtractCheck([FromUri] LeadWebRequest request)
        {
            try
            {
                AuthenticateRequest();

                if (!VerifyCommonParameters(request))
                {
                    throw new MalformedRequestException();
                }

                using (var stream = await GetImageStream(request.fileUrl))
                {
                    int lastPage = request.LastPage;
                    ValidateFile(stream, ref lastPage);

                    LoadDocumentOptions options = new LoadDocumentOptions()
                    {
                        FirstPageNumber = request.FirstPage,
                        LastPageNumber  = lastPage
                    };
                    RecognitionEngine recognitionEngine = new RecognitionEngine();
                    recognitionEngine.OcrEngine = ocrEngine;
                    var micrResults = recognitionEngine.ExtractMicr(stream, options, Leadtools.Forms.Commands.BankCheckMicrFontType.Unknown);
                    return(new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StringContent(JsonConvert.SerializeObject(micrResults))
                    });
                }
            }
            catch (Exception e)
            {
                return(GenerateExceptionMessage(e));
            }
        }
Beispiel #3
0
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            //synthEngine.Speak("what is your gender");

reiterateIfStaticCommand:

            string command = recogEngine.GetRecognizedText(synthEngine);

            bool WhetherStaticCommand = StaticCommands.WhetherExecuted(driver, command);

            if (!WhetherStaticCommand)
            {
                switch (command)
                {
                case "male":
                    driver.FindElement(By.ClassName("Gender_iconMale_2uEOT")).Click();
                    WhetherSeniorCitizen.run(recogEngine, synthEngine, driver);
                    break;

                case "female":
                    driver.FindElement(By.ClassName("Gender_iconFemale_yFfRz")).Click();
                    WhetherSeniorCitizen.run(recogEngine, synthEngine, driver);
                    break;

                default:
                    break;
                }
            }
            else
            {
                goto reiterateIfStaticCommand;
            }
        }
        public static void Main(string[] args)
        {
            // Initialize RecognitionEngine
            RecognitionEngine recogEngine = new RecognitionEngine();

            recogEngine.SetupRecognitionEngine();

            // Initialize SpeechSynthesizer
            SpeechSynthesizer synthEngine = new SpeechSynthesizer();

            synthEngine.SetOutputToDefaultAudioDevice();

            // Initialize FirefoxDriver
            string     GeckoDriverPath = @"C:\Users\adity\source\repos\SpeechRecogTest\geckodriver-v0.21.0-win64";
            IWebDriver driver          = new FirefoxDriver(GeckoDriverPath);

            /*
             * string recognizedText = recogEngine.GetRecognizedText(synthEngine);
             * synthEngine.Speak("You have said " + recognizedText + "which I have successfully detected");
             */

            BankBazaar.HomePageClass.run(recogEngine, synthEngine, driver);
            //Youtube.HomePageClass.run(recogEngine, synthEngine, driver);

            driver.Close();
            driver.Quit();
        }
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            //synthEngine.SpeakAsync("choose from compare fixed deposit, get a rate, fixed deposit reviews" +
            //     "hungry for more");

reiterateIfStaticCommand:

            string command = recogEngine.GetRecognizedText(synthEngine);

            bool WhetherStaticCommand = StaticCommands.WhetherExecuted(driver, command);

            if (!WhetherStaticCommand)
            {
                switch (command)
                {
                case "submit my fixed deposit":
                    driver.FindElement(By.ClassName("custom-quote")).Click();
                    Location.run(recogEngine, synthEngine, driver);
                    break;

                default:
                    break;
                }
            }
            else
            {
                goto reiterateIfStaticCommand;
            }
        }
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            //synthEngine.Speak("are you a senior citizen");

reiterateIfStaticCommand:

            string command = recogEngine.GetRecognizedText(synthEngine);

            bool WhetherStaticCommand = StaticCommands.WhetherExecuted(driver, command);

            if (!WhetherStaticCommand)
            {
                switch (command)
                {
                case "yes":
                    driver.FindElement(By.ClassName("YesNo_iconMaleSeniorCitizenYes_1b5Xa")).Click();
                    FreeOffers.run(recogEngine, synthEngine, driver);
                    break;

                case "no":
                    driver.FindElement(By.ClassName("YesNo_iconMaleSeniorCitizenNo_AjA0z")).Click();
                    FreeOffers.run(recogEngine, synthEngine, driver);
                    break;

                default:
                    break;
                }
            }
            else
            {
                goto reiterateIfStaticCommand;
            }
        }
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            //recogEngine.UnSetAllGrammarFiles();
            //recogEngine.SetAnotherGrammarFile("CreditScore.txt");

reiterateIfStaticCommand:

            string command = recogEngine.GetRecognizedText(synthEngine);

            bool WhetherStaticCommand = StaticCommands.WhetherExecuted(driver, command);

            if (!WhetherStaticCommand)
            {
                Console.WriteLine(command);

                /*
                 * switch (command)
                 * {
                 *
                 *  default:
                 *      break;
                 * }
                 */
            }
            else
            {
                goto reiterateIfStaticCommand;
            }
        }
Beispiel #8
0
        public FormRecognitionAttributes CreateForm(FormsRecognitionMethod method)
        {
            FormRecognitionOptions options = new FormRecognitionOptions();

            options.RecognitionMethod = method;
            FormRecognitionAttributes attributes = RecognitionEngine.CreateForm(options);

            RecognitionEngine.CloseForm(attributes);
            return(attributes);
        }
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            string command = null;

            while (command != "terminate program")
            {
                command = recogEngine.GetRecognizedText(synthEngine);
                synthEngine.Speak("You have said " + command);
                Console.WriteLine(command);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Changes the currently used <see cref="ProgrammingLanguage"/> and everything code specific according to the new <see cref="ProgrammingLanguage"/>.
        /// </summary>
        /// <param name="programmingLanguage">
        /// The <see cref="ProgrammingLanguage"/> to be changed to.
        /// </param>
        /// <param name="scheduler">
        /// The <see cref="TaskScheduler"/> containing GUI-context.
        /// </param>
        private static void ChangeProgrammingLanguage(ProgrammingLanguage programmingLanguage, TaskScheduler scheduler)
        {
            if (programmingLanguage == null || scheduler == null)
            {
                throw new ArgumentNullException();
            }

            currentProgrammingLanguage = programmingLanguage;
            cancellationToken.Cancel();
            Task.Factory.StartNew(() => RecognitionEngine.UpdateCodeAsync(currentProgrammingLanguage), CancellationToken.None, TaskCreationOptions.None, scheduler);
            LocalizeMistakes();
            StartPerformanceIntensiveCodeAlteredTasksAsync(TaskScheduler.FromCurrentSynchronizationContext());
            cancellationToken = new CancellationTokenSource();
        }
Beispiel #11
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "Recognition/ExtractCheck")] HttpRequestMessage req, TraceWriter log, ExecutionContext context)
        {
            try
            {
                if (!DemoConfiguration.UnlockSupport(log))
                {
                    return(GenerateErrorMessage(ApiError.LicenseNotSet, req));
                }

                var leadParameterObject = ParseLeadWebRequestParameters(req);
                if (!leadParameterObject.Successful)
                {
                    return(GenerateErrorMessage(ApiError.InvalidRequest, req));
                }

                var imageReturn = await GetImageStreamAsync(leadParameterObject.LeadWebRequest.fileUrl, req, DemoConfiguration.MaxUrlMbs);

                if (!imageReturn.Successful)
                {
                    return(GenerateErrorMessage(imageReturn.ErrorType.Value, req));
                }

                using (imageReturn.Stream)
                {
                    LoadDocumentOptions options = new LoadDocumentOptions()
                    {
                        FirstPageNumber = leadParameterObject.LeadWebRequest.FirstPage,
                        LastPageNumber  = leadParameterObject.LeadWebRequest.LastPage
                    };

                    RecognitionEngine recognitionEngine = new RecognitionEngine
                    {
                        WorkingDirectory = Path.GetTempPath(),
                        OcrEngine        = GetOcrEngine()
                    };

                    var micrResults   = recognitionEngine.ExtractMicr(imageReturn.Stream, options, BankCheckMicrFontType.Unknown);
                    var returnRequest = req.CreateResponse(HttpStatusCode.OK);
                    returnRequest.Content = new StringContent(JsonConvert.SerializeObject(micrResults));
                    return(returnRequest);
                }
            }
            catch (Exception ex)
            {
                log.Error($"API Error occurred for request: {context.InvocationId} \n Details: {JsonConvert.SerializeObject(ex)}");
                return(GenerateErrorMessage(ApiError.InternalServerError, req));
            }
        }
Beispiel #12
0
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            //synthEngine.Speak("which company do you work for");

reiterateIfStaticCommand:

            string command = recogEngine.GetRecognizedText(synthEngine);

            bool WhetherStaticCommand = StaticCommands.WhetherExecuted(driver, command);

            if (!WhetherStaticCommand)
            {
                switch (command)
                {
                case "microsoft":
                    driver.FindElement(By.ClassName("react-autosuggest__input")).SendKeys("microsoft");
                    driver.FindElement(By.ClassName("btn-large")).Click();
                    Salary.run(recogEngine, synthEngine, driver);
                    break;

                case "google":
                    driver.FindElement(By.ClassName("react-autosuggest__input")).SendKeys("google");
                    driver.FindElement(By.ClassName("btn-large")).Click();
                    Salary.run(recogEngine, synthEngine, driver);
                    break;

                case "facebook":
                    driver.FindElement(By.ClassName("react-autosuggest__input")).SendKeys("facebook");
                    driver.FindElement(By.ClassName("btn-large")).Click();
                    Salary.run(recogEngine, synthEngine, driver);
                    break;

                case "twitter":
                    driver.FindElement(By.ClassName("react-autosuggest__input")).SendKeys("twitter");
                    driver.FindElement(By.ClassName("btn-large")).Click();
                    Salary.run(recogEngine, synthEngine, driver);
                    break;

                default:
                    break;
                }
            }
            else
            {
                goto reiterateIfStaticCommand;
            }
        }
Beispiel #13
0
        public void AlignForm(FilledForm form, bool calculateAlignment)
        {
            if (calculateAlignment)
            {
                CreateFormForRecognition(form, FormsRecognitionMethod.Complex);

                form.Alignment = RecognitionEngine.GetFormAlignment(form.Master.Attributes, form.Attributes, null);
            }
            else
            {
                form.Alignment = new List <PageAlignment>();
                for (int i = 0; i < form.Result.PageResults.Count; i++)
                {
                    form.Alignment.Add(form.Result.PageResults[i].Alignment);
                }
            }
        }
Beispiel #14
0
        public static void Main(string[] args)
        {
            // Initialize RecognitionEngine
            RecognitionEngine recogEngine = new RecognitionEngine();

            recogEngine.SetupRecognitionEngine();
            recogEngine.SetGrammarFile("Numbers.txt");

            // Initialize SpeechSynthesizer
            SpeechSynthesizer synthEngine = new SpeechSynthesizer();

            synthEngine.SetOutputToDefaultAudioDevice();

            string command = recogEngine.GetRecognizedText(synthEngine);

            Console.WriteLine(command);
        }
Beispiel #15
0
        public void get_recog()
        {
            System.IO.FileStream ostrm = new FileStream(curr_dir + @"\recognize.log", FileMode.OpenOrCreate, FileAccess.Write);
            string image_path          = curr_dir + @"\recog.jpg";
            string config_path         = curr_dir + @"\smartid.json";
            string document_types      = "rus.passport.*";

            StreamWriter writer;
            TextWriter   oldOut = Console.Out;

            writer = new StreamWriter(ostrm);
            Console.SetOut(writer);

            Console.WriteLine("Start recognize application");
            Console.WriteLine("--------------------------------");
            Console.WriteLine("image_path = {0}", image_path);
            Console.WriteLine("config_path = {0}", config_path);
            Console.WriteLine("document_types = {0}", document_types);

            try
            {
                CsReporter reporter = new CsReporter();

                var             engine   = new RecognitionEngine(config_path);
                SessionSettings settings = engine.CreateSessionSettings();
                settings.AddEnabledDocumentTypes(document_types);
                RecognitionSession session      = engine.SpawnSession(settings, reporter);
                RecognitionResult  recog_result = session.ProcessImageFile(image_path);

                OutputRecognitionResult(recog_result);

                recog_result.Dispose();
                session.Dispose();
                engine.Dispose();
                reporter.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception caught: {0}", e);
            }

            Console.WriteLine("End application!");
            Console.SetOut(oldOut);
            writer.Close();
            ostrm.Close();
        }
        private void videoPanel_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.C)
            {
                string image_path     = curr_dir + @"\recog.jpg";
                string config_path    = curr_dir + @"\smartid.json";
                string document_types = "rus.passport.*";
                engine = new RecognitionEngine(config_path);

                settings = engine.CreateSessionSettings();
                settings.AddEnabledDocumentTypes(document_types);

                session = engine.SpawnSession(settings, reporter);

                Capture();
            }
            else if (e.KeyCode == Keys.F)
            {
                string image_path = curr_dir + @"\recog.jpg";
                byte[] im_bt      = FileToByteArray(image_path);

                Bitmap d_image = (Bitmap)System.Drawing.Image.FromFile(image_path);

                int w = d_image.Width;
                int h = d_image.Height;

                BitmapData bitmapData = d_image.LockBits(new System.Drawing.Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, d_image.PixelFormat);
                int        ByteCount  = bitmapData.Stride * h;
                byte[]     Pixels     = new byte[ByteCount];

                int bitsPerPixel  = ((int)bitmapData.PixelFormat & 0xff00) >> 8;
                int bytesPerPixel = (bitsPerPixel + 7) / 8;
                int stride        = 4 * ((w * bytesPerPixel + 3) / 4);

                //указатель на первый пиксель
                IntPtr ptrFirstPixel = bitmapData.Scan0;
                //копируем данные из указателя в массив байтов
                Marshal.Copy(ptrFirstPixel, Pixels, 0, Pixels.Length);

                get_recog(Pixels, Pixels.Length, w, h, stride);
            }

            //Application.Exit();
        }
Beispiel #17
0
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            //synthEngine.Speak("where do you live");

reiterateIfStaticCommand:

            string command = recogEngine.GetRecognizedText(synthEngine);

            bool WhetherStaticCommand = StaticCommands.WhetherExecuted(driver, command);

            if (!WhetherStaticCommand)
            {
                switch (command)
                {
                case "banglore":
                    driver.FindElement(By.ClassName("ResidentCity_iconBangalore_21hQE")).Click();
                    CompanyName.run(recogEngine, synthEngine, driver);
                    break;

                case "chennai":
                    driver.FindElement(By.ClassName("ResidentCity_iconChennai_SfqFL")).Click();
                    CompanyName.run(recogEngine, synthEngine, driver);
                    break;

                case "mumbai":
                    driver.FindElement(By.ClassName("ResidentCity_iconMumbai_3i73_")).Click();
                    CompanyName.run(recogEngine, synthEngine, driver);
                    break;

                case "new delhi":
                    driver.FindElement(By.ClassName("ResidentCity_iconNewDelhi_2IARH")).Click();
                    CompanyName.run(recogEngine, synthEngine, driver);
                    break;

                default:
                    break;
                }
            }
            else
            {
                goto reiterateIfStaticCommand;
            }
        }
Beispiel #18
0
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            //synthEngine.Speak("entering your details");

            string command = recogEngine.GetRecognizedText(synthEngine);

            StaticCommands.WhetherExecuted(driver, command);

            if (command == "enter details")
            {
                driver.FindElement(By.CssSelector("input[name=firstName]")).SendKeys("Aditya Singh");
                driver.FindElement(By.CssSelector("input[name=mobileNumber]")).SendKeys("7769987541");
                driver.FindElement(By.CssSelector("input[name=email]")).SendKeys("*****@*****.**");
                driver.FindElement(By.ClassName("btn-large")).Click();
            }

            string command2 = recogEngine.GetRecognizedText(synthEngine);

            StaticCommands.WhetherExecuted(driver, command2);
        }
Beispiel #19
0
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
reiterateIfStaticCommand:

            string command = recogEngine.GetRecognizedText(synthEngine);

            bool WhetherStaticCommand = StaticCommands.WhetherExecuted(driver, command);

            if (!WhetherStaticCommand)
            {
                switch (command)
                {
                default:
                    break;
                }
            }
            else
            {
                goto reiterateIfStaticCommand;
            }
        }
Beispiel #20
0
        private void RecognizeUser(ref Image <Bgr, byte> original, Image <Gray, byte> grayframe, Rectangle rectangle)
        {
            grayframe.ROI = rectangle;
            var size = Properties.Settings.Default.RecognitionImageSize;

            try
            {
                var id = RecognitionEngine.RecognizeUser(grayframe.Copy().Resize(size, size, Inter.Cubic));
                if (id > 0)
                {
                    var user = RecognitionData.GetUser(id);
                    if (user != null)
                    {
                        original.Draw(user.Username, new Point(rectangle.Left, rectangle.Top - 10), FontFace.HersheyPlain, 2, new Bgr(Color.DarkTurquoise));
                    }
                }
            }
            catch (CvException)
            {
                // ignored
            }
        }
Beispiel #21
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "Recognition/ExtractText")] HttpRequestMessage req, TraceWriter log, ExecutionContext context)
        {
            try
            {
                if (!DemoConfiguration.UnlockSupport(log))
                {
                    return(GenerateErrorMessage(ApiError.LicenseNotSet, req));
                }

                var leadParameterObject = ParseLeadWebRequestParameters(req);
                if (!leadParameterObject.Successful)
                {
                    return(GenerateErrorMessage(ApiError.InvalidRequest, req));
                }

                var imageReturn = await GetImageStreamAsync(leadParameterObject.LeadWebRequest.fileUrl, req, DemoConfiguration.MaxUrlMbs);

                if (!imageReturn.Successful)
                {
                    return(GenerateErrorMessage(imageReturn.ErrorType.Value, req));
                }

                using (imageReturn.Stream)
                {
                    LoadDocumentOptions options = new LoadDocumentOptions()
                    {
                        FirstPageNumber = leadParameterObject.LeadWebRequest.FirstPage,
                        LastPageNumber  = leadParameterObject.LeadWebRequest.LastPage
                    };

                    RecognitionEngine recognitionEngine = new RecognitionEngine
                    {
                        WorkingDirectory = Path.GetTempPath(),
                        OcrEngine        = GetOcrEngine()
                    };

                    var documentPageText = recognitionEngine.ExtractText(imageReturn.Stream, options);
                    List <ExtractTextData> PageDataList = new List <ExtractTextData>();
                    int currentPage = options.FirstPageNumber;
                    foreach (var page in documentPageText)
                    {
                        for (int i = 0; i < page.Words.Count; i++)
                        {
                            var word = page.Words[i];
                            word.Bounds   = word.Bounds.ToLeadRect().ToLeadRectD();
                            page.Words[i] = word;
                        }
                        for (int i = 0; i < page.Characters.Count; i++)
                        {
                            var character = page.Characters[i];
                            character.Bounds   = character.Bounds.ToLeadRect().ToLeadRectD();
                            page.Characters[i] = character;
                        }

                        ExtractTextData pageData = new ExtractTextData
                        {
                            PageNumber = currentPage,
                            PageText   = page.Text,
                            Words      = page.Words,
                            Characters = page.Characters
                        };
                        PageDataList.Add(pageData);
                        currentPage++;
                    }

                    using (var ms = new MemoryStream())
                    {
                        using (TextWriter tw = new StreamWriter(ms))
                        {
                            tw.Write(JsonConvert.SerializeObject(PageDataList));
                            tw.Flush();
                            ms.Position = 0;

                            Guid   id            = Guid.NewGuid();
                            string baseName      = $"ExtractText-{id}.json";
                            var    blobUri       = UploadFileToBlobStorage(ms, baseName);
                            var    returnRequest = req.CreateResponse(HttpStatusCode.OK);
                            returnRequest.Content = new StringContent(JsonConvert.SerializeObject(blobUri));
                            return(returnRequest);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error($"API Error occurred for request: {context.InvocationId} \n Details: {JsonConvert.SerializeObject(ex)}");
                return(GenerateErrorMessage(ApiError.InternalServerError, req));
            }
        }
Beispiel #22
0
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            recogEngine.SetGrammarFile("HomePage.txt");

            driver.Url = "https://www.bankbazaar.com/";

            /*
             * synthEngine.SpeakAsync("choose from credit score, home loan, car loan" +
             *  "used car loan, personal loan, short term loan, credit card, debit card" +
             *  "mutual fund, life insurance, car insurance, two wheeler insurance" +
             *  "health insurance, savings account, fixed deposit");
             */

reiterateIfStaticCommand:

            string command = recogEngine.GetRecognizedText(synthEngine);

            bool WhetherStaticCommand = StaticCommands.WhetherExecuted(driver, command);

            if (!WhetherStaticCommand)
            {
                switch (command)
                {
                case "credit score":
                    driver.FindElement(By.ClassName("bbicons-cs")).Click();
                    CreditScore.CreditScore.run(recogEngine, synthEngine, driver);
                    break;

                case "home loan":
                    driver.FindElement(By.ClassName("bbicons-hl")).Click();
                    HomeLoan.HomeLoan.run(recogEngine, synthEngine, driver);
                    break;

                case "car loan":
                    driver.FindElement(By.ClassName("bbicons-cl")).Click();
                    CarLoan.CarLoan.run(recogEngine, synthEngine, driver);
                    break;

                case "used car loan":
                    driver.FindElement(By.ClassName("bbicons-ucl")).Click();
                    UsedCarLoan.UsedCarLoan.run(recogEngine, synthEngine, driver);
                    break;

                case "personal loan":
                    driver.FindElement(By.ClassName("bbicons-pl")).Click();
                    PersonalLoan.PersonalLoan.run(recogEngine, synthEngine, driver);
                    break;

                case "short term loan":
                    driver.FindElement(By.ClassName("bbicons-stpl")).Click();
                    ShortTermLoan.ShortTermLoan.run(recogEngine, synthEngine, driver);
                    break;

                case "credit card":
                    driver.FindElement(By.ClassName("bbicons-cc")).Click();
                    CreditCard.CreditCard.run(recogEngine, synthEngine, driver);
                    break;

                case "debit card":
                    driver.FindElement(By.ClassName("bbicons-dc")).Click();
                    DebitCard.DebitCard.run(recogEngine, synthEngine, driver);
                    break;

                case "mutual fund":
                    driver.FindElement(By.ClassName("bbicons-mf")).Click();
                    MutualFund.MutualFund.run(recogEngine, synthEngine, driver);
                    break;

                case "life insurance":
                    driver.FindElement(By.ClassName("bbicons-lfi")).Click();
                    LifeInsurance.LifeInsurance.run(recogEngine, synthEngine, driver);
                    break;

                case "car insurance":
                    driver.FindElement(By.ClassName("bbicons-ci")).Click();
                    CarInsurance.CarInsurance.run(recogEngine, synthEngine, driver);
                    break;

                case "two wheeler insurance":
                    driver.FindElement(By.ClassName("bbicons-twi")).Click();
                    TwoWheelerInsurance.TwoWheelerInsurance.run(recogEngine, synthEngine, driver);
                    break;

                case "health insurance":
                    driver.FindElement(By.ClassName("bbicons-hi")).Click();
                    HealthInsurance.HealthInsurance.run(recogEngine, synthEngine, driver);
                    break;

                case "savings account":
                    driver.FindElement(By.ClassName("bbicons-acc")).Click();
                    SavingsAccount.SavingsAccount.run(recogEngine, synthEngine, driver);
                    break;

                case "fixed deposit":
                    driver.FindElement(By.ClassName("bbicons-fd")).Click();
                    FixedDeposit.FixedDeposit.run(recogEngine, synthEngine, driver);
                    break;

                default:
                    break;
                }
            }
            else
            {
                goto reiterateIfStaticCommand;
            }
        }
Beispiel #23
0
        /// <summary>
        /// Starts the fast operations to be executed at every user interaction with the <see cref="RichTextBox"/>.
        /// </summary>
        /// <param name="richTextBox">
        /// The <see cref="RichTextBox"/> which text was changed.
        /// </param>
        /// <param name="eventArgs">
        /// The <see cref="TextChangedEventArgs"/> containing specific information about the user interaction.
        /// </param>
        /// <param name="scheduler">
        /// The <see cref="TaskScheduler"/> containing GUI-context.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// One or all of the parameters was/ were passed as null.
        /// </exception>
        public static async Task CodeAlteredAsync(RichTextBox richTextBox, TextChangedEventArgs eventArgs, TaskScheduler scheduler)
        {
            if (richTextBox == null)
            {
                throw new ArgumentNullException("richTextBox");
            }

            if (eventArgs == null)
            {
                throw new ArgumentNullException("eventArgs");
            }

            if (scheduler == null)
            {
                throw new ArgumentNullException("scheduler");
            }

            if (NoTextChangedPlox)
            {
                return;
            }

            var text =
                new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd).Text.Replace(
                    " ",
                    string.Empty);

            if (richTextBox.Document == null || text == "\r\n")
            {
                RecognitionEngine.AllWordsInCode.Clear();
                MistakeEngine.Mistakes.Clear();
                MainWindow.ErrorListView.Items.Clear();
                return;
            }

            TextChange textChange  = null;
            var        textChanges = eventArgs.Changes;

            if (textChanges != null && textChanges.Count > 0)
            {
                textChange = textChanges.First();
            }

            if (textChange == null || (textChange.AddedLength <= 0 && textChange.RemovedLength <= 0))
            {
                return;
            }

            IEnumerable <Word> changedWords = RecognitionEngine.RecognizeWordsInCode(richTextBox.CaretPosition, CurrentProgrammingLanguage).Result;

            var newWord = changedWords.First();

            if (newWord.Content == string.Empty)
            {
                await FacilitateCoding.PseudoSenseAsync(newWord, RecognitionEngine.AllWordsInCode, CurrentProgrammingLanguage, MainWindow.CodeListBox);

                return;
            }

            switch (pseudoSenseTask.Status)
            {
            case TaskStatus.Created:
                pseudoSenseTask.Start(scheduler);
                break;

            case TaskStatus.RanToCompletion:
            case TaskStatus.Faulted:
                pseudoSenseTask.Dispose();
                pseudoSenseTask = new Task(
                    () => FacilitateCoding.PseudoSenseAsync(newWord, RecognitionEngine.AllWordsInCode, CurrentProgrammingLanguage, MainWindow.CodeListBox),
                    cancellationToken.Token,
                    TaskCreationOptions.LongRunning);
                pseudoSenseTask.Start(scheduler);
                break;
            }
        }
Beispiel #24
0
        public static void run(RecognitionEngine recogEngine, SpeechSynthesizer synthEngine, IWebDriver driver)
        {
            //synthEngine.Speak("what is you net monthly salary, enter one digit at a time");

reiterateIfStaticCommand:

            //synthEngine.Speak("If done speak click continue");

            string command = recogEngine.GetRecognizedText(synthEngine);

            bool WhetherStaticCommand = StaticCommands.WhetherExecuted(driver, command);

            if (!WhetherStaticCommand)
            {
                switch (command)
                {
                case "number one":
                    driver.FindElement(By.CssSelector("input[name='netMonthlyIncome']")).SendKeys("1");
                    goto reiterateIfStaticCommand;

                case "number two":
                    driver.FindElement(By.CssSelector("input[name='netMonthlyIncome']")).SendKeys("2");
                    goto reiterateIfStaticCommand;

                case "number three":
                    driver.FindElement(By.CssSelector("input[name='netMonthlyIncome']")).SendKeys("3");
                    goto reiterateIfStaticCommand;

                case "number four":
                    driver.FindElement(By.CssSelector("input[name='netMonthlyIncome']")).SendKeys("4");
                    goto reiterateIfStaticCommand;

                case "number five":
                    driver.FindElement(By.CssSelector("input[name='netMonthlyIncome']")).SendKeys("5");
                    goto reiterateIfStaticCommand;

                case "number six":
                    driver.FindElement(By.CssSelector("input[name='netMonthlyIncome']")).SendKeys("6");
                    goto reiterateIfStaticCommand;

                case "number seven":
                    driver.FindElement(By.CssSelector("input[name='netMonthlyIncome']")).SendKeys("7");
                    goto reiterateIfStaticCommand;

                case "number eight":
                    driver.FindElement(By.CssSelector("input[name='netMonthlyIncome']")).SendKeys("8");
                    goto reiterateIfStaticCommand;

                case "numberoo nine":
                    driver.FindElement(By.CssSelector("input[name='netMonthlyIncome']")).SendKeys("9");
                    goto reiterateIfStaticCommand;

                case "click continue":
                    driver.FindElement(By.ClassName("btn-large")).Click();
                    Gender.run(recogEngine, synthEngine, driver);
                    break;

                default:
                    break;
                }
            }
            else
            {
                goto reiterateIfStaticCommand;
            }
        }
Beispiel #25
0
 public Window()
 {
     InitializeComponent();
     FormClosing += Window_FormClosing;
     engine       = new RecognitionEngine();
 }
Beispiel #26
0
        public static AIService CreateService(Context context, AIConfiguration config, RecognitionEngine recognitionEngine)
        {
            switch (recognitionEngine)
            {
            case RecognitionEngine.System:
                return(new SystemRecognitionService(context, config));

            //break;

            case RecognitionEngine.ApiAi:
                return(new SpeaktoitRecognitionService(context, config));

            //break;

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #27
0
 public void AddPageToForm(RasterImage image, FormRecognitionAttributes attributes, PageRecognitionOptions options)
 {
     RecognitionEngine.OpenForm(attributes);
     RecognitionEngine.AddFormPage(attributes, image, options);
     RecognitionEngine.CloseForm(attributes);
 }
Beispiel #28
0
 public void ReinitializeRecognition()
 {
     RecognitionEngine.InitializeFaceRecognizer();
 }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RecognitionEngine obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Beispiel #30
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "Recognition/ExtractAllBarcodes")] HttpRequestMessage req, TraceWriter log, ExecutionContext context)
        {
            try
            {
                if (!DemoConfiguration.UnlockSupport(log))
                {
                    return(GenerateErrorMessage(ApiError.LicenseNotSet, req));
                }

                var leadParameterObject = ParseLeadWebRequestParameters(req);
                if (!leadParameterObject.Successful)
                {
                    return(GenerateErrorMessage(ApiError.InvalidRequest, req));
                }

                var barcodeList = ExtractBarcodeSymbologies(req);
                if (barcodeList.Count == 0)
                {
                    return(GenerateErrorMessage(ApiError.InvalidRequest, req));
                }

                var imageReturn = await GetImageStreamAsync(leadParameterObject.LeadWebRequest.fileUrl, req, DemoConfiguration.MaxUrlMbs);

                if (!imageReturn.Successful)
                {
                    return(GenerateErrorMessage(imageReturn.ErrorType.Value, req));
                }

                using (imageReturn.Stream)
                {
                    LoadDocumentOptions options = new LoadDocumentOptions()
                    {
                        FirstPageNumber = leadParameterObject.LeadWebRequest.FirstPage,
                        LastPageNumber  = leadParameterObject.LeadWebRequest.LastPage
                    };

                    RecognitionEngine recognitionEngine = new RecognitionEngine();
                    recognitionEngine.WorkingDirectory = Path.GetTempPath();
                    BarcodeEngine            barcodeEngine  = new BarcodeEngine();
                    var                      barcodeResults = recognitionEngine.ExtractBarcode(imageReturn.Stream, options, barcodeEngine, barcodeList.ToArray(), 0, true);
                    List <BarcodeResultData> results        = new List <BarcodeResultData>();
                    foreach (var pageBarcodeData in barcodeResults)
                    {
                        foreach (var d in pageBarcodeData.BarcodeData)
                        {
                            if (d != null && d.Value != null)
                            {
                                var rect = new Rectangle(d.Bounds.X, d.Bounds.Y, d.Bounds.Width, d.Bounds.Height);
                                results.Add(new BarcodeResultData(pageBarcodeData.PageNumber, d.Symbology.ToString(), d.Value, rect, d.RotationAngle));
                            }
                        }
                    }
                    var returnRequest = req.CreateResponse(HttpStatusCode.OK);
                    returnRequest.Content = new StringContent(JsonConvert.SerializeObject(results));
                    return(returnRequest);
                }
            }
            catch (Exception ex)
            {
                log.Error($"API Error occurred for request: {context.InvocationId} \n Details: {JsonConvert.SerializeObject(ex)}");
                return(GenerateErrorMessage(ApiError.InternalServerError, req));
            }
        }