Exemple #1
0
        public void Motion2aMultipleCompare()
        {
            try
            {
                //images in memory when sent to the
                ByteWrapper image1 = ImageConvert.ReturnByteWrapper(@"F:\temp\analysis\640x480\test_0.jpg");
                ByteWrapper image2 = ImageConvert.ReturnByteWrapper(@"F:\temp\analysis\640x480\test_1.jpg");

                PixelMatrix dummy = new PixelMatrix();
                dummy.LinkCompare = true;
                dummy.Populate(new BitmapWrapper(ImageConvert.ReturnBitmap(image1.bytes)), new BitmapWrapper(ImageConvert.ReturnBitmap(image2.bytes)));

                MotionSensor_2a motion = new MotionSensor_2a();
                motion.ThresholdSet         = true;
                motion.settings.linkCompare = true;
                motion.Comparison           = dummy.Comparision;

                motion.ImageCreated(image1, EventArgs.Empty);
                motion.ImageCreated(image2, EventArgs.Empty);

                motion.ImageCreated(image1, EventArgs.Empty);
                motion.ImageCreated(image2, EventArgs.Empty);


                Assert.IsTrue(true);
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
        /// <summary>
        /// called once the Setups are complete
        /// </summary>
        private void Go()
        {
            //create the motion sensor, and listen for images
            MotionSensor_2a motionSensor = new MotionSensor_2a();

            motionSensor.settings = settings == null ? motionSensor.settings = new MotionSensorSettings() : motionSensor.settings = settings;

            motionSensor.motionDetected   += new MotionSensor_2.MotionDetected(MotionDetected); //set up the motion detector hook
            motionSensor.logging.LoggingOn = true;

            //create the validator
            ImageValidator imageValidator = new ImageValidator();

            imageValidator.ListenForImages(imageExtractor);

            imageExtractor.asyncrohous = settings.asynchronous;

            if (settings.asynchronous)
            {
                imageValidator.imageValidated += new ImageValidator.ImageValidatedEvent(motionSensor.ImageCreatedAsync); //subscribe to events from the validator
            }
            else
            {
                imageValidator.imageValidated += new ImageValidator.ImageValidatedEvent(motionSensor.ImageCreated); //subscribe to events from the validator
            }

            if (timedTest)
            {
                testTimer = new Stopwatch(); testTimer.Start();
            }

            imageExtractor.Run();

            //if here and async then the motion detector is likely still going
            //wait for i to finish and record the lag
            if (settings.asynchronous && timedTest)
            {
                imageExtractionEnd = DateTime.Now;
                while (motionSensor.logging.imagesReceived + 3 < expectedFrames)
                {
                    System.Threading.Thread.Sleep(250);
                }

                testTimer.Stop();
            }
            else
            {
                testTimer.Stop();
            }
        }
Exemple #3
0
        public void Motion2aSubequent()
        {
            try
            {
                List <int> dimensions = ReturnDimensions();
                Stopwatch  sw         = new Stopwatch();
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"f:\temp\runtime\motion_analysis.txt", true))
                {
                    for (int i = 0; i < dimensions.Count; i++)
                    {
                        for (int n = 0; n < 200; n++)
                        {
                            //images in memory when sent to the
                            ByteWrapper image1 = ImageConvert.ReturnByteWrapper(@"F:\temp\analysis\640x480\test_0.jpg");
                            image1.sequenceNumber = i;
                            ByteWrapper image2 = ImageConvert.ReturnByteWrapper(@"F:\temp\analysis\640x480\test_1.jpg");
                            image2.sequenceNumber = i;


                            PixelMatrix dummy = new PixelMatrix();
                            dummy.LinkCompare = true;
                            dummy.SearchWidth = dimensions[i];
                            dummy.Populate(new BitmapWrapper(ImageConvert.ReturnBitmap(image1.bytes)), new BitmapWrapper(ImageConvert.ReturnBitmap(image2.bytes)));


                            sw.Restart();
                            MotionSensor_2a motion = new MotionSensor_2a();
                            motion.ThresholdSet         = true;
                            motion.settings.linkCompare = true;
                            motion.settings.searchWidth = dimensions[i];
                            motion.Comparison           = dummy.Comparision;

                            motion.ImageCreated(image1, EventArgs.Empty);
                            motion.ImageCreated(image2, EventArgs.Empty);

                            motion.ImageCreated(image1, EventArgs.Empty);
                            motion.ImageCreated(image2, EventArgs.Empty);
                            sw.Stop();
                            file.WriteLine(i + " - " + n + " - " + " no grid - " + sw.Elapsed.TotalMilliseconds);
                        }
                    }
                }
                Assert.IsTrue(true);
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
        public void Run(string captureKey)
        {
            //set up the extractor
            string uri = "http://*****:*****@"F:\temp\MotionSensor\2.1\movement\info.txt";
            motionSensor.motionDetected += new MotionSensor_2.MotionDetected(MotionDetected);

            //create the validator 
            ImageValidator imageValidator = new ImageValidator();
            imageValidator.ListenForImages(imageExtractor);
            imageValidator.imageValidated += new ImageValidator.ImageValidatedEvent(motionSensor.ImageCreatedAsync);//subscribe to events from the validator

            imageExtractor.Run();

        }
        public void Run(string captureKey)
        {
            //set up the extractor
            string uri = "http://*****:*****@"F:\temp\MotionSensor\2.1\movement\info.txt";
            motionSensor.motionDetected += new MotionSensor_2.MotionDetected(MotionDetected);

            //create the validator
            ImageValidator imageValidator = new ImageValidator();

            imageValidator.ListenForImages(imageExtractor);
            imageValidator.imageValidated += new ImageValidator.ImageValidatedEvent(motionSensor.ImageCreatedAsync);//subscribe to events from the validator

            imageExtractor.Run();
        }