Beispiel #1
0
        private static void ParseLightmaps(GND gnd, MemoryStreamReader data)
        {
            uint lightmapCount  = data.ReadUInt();
            int  lightmapWidth  = data.ReadInt();
            int  lightmapHeight = data.ReadInt();
            int  gridSizeCell   = data.ReadInt();
            int  perCell        = lightmapWidth * lightmapHeight * gridSizeCell;

            if (perCell != 64)
            {
                throw new Exception("Non supported lightmap");
            }


            var lightmap = gnd.lightmap = new GND.Lightmap();

            lightmap.count = lightmapCount;
            //lightmap.perCell = perCell;
            lightmap.data = new byte[lightmapCount][];

            for (int i = 0; i < lightmapCount; i++)
            {
                lightmap.data[i] = new byte[256];
                data.Read(lightmap.data[i], 0, 256);
            }
            //data.Read(lightmap.data, 0, lightmap.data.Length);
        }
        /// <summary>
        /// Lodas the MNIST training dataset from disk.
        /// </summary>
        /// <returns>The current dataset.</returns>
        public List <MnistImage> LoadDataset()
        {
            var result = new List <MnistImage>();

            using (var labelReader = new MemoryStreamReader(TrainLabelsFilePath, LabelReader.InitialOffset))
                using (var pixelReader = new MemoryStreamReader(TrainImagesFilePath, PixelReader.InitialOffset))
                {
                    for (var i = 0; i < DatasetSize; i++)
                    {
                        byte label = labelReader.Read(1)[0];

                        byte[] pixels = pixelReader.Read(ImagePixelCount);

                        var img = new MnistImage(label, pixels);

                        result.Add(img);
                    }
                }

            return(result);
        }