Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="processingEngine"></param>
        /// <param name="dataWidth">Largeur de la fenêtre de données dans laquelle se trouve les blobs</param>
        /// <param name="dataHeight">Hauteur de la fenêtre de données dans laquelle se trouve les blobs</param>
        public KinectBlobsMatcher(ImageProcessingEngine processingEngine, int dataWidth,int dataHeight)
        {
            if (processingEngine == null)
                throw new ArgumentNullException("processingEngine");

            ProcessingEngine = processingEngine;

            if (ProcessingEngine.MaxMainBlobsCount <= 1)
                throw new ArgumentOutOfRangeException("processingEngine.MaxMainBlobsCount <= 1");

            BlobsTracker = new ImageProcessing.BlobsTracker();

            DataWidth = dataWidth;
            DataHeight = dataHeight;

            LeftHandBlob = new BlobParametersRecord();
            LeftHandBlob.CursorPosition = idealLeftHandPosition;

            RightHandBlob = new BlobParametersRecord();
            RightHandBlob.CursorPosition = idealRightHandPosition;

            scoringBlobs = new BlobParametersRecord[ProcessingEngine.MaxMainBlobsCount];

            for (int i = 0; i < scoringBlobs.Length; i++)
                scoringBlobs[i] = new BlobParametersRecord();

            LeftHandBlob.CursorPosition = idealLeftHandPosition;
            RightHandBlob.CursorPosition = idealRightHandPosition;
        }
Example #2
0
        /// <summary>
        /// When implemented in a derived class, executes when a Stop command is sent to the service by the Service Control Manager (SCM). Specifies actions to take when a service stops running.
        /// </summary>
        protected override void OnStop()
        {
            if (collector != null)
            {
                collector.Dispose();
                collector = null;
            }

            if (monitor != null)
            {
                monitor.Dispose();
                monitor = null;
            }

            EmailConverter.WaitOnComplete();
            ImageProcessingEngine.Complete();

            ConfigLogger.Instance.LogInfo(String.Format("{0} Stopped.", GetServiceName()));
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Graphics gr = Graphics.FromImage(ImageBox.Image);
            //using (Pen pen = new Pen(Color.Green, 2))
            //{
            //    gr.Draw
            //}
            isGrey = false;
            var   fileContent = string.Empty;
            var   filePath    = string.Empty;
            Image image;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter           = "BMP files (*.bmp)|*.bmp|PNG files (*.png)|*.png|JPG files (*.jpg)|*.jpg|JPEG files (*.jpeg)|*.jpeg|GIF files (*.gif)|*.gif";
                openFileDialog.FilterIndex      = 0;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path
                    filePath = openFileDialog.FileName;
                    var fileStream = openFileDialog.OpenFile();
                    ImageBox.ImageLocation = filePath;
                    //Dilation added using emguCV
                    imageEmgu     = new Image <Bgr, byte>(filePath);
                    filePathInner = filePath;

                    ImageBox.SizeMode     = PictureBoxSizeMode.StretchImage;
                    imageProcessingEngine = new ImageProcessingEngine(fileStream);
                    imageProcessingEngine.generateHistogram();
                    ImagePostBox.Image = null;

                    //  ImageBox.Paint +=
                }
            }
        }
Example #4
0
        public KinectProvider(IInputListener listener)
        {
            if (listener == null)
                throw new ArgumentNullException("listener");

            Listener = listener;
            Enabled = true;
            Available = true;

            try
            {
                nui = new Runtime();

#if(RETRHOW_RUNTIME_EXCEPTION)
                try
                {
                    nui.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking);
                }
                catch (InvalidOperationException)
                {
                    throw new InvalidOperationException("Runtime initialization failed. Please make sure Kinect device is plugged in.");
                }


                try
                {
                    nui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);
                }
                catch (InvalidOperationException)
                {
                    throw new InvalidOperationException("Failed to open stream. Please make sure to specify a supported image type and resolution.");
                }
#else
                nui.Initialize(RuntimeOptions.UseDepthAndPlayerIndex);// | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);

                nui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);
#endif


                nui.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nui_DepthFrameReady);
                nui.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady);

                leftHandProvider = new KinectPositionProvider("left", this);
                rightHandProvider = new KinectPositionProvider("right", this);

                providers = new KinectPositionProvider[] { rightHandProvider, leftHandProvider };
            }
            catch
            {
                Available = false;
            }

            if (Available)
            {
                try
                {
                    ImageProcessingEngine = new ImageProcessingEngine(320, 240, 4);
                    KinectBlobsMatcher = new KinectBlobsMatcher(ImageProcessingEngine, 320 >> 1, 240 >> 1);
                }
                catch
                {
                    KinectBlobsMatcher = null;
                    ImageProcessingEngine = null;
                    Available = false;
                }
            }
        }