Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. public static bool FindPlate(RGB888Image plateImage, ref Int32Image binaryPlateImage)
  2. {
  3. try
  4. {
  5. //Constants
  6. const int norm_threshold_h_min = 11;
  7. const int norm_threshold_h_max = 80;
  8. const int norm_threshold_s_min = 100;
  9. const int norm_threshold_s_max = 255;
  10. const int norm_threshold_v_min = 100;
  11. const int norm_threshold_v_max = 255;
  12. const int norm_remove_blobs_min = 1;
  13. const int norm_remove_blobs_max = 1000;
  14.  
  15. const int over_threshold_h_min = 20;
  16. const int over_threshold_h_max = 240;
  17. const int over_threshold_s_min = 30;
  18. const int over_threshold_s_max = 150;
  19. const int over_threshold_v_min = 250;
  20. const int over_threshold_v_max = 255;
  21.  
  22. const int onder_threshold_h_min = 11;
  23. const int onder_threshold_h_max = 85;
  24. const int onder_threshold_s_min = 20;
  25. const int onder_threshold_s_max = 160;
  26. const int onder_threshold_v_min = 30;
  27. const int onder_threshold_v_max = 175;
  28.  
  29. //*******************************//
  30. //** Exercise: **//
  31. //** adjust licenseplate **//
  32. //** segmentation **//
  33. //*******************************//
  34.  
  35. //Find licenseplate
  36. HSV888Image plateImageHSV = new HSV888Image();
  37. Int32Image h = new Int32Image();
  38. Int32Image s = new Int32Image();
  39. Int32Image v = new Int32Image();
  40. //Convert to RGB to HSV
  41. VisionLab.FastRGBToHSV(plateImage, plateImageHSV);
  42. Int32Image binaryPlateImageCopy = new Int32Image(binaryPlateImage);
  43. Int32Image binaryPlateImageCopy2 = new Int32Image(binaryPlateImage);
  44. Int32Image binaryPlateImageCopy3 = new Int32Image(binaryPlateImage);
  45.  
  46. if ("variable naam"== "normaal")
  47. {
  48. //Threshold HSV image
  49. 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);
  50.  
  51. }
  52. else if ("variable naam"== "overbelicht")
  53. {
  54. //Threshold HSV image
  55. 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);
  56.  
  57. }
  58. else if ("variable naam"== "onderbelicht")
  59. {
  60. //Threshold HSV image
  61. 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);
  62. //Return true, if pixels found
  63. }
  64.  
  65. //Remove blobs with small areas
  66. VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_Area, norm_remove_blobs_min, norm_remove_blobs_max);
  67.  
  68. VisionLab.RemoveBorderBlobs(binaryPlateImage, Connected.EightConnected, Border.AllBorders);
  69.  
  70. VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_LengthBreadthRatio, 0, 2.5);
  71.  
  72.  
  73. VisionLab.RemoveBlobs(binaryPlateImage, Connected.EightConnected, BlobAnalyse.BA_NrOfHoles, 0, 5);
  74. //Fill up characters
  75. //VisionLab.FillHoles(binaryPlateImage, Connected.FourConnected);
  76.  
  77. plateImageHSV.Dispose();
  78.  
  79. return (VisionLab.SumIntPixels(binaryPlateImage) > 0);
  80.  
  81. }
  82. catch (System.Exception ex)
  83. {
  84. throw new Exception("FindPlate: " + ex.Message);
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement