예제 #1
0
 public BPN(ActivationFunction func, vector_int layerDescrTab, BiasNodes bias, vector_MinMaxInput minMaxInputTab, double minOutput, double maxOutput) : this(VisionLabPINVOKE.new_BPN__SWIG_1((int)func, vector_int.getCPtr(layerDescrTab), (int)bias, vector_MinMaxInput.getCPtr(minMaxInputTab), minOutput, maxOutput), true)
 {
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #2
0
 public vector_intEnumerator(vector_int collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
예제 #3
0
 public vector_int(vector_int other) : this(VisionLabPINVOKE.new_vector_int__SWIG_1(vector_int.getCPtr(other)), true)
 {
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #4
0
 public void GetSelectedSet(vector_vector_double features, vector_int classIds)
 {
     VisionLabPINVOKE.ClassFeatureSet_YUV16_GetSelectedSet(swigCPtr, vector_vector_double.getCPtr(features), vector_int.getCPtr(classIds));
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public void SetWord(int index, vector_int word)
 {
     VisionLabPINVOKE.ClassLexicon_SetWord(swigCPtr, index, vector_int.getCPtr(word));
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public void RemoveWord(vector_int word)
 {
     VisionLabPINVOKE.ClassLexicon_RemoveWord__SWIG_1(swigCPtr, vector_int.getCPtr(word));
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #7
0
 public void GetClassIds(vector_int classIds)
 {
     VisionLabPINVOKE.ClassFeatureSet_YUV16_GetClassIds(swigCPtr, vector_int.getCPtr(classIds));
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #8
0
 public void SetRange(int index, vector_int values)
 {
     VisionLabPINVOKE.vector_int_SetRange(swigCPtr, index, vector_int.getCPtr(values));
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #9
0
 public void Init(ActivationFunction func, vector_int layerDescrTab, BiasNodes bias, vector_MinMaxInput minMaxInputTab, double minOutput, double maxOutput)
 {
     VisionLabPINVOKE.BPN_Init(swigCPtr, (int)func, vector_int.getCPtr(layerDescrTab), (int)bias, vector_MinMaxInput.getCPtr(minMaxInputTab), minOutput, maxOutput);
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public void GetSets(vector_DoubleImage images, vector_int classIds)
 {
     VisionLabPINVOKE.ClassImageSet_Double_GetSets(swigCPtr, vector_DoubleImage.getCPtr(images), vector_int.getCPtr(classIds));
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
    public vector_int GetWord(int index)
    {
        vector_int ret = new vector_int(VisionLabPINVOKE.ClassLexicon_GetWord(swigCPtr, index), true);

        if (VisionLabPINVOKE.SWIGPendingException.Pending)
        {
            throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
    public double EvaluateClassSet(vector_vector_double inputs, vector_int classesExp, vector_int classesRes, vector_double confidencies, vector_vector_double outputs, ref double meanError)
    {
        double ret = VisionLabPINVOKE.BPN_Classifier_EvaluateClassSet(swigCPtr, vector_vector_double.getCPtr(inputs), vector_int.getCPtr(classesExp), vector_int.getCPtr(classesRes), vector_double.getCPtr(confidencies), vector_vector_double.getCPtr(outputs), ref meanError);

        if (VisionLabPINVOKE.SWIGPendingException.Pending)
        {
            throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
    public double EvaluateClassImageSet(ClassImageSet_RGB16 cis, vector_int classesRes, vector_double confidencies, vector_vector_double outputs, ref double meanError)
    {
        double ret = VisionLabPINVOKE.BPN_ImageClassifier_RGB16_EvaluateClassImageSet(swigCPtr, ClassImageSet_RGB16.getCPtr(cis), vector_int.getCPtr(classesRes), vector_double.getCPtr(confidencies), vector_vector_double.getCPtr(outputs), ref meanError);

        if (VisionLabPINVOKE.SWIGPendingException.Pending)
        {
            throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
    public double FindBestWord(vector_vector_LetterMatch wmTab, vector_int bestWord, Optimize opt)
    {
        double ret = VisionLabPINVOKE.ClassLexicon_FindBestWord__SWIG_1(swigCPtr, vector_vector_LetterMatch.getCPtr(wmTab), vector_int.getCPtr(bestWord), (int)opt);

        if (VisionLabPINVOKE.SWIGPendingException.Pending)
        {
            throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
예제 #15
0
    public vector_int GetRange(int index, int count)
    {
        IntPtr     cPtr = VisionLabPINVOKE.vector_int_GetRange(swigCPtr, index, count);
        vector_int ret  = (cPtr == IntPtr.Zero) ? null : new vector_int(cPtr, true);

        if (VisionLabPINVOKE.SWIGPendingException.Pending)
        {
            throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
예제 #16
0
    public static vector_int Repeat(int value, int count)
    {
        IntPtr     cPtr = VisionLabPINVOKE.vector_int_Repeat(value, count);
        vector_int ret  = (cPtr == IntPtr.Zero) ? null : new vector_int(cPtr, true);

        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);
            }
        }
예제 #18
0
 public static void LUT(Int32Image image, int minPixel, vector_int tab) {
   VisionLabPINVOKE.LUT__SWIG_9(Int32Image.getCPtr(image), minPixel, vector_int.getCPtr(tab));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
예제 #19
0
 public void Init(ActivationFunction func, vector_int layerDescrTab, BiasNodes bias, vector_MinMaxInput minMaxInputTab, double minOutput, double maxOutput) {
   VisionLabPINVOKE.BPN_Init(swigCPtr, (int)func, vector_int.getCPtr(layerDescrTab), (int)bias, vector_MinMaxInput.getCPtr(minMaxInputTab), minOutput, maxOutput);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
예제 #20
0
 public static SWIGTYPE_p_std__mapT_std__string_int_t VectorsToMap_string_int(vector_string key, vector_int value) {
   SWIGTYPE_p_std__mapT_std__string_int_t ret = new SWIGTYPE_p_std__mapT_std__string_int_t(VisionLabPINVOKE.VectorsToMap_string_int(vector_string.getCPtr(key), vector_int.getCPtr(value)), true);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
예제 #21
0
 public static void MapToVectors_string_int(SWIGTYPE_p_std__mapT_std__string_int_t keyvalue, vector_string key, vector_int value) {
   VisionLabPINVOKE.MapToVectors_string_int(SWIGTYPE_p_std__mapT_std__string_int_t.getCPtr(keyvalue), vector_string.getCPtr(key), vector_int.getCPtr(value));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public double TrainImageSet(int nrOfEpochs, double learnRate, double momentum, vector_DoubleImage images, vector_int classes, ref double meanError) {
   double ret = VisionLabPINVOKE.BPN_ImageClassifier_Double_TrainImageSet(swigCPtr, nrOfEpochs, learnRate, momentum, vector_DoubleImage.getCPtr(images), vector_int.getCPtr(classes), ref meanError);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 public void SetWord(int index, vector_int word) {
   VisionLabPINVOKE.ClassLexicon_SetWord(swigCPtr, index, vector_int.getCPtr(word));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public void GetSelectedSet(vector_vector_double features, vector_int classIds) {
   VisionLabPINVOKE.ClassFeatureSet_Float_GetSelectedSet(swigCPtr, vector_vector_double.getCPtr(features), vector_int.getCPtr(classIds));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public void GetClassIds(vector_int classIds) {
   VisionLabPINVOKE.ClassImageSet_Float_GetClassIds(swigCPtr, vector_int.getCPtr(classIds));
   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;
        }
예제 #27
0
 public BPN(ActivationFunction func, vector_int layerDescrTab, BiasNodes bias, vector_MinMaxInput minMaxInputTab, double minOutput, double maxOutput) : this(VisionLabPINVOKE.new_BPN__SWIG_1((int)func, vector_int.getCPtr(layerDescrTab), (int)bias, vector_MinMaxInput.getCPtr(minMaxInputTab), minOutput, maxOutput), true) {
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public void RemoveWord(vector_int word) {
   VisionLabPINVOKE.ClassLexicon_RemoveWord__SWIG_1(swigCPtr, vector_int.getCPtr(word));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public vector_int GetWord(int index) {
   vector_int ret = new vector_int(VisionLabPINVOKE.ClassLexicon_GetWord(swigCPtr, index), true);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
예제 #30
0
 internal static HandleRef getCPtr(vector_int obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
    public double TrainImageSet(int nrOfEpochs, double learnRate, double momentum, vector_RGB161616Image images, vector_int classes, ref double meanError)
    {
        double ret = VisionLabPINVOKE.BPN_ImageClassifier_RGB16_TrainImageSet(swigCPtr, nrOfEpochs, learnRate, momentum, vector_RGB161616Image.getCPtr(images), vector_int.getCPtr(classes), ref meanError);

        if (VisionLabPINVOKE.SWIGPendingException.Pending)
        {
            throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
예제 #32
0
 public static void ResampleLine(Int32Image image, Coord2D start, Coord2D end, int nrPixels, vector_Coord2D cTab, vector_int pTab) {
   VisionLabPINVOKE.ResampleLine__SWIG_5(Int32Image.getCPtr(image), Coord2D.getCPtr(start), Coord2D.getCPtr(end), nrPixels, vector_Coord2D.getCPtr(cTab), vector_int.getCPtr(pTab));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public void GetSets(vector_Int8Image images, vector_int classIds) {
   VisionLabPINVOKE.ClassImageSet_Int8_GetSets(swigCPtr, vector_Int8Image.getCPtr(images), vector_int.getCPtr(classIds));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
예제 #34
0
 public static SWIGTYPE_p_std__setT_int_t VectorToSet_int(vector_int v) {
   SWIGTYPE_p_std__setT_int_t ret = new SWIGTYPE_p_std__setT_int_t(VisionLabPINVOKE.VectorToSet_int(vector_int.getCPtr(v)), true);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 public double EvaluateClassImageSet(ClassImageSet_Double cis, vector_int classesRes, vector_double confidencies, vector_vector_double outputs, ref double meanError) {
   double ret = VisionLabPINVOKE.BPN_ImageClassifier_Double_EvaluateClassImageSet(swigCPtr, ClassImageSet_Double.getCPtr(cis), vector_int.getCPtr(classesRes), vector_double.getCPtr(confidencies), vector_vector_double.getCPtr(outputs), ref meanError);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
예제 #36
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(vector_int obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
        /*
         *  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 double FindBestWord(vector_vector_LetterMatch wmTab, vector_int bestWord, Optimize opt) {
   double ret = VisionLabPINVOKE.ClassLexicon_FindBestWord__SWIG_1(swigCPtr, vector_vector_LetterMatch.getCPtr(wmTab), vector_int.getCPtr(bestWord), (int)opt);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }