private void generateInference() { lbResult.Items.Clear(); lbResult.Items.Add("Los resultados de la inferencia son los siguientes:"); StorageCharacter storageCharacter = null; float matches = 0, percent = 0; for (int i = 0; i < segmentsList.Images.Count; i++) { lbResult.Items.Add("\n Posibilidades para el caracter " + i + " del captcha:"); for (int j = 0; j < storageCharacterList.Count; j++) { storageCharacter = storageCharacterList.ElementAt(j); matches = inference(ResizeImage((Bitmap)segmentsList.Images[i]), ResizeImage(storageCharacter.getBitmap())); percent = matches * 100 / (imageSize * imageSize); if (matches > 500) { lbResult.Items.Add("\n Con un %" + percent + " de probabilidades: " + storageCharacter.getCharacterString()); } } } }
/// <summary> /// Create a list of default storage images of characters. /// </summary> private void GenerateStorageCharacterList() { storageCharacterList = new List <StorageCharacter>(); DirectoryInfo currentDirectory = new DirectoryInfo( Application.StartupPath + "/iaimages/"); int filesSize = currentDirectory.GetFiles("*.*").Count(); int index = 0; if (filesSize > 0) { foreach (FileInfo archivo in currentDirectory.GetFiles("*.JPG")) { Bitmap bitmap = new Bitmap(archivo.FullName); StorageCharacter newStorageCharacter = new StorageCharacter( ResizeImage(bitmap), charactersList.ElementAt(index)); storageCharacterList.Add(newStorageCharacter); index++; } } }