Example #1
0
        public void BarcodesRecognition(string qrCodeText = "")
        {
            var tempbarCodesPrompt = barCodesPrompt;
            ProcessingRegions(qrCodeText);
            if (barCodesPrompt == "Rotate180")
                return;

            if (!Auto && barCodesPrompt != "" && tempbarCodesPrompt != barCodesPrompt)
            {
                if (!barCodesPrompt.StartsWith("Aligment"))
                {
                    barCodesPrompt = tempbarCodesPrompt;
                }
            }
            if (!string.IsNullOrEmpty(qrCodeText))
            {
                if (!defaults.useStudentId)
                    filterType = (1 + filterType) / 2;
                else
                    filterType = 1;
            }
            else if (allFilterCount > 0)
                filterType = allFilterType / allFilterCount;
            if (Auto && barCodesPrompt != "")
                return;

            recTools.SetAdditionalOutputData(ref headers, ref totalOutput, regions, Path.GetFileName(FileName));
            Status = RecognizeAction.SearchBarcodesFinished;
        }
Example #2
0
 public void BubblesRecognition(bool clear = true)
 {
     Status = RecognizeAction.SearchBubles;
     if (clear)
         BubbleItems.Clear();
     if (indexAnswersPosition < 1)
     {
         Exception = new Exception("Error in indexAnswersPosition");
         log.LogMessage(Exception);
         NotifyUpdated(ExceptionEvent, Exception, null);
         return;
     }
     if (answersPosition < 1)
     {
         Exception = new Exception("Error in answersPosition");
         log.LogMessage(Exception);
         NotifyUpdated(ExceptionEvent, Exception, null);
         return;
     }
     maxAmoutOfQuestions = linesPerArea.Sum();
     totalOutput[indexAnswersPosition - 1] = new string[0];
     totalOutput[answersPosition - 1] = new string[0];
     if (AmoutOfQuestions > maxAmoutOfQuestions)
     {
         AmoutOfQuestions = maxAmoutOfQuestions;
     }
     if (AmoutOfQuestions == 0)
     {
         AmoutOfQuestions = maxAmoutOfQuestions;
         FindOrAddAndSetValueBarcode("amout_of_questions", maxAmoutOfQuestions.ToString());
         if (SheetIdentifier == "FLEX")
             FindOrAddAndSetValueBarcode("question_number_1", IndexOfFirstQuestion.ToString());
         else
             FindOrAddAndSetValueBarcode("index_of_first_question", IndexOfFirstQuestion.ToString());
     }
 }
Example #3
0
 //-------------------------------------------------------------------------
 private void SheetIdentifierFixProblem()
 {
     lastSheetIdentifier = "";
     Status = RecognizeAction.WaitingForUserResponse;
     NotifyUpdated(ChangedBarCodesPrompt, new RecognizeEventArgs(barCodesPrompt), null);
 }
Example #4
0
        //-------------------------------------------------------------------------
        private void Searchmarkers(bool alignmentOnly, ref string qrCodeText
            , bool isRotate = false, bool isCut = false, bool ShetIdManualySet = false)
        {
            BubbleItems.Clear();
            if (alignmentOnly)
            {
                var tempbarCodesPrompt = barCodesPrompt;
                recTools.GetSheetIdentifier(ref bitmap, ref kx, ref ky, ref sheetIdentifier, ref lastSheetIdentifier
                    , regionsList, ref filterType, ref barCodesPrompt, out curRect, out etRect, deltaY
                    , defaults, ref sheetIdentifierBarCodeRectangle, alignmentOnly, ref qrCodeText, isRotate, isCut, ShetIdManualySet);
                if (barCodesPrompt != "" && tempbarCodesPrompt != "" && tempbarCodesPrompt != barCodesPrompt)
                    barCodesPrompt = tempbarCodesPrompt;
                sheetIdentifier = regions.SheetIdentifierName;
                lastSheetIdentifier = sheetIdentifier;
            }
            else
            {
                regions = recTools.GetSheetIdentifier(ref bitmap, ref kx, ref ky, ref sheetIdentifier, ref lastSheetIdentifier
                , regionsList, ref filterType, ref barCodesPrompt, out curRect, out etRect, deltaY
                , defaults, ref sheetIdentifierBarCodeRectangle, alignmentOnly, ref qrCodeText, isRotate, isCut, ShetIdManualySet);

                QrCode = qrCodeText;
                if (cancellationToken.IsCancellationRequested)
                    return;

                if (Auto && (barCodesPrompt != "" || regions == null) || !Auto && string.IsNullOrEmpty(QrCode) && (barCodesPrompt != "" || regions == null))//!!!
                {
                    filterType = 0;
                    //if (Auto || string.IsNullOrEmpty(QrCode))
                    //{
                    //    if (!Auto && barCodesPrompt != "Markers not found ")
                    //    {
                    //        return;
                    //    }

                    //    SheetIdentifierFixProblem();
                    //    return;
                    //}

                    //if (!string.IsNullOrEmpty(QrCode) && !Auto && barCodesPrompt == "Aligment error")
                    //{
                    //    QrCode = "";
                    //    //regions = null;
                    //}

                    //string pr = barCodesPrompt;
                    SheetIdentifierFixProblem();
                    lastSheetIdentifier = sheetIdentifier;
                    //barCodesPrompt = pr;
                    return;
                }
            }
            if (filterType > 0 && filterType < 10)
            {
                allFilterType += filterType;
                allFilterCount++;
            }
            //lastSheetIdentifier = sheetIdentifier;

            Status = RecognizeAction.SearchMarkersFinished;
        }
