public ViDiReadResultList GenerateList(SegmentInput Input) /* Generate lists of all relevant data: Score, X-position, width */ { ViDiReadResultList result = new ViDiReadResultList(); string readResult = ""; List <double> xpos_list = new List <double>(); //list for x-positions of start of new segment List <double> w_list = new List <double>(); //list for width of characters List <double> score_list = new List <double>(); //list for score of characters if (Input.Marking != null && Input.OcrString != null) { readResult = Input.OcrString; IBlueMarking m = Input.Marking; Point p = new Point(); int n = readResult.Length; int i = 0; while (i < n) { try { p = m.Views[0].Matches[0].Features[i].Position; //We assume only 1 model match and this model is 0 p = p.ToOriginalFromView(m.Views[0]); //Tranformation back to pixel image from Vidi image xpos_list.Add(p.X); score_list.Add(m.Views[0].Matches[0].Features[i].Score); w_list.Add(m.Views[0].Matches[0].Features[i].Size.Width); } catch { } } } else { readResult = ""; } result.Read = readResult; result.ScoreList = score_list; result.XPosList = xpos_list; result.WidthList = w_list; return(result); }
//Blue 툴 결과 처리 public bool GetBlueToolResult(string strToolName, out double dMatchScore, out double dFeatureScore) { dMatchScore = 99999.0; dFeatureScore = 99999.0; // access the marking for the blue tool called 'localize' //'현지화'라는 파란 색 도구의 표시에 액세스 IBlueMarking blueMarking = m_Sample.Markings[strToolName] as IBlueMarking; if (blueMarking != null) { foreach (IBlueView view in blueMarking.Views) { foreach (IMatch match in view.Matches) { if (dMatchScore > match.Score) { dMatchScore = match.Score; } } foreach (IFeature feature in view.Features) { if (dFeatureScore > feature.Score) { dFeatureScore = feature.Score; } } } } else { return(false); } return(true); }
public DoublesRemoved RemoveDoubles(SegmentInput Input, int StartIndex, int EndIndex, double devP) //Code to remove double characters at the same position based on the score { DoublesRemoved result = new DoublesRemoved(); IBlueMarking m = Input.Marking; int n = (EndIndex + 1); string ocr = Input.OcrString; Point p = new Point(); char[] ocr_char = ocr.ToCharArray(); //string[int] is read-only--> create and modify the character array and convert back to string List <char> char_list = new List <char>(ocr_char); //Convert to List to be able to easily remove at certain position List <char> newChar_list = new List <char>(); //list to build new string (no doubles) List <double> score_list = new List <double>(); //list for score (to build result array later) List <double> pos_list = new List <double>(); //list for positions (to build result array later) double w = 0; //Char width double dev = devP; //consider same when difference between two positions is < dev * characterwidth double x_curr = 0; double x_prev = 0; double score_prev = 0; double score_curr = 0; try { if (m != null && n > 1) //Marking present and at least 2 characters { int i = StartIndex; //index in Marking int j = 0; //index for newChar_list while (i < n) //loop trough all of characters { w = m.Views[0].Matches[0].Features[i].Size.Width; //Get char width p = m.Views[0].Matches[0].Features[i].Position; p = p.ToOriginalFromView(m.Views[0]); x_curr = p.X; score_curr = m.Views[0].Matches[0].Features[i].Score; if (((x_curr - x_prev) < (dev * w)) && (j > 0)) //Compare scores when two char at one position (but not for 1st index of loop) { if (score_curr >= score_prev) { newChar_list.RemoveAt(j - 1); score_list.RemoveAt(j - 1); pos_list.RemoveAt(j - 1); newChar_list.Add(char_list[j]); score_list.Add(score_curr); pos_list.Add(x_curr); } else { //Niks doen (niet toevoegen aan list) } } else { newChar_list.Add(char_list[j]); score_list.Add(score_curr); pos_list.Add(x_curr); } x_prev = x_curr; score_prev = score_curr; i++; j++; } ocr_char = newChar_list.ToArray(); result.DbleRemovedStr = ocr = new string(ocr_char); } else { result.DbleRemovedStr = ""; } result.CharList = newChar_list; result.PosList = pos_list; result.ScoreList = score_list; } catch { result.DbleRemovedStr = ""; } return(result); }