コード例 #1
0
 /*
  *  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, ref LicensePlate result)
 {
     try
     {
         VisionLab.SetInt32Image(cmdInt, "binaryCharacterImage", binaryCharacterImage);
         String plateStr = StripTime(cmdInt.ExecRequest("icall MatchPlate binaryCharacterImage"));
         if (plateStr.Substring(0, 5) != "false")
         {
             string[] plateResult      = plateStr.Split(' ');
             string   plateResultChars = plateResult[0];
             result.confidence = double.Parse(plateResult[1], CultureInfo.InvariantCulture);
             for (int c = 0; c < 6; c++)
             {
                 result.characters.Add(new LicenseCharacter(plateResultChars[c].ToString(), double.Parse(plateResult[2 + c], CultureInfo.InvariantCulture), result.confidence));
             }
             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);
         }
         else
         {
             return(false);
         }
     }
     catch (System.Exception ex)
     {
         throw new Exception("MatchPlate: " + ex.Message);
     }
 }
コード例 #2
0
 /*
  *  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);
     }
 }