Example #1
0
        public List<MarkerLabel> FindMarkers(ComponentFinder componentFinder, RegionAdjacencyGraph regionAdjacencyGraph)
        {
            if (componentFinder.ObjectCount == 0)
            {
                return null;
            }

            List<MarkerLabel> markers = new List<MarkerLabel>();

            int objectCount = componentFinder.ObjectCount;
            List<int>[] adjacencyList = regionAdjacencyGraph.AdjacencyList;
            byte[] objectClassifications = componentFinder.ObjectClassifications;

            for (int i = 0; i < objectCount; i++)
            {
                // Apply root marker rules to determine if the region is a possible marker
                if (objectClassifications[i] == markerRootClassification
                    && adjacencyList[i].Count > minimumBranches
                    && adjacencyList[i].Count <= maximumBranches + 1)
                {
                    // Candidate marker
                    string markerCode = "";
                    if (VerifyRoot(adjacencyList, objectClassifications, i, out markerCode))
                    {
                        markers.Add(new MarkerLabel(i, markerCode));
                    }
                }

            }
            return markers;
        }
Example #2
0
        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();
        }