public static Image <Bgr, byte> getAlignedImage(Image <Bgr, byte> image,
                                                        HomoTrans ht)
        {
            Image <Bgr, byte> result = new Image <Bgr, byte>(ht.resolution);

            CvInvoke.WarpPerspective(image, result, ht.h**o, ht.resolution, Emgu.CV.CvEnum.Inter.Linear,
                                     Emgu.CV.CvEnum.Warp.InverseMap, Emgu.CV.CvEnum.BorderType.Constant, new MCvScalar(0, 0, 0, 0));
            return(result);
        }
        public static BulbPoint[] findFlicker(VideoCapture vc, HomoTrans h**o, int durationMs,
                                              int leastFliker = 2, int threshold = 80, int erodeTimes = 2, bool debug = false)
        {
            Mat ele       = CvInvoke.GetStructuringElement(Emgu.CV.CvEnum.ElementShape.Ellipse, new Size(3, 3), new Point(-1, -1));
            int startTime = System.Environment.TickCount;
            Mat pic1      = new Mat();
            Mat pic2      = new Mat();

            vc.Read(pic1);
            vc.Read(pic2);
            Mat diffPicAcc = new Mat();

            do
            {
                Image <Bgr, byte> diffImg =
                    MarkerManager.getAlignedImage(pic1.ToImage <Bgr, byte>(), h**o).AbsDiff(
                        MarkerManager.getAlignedImage(pic2.ToImage <Bgr, byte>(), h**o));
                CvInvoke.CvtColor(diffImg, diffImg, Emgu.CV.CvEnum.ColorConversion.Bgr2Hsv);
                Image <Gray, byte> diffImgValue = diffImg[2].Clone();
                for (int y = 0; y < diffImg.Height; y++)
                {
                    for (int x = 0; x < diffImg.Width; x++)
                    {
                        if (diffImgValue.Data[y, x, 0] < threshold)
                        {
                            diffImgValue.Data[y, x, 0] = 0;
                        }
                        else
                        {
                            diffImgValue.Data[y, x, 0] = 1;
                        }
                    }
                }

                if (diffPicAcc.IsEmpty)
                {
                    diffPicAcc.Create(diffImgValue.Rows, diffImgValue.Cols, Emgu.CV.CvEnum.DepthType.Cv8U, 1);
                    diffPicAcc.SetTo(new MCvScalar(0));
                }
                CvInvoke.Add(diffImgValue, diffPicAcc, diffPicAcc);
                Mat t = pic1;
                pic1 = pic2;
                pic2 = t;
                vc.Read(pic2);
            } while (System.Environment.TickCount - startTime < durationMs);

            Image <Gray, byte> diffPicAccI     = diffPicAcc.ToImage <Gray, byte>();
            Image <Gray, byte> diffPicAccDebug = null;

            if (debug)
            {
                diffPicAccDebug = diffPicAcc.ToImage <Gray, byte>();
            }
            for (int y = 0; y < diffPicAccI.Height; y++)
            {
                for (int x = 0; x < diffPicAccI.Width; x++)
                {
                    if (diffPicAccI.Data[y, x, 0] < leastFliker)
                    {
                        diffPicAccI.Data[y, x, 0] = 0;
                    }
                    else if (debug)
                    {
                        diffPicAccDebug.Data[y, x, 0] = 255;
                    }
                }
            }
            if (debug)
            {
                CvInvoke.Imshow("diffImgAcc", diffPicAccDebug);
            }

            CvInvoke.MorphologyEx(diffPicAccI, diffPicAccI,
                                  Emgu.CV.CvEnum.MorphOp.Erode, ele, new Point(-1, -1), erodeTimes, Emgu.CV.CvEnum.BorderType.Default, new MCvScalar(0));
            CvInvoke.MorphologyEx(diffPicAccI, diffPicAccI,
                                  Emgu.CV.CvEnum.MorphOp.Dilate, ele, new Point(-1, -1), erodeTimes + ERODE_ADDTIONAL_RETRIEVE_COUNT, Emgu.CV.CvEnum.BorderType.Default, new MCvScalar(0));

            List <BulbPoint> result = new List <BulbPoint>();

            for (int y = 0; y < diffPicAccI.Height; y++)
            {
                for (int x = 0; x < diffPicAccI.Width; x++)
                {
                    if (diffPicAccI.Data[y, x, 0] != 0)
                    {
                        Mat    ptsSet         = new Mat();
                        double totalIntensity = hfsMarker(diffPicAccI, x, y, ptsSet, 0, 0);
                        int    px             = (int)(CvInvoke.Mean(ptsSet.Col(0)).V0);
                        int    py             = (int)(CvInvoke.Mean(ptsSet.Col(1)).V0);
                        int    fTimes         = (int)Math.Round(totalIntensity / ptsSet.Rows);
                        result.Add(new BulbPoint(new Point(px, py), h**o.resolution, 0, fTimes));
                    }
                }
            }
            return(result.ToArray());
        }