private void createMapButton_Click(object sender, EventArgs e) { for (int i = 0; i < imagePaths[0].Count; i++) { using (Bitmap source = new Bitmap(imagePaths[0][i])) using (Bitmap mask = new Bitmap(imagePaths[1][i])) { probabilityMap = new ProbabilityMap(); probabilityMap.TrainHistograms(source, mask); } } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = xmlPath; saveFileDialog.Filter = "Histogram Files|*.hst|All Files|*.*"; saveFileDialog.FilterIndex = 0; MessageBox.Show("Training data created successfully. Please select a location to save to."); if (saveFileDialog.ShowDialog() == DialogResult.OK) this.probabilityMap.SaveHistograms(saveFileDialog.FileName); //if (this.probabilityMap != null) //this.probabilityMap.CreateMaps(); }
private void thresholdOpenLabel_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); openFileDialog.Filter = "Histograms|*.hst|All Files|*.*"; openFileDialog.FilterIndex = 0; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // Initialise Probability Map this.probabilityMap = new ProbabilityMap(openFileDialog.FileName); // Convert histograms into probability maps this.probabilityMap.CreateMaps(); } }
public MainForm( ) { InitializeComponent( ); cameraFpsLabel.Text = string.Empty; permittedCodesLabel.Text = string.Empty; // initialise filters grayFilter = new AForge.Imaging.Filters.Grayscale(0.2125, 0.7154, 0.0721); otsuFilter = new AForge.Imaging.Filters.OtsuThreshold(); // image buffers grayBuffer = new Bitmap(DesiredWidth, DesiredHeight, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); // component finder componentFinder = new ComponentFinder(); // rag constructor regionAdjacencyGraph = new RegionAdjacencyGraph(DesiredWidth, DesiredHeight); // Marker Detector markerDetector = new MarkerDetector(); // Worker resetEvent = new ManualResetEvent(false); frameMutex = new Mutex(false); //RNM // Image exporter imageExporter = new ImageExporter(this.ExportImage); openFileDialog = new SaveFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); openFileDialog.Filter = "Bitmap Images|*.bmp|JPEG Images|*.jpg|PNG Images|*.png|All Files|*.*"; // Probability maps probabilityMap = null; //xml markerStreamProducer = new MakerStreamProducer(PORT); markerStreamProducer.Start(); xmlDocument = new XmlDocument(); xmlDocument.LoadXml("<!DOCTYPE CERAMICS [<!ELEMENT STREAMS (STREAM+)><!ELEMENT STREAM (MARKER+)><!ELEMENT MARKER (EMPTY)><!ATTLIST STREAM DATE CDATA #REQUIRED><!ATTLIST STREAM ID CDATA #REQUIRED><!ATTLIST MARKER CODE CDATA #REQUIRED><!ATTLIST MARKER TIMESTAMP CDATA #REQUIRED><!ATTLIST MARKER X1 CDATA #REQUIRED><!ATTLIST MARKER Y1 CDATA #REQUIRED><!ATTLIST MARKER X2 CDATA #REQUIRED><!ATTLIST MARKER Y2 CDATA #REQUIRED>]><stream></stream>"); XmlElement root = xmlDocument.DocumentElement; root.SetAttribute("date",DateTime.Now.Date.ToString().Substring(0,10)); root.SetAttribute("id", "0001"); Console.WriteLine(xmlDocument.OuterXml); xmlDocument.Save(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\dtd.xml"); displayDeviceList(); }