public LicenseCharacter(string character, double error, double confidence, int middlePos, vector_PatternMatchResult results) { chr = character; err = error; conf = confidence; middle = middlePos; PatternResults = results; }
public static vector_LetterMatch PatternMatchResultToLetterMatch(vector_PatternMatchResult vpmr) { vector_LetterMatch ret = new vector_LetterMatch(); for (int i = 0; i < vpmr.Count; i++) { ret.Add(PatternMatchResultToLetterMatch(vpmr[i])); } return ret; }
public static vector_PatternMatchResult Repeat(PatternMatchResult value, int count) { IntPtr cPtr = VisionLabPINVOKE.vector_PatternMatchResult_Repeat(PatternMatchResult.getCPtr(value), count); vector_PatternMatchResult ret = (cPtr == IntPtr.Zero) ? null : new vector_PatternMatchResult(cPtr, true); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public vector_PatternMatchResult GetRange(int index, int count) { IntPtr cPtr = VisionLabPINVOKE.vector_PatternMatchResult_GetRange(swigCPtr, index, count); vector_PatternMatchResult ret = (cPtr == IntPtr.Zero) ? null : new vector_PatternMatchResult(cPtr, true); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static string PatternMatchResultTabToStr(vector_PatternMatchResult tab) { string ret = VisionLabPINVOKE.PatternMatchResultTabToStr(vector_PatternMatchResult.getCPtr(tab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public override float AllMatches(Int8Image blob, float beginAngle, float endAngle, vector_PatternMatchResult tab) { float ret = VisionLabPINVOKE.BlobMatcher_Int8_AllMatches(swigCPtr, Int8Image.getCPtr(blob), beginAngle, endAngle, vector_PatternMatchResult.getCPtr(tab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public override int FindPatterns(Int8Image image, float maxError, float minConfindence, float beginAngle, float endAngle, vector_PatternMatchResult labelTab, vector_vector_int patTab) { int ret = VisionLabPINVOKE.BlobMatcher_Int8_FindPatterns(swigCPtr, Int8Image.getCPtr(image), maxError, minConfindence, beginAngle, endAngle, vector_PatternMatchResult.getCPtr(labelTab), vector_vector_int.getCPtr(patTab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public LicenseCharacter(string character, double error, double confidence, int middlePos, vector_PatternMatchResult results) { chr = character; err = error; conf = confidence; middle = middlePos; PatternResults = results; }
public override float AllMatches(Int32Image blob, float beginAngle, float endAngle, vector_PatternMatchResult tab) { float ret = VisionLabPINVOKE.BlobMatcher_Int32_AllMatches(swigCPtr, Int32Image.getCPtr(blob), beginAngle, endAngle, vector_PatternMatchResult.getCPtr(tab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public virtual float AllMatches(ByteImage blob, float beginAngle, float endAngle, vector_PatternMatchResult tab) { float ret = VisionLabPINVOKE.PatternMatcher_Byte_AllMatches(swigCPtr, ByteImage.getCPtr(blob), beginAngle, endAngle, vector_PatternMatchResult.getCPtr(tab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public virtual float AllMatches(ByteImage blob, float beginAngle, float endAngle, vector_PatternMatchResult tab) { float ret = VisionLabPINVOKE.PatternMatcher_Byte_AllMatches(swigCPtr, ByteImage.getCPtr(blob), beginAngle, endAngle, vector_PatternMatchResult.getCPtr(tab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
/* * Description: * Read the license plate * Input: * //Rectified license plate image containing six characters * Int32Image labeledRectifiedPlateImage * Output: * //Result by the blob matcher * ref LicensePlate result * Return: * //six characters found * bool */ public static bool MatchPlate(Int32Image binaryCharacterImage, BlobMatcher_Int32 matcher, ClassLexicon lexicon, ref LicensePlate result, ref LicensePlate lexiconResult) { try { //Check if 6 characters/blobs have been found and label image. if (VisionLab.LabelBlobs(binaryCharacterImage, Connected.EightConnected) != 6) { return(false); } //Calculate dimensions and locations of all characters/blobs. vector_BlobAnalyse ba_vec = new vector_BlobAnalyse(); ba_vec.Add(BlobAnalyse.BA_TopLeft); ba_vec.Add(BlobAnalyse.BA_Height); ba_vec.Add(BlobAnalyse.BA_Width); vector_Blob returnBlobs = new vector_Blob(); VisionLab.BlobAnalysis(binaryCharacterImage, VisionLab.VectorToSet_BlobAnalyse(ba_vec), VisionLab.MaxPixel(binaryCharacterImage), returnBlobs, SortOrder.SortDown, BlobAnalyse.BA_TopLeft, UseXOrY.UseX); ba_vec.Dispose(); Int32Image binaryCharacter = new Int32Image(); //Create data structure for lexicon. vector_vector_LetterMatch match = new vector_vector_LetterMatch(); //Process each character/blob. foreach (Blob b in returnBlobs) { //Cut out character VisionLab.ROI(binaryCharacterImage, binaryCharacter, b.TopLeft(), new HeightWidth(b.Height(), b.Width())); //Convert ROI result to binary VisionLab.ClipPixelValue(binaryCharacter, 0, 1); //Calculate character's classification for all classes. vector_PatternMatchResult returnMatches = new vector_PatternMatchResult(); float conf = matcher.AllMatches(binaryCharacter, (float)-0.5, (float)0.5, returnMatches); float err = returnMatches[0].error; int id = returnMatches[0].id; string chr = matcher.PatternName(id); //Fill datastructure for lexicon. match.Add(VisionLabEx.PatternMatchResultToLetterMatch(returnMatches)); //Store best match in result result.characters.Add(new LicenseCharacter(chr, err, conf)); } //Validate match with lexicon. vector_int bestWord = new vector_int(); lexiconResult.confidence = lexicon.FindBestWord(match, bestWord, Optimize.OptimizeForMinimum); for (int i = 0; i < bestWord.Count; i++) { string character = matcher.PatternName(bestWord[i]); //Store lexicon result lexiconResult.characters.Add(new LicenseCharacter(character)); } binaryCharacter.Dispose(); returnBlobs.Dispose(); match.Dispose(); bestWord.Dispose(); bool[] types = new bool[6]; for (int i = 0; i < 6; i++) { types[i] = '0' <= result.characters[i].character[0] && result.characters[i].character[0] <= '9'; } if (types[0] && types[1] && !types[2] && !types[3] && !types[4] && !types[5]) { return(true); } if (!types[0] && !types[1] && types[2] && types[3] && !types[4] && !types[5]) { return(true); } if (!types[0] && !types[1] && !types[2] && !types[3] && types[4] && types[5]) { return(true); } if (types[0] && !types[1] && !types[2] && !types[3] && types[4] && types[5]) { return(true); } if (types[0] && types[1] && !types[2] && !types[3] && !types[4] && types[5]) { return(true); } return(false); } catch (System.Exception ex) { throw new Exception("MatchPlate: " + ex.Message); } }
public PatternEvalResult(int eId, int iId, vector_PatternMatchResult pmRes, float conf) : this(VisionLabPINVOKE.new_PatternEvalResult__SWIG_1(eId, iId, vector_PatternMatchResult.getCPtr(pmRes), conf), true) { if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
/* Description: Read the license plate Input: //Rectified license plate image containing six characters Int16Image labeledRectifiedPlateImage BlobMatcher_Int16 matcher //initialized blobmatcher ClassLexicon lexicon //initialized lexicon Output: //Result by the blob matcher ref LicensePlate result //Result by the lexicon ref LicensePlate lexiconResult Return: //six characters found bool */ public static bool MatchPlate(Int16Image binaryCharacterImage, BlobMatcher_Int16 matcher, ClassLexicon lexicon, ref LicensePlate result, ref LicensePlate lexiconResult, bool dilate) { // NIEUW // 2de optie voor aanroep als eerste low confidence levert if (dilate) { Int16Image temp = new Int16Image(); VisionLab.Dilation(binaryCharacterImage, temp, new Mask_Int32(3, 3, 1)); binaryCharacterImage = new Int16Image(temp); temp.Dispose(); } if (VisionLab.LabelBlobs(binaryCharacterImage, Connected.EightConnected) != 6) return false; //Calculate dimensions and locations of all characters/blobs. vector_BlobAnalyse ba_vec = new vector_BlobAnalyse(); ba_vec.Add(BlobAnalyse.BA_TopLeft); ba_vec.Add(BlobAnalyse.BA_Height); ba_vec.Add(BlobAnalyse.BA_Width); vector_Blob returnBlobs = new vector_Blob(); VisionLab.BlobAnalysis(binaryCharacterImage, VisionLab.VectorToSet_BlobAnalyse(ba_vec), VisionLab.MaxPixel(binaryCharacterImage), returnBlobs, SortOrder.SortDown, BlobAnalyse.BA_TopLeft, UseXOrY.UseX); ba_vec.Dispose(); Int16Image binaryCharacter = new Int16Image(); //Create data structure for lexicon. vector_vector_LetterMatch match = new vector_vector_LetterMatch(); // NIEUW // Change the matcher params matcher.ChangeParams(60, 10, 64, 0); //Process each character/blob. foreach (Blob b in returnBlobs) { //Cut out character VisionLab.ROI(binaryCharacterImage, binaryCharacter, b.TopLeft(), new HeightWidth(b.Height(), b.Width())); //Convert ROI result to binary VisionLab.ClipPixelValue(binaryCharacter, 0, 1); //Calculate character's classification for all classes. vector_PatternMatchResult returnMatches = new vector_PatternMatchResult(); float conf = matcher.AllMatches(binaryCharacter, (float)-0.5, (float)0.5, returnMatches); float err = returnMatches[0].error; int id = returnMatches[0].id; string chr = matcher.PatternName(id); // NIEUW // If error to big decrease the confidence if(err > 0.20f) conf -= 0.2f; //Fill datastructure for lexicon. match.Add(VisionLabEx.PatternMatchResultToLetterMatch(returnMatches)); //Store best match in result result.characters.Add( new LicenseCharacter( chr, err, conf, // NIEUW // Extra param: The middle of a character // (used for matching patterns) b.TopLeft().x + ((b.TopRight().x - b.TopLeft().x)/2) , // NIEUW // All other results that we're found // So we can switch between em returnMatches )); } //Validate match with lexicon. vector_int bestWord = new vector_int(); lexiconResult.confidence = lexicon.FindBestWord(match, bestWord, Optimize.OptimizeForMinimum); for (int i = 0; i < bestWord.Count; i++) { string character = matcher.PatternName(bestWord[i]); //Store lexicon result lexiconResult.characters.Add(new LicenseCharacter(character)); } // NIEUW // Create the best match with the aid of the pattern matcher result.CalculateBestMatch(matcher); binaryCharacter.Dispose(); returnBlobs.Dispose(); match.Dispose(); bestWord.Dispose(); GC.Collect(); return true; }
public static vector_PatternMatchResult StrToPatternMatchResultTab(string str) { vector_PatternMatchResult ret = new vector_PatternMatchResult(VisionLabPINVOKE.StrToPatternMatchResultTab(str), true); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
internal static HandleRef getCPtr(vector_PatternMatchResult obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(vector_PatternMatchResult obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public override int FindPatterns(Int32Image image, float maxError, float minConfindence, float beginAngle, float endAngle, vector_PatternMatchResult labelTab, vector_vector_int patTab) { int ret = VisionLabPINVOKE.BlobMatcher_Int32_FindPatterns(swigCPtr, Int32Image.getCPtr(image), maxError, minConfindence, beginAngle, endAngle, vector_PatternMatchResult.getCPtr(labelTab), vector_vector_int.getCPtr(patTab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
/* * Description: * Read the license plate * Input: * //Rectified license plate image containing six characters * Int16Image labeledRectifiedPlateImage * BlobMatcher_Int16 matcher //initialized blobmatcher * ClassLexicon lexicon //initialized lexicon * Output: * //Result by the blob matcher * ref LicensePlate result * //Result by the lexicon * ref LicensePlate lexiconResult * Return: * //six characters found * bool */ public static bool MatchPlate(Int16Image binaryCharacterImage, BlobMatcher_Int16 matcher, ClassLexicon lexicon, ref LicensePlate result, ref LicensePlate lexiconResult, bool dilate) { // NIEUW // 2de optie voor aanroep als eerste low confidence levert if (dilate) { Int16Image temp = new Int16Image(); VisionLab.Dilation(binaryCharacterImage, temp, new Mask_Int32(3, 3, 1)); binaryCharacterImage = new Int16Image(temp); temp.Dispose(); } if (VisionLab.LabelBlobs(binaryCharacterImage, Connected.EightConnected) != 6) { return(false); } //Calculate dimensions and locations of all characters/blobs. vector_BlobAnalyse ba_vec = new vector_BlobAnalyse(); ba_vec.Add(BlobAnalyse.BA_TopLeft); ba_vec.Add(BlobAnalyse.BA_Height); ba_vec.Add(BlobAnalyse.BA_Width); vector_Blob returnBlobs = new vector_Blob(); VisionLab.BlobAnalysis(binaryCharacterImage, VisionLab.VectorToSet_BlobAnalyse(ba_vec), VisionLab.MaxPixel(binaryCharacterImage), returnBlobs, SortOrder.SortDown, BlobAnalyse.BA_TopLeft, UseXOrY.UseX); ba_vec.Dispose(); Int16Image binaryCharacter = new Int16Image(); //Create data structure for lexicon. vector_vector_LetterMatch match = new vector_vector_LetterMatch(); // NIEUW // Change the matcher params matcher.ChangeParams(60, 10, 64, 0); //Process each character/blob. foreach (Blob b in returnBlobs) { //Cut out character VisionLab.ROI(binaryCharacterImage, binaryCharacter, b.TopLeft(), new HeightWidth(b.Height(), b.Width())); //Convert ROI result to binary VisionLab.ClipPixelValue(binaryCharacter, 0, 1); //Calculate character's classification for all classes. vector_PatternMatchResult returnMatches = new vector_PatternMatchResult(); float conf = matcher.AllMatches(binaryCharacter, (float)-0.5, (float)0.5, returnMatches); float err = returnMatches[0].error; int id = returnMatches[0].id; string chr = matcher.PatternName(id); // NIEUW // If error to big decrease the confidence if (err > 0.20f) { conf -= 0.2f; } //Fill datastructure for lexicon. match.Add(VisionLabEx.PatternMatchResultToLetterMatch(returnMatches)); //Store best match in result result.characters.Add( new LicenseCharacter( chr, err, conf, // NIEUW // Extra param: The middle of a character // (used for matching patterns) b.TopLeft().x + ((b.TopRight().x - b.TopLeft().x) / 2), // NIEUW // All other results that we're found // So we can switch between em returnMatches )); } //Validate match with lexicon. vector_int bestWord = new vector_int(); lexiconResult.confidence = lexicon.FindBestWord(match, bestWord, Optimize.OptimizeForMinimum); for (int i = 0; i < bestWord.Count; i++) { string character = matcher.PatternName(bestWord[i]); //Store lexicon result lexiconResult.characters.Add(new LicenseCharacter(character)); } // NIEUW // Create the best match with the aid of the pattern matcher result.CalculateBestMatch(matcher); binaryCharacter.Dispose(); returnBlobs.Dispose(); match.Dispose(); bestWord.Dispose(); GC.Collect(); return(true); }