Пример #1
0
        /// <summary>
        /// Generates a marker layout image and configuration file to be used with ALVAR
        /// tracking library.
        /// </summary>
        public static void GenerateALVARLayout()
        {
            // Create a layout manager with size 400x400 pixels and 10 pixels inch (40x40 inches)
            LayoutManager layout = new LayoutManager(400, 400, 10);

            // Begin a coordinate frame (ALVAR does not need name or min_points)
            layout.BeginCoordframe("");

            // 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");
                }
            }

            // End "ground" coordinate frame
            layout.EndCoordframe();

            // 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");

            // Disposes the layout
            layout.Dispose();
        }
Пример #2
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("SampleLayout.xml");

            // Compile the layout
            layout.Compile();

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

            // Output the configuration file
            layout.OutputConfig("ALVARConfigFromXML.txt");

            // Disposes the layout
            layout.Dispose();
        }
Пример #3
0
        /// <summary>
        /// Generates a marker layout image and configuration for Tutorial 8 ground marker array.
        /// </summary>
        public static void GenerateTutorial8Grid()
        {
            LayoutManager layout = new LayoutManager(1080, 594, 108 / 32.4f);

            layout.BeginCoordframe("");

            int[] array1 = { 0, 1, 2, 3, 4, 5, 6 };
            int[] array2 = { 7, 8, 9, 10, 11, 12, 13 };
            int[] array3 = { 14, 15, 16, 17, 18, 19, 20 };
            int[] array4 = { 21, 22, 23, 24, 25, 26, 27 };

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

            for (int j = 0; j < 4; j++)
            {
                for (int i = 0; i < 7; i++)
                {
                    layout.AddMarker(marker_arrays[j][i], new Point(i * 162, j * 162),
                                     "raw_markers/ALVAR/MarkerData_" + marker_arrays[j][i] + ".png");
                }
            }

            // End "ground" coordinate frame
            layout.EndCoordframe();

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

            // Compile the layout
            layout.Compile();

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

            // Output the configuration file
            layout.OutputConfig("Tutorial8Ground.xml");

            // Disposes the layout
            layout.Dispose();
        }
Пример #4
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();
        }
Пример #5
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();
        }
Пример #6
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();
        }