public void PaintSlots(String parkingName, ref Hashtable parkinglist, int counter, Bitmap bmModel, Bitmap bmFrame, Bitmap[] SlotsFrames, Bitmap[] ParkingSlotsModel, Point[] ParkingPoint, Graphics graphics, parkingSlot parkings)
        {
            for (int i = 0; i < (counter); i++)
            {
                parkings.QuadrilateralSlotsTransformation(ParkingPoint, ParkingSlotsModel, bmModel, i); //
                parkings.QuadrilateralSlotsTransformation(ParkingPoint, SlotsFrames, bmFrame, i);

                Subtract filter = new Subtract(ParkingSlotsModel[i]);
                Bitmap resultImage = filter.Apply(SlotsFrames[i]);

                Boolean boolean = false;
                int valueToCompare = 130;

                boolean = parkings.emptyOrFull(resultImage, valueToCompare);

                if (boolean)
                {
                    int cont = i + 1;

                    //MessageBox.Show(parkingName + " full lot #" + cont);
                    parkinglist[parkingName + cont] = "Ocupado";
                    Color color = new Color();
                    color = Color.FromArgb(0x30FF0000);
                    Point[] parkingLot = { ParkingPoint[0 + (4 * i)], ParkingPoint[1 + (4 * i)],
                                         ParkingPoint[2 + (4 * i)], ParkingPoint[3 + (4 * i)] };
                    graphics.DrawPolygon(new Pen(Color.Gray, 3), parkingLot);
                    graphics.FillPolygon(new SolidBrush(color), parkingLot);
                }
                else
                {
                    int resu = i + 1;
                    parkinglist[parkingName + resu] = "Vacio";
                    Point[] parkingLot = { ParkingPoint[0 + (4 * i)], ParkingPoint[1 + (4 * i)],
                                         ParkingPoint[2 + (4 * i)], ParkingPoint[3 + (4 * i)] };
                    graphics.DrawPolygon(new Pen(Color.Gray, 3), parkingLot);
                    graphics.FillPolygon(new SolidBrush(Color.FromArgb(0x3000ff00)), parkingLot);
                }

            }
        }
        private Hashtable OccupancyChecker()
        {
            // Se pintan que aparcamientos estan ocupados.
               // parkingC = homeForm.parkingC;
            Bitmap cFrame = null;
            Bitmap mFrame = null;
            do
            {
                try {
                    cFrame = (Bitmap)currentFrame.Clone();
                    mFrame = new Bitmap(@"lastImage.jpg");
                }

                catch {
                    cFrame = null;
                    mFrame = null;
                }

            } while (cFrame == null || mFrame == null);

            parkingC.rgb2hsv(cFrame);
            parkingC.rgb2hsv(mFrame);

            //MessageBox.Show("Compare process about to begin. The RGB image has been change to HSV colour space, which will shows only Saturation");

            int upperCont = parkingC.UpperParkingPoint.Length / 4;
            int downerCont = parkingC.DownParkingPoints.Length / 4;

            Bitmap[] upperSlotsFrames = new Bitmap[(upperCont)];
            parkingC.UpperParkingSlotsModel = new Bitmap[(upperCont)];

            Bitmap[] downParkingSlotsFrames = new Bitmap[(downerCont)];
            parkingC.DownParkingSlotsModel = new Bitmap[(downerCont)];

            //Bitmap paintedF = new Bitmap(@"currImage.jpg");
            Bitmap paintedF = (Bitmap)currentFrame.Clone();

            Graphics graphics = Graphics.FromImage(paintedF);
            parkingSlot parkings = new parkingSlot();

            Hashtable parkingList = parkingC.ParkingList;

            parkings.PaintSlots("A", ref parkingList, upperCont, mFrame, cFrame, upperSlotsFrames, parkingC.UpperParkingSlotsModel, parkingC.UpperParkingPoint, graphics, parkings);
            parkings.PaintSlots("B", ref parkingList, downerCont, mFrame, cFrame, downParkingSlotsFrames, parkingC.DownParkingSlotsModel, parkingC.DownParkingPoints, graphics, parkings);

            pictureBox4.Image = paintedF;
               // pictureBox4.SizeMode = PictureBoxSizeMode.StretchImage;

            return parkingList;
        }