public static void addTrainingPoint(Bgr[] samples, Stack.Color correctColor) { DataSet dataSet = new DataSet(); dataSet.Inputs = convertBgrListToInputArray(samples); dataSet.Outputs = convertChipColorToOutput(correctColor); Instance.trainingData.Add(dataSet); retrain(); }
public static void trainChip(Image <Bgr, Byte> img, Point[] samplePoints, Stack.Color color) { List <Bgr> colorSamples = new List <Bgr>(); foreach (Point point in samplePoints) { colorSamples.Add(img[point]); } ColorFinder.addTrainingPoint(colorSamples.ToArray(), color); }
private static double[] convertChipColorToOutput(Stack.Color chipColor) { List <double> correctOutputs = new List <double>(); foreach (Stack.Color color in Enum.GetValues(typeof(Stack.Color))) { if (color.Equals(chipColor)) { correctOutputs.Add(1.0); } else { correctOutputs.Add(0.0); } } return(correctOutputs.ToArray()); }