コード例 #1
0
        public void MotionSensor_2b_threshold()
        {
            MotionSensor_2b motion = new MotionSensor_2b();

            motion.settings = new MotionSensorSettings();
            motion.settings.LoadDefaults();

            motion.ControlImageNumber = 10;

            foreach (var file in Directory.EnumerateFiles(@"d:\bsc\project\TestImages"))
            {
                ByteWrapper wrapper = ImageConvert.ReturnByteWrapper(file);
                motion.ImageCreatedAsync(wrapper, EventArgs.Empty);
                Thread.Sleep(250);
            }
            Assert.IsNotNull(motion.ThresholdImage);

            for (int i = 0; i < motion.ThresholdImage.Columns.Count; i++)
            {
                for (int n = 0; n < motion.ThresholdImage.Columns[i].grids.Count; n++)
                {
                    Assert.IsTrue(motion.ThresholdImage.Columns[i].grids[n].threshold != 0);
                }
            }
        }//MotionSensor_2b_threshold
コード例 #2
0
        public void Run(string captureKey)
        {
            //set up the extractor
            string uri = "http://localhost:9000/api/jpeg/0/" + captureKey;

            ImageExtractor imageExtractor = new ImageExtractor(uri, "root", "root");

            //create the motion sensor, and listen for images
            MotionSensor_2b motionSensor = new MotionSensor_2b();

            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();
        }
コード例 #3
0
        public void MotionSensor2b()
        {
            try
            {
                List <int> dimensions = ReturnDimensions();
                Stopwatch  sw         = new Stopwatch();
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"f:\temp\runtime\motion2b_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;


                            MotionSensor_2b motion = new MotionSensor_2b();
                            motion.CreateDummyThreshold(4, 4);
                            sw.Restart();
                            motion.ThresholdSet         = true;
                            motion.settings.searchWidth = dimensions[i];
                            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);
            }
        }