Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool FindPlate(RGB888Image plateImage, ref Int32Image binaryPlateImage)
- {
- try
- {
- //Constants
- const int norm_threshold_h_min = 11;
- const int norm_threshold_h_max = 80;
- const int norm_threshold_s_min = 100;
- const int norm_threshold_s_max = 255;
- const int norm_threshold_v_min = 100;
- const int norm_threshold_v_max = 255;
- const int norm_remove_blobs_min = 1;
- const int norm_remove_blobs_max = 1000;
- const int over_threshold_h_min = 20;
- const int over_threshold_h_max = 240;
- const int over_threshold_s_min = 30;
- const int over_threshold_s_max = 150;
- const int over_threshold_v_min = 250;
- const int over_threshold_v_max = 255;
- const int onder_threshold_h_min = 11;
- const int onder_threshold_h_max = 85;
- const int onder_threshold_s_min = 20;
- const int onder_threshold_s_max = 160;
- const int onder_threshold_v_min = 30;
- const int onder_threshold_v_max = 175;
- //*******************************//
- //** Exercise: **//
- //** adjust licenseplate **//
- //** segmentation **//
- //*******************************//
- //Find licenseplate
- HSV888Image plateImageHSV = new HSV888Image();
- Int32Image h = new Int32Image();
- Int32Image s = new Int32Image();
- Int32Image v = new Int32Image();
- //Convert to RGB to HSV
- VisionLab.FastRGBToHSV(plateImage, plateImageHSV);
- Int32Image binaryPlateImageCopy = new Int32Image(binaryPlateImage);
- Int32Image binaryPlateImageCopy2 = new Int32Image(binaryPlateImage);
- Int32Image binaryPlateImageCopy3 = new Int32Image(binaryPlateImage);
- if ("variable naam"== "normaal")
- {
- //Threshold HSV image
- VisionLab.Threshold3Channels(plateImageHSV, binaryPlateImage, norm_threshold_h_min, norm_threshold_h_max, norm_threshold_s_min, norm_threshold_s_max, norm_threshold_v_min, norm_threshold_v_max);
- }
- else if ("variable naam"== "overbelicht")
- {
- //Threshold HSV image
- VisionLab.Threshold3Channels(plateImageHSV, binaryPlateImage, over_threshold_h_min, over_threshold_h_max, over_threshold_s_min, over_threshold_s_max, over_threshold_v_min, over_threshold_v_max);
- }
- else if ("variable naam"== "onderbelicht")
- {
- //Threshold HSV image
- VisionLab.Threshold3Channels(plateImageHSV, binaryPlateImage, onder_threshold_h_min, onder_threshold_h_max, onder_threshold_s_min, onder_threshold_s_max, onder_threshold_v_min, onder_threshold_v_max);
- //Return true, if pixels found
- }
- //Remove blobs with small areas
- VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_Area, norm_remove_blobs_min, norm_remove_blobs_max);
- VisionLab.RemoveBorderBlobs(binaryPlateImage, Connected.EightConnected, Border.AllBorders);
- VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_LengthBreadthRatio, 0, 2.5);
- VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_NrOfHoles, 0, 5);
- //Fill up characters
- //VisionLab.FillHoles(binaryPlateImage, Connected.FourConnected);
- plateImageHSV.Dispose();
- return (VisionLab.SumIntPixels(binaryPlateImage) > 0);
- }
- catch (System.Exception ex)
- {
- throw new Exception("FindPlate: " + ex.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement