public void DisplayImage(Image img, PictureBox pb, bool stretch, bool invert) { Bitmap bm; if (img is Int16Image) { Int16Image disp = new Int16Image((Int16Image)img); if (invert) { VisionLab.Not((Int16Image)disp); } if (stretch) { VisionLab.Multiply((Int16Image)disp, 255); } bm = VisionLabEx.JLToBitmap(disp); disp.Dispose(); } else { bm = VisionLabEx.JLToBitmap(img); } if (pb.Image != null) { pb.Image.Dispose(); } pb.Image = bm; }
public Int16Image(Int16Image image) : this(VisionLabPINVOKE.new_Int16Image__SWIG_3(Int16Image.getCPtr(image)), true) { if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } }
public virtual void SnapShot(Int16Image image) { VisionLabPINVOKE.Camera_Int16_SnapShot__SWIG_1(swigCPtr, Int16Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } }
public virtual void Resize(HeightWidth hw, Int16Image properties) { VisionLabPINVOKE.Int16Image_Resize__SWIG_1(swigCPtr, HeightWidth.getCPtr(hw), Int16Image.getCPtr(properties)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } }
public int AddImage(string className, Int16Image image) { int ret = VisionLabPINVOKE.ClassFeatureSet_Int16_AddImage(swigCPtr, className, Int16Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public virtual int FindPatterns(Int16Image image, float maxError, float minConfindence, float beginAngle, float endAngle, vector_PatternMatchResult labelTab, vector_vector_int patTab) { int ret = VisionLabPINVOKE.PatternMatcher_Int16_FindPatterns(swigCPtr, Int16Image.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 Int16Image GetImage(string className, int imageIndex) { Int16Image ret = new Int16Image(VisionLabPINVOKE.ClassFeatureSet_Int16_GetImage(swigCPtr, className, imageIndex), false); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public double EvaluateImage(Int16Image image, int classExp, ref int classRes, ref double confidency, vector_double output) { double ret = VisionLabPINVOKE.BPN_ImageClassifier_Int16_EvaluateImage(swigCPtr, Int16Image.getCPtr(image), classExp, ref classRes, ref confidency, vector_double.getCPtr(output)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public double ClassifyOutputTab(Int16Image image, vector_ClassOutput outputTab) { double ret = VisionLabPINVOKE.BPN_ImageClassifier_Int16_ClassifyOutputTab(swigCPtr, Int16Image.getCPtr(image), vector_ClassOutput.getCPtr(outputTab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public double TrainImage(double learnRate, double momentum, Int16Image image, int classNr) { double ret = VisionLabPINVOKE.BPN_ImageClassifier_Int16_TrainImage(swigCPtr, learnRate, momentum, Int16Image.getCPtr(image), classNr); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public int Classify(Int16Image image, ref double confidency) { int ret = VisionLabPINVOKE.BPN_ImageClassifier_Int16_Classify(swigCPtr, Int16Image.getCPtr(image), ref confidency); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public virtual float AllMatches(Int16Image blob, float beginAngle, float endAngle, vector_PatternMatchResult tab) { float ret = VisionLabPINVOKE.PatternMatcher_Int16_AllMatches(swigCPtr, Int16Image.getCPtr(blob), beginAngle, endAngle, vector_PatternMatchResult.getCPtr(tab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public override Int16Image PatternImage(int id) { Int16Image ret = new Int16Image(VisionLabPINVOKE.BlobMatcher_Int16_PatternImage__SWIG_0(swigCPtr, id), false); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public virtual int BestMatch(Int16Image blob, float beginAngle, float endAngle, ref float confidency, ref float error, ref float scale, ref float angle) { int ret = VisionLabPINVOKE.PatternMatcher_Int16_BestMatch(swigCPtr, Int16Image.getCPtr(blob), beginAngle, endAngle, ref confidency, ref error, ref scale, ref angle); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool GetImage(string imageName, Int16Image image) { bool ret = VisionLabPINVOKE.VisLibCmdInt_GetImage__SWIG_3(swigCPtr, imageName, Int16Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public virtual int AddPattern(Int16Image image, string name) { int ret = VisionLabPINVOKE.PatternMatcher_Int16_AddPattern(swigCPtr, Int16Image.getCPtr(image), name); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public virtual Int16Image PatternImage(string name) { Int16Image ret = new Int16Image(VisionLabPINVOKE.PatternMatcher_Int16_PatternImage__SWIG_1(swigCPtr, name), false); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static void InvertLUT(Int16Image image) { VisionLabPINVOKE.InvertLUT__SWIG_3(Int16Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void DiskShape(Int16Image image, XYCoord centre, double r, short value) { VisionLabPINVOKE.DiskShape__SWIG_7(Int16Image.getCPtr(image), XYCoord.getCPtr(centre), r, value); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static int CountPixel(Int16Image image, short value) { int ret = VisionLabPINVOKE.CountPixel__SWIG_3(Int16Image.getCPtr(image), value); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void BlockPattern(Int16Image image, XYCoord leftTop, int height, int width, short value, int repeatx, int repeaty) { VisionLabPINVOKE.BlockPattern__SWIG_7(Int16Image.getCPtr(image), XYCoord.getCPtr(leftTop), height, width, value, repeatx, repeaty); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void ThresholdMulti(Int16Image image, SWIGTYPE_p_std__setT_short_t selectSet) { VisionLabPINVOKE.ThresholdMulti__SWIG_3(Int16Image.getCPtr(image), SWIGTYPE_p_std__setT_short_t.getCPtr(selectSet)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void ThresholdHysteresis(Int16Image image, short low, short high, Connected connected) { VisionLabPINVOKE.ThresholdHysteresis__SWIG_3(Int16Image.getCPtr(image), low, high, (int)connected); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void ThresholdFast(Int16Image image, short thres, ObjectBrightness arg2) { VisionLabPINVOKE.ThresholdFast__SWIG_20(Int16Image.getCPtr(image), thres, (int)arg2); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static int SumIntPixels(Int16Image image) { int ret = VisionLabPINVOKE.SumIntPixels__SWIG_3(Int16Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void GammaLUT(Int16Image image, double gamma) { VisionLabPINVOKE.GammaLUT__SWIG_3(Int16Image.getCPtr(image), gamma); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void CalcHistogram0(Int16Image image, int hisSize, SWIGTYPE_p_int his) { VisionLabPINVOKE.CalcHistogram0__SWIG_3(Int16Image.getCPtr(image), hisSize, SWIGTYPE_p_int.getCPtr(his)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Int16Image obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public static void ContrastStretchLUT(Int16Image image, short low, short high) { VisionLabPINVOKE.ContrastStretchLUT__SWIG_3(Int16Image.getCPtr(image), low, high); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Remainder(Int16Image dest, Int16Image src) { VisionLabPINVOKE.Remainder__SWIG_3(Int16Image.getCPtr(dest), Int16Image.getCPtr(src)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void HistogramEqualize(Int16Image image) { VisionLabPINVOKE.HistogramEqualize__SWIG_3(Int16Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
/* * Description: * Read the license plate * Input: * //Rectified license plate image containing six characters * Int32Image 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(Int32Image binaryCharacterImage, BlobMatcher_Int16 matcher, ClassLexicon lexicon, ref LicensePlate result, ref LicensePlate lexiconResult) { //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(); Int16Image binaryCharacter16 = new Int16Image(); //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(); VisionLab.Convert(binaryCharacter, binaryCharacter16); float conf = matcher.AllMatches(binaryCharacter16, (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(); binaryCharacter16.Dispose(); returnBlobs.Dispose(); match.Dispose(); bestWord.Dispose(); //GC.Collect(); return(true); }
public static void LUT(Int16Image image, short minPixel, vector_short tab) { VisionLabPINVOKE.LUT__SWIG_7(Int16Image.getCPtr(image), minPixel, vector_short.getCPtr(tab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void FastHoughCircleT(Int16Image src, CircleBrightness brightness, short edgeMin, double minR, double maxR, double deltaR, vector_Int16Image destTab) { VisionLabPINVOKE.FastHoughCircleT__SWIG_3(Int16Image.getCPtr(src), (int)brightness, edgeMin, minR, maxR, deltaR, vector_Int16Image.getCPtr(destTab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void SetMultiToValueLUT(Int16Image image, SWIGTYPE_p_std__setT_short_t selectSet, short value) { VisionLabPINVOKE.SetMultiToValueLUT__SWIG_3(Int16Image.getCPtr(image), SWIGTYPE_p_std__setT_short_t.getCPtr(selectSet), value); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static vector_HoughCircle FindBestCircles(Int16Image src, double minR, double maxR, double deltaR) { vector_HoughCircle ret = new vector_HoughCircle(VisionLabPINVOKE.FindBestCircles__SWIG_15(Int16Image.getCPtr(src), minR, maxR, deltaR), true); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void SwapAxis(Int16Image src, Int16Image dest, ViewPoint viewPoint, int scale) { VisionLabPINVOKE.SwapAxis__SWIG_3(Int16Image.getCPtr(src), Int16Image.getCPtr(dest), (int)viewPoint, scale); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static vector_HoughCircle FindFastBestCircles(Int16Image src, CircleBrightness brightness, short edgeMin, double minR, double maxR, double deltaR) { vector_HoughCircle ret = new vector_HoughCircle(VisionLabPINVOKE.FindFastBestCircles__SWIG_15(Int16Image.getCPtr(src), (int)brightness, edgeMin, minR, maxR, deltaR), true); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void ThresholdFast(Int16Image image, short low, short high) { VisionLabPINVOKE.ThresholdFast__SWIG_23(Int16Image.getCPtr(image), low, high); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void FastHoughLineT(Int16Image src, HLParams p, short edgeMin, Int16Image dest) { VisionLabPINVOKE.FastHoughLineT__SWIG_3(Int16Image.getCPtr(src), HLParams.getCPtr(p), edgeMin, Int16Image.getCPtr(dest)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static int ThresholdIsoData(Int16Image image, Int16Image roi, ObjectBrightness arg2) { int ret = VisionLabPINVOKE.ThresholdIsoData__SWIG_7(Int16Image.getCPtr(image), Int16Image.getCPtr(roi), (int)arg2); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static HoughLine HTBestLine(Int16Image src, HLParams p) { HoughLine ret = new HoughLine(VisionLabPINVOKE.HTBestLine__SWIG_3(Int16Image.getCPtr(src), HLParams.getCPtr(p)), true); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void AddBorder(Int16Image src, Int16Image dest, int top, int left, int right, int bottom, short value) { VisionLabPINVOKE.AddBorder__SWIG_3(Int16Image.getCPtr(src), Int16Image.getCPtr(dest), top, left, right, bottom, value); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static HoughLine FindFastBestLine(Int16Image src, HLParams p, short edgeMin) { HoughLine ret = new HoughLine(VisionLabPINVOKE.FindFastBestLine__SWIG_3(Int16Image.getCPtr(src), HLParams.getCPtr(p), edgeMin), true); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void CircleShape(Int16Image image, XYCoord centre, int r, short value, ZeroOrOriginal zorg) { VisionLabPINVOKE.CircleShape__SWIG_6(Int16Image.getCPtr(image), XYCoord.getCPtr(centre), r, value, (int)zorg); 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 void DeInterlace(Int16Image image) { VisionLabPINVOKE.DeInterlace__SWIG_3(Int16Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
/* Description: * Find the largest license plate in the image * - Segment using ThresholdHSVchannels * - Remove blobs which are not license plates * Input: * //Original image * RGB888Image plateImage * Output: * //Segmented license plate * ref Int16Image binaryPlateImage * Return: * //License plate found? * bool */ public static bool FindPlate(RGB888Image plateImage, ref Int16Image binaryPlateImage, TresholdConditions state) { //Constants int c_threshold_h_min = 0; int c_threshold_h_max = 0; int c_threshold_s_min = 0; int c_threshold_s_max = 0; int c_threshold_v_min = 0; int c_threshold_v_max = 0; int c_remove_blobs_min = 0; int c_remove_blobs_max = 500; switch (state) { case (TresholdConditions.NORMAAL): c_threshold_h_min = 21; c_threshold_h_max = 50; c_threshold_s_min = 100; c_threshold_s_max = 255; c_threshold_v_min = 100; c_threshold_v_max = 255; break; case (TresholdConditions.ONDERBELICHT): c_threshold_h_min = 11; c_threshold_h_max = 119; c_threshold_s_min = 23; c_threshold_s_max = 255; c_threshold_v_min = 56; c_threshold_v_max = 176; break; case (TresholdConditions.OVERBELICHT): c_threshold_h_min = 0; c_threshold_h_max = 241; c_threshold_s_min = 29; c_threshold_s_max = 241; c_threshold_v_min = 249; c_threshold_v_max = 255; break; } //*******************************// //** Exercise: **// //** adjust licenseplate **// //** segmentation **// //*******************************// //Find licenseplate HSV888Image plateImageHSV = new HSV888Image(); //Convert to RGB to HSV VisionLab.FastRGBToHSV(plateImage, plateImageHSV); //Threshold HSV image VisionLab.Threshold3Channels(plateImageHSV, binaryPlateImage, c_threshold_h_min, c_threshold_h_max, c_threshold_s_min, c_threshold_s_max, c_threshold_v_min, c_threshold_v_max); //Convert to a 32 bit format Int32Image binaryPlateImage32 = new Int32Image(); VisionLab.Convert(binaryPlateImage, binaryPlateImage32); //Remove blobs with small areas VisionLab.RemoveBlobs(binaryPlateImage32, Connected.EightConnected, BlobAnalyse.BA_Area, c_remove_blobs_min, c_remove_blobs_max); //Remove border blobs VisionLab.RemoveBorderBlobs(binaryPlateImage32, Connected.EightConnected, Border.AllBorders); //Length Breath Ratio VisionLab.RemoveBlobs(binaryPlateImage32, Connected.EightConnected, BlobAnalyse.BA_LengthBreadthRatio, 0, 2.5); VisionLab.RemoveBlobs(binaryPlateImage32, Connected.EightConnected, BlobAnalyse.BA_LengthBreadthRatio, 6.7, 10); // Remove blobs that have to less holes VisionLab.RemoveBlobs(binaryPlateImage32, Connected.EightConnected, BlobAnalyse.BA_NrOfHoles, 0, 5); // And remove blobs that have a to small area for the holes VisionLab.RemoveBlobs(binaryPlateImage32, Connected.EightConnected, BlobAnalyse.BA_AreaHoles, 0, 200); //Convert back to a 16 bit format VisionLab.Convert(binaryPlateImage32, binaryPlateImage); //binPlateImage32.Dispose(); binaryPlateImage32.Dispose(); plateImageHSV.Dispose(); GC.Collect(); //Return true, if pixels found return(VisionLab.SumIntPixels(binaryPlateImage) > 0); //return VisionLab.LabelBlobs(binaryPlateImage, Connected.EightConnected) == 1; }
public static vector_HoughLine FindFastBestLines(Int16Image src, HLParams p, short edgeMin, int nrLines, double minR, double minPhi, int minHits) { vector_HoughLine ret = new vector_HoughLine(VisionLabPINVOKE.FindFastBestLines__SWIG_3(Int16Image.getCPtr(src), HLParams.getCPtr(p), edgeMin, nrLines, minR, minPhi, minHits), true); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
private void MatchImage(String Filename, bool add) { ErrorTB.Text = ""; lblExpected.Text = Filename.Substring(0, 6); //*************************************// //** load and display original image **// //*************************************// Bitmap bm; bm = new Bitmap(Filename); RGB888Image plateImage = VisionLabEx.BitmapToJL(bm); DisplayImage(plateImage, imgOrig); //****************// //** Find plate **// //****************// Int16Image binaryPlateImage = new Int16Image(); if (!LicensePlateMatcher.FindPlate(plateImage, ref binaryPlateImage, TresholdConditions.NORMAAL) && !LicensePlateMatcher.FindPlate(plateImage, ref binaryPlateImage, TresholdConditions.OVERBELICHT) && !LicensePlateMatcher.FindPlate(plateImage, ref binaryPlateImage, TresholdConditions.ONDERBELICHT)) { DisplayImage(binaryPlateImage, imgPlateBin, true, true); lblLexiconResult.Text = ""; if (add) { lstFindPlateErr.Items.Add(Filename); lblFindPlateErrCount.Text = lstFindPlateErr.Items.Count.ToString(); } ClearResultLabels(); return; } DisplayImage(binaryPlateImage, imgPlateBin, true, true); //*******************// //** Rectify plate **// //*******************// Int16Image binaryRectifiedImage = new Int16Image(); do { // Check if we can find the plate if (LicensePlateMatcher.FindCharacters(plateImage, binaryPlateImage, ref binaryRectifiedImage)) { // if so we are done break; } else { // ************************************ // ** Find the biggest blob in the ** // ** image and remove that one ** // ************************************ VisionLab.LabelBlobs(binaryPlateImage, Connected.EightConnected); vector_BlobAnalyse ba_vec = new vector_BlobAnalyse(); ba_vec.Add(BlobAnalyse.BA_Area); vector_Blob blobs = new vector_Blob(); VisionLab.BlobAnalysis(binaryPlateImage, VisionLab.VectorToSet_BlobAnalyse(ba_vec), VisionLab.MaxPixel(binaryPlateImage), blobs); int biggestArea = 0; foreach (Blob ba in blobs) { if (ba.Area() > biggestArea) { biggestArea = ba.Area(); } } VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_Area, biggestArea - 1, biggestArea + 1); } } // Repeat this until there is nothing left while (VisionLab.SumIntPixels(binaryPlateImage) > 0); // If that is so it wasn't found if (VisionLab.SumIntPixels(binaryPlateImage) == 0) { // So do all this if (imgRectifiedPlate.Image != null) { imgRectifiedPlate.Image.Dispose(); } imgRectifiedPlate.Image = null; lblLexiconResult.Text = ""; if (add) { lstRectifyPlateErr.Items.Add(Filename); lblRectfyPlateErrCount.Text = lstRectifyPlateErr.Items.Count.ToString(); } ClearResultLabels(); return; } DisplayImage(binaryRectifiedImage, imgRectifiedPlate, true, true); //*****************// //** Match Plate **// //*****************// LicensePlate result = new LicensePlate(); LicensePlate lexiconResult = new LicensePlate(); if (!LicensePlateMatcher.MatchPlate(binaryRectifiedImage, blobMatcher, lexicon, ref result, ref lexiconResult, false)) { lblLexiconResult.Text = ""; if (add) { lstMatchPlateErr.Items.Add(Filename); lblMatchPlateErrCount.Text = lstMatchPlateErr.Items.Count.ToString(); } ClearResultLabels(); return; } // Extra way to up confidence perhaps if (result.characters != null && result.confidence < (double)nupConfidence.Value / 100) { LicensePlateMatcher.MatchPlate(binaryRectifiedImage, blobMatcher, lexicon, ref result, ref lexiconResult, true); } //*********************// //** Process results **// //*********************// ProcessResults(result, lexiconResult, Filename, (double)nupConfidence.Value / 100, add); bm.Dispose(); plateImage.Dispose(); binaryPlateImage.Dispose(); binaryRectifiedImage.Dispose(); //Force a garbage collect to prevens malloc errors from unmanaged code. GC.Collect(); }
internal static HandleRef getCPtr(Int16Image obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }
public static void Extract1Channel(HSV161616Image image, HSVColor plane, Int16Image chan) { VisionLabPINVOKE.Extract1Channel__SWIG_60(HSV161616Image.getCPtr(image), (int)plane, Int16Image.getCPtr(chan)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static Histogram CalcHistogram(Int16Image image, Int16Image roi) { Histogram ret = new Histogram(VisionLabPINVOKE.CalcHistogram__SWIG_15(Int16Image.getCPtr(image), Int16Image.getCPtr(roi)), true); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
/* Description: * Locates the characters of the license plate * - Warp image (Rectify) * - Segment characters * - Remove blobs which are to small (Lines between characters) * Input: * //Original image * RGB888Image plateImage * //Segmented license plate * Int16Image binaryPlateImage * Output: * //Image containing binary six characters * ref Int16Image binaryCharacterImage * Return: * //Function executed successfully * bool */ public static bool FindCharacters(RGB888Image plateImage, Int16Image binaryPlateImage, ref Int16Image binaryCharacterImage) { //Constants const int c_height = 100; const int c_width = 470; const int c_remove_blobs_min = 0; const int c_remove_blobs_max = 400; XYCoord leftTop = new XYCoord(); XYCoord rightTop = new XYCoord(); XYCoord leftBottom = new XYCoord(); XYCoord rightBottom = new XYCoord(); // 2de set coordinaten: // NIEUW XYCoord leftTop2 = new XYCoord(); XYCoord rightTop2 = new XYCoord(); XYCoord leftBottom2 = new XYCoord(); XYCoord rightBottom2 = new XYCoord(); //Find licenseplate Int32Image binaryPlateImage32 = new Int32Image(); VisionLab.Convert(binaryPlateImage, binaryPlateImage32); VisionLab.FindCornersRectangle( binaryPlateImage32, Connected.EightConnected, 0.5, Orientation.Landscape, leftTop, rightTop, leftBottom, rightBottom ); // NIEUW // Coordinaten bepalen voor deze functie VisionLab.FindCornersRectangleSq( binaryPlateImage32, Connected.EightConnected, leftTop2, rightTop2, leftBottom2, rightBottom2 ); binaryPlateImage32.Dispose(); Int16Image plateImageGray = new Int16Image(); VisionLab.Convert(plateImage, plateImageGray); binaryCharacterImage.Assign_Op(plateImageGray); // Eerst de standaard wrap proberen try { //Rectify plate VisionLab.Warp( plateImageGray, binaryCharacterImage, TransformDirection.ForwardT, new Coord2D(leftTop), new Coord2D(rightTop), new Coord2D(leftBottom), new Coord2D(rightBottom), c_height, c_width, 0 ); } catch (Exception) { // NIEUW // Als dat mislukt dan de andere gebruiken try { VisionLab.Warp(plateImageGray, binaryCharacterImage, TransformDirection.ForwardT, new Coord2D(leftTop2), new Coord2D(rightTop2), new Coord2D(leftBottom2), new Coord2D(rightBottom2), c_height, c_width, 0 ); } catch (Exception) { return(false); } } plateImageGray.Dispose(); //*******************************// //** Exercise: **// //** adjust licenseplate **// //** segmentation **// //*******************************// // NIEUW Int16Image MaxMin = new Int16Image(); Int16Image MaxMin2 = new Int16Image(); // NIEUW //2 x max rondje ding //dan 2 x min rondje ding //dan van elkaar aftrekken //(zoeken op heldere object) Mask_Int32 mask = new Mask_Int32(11, 11, 5, 5); VisionLab.MaximumFilter(binaryCharacterImage, MaxMin, FixEdge.EdgeExtend, mask); VisionLab.MaximumFilter(MaxMin, MaxMin2, FixEdge.EdgeExtend, mask); VisionLab.MinimumFilter(MaxMin2, MaxMin, FixEdge.EdgeExtend, mask); VisionLab.MinimumFilter(MaxMin, MaxMin2, FixEdge.EdgeExtend, mask); // Maxmin2 holds the result now of the filter oparations // Get the difference between both VisionLab.Subtract(binaryCharacterImage, MaxMin2); MaxMin2.Dispose(); MaxMin.Dispose(); //Find dark text on bright licenseplate using ThresholdISOData VisionLab.ThresholdIsoData(binaryCharacterImage, ObjectBrightness.DarkObject); Int16Image bin = new Int16Image(); // NIEUW // Recreate images that are corralated / deformed VisionLab.Opening(binaryCharacterImage, bin, new Mask_Int32(2, 2, 1)); // Convert to a 32 bit format Int32Image binaryCharacterImage32 = new Int32Image(); // Int32Image binCharImg32 = new Int32Image(); VisionLab.Convert(bin, binaryCharacterImage32); bin.Dispose(); // Remove blobs connected to the border VisionLab.RemoveBorderBlobs(binaryCharacterImage32, Connected.EightConnected, Border.AllBorders); // Remove small blobs VisionLab.RemoveBlobs(binaryCharacterImage32, Connected.EightConnected, BlobAnalyse.BA_Area, c_remove_blobs_min, c_remove_blobs_max); //Convert to a 16 bit format VisionLab.Convert(binaryCharacterImage32, binaryCharacterImage); binaryCharacterImage32.Dispose(); leftTop.Dispose(); rightTop.Dispose(); leftBottom.Dispose(); rightBottom.Dispose(); GC.Collect(); // NIEUW // Check if 6 characters/blobs have been found and label image. if (VisionLab.LabelBlobs(binaryCharacterImage, Connected.EightConnected) != 6) { return(false); } return(true); }