Esempio n. 1
0
        /* private void detCap()
         * {
         *   while(Thread.CurrentThread.IsAlive)
         *   {
         *       detectionCapture();
         *   }
         * }*/

        private void detectionCapture(object sender, EventArgs e)
        {
            if (!shuttingDown)
            {
                currentFrame = _cap.QueryFrame().ToImage <Bgr, byte>();

                DateTime timeNow = DateTime.Now;

                string S = destFolder + "  " + timeNow.ToString();
                CvInvoke.PutText(currentFrame, S, new Point(10, 25), FontFace.HersheyComplex, 0.5, new Bgr(0, 0, 255).MCvScalar);
                List <Rectangle> subjects;
                if (useCuda)
                {
                    subjects = detectionCuda.FilterImage(currentFrame);
                }
                else
                {
                    subjects = detection.filterImage(currentFrame);
                }

                if (subjects.Count > 0)
                {
                    detected = true;
                    Image <Bgr, byte> detectedImage;
                    if (useCuda)
                    {
                        detectedImage = detectionCuda.drawRectangles(subjects, currentFrame);
                    }
                    else
                    {
                        detectedImage = detection.drawRectangles(subjects, currentFrame);
                    }
                    string     rndm     = new Random().Next(1000, 10000).ToString();
                    frameClass detFrame = new frameClass(detectedImage, timeNow.ToString("yyyy-dd-M--HH-mm-ss-ms") + "-[DETECTED " + rndm + "]");
                    imageBox.Image = detectedImage;
                    imageBox.Invalidate();
                    log.ActWrite("Detected Subject at [" + timeNow.ToString("yyyy-dd-M--HH-mm-ss-ms") + "]");
                    Console.WriteLine("Cotcha!");
                    frameQueue.Add(detFrame);
                }
                else
                {
                    detected       = false;
                    imageBox.Image = currentFrame;
                    imageBox.Invalidate();
                }
            }
        }
Esempio n. 2
0
        private void NormalCapture(object sender, EventArgs e)
        {
            if (!shuttingDown)
            {
                if (!detected)
                {
                    Image <Bgr, byte> currentFrame = _cap.QueryFrame().ToImage <Bgr, byte>();
                    DateTime          timeNow      = DateTime.Now;

                    string S = destFolder + "  " + timeNow.ToString();
                    CvInvoke.PutText(currentFrame, S, new Point(10, 25), FontFace.HersheyComplex, 0.5, new Bgr(0, 0, 255).MCvScalar);
                    frameClass P = new frameClass(currentFrame, timeNow.ToString("yyyy-dd-M--HH-mm-ss-ms"));
                    frameQueue.Add(P);
                    log.ActWrite(timeNow.ToString("yyyy-dd-M--HH-mm-ss"));
                }
            }
        }