public RGB888Image(RGB888Image image) : this(VisionLabPINVOKE.new_RGB888Image__SWIG_3(RGB888Image.getCPtr(image)), true) { 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 Int32Image binaryPlateImage * Return: * //License plate found? * bool */ public static bool FindPlate(RGB888Image plateImage, ref Int32Image binaryPlateImage) { //Constants const int c_threshold_h_min = 21; const int c_threshold_h_max = 50; const int c_threshold_s_min = 100; const int c_threshold_s_max = 255; const int c_threshold_v_min = 100; const int c_threshold_v_max = 255; const int c_remove_blobs_min = 1; const int c_remove_blobs_max = 5000; //*******************************// //** 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); //Remove blobs with small areas VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_Area, c_remove_blobs_min, c_remove_blobs_max); plateImageHSV.Dispose(); //GC.Collect(); //Return true, if pixels found return(VisionLab.SumIntPixels(binaryPlateImage) > 0); }
public virtual void SnapShot(RGB888Image image) { VisionLabPINVOKE.Camera_RGB8_SnapShot__SWIG_1(swigCPtr, RGB888Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } }
public override void SnapShot(RGB888Image image, int roiNr) { VisionLabPINVOKE.MFCam_SnapShot__SWIG_2(swigCPtr, RGB888Image.getCPtr(image), roiNr); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } }
public int AddImage(string className, RGB888Image image) { int ret = VisionLabPINVOKE.ClassImageSet_RGB8_AddImage(swigCPtr, className, RGB888Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public RGB888Image GetImage(int classId, int imageIndex) { RGB888Image ret = new RGB888Image(VisionLabPINVOKE.ClassImageSet_RGB8_GetImage__SWIG_1(swigCPtr, classId, imageIndex), false); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public double ClassifyOutputTab(RGB888Image image, vector_ClassOutput outputTab) { double ret = VisionLabPINVOKE.BPN_ImageClassifier_RGB8_ClassifyOutputTab(swigCPtr, RGB888Image.getCPtr(image), vector_ClassOutput.getCPtr(outputTab)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public double EvaluateImage(RGB888Image image, int classExp, ref int classRes, ref double confidency, vector_double output) { double ret = VisionLabPINVOKE.BPN_ImageClassifier_RGB8_EvaluateImage(swigCPtr, RGB888Image.getCPtr(image), classExp, ref classRes, ref confidency, vector_double.getCPtr(output)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public double TrainImage(double learnRate, double momentum, RGB888Image image, int classNr) { double ret = VisionLabPINVOKE.BPN_ImageClassifier_RGB8_TrainImage(swigCPtr, learnRate, momentum, RGB888Image.getCPtr(image), classNr); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool GetImage(string imageName, RGB888Image image) { bool ret = VisionLabPINVOKE.VisLibCmdInt_GetImage__SWIG_7(swigCPtr, imageName, RGB888Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) { throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public int Classify(RGB888Image image, ref double confidency) { int ret = VisionLabPINVOKE.BPN_ImageClassifier_RGB8_Classify(swigCPtr, RGB888Image.getCPtr(image), ref confidency); 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 * Int32Image binaryPlateImage * Output: * //Image containing binary six characters * ref Int32Image binaryCharacterImage * Return: * //Function executed successfully * bool */ public static bool FindCharacters(RGB888Image plateImage, Int32Image binaryPlateImage, ref Int32Image binaryCharacterImage) { //Constants const int c_height = 100; const int c_width = 470; const int c_remove_blobs_min = 1; const int c_remove_blobs_max = 400; XYCoord leftTop = new XYCoord(); XYCoord rightTop = new XYCoord(); XYCoord leftBottom = new XYCoord(); XYCoord rightBottom = new XYCoord(); //Find licenseplate VisionLab.FindCornersRectangle(binaryPlateImage, Connected.EightConnected, 0.5, Orientation.Landscape, leftTop, rightTop, leftBottom, rightBottom); Int32Image plateImageGray = new Int32Image(); VisionLab.Convert(plateImage, plateImageGray); 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) { //Warp, 3 coords on one line return(false); } plateImageGray.Dispose(); //*******************************// //** Exercise: **// //** adjust licenseplate **// //** segmentation **// //*******************************// //Find dark text on bright licenseplate using ThresholdISOData VisionLab.ThresholdIsoData(binaryCharacterImage, ObjectBrightness.DarkObject); //Remove blobs connected to the border VisionLab.RemoveBorderBlobs(binaryCharacterImage, Connected.EightConnected, Border.AllBorders); //Remove small blobs VisionLab.RemoveBlobs(binaryCharacterImage, Connected.EightConnected, BlobAnalyse.BA_Area, c_remove_blobs_min, c_remove_blobs_max); leftTop.Dispose(); rightTop.Dispose(); leftBottom.Dispose(); rightBottom.Dispose(); //GC.Collect(); return(true); }
public static RGB888Image BitmapToJL(Bitmap bm) { RGB888Image vlimage; BitmapData bmdata = bm.LockBits(new Rectangle(0, 0, bm.Width, bm.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb); try { vlimage = new RGB888Image(bmdata.Height, bm.Width); CopyMemory(vlimage.GetBufPtr(), bmdata.Scan0, bm.Width * bm.Height * 4 /*RGB8*/); } finally { bm.UnlockBits(bmdata); } return vlimage; }
/* * 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 Int32Image binaryPlateImage * Return: * //License plate found? * bool */ public static bool FindPlate(RGB888Image plateImage, ref Int32Image binaryPlateImage) { try { //Constants const int c_threshold_h_min = 14; const int c_threshold_h_max = 50; const int c_threshold_s_min = 100; const int c_threshold_s_max = 255; const int c_threshold_v_min = 46; const int c_threshold_v_max = 255; //*******************************// //** 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); VisionLab.LabelBlobs(binaryPlateImage, Connected.EightConnected); VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_LengthBreadthRatio, 0.0, 2.50); VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_LengthBreadthRatio, 10.0, 9999.0); //Remove blobs with small areas VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_Area, 1, 1000, UseXOrY.UseX); //VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_Area, 80000, 120000); //Fill up characters VisionLab.FillHoles(binaryPlateImage, Connected.EightConnected); plateImageHSV.Dispose(); //Return true, if pixels found return(VisionLab.SumIntPixels(binaryPlateImage) > 0); } catch (System.Exception ex) { throw new Exception("FindPlate: " + ex.Message); } }
public static RGB888Image BitmapToJL(Bitmap bm) { RGB888Image vlimage; BitmapData bmdata = bm.LockBits(new Rectangle(0, 0, bm.Width, bm.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb); try { vlimage = new RGB888Image(bmdata.Height, bm.Width); CopyMemory(vlimage.GetBufPtr(), bmdata.Scan0, bm.Width * bm.Height * 4 /*RGB8*/); } finally { bm.UnlockBits(bmdata); } return(vlimage); }
/* * 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 Int32Image binaryPlateImage * Return: * //License plate found? * bool */ public static bool FindPlate(RGB888Image plateImage, ref Int32Image binaryPlateImage) { try { VisionLab.SetRGB888Image(cmdInt, "plateImage", plateImage); String result = StripTime(cmdInt.ExecRequest("icall FindPlate plateImage binaryPlateImage")); if (result == "true") { VisionLab.GetInt32Image(cmdInt, "binaryPlateImage", binaryPlateImage); } return(result == "true"); } catch (System.Exception ex) { throw new Exception("FindPlate: " + ex.Message); } }
public static Bitmap JLToBitmap(Image img) { Bitmap bm = new Bitmap(img.GetWidth(), img.GetHeight(), PixelFormat.Format32bppRgb); BitmapData bmdata = bm.LockBits(new Rectangle(0, 0, bm.Width, bm.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb); try { RGB888Image vlimage = new RGB888Image(); VisionLab.Convert(img, vlimage); CopyMemory(bmdata.Scan0, vlimage.GetBufPtr(), vlimage.GetWidth() * vlimage.GetHeight() * 4 /*RGB8*/); vlimage.Dispose(); } finally { bm.UnlockBits(bmdata); } return bm; }
public static Bitmap JLToBitmap(Image img) { Bitmap bm = new Bitmap(img.GetWidth(), img.GetHeight(), PixelFormat.Format32bppRgb); BitmapData bmdata = bm.LockBits(new Rectangle(0, 0, bm.Width, bm.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb); try { RGB888Image vlimage = new RGB888Image(); VisionLab.Convert(img, vlimage); CopyMemory(bmdata.Scan0, vlimage.GetBufPtr(), vlimage.GetWidth() * vlimage.GetHeight() * 4 /*RGB8*/); vlimage.Dispose(); } finally { bm.UnlockBits(bmdata); } return(bm); }
/* * 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 * Int32Image binaryPlateImage * Output: * //Image containing binary six characters * ref Int32Image binaryCharacterImage * Return: * //Function executed successfully * bool */ public static bool FindCharacters(RGB888Image plateImage, Int32Image binaryPlateImage, ref Int32Image binaryCharacterImage) { try { VisionLab.SetRGB888Image(cmdInt, "plateImage", plateImage); VisionLab.SetInt32Image(cmdInt, "binaryPlateImage", binaryPlateImage); String result = StripTime(cmdInt.ExecRequest("icall FindCharacters plateImage binaryPlateImage binaryCharacterImage")); if (result == "true") { VisionLab.GetInt32Image(cmdInt, "binaryCharacterImage", binaryCharacterImage); } return(result == "true"); } catch (System.Exception ex) { //if (ex.Message.StartsWith("[DefaultLUTForImage]")) // return false; ////if (ex.Message.Substring(0, 6) == "[DefaultLUTForImage]") //// return false; throw new Exception("FindCharacters: " + ex.Message); } }
public static void TranslateCyclic(RGB888Image src, RGB888Image dest, XYCoord vector) { VisionLabPINVOKE.TranslateCyclic__SWIG_7(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest), XYCoord.getCPtr(vector)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void SwapQuadrants(RGB888Image src, RGB888Image dest) { VisionLabPINVOKE.SwapQuadrants__SWIG_7(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest)); 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; }
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(); }
public static void Zoom(RGB888Image src, RGB888Image dest, double factorX, double factorY, PixelInterpolation pi) { VisionLabPINVOKE.Zoom__SWIG_30(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest), factorX, factorY, (int)pi); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void ConvertRGB888ToOrdImage(RGB888Image src, DoubleImage dest) { VisionLabPINVOKE.ConvertRGB888ToOrdImage__SWIG_6(RGB888Image.getCPtr(src), DoubleImage.getCPtr(dest)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Zoom(RGB888Image src, RGB888Image dest, double factorX, double factorY) { VisionLabPINVOKE.Zoom__SWIG_28(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest), factorX, factorY); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Warp(RGB888Image src, RGB888Image dest, TransformDirection dir, Coord2D leftTop, Coord2D rightTop, Coord2D leftBottom, Coord2D rightBottom, int height, int width, RGB888Pixel border, PixelInterpolation pi) { VisionLabPINVOKE.Warp__SWIG_15(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest), (int)dir, Coord2D.getCPtr(leftTop), Coord2D.getCPtr(rightTop), Coord2D.getCPtr(leftBottom), Coord2D.getCPtr(rightBottom), height, width, RGB888Pixel.getCPtr(border), (int)pi); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RGB888Image obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
/* * 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 * Int32Image binaryPlateImage * Output: * //Image containing binary six characters * ref Int32Image binaryCharacterImage * Return: * //Function executed successfully * bool */ public static bool FindCharacters(RGB888Image plateImage, Int32Image binaryPlateImage, ref Int32Image binaryCharacterImage) { try { //Constants const int c_height = 100; const int c_width = 470; const int c_remove_blobs_min = 1; const int c_remove_blobs_max = 450; XYCoord leftTop = new XYCoord(); XYCoord rightTop = new XYCoord(); XYCoord leftBottom = new XYCoord(); XYCoord rightBottom = new XYCoord(); //Find licenseplate VisionLab.FindCornersRectangle(binaryPlateImage, Connected.EightConnected, 0.5, Orientation.Landscape, leftTop, rightTop, leftBottom, rightBottom); if (!VisionLab.WarpCoordsValid(new Coord2D(leftTop), new Coord2D(rightTop), new Coord2D(leftBottom), new Coord2D(rightBottom))) { VisionLab.FindCornersRectangleSq(binaryPlateImage, Connected.EightConnected, leftTop, rightTop, leftBottom, rightBottom); if (!VisionLab.WarpCoordsValid(new Coord2D(leftTop), new Coord2D(rightTop), new Coord2D(leftBottom), new Coord2D(rightBottom))) { return(false); } } Int32Image plateImageGray = new Int32Image(); VisionLab.Convert(plateImage, plateImageGray); //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); plateImageGray.Dispose(); //*******************************// //** Exercise: **// //** adjust licenseplate **// //** segmentation **// //*******************************// //Find dark text on bright licenseplate using ThresholdISOData VisionLab.ThresholdIsoData(binaryCharacterImage, ObjectBrightness.DarkObject); //Remove small blobs and noise Int32Image binaryCharacterImageCopy = new Int32Image(binaryCharacterImage); VisionLab.Opening(binaryCharacterImageCopy, binaryCharacterImage, new Mask_Int32(5, 1, 1)); //Remove blobs connected to the border VisionLab.RemoveBorderBlobs(binaryCharacterImage, Connected.EightConnected, Border.AllBorders); //Remove small blobs VisionLab.RemoveBlobs(binaryCharacterImage, Connected.EightConnected, BlobAnalyse.BA_Area, c_remove_blobs_min, c_remove_blobs_max); leftTop.Dispose(); rightTop.Dispose(); leftBottom.Dispose(); rightBottom.Dispose(); return(true); } catch (System.Exception ex) { throw new Exception("FindCharacters: " + ex.Message); } }
internal static HandleRef getCPtr(RGB888Image obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }
public static int XYCoordTabFromImage(RGB888Image image, vector_XYCoord tab, RGB888Pixel low, RGB888Pixel high) { int ret = VisionLabPINVOKE.XYCoordTabFromImage__SWIG_15(RGB888Image.getCPtr(image), vector_XYCoord.getCPtr(tab), RGB888Pixel.getCPtr(low), RGB888Pixel.getCPtr(high)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void TextOnImage(RGB888Image image, int left, int top, string font, string text) { VisionLabPINVOKE.TextOnImage__SWIG_7(RGB888Image.getCPtr(image), left, top, font, text); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Zoom(RGB888Image src, RGB888Image dest, HeightWidth hw) { VisionLabPINVOKE.Zoom__SWIG_29(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest), HeightWidth.getCPtr(hw)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Extract1Channel(RGB888Image image, int chanNr, DoubleImage chan) { VisionLabPINVOKE.Extract1Channel__SWIG_36(RGB888Image.getCPtr(image), chanNr, DoubleImage.getCPtr(chan)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Zoom(RGB888Image src, RGB888Image dest, HeightWidth hw, PixelInterpolation pi) { VisionLabPINVOKE.Zoom__SWIG_31(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest), HeightWidth.getCPtr(hw), (int)pi); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Merge3Channels(DoubleImage chan1, DoubleImage chan2, DoubleImage chan3, RGB888Image image) { VisionLabPINVOKE.Merge3Channels__SWIG_30(DoubleImage.getCPtr(chan1), DoubleImage.getCPtr(chan2), DoubleImage.getCPtr(chan3), RGB888Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void ConvertCFAToRGB888Image(Int32Image src, RGB888Image dest, CFAType cfa) { VisionLabPINVOKE.ConvertCFAToRGB888Image__SWIG_8(Int32Image.getCPtr(src), RGB888Image.getCPtr(dest), (int)cfa); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Extract1Channel(RGB888Image image, RGBColor plane, DoubleImage chan) { VisionLabPINVOKE.Extract1Channel__SWIG_73(RGB888Image.getCPtr(image), (int)plane, DoubleImage.getCPtr(chan)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void ConvertToFalseColor(DoubleImage src, RGB888Image lut, RGB888Image dest) { VisionLabPINVOKE.ConvertToFalseColor__SWIG_30(DoubleImage.getCPtr(src), RGB888Image.getCPtr(lut), RGB888Image.getCPtr(dest)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void AddBorder(RGB888Image src, RGB888Image dest, int top, int left, int right, int bottom, RGB888Pixel value) { VisionLabPINVOKE.AddBorder__SWIG_7(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest), top, left, right, bottom, RGB888Pixel.getCPtr(value)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Extract3Channels(RGB888Image image, DoubleImage chan1, DoubleImage chan2, DoubleImage chan3) { VisionLabPINVOKE.Extract3Channels__SWIG_30(RGB888Image.getCPtr(image), DoubleImage.getCPtr(chan1), DoubleImage.getCPtr(chan2), DoubleImage.getCPtr(chan3)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void FastRGBToHSV(RGB888Image src, HSV888Image dest) { VisionLabPINVOKE.FastRGBToHSV(RGB888Image.getCPtr(src), HSV888Image.getCPtr(dest)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Threshold3Channels(RGB888Image image, DoubleImage thresImage, int lowChan1, int highChan1, int lowChan2, int highChan2, int lowChan3, int highChan3) { VisionLabPINVOKE.Threshold3Channels__SWIG_30(RGB888Image.getCPtr(image), DoubleImage.getCPtr(thresImage), lowChan1, highChan1, lowChan2, highChan2, lowChan3, highChan3); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static int CountPixel(RGB888Image image, RGB888Pixel value) { int ret = VisionLabPINVOKE.CountPixel__SWIG_7(RGB888Image.getCPtr(image), RGB888Pixel.getCPtr(value)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void ConvertHSV888ToRGB888Image(HSV888Image src, RGB888Image dest) { VisionLabPINVOKE.ConvertHSV888ToRGB888Image(HSV888Image.getCPtr(src), RGB888Image.getCPtr(dest)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void DiskShape(RGB888Image image, XYCoord centre, double r, RGB888Pixel value, ZeroOrOriginal zorg) { VisionLabPINVOKE.DiskShape__SWIG_14(RGB888Image.getCPtr(image), XYCoord.getCPtr(centre), r, RGB888Pixel.getCPtr(value), (int)zorg); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void BlockPattern(RGB888Image image, XYCoord leftTop, int height, int width, RGB888Pixel value, int repeatx, int repeaty) { VisionLabPINVOKE.BlockPattern__SWIG_15(RGB888Image.getCPtr(image), XYCoord.getCPtr(leftTop), height, width, RGB888Pixel.getCPtr(value), repeatx, repeaty); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Rotate(RGB888Image src, RGB888Image dest, XYCoord centre, double phi, RGB888Pixel borderValue, PixelInterpolation pi) { VisionLabPINVOKE.Rotate__SWIG_15(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest), XYCoord.getCPtr(centre), phi, RGB888Pixel.getCPtr(borderValue), (int)pi); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void CircleShape(RGB888Image image, XYCoord centre, int r, RGB888Pixel value) { VisionLabPINVOKE.CircleShape__SWIG_15(RGB888Image.getCPtr(image), XYCoord.getCPtr(centre), r, RGB888Pixel.getCPtr(value)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static XYCoord RotateFull(RGB888Image src, RGB888Image dest, double phi, RGB888Pixel borderValue, PixelInterpolation pi) { XYCoord ret = new XYCoord(VisionLabPINVOKE.RotateFull__SWIG_15(RGB888Image.getCPtr(src), RGB888Image.getCPtr(dest), phi, RGB888Pixel.getCPtr(borderValue), (int)pi), true); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void DeInterlace(RGB888Image image) { VisionLabPINVOKE.DeInterlace__SWIG_7(RGB888Image.getCPtr(image)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void SetBorders(RGB888Image image, RGB888Pixel value) { VisionLabPINVOKE.SetBorders__SWIG_15(RGB888Image.getCPtr(image), RGB888Pixel.getCPtr(value)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
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); VisionLabEx.DisplayImage(plateImage, imgOrig); //****************// //** Find plate **// //****************// Int32Image binaryPlateImage = new Int32Image(); if (!LicensePlateMatcher.FindPlate(plateImage, ref binaryPlateImage)) { VisionLabEx.DisplayImage(binaryPlateImage, imgPlateBin, true, true); lblLexiconResult.Text = ""; if (add) { lstFindPlateErr.Items.Add(Filename); lblFindPlateErrCount.Text = lstFindPlateErr.Items.Count.ToString(); } ClearResultLabels(); return; } VisionLabEx.DisplayImage(binaryPlateImage, imgPlateBin, true, true); //** //** Enable this to display blob measurements to debug output //** DisplayBlobs(binaryPlateImage); //*******************// //** Rectify plate **// //*******************// Int32Image binaryCharacterImage = new Int32Image(); if (!LicensePlateMatcher.FindCharacters(plateImage, binaryPlateImage, ref binaryCharacterImage)) { 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; } VisionLabEx.DisplayImage(binaryCharacterImage, imgRectifiedPlate, true, true); //** //** Enable this to display blob measurements to debug output //** DisplayBlobs(binaryCharacterImage); //*****************// //** Match Plate **// //*****************// LicensePlate result = new LicensePlate(); LicensePlate lexiconResult = new LicensePlate(); if (!LicensePlateMatcher.MatchPlate(binaryCharacterImage, blobMatcher, lexicon, ref result, ref lexiconResult)) { lblLexiconResult.Text = ""; if (add) { lstMatchPlateErr.Items.Add(Filename); lblMatchPlateErrCount.Text = lstMatchPlateErr.Items.Count.ToString(); } ClearResultLabels(); return; } //*********************// //** Process results **// //*********************// ProcessResults(result, lexiconResult, Filename, (double)nupConfidence.Value / 100, add); bm.Dispose(); plateImage.Dispose(); binaryPlateImage.Dispose(); binaryCharacterImage.Dispose(); //Force a garbage collect to prevens malloc errors from unmanaged code. GC.Collect(); }
/* 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); }