Example #5
0
 //-------------------------------------------------------------------------
 public void UpdateGui()
 {
     Status = RecognizeAction.SearchBublesFinished;
     NotifyUpdated(ChangedBubble, null, new BubbleEventArgs(true, BubbleItems, regions.regions[numberOfBubblesRegion].areas
         , AmoutOfQuestions, maxAmoutOfQuestions, IndexOfFirstQuestion, linesPerArea, bubblesPerLine));
 }
Example #6
0
 //-------------------------------------------------------------------------
 public void SelectedSheetIdentifier(string BoxSheetSelectedValue, ref string qrCodeText, bool isRotate = false
     , bool isCut = false, bool ShetIdManualySet = false)
 {
     Status = RecognizeAction.InProcess;
     string barcode = BoxSheetSelectedValue;
     regions = recTools.GetRegions(barcode, regionsList);
     if (regions == null)
     {
         SheetIdentifierFixProblem();
         return;
     }
     lastSheetIdentifier = BoxSheetSelectedValue;
     sheetIdentifier = lastSheetIdentifier;
     Searchmarkers(true, ref qrCodeText, isRotate, isCut, ShetIdManualySet);
 }
Example #7
0
        //-------------------------------------------------------------------------
        public void RecAndFindBubble(
              bool empty = false
            //, Rectangle[] factRectangle = null
            //, Dictionary<Bubble, Point[]> allContourMultiLine = null
            )
        {
            //if (factRectangle == null)
            //{
            //factRectangle = new Rectangle[0];
            //allContourMultiLine = new Dictionary<Bubble, Point[]>();
            //}

            //var
            maxCountRectangles = AddMaxCountRectangles();

            //Bitmap.Save("recBitmap.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

            if (!barCodesPrompt.StartsWith("Markers") && !barCodesPrompt.StartsWith("Aligment"))//) || empty
            {
                barCodesPrompt = "";
                try
                {
                    if (Auto)
                    {
                        SetDarkness(regions.darknessPercent, regions.darknessDifferenceLevel);
                    }
                    recTools.BubblesRecognize
                            (
                              ref allContourMultiLine
                            , ref factRectangle
                            , Bitmap
                            , ref barCodesPrompt
                            , filterType
                            , true
                            , bubblesRegions
                            , bubblesOfRegion
                            , bubblesSubLinesCount
                            , bubblesSubLinesStep
                            , bubblesPerLine
                            , lineHeight
                            , linesPerArea
                            , answersPosition
                            , indexAnswersPosition
                            , totalOutput
                            , bubbleLines
                            , regions
                            , areas
                            , x1, x2, y1, y2
                            , kx, ky
                            , curRect, etRect
                            , deltaY
                            , AmoutOfQuestions, IndexOfFirstQuestion
                            , maxCountRectangles
                            , darknessPercent, darknessDifferenceLevel
                            , lastBannerBottom
                            //, deltaX
                            );

                    //Bitmap.Save("recBitmap.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

                    if (Auto && barCodesPrompt != "" || cancellationToken.IsCancellationRequested)
                    {
                        return;//errorFrame = true;
                    }
                }
                catch (Exception ex)
                {
                    Exception = ex;
                    log.LogMessage(Exception);
                    barCodesPrompt = "Error in \"RecAndFindBubble\"";
                    Audit.error = ex.Message;
                    FillBubbleItems(maxCountRectangles);
                    //NotifyUpdated(ExceptionEvent, Exception, null);
                    NotifyUpdated(ChangedBubble, null, new BubbleEventArgs(false, BubbleItems, regions.regions[numberOfBubblesRegion].areas
                        , AmoutOfQuestions, maxAmoutOfQuestions, IndexOfFirstQuestion, linesPerArea, bubblesPerLine));
                    Status = RecognizeAction.SearchBublesFinished;
                    return;
                }
                if (barCodesPrompt == "")
                {
                    FillBubbleItems(maxCountRectangles);
                    //FillBubbleItemsRectangle(allContourMultiLine, factRectangle);//???
                    FindBubble(factRectangle, allContourMultiLine);
                }
                else
                    maxCountRectangles = AddMaxCountRectangles();
            }
            else
            {
                FillBubbleItems(maxCountRectangles);
                recTools.AppendOutput(ref totalOutput, indexAnswersPosition, IndexOfFirstQuestion.ToString(), indexAnswersPosition, indexOfFirstBubble);
            }
            UpdateGui();
        }