Example #1
0
        /// <summary>
        /// Generates a marker layout image and configuration file to be used with ALVAR
        /// tracking library.
        /// 
        /// You can get more ALVAR markers using the SampleMarkerCreator program provided with
        /// ALVAR distribution.
        /// </summary>
        public static void GenerateALVARLayout()
        {
            // Create a layout manager with size 400x400 pixels, and actual marker size of 9 inches
            LayoutManager layout = new LayoutManager(400, 400, 9);

            // Create arrays of marker IDs we want to layout
            // NOTE: Please use the SampleMarkerCreator project that comes with the ALVAR
            // package to generate the raw marker images
            int[] array1 = { 0, 1 };
            int[] array2 = { 2, 3 };

            int[][] marker_arrays = new int[2][];
            marker_arrays[0] = array1;
            marker_arrays[1] = array2;

            // Layout the markers
            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < 2; i++)
                    layout.AddMarker(marker_arrays[j][i], new Point(60 + j * 172, 60 + i * 172),
                        "raw_markers/ALVAR/MarkerData_" + marker_arrays[j][i] + ".png");
            }

            // Set the (0, 0) point in the configuration file to be at (60, 60) in the layout image
            // In this case, it is at the left-upper corner of marker ID 0. 
            layout.ConfigCenter = new Point(60, 60);

            // Compile the layout
            layout.Compile();

            // Output the layout image in gif format
            layout.OutputImage("ALVARArray.gif", ImageFormat.Gif);

            // Output the configuration file
            layout.OutputConfig("ALVARConfig.xml", LayoutManager.ConfigType.ALVAR);

            // Disposes the layout
            layout.Dispose();
        }
Example #2
0
        /// <summary>
        /// Generates a marker layout image and configuration file to be used with NyARToolkit
        /// tracking library for ID based markers.
        /// 
        /// You can get more ID-based markers generated at this site: http://sixwish.jp/AR/Marker/idMarker/
        /// </summary>
        /// 

        public static void GenerateNyARToolkitIdLayout()
        {
            // Create a layout manager with size 1392x1392 pixels, and actual marker size of 40 inches
            LayoutManager layout = new LayoutManager(1392, 1392, 40);

            List<KeyValuePair<string, string>> generalMarkerInfo = new List<KeyValuePair<string, string>>();

            int[] array1 = { 3, 23, 43 };
            int[] array2 = { 63, 83, 103 };
            int[] array3 = { 123, 143, 163 };

            int[][] marker_arrays = new int[3][];
            marker_arrays[0] = array1;
            marker_arrays[1] = array2;
            marker_arrays[2] = array3;

            // Layout the markers
            for (int j = 0; j < 3; j++)
            {
                for (int i = 0; i < 3; i++)
                {
                    int id = marker_arrays[j][i];

                    List<KeyValuePair<string, string>> markerInfo = new List<KeyValuePair<string, string>>();
                    markerInfo.Add(new KeyValuePair<string, string>("patternId", id + ""));
                    markerInfo.AddRange(generalMarkerInfo);

                    layout.AddMarker(id, new Point(123 + j * 423, 123 + i * 423),
                        "raw_markers/NyARToolkitID/nyid-m2_id" + id.ToString("D3") + ".jpg", markerInfo);
                }
            }

            // Set the (0, 0) point in the configuration file to be at (696, 696) in the layout image
            layout.ConfigCenter = new Point(696, 696);

            // Compile the layout
            layout.Compile();

            // Output the layout image in gif format
            layout.OutputImage("NyARToolkitIDArray.gif", ImageFormat.Gif);

            // Output the configuration file
            layout.OutputConfig("NyARToolkitIDArray.xml", LayoutManager.ConfigType.NyARToolkitID);

            // Disposes the layout
            layout.Dispose();
        }
Example #3
0
        /// <summary>
        /// Generates the same marker layout in GenerateALVARLayout using an XML file.
        /// </summary>
        public static void GenerateFromXML()
        {
            // Create a layout manager from an XML file
            //LayoutManager layout = new LayoutManager("SampleALVARLayout.xml");
            LayoutManager layout = new LayoutManager("SampleNyARToolkitLayout.xml");

            // Disposes the layout
            layout.Dispose();
        }
Example #4
0
        /// <summary>
        /// Generates a marker layout image and configuration file to be used with NyARToolkit
        /// tracking library for pattern markers.
        /// </summary>
        public static void GenerateNyARToolkitLayout()
        {
            // Create a layout manager with size 400x400 pixels, and actual marker size of 9 inches
            LayoutManager layout = new LayoutManager(400, 400, 9);

            List<KeyValuePair<string, string>> generalMarkerInfo = new List<KeyValuePair<string, string>>();
            generalMarkerInfo.Add(new KeyValuePair<string, string>("patternWidth", "16"));
            generalMarkerInfo.Add(new KeyValuePair<string, string>("patternHeight", "16"));
            generalMarkerInfo.Add(new KeyValuePair<string, string>("confidence", "0.7"));

            int[] array1 = { 0, 1 };
            int[] array2 = { 2, 3 };

            int[][] marker_arrays = new int[2][];
            marker_arrays[0] = array1;
            marker_arrays[1] = array2;

            // Layout the markers
            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < 2; i++)
                {
                    int id = marker_arrays[j][i];

                    List<KeyValuePair<string, string>> markerInfo = new List<KeyValuePair<string, string>>();
                    markerInfo.Add(new KeyValuePair<string, string>("patternName", "marker" + id + ".patt"));
                    markerInfo.AddRange(generalMarkerInfo);

                    layout.AddMarker(id, new Point(60 + j * 172, 60 + i * 172),
                        "raw_markers/ALVAR/MarkerData_" + id + ".png", markerInfo);
                }
            }

            // Set the (0, 0) point in the configuration file to be at (60, 60) in the layout image
            // In this case, it is at the left-upper corner of marker ID 0. 
            layout.ConfigCenter = new Point(160, 160);

            // Compile the layout
            layout.Compile();

            // Output the layout image in gif format
            layout.OutputImage("NyARToolkitArray.gif", ImageFormat.Gif);

            // Output the configuration file
            layout.OutputConfig("NyARToolkitConfig.xml", LayoutManager.ConfigType.NyARToolkitPattern);

            // Disposes the layout
            layout.Dispose();
        }