/// <summary> /// Gets the data from the file system. /// </summary> /// <returns></returns> public override MnistImageBatch GetData() { int[] label = LabelReader.ReadLabels(BatchSize); double[][] pixels = PixelReader.ReadPixels(BatchSize, ImageSizeInPixels); pixels = NormalizePixels(pixels); var result = new MnistImageBatch(label, pixels); return(result); }
private void MouseHook_MouseUp() { rMouseUpAction?.Invoke(lastLocation); //Set color DropperColor = PixelReader.GetColorAt(lastLocation); //Reset mouse hook MouseHook.StopHook(); MouseHook.LMouseUp -= MouseHook_MouseUp; MouseHook.MouseMoved -= MouseHook_MouseMoved; MouseHook.DisableRMouseDown = false; MouseHook.DisableRMouseUp = false; }
private int GetLeftBandingWidth() { double segmentWidthPercent = this.BlackSegmentHeight / 100.00; int leftHalfWidth = _captureWidth / 2; int segmentWidthPixels = Convert.ToInt32(_captureWidth * segmentWidthPercent); if (segmentWidthPixels <= 0) { segmentWidthPixels = 1; } //TODO log info segmentWidthPixels int blackHeight = 0; //iterate long segments for (int i = 0; i < leftHalfWidth; i += segmentWidthPixels) { //create region Rectangle region = new Rectangle(i, _topOffset, segmentWidthPixels, _captureHeight); PixelReader pixelReader = new PixelReader(_fastBitmap, region); // Average the pixels int r = 0, g = 0, b = 0, pixelCount = 0; foreach (var pixel in pixelReader.GetEveryNthPixel(this.PixelSkip)) { r += pixel.R; g += pixel.G; b += pixel.B; pixelCount++; } int redAvg = r / pixelCount; int greenAvg = g / pixelCount; int blueAvg = b / pixelCount; if (redAvg <= this.DarknessThreshold && greenAvg <= this.DarknessThreshold && blueAvg <= this.DarknessThreshold) { blackHeight = i + segmentWidthPixels; } } return(blackHeight); }
static async Task Main(string[] args) { #if DEBUG if ((args?.Length ?? 0) == 0) { args = new[] { @"C:\data\sample.mp4", "0.47", "0.47", "0.06", "0.06", }; Console.WriteLine("*** This is Debug Arguments. ***" + Environment.NewLine); } #endif if (args.Length < 5) { Console.WriteLine("Argument Error. VideoPixelReader.exe [video_path] [x] [y] [width] [height]"); return; } try { var path = args[0]; var x = double.Parse(args[1]); var y = double.Parse(args[2]); var width = double.Parse(args[3]); var height = double.Parse(args[4]); if (File.Exists(path)) { var reader = new PixelReader(path, new RectRatio(x, y, width, height)); await reader.Start(); } Console.WriteLine(Environment.NewLine + "End!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } #if DEBUG Console.ReadKey(); #endif }
public IDictionary <Core.Light, Core.PixelReader> Capture(ILightSetupPlugin lightSetup) { _graphics.CopyFromScreen(_dispBounds.Left, _dispBounds.Top, 0, 0, new Size(_dispBounds.Width, _dispBounds.Height)); _fastBitmap = new FastBitmap(_img); GetCaptureSize(); IDictionary <Core.Light, Core.PixelReader> dictionary = new Dictionary <Core.Light, Core.PixelReader>(); foreach (Light light in lightSetup.GetLightsForBounds(_captureWidth, _captureHeight, _leftOffset, _topOffset)) { dictionary[light] = new PixelReader(_fastBitmap, light.Region); } return(dictionary); }
public IDictionary <Core.Light, Core.PixelReader> Capture(ILightSetupPlugin lightSetup) { IDictionary <Core.Light, Core.PixelReader> dictionary = new Dictionary <Core.Light, Core.PixelReader>(); if (_currentResponse != null) { _capturedImage = _currentResponse.CapturedBitmapAsImage; _fastBitmap = new FastBitmap(_capturedImage); foreach (var light in lightSetup.GetLightsForBounds(_capturedImage.Width, _capturedImage.Height, 0, 0)) { dictionary[light] = new PixelReader(_fastBitmap, light.Region); } } if (_captures > 0 && _captures % 10 == 0) { Console.WriteLine("Time per capture: {0}", new TimeSpan(0, 0, 0, 0, (int)(DateTime.Now - _startTime).TotalMilliseconds / _captures)); } return(dictionary); }
public async Task <PixelResult> GetPixel(GetPixelRequest model) { var game = await GameCache.GetGame(model.GameId); if (game == null) { return(new PixelResult(false, "Game not found")); } if (Context.IsAuthenticated()) { if (game.Status == GameStatus.Started) { var userId = Context.GetUserId(); var rateLimitResult = await CheckRateLimits(userId, game); if (!string.IsNullOrEmpty(rateLimitResult)) { return(new PixelResult(false, rateLimitResult)); } var clickResult = await PixelWriter.AddClick(userId, new AddClickRequest(model.GameId, model.X, model.Y)); if (!clickResult.Success) { return(new PixelResult(false, clickResult.Message)); } } } var result = await PixelReader.GetPixel(model.GameId, model.X, model.Y); if (result == null) { return(new PixelResult(false, "Pixel not found.")); } return(new PixelResult(result)); }
public IDictionary <Core.Light, Core.PixelReader> Capture(ILightSetupPlugin lightSetup) { IDictionary <Core.Light, Core.PixelReader> dictionary = new Dictionary <Core.Light, Core.PixelReader>(); Capture.Interface.Screenshot response = null; if (_capturedProcess != null && _capturedProcess.CaptureInterface != null) { response = _capturedProcess.CaptureInterface.GetScreenshot(); } if (response != null) { Interlocked.Increment(ref _captures); } Interlocked.Exchange(ref _currentResponse, response); if (_currentResponse != null) { using (System.IO.MemoryStream ms = new System.IO.MemoryStream(_currentResponse.CapturedBitmap)) _capturedImage = new Bitmap(ms); _fastBitmap = new FastBitmap(_capturedImage); foreach (var light in lightSetup.GetLightsForBounds(_capturedImage.Width, _capturedImage.Height, 0, 0)) { dictionary[light] = new PixelReader(_fastBitmap, light.Region); } } if (_captures > 0 && _captures % 10 == 0) { AfterglowRuntime.Logger.Debug("Time per capture: {0}", new TimeSpan(0, 0, 0, 0, (int)((DateTime.Now - _startTime).TotalMilliseconds / _captures))); } return(dictionary); }
void Start() { pixelReader = new PixelReader(); LoadObstacleFormation(); topBorder = CameraController.instance.HEIGHT_HALF - GridSystem.instance.cellSize / 2; //Generate(); }
public override void OnInspectorGUI() { PixelReader pixelReader = (PixelReader)target; DrawDefaultInspector(); //pixelReader.x = EditorGUILayout.IntField("X axis", pixelReader.x); //pixelReader.y = EditorGUILayout.IntField("Y axis", pixelReader.y); EditorGUILayout.LabelField("RGB Color: ", ColorUtility.ToHtmlStringRGBA(pixelReader.testPixelColor)); x = EditorGUILayout.IntField("tilemaps: ", x); if (pixelReader.pixelData != null) { EditorGUILayout.LabelField("Texture Width: ", pixelReader.pixelData.textureWidth.ToString()); EditorGUILayout.LabelField("Texture Height: ", pixelReader.pixelData.textureHeight.ToString()); } // Buttons if (GUILayout.Button("Generate new Grid")) { if (pixelReader.tileMap == null) { GameObject grid = TileMapAdder.AddGameObject("Tile Grid", x); pixelReader.targetTileGrid = grid.GetComponent <Grid>(); for (int i = 0; i < x; i++) { pixelReader.tiles.tilemaps.Add(grid.transform.GetChild(i).GetComponent <Tilemap>()); } pixelReader.tiles.tileWrapper.listOfColorTileHolder = new List <ColorTileHolder>(); foreach (var pix in pixelReader.tiles.tileWrapper.listOfColorTileHolder) { pix.colorTiles = new List <ColorTile>(); } } } if (GUILayout.Button("ShowRGBA values")) { pixelReader.DebugRGBA(); pixelReader.ShowPixelValue(); pixelReader.pixelData.DebugNames(); } if (GUILayout.Button("Generate Grid TileTest")) { pixelReader.PlaceTiles(pixelReader.tileMap); } if (GUILayout.Button("Generate Grid TileTestperLayer")) { pixelReader.SetupTiles(); pixelReader.DebugProperties(); } if (GUILayout.Button("Generate Room")) { pixelReader.StartCoroutine(pixelReader.GenerateTiles()); } if (GUILayout.Button("Stop")) { pixelReader.StopAllCoroutines(); } if (GUILayout.Button("Load Colors") && pixelReader.platformImage != null) { pixelReader.LoadColorPalette(); } if (GUILayout.Button("Load Palette Set") && pixelReader.platformImage != null) { pixelReader.LoadColorPaletteSet(); } if (GUILayout.Button("Delete Cubes")) { GameObject[] objects; objects = GameObject.FindGameObjectsWithTag("Test"); foreach (var x in objects) { DestroyImmediate(x); } } }
public async Task <ActionResult> GetPixelHistory(DataTablesParam model) { return(DataTable(await PixelReader.GetUserHistory(model, User.Identity.GetUserId <int>(), null))); }