private bool isAlive(Color xColor, int x, int y) { //CHECK IS ALIVE if (x == 0 && y == 0) { Black = false; FrameCounter++; } else if (!Black && !Mod_Check.isGray(xColor, 150)) { Black = true; } if (Black) { Color after = xColor; if (xColor.R != 255 && xColor.G != 255 && xColor.B != 255) { after = Color.FromArgb(xColor.A, xColor.R + 1, xColor.G + 1, xColor.B + 1); } Color before = xColor; if (xColor.R != 0 && xColor.G != 0 && xColor.B != 0) { before = Color.FromArgb(xColor.A, xColor.R - 1, xColor.G - 1, xColor.B - 1); } Color last = LastFrameCam.GetPixel(x, y); if (last != xColor && last != after && last != before) { FrameCounter = 0; return(true); } else { return(false); } } //FRAME FREEZE if (FrameCounter > FrameFreeze) { return(false); } else { return(true); } }
private void ModeHSensor(Bitmap xBmp, PaintEventArgs e) { //HSENSOR MODE Graphics g = e.Graphics; //GENERATE SENSOR DATA double max = xBmp.Width; double[] sensor = new double[xBmp.Height]; for (int y = 0; y < xBmp.Height; y++) { int count = 0; for (int x = 0; x < xBmp.Width; x++) { Color getColor = xBmp.GetPixel(x, y); if (Mod_Check.isGray(getColor, 200)) { count++; } else { if (Mod_Check.isEven(y)) //DISPLAY EVERY SECOND SENSOR { g.DrawLine(Pen, new Point(0, y), new Point(count, y)); //DRAW SENSOR TO CAMERA Graphics.FromImage(xBmp).DrawLine(Pen, new Point(0, y), new Point(count, y)); //DRAW SENSOR TO SCREEN } sensor[y] = count / max; count = 0; break; } } } //SET BINARY IMAGE NetMain.PanelBinary.BackgroundImage = NetDraw.ScaleUp(new Bitmap(xBmp)); LastSensor = sensor; g.Dispose(); }